source: branches/v2.9/classes/c/c_image/cwbmp.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: 30.8 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_cwbmp_Source
35#define SOM_Module_cwbmp_Source
36#endif
37#define CWBitmap_Class_Source
38#define M_CWBitmap_Class_Source
39
40#define INCL_DOS
41#define INCL_PM
42#define INCL_MMIOOS2
43#include <os2.h>
44#include <stdio.h>
45#include "mmioos2.h"
46
47#include "cwbmp.ih"
48#include "except.h"
49//#include "cwmmres.h"
50#include "mmres.h"
51#include "cwaudioinc.h"
52
53#include "sys_funcs.h"
54
55#define STR_BITMAPNAME "Bitmap"
56
57extern PSZ pszImageColTitles[NUM_IMAGE_DETAILS_FIELDS];
58
59extern CLASSFIELDINFO cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS];
60
61extern LONG lNumIOProcs;
62extern PMMFORMATINFO g_pmmFormatInfoArray;
63
64HMODULE queryResModuleHandle(void);
65HMODULE queryModuleHandle(void);
66BOOL insertIOProcMenuItems( HWND hwndMenu );
67ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters, WPObject *thisPtr, ULONG ulView);
68BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
69BOOL getBmpInfoHeader(PBITMAPINFOHEADER2 bmpih2, PSZ pszFileName, char* procName, ULONG ulLength, BOOL *bNoIOProcAvailable);
70HBITMAP loadBitmap ( PSZ pszFileName, PBITMAPINFOHEADER2 pBMPInfoHeader2);
71HBITMAP createNewBitmap ( HBITMAP hbm,
72 PBITMAPINFOHEADER2 pBmpInfoHeader2,
73 ULONG ulWidth,
74 ULONG ulHeight,
75 BOOL* pbQuitEarly);
76BOOL checkImageIOProc(char * chrExt);
77BOOL mmclsCreateTheDefaultTemplate(M_WPObject *somSelf,
78 WPObject* Folder);
79MRESULT menuInsertMenuSeparator(HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition );
80
81MRESULT EXPENTRY bmpInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
82{
83 MMBitmap *cwImage;
84
85 switch(msg) {
86 case WM_INITDLG :
87 cwImage=(MMBitmap*)LONGFROMMP(mp2);
88 if(somIsObj(cwImage)) {
89 // CWBitmapData *somThis = CWBitmapGetData(cwImage);
90
91 PBITMAPINFOHEADER2 pbmpih2;
92
93 if((pbmpih2=(PBITMAPINFOHEADER2) _cwmmQueryBitmapInfoHeader(cwImage))!=NULLHANDLE)
94 {
95 char fName[CCHMAXPATH];
96 char chrTemplate[100];
97
98 if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER2)) {
99 if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
100 queryResModuleHandle(), hwnd))
101 strcpy(chrTemplate, "%d Pixel");
102 sprintf(fName, chrTemplate,pbmpih2->cx);
103 WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
104
105 sprintf(fName, chrTemplate, pbmpih2->cy);
106 WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
107
108 if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
109 queryResModuleHandle(), hwnd))
110 strcpy(chrTemplate, "%d Bit");
111 sprintf(fName, chrTemplate, pbmpih2->cBitCount);
112 WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
113 }
114 else if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER)) {
115 /* We shouldn't get a BITMAPINFOHEADER here but who knows...*/
116 PBITMAPINFOHEADER pbmpih=(PBITMAPINFOHEADER)pbmpih2;
117 if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
118 queryResModuleHandle(), hwnd))
119 strcpy(chrTemplate, "%d Pixel");
120
121 sprintf(fName, chrTemplate,pbmpih->cx);
122 WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
123
124 sprintf(fName, chrTemplate, pbmpih->cy);
125 WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
126
127 if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
128 queryResModuleHandle(), hwnd))
129 strcpy(chrTemplate, "%d Bit");
130 sprintf(fName, chrTemplate, pbmpih->cBitCount);
131 WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
132 }
133
134 WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEFORMAT), STR_BITMAPNAME);
135 }
136 }/* somIsObj() */
137 return (MRESULT)TRUE;
138 /* This prevents switching the notebook page behind the open folder */
139 case WM_WINDOWPOSCHANGED:
140 {
141 MRESULT mr;
142
143 if(WinQueryFocus(HWND_DESKTOP)!=
144 WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
145 mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
146 mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
147 return mr;
148 }
149 break;
150 }
151 case WM_FOCUSCHANGE:
152 {
153 if(!SHORT1FROMMP(mp2)) {
154 if(HWNDFROMMP(mp1)==hwnd) {
155 MRESULT mr;
156
157 mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
158 WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT),
159 WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
160 return mr;
161 }
162 }
163 break;
164 }
165 case WM_DESTROY:
166 /* The notebook closes and gets destroyed */
167 /* Set focus to desktop to prevent PM freeze */
168 WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
169 break;
170 default:
171 break;
172 }
173 return WinDefDlgProc(hwnd, msg, mp1, mp2);
174}
175
176
177
178/*
179 * The prototype for cwbmp_cwmmAddImageInformationPage was replaced by the following prototype:
180 */
181SOM_Scope ULONG SOMLINK cwbmp_cwmmAddImageInformationPage(MMBitmap *somSelf,
182 HWND hwndNotebook)
183{
184 PAGEINFO pageinfo;
185 char pageName[100];
186
187 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
188 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmAddImageInformationPage");
189
190 //Clear the pageinfo structure
191 memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
192 //Fill the pageinfo structure
193 pageinfo.cb = sizeof(PAGEINFO);
194 pageinfo.hwndPage = NULLHANDLE;
195 pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
196 pageinfo.usPageInsertFlags = BKA_FIRST;
197 //We want page numbers
198 pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
199 //The dialog procedure for this page
200 pageinfo.pfnwp = bmpInfoDlgProc;
201 //The resource DLL
202 pageinfo.resid = queryResModuleHandle();
203 //pageinfo.resid = queryModuleHandle();
204 //The ID of the dialog template
205 pageinfo.dlgid = IDDLG_IMAGEINFOPAGE;
206 //pageinfo.dlgid = IDDLG_WAVEINFOPAGE;
207 //We need a pointer to our WPS-object in the dialog procedure
208 //to call class functions
209 pageinfo.pCreateParams = somSelf;
210 //The ID of the help panel for this page
211 //pageinfo.idDefaultHelpPanel = IDDLG_GENERAL2PAGE;
212
213 //Tell the WPS the help library name
214 pageinfo.pszHelpLibraryName = NULLHANDLE;
215 //We have a major tab so we need a name
216 /* pageName: "ISO filesystem" */
217 if(!getMessage(pageName, IDSTR_IMAGEINFOPAGENAME, sizeof(pageName), queryResModuleHandle(), hwndNotebook))
218 strcpy(pageName, "~Image information");
219 pageinfo.pszName = pageName;
220 //Insert the page into the settings notebook
221 return _wpInsertSettingsPage(somSelf,hwndNotebook,&pageinfo);
222}
223
224/* This private function is for creating a small bitmap handle. It loads the bitmap
225 and creates the small bitmap but *does not* keep the original size bitmap.
226 If using _wpQueryBitmapHandle() the object would keep (the maybe huge) original
227 size bitmap in memory until going dormant. This would eat up all memory rather fast. */
228static HBITMAP cwQueryBitmapHandle(MMBitmap *somSelf,
229 ULONG ulWidth,
230 ULONG ulHeight)
231{
232 ULONG ulSize;
233 char chrName[CCHMAXPATH];
234 BOOL bGotHeader=FALSE;
235 HBITMAP hbm=NULLHANDLE;
236 HBITMAP hbm2;
237
238 MMBitmapData *somThis = MMBitmapGetData(somSelf);
239 // CWImageMethodDebug("CWBitmap","cwimg_wpQueryBitmapHandle");
240
241 if(ulWidth==0 || ulHeight==0)
242 return NULLHANDLE;
243
244 ulSize=sizeof(chrName);
245 if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
246 return NULLHANDLE;
247
248
249 TRY_LOUD(LOAD_BMP3) {
250 if(_cwmmQueryBitmapInfoHeader(somSelf))
251 bGotHeader=TRUE;
252 }
253 CATCH(LOAD_BMP3)
254 {
255#if 0
256 if(MBID_OK==showMsgBox2(IDSTR_CWIMAGETITLE, IDSTR_IMGIOPROCCRASH, queryModuleHandle(),
257 MB_OK | MB_MOVEABLE | MB_WARNING))
258 exit(0);
259 exit(0);
260#endif
261 }END_CATCH;
262
263 if(!bGotHeader)
264 return NULLHANDLE;
265
266 TRY_LOUD(LOAD_BMP4) {
267 hbm=loadBitmap ( chrName , (PBITMAPINFOHEADER2) _pBmpInfoHeader2);
268 }
269 CATCH(LOAD_BMP4)
270 {
271#if 0
272 if(MBID_OK==showMsgBox2(IDSTR_CWIMAGETITLE, IDSTR_IMGIOPROCCRASH, queryModuleHandle(),
273 MB_OK | MB_MOVEABLE | MB_WARNING))
274 exit(0);
275 exit(0);
276#endif
277 hbm=NULLHANDLE;
278 } END_CATCH;
279
280 if(!hbm)
281 return NULLHANDLE;
282
283
284 TRY_LOUD(QRY_HBM) {
285 hbm2=createNewBitmap ( hbm, (PBITMAPINFOHEADER2) _pBmpInfoHeader2, ulWidth, ulHeight , NULLHANDLE);
286 }
287 CATCH(QRY_HBM)
288 {
289 hbm2=NULLHANDLE;
290 } END_CATCH;
291
292 GpiDeleteBitmap(hbm);
293 return hbm2;
294}
295
296/*
297 * The prototype for cwbmp_cwmmQuerySmallBitmapHandle was replaced by the following prototype:
298 */
299SOM_Scope HBITMAP SOMLINK cwbmp_cwmmQuerySmallBitmapHandle(MMBitmap *somSelf,
300 ULONG ulSize)
301{
302 HBITMAP hbm;
303 MMBitmapData *somThis = MMBitmapGetData(somSelf);
304 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmQuerySmallBitmapHandle");
305
306 if(_bNoIOProcAvailable)
307 return NULLHANDLE; /* No IO-proc for this image format. Don't try again in the future. */
308
309 if(ulSize<MAX_SIZE_SMALLBITMAP)
310 ulSize=MAX_SIZE_SMALLBITMAP;
311
312 if(ulSize>_ulSizeSmallBitmap)
313 {
314 if(_hBitmapSmall) {
315 GpiDeleteBitmap(_hBitmapSmall);
316 _hBitmapSmall=NULLHANDLE;
317 }
318 }
319
320 if(!_hBitmapSmall) {
321 _ulSizeSmallBitmap=0;
322
323 /* Get a small bitmap without caching the big size bitmap */
324 if((hbm=cwQueryBitmapHandle(somSelf,
325 ulSize,
326 ulSize))!=NULLHANDLE) {
327
328 _hBitmapSmall=hbm;
329 _ulSizeSmallBitmap=ulSize;
330 }
331 }
332 /* Return statement to be customized: */
333 return _hBitmapSmall;
334}
335
336/*
337 * The prototype for cwbmp_cwmmFreeBitmaps was replaced by the following prototype:
338 */
339SOM_Scope void SOMLINK cwbmp_cwmmFreeBitmaps(MMBitmap *somSelf)
340{
341 /* MMBitmapData *somThis = MMBitmapGetData(somSelf);*/
342 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmFreeBitmaps");
343
344 _cwmmFreeSmallBitmap(somSelf);
345}
346
347/*
348 * The prototype for cwbmp_cwmmFreeSmallBitmap was replaced by the following prototype:
349 */
350SOM_Scope void SOMLINK cwbmp_cwmmFreeSmallBitmap(MMBitmap *somSelf)
351{
352 MMBitmapData *somThis = MMBitmapGetData(somSelf);
353 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmFreeSmallBitmap");
354
355 if(_hBitmapSmall) {
356 GpiDeleteBitmap(_hBitmapSmall);
357 _hBitmapSmall=NULLHANDLE;
358 _ulSizeSmallBitmap=0;
359 }
360}
361
362/*
363 * The prototype for cwbmp_cwmmQueryBitmapInfoHeader was replaced by the following prototype:
364 */
365SOM_Scope PBYTE SOMLINK cwbmp_cwmmQueryBitmapInfoHeader(MMBitmap *somSelf)
366{
367 ULONG ulSize;
368 char chrName[CCHMAXPATH];
369 PBYTE pByte;
370 BOOL bGotHeader=FALSE;
371
372 MMBitmapData *somThis = MMBitmapGetData(somSelf);
373 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmQueryBitmapInfoHeader");
374
375 if(_pBmpInfoHeader2)
376 return _pBmpInfoHeader2;
377
378 if(_bNoIOProcAvailable)
379 return NULL; /* No IO-proc for this image format. Don't try again in the future. */
380
381 ulSize=sizeof(chrName);
382 if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
383 return NULL;
384
385 if((pByte=_wpAllocMem(somSelf, sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2), &ulSize))==NULLHANDLE)
386 return NULL;
387
388 TRY_LOUD(GET_CWBMPIH) {
389 bGotHeader=getBmpInfoHeader( (PBITMAPINFOHEADER2) pByte, chrName, _chrIOProcName,
390 sizeof(_chrIOProcName), &_bNoIOProcAvailable);
391 }
392 CATCH(GET_CWBMPIH)
393 {
394#if 0
395 if(MBID_OK==showMsgBox2(IDSTR_CWIMAGETITLE, IDSTR_IMGIOPROCCRASH, queryModuleHandle(),
396 MB_OK | MB_MOVEABLE | MB_WARNING))
397 exit(0);
398 exit(0);
399#endif
400
401 } END_CATCH;
402
403 if(!bGotHeader) {
404 _wpFreeMem(somSelf,pByte);
405 _pBmpInfoHeader2=NULLHANDLE;
406 _chrIOProcName[0]=0;
407 return NULL;
408 }
409 _pBmpInfoHeader2=pByte;
410
411#if 0
412 /* Update instance data */
413 if(((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cbFix==sizeof(BITMAPINFOHEADER2)) {
414 _ulWidth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cx;
415 _ulHeight=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cy;
416 _ulDepth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cBitCount;
417 }
418 else {
419 PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)_pBmpInfoHeader2;
420 _ulWidth=pBmpInfoHdr->cx;
421 _ulHeight=pBmpInfoHdr->cy;
422 _ulDepth=pBmpInfoHdr->cBitCount;
423 }
424#endif
425 return (PBYTE) _pBmpInfoHeader2;
426}
427
428SOM_Scope ULONG SOMLINK cwbmp_cwmmQueryImageInfo(MMBitmap *somSelf,
429 char** chrString,
430 ULONG ulSize,
431 int iWhich)
432{
433 PBITMAPINFOHEADER2 pBmpInfoHdr2=NULLHANDLE;
434 ULONG ulWidth, ulHeight, ulDepth;
435
436 MMBitmapData *somThis = MMBitmapGetData(somSelf);
437 MMBitmapMethodDebug("MMBitmap","cwbmp_cwmmQueryImageInfo");
438
439 pBmpInfoHdr2=(PBITMAPINFOHEADER2) _wpQueryBitmapInfoHeader(somSelf);
440
441 if(!pBmpInfoHdr2)
442 return 0;
443
444 if(pBmpInfoHdr2->cbFix==sizeof(BITMAPINFOHEADER2)) {
445 ulWidth=pBmpInfoHdr2->cx;
446 ulHeight=pBmpInfoHdr2->cy;
447 ulDepth=pBmpInfoHdr2->cBitCount;
448 }
449 else {
450 PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)pBmpInfoHdr2;
451 ulWidth=pBmpInfoHdr->cx;
452 ulHeight=pBmpInfoHdr->cy;
453 ulDepth=pBmpInfoHdr->cBitCount;
454 }
455 switch(iWhich)
456 {
457 case IDINFO_WIDTH:
458 return ulWidth;
459 case IDINFO_HEIGHT:
460 return ulHeight;
461 case IDINFO_BPP:
462 return ulDepth;
463 case IDINFO_FORMAT:
464 {
465 char *chr;
466 /* Image format */
467 if(!chrString)
468 return 0;
469
470 chr=*chrString;
471 strncpy(chr, _chrIOProcName, ulSize);
472 chr[ulSize-1]=0;
473 if(chr[0]==0)
474 return 0;
475 else
476 return 1;
477 }
478 default:
479 break;
480 }
481 return 0;
482}
483
484/*
485 * The prototype for cwbmp_wpModifyPopupMenu was replaced by the following prototype:
486 */
487SOM_Scope BOOL SOMLINK cwbmp_wpModifyPopupMenu(MMBitmap *somSelf,
488 HWND hwndMenu,
489 HWND hwndCnr,
490 ULONG iPosition)
491{
492 char text[120];
493 char menuText[200];
494 MENUITEM menuItem;
495
496 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
497 MMBitmapMethodDebug("MMBitmap","cwbmp_wpModifyPopupMenu");
498 _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_IMGEDITOR, 1);
499
500 TRY_LOUD(IMAGE_INSERTPOPUPMENU) {
501 /* Insert image info */
502 if(!getMessage(text, IDSTR_MENU_IMAGEINFO, sizeof(text), queryResModuleHandle(), hwndMenu))
503 strcpy(text, "Image information: %d x %d x %d");
504
505 sprintf(menuText, text,
506 _cwmmQueryImageInfo(somSelf, NULLHANDLE, 0, IDINFO_WIDTH),
507 _cwmmQueryImageInfo(somSelf, NULLHANDLE, 0, IDINFO_HEIGHT),
508 _cwmmQueryImageInfo(somSelf, NULLHANDLE, 0, IDINFO_BPP));//create menuitem
509
510 //insert size menuitem in popupmenu
511
512 menuItem.iPosition=MIT_END;
513 menuItem.afStyle=MIS_TEXT|MIS_STATIC;
514 menuItem.afAttribute=0;
515 menuItem.id=ID_MENU_IMAGEINFO;
516 menuItem.hwndSubMenu=NULLHANDLE;
517 menuItem.hItem=0;
518 WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&menuItem,(MPARAM)&menuText);
519
520 /* Insert all known image I/O procs */
521 insertIOProcMenuItems( hwndMenu );
522 menuInsertMenuSeparator(hwndMenu, NULLHANDLE, MIT_END );
523
524 }/* TRY_LOUD */
525 CATCH(IMAGE_INSERTPOPUPMENU)
526 {
527 SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
528 __FUNCTION__, __FILE__, __LINE__);
529 } END_CATCH;
530
531 return (MMBitmap_parent_WPBitmap_wpModifyPopupMenu(somSelf,
532 hwndMenu,
533 hwndCnr,
534 iPosition));
535}
536
537/*
538 * The prototype for cwbmp_wpMenuItemSelected was replaced by the following prototype:
539 */
540SOM_Scope BOOL SOMLINK cwbmp_wpMenuItemSelected(MMBitmap *somSelf,
541 HWND hwndFrame,
542 ULONG ulMenuId)
543{
544 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
545 MMBitmapMethodDebug("MMBitmap","cwbmp_wpMenuItemSelected");
546
547 if(ulMenuId>=ID_ITEM_FIRSTCONVERT && ulMenuId<=ID_ITEM_FIRSTCONVERT+lNumIOProcs-1)
548 {
549 char chrEditor[CCHMAXPATH]={0};
550 char chrParams[2*CCHMAXPATH]="\"";
551 char *chrPtr=chrParams;
552 ULONG ulSize;
553 ULONG ulRc;
554
555 PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageconverter", "", chrEditor,
556 sizeof(chrEditor));
557 chrPtr++;
558 ulSize=sizeof(chrParams);
559 _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
560 strcat(chrPtr,"\" \"");
561 chrPtr=strrchr(chrPtr, 0);
562
563 mmioGetFormatName(&g_pmmFormatInfoArray[ulMenuId-ID_ITEM_FIRSTCONVERT], chrPtr,(LONG*) &ulSize, 0L, 0L);
564 *( chrPtr + ulSize ) = (CHAR)NULL;
565 strcat(chrPtr,"\"");
566
567 if((ulRc=launchPMProg("", chrEditor, chrParams, somSelf, ulMenuId-ID_ITEM_FIRSTCONVERT))==NULLHANDLE) {
568 /* Error */
569 return TRUE;
570 }
571 return TRUE;
572 }
573 switch(ulMenuId)
574 {
575 case ID_MENU_IMGEDITOR:
576 _wpViewObject(somSelf, NULLHANDLE, ulMenuId, 0);
577 return TRUE;
578 default:
579 break;
580 }
581
582 return (MMBitmap_parent_WPBitmap_wpMenuItemSelected(somSelf,
583 hwndFrame,
584 ulMenuId));
585}
586
587/*
588 * The prototype for cwbmp_wpOpen was replaced by the following prototype:
589 */
590SOM_Scope HWND SOMLINK cwbmp_wpOpen(MMBitmap *somSelf, HWND hwndCnr,
591 ULONG ulView, ULONG param)
592{
593 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
594 MMBitmapMethodDebug("MMBitmap","cwbmp_wpOpen");
595
596 switch(ulView)
597 {
598 case ID_MENU_IMGEDITOR:
599 /*case 0xbc2b: editor */
600 {
601 char chrEditor[CCHMAXPATH]={0};
602 char chrParams[CCHMAXPATH+2]="\"";
603 char chrTitle[50];
604 char *chrPtr=chrParams;
605 ULONG ulSize;
606 ULONG ulRc;
607
608 if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageeditor", NULLHANDLE, chrEditor,
609 sizeof(chrEditor)))
610 PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "ib", NULLHANDLE, chrEditor,
611 sizeof(chrEditor));
612
613 chrPtr++;
614 ulSize=sizeof(chrParams)-2;
615 _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
616 strcat(chrPtr,"\"");
617
618 if(!getMessage(chrTitle, IDSTR_IMGEDITORTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
619 strcpy(chrTitle, "Editor");
620
621 if((ulRc=launchPMProg( chrTitle, chrEditor, chrParams, somSelf, ulView))==NULLHANDLE) {
622 return NULLHANDLE;
623 }
624 return NULLHANDLE;
625 }
626 default:
627 break;
628 }
629
630 return (MMBitmap_parent_WPBitmap_wpOpen(somSelf, hwndCnr,
631 ulView, param));
632}
633
634/*
635 * The prototype for cwbmp_wpAddSettingsPages was replaced by the following prototype:
636 */
637SOM_Scope BOOL SOMLINK cwbmp_wpAddSettingsPages(MMBitmap *somSelf,
638 HWND hwndNotebook)
639{
640 BOOL rc;
641 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
642 MMBitmapMethodDebug("MMBitmap","cwbmp_wpAddSettingsPages");
643
644
645 rc=(MMBitmap_parent_WPBitmap_wpAddSettingsPages(somSelf,
646 hwndNotebook));
647 return rc | (_cwmmAddImageInformationPage(somSelf, hwndNotebook));
648}
649
650/*
651 * The prototype for cwbmp_wpUnInitData was replaced by the following prototype:
652 */
653SOM_Scope void SOMLINK cwbmp_wpUnInitData(MMBitmap *somSelf)
654{
655 MMBitmapData *somThis = MMBitmapGetData(somSelf);
656 MMBitmapMethodDebug("MMBitmap","cwbmp_wpUnInitData");
657
658 /* Free the private BITMAPINFOHEADER2 */
659 if(_pBmpInfoHeader2) {
660 _wpFreeMem(somSelf, _pBmpInfoHeader2);
661 _pBmpInfoHeader2=NULLHANDLE;
662 }
663
664 _cwmmFreeBitmaps(somSelf);
665
666 MMBitmap_parent_WPBitmap_wpUnInitData(somSelf);
667}
668
669
670/*
671 * The prototype for cwbmp_wpInitData was replaced by the following prototype:
672 */
673SOM_Scope void SOMLINK cwbmp_wpInitData(MMBitmap *somSelf)
674{
675 MMBitmapData *somThis = MMBitmapGetData(somSelf);
676 MMBitmapMethodDebug("MMBitmap","cwbmp_wpInitData");
677
678 MMBitmap_parent_WPBitmap_wpInitData(somSelf);
679
680 _hBitmapSmall=NULLHANDLE;
681 _ulSizeSmallBitmap=0;
682 _pBmpInfoHeader2=NULL;
683 _chrIOProcName[0]=0;
684 _bNoIOProcAvailable=FALSE;
685}
686
687
688/*
689 * The prototype for cwbmp_wpQueryDetailsData was replaced by the following prototype:
690 */
691SOM_Scope ULONG SOMLINK cwbmp_wpQueryDetailsData(MMBitmap *somSelf,
692 PVOID* ppDetailsData,
693 PULONG pcp)
694{
695 BOOL rcParent;
696 PIMAGEDETAILS pImageDetails;
697
698 MMBitmapData *somThis = MMBitmapGetData(somSelf);
699 MMBitmapMethodDebug("MMBitmap","cwbmp_wpQueryDetailsData");
700
701 rcParent= (MMBitmap_parent_WPBitmap_wpQueryDetailsData(somSelf,
702 ppDetailsData,
703 pcp));
704
705 /* The WPS asks for data to be displayed */
706 if(ppDetailsData)
707 {
708 ULONG ulWidth, ulHeight, ulDepth;
709 PBITMAPINFOHEADER2 pBmpInfoHeader2;
710
711 pBmpInfoHeader2=(PBITMAPINFOHEADER2) _cwmmQueryBitmapInfoHeader(somSelf);
712
713 if(pBmpInfoHeader2) {
714 if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
715 ulWidth=pBmpInfoHeader2->cx;
716 ulHeight=pBmpInfoHeader2->cy;
717 ulDepth=pBmpInfoHeader2->cBitCount;
718 }
719 else {
720 PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
721 ulWidth=pBmpInfoHeader->cx;
722 ulHeight=pBmpInfoHeader->cy;
723 ulDepth=pBmpInfoHeader->cBitCount;
724 }
725 }
726
727 /* Fill the structure with the info to be displayed */
728 pImageDetails=(PIMAGEDETAILS)*ppDetailsData;
729 pImageDetails->ulWidth=ulWidth;
730 pImageDetails->ulHeight=ulHeight;
731 pImageDetails->ulDepth=ulDepth;
732 pImageDetails->pszFormat=STR_BITMAPNAME;
733
734 *ppDetailsData=((PBYTE) (*ppDetailsData))+sizeof(*pImageDetails);
735 }
736 else
737 {
738 /* Buffer size is queried */
739 if(pcp)
740 *pcp+=sizeof(*pImageDetails);
741 }
742 return rcParent;
743}
744
745
746
747
748SOM_Scope BOOL SOMLINK cwbmpM_wpclsCreateDefaultTemplates(M_MMBitmap *somSelf,
749 WPObject* Folder)
750{
751 /* M_MMBitmapData *somThis = M_MMBitmapGetData(somSelf); */
752 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsCreateDefaultTemplates");
753
754 if(checkImageIOProc( _wpclsQueryInstanceFilter(somSelf))) {
755 WPFolder* wpFolder;
756 wpFolder=_wpclsQueryFolder(somSelf, "<MMPM2_MMTEMPLATEFOLDER>", FALSE);
757 // return M_MMAudio_parent_M_MMDataFile_wpclsCreateDefaultTemplates(somSelf, wpFolder);
758 // HlpWriteToTrapLog("Create template for: %s\n", _wpclsQueryTitle(somSelf));
759 //HlpWriteToTrapLog("Create template for: %s\n", _somGetClassName(somSelf) );
760 mmclsCreateTheDefaultTemplate(somSelf, Folder);
761 return TRUE;
762 }
763
764 return TRUE;
765
766 // return (M_MMBitmap_parent_M_WPBitmap_wpclsCreateDefaultTemplates(somSelf,
767 // Folder));
768}
769
770/*
771 * The prototype for cwbmpM_wpclsQueryDefaultView was replaced by the following prototype:
772 */
773SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryDefaultView(M_MMBitmap *somSelf)
774{
775 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
776 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryDefaultView");
777
778 return ID_MENU_IMGEDITOR;
779}
780
781/*
782 * The prototype for cwbmpM_wpclsQueryIconData was replaced by the following prototype:
783 */
784SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryIconData(M_MMBitmap *somSelf,
785 PICONINFO pIconInfo)
786{
787 HMODULE hmod;
788 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
789 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryIconData");
790
791 hmod=queryModuleHandle();
792 if(!hmod)
793 return M_MMBitmap_parent_M_WPBitmap_wpclsQueryIconData(somSelf, pIconInfo);
794
795 if (pIconInfo) {
796 pIconInfo->fFormat = ICON_RESOURCE;
797 pIconInfo->hmod = hmod;
798 pIconInfo->resid = ID_ICONBMPFILE;
799 } /* endif */
800
801 return ( sizeof(ICONINFO) );
802}
803
804/*
805 * The prototype for cwbmpM_wpclsQueryDetailsInfo was replaced by the following prototype:
806 */
807SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryDetailsInfo(M_MMBitmap *somSelf,
808 PCLASSFIELDINFO* ppClassFieldInfo,
809 PULONG pSize)
810{
811 ULONG cParentColumns;
812 PCLASSFIELDINFO pCfi;
813 int i;
814
815 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
816 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryDetailsInfo");
817
818 cParentColumns=(M_MMBitmap_parent_M_WPBitmap_wpclsQueryDetailsInfo(somSelf,
819 ppClassFieldInfo,
820 pSize));
821
822 if(pSize)
823 *pSize+=sizeof(IMAGEDETAILS);
824
825 if(ppClassFieldInfo)
826 {
827 if(*ppClassFieldInfo)
828 {
829 pCfi=*ppClassFieldInfo;
830 for(i=0; i<cParentColumns;i++)
831 pCfi=(pCfi->pNextFieldInfo ? pCfi->pNextFieldInfo: pCfi);
832
833 pCfi->pNextFieldInfo=cfiImageFieldInfo;
834 }
835 else
836 *ppClassFieldInfo=cfiImageFieldInfo;
837 }
838 return (cParentColumns+NUM_IMAGE_DETAILS_FIELDS);
839}
840
841/*
842 * The prototype for cwbmpM_wpclsInitData was replaced by the following prototype:
843 */
844SOM_Scope void SOMLINK cwbmpM_wpclsInitData(M_MMBitmap *somSelf)
845{
846 PCLASSFIELDINFO pCfi;
847 USHORT i;
848
849 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
850 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsInitData");
851
852 M_MMBitmap_parent_M_WPBitmap_wpclsInitData(somSelf);
853
854 /* Load strings for details titles */
855 if(getMessage(chrWidth, IDSTR_IMAGEDETAIL_WIDTH, sizeof(chrWidth), queryResModuleHandle(), HWND_DESKTOP))
856 pszImageColTitles[0]=chrWidth;
857 if(getMessage(chrHeight, IDSTR_IMAGEDETAIL_HEIGHT, sizeof(chrHeight), queryResModuleHandle(), HWND_DESKTOP))
858 pszImageColTitles[1]=chrHeight;
859 if(getMessage(chrDepth, IDSTR_IMAGEDETAIL_DEPTH, sizeof(chrDepth), queryResModuleHandle(), HWND_DESKTOP))
860 pszImageColTitles[2]=chrDepth;
861 if(getMessage(chrFormat, IDSTR_IMAGEDETAIL_FORMAT, sizeof(chrFormat), queryResModuleHandle(), HWND_DESKTOP))
862 pszImageColTitles[3]=chrFormat;
863
864 /* Setup the static data for the details view */
865 for(i=0,pCfi=cfiImageFieldInfo;i<NUM_IMAGE_DETAILS_FIELDS;i++,pCfi++)
866 {
867 memset((PCH)pCfi,0,sizeof(CLASSFIELDINFO));
868
869 pCfi->cb=sizeof(CLASSFIELDINFO);
870 pCfi->flData=CFA_LEFT|CFA_SEPARATOR|CFA_FIREADONLY;
871 pCfi->flTitle=CFA_CENTER|CFA_SEPARATOR|CFA_HORZSEPARATOR|CFA_STRING|CFA_FITITLEREADONLY;
872 pCfi->pNextFieldInfo=pCfi+1;
873 pCfi->pTitleData=(PVOID)pszImageColTitles[i];
874 pCfi->flCompare=COMPARE_SUPPORTED|SORTBY_SUPPORTED;
875
876 switch(i)
877 {
878 case 0: /* Width */
879 pCfi->flData|=CFA_ULONG;
880 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS, ulWidth));
881 pCfi->ulLenFieldData=sizeof(ULONG);
882 pCfi->ulLenCompareValue=sizeof(ULONG);
883 pCfi->DefaultComparison=CMP_GREATER;
884 break;
885 case 1: /* Height */
886 pCfi->flData|=CFA_ULONG;
887 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulHeight));
888 pCfi->ulLenFieldData=sizeof(ULONG);
889 pCfi->ulLenCompareValue=sizeof(ULONG);
890 pCfi->DefaultComparison=CMP_GREATER;
891 break;
892 case 2: /* Depth */
893 pCfi->flData|=CFA_ULONG;
894 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulDepth));
895 pCfi->ulLenFieldData=sizeof(ULONG);
896 pCfi->ulLenCompareValue=sizeof(ULONG);
897 pCfi->DefaultComparison=CMP_GREATER;
898 break;
899 case 3: /* Format */
900 pCfi->flData|=CFA_STRING;
901 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,pszFormat));
902 pCfi->ulLenFieldData=sizeof(PSZ);
903 pCfi->DefaultComparison=CMP_EQUAL;
904 break;
905 }/* switch(i) */
906 }/* for() */
907 cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS].pNextFieldInfo=NULL;
908}
909
Note: See TracBrowser for help on using the repository browser.