source: branches/v2.9/classes/c/c_mm/mmfolder.c

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

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