1 | /*
|
---|
2 | * pframeproc.cpp: window procedure for WPS folder which
|
---|
3 | * handles our private frame controls
|
---|
4 | *
|
---|
5 | * (C) Chris Wohlgenuth 1999
|
---|
6 | */
|
---|
7 | /*
|
---|
8 | * This program is free software; you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU General Public License as published by
|
---|
10 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
11 | * any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public License
|
---|
19 | * along with this program; see the file COPYING. If not, write to
|
---|
20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
21 | */
|
---|
22 | #include "progfolder.h"
|
---|
23 | #include "progfolder.hh"
|
---|
24 | #include <stdio.h>
|
---|
25 |
|
---|
26 | /**************************************************************/
|
---|
27 | /* */
|
---|
28 | /* New frame window procedure which handles all the stuff */
|
---|
29 | /* related to our private frame controls. */
|
---|
30 | /* It calls member functions of CWProgFolder to size and */
|
---|
31 | /* position our frame controls. */
|
---|
32 | /* */
|
---|
33 | /**************************************************************/
|
---|
34 | MRESULT EXPENTRY folderFrameProcedure(HWND hwnd,ULONG msg, MPARAM mp1,MPARAM mp2)
|
---|
35 | {
|
---|
36 | MRESULT mr;
|
---|
37 | PSWP pswp, pswpClient=0, pswpFrame=0;
|
---|
38 | PFNWP orgFrameProc;
|
---|
39 |
|
---|
40 | switch(msg)
|
---|
41 | {
|
---|
42 |
|
---|
43 |
|
---|
44 | case WM_CALCVALIDRECTS:
|
---|
45 | {
|
---|
46 | MRESULT mr;
|
---|
47 | PRECTL pRectl, pRectlNew;
|
---|
48 | PSWP pswp;
|
---|
49 | POINTL ptl;
|
---|
50 | HWND hwndClient;
|
---|
51 | FRAMECTRLDATA * fctrlData;
|
---|
52 | SWP swp;
|
---|
53 |
|
---|
54 | pswp=(PSWP)mp2;
|
---|
55 | if(pswp->fl&SWP_SIZE) {
|
---|
56 | pRectl=(PRECTL)mp1;
|
---|
57 | pRectlNew=pRectl;
|
---|
58 | pRectlNew++;
|
---|
59 |
|
---|
60 |
|
---|
61 | if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
|
---|
62 | pRectl->yBottom+=ptl.y;
|
---|
63 | pRectl->yTop-=ptl.y;
|
---|
64 | pRectl->xRight-=ptl.x;
|
---|
65 | pRectl->xLeft+=ptl.x;
|
---|
66 | }else {
|
---|
67 | /* Ok, then use some defaults. Better than nothing... */
|
---|
68 | pRectl->yBottom+=4;
|
---|
69 | pRectl->yTop-=4;
|
---|
70 | pRectl->xRight-=4;
|
---|
71 | pRectl->xLeft+=4;
|
---|
72 | }
|
---|
73 | *pRectlNew=*pRectl;
|
---|
74 | return (MRESULT)0;
|
---|
75 | }
|
---|
76 |
|
---|
77 | }
|
---|
78 | #if 0
|
---|
79 | case WM_CALCVALIDRECTS:
|
---|
80 | {
|
---|
81 | PRECTL pRectl, pRectlNew;
|
---|
82 | PSWP pswp;
|
---|
83 | POINTL ptl;
|
---|
84 |
|
---|
85 | pswp=(PSWP)mp2;
|
---|
86 | if(pswp->fl&SWP_SIZE) {
|
---|
87 | pRectl=(PRECTL)mp1;
|
---|
88 | pRectlNew=pRectl;
|
---|
89 | pRectlNew++;
|
---|
90 |
|
---|
91 | if(pRectlNew->yBottom!=pRectl->yBottom) {
|
---|
92 | if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
|
---|
93 | pRectlNew->xLeft+=ptl.x;
|
---|
94 | pRectl->xLeft+=ptl.x;
|
---|
95 | pRectlNew->xRight-=ptl.x;
|
---|
96 | pRectl->xRight-=ptl.x;
|
---|
97 | pRectl->yBottom+=ptl.y;
|
---|
98 | }else {
|
---|
99 | /* Ok, then use some defaults. Better than nothing... */
|
---|
100 | pRectlNew->xLeft+=4;
|
---|
101 | pRectl->xLeft+=4;
|
---|
102 | pRectlNew->xRight-=4;
|
---|
103 | pRectl->xRight-=4;
|
---|
104 | pRectl->yBottom+=4;
|
---|
105 | }
|
---|
106 | pRectlNew->yBottom=pRectl->yBottom;
|
---|
107 | return (MRESULT)0;
|
---|
108 | }
|
---|
109 | #if 0
|
---|
110 | else if(pRectlNew->yTop!=pRectl->yTop) {
|
---|
111 | if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
|
---|
112 | pRectl->yBottom+=ptl.y;
|
---|
113 | pRectl->yTop-=ptl.y;
|
---|
114 | pRectl->xRight-=ptl.x;
|
---|
115 | pRectl->xLeft+=ptl.x;
|
---|
116 | }else {
|
---|
117 | /* Ok, then use some defaults. Better than nothing... */
|
---|
118 | pRectl->yBottom+=4;
|
---|
119 | pRectl->yTop-=4;
|
---|
120 | pRectl->xRight-=4;
|
---|
121 | pRectl->xLeft+=4;
|
---|
122 | }
|
---|
123 | *pRectlNew=*pRectl;
|
---|
124 | return (MRESULT)0;
|
---|
125 | }
|
---|
126 | }
|
---|
127 | #endif
|
---|
128 | else if(pRectlNew->xLeft!=pRectl->xLeft || pRectlNew->xRight!=pRectl->xRight) {
|
---|
129 | /* Make sure the border will be redrawn */
|
---|
130 | if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
|
---|
131 | pRectl->yBottom+=ptl.y;
|
---|
132 | pRectl->yTop-=ptl.y;
|
---|
133 | pRectl->xRight-=ptl.x;
|
---|
134 | pRectl->xLeft+=ptl.x;
|
---|
135 | }else {
|
---|
136 | /* Ok, then use some defaults. Better than nothing... */
|
---|
137 | pRectl->yBottom+=4;
|
---|
138 | pRectl->yTop-=4;
|
---|
139 | pRectl->xRight-=4;
|
---|
140 | pRectl->xLeft+=4;
|
---|
141 | }
|
---|
142 | *pRectlNew=*pRectl;
|
---|
143 | return (MRESULT)0;
|
---|
144 | }
|
---|
145 | return (MRESULT)0;
|
---|
146 | }
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | case WM_CALCFRAMERECT:
|
---|
150 |
|
---|
151 | /* Get the original frame procedure from the window words of the invisible child window */
|
---|
152 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
153 | if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured! The original frame proc is lost */
|
---|
154 |
|
---|
155 | mr=(*orgFrameProc)(hwnd,msg,mp1,mp2);
|
---|
156 |
|
---|
157 | // mp2:
|
---|
158 | //
|
---|
159 | // TRUE: Frame rectangle provided, calculate client
|
---|
160 | // FALSE: Client area rectangle provided, calculate frame
|
---|
161 |
|
---|
162 | /* Calculate new size.
|
---|
163 | This is done in a member function of our folder class.
|
---|
164 | We get the pointer to our folder object by querying the
|
---|
165 | window ptr. of the hidden child window. */
|
---|
166 | ((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
|
---|
167 | ->cwCalculateClient(hwnd, (PRECTL)mp1, SHORT1FROMMP( mp2));
|
---|
168 |
|
---|
169 | return mr;
|
---|
170 |
|
---|
171 | case WM_FORMATFRAME:
|
---|
172 | SHORT countSwp;
|
---|
173 | SWP *sav;
|
---|
174 |
|
---|
175 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
176 | if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
177 | /* Query the count of standard frame controls */
|
---|
178 | countSwp = (int) (*orgFrameProc)(hwnd, msg, mp1, mp2);
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * Reformat the frame to move the client
|
---|
182 | * over and make room for the framecontrols.
|
---|
183 | * Add the new controls to the array of
|
---|
184 | * frame controls.
|
---|
185 | * After doing so add our own framecontrols
|
---|
186 | * to the total number of framecontrols.
|
---|
187 | * This is done in the member function of the class.
|
---|
188 | */
|
---|
189 | return MRFROMSHORT(countSwp+((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),
|
---|
190 | 0))
|
---|
191 | ->cwFormatFrame(hwnd, countSwp,(PSWP)mp1));//Our Frame(s) added
|
---|
192 | case WM_QUERYFRAMECTLCOUNT:
|
---|
193 | /* The system asks for the total count of framecontrols.
|
---|
194 | First we ask the old frame procedure for the number of standard
|
---|
195 | controls. After that we add our controls to the count. */
|
---|
196 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
197 | if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
198 |
|
---|
199 | return MRFROMSHORT((ULONG)((*orgFrameProc)(hwnd,msg,mp1,mp2))
|
---|
200 | +((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
|
---|
201 | ->cwNumAdditionalFrameControls(hwnd));//Our Frame(s) added
|
---|
202 |
|
---|
203 | case WM_CLOSE:
|
---|
204 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
205 | if(!orgFrameProc)
|
---|
206 | return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
207 | /* Call the cwClose() method */
|
---|
208 | if(((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
|
---|
209 | ->cwClose(hwnd))
|
---|
210 | return (MRESULT)(*orgFrameProc)(hwnd,msg,mp1,mp2);
|
---|
211 | return (MRESULT) 0;
|
---|
212 | default:
|
---|
213 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
214 | if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
215 |
|
---|
216 | return (*orgFrameProc)(hwnd,msg,mp1,mp2);
|
---|
217 | }
|
---|
218 | orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
|
---|
219 | if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
220 |
|
---|
221 | return (*orgFrameProc)(hwnd,msg,mp1,mp2);
|
---|
222 | return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 |
|
---|
227 |
|
---|