1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2001
|
---|
3 | */
|
---|
4 | /*
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
8 | * any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program; see the file COPYING. If not, write to
|
---|
17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #define INCL_WIN
|
---|
21 | #define INCL_GPILCIDS
|
---|
22 | #define INCL_GPIPRIMITIVES
|
---|
23 | #define INCL_GPIBITMAPS
|
---|
24 |
|
---|
25 |
|
---|
26 | #include "mediafolder.hh"
|
---|
27 | #include "launchpad.hh"
|
---|
28 |
|
---|
29 | #include <os2.h>
|
---|
30 | #include "stdio.h"
|
---|
31 | #include "stdlib.h"
|
---|
32 |
|
---|
33 | #include "sys_funcs.h"
|
---|
34 |
|
---|
35 | extern HWND hwndShadow;// The handle of the help window
|
---|
36 | extern PFNWP oldProc; //place for original button-procedure
|
---|
37 | extern HWND hwndBubbleWindow;// The handle of the help window
|
---|
38 | #define WM_NEWBUBBLE WM_USER+100 //Use ATOM later
|
---|
39 | #define xVal 12 //x-distance of Bubble
|
---|
40 | #define yVal 8 //y-distance of Bubble
|
---|
41 | extern char chrTBFlyFontName[CCHMAXPATH];/* Font for toolbar fly over help */
|
---|
42 | extern RGB rgbTBFlyForeground;
|
---|
43 | extern RGB rgbTBFlyBackground;
|
---|
44 | extern BOOL bTBFlyOverEnabled;
|
---|
45 | extern int iTBFlyOverDelay;
|
---|
46 |
|
---|
47 |
|
---|
48 | #define xButtonDelta 2
|
---|
49 | #define xButtonOffset 6
|
---|
50 |
|
---|
51 | PFNWP pfnwpOldLPProc;
|
---|
52 | LPList* lplAllLPads=NULL;
|
---|
53 |
|
---|
54 | extern PFNWP oldButtonProc2; //place for original button-procedure
|
---|
55 |
|
---|
56 | MRESULT EXPENTRY newButtonProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 );
|
---|
57 | MRESULT EXPENTRY shadowProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 );
|
---|
58 |
|
---|
59 | /******************************************************************************/
|
---|
60 | /* New button procedure which handles the context menu stuff for the objects */
|
---|
61 | /* The fly over help is managed by the standard button replacement proc. */
|
---|
62 | /******************************************************************************/
|
---|
63 | static MRESULT EXPENTRY newLaunchPadButtonProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
|
---|
64 | {
|
---|
65 | POINTL ptl;
|
---|
66 | HWND hwndMenu;
|
---|
67 | WPObject * wpObject;
|
---|
68 | LPObject* lpo;
|
---|
69 | PDRAGINFO pDragInfo;
|
---|
70 | static BOOL bDrawn=FALSE;
|
---|
71 | static DRAGITEM DragItem;
|
---|
72 | static DRAGIMAGE DragImage;
|
---|
73 | static DRAGINFO *DragInfo;
|
---|
74 |
|
---|
75 | switch (msg)
|
---|
76 | {
|
---|
77 | #if 0
|
---|
78 | case WM_BEGINDRAG:
|
---|
79 | if(SHORT1FROMMP(mp2)||1) {
|
---|
80 | // DosBeep(5000,130);
|
---|
81 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
82 | if(lpo) {
|
---|
83 | wpObject=lpo->wpObject;
|
---|
84 | if(somIsObj(wpObject)) {
|
---|
85 | #if 0
|
---|
86 | DragItem.hwndItem=hwnd;
|
---|
87 | DragItem.ulItemID=(ULONG)wpObject;
|
---|
88 | DragItem.hstrType=DrgAddStrHandle("DRT_UNKNOWN");
|
---|
89 | DragItem.hstrRMF=DrgAddStrHandle("DRM_OBJECT");
|
---|
90 | DragItem.hstrContainerName=DrgAddStrHandle("E:\\CD-Brenner\\ADC_050\\!AUDIOCD_TOOLBAR!");
|
---|
91 | DragItem.hstrSourceName=DrgAddStrHandle("E:\\CD-Brenner\\ADC_050\\");
|
---|
92 | #endif
|
---|
93 | wpObject->wpFormatDragItem(&DragItem);
|
---|
94 | // DragItem.fsSupportedOps=DO_LINKABLE;
|
---|
95 | DragInfo=DrgAllocDraginfo(1);
|
---|
96 |
|
---|
97 | DrgSetDragitem(DragInfo, &DragItem,(ULONG)sizeof(DragItem),0);
|
---|
98 | memset(&DragImage, 0, sizeof(DragImage));
|
---|
99 | DragImage.cb=sizeof(DragImage);
|
---|
100 | DragImage.fl=DRG_ICON;
|
---|
101 | DragImage.hImage=wpObject->wpQueryIcon();
|
---|
102 |
|
---|
103 |
|
---|
104 | if(DrgDrag(hwnd, DragInfo, &DragImage, 1, VK_ENDDRAG, NULL)) {
|
---|
105 | lpo->lpParent->lpRefreshLaunchPad();
|
---|
106 | }
|
---|
107 |
|
---|
108 | /* Free DragInfo here!!!!!!!!!!! */
|
---|
109 | //DrgDeleteDraginfoStrHandles(pDragInfo);
|
---|
110 | // ????? DrgFreeDraginfo(DragInfo);
|
---|
111 | return (MRESULT)TRUE;
|
---|
112 | }/* somIsObj() */
|
---|
113 | }/* lpo */
|
---|
114 | }
|
---|
115 | break;
|
---|
116 |
|
---|
117 | case DM_ENDCONVERSATION:
|
---|
118 | case DM_DRAGFILECOMPLETE:
|
---|
119 | case DM_DROPNOTIFY:
|
---|
120 | case DM_FILERENDERED:
|
---|
121 | case DM_RENDERCOMPLETE:
|
---|
122 | DosBeep(500,500);
|
---|
123 | break;
|
---|
124 | return (MRESULT)FALSE;
|
---|
125 | case WM_ENDDRAG:
|
---|
126 | DosBeep(500,500);
|
---|
127 | return (MRESULT)TRUE;
|
---|
128 | break;
|
---|
129 | #endif
|
---|
130 | case WM_PAINT:
|
---|
131 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
132 | if(lpo) {
|
---|
133 | BTNCDATA btCtrl={0};
|
---|
134 | WNDPARAMS wndParams={0};
|
---|
135 |
|
---|
136 | // memset(&btCtrl,0,sizeof(btCtrl));
|
---|
137 | btCtrl.cb=sizeof(btCtrl);
|
---|
138 | if(somIsObj(lpo->wpObject)) {
|
---|
139 | btCtrl.hImage=lpo->wpObject->wpQueryIcon();
|
---|
140 | // memset(&wndParams,0,sizeof(wndParams));
|
---|
141 | wndParams.fsStatus=WPM_CTLDATA;
|
---|
142 | wndParams.cbCtlData=btCtrl.cb;
|
---|
143 | wndParams.pCtlData=&btCtrl;
|
---|
144 | WinSendMsg(hwnd,WM_SETWINDOWPARAMS,
|
---|
145 | MPFROMP(&wndParams),0);
|
---|
146 | }
|
---|
147 | }
|
---|
148 | break;
|
---|
149 | case WM_CONTEXTMENU:
|
---|
150 | if(!SHORT2FROMMP(mp2)) {
|
---|
151 |
|
---|
152 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
153 | if(lpo) {
|
---|
154 | wpObject=lpo->wpObject;
|
---|
155 | if(somIsObj(wpObject)) {
|
---|
156 | ptl.y=0;
|
---|
157 | ptl.x=0;
|
---|
158 | hwndMenu=wpObject->wpDisplayMenu(hwnd,hwnd,&ptl,MENU_OBJECTPOPUP,0);
|
---|
159 | }
|
---|
160 | return (MRESULT) TRUE;
|
---|
161 | }
|
---|
162 |
|
---|
163 | }/* end of if(!SHORT2FROMMP(mp2)) */
|
---|
164 | break;
|
---|
165 | case DM_DRAGOVER:
|
---|
166 | {
|
---|
167 | BOOL bReturn=FALSE;
|
---|
168 |
|
---|
169 | TRY_LOUD(LP_DRAGOVER) {
|
---|
170 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
171 | if(lpo) {
|
---|
172 | wpObject=lpo->wpObject;
|
---|
173 | if(somIsObj(wpObject)) {
|
---|
174 | char chrClassName[10];
|
---|
175 | LONG lLength;
|
---|
176 |
|
---|
177 | pDragInfo=(PDRAGINFO) mp1;
|
---|
178 | hwndMenu=pDragInfo->hwndSource;
|
---|
179 | lLength=sizeof(chrClassName);
|
---|
180 | WinQueryClassName(hwndMenu, lLength, chrClassName);
|
---|
181 | if(strcmp(chrClassName,"#37"))
|
---|
182 | hwndMenu=NULL;/* Source isn't a container */
|
---|
183 | if(!bDrawn) {
|
---|
184 | HPS hps;
|
---|
185 | RECTL rectl;
|
---|
186 | SWP swp;
|
---|
187 |
|
---|
188 | /* Draw the rect */
|
---|
189 | hps=DrgGetPS(hwnd);
|
---|
190 | WinQueryWindowPos(hwnd,&swp);
|
---|
191 | rectl.xLeft=1;
|
---|
192 | rectl.yBottom=1;
|
---|
193 | rectl.xRight=swp.cx-1;
|
---|
194 | rectl.yTop=swp.cy-1;
|
---|
195 | //WinDrawBorder(hps,&rectl, 3, 3, 0, 0, DB_STANDARD|DB_PATINVERT);
|
---|
196 | DrgReleasePS(hps);
|
---|
197 | //bDrawn=TRUE;
|
---|
198 | }
|
---|
199 | bReturn=TRUE;
|
---|
200 | }
|
---|
201 | }
|
---|
202 | }
|
---|
203 | CATCH(LP_DRAGOVER)
|
---|
204 | {
|
---|
205 | } END_CATCH;
|
---|
206 | if(bReturn)
|
---|
207 | return wpObject->wpDragOver(hwndMenu,(PDRAGINFO) mp1);
|
---|
208 | break;
|
---|
209 | }
|
---|
210 | case DM_DRAGLEAVE:
|
---|
211 | {
|
---|
212 | RECTL rectl;
|
---|
213 | SWP swp;
|
---|
214 | HPS hps;
|
---|
215 |
|
---|
216 | /* Remove target emphasis here */
|
---|
217 | hps=DrgGetPS(hwnd);
|
---|
218 | WinQueryWindowPos(hwnd,&swp);
|
---|
219 | rectl.xLeft=1;
|
---|
220 | rectl.yBottom=1;
|
---|
221 | rectl.xRight=swp.cx-1;
|
---|
222 | rectl.yTop=swp.cy-1;
|
---|
223 | // WinDrawBorder(hps,&rectl,3, 3, 0, 0, DB_STANDARD|DB_PATINVERT);
|
---|
224 | bDrawn=FALSE;
|
---|
225 | DrgReleasePS(hps);
|
---|
226 | return (MRESULT) FALSE;
|
---|
227 | }
|
---|
228 | case DM_DROP:
|
---|
229 | {
|
---|
230 | BOOL bReturn=FALSE;
|
---|
231 | char chrClassName[10];
|
---|
232 | LONG lLength;
|
---|
233 | PDRAGITEM pDragItem;
|
---|
234 |
|
---|
235 | TRY_LOUD(LP_DROP) {
|
---|
236 | /* A drop on a toolbar button */
|
---|
237 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
238 | if(lpo) {
|
---|
239 | wpObject=lpo->wpObject;
|
---|
240 | if(somIsObj(wpObject)) {
|
---|
241 | pDragInfo=(PDRAGINFO) mp1;
|
---|
242 | pDragItem=DrgQueryDragitemPtr(pDragInfo, 0);
|
---|
243 | hwndMenu=pDragInfo->hwndSource;
|
---|
244 | lLength=sizeof(chrClassName);
|
---|
245 | WinQueryClassName(hwndMenu, lLength, chrClassName);
|
---|
246 | if(strcmp(chrClassName,"#37"))
|
---|
247 | hwndMenu=NULL;/* Source isn't a container */
|
---|
248 | bReturn=TRUE;
|
---|
249 | }
|
---|
250 | }
|
---|
251 | }
|
---|
252 | CATCH(LP_DROP)
|
---|
253 | {
|
---|
254 | } END_CATCH;
|
---|
255 | if(bReturn)
|
---|
256 | return wpObject->wpDrop(hwndMenu,(PDRAGINFO) mp1, pDragItem);
|
---|
257 | break;
|
---|
258 | }
|
---|
259 | case WM_COMMAND:
|
---|
260 | TRY_LOUD(LP_COMMAND) {
|
---|
261 | lpo=(LPObject*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
262 | if(lpo) {
|
---|
263 | wpObject=lpo->wpObject;
|
---|
264 | if(somIsObj(wpObject)) {
|
---|
265 | if((SHORT)0x6d==SHORT1FROMMP(mp1)) {
|
---|
266 | /* Delete menu item */
|
---|
267 | if(wpObject->wpDelete(CONFIRM_DELETE|CONFIRM_DELETEFOLDER ) == OK_DELETE)
|
---|
268 | lpo->lpParent->lpRemoveButton(lpo);
|
---|
269 | }
|
---|
270 | else
|
---|
271 | wpObject->wpMenuItemSelected(NULL, SHORT1FROMMP(mp1));
|
---|
272 | }/* end of if(somIsObj(wpObject)) */
|
---|
273 | }
|
---|
274 | }
|
---|
275 | CATCH(LP_COMMAND)
|
---|
276 | {
|
---|
277 | } END_CATCH;
|
---|
278 | return (MRESULT) FALSE;
|
---|
279 | default:
|
---|
280 | break;
|
---|
281 | }
|
---|
282 | // call the standard flyover button procedure to handle the rest of the messages
|
---|
283 | return (newButtonProc)(hwnd,msg,mp1,mp2);
|
---|
284 | };
|
---|
285 |
|
---|
286 | static BOOL bDrawn=FALSE;
|
---|
287 | static RECTL rclDrawn;
|
---|
288 | static MRESULT handleDragOver(HWND hwnd, MPARAM mp1, MPARAM mp2)
|
---|
289 | {
|
---|
290 | MRESULT mResult;
|
---|
291 | ULONG ulNumberOfObjects;
|
---|
292 | PDRAGINFO pDragInfo;
|
---|
293 | HPS hps;
|
---|
294 | RECTL rectl;
|
---|
295 | SWP swp;
|
---|
296 |
|
---|
297 | mResult = MRFROM2SHORT( DOR_NODROPOP, DO_LINK);
|
---|
298 |
|
---|
299 | /* Get access to the dragInfo */
|
---|
300 | pDragInfo=(PDRAGINFO)mp1;
|
---|
301 | DrgAccessDraginfo(pDragInfo);
|
---|
302 | /* Get number of items */
|
---|
303 | ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);
|
---|
304 |
|
---|
305 | if(ulNumberOfObjects>1) {
|
---|
306 | /* Free the draginfo */
|
---|
307 | DrgFreeDraginfo(pDragInfo);
|
---|
308 | return MRFROM2SHORT( DOR_NODROPOP, DO_LINK);
|
---|
309 | }
|
---|
310 |
|
---|
311 | switch(pDragInfo->usOperation)
|
---|
312 | {
|
---|
313 | case DO_DEFAULT:
|
---|
314 | case DO_LINK:
|
---|
315 | if(!bDrawn) {
|
---|
316 | POINTL ptl;
|
---|
317 | launchPad * lp;
|
---|
318 |
|
---|
319 | ptl.x=SHORT1FROMMP(mp2);
|
---|
320 | ptl.y=SHORT2FROMMP(mp2);
|
---|
321 | /* Pos in window coords */
|
---|
322 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
|
---|
323 |
|
---|
324 | hps=DrgGetPS(hwnd);
|
---|
325 | WinQueryWindowPos(hwnd,&swp);
|
---|
326 |
|
---|
327 | rectl.xLeft=swp.cx;//-swp.cy;
|
---|
328 |
|
---|
329 | lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
330 | if(lp) {
|
---|
331 | if(lp->lpQueryNumObjects()==0) {
|
---|
332 | rectl.xLeft=0;
|
---|
333 | }
|
---|
334 | }
|
---|
335 |
|
---|
336 | rectl.yTop=swp.cy-1;
|
---|
337 | rectl.yBottom=1;
|
---|
338 | if(ptl.x<rectl.xLeft) {
|
---|
339 | int numB;
|
---|
340 |
|
---|
341 | numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
|
---|
342 | rectl.xLeft=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);
|
---|
343 | rectl.xLeft*=(swp.cy+xButtonDelta);
|
---|
344 | rectl.xLeft-=(xButtonDelta)-xButtonOffset+xButtonDelta;
|
---|
345 | rectl.xRight=rectl.xLeft+(xButtonDelta*2);
|
---|
346 | }
|
---|
347 | else {
|
---|
348 | rectl.xRight=swp.cx-1;
|
---|
349 | }
|
---|
350 | rclDrawn=rectl;
|
---|
351 | WinDrawBorder(hps,&rectl, 2, 2, 0, 0, DB_STANDARD|DB_PATINVERT);
|
---|
352 | bDrawn=TRUE;
|
---|
353 |
|
---|
354 | DrgReleasePS(hps);
|
---|
355 | }
|
---|
356 | mResult = MRFROM2SHORT( DOR_DROP, DO_LINK);
|
---|
357 | break;
|
---|
358 | default:
|
---|
359 | break;
|
---|
360 | }
|
---|
361 |
|
---|
362 | /* Free the draginfo */
|
---|
363 | DrgFreeDraginfo(pDragInfo);
|
---|
364 |
|
---|
365 | return mResult;
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | static MRESULT handleDragLeave(HWND hwnd, MPARAM mp1, MPARAM mp2)
|
---|
370 | {
|
---|
371 | RECTL rectl;
|
---|
372 | SWP swp;
|
---|
373 | HPS hps;
|
---|
374 |
|
---|
375 | /* Remove target emphasis here */
|
---|
376 | hps=DrgGetPS(hwnd);
|
---|
377 | WinDrawBorder(hps,&rclDrawn, 2, 2, 0, 0, DB_STANDARD|DB_PATINVERT);
|
---|
378 | DrgReleasePS(hps);
|
---|
379 | bDrawn=FALSE;
|
---|
380 | return (MRESULT) FALSE;
|
---|
381 | }
|
---|
382 |
|
---|
383 |
|
---|
384 | static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
385 | {
|
---|
386 | WPFolder* thisPtr;
|
---|
387 | launchPad * lp;
|
---|
388 | LPObject *lpo;
|
---|
389 | static USHORT id=0;//Initialisation new in V1.00a
|
---|
390 |
|
---|
391 | switch(msg)
|
---|
392 | {
|
---|
393 | #if 0
|
---|
394 | case DM_ENDCONVERSATION:
|
---|
395 | case DM_DRAGFILECOMPLETE:
|
---|
396 | case DM_DROPNOTIFY:
|
---|
397 | case DM_FILERENDERED:
|
---|
398 | case DM_RENDERCOMPLETE:
|
---|
399 | DosBeep(500,500);
|
---|
400 | break;
|
---|
401 | return (MRESULT)FALSE;
|
---|
402 | case WM_ENDDRAG:
|
---|
403 | DosBeep(500,500);
|
---|
404 | break;
|
---|
405 | return (MRESULT)TRUE;
|
---|
406 | #endif
|
---|
407 | case WM_PAINT:
|
---|
408 | {
|
---|
409 | RECTL rcl;
|
---|
410 | launchPad * lp;
|
---|
411 |
|
---|
412 | HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl);
|
---|
413 | WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND);
|
---|
414 | lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
415 | if(lp) {
|
---|
416 | if(lp->lpQueryNumObjects()==0) {
|
---|
417 | WinQueryWindowRect(hwnd,&rcl);
|
---|
418 | WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD);
|
---|
419 | }
|
---|
420 | }
|
---|
421 | WinEndPaint(hps);
|
---|
422 | return (MRESULT) 0;
|
---|
423 | }
|
---|
424 | case DM_DRAGOVER:
|
---|
425 | return handleDragOver(hwnd, mp1, mp2);
|
---|
426 | case DM_DROP:
|
---|
427 | {
|
---|
428 | ULONG ulCount;
|
---|
429 | ULONG ulNumberOfObjects;
|
---|
430 | PDRAGITEM pDragItem;
|
---|
431 | SOMClass *folderClass;
|
---|
432 | WPObject * wpObject;
|
---|
433 | PDRAGINFO pDragInfo;
|
---|
434 |
|
---|
435 | TRY_LOUD(LP_FRAMEDROP) {
|
---|
436 | /* A new object dropped on the launchpad */
|
---|
437 | pDragInfo=(PDRAGINFO)mp1;
|
---|
438 | if(DrgAccessDraginfo(pDragInfo)) {
|
---|
439 | /* Get number of items */
|
---|
440 | ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);
|
---|
441 | if(ulNumberOfObjects>1){
|
---|
442 | /* Free the draginfo */
|
---|
443 | DrgDeleteDraginfoStrHandles(pDragInfo);
|
---|
444 | DrgFreeDraginfo(pDragInfo);
|
---|
445 | }
|
---|
446 | else {
|
---|
447 | ulCount=0;
|
---|
448 |
|
---|
449 | pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount);
|
---|
450 | wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
|
---|
451 | lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
452 | if(lp) {
|
---|
453 | if(somIsObj(wpObject)) {
|
---|
454 |
|
---|
455 | POINTL ptl;
|
---|
456 | int numB;
|
---|
457 | SWP swp;
|
---|
458 |
|
---|
459 | WinQueryWindowPos(hwnd,&swp);
|
---|
460 | ptl.x=pDragInfo->xDrop;
|
---|
461 | ptl.y=pDragInfo->yDrop;
|
---|
462 | /* Pos in window coords */
|
---|
463 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
|
---|
464 | numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
|
---|
465 | numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);
|
---|
466 |
|
---|
467 | /* Do a link */
|
---|
468 | lp->lpAddButton(wpObject, numB);
|
---|
469 | handleDragLeave(hwnd, mp1, mp2);
|
---|
470 | }
|
---|
471 | }
|
---|
472 | DrgDeleteDraginfoStrHandles(pDragInfo);
|
---|
473 | DrgFreeDraginfo(pDragInfo);
|
---|
474 | }
|
---|
475 | }
|
---|
476 | handleDragLeave(hwnd, mp1, mp2);
|
---|
477 | }
|
---|
478 | CATCH(LP_FRAMEDROP)
|
---|
479 | {
|
---|
480 | } END_CATCH;
|
---|
481 |
|
---|
482 | break;
|
---|
483 | }
|
---|
484 | case DM_DRAGLEAVE:
|
---|
485 | return handleDragLeave(hwnd, mp1, mp2);
|
---|
486 | break;
|
---|
487 | case WM_COMMAND:
|
---|
488 | if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
|
---|
489 | /* It's a push button */
|
---|
490 | lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER);
|
---|
491 | if(lpo) {
|
---|
492 | if(somIsObj(lpo->wpObject))
|
---|
493 | lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0);
|
---|
494 | }
|
---|
495 | }
|
---|
496 | return (MRESULT)FALSE;
|
---|
497 | /***********************************************/
|
---|
498 | /* Stuff for fly over help */
|
---|
499 | case WM_MOUSEMOVE:
|
---|
500 | launchPad * lp;
|
---|
501 |
|
---|
502 | lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
503 | if(lp) {
|
---|
504 | if(lp->lpQueryNumObjects()!=0) {
|
---|
505 | break;
|
---|
506 | }
|
---|
507 | }
|
---|
508 |
|
---|
509 | #if 0
|
---|
510 | tempID=WinQueryWindowUShort(hwnd,QWS_ID);/* get the id of the window under the pointer */
|
---|
511 | if(id!=tempID) { // New Button?
|
---|
512 | WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
|
---|
513 | id=tempID; // Save ID
|
---|
514 | }
|
---|
515 | else {
|
---|
516 | if(!hwndBubbleWindow)
|
---|
517 | WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
|
---|
518 | }
|
---|
519 | #endif
|
---|
520 | if(!hwndBubbleWindow)
|
---|
521 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay
|
---|
522 |
|
---|
523 | break;
|
---|
524 | case WM_DESTROY:
|
---|
525 | WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
|
---|
526 | if(hwndBubbleWindow)
|
---|
527 | WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
|
---|
528 | hwndBubbleWindow=0;
|
---|
529 | /* Stop delay timer if running */
|
---|
530 | WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2);
|
---|
531 | break;
|
---|
532 |
|
---|
533 | case WM_NEWBUBBLE:
|
---|
534 | ULONG bubbleEnabled;
|
---|
535 | HWND hwndStore;
|
---|
536 | POINTL ptl;
|
---|
537 | RECTL rclWork;
|
---|
538 | LONG ulWinTextLen;
|
---|
539 | POINTL aptlPoints[TXTBOX_COUNT];
|
---|
540 | LONG deltaX,deltaY;
|
---|
541 | HPS hps;
|
---|
542 | RECTL rcl;
|
---|
543 |
|
---|
544 | /* we have to build a new information window */
|
---|
545 | if(hwndBubbleWindow){// if(){...} new in V1.00a
|
---|
546 | WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
|
---|
547 | hwndBubbleWindow=NULL;
|
---|
548 | }
|
---|
549 | // Query the pointer position
|
---|
550 | WinQueryPointerPos(HWND_DESKTOP,&ptl);
|
---|
551 | WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
|
---|
552 | WinQueryWindowRect(hwnd,&rclWork);
|
---|
553 | if(!hwndBubbleWindow
|
---|
554 | && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
|
---|
555 | && bTBFlyOverEnabled) {
|
---|
556 |
|
---|
557 | static HWND hwndBubbleClient;
|
---|
558 | ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
|
---|
559 | char winText[255];
|
---|
560 |
|
---|
561 | /* Get window text for size calculating */
|
---|
562 | lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
563 | if(lp) {
|
---|
564 | strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText));
|
---|
565 | winText[sizeof(winText)-1]=0;
|
---|
566 | }
|
---|
567 |
|
---|
568 | ulWinTextLen=(LONG)strlen(winText); // Query text length
|
---|
569 |
|
---|
570 | /* Delete 'Returns' in object title */
|
---|
571 | char *pBuchst;
|
---|
572 | char *pRest;
|
---|
573 | pRest=winText;
|
---|
574 | while((pBuchst=strchr(pRest,13))!=NULL) {
|
---|
575 | *pBuchst=' ';
|
---|
576 | pBuchst++;
|
---|
577 | if(*pBuchst==10)
|
---|
578 | *pBuchst=' ';
|
---|
579 | pRest=pBuchst;
|
---|
580 | }
|
---|
581 |
|
---|
582 | /* Create help window */
|
---|
583 | hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
|
---|
584 | 0,
|
---|
585 | &style,
|
---|
586 | WC_STATIC,
|
---|
587 | "",
|
---|
588 | SS_TEXT|DT_CENTER|DT_VCENTER,
|
---|
589 | NULLHANDLE,
|
---|
590 | 400,
|
---|
591 | &hwndBubbleClient);
|
---|
592 |
|
---|
593 | hwndShadow=WinCreateWindow(HWND_DESKTOP,
|
---|
594 | WC_STATIC,
|
---|
595 | "",
|
---|
596 | SS_TEXT|DT_CENTER|DT_VCENTER,
|
---|
597 | 0, 0,
|
---|
598 | 0, 0,
|
---|
599 | hwndBubbleWindow,
|
---|
600 | hwndBubbleWindow,
|
---|
601 | 401,
|
---|
602 | NULLHANDLE,
|
---|
603 | NULLHANDLE);
|
---|
604 | oldProc=WinSubclassWindow(hwndShadow, shadowProc);
|
---|
605 |
|
---|
606 | // Set the font for the help
|
---|
607 | WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
|
---|
608 | sizeof(chrTBFlyFontName),
|
---|
609 | chrTBFlyFontName);
|
---|
610 | /* Calculate text size in pixel */
|
---|
611 | hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
|
---|
612 | GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
|
---|
613 | WinEndPaint(hps);
|
---|
614 |
|
---|
615 | /* Set colors */
|
---|
616 | WinSetPresParam(hwndBubbleClient,
|
---|
617 | PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
|
---|
618 | &rgbTBFlyBackground );
|
---|
619 | WinSetPresParam(hwndBubbleClient,
|
---|
620 | PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
|
---|
621 | &rgbTBFlyForeground );
|
---|
622 |
|
---|
623 | /* Calculate bubble positon and show bubble */
|
---|
624 | WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
|
---|
625 | WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
|
---|
626 | aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x
|
---|
627 | > rcl.xRight
|
---|
628 | ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7
|
---|
629 | : deltaX=0 ;
|
---|
630 |
|
---|
631 | aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y
|
---|
632 | > rcl.yTop
|
---|
633 | ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
|
---|
634 | : deltaY=0 ;
|
---|
635 | WinSetWindowPos(hwndBubbleWindow,
|
---|
636 | HWND_TOP,
|
---|
637 | ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,
|
---|
638 | aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
|
---|
639 | aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
|
---|
640 | SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
|
---|
641 |
|
---|
642 | WinSetWindowPos(hwndShadow,
|
---|
643 | hwndBubbleWindow,
|
---|
644 | ptl.x+xVal+deltaX+5
|
---|
645 | ,ptl.y+yVal+deltaY-5,
|
---|
646 | aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
|
---|
647 | aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
|
---|
648 | SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
|
---|
649 |
|
---|
650 | /* Set bubble text */
|
---|
651 | WinSetWindowText(hwndBubbleClient,winText);
|
---|
652 | WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35);
|
---|
653 | } // end if(!hwndBubbleWindow)
|
---|
654 | break;
|
---|
655 | case WM_TIMER:
|
---|
656 | switch (SHORT1FROMMP(mp1))
|
---|
657 | {
|
---|
658 | case 1: //Intervall timer
|
---|
659 | {
|
---|
660 | POINTL ptl;
|
---|
661 | RECTL rclWork;
|
---|
662 |
|
---|
663 | /* Test pointer position */
|
---|
664 | WinQueryPointerPos(HWND_DESKTOP, &ptl);
|
---|
665 | WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1);
|
---|
666 | WinQueryWindowRect(hwnd, &rclWork);
|
---|
667 | if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
|
---|
668 | { // Window has changed
|
---|
669 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1); // stop the running timer
|
---|
670 | if(hwndBubbleWindow)
|
---|
671 | WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
|
---|
672 | hwndBubbleWindow=0;
|
---|
673 | id=0;
|
---|
674 | }
|
---|
675 | break;
|
---|
676 | }
|
---|
677 | case 2:// delay over
|
---|
678 | {//our own timer.
|
---|
679 | POINTL ptl;
|
---|
680 | RECTL rclWork;
|
---|
681 |
|
---|
682 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer
|
---|
683 | /* Check the pointer position */
|
---|
684 | WinQueryPointerPos(HWND_DESKTOP,&ptl);
|
---|
685 | WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
|
---|
686 | WinQueryWindowRect(hwnd,&rclWork);
|
---|
687 | if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
|
---|
688 | WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
|
---|
689 | return (MRESULT)FALSE;
|
---|
690 | }
|
---|
691 | default:
|
---|
692 | break;
|
---|
693 | }
|
---|
694 | break;
|
---|
695 | default:
|
---|
696 | break;
|
---|
697 | }
|
---|
698 | return pfnwpOldLPProc(hwnd, msg, mp1, mp2);
|
---|
699 | }
|
---|
700 |
|
---|
701 | void LPList::lplRefreshAllPads()
|
---|
702 | {
|
---|
703 |
|
---|
704 | }
|
---|
705 |
|
---|
706 | LPObject::LPObject(HPOINTER hptr)
|
---|
707 | {
|
---|
708 | hPtr=hptr;
|
---|
709 | }
|
---|
710 |
|
---|
711 | LPObject::~LPObject(void)
|
---|
712 | {
|
---|
713 | #if 0
|
---|
714 | if(hPtr) {
|
---|
715 | if(!WinDestroyPointer(hPtr))
|
---|
716 | DosBeep(100,200);
|
---|
717 | }
|
---|
718 | #endif
|
---|
719 | }
|
---|
720 |
|
---|
721 | launchPad::launchPad(HWND hwndParent,HWND hwndOwner, BOOL bVisible, WPFolder *wpParent, LPList** lpadList, HWND hwndPrev, ULONG ulFl)
|
---|
722 | {
|
---|
723 | LPList *lplTemp;
|
---|
724 |
|
---|
725 | wpParentFolder=wpParent;
|
---|
726 | hwndPrevious=hwndPrev;
|
---|
727 | fl=ulFl;
|
---|
728 | lpList=lpadList;
|
---|
729 |
|
---|
730 | /* Reset text */
|
---|
731 | chrFlyOverText[0]=0;
|
---|
732 |
|
---|
733 | if((hwndLaunchPad=WinCreateWindow(hwndParent ,WC_FRAME, "Toolbar", FS_BORDER| (bVisible ? WS_VISIBLE: 0),
|
---|
734 | 0, 0, 0, 0, hwndOwner, HWND_TOP, 1234, NULLHANDLE, NULLHANDLE))!=NULLHANDLE) {
|
---|
735 | WinSetWindowULong(hwndLaunchPad, QWL_USER,(ULONG) this);//Save object ptr.
|
---|
736 | pfnwpOldLPProc=WinSubclassWindow(hwndLaunchPad, launchPadWindowProc);
|
---|
737 | }
|
---|
738 |
|
---|
739 | ulNumObjects=0;
|
---|
740 | lpoObjectList=NULL;
|
---|
741 |
|
---|
742 | /* Add this pad to the list of pads */
|
---|
743 | if(!lplAllLPads) {
|
---|
744 | /* It's the first one */
|
---|
745 | if((lplAllLPads=new LPList)!=NULL) {
|
---|
746 | lplAllLPads->lpPad=this;
|
---|
747 | lplAllLPads->lplNext=NULL;
|
---|
748 | }
|
---|
749 | }
|
---|
750 | else {
|
---|
751 | if((lplTemp=new LPList)!=NULL) {
|
---|
752 | lplTemp->lpPad=this;
|
---|
753 | lplTemp->lplNext=lplAllLPads;
|
---|
754 | lplAllLPads=lplTemp;
|
---|
755 | }
|
---|
756 | }
|
---|
757 | }
|
---|
758 |
|
---|
759 | launchPad::~launchPad()
|
---|
760 | {
|
---|
761 | LPList *lplTemp, *lplTemp2;
|
---|
762 |
|
---|
763 | lpSaveObjectList();
|
---|
764 | lpFreeObjectList();
|
---|
765 |
|
---|
766 | if(hwndLaunchPad)
|
---|
767 | WinDestroyWindow(hwndLaunchPad);
|
---|
768 |
|
---|
769 | /* Remove this pad from the list of pads */
|
---|
770 | lplTemp=lplAllLPads;
|
---|
771 |
|
---|
772 | if(lplTemp->lpPad==this) {
|
---|
773 | lplAllLPads=lplTemp->lplNext;
|
---|
774 | delete(lplTemp);
|
---|
775 | }
|
---|
776 | else {
|
---|
777 | while(lplTemp->lplNext)
|
---|
778 | {
|
---|
779 | if(lplTemp->lplNext->lpPad==this) {
|
---|
780 | lplTemp2=lplTemp->lplNext;
|
---|
781 | lplTemp->lplNext=lplTemp->lplNext->lplNext;
|
---|
782 | delete(lplTemp2);
|
---|
783 | break;
|
---|
784 | }
|
---|
785 | lplTemp=lplTemp->lplNext;
|
---|
786 | }
|
---|
787 | }
|
---|
788 | }
|
---|
789 |
|
---|
790 | BOOL launchPad::lpSetFlyOverText(char* chrText)
|
---|
791 | {
|
---|
792 | strncpy(chrFlyOverText, chrText, sizeof(chrFlyOverText));
|
---|
793 | chrFlyOverText[sizeof(chrFlyOverText)-1]=0;
|
---|
794 |
|
---|
795 | return TRUE;
|
---|
796 | }
|
---|
797 |
|
---|
798 | PSZ launchPad::lpQueryFlyOverText(void)
|
---|
799 | {
|
---|
800 | return chrFlyOverText;
|
---|
801 | }
|
---|
802 |
|
---|
803 | BOOL launchPad::lpSetLaunchPadPos(HWND hwndInsertBehind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl)
|
---|
804 | {
|
---|
805 | if(WinIsWindow(WinQueryAnchorBlock(hwndLaunchPad), hwndPrevious)) {
|
---|
806 | SWP swp;
|
---|
807 | WinQueryWindowPos(hwndPrevious,&swp);
|
---|
808 | return WinSetWindowPos(hwndLaunchPad, hwndInsertBehind, swp.x+swp.cx+x, y, cx, cy, fl);
|
---|
809 | }
|
---|
810 | else
|
---|
811 | return WinSetWindowPos(hwndLaunchPad, hwndInsertBehind, x, y, cx, cy, fl);
|
---|
812 | }
|
---|
813 |
|
---|
814 |
|
---|
815 | BOOL launchPad::lpSetConfiguration(char * chrTarget, char * chrConfigID_)
|
---|
816 | {
|
---|
817 | HOBJECT hObject;
|
---|
818 | char chrSetup[CCHMAXPATH];
|
---|
819 |
|
---|
820 | /* Destination of toolbar folder */
|
---|
821 | strncpy(chrConfigTarget, chrTarget,sizeof(chrConfigTarget));
|
---|
822 | chrConfigTarget[sizeof(chrConfigTarget)-1]=0;
|
---|
823 | /* The ID of the toolbar folder */
|
---|
824 | strncpy(chrConfigID, chrConfigID_,sizeof(chrConfigID));
|
---|
825 | chrConfigID[sizeof(chrConfigID)-1]=0;
|
---|
826 |
|
---|
827 | /* First check the config folder */
|
---|
828 | if((hObject=WinQueryObject(chrConfigID))==NULLHANDLE)
|
---|
829 | {
|
---|
830 | /* Toolbar folder lost recreate it */
|
---|
831 | if(!SysCheckFileExists(chrConfigTarget))
|
---|
832 | return FALSE; /* No install dir defined */
|
---|
833 |
|
---|
834 | if(fl & LP_USEOBJECTASPARAM) {
|
---|
835 | /* This isn't used yet */
|
---|
836 | sprintf(chrSetup, "HIDECLASSPAGE=1;OBJECTID=%s",chrConfigID);
|
---|
837 | if((hObject=WinCreateObject("CWMenuFolder", chrConfigID, chrSetup, chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
|
---|
838 | return FALSE; /* Can't create new toolbar folder */
|
---|
839 | }
|
---|
840 | else {
|
---|
841 | sprintf(chrSetup, "OBJECTID=%s", chrConfigID);
|
---|
842 | if((hObject=WinCreateObject("WPFolder", chrConfigID, chrSetup, chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
|
---|
843 | return FALSE; /* Can't create new toolbar folder */
|
---|
844 | }
|
---|
845 | }
|
---|
846 |
|
---|
847 | lpBuildObjectList(chrConfigID);
|
---|
848 |
|
---|
849 | return TRUE;
|
---|
850 | }
|
---|
851 |
|
---|
852 | WPFolder* launchPad::lpQueryParentFolder()
|
---|
853 | {
|
---|
854 | return wpParentFolder;
|
---|
855 | }
|
---|
856 |
|
---|
857 | void launchPad::lpRefreshLaunchPad()
|
---|
858 | {
|
---|
859 | /* Refresh all launchpads */
|
---|
860 | LPList *lplTemp;
|
---|
861 |
|
---|
862 | //lplTemp=lplAllLPads;
|
---|
863 | lplTemp=*lpList;
|
---|
864 |
|
---|
865 | while(lplTemp)
|
---|
866 | {
|
---|
867 | if(lplTemp->lpPad) {
|
---|
868 | lplTemp->lpPad->lpFreeObjectList();
|
---|
869 | lplTemp->lpPad->lpReBuildObjectList();
|
---|
870 | lplTemp->lpPad->lpFillPad();
|
---|
871 | }
|
---|
872 | lplTemp=lplTemp->lplNext;
|
---|
873 | }
|
---|
874 | return;
|
---|
875 | }
|
---|
876 |
|
---|
877 | BOOL launchPad::lpRemoveButton(LPObject *lpObject)
|
---|
878 | {
|
---|
879 | int a;
|
---|
880 | LPObject* lpoTemp, *lpoTemp2;
|
---|
881 |
|
---|
882 | /* Find object in list */
|
---|
883 | lpoTemp=lpoObjectList;
|
---|
884 |
|
---|
885 | if(lpoTemp==lpObject) {
|
---|
886 | lpoObjectList=lpoTemp->lpoNext;
|
---|
887 |
|
---|
888 | delete(lpObject);
|
---|
889 | ulNumObjects--;
|
---|
890 | }
|
---|
891 | else {
|
---|
892 | while(lpoTemp->lpoNext)
|
---|
893 | {
|
---|
894 | if(lpoTemp->lpoNext==lpObject) {
|
---|
895 | lpoTemp->lpoNext=lpObject->lpoNext;
|
---|
896 |
|
---|
897 | delete(lpObject);
|
---|
898 | ulNumObjects--;
|
---|
899 | break;
|
---|
900 | }
|
---|
901 | lpoTemp=lpoTemp->lpoNext;
|
---|
902 | }
|
---|
903 | }
|
---|
904 |
|
---|
905 | lpSaveObjectList();
|
---|
906 | lpRefreshLaunchPad();
|
---|
907 |
|
---|
908 | return TRUE;
|
---|
909 | }
|
---|
910 |
|
---|
911 |
|
---|
912 | BOOL launchPad::lpAddButton(WPObject* wpObject, int iPos)
|
---|
913 | {
|
---|
914 | HOBJECT hObject;
|
---|
915 | SOMClass *folderClass;
|
---|
916 | char chrSetup[CCHMAXPATH];
|
---|
917 | WPObject *wpTempObject;
|
---|
918 | LPObject *lpoTemp, *lpoTemp2, *lpoTempNew;
|
---|
919 | int a;
|
---|
920 |
|
---|
921 |
|
---|
922 | /* First check the config folder */
|
---|
923 | if((hObject=WinQueryObject(chrConfigID))==NULLHANDLE)
|
---|
924 | {
|
---|
925 | /* Toolbar folder lost recreate it */
|
---|
926 | if(!SysCheckFileExists(chrConfigTarget))
|
---|
927 | return FALSE; /* No install dir defined */
|
---|
928 |
|
---|
929 | if(fl & LP_USEOBJECTASPARAM) {
|
---|
930 | sprintf(chrSetup, "HIDECLASSPAGE=1;OBJECTID=%s", chrConfigID);
|
---|
931 | if((hObject=WinCreateObject("CWMenuFolder", chrConfigID, chrSetup, chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
|
---|
932 | return FALSE; /* Can't create new toolbar folder */
|
---|
933 | }
|
---|
934 | else {
|
---|
935 | sprintf(chrSetup, "OBJECTID=%s", chrConfigID);
|
---|
936 | if((hObject=WinCreateObject("WPFolder", chrConfigID, chrSetup, chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
|
---|
937 | return FALSE; /* Can't create new toolbar folder */
|
---|
938 | }
|
---|
939 | }
|
---|
940 |
|
---|
941 | if(somIsObj(wpObject) && somIsObj(wpParentFolder)) {
|
---|
942 | folderClass=wpParentFolder->somGetClass();
|
---|
943 | if(somIsObj(folderClass)) {
|
---|
944 | /* Create a shadow in our toolbar folder */
|
---|
945 | wpTempObject=wpObject->wpCreateShadowObject((WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrConfigID, FALSE), FALSE);
|
---|
946 | if(somIsObj(wpTempObject)) {
|
---|
947 | /* Get the persistent object handle */
|
---|
948 | hObject=wpTempObject->wpQueryHandle();
|
---|
949 |
|
---|
950 | /* Find the insertion point */
|
---|
951 | /* iPos is the button after which we insert the new one. The list of objects is in reverse order. */
|
---|
952 | lpoTemp2=lpoObjectList;
|
---|
953 | if(iPos<ulNumObjects) {
|
---|
954 | lpoTemp=lpoTemp2;
|
---|
955 | for(a=ulNumObjects;a>iPos && lpoTemp; a--)
|
---|
956 | {
|
---|
957 | lpoTemp=lpoTemp2;
|
---|
958 | lpoTemp2=lpoTemp2->lpoNext;
|
---|
959 | }
|
---|
960 | }
|
---|
961 | else
|
---|
962 | lpoTemp=NULLHANDLE;
|
---|
963 |
|
---|
964 | /* lpoTemp contains object */
|
---|
965 | /* Alloc a struct for this object to insert it on the toolbar */
|
---|
966 |
|
---|
967 | if((lpoTempNew=new LPObject(wpTempObject->wpQueryIcon()))!=NULL) {
|
---|
968 | ULONG ulRC;
|
---|
969 |
|
---|
970 | lpoTempNew->wpObject=wpTempObject;
|
---|
971 | lpoTempNew->wpObject->wpLockObject();
|
---|
972 | lpoTempNew->hObject=hObject;
|
---|
973 | // lpoTempNew->hPtr=wpTempObject->wpQueryIcon();
|
---|
974 |
|
---|
975 | /* Title of the object */
|
---|
976 | strncpy(lpoTempNew->chrName, wpTempObject->wpQueryTitle(),sizeof(lpoTempNew->chrName));
|
---|
977 | lpoTempNew->lpParent=this;
|
---|
978 |
|
---|
979 | if(lpoTemp) {
|
---|
980 | lpoTempNew->lpoNext=lpoTemp->lpoNext;
|
---|
981 | lpoTemp->lpoNext=lpoTempNew;
|
---|
982 | }
|
---|
983 | else {
|
---|
984 | lpoTempNew->lpoNext=lpoObjectList;
|
---|
985 | lpoObjectList=lpoTempNew;
|
---|
986 | }
|
---|
987 | ulNumObjects++;
|
---|
988 | }
|
---|
989 | }
|
---|
990 | }
|
---|
991 | }
|
---|
992 |
|
---|
993 | lpSaveObjectList();
|
---|
994 | lpRefreshLaunchPad();
|
---|
995 |
|
---|
996 | return TRUE;
|
---|
997 | }
|
---|
998 |
|
---|
999 |
|
---|
1000 | BOOL launchPad::lpSaveObjectList()
|
---|
1001 | {
|
---|
1002 | SOMClass *folderClass;
|
---|
1003 | WPFolder *wpFolder;
|
---|
1004 | char chrPath[CCHMAXPATH];
|
---|
1005 | ULONG ulBufferSize;
|
---|
1006 | HINI hIni;
|
---|
1007 | char * memPtr;
|
---|
1008 | HOBJECT *hObject;
|
---|
1009 | HOBJECT hObject2;
|
---|
1010 | int a;
|
---|
1011 | LPObject *lpoTemp;
|
---|
1012 |
|
---|
1013 | /* First check the config folder */
|
---|
1014 | if((hObject2=WinQueryObject(chrConfigID))==NULLHANDLE)
|
---|
1015 | {
|
---|
1016 | /* Toolbar folder lost recreate it */
|
---|
1017 | if(!SysCheckFileExists(chrConfigTarget))
|
---|
1018 | return FALSE; /* No install dir defined */
|
---|
1019 |
|
---|
1020 | sprintf(chrPath,"OBJECTID=%s",chrConfigID);
|
---|
1021 | if((hObject2=WinCreateObject("WPFolder", chrConfigID, chrPath,chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
|
---|
1022 | return FALSE; /* Can't create new toolbar folder */
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | /* Get toolbar folder */
|
---|
1026 | if(somIsObj(wpParentFolder)) {
|
---|
1027 | folderClass=wpParentFolder->somGetClass();
|
---|
1028 | if(somIsObj(folderClass))
|
---|
1029 | wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrConfigID, FALSE);
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | ulBufferSize=sizeof(chrPath);
|
---|
1033 | wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
|
---|
1034 | strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
|
---|
1035 |
|
---|
1036 | // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrPath, "~launchPad", 123, MB_OK| MB_MOVEABLE);
|
---|
1037 | do{
|
---|
1038 | /* Open the ini-file */
|
---|
1039 | if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
|
---|
1040 | break;
|
---|
1041 |
|
---|
1042 | if((memPtr=(char*)malloc(ulNumObjects*sizeof(HOBJECT)))==NULL)
|
---|
1043 | break;
|
---|
1044 |
|
---|
1045 |
|
---|
1046 | hObject=(HOBJECT*)memPtr;
|
---|
1047 |
|
---|
1048 | lpoTemp=lpoObjectList;
|
---|
1049 | for(a=ulNumObjects;a>0 && lpoTemp; a--)
|
---|
1050 | {
|
---|
1051 | hObject[a-1]=lpoTemp->hObject;
|
---|
1052 | lpoTemp=lpoTemp->lpoNext;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | if(!PrfWriteProfileData(hIni,"objects","handles", hObject, ulNumObjects*sizeof(HOBJECT))) {
|
---|
1056 | free(hObject);
|
---|
1057 | break;
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | free(hObject);
|
---|
1061 |
|
---|
1062 | PrfCloseProfile(hIni);
|
---|
1063 | return TRUE;
|
---|
1064 | }while(TRUE);
|
---|
1065 |
|
---|
1066 | if(hIni)
|
---|
1067 | PrfCloseProfile(hIni);
|
---|
1068 | return FALSE;
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | BOOL launchPad::lpReBuildObjectList()
|
---|
1072 | {
|
---|
1073 | return lpBuildObjectList( chrConfigID);
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | BOOL launchPad::lpBuildObjectList(char * chrFolderID)
|
---|
1077 | {
|
---|
1078 | WPObject* wpObject;
|
---|
1079 |
|
---|
1080 | char chrText[200];
|
---|
1081 | ULONG ul;
|
---|
1082 |
|
---|
1083 | SOMClass *folderClass;
|
---|
1084 | WPFolder *wpFolder;
|
---|
1085 | char chrPath[CCHMAXPATH];
|
---|
1086 | ULONG ulBufferSize;
|
---|
1087 | HINI hIni;
|
---|
1088 | char * memPtr;
|
---|
1089 | HOBJECT *hObjectArray;
|
---|
1090 | int a;
|
---|
1091 | LPObject *lpoTemp;
|
---|
1092 | WPObject * wpTempObject;
|
---|
1093 |
|
---|
1094 |
|
---|
1095 | /* Get toolbar folder */
|
---|
1096 | if(somIsObj(wpParentFolder)) {
|
---|
1097 | folderClass=wpParentFolder->somGetClass();
|
---|
1098 | if(somIsObj(folderClass))
|
---|
1099 | wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrFolderID, FALSE);
|
---|
1100 | if(!somIsObj(wpFolder))
|
---|
1101 | return FALSE;
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | /* Build ini name */
|
---|
1105 | ulBufferSize=sizeof(chrPath);
|
---|
1106 | wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
|
---|
1107 | strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
|
---|
1108 |
|
---|
1109 | do{
|
---|
1110 | /* Open the ini-file */
|
---|
1111 | if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
|
---|
1112 | break;
|
---|
1113 |
|
---|
1114 | if(!PrfQueryProfileSize(hIni,"objects","handles", &ulBufferSize))
|
---|
1115 | break;
|
---|
1116 |
|
---|
1117 | if(ulBufferSize==0)
|
---|
1118 | break;/* No entries yet */
|
---|
1119 |
|
---|
1120 | if((memPtr=(char*)malloc(ulBufferSize))==NULL)
|
---|
1121 | break;
|
---|
1122 |
|
---|
1123 | ulNumObjects=ulBufferSize/sizeof(HOBJECT);
|
---|
1124 |
|
---|
1125 | if(!PrfQueryProfileData(hIni,"objects","handles", memPtr, &ulBufferSize)){
|
---|
1126 | free(memPtr);
|
---|
1127 | break;
|
---|
1128 | }
|
---|
1129 |
|
---|
1130 | hObjectArray=(HOBJECT*)memPtr;
|
---|
1131 | ulBufferSize=ulNumObjects;
|
---|
1132 | for(a=0;a<ulBufferSize && lpoTemp; a++)
|
---|
1133 | {
|
---|
1134 | wpTempObject=((M_WPObject*)folderClass)->wpclsQueryObject(hObjectArray[a]);
|
---|
1135 | if(somIsObj(wpTempObject)) {
|
---|
1136 | if((lpoTemp=new LPObject(wpTempObject->wpQueryIcon()))!=NULL) {
|
---|
1137 | lpoTemp->wpObject=wpTempObject;
|
---|
1138 | wpTempObject->wpLockObject();
|
---|
1139 | lpoTemp->hObject=hObjectArray[a];
|
---|
1140 | // lpoTemp->hPtr=wpTempObject->wpQueryIcon();
|
---|
1141 | /* Title of the object */
|
---|
1142 | strncpy(lpoTemp->chrName, wpTempObject->wpQueryTitle(),sizeof(lpoTemp->chrName));
|
---|
1143 | lpoTemp->lpParent=this;
|
---|
1144 |
|
---|
1145 | lpoTemp->lpoNext=lpoObjectList;
|
---|
1146 | lpoObjectList=lpoTemp;
|
---|
1147 | }
|
---|
1148 | }
|
---|
1149 | else {
|
---|
1150 | ulNumObjects--;
|
---|
1151 | }
|
---|
1152 | }/* for */
|
---|
1153 |
|
---|
1154 | free(hObjectArray);
|
---|
1155 |
|
---|
1156 | PrfCloseProfile(hIni);
|
---|
1157 | return TRUE;
|
---|
1158 | }while(TRUE);
|
---|
1159 |
|
---|
1160 | if(hIni)
|
---|
1161 | PrfCloseProfile(hIni);
|
---|
1162 | return FALSE;
|
---|
1163 |
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | void launchPad::lpFreeObjectList()
|
---|
1167 | {
|
---|
1168 | LPObject *lpoTemp, *lpoTemp2;
|
---|
1169 |
|
---|
1170 | /* Free our object list */
|
---|
1171 | lpoTemp=lpoObjectList;
|
---|
1172 | while(lpoTemp) {
|
---|
1173 | lpoTemp2=lpoTemp->lpoNext;
|
---|
1174 | lpoTemp->wpObject->wpUnlockObject();
|
---|
1175 | delete (lpoTemp);
|
---|
1176 | lpoTemp=lpoTemp2;
|
---|
1177 | }
|
---|
1178 | lpoObjectList=NULL;
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | BOOL launchPad::lpClearPad()
|
---|
1182 | {
|
---|
1183 | LPObject *lpoTemp, *lpoTemp2;
|
---|
1184 | int a;
|
---|
1185 | HENUM hEnum;
|
---|
1186 | HWND hwnd;
|
---|
1187 |
|
---|
1188 | /* Destroy all Buttons */
|
---|
1189 | hEnum=WinBeginEnumWindows(hwndLaunchPad);
|
---|
1190 | while((hwnd=WinGetNextWindow(hEnum))!=NULLHANDLE)
|
---|
1191 | WinDestroyWindow(hwnd);
|
---|
1192 | WinEndEnumWindows(hEnum);
|
---|
1193 |
|
---|
1194 | return TRUE;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | BOOL launchPad::lpFillPad()
|
---|
1199 | {
|
---|
1200 | HOBJECT hObject;
|
---|
1201 | char chrSetup[CCHMAXPATH];
|
---|
1202 | WPFolder* wpFolder;
|
---|
1203 | LPObject *lpoTemp;
|
---|
1204 |
|
---|
1205 | SWP swp;
|
---|
1206 | HWND hwndTemp;
|
---|
1207 | BTNCDATA btCtrl;
|
---|
1208 | WNDPARAMS wndParams;
|
---|
1209 | ULONG ulStyle;
|
---|
1210 | int a;
|
---|
1211 | LONG lXSize;
|
---|
1212 | HENUM hEnum;
|
---|
1213 | HWND hwndClient;
|
---|
1214 | LONG lCxSave;
|
---|
1215 |
|
---|
1216 | /* Remove Buttons from pad */
|
---|
1217 | lpClearPad();
|
---|
1218 |
|
---|
1219 | /* Resize the pad for all objects */
|
---|
1220 | if(!WinQueryWindowPos(hwndLaunchPad, &swp))
|
---|
1221 | return FALSE;
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | lCxSave=swp.cx;
|
---|
1225 |
|
---|
1226 | lXSize=(ulNumObjects == 0 ? swp.cy : (ulNumObjects) * (swp.cy+xButtonDelta) +2*xButtonOffset);
|
---|
1227 | lpSetLaunchPadPos( NULLHANDLE,0,0, lXSize , swp.cy, SWP_SIZE);
|
---|
1228 |
|
---|
1229 | /* Move all controls on the right */
|
---|
1230 | /* Move all client windows so they keep their distance to the left border */
|
---|
1231 | hEnum=WinBeginEnumWindows(WinQueryWindow(hwndLaunchPad,QW_PARENT));
|
---|
1232 | while((hwndClient=WinGetNextWindow(hEnum))!=NULLHANDLE) {
|
---|
1233 | SWP swpClient;
|
---|
1234 |
|
---|
1235 | WinQueryWindowPos(hwndClient,&swpClient);
|
---|
1236 | if(swpClient.x > swp.x)
|
---|
1237 | WinSetWindowPos(hwndClient, NULLHANDLE, swpClient.x+(lXSize-lCxSave), swpClient.y, 0, 0, SWP_MOVE);
|
---|
1238 | }/* while */
|
---|
1239 | WinEndEnumWindows(hEnum);
|
---|
1240 |
|
---|
1241 | lpoTemp=lpoObjectList;
|
---|
1242 | for(a=ulNumObjects;a>0 && lpoTemp; a--)
|
---|
1243 | {
|
---|
1244 | /* Create Buttons */
|
---|
1245 | if((hwndTemp=WinCreateWindow(hwndLaunchPad, WC_BUTTON, lpoTemp->chrName, WS_VISIBLE, xButtonOffset+(a-1)*(swp.cy+xButtonDelta), 1, swp.cy-2, swp.cy-2,
|
---|
1246 | hwndLaunchPad, HWND_TOP, a*100,
|
---|
1247 | NULLHANDLE, NULLHANDLE))!=NULLHANDLE)
|
---|
1248 | {
|
---|
1249 | /* Change Style to mini icon */
|
---|
1250 | ulStyle=WinQueryWindowULong(hwndTemp,QWL_STYLE);
|
---|
1251 | ulStyle|=(BS_MINIICON);
|
---|
1252 | ulStyle&=~BS_TEXT;
|
---|
1253 | if(WinSetWindowULong(hwndTemp,QWL_STYLE,ulStyle)) {
|
---|
1254 | memset(&btCtrl,0,sizeof(btCtrl));
|
---|
1255 | btCtrl.cb=sizeof(btCtrl);
|
---|
1256 | btCtrl.hImage=lpoTemp->hPtr;
|
---|
1257 | memset(&wndParams,0,sizeof(wndParams));
|
---|
1258 | wndParams.fsStatus=WPM_CTLDATA;
|
---|
1259 | wndParams.cbCtlData=btCtrl.cb;
|
---|
1260 | wndParams.pCtlData=&btCtrl;
|
---|
1261 | WinSendMsg(hwndTemp,WM_SETWINDOWPARAMS,
|
---|
1262 | MPFROMP(&wndParams),0);
|
---|
1263 | /* Subclass button for flyover help */
|
---|
1264 | oldButtonProc2=WinSubclassWindow(hwndTemp, newLaunchPadButtonProc);
|
---|
1265 | /* Set the class pointer into the window words */
|
---|
1266 | WinSetWindowULong(hwndTemp,QWL_USER,(ULONG)lpoTemp);//Save object ptr.
|
---|
1267 | }
|
---|
1268 | }
|
---|
1269 | lpoTemp=lpoTemp->lpoNext;
|
---|
1270 | }
|
---|
1271 | return TRUE;
|
---|
1272 | }
|
---|
1273 |
|
---|
1274 |
|
---|
1275 |
|
---|