1 | #define INCL_DOSERRORS
|
---|
2 | #define INCL_DOSMODULEMGR
|
---|
3 | #define INCL_DOSPROCESS
|
---|
4 | #define INCL_DOSSEMAPHORES
|
---|
5 | #define INCL_DOSMEMMGR
|
---|
6 | #define INCL_GPI
|
---|
7 | #define INCL_GPICONTROL
|
---|
8 | #define INCL_GPILCIDS
|
---|
9 | #define INCL_GPIMETAFILES
|
---|
10 | #define INCL_GPIPRIMITIVES
|
---|
11 | #define INCL_GPIREGIONS
|
---|
12 | #define INCL_PM
|
---|
13 | #define INCL_WIN
|
---|
14 | #define INCL_WINDIALOGS
|
---|
15 | #define INCL_WINERRORS
|
---|
16 | #define INCL_WINFRAMEMGR
|
---|
17 | #define INCL_WINHELP
|
---|
18 | #define INCL_WINMENUS
|
---|
19 | #define INCL_WINMESSAGEMGR
|
---|
20 | #define INCL_WINMLE
|
---|
21 | #define INCL_WINPOINTERS
|
---|
22 | #define INCL_WINSTDDLGS
|
---|
23 | #define INCL_WINSTDFILE
|
---|
24 | #define INCL_WINSTDSLIDER
|
---|
25 | #define INCL_WINSWITCHLIST
|
---|
26 | #define INCL_WINSYS
|
---|
27 | #define INCL_WINTIMER
|
---|
28 | #define INCL_WINWINDOWMGR
|
---|
29 | #define INCL_REXXSAA
|
---|
30 |
|
---|
31 | #include <os2.h>
|
---|
32 | #include "framecontrol.h"
|
---|
33 |
|
---|
34 | FRAMECTRLDATA fcd;
|
---|
35 |
|
---|
36 | PFNWP g_pfnwpOrgFrameProc=NULLHANDLE;
|
---|
37 |
|
---|
38 | static USHORT cwNumAdditionalFrameControls(HWND hwndFolder)
|
---|
39 | {
|
---|
40 | USHORT rc;
|
---|
41 | FRAMECTRLDATA * fctrlData;
|
---|
42 |
|
---|
43 | fctrlData=&fcd;
|
---|
44 |
|
---|
45 | if(!fctrlData)
|
---|
46 | return 0;
|
---|
47 |
|
---|
48 | rc=0;
|
---|
49 |
|
---|
50 | if(fctrlData->bLeft)rc++;
|
---|
51 | if(fctrlData->bRight)rc++;
|
---|
52 | if(fctrlData->bTop)rc++;
|
---|
53 | if(fctrlData->bBottom)rc++;
|
---|
54 |
|
---|
55 | return rc;
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | /**************************************************************/
|
---|
60 | /* */
|
---|
61 | /* This function adjusts the size and position of the client. */
|
---|
62 | /* It is called from the frame window procedure */
|
---|
63 | /* */
|
---|
64 | /**************************************************************/
|
---|
65 | static BOOL cwCalculateClient(HWND hwndFolder, PRECTL pRectl, BOOL which)
|
---|
66 | {
|
---|
67 | FRAMECTRLDATA * fctrlData;
|
---|
68 |
|
---|
69 | // which:
|
---|
70 | // TRUE: Frame rectangle provided, calculate client
|
---|
71 | // FALSE: Client area rectangle provided, calculate frame
|
---|
72 |
|
---|
73 | /* Get our control data */
|
---|
74 | fctrlData=&fcd;
|
---|
75 | if(!fctrlData)
|
---|
76 | return FALSE;
|
---|
77 |
|
---|
78 | if (SHORT1FROMMP(which))
|
---|
79 | // TRUE: Frame rectangle provided, calculate client
|
---|
80 | // FALSE: Client area rectangle provided, calculate frame
|
---|
81 | {
|
---|
82 | // TRUE: calculate the rectl of the client;
|
---|
83 | // call default window procedure to subtract child frame
|
---|
84 | // controls from the rectangle's height
|
---|
85 | LONG lClientHeight;
|
---|
86 | LONG lNewControls;
|
---|
87 |
|
---|
88 | lNewControls=0;
|
---|
89 | if(fctrlData->bTop)
|
---|
90 | lNewControls=fctrlData->sizelTopFrame.cy;
|
---|
91 | if(fctrlData->bBottom)
|
---|
92 | lNewControls+=fctrlData->sizelBottomFrame.cy;
|
---|
93 |
|
---|
94 | lClientHeight = pRectl->yTop - pRectl->yBottom;
|
---|
95 | if ( lNewControls > lClientHeight )
|
---|
96 | {
|
---|
97 | if(fctrlData->bBottom || fctrlData->bTop)
|
---|
98 | // extension is taller than client, so set client height to 0
|
---|
99 | pRectl->yTop = pRectl->yBottom;
|
---|
100 | }
|
---|
101 | else
|
---|
102 | {
|
---|
103 | // set the origin of the client and shrink it based upon the
|
---|
104 | // frame control's height
|
---|
105 | if(fctrlData->bBottom) {
|
---|
106 | pRectl->yBottom +=fctrlData->sizelBottomFrame.cy;
|
---|
107 | //pRectl->yTop -= fctrlData->sizelBottomFrame.cy;
|
---|
108 | }
|
---|
109 | if(fctrlData->bTop) {
|
---|
110 | pRectl->yTop -=fctrlData->sizelTopFrame.cy;
|
---|
111 | //pRectl->yBottom +=fctrlData->sizelTopFrame.cy;
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 | else
|
---|
116 | {
|
---|
117 | // FALSE: calculate the rectl of the frame;
|
---|
118 | // call default window procedure to subtract child frame
|
---|
119 | // controls from the rectangle's height;
|
---|
120 | // set the origin of the frame and increase it based upon the
|
---|
121 | // static text control's height
|
---|
122 |
|
---|
123 | return TRUE;
|
---|
124 |
|
---|
125 | if(fctrlData->bBottom) {
|
---|
126 | pRectl->yBottom +=fctrlData->sizelBottomFrame.cy;
|
---|
127 | // pRectl->yTop -= fctrlData->sizelBottomFrame.cy;
|
---|
128 | }
|
---|
129 | if(fctrlData->bTop)
|
---|
130 | pRectl->yTop -=fctrlData->sizelTopFrame.cy;
|
---|
131 |
|
---|
132 | if(fctrlData->bLeft) {
|
---|
133 | pRectl->xLeft +=fctrlData->sizelLeftFrame.cx;
|
---|
134 | }
|
---|
135 | if(fctrlData->bRight)
|
---|
136 | pRectl->xRight -=fctrlData->sizelRightFrame.cx;
|
---|
137 |
|
---|
138 | }
|
---|
139 | return TRUE;/* Everything's ok */
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | /**************************************************************/
|
---|
144 | /* */
|
---|
145 |
|
---|
146 | /* */
|
---|
147 | /**************************************************************/
|
---|
148 | static ULONG cwFormatFrame(HWND hwndFolder, USHORT countSWP,PSWP pswp)
|
---|
149 | {
|
---|
150 | /* countSWP: number of standard framecontrols
|
---|
151 | pswp: Array of SWP describing the framecontrols.
|
---|
152 | Since we added the number of our controls to the
|
---|
153 | standard controls in the framecontrol there is
|
---|
154 | space for the new controls.
|
---|
155 | */
|
---|
156 | ULONG rc;
|
---|
157 | PSWP pswpClient=0, pswpFrameCtl=0;
|
---|
158 | int iCount;
|
---|
159 | FRAMECTRLDATA * fctrlData;
|
---|
160 | int a;
|
---|
161 | CNRINFO CnrInfo;
|
---|
162 | HWND hwndClient;
|
---|
163 |
|
---|
164 | /* The data of our framecontrols is stored in a structure.
|
---|
165 | Get a pointer from the window words. */
|
---|
166 | fctrlData=&fcd;
|
---|
167 | if(!fctrlData)
|
---|
168 | return 0;
|
---|
169 |
|
---|
170 | iCount=0;
|
---|
171 | rc=0;
|
---|
172 |
|
---|
173 | for (a = 0; a < countSWP; a++)
|
---|
174 | {
|
---|
175 | /* Find the client window */
|
---|
176 | if ( WinQueryWindowUShort( pswp[a].hwnd, QWS_ID ) == 0x8008 ) // FID_CLIENT
|
---|
177 | {
|
---|
178 | pswpClient=&pswp[a];
|
---|
179 |
|
---|
180 | /* Framecontrol at the top */
|
---|
181 | if(fctrlData->bTop){
|
---|
182 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
183 |
|
---|
184 | /* Adjust client and insert the new control into the array of SWPs */
|
---|
185 |
|
---|
186 | /* Decrease the height of the client to have place for the new control */
|
---|
187 | pswp[a].cy -= fctrlData->sizelTopFrame.cy;
|
---|
188 |
|
---|
189 | /* Insert the HWND of the new control into the structure */
|
---|
190 | pswpFrameCtl->hwnd=fctrlData->hwndCtlTop;
|
---|
191 | /* The x-position is the same as that of the client */
|
---|
192 | pswpFrameCtl->x = pswpClient->x;
|
---|
193 | /* The control is placed above the client */
|
---|
194 | pswpFrameCtl->y = pswpClient->y + pswpClient->cy;
|
---|
195 | /* The control is as wide as the client */
|
---|
196 | pswpFrameCtl->cx = pswpClient->cx;
|
---|
197 | /* Insert the height of the control */
|
---|
198 | pswpFrameCtl->cy = fctrlData->sizelTopFrame.cy;
|
---|
199 | /* Place the control on top of all windows */
|
---|
200 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
201 | /* Insert necessary flags */
|
---|
202 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
203 |
|
---|
204 | /* Adjust position if flags are set. It's possible to place
|
---|
205 | the control above the controls on the left and right or let these controls
|
---|
206 | cover the full height of the folder. */
|
---|
207 | if(fctrlData->bLeft){
|
---|
208 | /* There is a frame control on the left side */
|
---|
209 | if(!(fctrlData->ulFlagsLeft & FCTL_POSBELOW)) {
|
---|
210 | pswpFrameCtl->x += fctrlData->sizelLeftFrame.cx;
|
---|
211 | pswpFrameCtl->cx -= fctrlData->sizelLeftFrame.cx;
|
---|
212 | }
|
---|
213 | }
|
---|
214 | /* framecontrol on the right side */
|
---|
215 | if(!(fctrlData->ulFlagsRight & FCTL_POSBELOW) && fctrlData->bRight)
|
---|
216 | pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx;
|
---|
217 |
|
---|
218 | if(!fctrlData->bCnrAdjusted) {
|
---|
219 | hwndClient=pswpClient->hwnd;
|
---|
220 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
221 | if(fctrlData->bBottom)
|
---|
222 | CnrInfo.ptlOrigin.y-=fctrlData->sizelBottomFrame.cy;
|
---|
223 | if(fctrlData->bTop)
|
---|
224 | CnrInfo.ptlOrigin.y-=fctrlData->sizelTopFrame.cy;
|
---|
225 | //CnrInfo.ptlOrigin.y+=0;
|
---|
226 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
227 | }
|
---|
228 | fctrlData->bCnrAdjusted=TRUE;
|
---|
229 | }
|
---|
230 | /* One new control added */
|
---|
231 | rc++;
|
---|
232 | }/* end of if(fctrlData->bTop) */
|
---|
233 |
|
---|
234 |
|
---|
235 | /* Bottom frame control */
|
---|
236 | if(fctrlData->bBottom){
|
---|
237 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
238 |
|
---|
239 | // HlpWriteToTrapLog("2 Client: x: %d y: %d\n", pswpClient->x, pswpClient->y);
|
---|
240 |
|
---|
241 | pswpClient->cy -= fctrlData->sizelBottomFrame.cy; /* Reduce height of client */
|
---|
242 |
|
---|
243 | pswpFrameCtl->hwnd=fctrlData->hwndCtlBottom;
|
---|
244 | pswpFrameCtl->x = pswpClient->x;
|
---|
245 | pswpFrameCtl->y = pswpClient->y;
|
---|
246 | pswpClient->y += fctrlData->sizelBottomFrame.cy;
|
---|
247 |
|
---|
248 | pswpFrameCtl->cx = pswpClient->cx;
|
---|
249 | pswpFrameCtl->cy = fctrlData->sizelBottomFrame.cy;
|
---|
250 |
|
---|
251 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
252 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
253 |
|
---|
254 | /* Adjust position if flags are set */
|
---|
255 | if(fctrlData->bLeft){
|
---|
256 | if((fctrlData->ulFlagsLeft & FCTL_POSABOVE)) {
|
---|
257 | pswpFrameCtl->cx +=fctrlData->sizelLeftFrame.cx;
|
---|
258 | pswpFrameCtl->x -= fctrlData->sizelLeftFrame.cx;
|
---|
259 | }
|
---|
260 | }
|
---|
261 | if(!(fctrlData->ulFlagsRight & FCTL_POSABOVE)&& fctrlData->bRight) {
|
---|
262 | pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx;
|
---|
263 | }
|
---|
264 | /* Adjust container view so items do not scroll out of view */
|
---|
265 | /* hwndClient=pswpClient->hwnd;
|
---|
266 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
267 | CnrInfo.ptlOrigin.y-=pswpFrameCtl->cy;
|
---|
268 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
269 | };*/
|
---|
270 |
|
---|
271 | if(!fctrlData->bCnrAdjusted) {
|
---|
272 | hwndClient=pswpClient->hwnd;
|
---|
273 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
274 | if(fctrlData->bBottom)
|
---|
275 | CnrInfo.ptlOrigin.y-=fctrlData->sizelBottomFrame.cy;
|
---|
276 | if(fctrlData->bTop)
|
---|
277 | CnrInfo.ptlOrigin.y-=fctrlData->sizelTopFrame.cy;
|
---|
278 | //CnrInfo.ptlOrigin.y+=0;
|
---|
279 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
280 | }
|
---|
281 | fctrlData->bCnrAdjusted=TRUE;
|
---|
282 | }
|
---|
283 |
|
---|
284 | rc++;
|
---|
285 | }/* end of if(fctrlData->bBottom) */
|
---|
286 | }
|
---|
287 | }
|
---|
288 | return rc;/* Return additional controls */
|
---|
289 | }
|
---|
290 |
|
---|
291 |
|
---|
292 | MRESULT EXPENTRY fnwpFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
293 | {
|
---|
294 | switch(msg)
|
---|
295 | {
|
---|
296 | case WM_CALCVALIDRECTS:
|
---|
297 | {
|
---|
298 | MRESULT mr;
|
---|
299 | PRECTL pRectl, pRectlNew;
|
---|
300 | PSWP pswp;
|
---|
301 | POINTL ptl;
|
---|
302 | HWND hwndClient;
|
---|
303 | SWP swp;
|
---|
304 |
|
---|
305 | pswp=(PSWP)mp2;
|
---|
306 | if(pswp->fl&SWP_SIZE) {
|
---|
307 | pRectl=(PRECTL)mp1;
|
---|
308 | pRectlNew=pRectl;
|
---|
309 | pRectlNew++;
|
---|
310 |
|
---|
311 | if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
|
---|
312 | pRectl->yBottom+=ptl.y;
|
---|
313 | pRectl->yTop-=ptl.y;
|
---|
314 | pRectl->xRight-=ptl.x;
|
---|
315 | pRectl->xLeft+=ptl.x;
|
---|
316 | }else {
|
---|
317 | /* Ok, then use some defaults. Better than nothing... */
|
---|
318 | pRectl->yBottom+=4;
|
---|
319 | pRectl->yTop-=4;
|
---|
320 | pRectl->xRight-=4;
|
---|
321 | pRectl->xLeft+=4;
|
---|
322 | }
|
---|
323 | *pRectlNew=*pRectl;
|
---|
324 | return (MRESULT)0;
|
---|
325 | }
|
---|
326 | }
|
---|
327 | case WM_QUERYFRAMECTLCOUNT:
|
---|
328 | /* The system asks for the total count of framecontrols.
|
---|
329 | First we ask the old frame procedure for the number of standard
|
---|
330 | controls. After that we add our controls to the count. */
|
---|
331 | if(!g_pfnwpOrgFrameProc)
|
---|
332 | return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured. Now we have a real problem... */
|
---|
333 |
|
---|
334 | return MRFROMSHORT(SHORT1FROMMR((*g_pfnwpOrgFrameProc)(hwnd,msg,mp1,mp2))
|
---|
335 | + cwNumAdditionalFrameControls(hwnd));
|
---|
336 |
|
---|
337 | case WM_CALCFRAMERECT:
|
---|
338 | {
|
---|
339 | MRESULT mr;
|
---|
340 |
|
---|
341 | if(!g_pfnwpOrgFrameProc)
|
---|
342 | return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured. Now we have a real problem... */
|
---|
343 |
|
---|
344 | mr=(*g_pfnwpOrgFrameProc)(hwnd,msg,mp1,mp2);
|
---|
345 |
|
---|
346 | // mp2:
|
---|
347 | //
|
---|
348 | // TRUE: Frame rectangle provided, calculate client
|
---|
349 | // FALSE: Client area rectangle provided, calculate frame
|
---|
350 |
|
---|
351 | /* Calculate new size.
|
---|
352 | This is done in a member function of our folder class.
|
---|
353 | We get the pointer to our folder object by querying the
|
---|
354 | window ptr. of the hidden child window. */
|
---|
355 | // ((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
|
---|
356 | // ->
|
---|
357 | cwCalculateClient(hwnd, (PRECTL)mp1, SHORT1FROMMP( mp2));
|
---|
358 |
|
---|
359 | return mr;
|
---|
360 | }
|
---|
361 |
|
---|
362 | case WM_FORMATFRAME:
|
---|
363 | {
|
---|
364 | SHORT countSwp;
|
---|
365 | SWP *sav;
|
---|
366 |
|
---|
367 | if(!g_pfnwpOrgFrameProc)
|
---|
368 | return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured. Now we have a real problem... */
|
---|
369 |
|
---|
370 | /* Query the count of standard frame controls */
|
---|
371 | countSwp = (int) (*g_pfnwpOrgFrameProc)(hwnd, msg, mp1, mp2);
|
---|
372 |
|
---|
373 | /*
|
---|
374 | * Reformat the frame to move the client
|
---|
375 | * over and make room for the framecontrols.
|
---|
376 | * Add the new controls to the array of
|
---|
377 | * frame controls.
|
---|
378 | * After doing so add our own framecontrols
|
---|
379 | * to the total number of framecontrols.
|
---|
380 | * This is done in the member function of the class.
|
---|
381 | */
|
---|
382 |
|
---|
383 | return MRFROMSHORT(countSwp+
|
---|
384 | cwFormatFrame(hwnd, countSwp,(PSWP)mp1));//Our Frame(s) added
|
---|
385 | }
|
---|
386 | case WM_DESTROY:
|
---|
387 | {
|
---|
388 | break;
|
---|
389 | }
|
---|
390 |
|
---|
391 | default:
|
---|
392 | break;
|
---|
393 | }
|
---|
394 | return (*g_pfnwpOrgFrameProc)(hwnd, msg, mp1, mp2);
|
---|
395 | }
|
---|