63ca2213bdf9f76c1ba420a50018324c0795dd55
[openafs.git] / src / WINNT / afsapplib / resize.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * I've FINALLY stuck this in a separate file; I must have twenty different
12  * implementations floating around these days.  Anyway, here's my generic
13  * let-your-dialog-resize-and-still-look-cool code; an example of how to use
14  * it:
15  *
16  * if dialog looks like:
17  *
18  * +-----------------------------------------------------+
19  * |                                                     |
20  * | [ TXT_HEADER (can resize horizontally, but should ] |
21  * | [ TXT_HEADER  retain same vertical size.  The     ] |
22  * | [_TXT_HEADER__upper-left corner should not move)__] |
23  * |                                                     |
24  * | [ ID_LIST_BOX (should resize horizontally and     ] |
25  * | [ ID_LIST_BOX  vertically to match changes in     ] |
26  * | [_ID_LIST_BOX__parent window; UL corner no move)__] |
27  * |                                                     |
28  * | (upper-left moves; don't resize ->)   [OK] [CANCEL] |
29  * |                                                     |
30  * +-----------------------------------------------------+
31  *
32  * then define something like this as a global variable:
33  *
34  *    rwWindowData awdDialog[] = {
35  *       { TXT_HEADER,    raSizeX           },
36  *       { ID_LIST_BOX,   raSizeX | raSizeY },
37  *       { IDOK,          raMoveX | raMoveY },
38  *       { IDCANCEL,      raMoveX | raMoveY },
39  *       { idDEFAULT,     raLeaveAlone },
40  *       { idENDLIST,     0 }
41  *    };
42  *
43  * in WM_INITDIALOG:
44  *
45  *    RECT rFromLastSession = GuessWhereWindowShouldGo();
46  *    ResizeWindow (hDlg, awdDialog, rwaMoveToHere, &rFromLastSession);
47  *
48  * in WM_SIZE:
49  *
50  *    // if (lp==0), we're minimizing--don't call ResizeWindow().
51  *    //
52  *    if (lp != 0)
53  *       ResizeWindow (hDlg, awdDialog, rwaFixupGuts);
54  *
55  * if you want to, say, add a status bar (which mucks with the client size
56  * of the window):
57  *
58  *    AddStatusBar (hDlg, ...);
59  *    ResizeWindow (hDlg, awdDialog, rwaJustResync);
60  *
61  * if you want to, say, add a tool bar (which doesn't much with the client
62  * location but should):
63  *
64  *    AddToolbar (hDlg, ID_TOOLBAR, ...);
65  *    GetWindowRect (GetDlgItem (hDlg, ID_TOOLBAR), &rToolBar);
66  *    ResizeWindow (hDlg, awdDialog, rwaNewClientArea, &rToolBar);
67  *
68  *
69  */
70
71 #ifndef RESIZE_H
72 #define RESIZE_H
73
74 #include <windows.h>
75
76 #ifndef EXPORTED
77 #define EXPORTED
78 #endif
79
80
81 /*
82  * DEFINITIONS ________________________________________________________________
83  *
84  */
85
86          // rwAction types:
87          //
88 typedef enum
89    {
90    rwaMoveToHere,       // resize window to {pr}, then fix guts
91    rwaFixupGuts,        // reposition guts to match window size
92    rwaJustResync,       // recognize new size but don't fix guts
93    rwaNewClientArea     // pretend the client area changed
94    } rwAction;
95
96          // ra flags:
97          //
98 #define raLeaveAlone   0x0000   // don't modify window during resize
99
100 #define raSizeX        0x0001   // increase width if resizing X+
101 #define raSizeY        0x0002   // increase height if resizing Y+
102 #define raMoveX        0x0004   // move right if resizing X+
103 #define raMoveY        0x0008   // move down if resizing Y+
104
105 #define raSizeXB       0x0010   // decrease width if resizing X+
106 #define raSizeYB       0x0020   // decrease height if resizing Y+
107 #define raMoveXB       0x0040   // move left if resizing X+
108 #define raMoveYB       0x0080   // move up if resizing Y+
109
110 #define raSizeXC       0x0100   // increase width by X/2 if resizing X+
111 #define raSizeYC       0x0200   // increase height by Y/2 if resizing Y+
112 #define raMoveXC       0x0400   // move right by X/2 if resizing X+
113 #define raMoveYC       0x0800   // move down by Y/2 if resizing Y+
114
115 #define raRepaint      0x1000   // force repaint whenever resized
116 #define raNotify       0x2000   // notify window with WM_SIZE afterwards
117
118          // rwWindowData types:
119          //
120 typedef struct
121    {
122    int     id;  // child ID (-1=end list, 0=default)
123    DWORD   ra;  // what to do with this child window
124    DWORD   cMinimum;    // minimum size (0=no limit, LO=x,HI=y)
125    DWORD   cMaximum;    // maximum size (0=no limit, LO=x,HI=y)
126    } rwWindowData;
127
128 #define idDEFAULT  (-2)
129 #define idENDLIST  (-3)
130
131
132 /*
133  * PROTOTYPES _________________________________________________________________
134  *
135  */
136
137 EXPORTED HWND CreateSplitter (HWND, int, int, int, LONG *, rwWindowData *, BOOL);
138 EXPORTED void DeleteSplitter (HWND, int);
139
140 EXPORTED void ResizeWindow (HWND, rwWindowData *, rwAction, RECT * = NULL);
141
142 EXPORTED void GetRectInParent (HWND hWnd, RECT *pr);
143
144 #endif
145