source: trunk/classes/c/c_mm/mmfolder.c

Last change on this file was 141, checked in by gyoung, 19 months ago

Merged changes from Lar's branch

File size: 48.0 KB
Line 
1/*
2 * (C) Chris Wohlgemuth 2002-2004
3 *
4 */
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20/*
21 * If you need another license for your project/product (commercial,
22 * noncommercial, whatever) contact me at
23 *
24 * http://www.os2world.com/cdwriting
25 * http://www.geocities.com/SiliconValley/Sector/5785/
26 *
27 */
28/*
29 * This file was generated by the SOM Compiler and Emitter Framework.
30 * Generated using:
31 * SOM Emitter emitctm: 2.42
32 */
33
34#ifndef SOM_Module_mmfolder_Source
35#define SOM_Module_mmfolder_Source
36#endif
37#define MMFolder_Class_Source
38#define M_MMFolder_Class_Source
39
40#define INCL_GPIBITMAPS
41#define INCL_PM
42#define INCL_DOSMODULEMGR
43#define INCL_WINPOINTERS
44#define INCL_DOS
45#include <os2.h>
46#include <stdio.h>
47#include "helpid.h"
48#include "mmfolder.ih"
49/* Include file with definition for WPShadow class */
50#include "wpshadow.h"
51#include "cwimage.h"
52//#include "cwmmres.h"
53#include "mmres.h"
54#include "cwbmp.h"
55#include "cwaudioinc.h"
56#include "mmfolderinc.h"
57#include "except.h"
58#include "som_wps_funcs.h"
59#include "sys_funcs.h"
60
61#define STOREWINDOWID 112233
62
63//#define DEBUG
64
65void writeLog(const char* chrFormat, ...);
66BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
67HMODULE queryModuleHandle(void);
68HMODULE queryResModuleHandle(void);
69SHORT menuInsertMenuItem( HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition, int iID, char * chrText);
70MRESULT menuInsertMenuSeparator(HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition );
71
72WPObject* somGetFileSystemObject(WPObject* wpObject);
73void SysWriteToTrapLog(const char* chrFormat, ...);
74
75static SOMClass * queryWpFolderClass(void)
76{
77 somId mySomId;
78 static SOMClass * mWPFolderClass=NULLHANDLE;
79
80 if(!mWPFolderClass) {
81 if((mySomId=somIdFromString("WPFolder"))!=NULLHANDLE) {
82 mWPFolderClass=(SOMClass*)_somClassFromId(SOMClassMgrObject, mySomId);
83 SOMFree(mySomId);
84 }
85 }
86 return mWPFolderClass;
87}
88
89/* Now using IBM names as of V0.2.4 */
90static SOMClass* queryCWImageFileClass(void)
91{
92 somId mySomId;
93 static SOMClass *mWPImgClass=NULL;
94
95 if(!mWPImgClass) {
96 if((mySomId=somIdFromString("MMImage"))!=NULLHANDLE) {
97 mWPImgClass=(SOMClass*)_somClassFromId(SOMClassMgrObject, mySomId);
98 SOMFree(mySomId);
99 }
100 }
101 return mWPImgClass;
102}
103
104/* Bitmap class */
105static SOMClass* queryCWBitmapFileClass(void)
106{
107 somId mySomId;
108 static SOMClass *mWPImgClass=NULL;
109
110 if(!mWPImgClass) {
111 if((mySomId=somIdFromString("MMBitmap"))!=NULLHANDLE) {
112 mWPImgClass=(SOMClass*)_somClassFromId(SOMClassMgrObject, mySomId);
113 SOMFree(mySomId);
114 }
115 }
116 return mWPImgClass;
117}
118
119MRESULT EXPENTRY mmFolderContainerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
120{
121 HWND hwndStore;
122 MMFolder *somSelf;
123
124
125 //writeLog("Msg: 0x%x, MPARM1: 0x%x, MPARM2: 0x%x\n", msg, mp1, mp2);
126 switch(msg)
127 {
128 // case CM_QUERYDRAGIMAGE:
129 // DosBeep(5000,150);
130 // break;
131 // return NULLHANDLE;
132 case CM_SETCNRINFO:
133 {
134 /* Make sure CNR stays ownerdrawn even when user changes view */
135 PCNRINFO pCnrInfo=(PCNRINFO)PVOIDFROMMP(mp1);
136
137 if(pCnrInfo) {
138 // writeLog("flWindowAttr: 0x%x, Mask: 0x%x, cxTreeIndent: %d, cyLineSpacing: %d\n",
139 // pCnrInfo->flWindowAttr, LONGFROMMP(mp2), pCnrInfo->cxTreeIndent, pCnrInfo->cyLineSpacing);
140
141 if(!(pCnrInfo->flWindowAttr & (CV_DETAIL|CV_TREE/*|CV_ICON|CV_NAME*/)) &&
142 (LONGFROMMP(mp2)&CMA_FLWINDOWATTR)) {
143 HWND hwndFrame=WinQueryWindow(hwnd, QW_PARENT);
144 // writeLog("Accepted, flWindowAttr: 0x%x, Mask: 0x%x\n", pCnrInfo->flWindowAttr, LONGFROMMP(mp2));
145 if((hwndStore=WinWindowFromID(hwndFrame, STOREWINDOWID))!=NULLHANDLE)
146 {
147 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
148 if(somIsObj(somSelf)) {
149 MMFolderData *somThis = MMFolderGetData(somSelf);
150
151 pCnrInfo->flWindowAttr&=~CA_DRAWICON;
152 pCnrInfo->flWindowAttr|=CA_DRAWBITMAP|CA_OWNERDRAW;
153 pCnrInfo->slBitmapOrIcon.cx=_ulCurrentSize;
154 pCnrInfo->slBitmapOrIcon.cy=_ulCurrentSize;
155
156 mp2=MPFROMLONG(LONGFROMMP(mp2)|CMA_SLBITMAPORICON|CMA_FLWINDOWATTR);
157 }
158 }
159 }
160 else
161 {
162 if(pCnrInfo->flWindowAttr & (CV_DETAIL|CV_TREE)) {
163 // writeLog("Accepted, flWindowAttr: 0x%x, Mask: 0x%x\n", pCnrInfo->flWindowAttr, LONGFROMMP(mp2));
164 pCnrInfo->flWindowAttr&=~(CA_OWNERDRAW|CA_DRAWBITMAP);
165 pCnrInfo->flWindowAttr|=CA_DRAWICON;
166 pCnrInfo->slBitmapOrIcon.cx=0;
167 pCnrInfo->slBitmapOrIcon.cy=0;
168
169 mp2=MPFROMLONG(LONGFROMMP(mp2)|CMA_SLBITMAPORICON);
170 }
171 }
172 }
173 break;
174 }
175 default:
176 break;
177 }
178 /* Any other message is handled by the folder container procedure */
179 if((hwndStore=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
180 {
181 if((hwndStore=WinWindowFromID(hwndStore, STOREWINDOWID))!=NULLHANDLE)
182 {
183 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
184 if(somIsObj(somSelf)) {
185 MMFolderData *somThis = MMFolderGetData(somSelf);
186 if(_oldContainerProc)
187 return _oldContainerProc(hwnd, msg, mp1, mp2);
188 }
189 }
190 }
191 return WinDefWindowProc(hwnd, msg, mp1, mp2);
192}
193
194
195/* This function draws a two coloured 1 pixel border. It's used to draw the outmost
196 line of any 3D element like buttons. */
197static BOOL cwDraw2ColorBorder(HPS hps, RECTL *rcl, ULONG color1, ULONG color2)
198{
199
200 POINTL ptl=*((PPOINTL)rcl);
201
202 GpiMove(hps, &ptl);
203 GpiSetColor(hps, color1);
204 ptl.x=rcl->xRight;
205 GpiLine(hps,&ptl);
206 ptl.y=rcl->yTop;
207 GpiLine(hps,&ptl);
208 ptl.x-=1;
209 GpiMove(hps, &ptl);
210 GpiSetColor(hps, color2);
211 ptl.x=rcl->xLeft;
212 GpiLine(hps,&ptl);
213 ptl.y=rcl->yBottom+1;
214 GpiLine(hps,&ptl);
215 return TRUE;
216}
217
218
219static void cwAdjustIconRECTL(RECTL * rcl, ULONG ulMaxIconWidth, ULONG ulWidthBMP, ULONG ulHeightBMP)
220{
221 if(!rcl)
222 return;
223
224 rcl->xLeft+=2;
225 if(ulMaxIconWidth>ulWidthBMP)
226 rcl->xLeft+=(ulMaxIconWidth-ulWidthBMP)/2;
227 rcl->xRight=rcl->xLeft+ulWidthBMP;
228 rcl->yBottom+=2;
229 if(ulMaxIconWidth>ulHeightBMP)
230 rcl->yBottom+=(ulMaxIconWidth-ulHeightBMP)/2;
231 rcl->yTop=rcl->yBottom+ulHeightBMP;///ulFact;
232}
233
234/*
235 This function draws the template (but not the icon) if the object is a template.
236 */
237static ULONG mfldrDrawTemplate(WPObject* wpObject, RECTL* rcl, HPS hps, ULONG flCnr)
238{
239 HPOINTER hptrTemplate;
240 HMODULE hmodTemplate;
241
242 if(!DosQueryModuleHandle("PMWP",&hmodTemplate))
243 {
244 ULONG ulIconSize;
245
246 hptrTemplate=WinLoadPointer(HWND_DESKTOP, hmodTemplate, 20);
247 WinDrawPointer(hps, rcl->xLeft, rcl->yBottom, hptrTemplate, (flCnr & CV_MINI ? DP_MINI:DP_NORMAL));
248 WinDestroyPointer(hptrTemplate);
249 if((ulIconSize=WinQuerySysValue(HWND_DESKTOP,SV_CXICON))!=0)
250 {
251 ulIconSize=(rcl->xRight-rcl->xLeft-ulIconSize/2)/2;
252 rcl->xLeft+=ulIconSize/2;
253 rcl->yBottom+=ulIconSize;
254 }
255 return DP_MINI;
256 }
257
258 return DP_NORMAL;
259}
260
261
262MRESULT EXPENTRY mmFolderFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
263{
264 HWND hwndStore;
265 MMFolder *somSelf;
266
267 switch(msg)
268 {
269 /************************************************/
270 /* Draw the icons */
271 /************************************************/
272 case WM_DRAWITEM:
273 {
274 POWNERITEM pOwnerItem=(POWNERITEM)PVOIDFROMMP(mp2);
275
276
277 /* We only draw icons not text */
278 if(pOwnerItem->idItem==CMA_ICON /*&& !bNot*/) {
279 PMINIRECORDCORE mrc=(PMINIRECORDCORE)((PCNRDRAWITEMINFO)pOwnerItem->hItem)->pRecord;
280 RECTL rclTemp=pOwnerItem->rclItem;
281 HWND hwndCnr=WinWindowFromID(hwnd, FID_CLIENT);
282 PCNRDRAWITEMINFO pCnrDrawItemInfo=(PCNRDRAWITEMINFO)pOwnerItem->hItem;
283 CNRINFO cnrInfo;
284 ULONG flCnr;
285
286 if(WinSendMsg(hwndCnr, CM_QUERYCNRINFO,MPFROMP(&cnrInfo), MPFROMLONG(sizeof(cnrInfo))))
287 flCnr=cnrInfo.flWindowAttr;
288
289 /*
290 Draw emphasis if any. Otherwise draw white background.
291 */
292 rclTemp.xLeft+=2;
293 rclTemp.xRight-=2;
294 rclTemp.yBottom+=2;
295 rclTemp.yTop-=2;
296 /* Check if record is selected and in use */
297 if((pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE)
298 && (pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_SELECTED)) {
299 POINTL pointl;
300
301 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_WHITE);
302 GpiSetPattern(pOwnerItem->hps,PATSYM_DIAG2);
303 pointl.x = rclTemp.xLeft;
304 pointl.y = rclTemp.yBottom;
305 GpiMove(pOwnerItem->hps, &pointl);
306 pointl.x = rclTemp.xRight - 1;
307 pointl.y = rclTemp.yTop - 1;
308 GpiSetColor(pOwnerItem->hps, CLR_BLACK);
309 GpiBox(pOwnerItem->hps,DRO_FILL,&pointl,1,1);
310
311 }
312 /* Check if record is in use */
313 else if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE) {
314 POINTL pointl;
315
316 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_WHITE);
317 GpiSetPattern(pOwnerItem->hps,PATSYM_DIAG1);
318 pointl.x = rclTemp.xLeft;
319 pointl.y = rclTemp.yBottom;
320 GpiMove(pOwnerItem->hps, &pointl);
321 pointl.x = rclTemp.xRight - 1;
322 pointl.y = rclTemp.yTop - 1;
323 GpiSetColor(pOwnerItem->hps, CLR_BLACK);
324 GpiBox(pOwnerItem->hps,DRO_FILL,&pointl,1,1);
325 }
326 /* or is it only selected? */
327 else if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_SELECTED)
328 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_DARKGRAY);
329 /* Default is paint white background */
330 else
331 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_WHITE);
332 /* Emphasis drawn */
333
334 /********************************************/
335 /* */
336 /* Draw the image */
337 /* */
338 /********************************************/
339 if(mrc){
340 WPObject *wpObject;
341 ULONG ulIconSize=150;/* Default if query fails */
342
343 wpObject=(WPObject*)OBJECT_FROM_PREC(mrc); // Get object
344 wpObject=somGetFileSystemObject(wpObject); // Get Filesystem object
345
346 if(somIsObj(wpObject) && _wpIsObjectInitialized(wpObject)) {
347 SOMClass* cwBitmapClass=queryCWBitmapFileClass();
348 SOMClass* cwImageClass=queryCWImageFileClass();
349
350 /* Check if object is an image or bitmap class. If yes paint the bitmap as
351 an icon. Only templates keep their normal icon. */
352 if((somIsObj(cwImageClass)||somIsObj(cwBitmapClass)) && !(_wpQueryStyle(wpObject) & OBJSTYLE_TEMPLATE)) {
353 HBITMAP hbm=NULLHANDLE;
354 PBITMAPINFOHEADER2 pBmpInfoHeader2=NULLHANDLE;
355#ifdef DEBUG
356 SysWriteToTrapLog("Object is an image. (%s line: %d)\n", __FUNCTION__, __LINE__);
357#endif
358 /* Get object pointer of lighttable folder */
359 if((hwndStore=WinWindowFromID(hwnd, STOREWINDOWID))!=NULLHANDLE)
360 {
361 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
362 if(somIsObj(somSelf)) {
363 MMFolderData *somThis = MMFolderGetData(somSelf);
364 ulIconSize=_ulCurrentSize;
365 }
366 }
367
368 /* Get a small bitmap */
369 if(_somIsA(wpObject, cwImageClass)) {
370
371 /*
372 V0.2.8 (09.09.2003)
373
374 Only try to get the bitmap header when we were able to get the handle (we don't need it
375 without the handle anyway). Interestingly the _wpQueryBitmapInfoHeader() call blocks
376 when called without a loaded bitmap. It doesn't block on loading the image but when trying
377 to alloc mem for the header using _wpAllocMem(). Probably there's a race condition while
378 inserting the USAGE_MEMORY item while the folder tries to insert the USAGE_RECORD_ITEM.
379 Requesting the object mutex semaphor doesn't work by the way. The object will just block.
380 Maybe that's exactly happening with _wpAllocMem() here. Solution is not to use _wpAllocMem()
381 at all in the image classes.
382
383 Wondering what hidden problems/bugs will show upt in the future...
384 */
385 if((hbm=MMImage_cwmmQuerySmallBitmapHandle( (MMImage*) wpObject, ulIconSize, mrc, hwndCnr))!=NULLHANDLE)
386 pBmpInfoHeader2=(PBITMAPINFOHEADER2)_wpQueryBitmapInfoHeader((MMImage*)wpObject);
387#ifdef DEBUG
388 SysWriteToTrapLog("Queried HBITMAP: %x (line: %d)\n", hbm, __LINE__);
389#endif
390
391 } /* somIsA( , cwImageClass) */
392 else if(_somIsA(wpObject, cwBitmapClass)) {
393 /* The default WPS bitmap class (WPBitmap) returns an PBITMAPHEADER. The CWBitmap class
394 does return a PBITMAPHEADER2<-. */
395 if((hbm=MMBitmap_cwmmQuerySmallBitmapHandle( (MMBitmap*) wpObject, ulIconSize))!=NULLHANDLE)
396 pBmpInfoHeader2=(PBITMAPINFOHEADER2)_cwmmQueryBitmapInfoHeader((MMBitmap*)wpObject);
397 }
398
399 if(hbm)
400 {
401 /* We have the small bitmap */
402 if(pBmpInfoHeader2) {
403 ULONG ulWidth, ulHeight;
404 ULONG ulIconWidth;
405 ULONG ulFact;
406 RECTL rcl=pOwnerItem->rclItem;
407
408 if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
409 ulWidth=pBmpInfoHeader2->cx;
410 ulHeight=pBmpInfoHeader2->cy;
411 }
412 else {
413 PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
414 ulWidth=pBmpInfoHeader->cx;
415 ulHeight=pBmpInfoHeader->cy;
416 }
417
418 ulIconWidth=rcl.xRight-rcl.xLeft-4;
419 ulFact=ulWidth>ulHeight ? ulWidth*1000/ulIconWidth : ulHeight*1000/ulIconWidth;
420 ulWidth=ulWidth*1000/ulFact;
421 ulHeight=ulHeight*1000/ulFact;
422 cwAdjustIconRECTL(&rcl, ulIconWidth, ulWidth, ulHeight);
423 /* And now draw the bitmap */
424#if 0
425 if(pBmpInfoHeader2->cclrUsed==2) {
426 WinDrawBitmap(pOwnerItem->hps, hbm, NULL, (PPOINTL)&rcl,//pOwnerItem->rclItem,
427 CLR_WHITE, CLR_BLACK, DBM_STRETCH /*| DBM_IMAGEATTRS*/);
428 }
429 else
430#endif
431 WinDrawBitmap(pOwnerItem->hps, hbm, NULL, (PPOINTL)&rcl,//pOwnerItem->rclItem,
432 CLR_WHITE, CLR_BLACK, DBM_STRETCH /*| DBM_IMAGEATTRS*/);
433 }
434
435 /* Draw a small border around the image */
436 cwDraw2ColorBorder(pOwnerItem->hps, &rclTemp, CLR_BLACK, CLR_DARKGRAY);
437 /* Done */
438 if(_somIsA(wpObject, cwImageClass)) {
439 MMImage_cwmmFreeSmallBitmap((MMImage *)wpObject);
440 }
441 else {
442 MMBitmap_cwmmFreeSmallBitmap((MMBitmap*)wpObject);
443 }
444 return (MRESULT) TRUE;
445 }/* hbm */
446 }/* cwImageClass/cwBitmapClass */
447
448 /****************************************************/
449 /*** It's not an image class. Draw normal pointer ***/
450 /****************************************************/
451 if((ulIconSize=WinQuerySysValue(HWND_DESKTOP,SV_CXICON))!=0)
452 {
453 ULONG ulWidth=ulIconSize;
454 ULONG ulHeight=ulIconSize;
455 ULONG ulIconWidth;
456 RECTL rcl=pOwnerItem->rclItem;
457 ULONG ulMiniOrNormal=(flCnr & CV_MINI ? DP_MINI:DP_NORMAL);
458 BOOL fIsTemplate=_wpQueryStyle(wpObject) & OBJSTYLE_TEMPLATE;
459
460 ulIconWidth=rcl.xRight-rcl.xLeft-4;
461 /* Move the icon into the middle of the drawing area */
462 cwAdjustIconRECTL(&rcl, ulIconWidth, ulWidth, ulHeight);
463
464 /* Draw the template background if necessary */
465 if(fIsTemplate) {
466 mfldrDrawTemplate(wpObject, &rcl, pOwnerItem->hps, flCnr);
467 if(flCnr&CV_MINI)
468 return (MRESULT) TRUE;
469 ulMiniOrNormal=DP_MINI;
470 }
471
472 /* Check for folder because of animated icon */
473 if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE)
474 {
475 SOMClass* wpFolderClass=queryWpFolderClass();
476
477 if(somIsObj(wpFolderClass)) {
478 if(_somIsA(wpObject, wpFolderClass)) {
479 /* It's a folder */
480 HPOINTER hptr;
481
482 pOwnerItem->rclItem.xLeft=rcl.xLeft;
483 pOwnerItem->rclItem.yBottom=rcl.yBottom;
484
485 /* The following is only for Warp 4 but Warp 3 isn't supported anyway...*/
486 hptr=_wpQueryIconN(wpObject,1);
487 if(WinDrawPointer(pOwnerItem->hps, rcl.xLeft, rcl.yBottom, hptr, ulMiniOrNormal)) {
488 cwDraw2ColorBorder(pOwnerItem->hps, &rclTemp, CLR_BLACK, CLR_DARKGRAY);
489 return (MRESULT) TRUE;
490 }
491
492 }
493 }/* if(somIsObj(wpFolderClass)) */
494 }/* if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE) */
495
496 if(WinDrawPointer(pOwnerItem->hps, rcl.xLeft, rcl.yBottom, mrc->hptrIcon, ulMiniOrNormal)) {
497 cwDraw2ColorBorder(pOwnerItem->hps, &rclTemp, CLR_BLACK, CLR_DARKGRAY);
498 return (MRESULT) TRUE;
499 }
500 }/* if((ulIconSize=WinQuerySysValue(HWND_DESKTOP,SV_CXICON))!=0) */
501
502 }/* somIsObj(wpObject)*/
503 }/* mrc */
504 }/* if(pOwnerItem->idItem==CMA_ICON) */
505 else if(pOwnerItem->idItem==0) {
506 /*************************/
507 /* It's the details view */
508 /*************************/
509 PCNRDRAWITEMINFO pCnrDrawItemInfo=(PCNRDRAWITEMINFO)pOwnerItem->hItem;
510
511 if(pCnrDrawItemInfo && pCnrDrawItemInfo->pFieldInfo->flData & CFA_BITMAPORICON) {
512 PMINIRECORDCORE mrc=(PMINIRECORDCORE)((PCNRDRAWITEMINFO)pOwnerItem->hItem)->pRecord;
513 if(mrc){
514 WPObject *wpObjToRefresh;
515 WPObject *wpObject;
516 ULONG ulIconSize=150;/* Default if query fails */
517 HWND hwndCnr=WinWindowFromID(hwnd, FID_CLIENT);
518 RECTL rclTemp=pOwnerItem->rclItem;
519
520 wpObjToRefresh=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
521 wpObject=somGetFileSystemObject(wpObjToRefresh);
522
523 /* Draw Background */
524 rclTemp.xLeft+=2;
525 rclTemp.xRight-=2;
526 rclTemp.yBottom+=2;
527 rclTemp.yTop-=2;
528
529 /* Check if record is selected and in use... */
530 if((pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE)
531 && (pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_SELECTED)) {
532 POINTL pointl;
533
534 GpiSetPattern(pOwnerItem->hps,PATSYM_DIAG2);
535 pointl.x = rclTemp.xLeft;
536 pointl.y = rclTemp.yBottom;
537 GpiMove(pOwnerItem->hps, &pointl);
538 pointl.x = rclTemp.xRight - 1;
539 pointl.y = rclTemp.yTop - 1;
540 GpiSetColor(pOwnerItem->hps, CLR_BLACK);
541 GpiBox(pOwnerItem->hps,DRO_FILL,&pointl,1,1);
542
543 }
544 /* or only in use... */
545 else if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_INUSE) {
546 POINTL pointl;
547
548 GpiSetPattern(pOwnerItem->hps,PATSYM_DIAG1);
549 pointl.x = rclTemp.xLeft;
550 pointl.y = rclTemp.yBottom;
551 GpiMove(pOwnerItem->hps, &pointl);
552 pointl.x = rclTemp.xRight - 1;
553 pointl.y = rclTemp.yTop - 1;
554 GpiSetColor(pOwnerItem->hps, CLR_BLACK);
555 GpiBox(pOwnerItem->hps,DRO_FILL,&pointl,1,1);
556 }
557 /* or only selected. */
558 else if(pCnrDrawItemInfo->pRecord->flRecordAttr & CRA_SELECTED)
559 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_DARKGRAY);
560 else /* default is a white background */
561 WinFillRect(pOwnerItem->hps, &rclTemp, CLR_WHITE);
562
563 if(somIsObj(wpObject) && _wpIsObjectInitialized(wpObject)) {
564 SOMClass* cwBitmapClass=queryCWBitmapFileClass();
565 SOMClass* cwImageClass=queryCWImageFileClass();
566
567 if(somIsObj(cwImageClass)||somIsObj(cwBitmapClass)) {
568 HBITMAP hbm=NULLHANDLE;
569 PBITMAPINFOHEADER2 pBmpInfoHeader2;
570
571 /* Query object pointer */
572 if((hwndStore=WinWindowFromID(hwnd, STOREWINDOWID))!=NULLHANDLE)
573 {
574 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
575 if(somIsObj(somSelf)) {
576 MMFolderData *somThis = MMFolderGetData(somSelf);
577 ulIconSize=_ulCurrentSize;
578 }
579 }
580 /* Get the small bitmap from the object */
581 if(_somIsA(wpObject, cwImageClass)) {
582 hbm=MMImage_cwmmQuerySmallBitmapHandle( (MMImage*) wpObject, ulIconSize, mrc, hwndCnr);
583 pBmpInfoHeader2=(PBITMAPINFOHEADER2)_wpQueryBitmapInfoHeader((MMImage*)wpObject);
584 }
585 else if(_somIsA(wpObject, cwBitmapClass)) {
586 hbm=MMBitmap_cwmmQuerySmallBitmapHandle( (MMBitmap*) wpObject, ulIconSize);
587 pBmpInfoHeader2=(PBITMAPINFOHEADER2)_cwmmQueryBitmapInfoHeader((MMBitmap*)wpObject);
588 }
589 if(hbm)
590 {
591 /* We got a small bitmap for display */
592 if(pBmpInfoHeader2) {
593 ULONG ulWidth, ulHeight;
594 ULONG ulIconHeight, ulIconWidth; /* size of drawing area on screen */
595 ULONG ulFact;
596 RECTL rcl=pOwnerItem->rclItem;
597
598 /* Get size of bitmap */
599 if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
600 ulWidth=pBmpInfoHeader2->cx;
601 ulHeight=pBmpInfoHeader2->cy;
602 }
603 else {
604 /* The default WPS bitmap class returned PBITMAPINFOHEADER */
605 PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
606 ulWidth=pBmpInfoHeader->cx;
607 ulHeight=pBmpInfoHeader->cy;
608 }
609
610 /* Calculate size of drawing area */
611 ulIconHeight=rcl.yTop-rcl.yBottom;
612 ulIconWidth=rcl.xRight-rcl.xLeft;
613 /* Calculate scaling factor for bitmap so aspect ratio is kept */
614 ulFact=ulWidth>ulHeight ? ulWidth*1000/ulIconHeight : ulHeight*1000/ulIconHeight;
615 ulWidth=ulWidth*1000/ulFact;
616 ulHeight=ulHeight*1000/ulFact;
617 /* Adjust x pos. Cx is greater than cy in details view. */
618 if(ulIconWidth>ulWidth)
619 rcl.xLeft+=(ulIconWidth-ulWidth)/2;
620 else {
621 ulWidth=ulIconWidth-2;
622 rcl.xLeft+=(ulIconWidth-ulWidth)/2;
623 }
624 rcl.xRight=rcl.xLeft+ulWidth;
625 /* Adjust y pos */
626 if(ulIconHeight>ulHeight)
627 rcl.yBottom+=(ulIconHeight-ulHeight)/2;
628 else {
629 ulHeight=ulIconHeight-2;
630 rcl.yBottom+=(ulIconHeight-ulHeight)/2;
631 }
632 rcl.yTop=rcl.yBottom+ulHeight;///ulFact;
633 /* And now draw the bitmap */
634 WinDrawBitmap(pOwnerItem->hps, hbm, NULL, (PPOINTL)&rcl,//pOwnerItem->rclItem,
635 CLR_WHITE, CLR_BLACK, DBM_STRETCH /*|DBM_IMAGEATTRS*/);
636 }
637 if(_somIsA(wpObject, cwImageClass)) {
638 MMImage_cwmmFreeSmallBitmap((MMImage *)wpObject);
639 }
640 else {
641 MMBitmap_cwmmFreeSmallBitmap((MMBitmap*)wpObject);
642 }
643 return (MRESULT) TRUE;
644 }/* hbm */
645 }/* cwImageClass */
646 }/* wpObject*/
647 /* It's not an image class. Draw normal pointer */
648 break;
649 }/* if(mrc) */
650 }/* if(pCnrDrawItemInfo && pCnrDrawItemInfo->pFieldInfo->flData & CFA_BITMAPORICON) */
651 }/* Details view */
652 break;
653 }
654#if 0
655 case WM_CONTROL:
656 if(SHORT2FROMMP(mp1)==CN_INITDRAG)
657 {
658 PCNRDRAGINIT pcnrInit=PVOIDFROMMP(mp2);
659 pcnrInit->cx=-20;
660 pcnrInit->cy=-20;
661 // if( pcnrInit->pRecord->cb==sizeof(MINIRECORDCORE))
662 // pcnrInit->cx+=75;
663 // pcnrInit->cy+=75;
664 //DosBeep(5000, 100);
665 }
666 break;
667
668 case WM_CONTROL:
669 if(SHORT2FROMMP(mp1)==CN_DRAGOVER)
670 {
671 PCNRDRAGINFO pcnrDragInfo=PVOIDFROMMP(mp2);
672
673 DrgSetDragInfo(pcnrDragInfo->pDragInfo, pdimage, 1, NULLHANDLE);
674 // if( pcnrInit->pRecord->cb==sizeof(MINIRECORDCORE))
675 // pcnrInit->cx+=75;
676 // pcnrInit->cy+=75;
677 DosBeep(5000, 20);
678 }
679 break;
680#endif
681 case WM_INITMENU:
682 if((hwndStore=WinWindowFromID(hwnd, STOREWINDOWID))!=NULLHANDLE)
683 {
684 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
685 if(somIsObj(somSelf)) {
686 MMFolderData *somThis = MMFolderGetData(somSelf);
687 switch(_usLastSelMenuItem)
688 {
689 case 0x2d1:/* view menu */
690 {
691 char text[CCHMAXPATH];
692 MENUITEM mi;
693 HWND hwndMenu;
694 CNRINFO cnrInfo;
695
696 /* Insert size menu only in icon view */
697 if(WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT),CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
698 MPFROMSHORT(sizeof(cnrInfo)))) {
699
700 if((cnrInfo.flWindowAttr & CV_ICON) && !(cnrInfo.flWindowAttr & CV_TREE)) {
701 /* insert separator */
702 menuInsertMenuSeparator( HWNDFROMMP(mp2), NULLHANDLE, MIT_END);
703
704 /* Load the menu from the resource */
705 hwndMenu=WinLoadMenu(hwnd,queryResModuleHandle(), ID_MENUICONSIZE);
706
707 /* Fill the MENUITEM structure */
708 mi.iPosition=MIT_END;
709 mi.afStyle=MIS_TEXT|MIS_SUBMENU;
710 mi.id=ID_MENUICONSIZE;
711 mi.afAttribute=NULLHANDLE;
712 mi.hwndSubMenu=hwndMenu;
713 mi.hItem=NULLHANDLE;
714 if(!getMessage(text, IDSTR_ICONSIZEMENU, sizeof(text), queryResModuleHandle(), hwnd))
715 strcpy(text, "Icon ~size");;
716 menuInsertMenuItem(HWNDFROMMP(mp2), hwndMenu, MIT_END, ID_MENUICONSIZE, text);
717
718 /* check current menuitem */
719 switch(_ulCurrentSize)
720 {
721 case 0:
722 WinCheckMenuItem(hwndMenu, ID_NORMALICONSITEM, TRUE);
723 break;
724 case 50:
725 WinCheckMenuItem(hwndMenu, ID_50X50ITEM, TRUE);
726 break;
727 case 100:
728 WinCheckMenuItem(hwndMenu, ID_100X100ITEM, TRUE);
729 break;
730 case 150:
731 WinCheckMenuItem(hwndMenu, ID_150X150ITEM, TRUE);
732 break;
733 case 200:
734 WinCheckMenuItem(hwndMenu, ID_200X200ITEM, TRUE);
735 break;
736 case 250:
737 WinCheckMenuItem(hwndMenu, ID_250X250ITEM, TRUE);
738 break;
739 default:
740 break;
741 }
742 }
743 }/* if() */
744 break;
745 }/* case 0x2d1 */
746 default:
747 break;
748 }
749 }
750 }
751 break;
752 case WM_MENUSELECT:
753 if((hwndStore=WinWindowFromID(hwnd, STOREWINDOWID))!=NULLHANDLE)
754 {
755 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
756 if(somIsObj(somSelf)) {
757 MMFolderData *somThis = MMFolderGetData(somSelf);
758 _usLastSelMenuItem=SHORT1FROMMP(mp1);
759 }
760 }
761 break;
762 default:
763 break;
764 }
765 /* Any other message is handled by the folder container procedure */
766 if((hwndStore=WinWindowFromID(hwnd, STOREWINDOWID))!=NULLHANDLE)
767 {
768 somSelf=(MMFolder*) WinQueryWindowULong(hwndStore,QWL_USER);
769 if(somIsObj(somSelf)) {
770 MMFolderData *somThis = MMFolderGetData(somSelf);
771 if(_oldFrameProc)
772 return _oldFrameProc(hwnd, msg, mp1, mp2);
773 }
774 }
775
776 return WinDefWindowProc(hwnd, msg, mp1, mp2);
777}
778
779/*
780 * wpSetupOnce :override;
781 */
782
783SOM_Scope HWND SOMLINK mmfldr_wpOpen(MMFolder *somSelf, HWND hwndCnr,
784 ULONG ulView, ULONG param)
785{
786 HWND hwnd;
787
788 MMFolderData *somThis = MMFolderGetData(somSelf);
789 MMFolderMethodDebug("MMFolder","mmfldr_wpOpen");
790
791 hwnd=(MMFolder_parent_WPFolder_wpOpen(somSelf, hwndCnr,
792 ulView, param));
793
794 /* Only subclass folder frames, not settings notebooks */
795 if(ulView!=OPEN_SETTINGS){
796 HWND hwndStore;
797
798 if((hwndStore=WinCreateWindow(hwnd, WC_STATIC, "objectStore", 0, 0,0,0,0,
799 hwnd, HWND_BOTTOM, STOREWINDOWID, NULLHANDLE, NULLHANDLE))!=NULLHANDLE)
800 {
801 HWND hwndContainer;
802
803 WinSetWindowULong(hwndStore, QWL_USER, (ULONG)somSelf);
804 _oldFrameProc=WinSubclassWindow(hwnd, mmFolderFrameProc);
805
806 if(hwnd)
807 {
808 CNRINFO cnrInfo;
809 HWND hwndContainer=WinWindowFromID(hwnd,FID_CLIENT);
810
811 /* Change the containerflags */
812 if(WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
813 MPFROMSHORT(sizeof(cnrInfo))))
814 {
815 if(cnrInfo.flWindowAttr & CV_ICON) {
816 cnrInfo.slBitmapOrIcon.cx=_ulCurrentSize;
817 cnrInfo.slBitmapOrIcon.cy=_ulCurrentSize;
818 cnrInfo.flWindowAttr&=~CA_DRAWICON;
819 cnrInfo.flWindowAttr|=CA_DRAWBITMAP|CA_OWNERDRAW;
820 WinSendMsg(hwndContainer,CM_SETCNRINFO, MPFROMP(&cnrInfo),
821 MPFROMLONG(CMA_SLBITMAPORICON|CMA_FLWINDOWATTR));
822 }
823 }
824 }
825 /* Subclass container */
826 hwndContainer=WinWindowFromID(hwnd,FID_CLIENT);//Get container hwnd
827 if(hwndContainer) {
828 _oldContainerProc=WinSubclassWindow(hwndContainer, mmFolderContainerProc);
829 }
830 }
831 }
832 return hwnd;
833}
834
835#if 0
836SOM_Scope BOOL SOMLINK mmfldr_wpSetupOnce(MMFolder *somSelf,
837 PSZ pszSetupString)
838{
839 BOOL rc;
840
841 MMFolderData *somThis = MMFolderGetData(somSelf);
842 MMFolderMethodDebug("MMFolder","mmfldr_wpSetupOnce");
843
844 rc=(MMFolder_parent_WPFolder_wpSetupOnce(somSelf, pszSetupString));
845
846 _ulCurrentSize=MMFLDR_DEFAULT_ICONSIZE;
847#if 0
848 if(_ulCurrentSize!=0 && _ulCurrentSize%50==0)
849 {
850 char setup[200];
851 sprintf(setup, "ICONGRIDSIZE=%d;", _ulCurrentSize+15);
852 _wpSetup(somSelf,setup);
853 }
854
855 _wpSetup(somSelf,"DETAILSCLASS=MMImage;ICONVIEW=GRIDDED;SORTCLASS=MMImage;");
856#endif
857 return rc;
858}
859#endif
860
861SOM_Scope BOOL SOMLINK mmfldr_wpRestoreState(MMFolder *somSelf,
862 ULONG ulReserved)
863{
864 MMFolderData *somThis = MMFolderGetData(somSelf);
865 MMFolderMethodDebug("MMFolder","mmfldr_wpRestoreState");
866
867 /* Set default icon size */
868 if(!_wpRestoreLong(somSelf, "MMFolder", KEY_ICONSIZE, &_ulCurrentSize)) {
869 _ulCurrentSize=MMFLDR_DEFAULT_ICONSIZE;
870 }
871
872 return (MMFolder_parent_WPFolder_wpRestoreState(somSelf,
873 ulReserved));
874}
875
876SOM_Scope BOOL SOMLINK mmfldr_wpRestoreData(MMFolder *somSelf,
877 PSZ pszClass, ULONG ulKey,
878 PBYTE pValue, PULONG pcbValue)
879{
880 BOOL rc;
881 MMFolderData *somThis = MMFolderGetData(somSelf);
882 MMFolderMethodDebug("MMFolder","mmfldr_wpRestoreData");
883
884 rc= (MMFolder_parent_WPFolder_wpRestoreData(somSelf, pszClass,
885 ulKey, pValue,
886 pcbValue));
887 switch(ulKey)
888 {
889 case IDKEY_FDRGRIDINFO: /* 2938 Warp 4 and above */
890 /* Get address in instance data for grid spacing */
891 {
892 if(!stricmp(pszClass, "WPFolder"))
893 {
894 if(!pcbValue || *pcbValue!=8L || !pValue) /* Sanity check */
895 break;
896 _pulGridSpacing=(ULONG*)pValue;
897 }
898 break;
899 }
900 case IDKEY_FDRLONGARRAY: /* 2931 */
901 /* Get address in instance data for view */
902 {
903 if(!stricmp(pszClass, "WPFolder"))
904 {
905 if(!pcbValue || *pcbValue!=84L || !pValue) /* Sanity check */
906 break;
907 _pFldrLongArray=pValue;
908 }
909 break;
910 }
911 default:
912 break;
913 }
914 return rc;
915}
916
917SOM_Scope BOOL SOMLINK mmfldr_wpSaveState(MMFolder *somSelf)
918{
919 MMFolderData *somThis = MMFolderGetData(somSelf);
920 MMFolderMethodDebug("MMFolder","mmfldr_wpSaveState");
921
922 _wpSaveLong( somSelf, "MMFolder", KEY_ICONSIZE, _ulCurrentSize);
923
924 return (MMFolder_parent_WPFolder_wpSaveState(somSelf));
925}
926
927
928SOM_Scope BOOL SOMLINK mmfldr_wpSaveData(MMFolder *somSelf,
929 PSZ pszClass, ULONG ulKey,
930 PBYTE pValue, ULONG cbValue)
931{
932 PSZ psz;
933 MMFolderData *somThis = MMFolderGetData(somSelf);
934 MMFolderMethodDebug("MMFolder","mmfldr_wpSaveData");
935
936 /* When the template is created wpRestoreData() isn't called so we don't have
937 the address of the instance data containing grid spacing and view. So
938 we force the object to save the instance data and in wpSaveData we
939 finally get the right addresses to change the object view to gridded.
940 This change is done in wpObjectReady() where we called wpSaveImmediate(). */
941
942 /* If no ID result is NULL */
943 /*
944 @@CHANGE 0.2.8
945
946 Check ID for NULL to prevent crash in stricmp().
947 */
948 psz=_wpQueryObjectID(somSelf);
949 // if(!stricmp(_wpQueryObjectID(somSelf), "<MMPM2_MMFOLDERTEMPLATE>"))
950 if(psz && !stricmp(psz, "<MMPM2_MMFOLDERTEMPLATE>"))
951 {
952 switch(ulKey)
953 {
954 case IDKEY_FDRGRIDINFO: /* 2938 Warp 4 and above */
955 /* Get address in instance data for grid spacing */
956 {
957 if(!stricmp(pszClass, "WPFolder"))
958 {
959 /* if address is already known do nothing */
960 if(_pulGridSpacing || cbValue!=8L || !pValue) /* Sanity check */
961 break;
962 _pulGridSpacing=(ULONG*)pValue;
963 }
964 break;
965 }
966 case IDKEY_FDRLONGARRAY: /* 2931 */
967 /* Get address in instance data for view */
968 {
969 if(!stricmp(pszClass, "WPFolder"))
970 {
971 /* if address is already known do nothing */
972 if(_pFldrLongArray || cbValue!=84L || !pValue) /* Sanity check */
973 break;
974 _pFldrLongArray=pValue;
975 //DosBeep(500, 200);
976 }
977 break;
978 }
979 default:
980 break;
981 }
982 }
983
984 return (MMFolder_parent_WPFolder_wpSaveData(somSelf, pszClass,
985 ulKey, pValue,
986 cbValue));
987}
988
989SOM_Scope BOOL SOMLINK mmfldr_wpMenuItemSelected(MMFolder *somSelf,
990 HWND hwndFrame,
991 ULONG ulMenuId)
992{
993 CNRINFO cnrInfo;
994
995 MMFolderData *somThis = MMFolderGetData(somSelf);
996 MMFolderMethodDebug("MMFolder","mmfldr_wpMenuItemSelected");
997
998 if(ulMenuId>=0xbc01 && ulMenuId <=0xbc06) {
999 HWND hwndContainer=WinWindowFromID(hwndFrame, FID_CLIENT);
1000 /* Change the containerflags */
1001 if(WinSendMsg(hwndContainer, CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
1002 MPFROMSHORT(sizeof(cnrInfo))))
1003 {
1004 char text[200];
1005 CNRINFO cnrInfo2=cnrInfo;
1006
1007 switch(ulMenuId)
1008 {
1009 case ID_50X50ITEM:
1010 cnrInfo.slBitmapOrIcon.cx=50;
1011 break;
1012 case ID_100X100ITEM:
1013 cnrInfo.slBitmapOrIcon.cx=100;
1014 break;
1015 case ID_150X150ITEM:
1016 cnrInfo.slBitmapOrIcon.cx=150;
1017 break;
1018 case ID_200X200ITEM:
1019 cnrInfo.slBitmapOrIcon.cx=200;
1020 break;
1021 case ID_250X250ITEM:
1022 cnrInfo.slBitmapOrIcon.cx=250;
1023 break;
1024 default:
1025 cnrInfo.slBitmapOrIcon.cx=0;
1026 break;
1027 }
1028
1029 _ulCurrentSize=cnrInfo.slBitmapOrIcon.cx;
1030
1031 sprintf(text, "ICONGRIDSIZE=%d",cnrInfo.slBitmapOrIcon.cx+20);
1032 _wpSetup(somSelf, text);
1033
1034 cnrInfo.slBitmapOrIcon.cy=cnrInfo.slBitmapOrIcon.cx;
1035 cnrInfo.flWindowAttr&=~CA_DRAWICON;
1036 cnrInfo.flWindowAttr|=CA_DRAWBITMAP|CA_OWNERDRAW;
1037
1038 /* Prevent drawing in container */
1039 WinEnableWindowUpdate(hwndContainer, FALSE);
1040
1041 cnrInfo2=cnrInfo;
1042 cnrInfo2.flWindowAttr=CV_DETAIL;
1043 WinSendMsg(hwndContainer,CM_SETCNRINFO, MPFROMP(&cnrInfo2),
1044 MPFROMLONG(CMA_FLWINDOWATTR));
1045
1046 WinSendMsg(hwndContainer,CM_SETCNRINFO, MPFROMP(&cnrInfo),
1047 MPFROMLONG(CMA_SLBITMAPORICON|CMA_FLWINDOWATTR));
1048
1049 /* Set gridsize. The address is gathered in wp_RestoreData */
1050 if(_pulGridSpacing!=NULLHANDLE){
1051 *(_pulGridSpacing++)=_ulCurrentSize+MMFLDR_SPACINGDELTA_X;
1052 /* FIXME: Use fontsize */
1053 *(_pulGridSpacing--)=_ulCurrentSize+MMFLDR_SPACINGDELTA_Y;
1054 }
1055
1056 _wpSetup(somSelf, "MENUITEMSELECTED=716");/* Change to icon view */
1057 _wpSetup(somSelf, "MENUITEMSELECTED=309");/* Arrange */
1058
1059 WinEnableWindowUpdate(hwndContainer, TRUE);
1060 _wpSaveDeferred(somSelf);
1061 return TRUE;
1062 }
1063 }/* if() */
1064 return (MMFolder_parent_WPFolder_wpMenuItemSelected(somSelf,
1065 hwndFrame,
1066 ulMenuId));
1067}
1068
1069
1070/*
1071 *wpSetup:override;
1072 */
1073SOM_Scope void SOMLINK mmfldr_wpObjectReady(MMFolder *somSelf,
1074 ULONG ulCode, WPObject* refObject)
1075{
1076 MMFolderData *somThis = MMFolderGetData(somSelf);
1077 MMFolderMethodDebug("MMFolder","mmfldr_wpObjectReady");
1078
1079 MMFolder_parent_WPFolder_wpObjectReady(somSelf, ulCode, refObject);
1080
1081 switch(ulCode)
1082 {
1083 case OR_FROMTEMPLATE:
1084 case OR_NEW:
1085 {
1086 PSZ psz;
1087
1088 /* Only after creation */
1089#if 0
1090 if(_ulCurrentSize!=0 && _ulCurrentSize%50==0)
1091 {
1092 char setup[200];
1093 sprintf(setup, "ICONGRIDSIZE=%d;", _ulCurrentSize+15);
1094 _wpSetup(somSelf,setup);
1095 }
1096#endif
1097 /* Set default icon size */
1098 if(!_ulCurrentSize || _ulCurrentSize%50!=0)
1099 _ulCurrentSize=MMFLDR_DEFAULT_ICONSIZE;
1100
1101 /* If no ID result is NULL */
1102 psz=_wpQueryObjectID(somSelf);
1103 if(psz && !stricmp(psz, "<MMPM2_MMFOLDERTEMPLATE>")) {
1104 /* When the template is created wpRestoreData() isn't called so we don't have
1105 the address of the instance data containing grid spacing and view. So
1106 we force the object to save the instance data and in wpSaveData we
1107 finally get the right addresses to change the object view to gridded. */
1108
1109 _wpSaveImmediate(somSelf);
1110 /* Set default view to gridded */
1111
1112 if(_pFldrLongArray!=NULLHANDLE) {
1113 *_pFldrLongArray=0x80;
1114 //DosBeep(100, 200);
1115 }
1116 /* Set gridsize. The address is gathered in wp_RestoreData */
1117 if(_pulGridSpacing!=NULLHANDLE){
1118 *(_pulGridSpacing++)=_ulCurrentSize+MMFLDR_SPACINGDELTA_X;
1119 /* FIXME: Use fontsize */
1120 *(_pulGridSpacing--)=_ulCurrentSize+MMFLDR_SPACINGDELTA_Y;
1121 }
1122
1123 }
1124 break;
1125 }
1126 default:
1127 break;
1128 }
1129}
1130
1131SOM_Scope BOOL SOMLINK mmfldr_wpSetup(MMFolder *somSelf, PSZ pszSetupString)
1132{
1133 char buffer[CCHMAXPATH];
1134 ULONG bufferSize;
1135
1136 MMFolderData *somThis = MMFolderGetData(somSelf);
1137 MMFolderMethodDebug("MMFolder","mmfldr_wpSetup");
1138
1139 bufferSize=sizeof(buffer);
1140 if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMTHUMBSIZE, buffer, &bufferSize))
1141 {
1142 PVIEWITEM pViewItem;
1143 int iSize=atoi(buffer);
1144 ULONG ulMenuId;
1145
1146 switch(iSize)
1147 {
1148 case 0:
1149 _ulCurrentSize=0;
1150 ulMenuId=ID_NORMALICONSITEM;
1151 break;
1152 case 50:
1153 _ulCurrentSize=50;
1154 ulMenuId=ID_50X50ITEM;
1155 break;
1156 case 100:
1157 _ulCurrentSize=100;
1158 ulMenuId=ID_100X100ITEM;
1159 break;
1160 case 150:
1161 _ulCurrentSize=150;
1162 ulMenuId=ID_150X150ITEM;
1163 break;
1164 case 200:
1165 _ulCurrentSize=200;
1166 ulMenuId=ID_200X200ITEM;
1167 break;
1168 case 250:
1169 _ulCurrentSize=250;
1170 ulMenuId=ID_250X250ITEM;
1171 break;
1172 default:
1173 break;
1174 }
1175 /* MENUITEMSELECTED=xxx would be easy but doesn't work to change the icons of the folder because there is no
1176 hwndFrame in _wpMenuItemSelected() when sending it. So iterate over all views and call the menu
1177 function. */
1178 for(pViewItem=_wpFindViewItem(somSelf,VIEW_CONTENTS|VIEW_TREE|VIEW_DETAILS, NULLHANDLE);
1179 pViewItem;
1180 pViewItem=_wpFindViewItem(somSelf,VIEW_CONTENTS|VIEW_TREE|VIEW_DETAILS, pViewItem))
1181 {
1182 _wpMenuItemSelected(somSelf,
1183 pViewItem->handle,
1184 ulMenuId);
1185 }
1186 }
1187 return (MMFolder_parent_WPFolder_wpSetup(somSelf, pszSetupString));
1188}
1189
1190
1191SOM_Scope BOOL SOMLINK mmfldrM_wpclsCreateDefaultTemplates(M_MMFolder *somSelf,
1192 WPObject* Folder)
1193{
1194 char chrSetup[sizeof(MMFLDR_TEMPLATE_SETUP)+1];
1195 WPFolder* wpFolder;
1196
1197
1198 /* M_MMFolderData *somThis = M_MMFolderGetData(somSelf); */
1199 M_MMFolderMethodDebug("M_MMFolder","mmfldrM_wpclsCreateDefaultTemplates");
1200
1201 if(WinQueryObject("<MMPM2_MMFOLDERTEMPLATE>"))
1202 return TRUE; /* There's already a template */
1203
1204 sprintf(chrSetup, MMFLDR_TEMPLATE_SETUP);
1205 wpFolder=_wpclsQueryFolder(somSelf, MMTEMPLATE_FOLDER_ID, FALSE);
1206 _wpclsNew(somSelf, _wpclsQueryTitle(somSelf), chrSetup, wpFolder,FALSE);
1207
1208 return TRUE;
1209}
1210
1211
1212SOM_Scope PSZ SOMLINK mmfldrM_wpclsQueryTitle(M_MMFolder *somSelf)
1213{
1214 static char chrTitle[20]={0};
1215 /* M_MMFolderData *somThis = M_MMFolderGetData(somSelf); */
1216 M_MMFolderMethodDebug("M_MMFolder","mmfldrM_wpclsQueryTitle");
1217
1218 if(chrTitle[0]==0)
1219 if(!getMessage(chrTitle, IDSTR_LIGHTTABLETITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
1220 strcpy(chrTitle,"Light table");
1221
1222 return chrTitle;
1223}
1224
1225
1226SOM_Scope ULONG SOMLINK mmfldrM_wpclsQueryIconData(M_MMFolder *somSelf,
1227 PICONINFO pIconInfo)
1228{
1229 HMODULE hmod;
1230
1231 /* M_MMFolderData *somThis = M_MMFolderGetData(somSelf); */
1232 M_MMFolderMethodDebug("M_MMFolder","mmfldrM_wpclsQueryIconData");
1233
1234 hmod=queryModuleHandle();
1235 if(!hmod)
1236 return M_MMFolder_parent_M_WPFolder_wpclsQueryIconData(somSelf, pIconInfo);
1237
1238 if (pIconInfo) {
1239 pIconInfo->fFormat = ICON_RESOURCE;
1240 pIconInfo->hmod = hmod;
1241 pIconInfo->resid = ID_ICONLIGHTTABLE;
1242 } /* endif */
1243
1244 return ( sizeof(ICONINFO) );
1245}
1246
1247
1248SOM_Scope ULONG SOMLINK mmfldrM_wpclsQueryIconDataN(M_MMFolder *somSelf,
1249 ICONINFO* pIconInfo,
1250 ULONG ulIconIndex)
1251{
1252 HMODULE hmod;
1253 /* M_MMFolderData *somThis = M_MMFolderGetData(somSelf); */
1254 M_MMFolderMethodDebug("M_MMFolder","mmfldrM_wpclsQueryIconDataN");
1255
1256 hmod=queryModuleHandle();
1257 if(!hmod)
1258 return M_MMFolder_parent_M_WPFolder_wpclsQueryIconDataN(somSelf, pIconInfo, ulIconIndex);
1259
1260 if (pIconInfo) {
1261 pIconInfo->fFormat = ICON_RESOURCE;
1262 pIconInfo->hmod = hmod;
1263 pIconInfo->resid = ID_ICONLIGHTTABLE2;
1264 } /* endif */
1265
1266 return ( sizeof(ICONINFO) );
1267}
1268
1269
1270SOM_Scope ULONG SOMLINK mmfldrM_wpclsQueryDefaultView(M_MMFolder *somSelf)
1271{
1272 /* M_MMFolderData *somThis = M_MMFolderGetData(somSelf); */
1273 M_MMFolderMethodDebug("M_MMFolder","mmfldrM_wpclsQueryDefaultView");
1274
1275 return VIEW_CONTENTS;
1276}
1277
Note: See TracBrowser for help on using the repository browser.