source: branches/classes/c/c_image/cwbmp.c

Last change on this file was 170, checked in by gyoung, 17 months ago

Add some error logging

File size: 31.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_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 ulRc = mmioGetFormatName(&g_pmmFormatInfoArray[ulMenuId-ID_ITEM_FIRSTCONVERT], chrPtr,(LONG*) &ulSize, 0L, 0L);
564 if(ulRc)
565 {
566 SysWriteToTrapLog("cwbmp.c: %s %u\n\n", chrPtr, ulRc);
567 }
568 *( chrPtr + ulSize ) = (CHAR)NULL;
569 strcat(chrPtr,"\"");
570
571 if((ulRc=launchPMProg("", chrEditor, chrParams, somSelf, ulMenuId-ID_ITEM_FIRSTCONVERT))==NULLHANDLE) {
572 /* Error */
573 return TRUE;
574 }
575 return TRUE;
576 }
577 switch(ulMenuId)
578 {
579 case ID_MENU_IMGEDITOR:
580 _wpViewObject(somSelf, NULLHANDLE, ulMenuId, 0);
581 return TRUE;
582 default:
583 break;
584 }
585
586 return (MMBitmap_parent_WPBitmap_wpMenuItemSelected(somSelf,
587 hwndFrame,
588 ulMenuId));
589}
590
591/*
592 * The prototype for cwbmp_wpOpen was replaced by the following prototype:
593 */
594SOM_Scope HWND SOMLINK cwbmp_wpOpen(MMBitmap *somSelf, HWND hwndCnr,
595 ULONG ulView, ULONG param)
596{
597 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
598 MMBitmapMethodDebug("MMBitmap","cwbmp_wpOpen");
599
600 switch(ulView)
601 {
602 case ID_MENU_IMGEDITOR:
603 /*case 0xbc2b: editor */
604 {
605 char chrEditor[CCHMAXPATH]={0};
606 char chrParams[CCHMAXPATH+2]="\"";
607 char chrTitle[50];
608 char *chrPtr=chrParams;
609 ULONG ulSize;
610 ULONG ulRc;
611
612 if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageeditor", NULLHANDLE, chrEditor,
613 sizeof(chrEditor)))
614 PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "ib", NULLHANDLE, chrEditor,
615 sizeof(chrEditor));
616
617 chrPtr++;
618 ulSize=sizeof(chrParams)-2;
619 _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
620 strcat(chrPtr,"\"");
621
622 if(!getMessage(chrTitle, IDSTR_IMGEDITORTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
623 strcpy(chrTitle, "Editor");
624
625 if((ulRc=launchPMProg( chrTitle, chrEditor, chrParams, somSelf, ulView))==NULLHANDLE) {
626 return NULLHANDLE;
627 }
628 return NULLHANDLE;
629 }
630 default:
631 break;
632 }
633
634 return (MMBitmap_parent_WPBitmap_wpOpen(somSelf, hwndCnr,
635 ulView, param));
636}
637
638/*
639 * The prototype for cwbmp_wpAddSettingsPages was replaced by the following prototype:
640 */
641SOM_Scope BOOL SOMLINK cwbmp_wpAddSettingsPages(MMBitmap *somSelf,
642 HWND hwndNotebook)
643{
644 BOOL rc;
645 /* CWBitmapData *somThis = CWBitmapGetData(somSelf); */
646 MMBitmapMethodDebug("MMBitmap","cwbmp_wpAddSettingsPages");
647
648
649 rc=(MMBitmap_parent_WPBitmap_wpAddSettingsPages(somSelf,
650 hwndNotebook));
651 return rc | (_cwmmAddImageInformationPage(somSelf, hwndNotebook));
652}
653
654/*
655 * The prototype for cwbmp_wpUnInitData was replaced by the following prototype:
656 */
657SOM_Scope void SOMLINK cwbmp_wpUnInitData(MMBitmap *somSelf)
658{
659 MMBitmapData *somThis = MMBitmapGetData(somSelf);
660 MMBitmapMethodDebug("MMBitmap","cwbmp_wpUnInitData");
661
662 /* Free the private BITMAPINFOHEADER2 */
663 if(_pBmpInfoHeader2) {
664 _wpFreeMem(somSelf, _pBmpInfoHeader2);
665 _pBmpInfoHeader2=NULLHANDLE;
666 }
667
668 _cwmmFreeBitmaps(somSelf);
669
670 MMBitmap_parent_WPBitmap_wpUnInitData(somSelf);
671}
672
673
674/*
675 * The prototype for cwbmp_wpInitData was replaced by the following prototype:
676 */
677SOM_Scope void SOMLINK cwbmp_wpInitData(MMBitmap *somSelf)
678{
679 MMBitmapData *somThis = MMBitmapGetData(somSelf);
680 MMBitmapMethodDebug("MMBitmap","cwbmp_wpInitData");
681
682 MMBitmap_parent_WPBitmap_wpInitData(somSelf);
683
684 _hBitmapSmall=NULLHANDLE;
685 _ulSizeSmallBitmap=0;
686 _pBmpInfoHeader2=NULL;
687 _chrIOProcName[0]=0;
688 _bNoIOProcAvailable=FALSE;
689}
690
691
692/*
693 * The prototype for cwbmp_wpQueryDetailsData was replaced by the following prototype:
694 */
695SOM_Scope ULONG SOMLINK cwbmp_wpQueryDetailsData(MMBitmap *somSelf,
696 PVOID* ppDetailsData,
697 PULONG pcp)
698{
699 BOOL rcParent;
700 PIMAGEDETAILS pImageDetails;
701
702 MMBitmapData *somThis = MMBitmapGetData(somSelf);
703 MMBitmapMethodDebug("MMBitmap","cwbmp_wpQueryDetailsData");
704
705 rcParent= (MMBitmap_parent_WPBitmap_wpQueryDetailsData(somSelf,
706 ppDetailsData,
707 pcp));
708
709 /* The WPS asks for data to be displayed */
710 if(ppDetailsData)
711 {
712 ULONG ulWidth = 0, ulHeight = 0, ulDepth = 0;
713 PBITMAPINFOHEADER2 pBmpInfoHeader2;
714
715 pBmpInfoHeader2=(PBITMAPINFOHEADER2) _cwmmQueryBitmapInfoHeader(somSelf);
716
717 if(pBmpInfoHeader2) {
718 if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
719 ulWidth=pBmpInfoHeader2->cx;
720 ulHeight=pBmpInfoHeader2->cy;
721 ulDepth=pBmpInfoHeader2->cBitCount;
722 }
723 else {
724 PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
725 ulWidth=pBmpInfoHeader->cx;
726 ulHeight=pBmpInfoHeader->cy;
727 ulDepth=pBmpInfoHeader->cBitCount;
728 }
729 }
730
731 /* Fill the structure with the info to be displayed */
732 // Fixme ulWidth and freinds are potentally uninitulized is the } above in the wrong place
733 pImageDetails=(PIMAGEDETAILS)*ppDetailsData;
734 pImageDetails->ulWidth=ulWidth;
735 pImageDetails->ulHeight=ulHeight;
736 pImageDetails->ulDepth=ulDepth;
737 pImageDetails->pszFormat=STR_BITMAPNAME;
738
739 *ppDetailsData=((PBYTE) (*ppDetailsData))+sizeof(*pImageDetails);
740 }
741 else
742 {
743 /* Buffer size is queried */
744 if(pcp)
745 *pcp+=sizeof(*pImageDetails);
746 }
747 return rcParent;
748}
749
750
751
752
753SOM_Scope BOOL SOMLINK cwbmpM_wpclsCreateDefaultTemplates(M_MMBitmap *somSelf,
754 WPObject* Folder)
755{
756 /* M_MMBitmapData *somThis = M_MMBitmapGetData(somSelf); */
757 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsCreateDefaultTemplates");
758
759 if(checkImageIOProc( _wpclsQueryInstanceFilter(somSelf))) {
760 WPFolder* wpFolder;
761 wpFolder=_wpclsQueryFolder(somSelf, "<MMPM2_MMTEMPLATEFOLDER>", FALSE);
762 // return M_MMAudio_parent_M_MMDataFile_wpclsCreateDefaultTemplates(somSelf, wpFolder);
763 // HlpWriteToTrapLog("Create template for: %s\n", _wpclsQueryTitle(somSelf));
764 //HlpWriteToTrapLog("Create template for: %s\n", _somGetClassName(somSelf) );
765 mmclsCreateTheDefaultTemplate(somSelf, Folder);
766 return TRUE;
767 }
768
769 return TRUE;
770
771 // return (M_MMBitmap_parent_M_WPBitmap_wpclsCreateDefaultTemplates(somSelf,
772 // Folder));
773}
774
775/*
776 * The prototype for cwbmpM_wpclsQueryDefaultView was replaced by the following prototype:
777 */
778SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryDefaultView(M_MMBitmap *somSelf)
779{
780 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
781 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryDefaultView");
782
783 return ID_MENU_IMGEDITOR;
784}
785
786/*
787 * The prototype for cwbmpM_wpclsQueryIconData was replaced by the following prototype:
788 */
789SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryIconData(M_MMBitmap *somSelf,
790 PICONINFO pIconInfo)
791{
792 HMODULE hmod;
793 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
794 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryIconData");
795
796 hmod=queryModuleHandle();
797 if(!hmod)
798 return M_MMBitmap_parent_M_WPBitmap_wpclsQueryIconData(somSelf, pIconInfo);
799
800 if (pIconInfo) {
801 pIconInfo->fFormat = ICON_RESOURCE;
802 pIconInfo->hmod = hmod;
803 pIconInfo->resid = ID_ICONBMPFILE;
804 } /* endif */
805
806 return ( sizeof(ICONINFO) );
807}
808
809/*
810 * The prototype for cwbmpM_wpclsQueryDetailsInfo was replaced by the following prototype:
811 */
812SOM_Scope ULONG SOMLINK cwbmpM_wpclsQueryDetailsInfo(M_MMBitmap *somSelf,
813 PCLASSFIELDINFO* ppClassFieldInfo,
814 PULONG pSize)
815{
816 ULONG cParentColumns;
817 PCLASSFIELDINFO pCfi;
818 int i;
819
820 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
821 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsQueryDetailsInfo");
822
823 cParentColumns=(M_MMBitmap_parent_M_WPBitmap_wpclsQueryDetailsInfo(somSelf,
824 ppClassFieldInfo,
825 pSize));
826
827 if(pSize)
828 *pSize+=sizeof(IMAGEDETAILS);
829
830 if(ppClassFieldInfo)
831 {
832 if(*ppClassFieldInfo)
833 {
834 pCfi=*ppClassFieldInfo;
835 for(i=0; i<cParentColumns;i++)
836 pCfi=(pCfi->pNextFieldInfo ? pCfi->pNextFieldInfo: pCfi);
837
838 pCfi->pNextFieldInfo=cfiImageFieldInfo;
839 }
840 else
841 *ppClassFieldInfo=cfiImageFieldInfo;
842 }
843 return (cParentColumns+NUM_IMAGE_DETAILS_FIELDS);
844}
845
846/*
847 * The prototype for cwbmpM_wpclsInitData was replaced by the following prototype:
848 */
849SOM_Scope void SOMLINK cwbmpM_wpclsInitData(M_MMBitmap *somSelf)
850{
851 PCLASSFIELDINFO pCfi;
852 USHORT i;
853
854 /* M_CWBitmapData *somThis = M_CWBitmapGetData(somSelf); */
855 M_MMBitmapMethodDebug("M_MMBitmap","cwbmpM_wpclsInitData");
856
857 M_MMBitmap_parent_M_WPBitmap_wpclsInitData(somSelf);
858
859 /* Load strings for details titles */
860 if(getMessage(chrWidth, IDSTR_IMAGEDETAIL_WIDTH, sizeof(chrWidth), queryResModuleHandle(), HWND_DESKTOP))
861 pszImageColTitles[0]=chrWidth;
862 if(getMessage(chrHeight, IDSTR_IMAGEDETAIL_HEIGHT, sizeof(chrHeight), queryResModuleHandle(), HWND_DESKTOP))
863 pszImageColTitles[1]=chrHeight;
864 if(getMessage(chrDepth, IDSTR_IMAGEDETAIL_DEPTH, sizeof(chrDepth), queryResModuleHandle(), HWND_DESKTOP))
865 pszImageColTitles[2]=chrDepth;
866 if(getMessage(chrFormat, IDSTR_IMAGEDETAIL_FORMAT, sizeof(chrFormat), queryResModuleHandle(), HWND_DESKTOP))
867 pszImageColTitles[3]=chrFormat;
868
869 /* Setup the static data for the details view */
870 for(i=0,pCfi=cfiImageFieldInfo;i<NUM_IMAGE_DETAILS_FIELDS;i++,pCfi++)
871 {
872 memset((PCH)pCfi,0,sizeof(CLASSFIELDINFO));
873
874 pCfi->cb=sizeof(CLASSFIELDINFO);
875 pCfi->flData=CFA_LEFT|CFA_SEPARATOR|CFA_FIREADONLY;
876 pCfi->flTitle=CFA_CENTER|CFA_SEPARATOR|CFA_HORZSEPARATOR|CFA_STRING|CFA_FITITLEREADONLY;
877 pCfi->pNextFieldInfo=pCfi+1;
878 pCfi->pTitleData=(PVOID)pszImageColTitles[i];
879 pCfi->flCompare=COMPARE_SUPPORTED|SORTBY_SUPPORTED;
880
881 switch(i)
882 {
883 case 0: /* Width */
884 pCfi->flData|=CFA_ULONG;
885 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS, ulWidth));
886 pCfi->ulLenFieldData=sizeof(ULONG);
887 pCfi->ulLenCompareValue=sizeof(ULONG);
888 pCfi->DefaultComparison=CMP_GREATER;
889 break;
890 case 1: /* Height */
891 pCfi->flData|=CFA_ULONG;
892 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulHeight));
893 pCfi->ulLenFieldData=sizeof(ULONG);
894 pCfi->ulLenCompareValue=sizeof(ULONG);
895 pCfi->DefaultComparison=CMP_GREATER;
896 break;
897 case 2: /* Depth */
898 pCfi->flData|=CFA_ULONG;
899 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulDepth));
900 pCfi->ulLenFieldData=sizeof(ULONG);
901 pCfi->ulLenCompareValue=sizeof(ULONG);
902 pCfi->DefaultComparison=CMP_GREATER;
903 break;
904 case 3: /* Format */
905 pCfi->flData|=CFA_STRING;
906 pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,pszFormat));
907 pCfi->ulLenFieldData=sizeof(PSZ);
908 pCfi->DefaultComparison=CMP_EQUAL;
909 break;
910 }/* switch(i) */
911 }/* for() */
912 cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS].pNextFieldInfo=NULL;
913}
914
Note: See TracBrowser for help on using the repository browser.