1 | /*
|
---|
2 | * (C) Chris Wohlgemuth 2002-2003
|
---|
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_cwimage_Source
|
---|
35 | #define SOM_Module_cwimage_Source
|
---|
36 | #endif
|
---|
37 | #define CWImage_Class_Source
|
---|
38 | #define M_CWImage_Class_Source
|
---|
39 |
|
---|
40 | #define INCL_DOS
|
---|
41 | #define INCL_GPI
|
---|
42 | #define INCL_PM
|
---|
43 | #define INCL_MMIOOS2
|
---|
44 | #include <os2.h>
|
---|
45 | #include <stdio.h>
|
---|
46 | #include "mmioos2.h"
|
---|
47 | #include "cwimage.ih"
|
---|
48 | #include "mmres.h"
|
---|
49 | #include "except.h"
|
---|
50 | #include "cwaudioinc.h"
|
---|
51 |
|
---|
52 | #include "sys_funcs.h"
|
---|
53 |
|
---|
54 | //#define DEBUG
|
---|
55 | char notImplementedMsg[]= {"\nMethod not available while processing file %s: %s, file %s, around line %d.\n"};
|
---|
56 |
|
---|
57 | /* Set some default titles */
|
---|
58 | PSZ pszImageColTitles[NUM_IMAGE_DETAILS_FIELDS]= {"Width", "Height", "Depth", "Format"};
|
---|
59 |
|
---|
60 | char chrWidth[SIZE_TITLE]="";
|
---|
61 | char chrHeight[SIZE_TITLE]="";
|
---|
62 | char chrDepth[SIZE_TITLE]="";
|
---|
63 | char chrFormat[SIZE_TITLE]="";
|
---|
64 |
|
---|
65 | CLASSFIELDINFO cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS];
|
---|
66 |
|
---|
67 | /* Some methods are not yet implemented */
|
---|
68 | #define NOT_IMPLEMENTED DosBeep(1000, 100);\
|
---|
69 | DosBeep(2000, 100);\
|
---|
70 | DosBeep(3000, 100);\
|
---|
71 | DosBeep(4000, 100);\
|
---|
72 | DosBeep(3000, 100);\
|
---|
73 | DosBeep(2000, 100);\
|
---|
74 | DosBeep(1000, 100);\
|
---|
75 | SysWriteToTrapLog(notImplementedMsg,\
|
---|
76 | _wpQueryTitle(somSelf), __FUNCTION__, __FILE__, __LINE__);
|
---|
77 |
|
---|
78 |
|
---|
79 | extern HAB globalHab;
|
---|
80 | HWND hwndCreateBMP; /* Object window for small bitmap creation */
|
---|
81 | extern char classDLLPath[CCHMAXPATH];
|
---|
82 | extern char chrHelpLibrary[CCHMAXPATH];
|
---|
83 | PMMFORMATINFO g_pmmFormatInfoArray=NULLHANDLE;
|
---|
84 | LONG lNumIOProcs=0;/* Needed to know how many convert menus we have */
|
---|
85 |
|
---|
86 | char chrMMImageKnownExt[320]={0};/* Array holding the extensions we have a class for e.g. JPG. This
|
---|
87 | array will be filled using an external REXX script. Space for
|
---|
88 | 80 ext should be enough for now (4 bytes per ext e.g.: "JPG "<- note the space) */
|
---|
89 | char chrMMImageExt[200]={0};/* Array holding the extensions for wpclsQueryInstanceFilter(). Will be
|
---|
90 | filled during processing of wpclsInitData() */
|
---|
91 |
|
---|
92 |
|
---|
93 | ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters, WPObject *thisPtr, ULONG ulView);
|
---|
94 |
|
---|
95 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
96 | ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
|
---|
97 | char* title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
98 | HMODULE hResource, HWND hwnd, ULONG ulFlags);
|
---|
99 |
|
---|
100 | void writeLog(char* chrFormat, ...);
|
---|
101 | HMODULE queryResModuleHandle(void);
|
---|
102 | HMODULE queryModuleHandle(void);
|
---|
103 | PSZ queryModuleName(void);
|
---|
104 |
|
---|
105 | BOOL getBmpInfoHeader(PBITMAPINFOHEADER2 bmpih2, PSZ pszFileName, char* procName, ULONG ulLength, BOOL * bNoIOProcAvailable);
|
---|
106 | HBITMAP loadBitmap ( PSZ pszFileName, PBITMAPINFOHEADER2 pBMPInfoHeader2);
|
---|
107 | HBITMAP createNewBitmap ( HBITMAP hbm,
|
---|
108 | PBITMAPINFOHEADER2 pBmpInfoHeader2,
|
---|
109 | ULONG ulWidth,
|
---|
110 | ULONG ulHeight,
|
---|
111 | BOOL* pbQuitEarly);
|
---|
112 |
|
---|
113 | ULONG showMsgBox2(ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag);
|
---|
114 | ULONG showMsgBox(ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule);
|
---|
115 | BOOL cwObjectIsOnCD(WPObject * somSelf);
|
---|
116 | BOOL getStringFromRexxScript(PSZ rexxFile, char* chrResult, ULONG ulSize);
|
---|
117 |
|
---|
118 | BOOL mmclsCreateTheDefaultTemplate(M_WPObject *somSelf,
|
---|
119 | WPObject* Folder);
|
---|
120 |
|
---|
121 | MRESULT menuInsertMenuSeparator(HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition );
|
---|
122 |
|
---|
123 | /* This Proc creates the small bitmaps for display on a separate thread. */
|
---|
124 | MRESULT EXPENTRY createBMPObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
125 | {
|
---|
126 |
|
---|
127 | switch (msg)
|
---|
128 | {
|
---|
129 | case WM_APPTERMINATENOTIFY:
|
---|
130 | {
|
---|
131 | switch(SHORT2FROMMP(mp2))
|
---|
132 | {
|
---|
133 | case ACKEY_CREATE_SMALLBITMAP:
|
---|
134 | {
|
---|
135 | BOOL bLoaded=FALSE;
|
---|
136 | HBITMAP hbm;
|
---|
137 | PCREATEBMPINFO pCreateBMP=PVOIDFROMMP(mp1);
|
---|
138 | MMImageData *somThis;
|
---|
139 | WPObject *wpObject;
|
---|
140 | PMINIRECORDCORE pmrcToRefresh;
|
---|
141 |
|
---|
142 | if(!pCreateBMP)
|
---|
143 | return (MRESULT) FALSE;
|
---|
144 | if(!somIsObj(pCreateBMP->wpObject))
|
---|
145 | return (MRESULT) FALSE;
|
---|
146 |
|
---|
147 | TRY_LOUD(BITMAP_OBJECT) {
|
---|
148 | somThis = MMImageGetData(pCreateBMP->wpObject);
|
---|
149 | wpObject=pCreateBMP->wpObject;
|
---|
150 | pmrcToRefresh=pCreateBMP->pmrcToRefresh;
|
---|
151 |
|
---|
152 | /* Check if in the meantime the bitmap was created */
|
---|
153 | if(!_hBitmapSmall) {
|
---|
154 | /* Check if bitmap data already loaded. Keep the info so we don't discard the bitmap later on. Another
|
---|
155 | function may have requested the bitmap before. */
|
---|
156 | if(_hBitmap)
|
---|
157 | bLoaded=TRUE;
|
---|
158 |
|
---|
159 | if(_wpQueryBitmapHandle(pCreateBMP->wpObject,
|
---|
160 | &hbm,
|
---|
161 | NULLHANDLE,
|
---|
162 | pCreateBMP->ulWidth,
|
---|
163 | pCreateBMP->ulHeight,
|
---|
164 | 0, /* ulFlags*/
|
---|
165 | 0,
|
---|
166 | NULLHANDLE)) {
|
---|
167 | _hBitmapSmall=hbm;
|
---|
168 | _ulSizeSmallBitmap=pCreateBMP->ulHeight;
|
---|
169 | if(!bLoaded) {
|
---|
170 | /* The bitmap wasn't loaded so discard it now, we don't need it any more as we have
|
---|
171 | the small one. */
|
---|
172 | GpiDeleteBitmap(_hBitmap);
|
---|
173 | _hBitmap=NULLHANDLE;
|
---|
174 | }
|
---|
175 | }/* _wpQueryBitmapHandle() */
|
---|
176 | }
|
---|
177 | if(WinIsWindow(globalHab, pCreateBMP->hwndCnr) && pmrcToRefresh)
|
---|
178 | // WinPostMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
179 | WinSendMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
180 | }/* Try */
|
---|
181 | CATCH(BITMAP_OBJECT)
|
---|
182 | {
|
---|
183 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
---|
184 | __FUNCTION__, __FILE__, __LINE__);
|
---|
185 | } END_CATCH;
|
---|
186 | // WinSendMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
187 | _wpFreeMem(wpObject, (PBYTE)pCreateBMP);
|
---|
188 | return (MRESULT) FALSE;
|
---|
189 | }/* case ACKEY_CREATE_SMALLBITMAP */
|
---|
190 | case ACKEY_QUERY_BITMAPINFO:
|
---|
191 | {
|
---|
192 | PCREATEBMPINFO pCreateBMP=PVOIDFROMMP(mp1);
|
---|
193 | MMImageData *somThis;
|
---|
194 |
|
---|
195 | if(!pCreateBMP)
|
---|
196 | return (MRESULT) FALSE;
|
---|
197 | if(!somIsObj(pCreateBMP->wpObject))
|
---|
198 | return (MRESULT) FALSE;
|
---|
199 |
|
---|
200 | TRY_LOUD(BITMAPIH_OBJECT) {
|
---|
201 | somThis = MMImageGetData(pCreateBMP->wpObject);
|
---|
202 |
|
---|
203 | /* Check if in the meantime the bitmap was created */
|
---|
204 | if(!_pBmpInfoHeader2) {
|
---|
205 | _pBmpInfoHeader2=_wpQueryBitmapInfoHeader(pCreateBMP->wpObject);
|
---|
206 | /* Make sure the image size is cached in the EA */
|
---|
207 | if(_pBmpInfoHeader2)
|
---|
208 | _wpSaveDeferred(pCreateBMP->wpObject);
|
---|
209 | }
|
---|
210 | }/* Try */
|
---|
211 | CATCH(BITMAPIH_OBJECT)
|
---|
212 | {
|
---|
213 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while getting BMPINFOHEADER.\n",
|
---|
214 | __FUNCTION__, __FILE__, __LINE__);
|
---|
215 | } END_CATCH;
|
---|
216 | return (MRESULT) FALSE;
|
---|
217 | }
|
---|
218 | default:
|
---|
219 | break;
|
---|
220 | }/* switch(SHORT2FROMMP(mp2)) */
|
---|
221 | return (MRESULT) FALSE;
|
---|
222 | }/* case WM_APPTERMINATENOTIFY */
|
---|
223 | default:
|
---|
224 | break;
|
---|
225 | }
|
---|
226 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
227 | }
|
---|
228 |
|
---|
229 | /*
|
---|
230 |
|
---|
231 | This thread is started in cwimgM_wpclsInitData(M_MMImage *somSelf). It will creates small bitmaps and reads
|
---|
232 | in the BITMAPINFOHEADER.
|
---|
233 |
|
---|
234 | */
|
---|
235 | void _Optlink createBMPThreadFunc (void *arg)
|
---|
236 | {
|
---|
237 |
|
---|
238 | HAB hab;
|
---|
239 | HMQ hmq;
|
---|
240 | QMSG qmsg;
|
---|
241 |
|
---|
242 | hab=WinInitialize(0);
|
---|
243 | if(hab) {
|
---|
244 | hmq=WinCreateMsgQueue(hab, 50);
|
---|
245 | if(hmq) {
|
---|
246 | hwndCreateBMP=WinCreateWindow(HWND_OBJECT,WC_STATIC,"coverObj",0,0,0,0,0,NULLHANDLE,HWND_BOTTOM,13343,NULL,NULL);
|
---|
247 | if(hwndCreateBMP) {
|
---|
248 | WinSubclassWindow(hwndCreateBMP,&createBMPObjectProc);
|
---|
249 | /* Window created. */
|
---|
250 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
|
---|
251 | WinDispatchMsg(hab,&qmsg);
|
---|
252 | WinDestroyWindow(hwndCreateBMP);
|
---|
253 | }
|
---|
254 | WinDestroyMsgQueue(hmq);
|
---|
255 | }
|
---|
256 | WinTerminate(hab);
|
---|
257 | }
|
---|
258 | }
|
---|
259 |
|
---|
260 |
|
---|
261 | MRESULT EXPENTRY imageInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
262 | {
|
---|
263 | MMImage *cwImage;
|
---|
264 |
|
---|
265 | switch(msg) {
|
---|
266 | case WM_INITDLG :
|
---|
267 | cwImage=(MMImage*)LONGFROMMP(mp2);
|
---|
268 | if(somIsObj(cwImage)) {
|
---|
269 | MMImageData *somThis = MMImageGetData(cwImage);
|
---|
270 |
|
---|
271 | PBITMAPINFOHEADER2 pbmpih2;
|
---|
272 |
|
---|
273 | if((pbmpih2=(PBITMAPINFOHEADER2)_wpQueryBitmapInfoHeader(cwImage))!=NULLHANDLE)
|
---|
274 | {
|
---|
275 | char fName[CCHMAXPATH];
|
---|
276 | char chrTemplate[100];
|
---|
277 |
|
---|
278 | if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
279 | if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
|
---|
280 | queryResModuleHandle(), hwnd))
|
---|
281 | strcpy(chrTemplate, "%d Pixel");
|
---|
282 | sprintf(fName, chrTemplate, pbmpih2->cx);
|
---|
283 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
|
---|
284 |
|
---|
285 | sprintf(fName, chrTemplate, pbmpih2->cy);
|
---|
286 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
|
---|
287 |
|
---|
288 | if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
|
---|
289 | queryResModuleHandle(), hwnd))
|
---|
290 | strcpy(chrTemplate, "%d Bit");
|
---|
291 | sprintf(fName, chrTemplate, pbmpih2->cBitCount);
|
---|
292 | WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
|
---|
293 | }
|
---|
294 | else if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER)) {
|
---|
295 | /* We shouldn't get a BITMAPINFOHEADER here but who knows...*/
|
---|
296 | PBITMAPINFOHEADER pbmpih=(PBITMAPINFOHEADER)pbmpih2;
|
---|
297 | if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
|
---|
298 | queryResModuleHandle(), hwnd))
|
---|
299 | strcpy(chrTemplate, "%d Pixel");
|
---|
300 | sprintf(fName, chrTemplate,pbmpih->cx);
|
---|
301 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
|
---|
302 |
|
---|
303 | sprintf(fName, chrTemplate, pbmpih->cy);
|
---|
304 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
|
---|
305 |
|
---|
306 | if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
|
---|
307 | queryResModuleHandle(), hwnd))
|
---|
308 | strcpy(chrTemplate, "%d Bit");
|
---|
309 | sprintf(fName, chrTemplate, pbmpih->cBitCount);
|
---|
310 | WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
|
---|
311 | }
|
---|
312 |
|
---|
313 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEFORMAT),_chrIOProcName);
|
---|
314 | }
|
---|
315 | }/* somIsObj() */
|
---|
316 | return (MRESULT)TRUE;
|
---|
317 | /* This prevents switching the notebook page behind the open folder */
|
---|
318 | case WM_WINDOWPOSCHANGED:
|
---|
319 | {
|
---|
320 | MRESULT mr;
|
---|
321 |
|
---|
322 | if(WinQueryFocus(HWND_DESKTOP)!=
|
---|
323 | WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
|
---|
324 | mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
|
---|
325 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
326 | return mr;
|
---|
327 | }
|
---|
328 | break;
|
---|
329 | }
|
---|
330 | case WM_FOCUSCHANGE:
|
---|
331 | {
|
---|
332 | if(!SHORT1FROMMP(mp2)) {
|
---|
333 | if(HWNDFROMMP(mp1)==hwnd) {
|
---|
334 | MRESULT mr;
|
---|
335 |
|
---|
336 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
337 | WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT),
|
---|
338 | WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
|
---|
339 | return mr;
|
---|
340 | }
|
---|
341 | }
|
---|
342 | break;
|
---|
343 | }
|
---|
344 | case WM_DESTROY:
|
---|
345 | /* The notebook closes and gets destroyed */
|
---|
346 | /* Set focus to desktop to prevent PM freeze */
|
---|
347 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
---|
348 | break;
|
---|
349 | default:
|
---|
350 | break;
|
---|
351 | }
|
---|
352 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
353 | }
|
---|
354 |
|
---|
355 | /*!*******************************************************/
|
---|
356 | /* */
|
---|
357 | /* @@DESC */
|
---|
358 | /* */
|
---|
359 | /* */
|
---|
360 | /* @@USAGE */
|
---|
361 | /* */
|
---|
362 | /* @@PARAM */
|
---|
363 | /* */
|
---|
364 | /* MMImage *somSelf input */
|
---|
365 | /* */
|
---|
366 | /* Pointer to the object on which the method is being */
|
---|
367 | /* invoked. */
|
---|
368 | /* :p. */
|
---|
369 | /* Points to an object of class :hp2.MMImage:ehp2.. */
|
---|
370 | /* */
|
---|
371 | /* @@PARAM */
|
---|
372 | /* */
|
---|
373 | /* HWND hwndNotebook input */
|
---|
374 | /* */
|
---|
375 | /* Settings notebook handle. */
|
---|
376 | /* */
|
---|
377 | /* @@OVERRIDE */
|
---|
378 | /* */
|
---|
379 | /* This method should always be overridden in order to */
|
---|
380 | /* remove or replace the image information page from */
|
---|
381 | /* the object's Settings notbook. */
|
---|
382 | /* :p. */
|
---|
383 | /* To remove the page from the Settings notebook, the */
|
---|
384 | /* override method should return */
|
---|
385 | /* :hp1.SETTINGS_PAGE_REMOVED:ehp1. without calling the */
|
---|
386 | /* the parent method. To replace the page with another */
|
---|
387 | /* page, the override method should call the */
|
---|
388 | /* wpInsertSettingsPAge method without calling the */
|
---|
389 | /* parent method. */
|
---|
390 | /* */
|
---|
391 | /* @@RETURNS */
|
---|
392 | /* */
|
---|
393 | /* ULONG rc */
|
---|
394 | /* */
|
---|
395 | /* :parml compact tsize=15 break=none. */
|
---|
396 | /* :pt.0:pd.Error occurred */
|
---|
397 | /* :pt.PageId :pd.Identifier for the inserted page. */
|
---|
398 | /* :eparml. */
|
---|
399 | /* */
|
---|
400 | /*!!******************************************************/
|
---|
401 | SOM_Scope ULONG SOMLINK cwimg_cwmmAddImageInformationPage(MMImage *somSelf,
|
---|
402 | HWND hwndNotebook)
|
---|
403 | {
|
---|
404 | PAGEINFO pageinfo;
|
---|
405 | char pageName[100];
|
---|
406 |
|
---|
407 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
408 | MMImageMethodDebug("MMImage","cwimg_cwmmAddImageInformationPage");
|
---|
409 |
|
---|
410 | //Clear the pageinfo structure
|
---|
411 | memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
|
---|
412 | //Fill the pageinfo structure
|
---|
413 | pageinfo.cb = sizeof(PAGEINFO);
|
---|
414 | pageinfo.hwndPage = NULLHANDLE;
|
---|
415 | pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
|
---|
416 | pageinfo.usPageInsertFlags = BKA_FIRST;
|
---|
417 | //We want page numbers
|
---|
418 | pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
|
---|
419 | //The dialog procedure for this page
|
---|
420 | pageinfo.pfnwp = imageInfoDlgProc;
|
---|
421 | //The resource DLL
|
---|
422 | pageinfo.resid = queryResModuleHandle();
|
---|
423 | //The ID of the dialog template
|
---|
424 | pageinfo.dlgid = IDDLG_IMAGEINFOPAGE;
|
---|
425 | //We need a pointer to our WPS-object in the dialog procedure
|
---|
426 | //to call class functions
|
---|
427 | pageinfo.pCreateParams = somSelf;
|
---|
428 | //The ID of the help panel for this page
|
---|
429 | //pageinfo.idDefaultHelpPanel = IDDLG_GENERAL2PAGE;
|
---|
430 |
|
---|
431 | //Tell the WPS the help library name
|
---|
432 | pageinfo.pszHelpLibraryName = NULLHANDLE;
|
---|
433 | //We have a major tab so we need a name
|
---|
434 | /* pageName: "ISO filesystem" */
|
---|
435 | if(!getMessage(pageName, IDSTR_IMAGEINFOPAGENAME, sizeof(pageName), queryResModuleHandle(), hwndNotebook))
|
---|
436 | strcpy(pageName, "~Image information");
|
---|
437 | pageinfo.pszName = pageName;
|
---|
438 | //Insert the page into the settings notebook
|
---|
439 | return _wpInsertSettingsPage(somSelf,hwndNotebook,&pageinfo);
|
---|
440 |
|
---|
441 | }
|
---|
442 |
|
---|
443 |
|
---|
444 | SOM_Scope HBITMAP SOMLINK cwimg_cwmmQuerySmallBitmapHandle(MMImage *somSelf,
|
---|
445 | ULONG ulSize,
|
---|
446 | PMINIRECORDCORE pmrcToRefresh,
|
---|
447 | HWND hwndCnr)
|
---|
448 | {
|
---|
449 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
450 | MMImageMethodDebug("MMImage","cwimg_cwmmQuerySmallBitmap");
|
---|
451 |
|
---|
452 | if(!_wpIsObjectInitialized(somSelf))
|
---|
453 | return NULLHANDLE;
|
---|
454 |
|
---|
455 | if(_bNoIOProcAvailable)
|
---|
456 | return NULLHANDLE; /* No IO-proc for this image format. Don't try again in the future. */
|
---|
457 |
|
---|
458 | if(ulSize<MAX_SIZE_SMALLBITMAP)
|
---|
459 | ulSize=MAX_SIZE_SMALLBITMAP;
|
---|
460 |
|
---|
461 | if(ulSize>_ulSizeSmallBitmap)
|
---|
462 | {
|
---|
463 | if(_hBitmapSmall) {
|
---|
464 | GpiDeleteBitmap(_hBitmapSmall);
|
---|
465 | _hBitmapSmall=NULLHANDLE;
|
---|
466 | }
|
---|
467 | }
|
---|
468 |
|
---|
469 | /*
|
---|
470 | FIXME: use WinIsWindow() here??
|
---|
471 | */
|
---|
472 | if(!_hBitmapSmall && hwndCreateBMP) {
|
---|
473 | ULONG ulError;
|
---|
474 | PCREATEBMPINFO pCreateBMP;
|
---|
475 | _ulSizeSmallBitmap=0;
|
---|
476 |
|
---|
477 |
|
---|
478 | /* Allocate memory for small bitmap info for the thread */
|
---|
479 | if((pCreateBMP=(PCREATEBMPINFO)_wpAllocMem(somSelf, sizeof(CREATEBMPINFO),&ulError))==NULLHANDLE)
|
---|
480 | return NULLHANDLE;
|
---|
481 |
|
---|
482 | pCreateBMP->ulWidth=ulSize;
|
---|
483 | pCreateBMP->ulHeight=ulSize;
|
---|
484 | pCreateBMP->wpObject=somSelf;
|
---|
485 | pCreateBMP->pmrcToRefresh=pmrcToRefresh;
|
---|
486 | pCreateBMP->hwndCnr=hwndCnr;
|
---|
487 |
|
---|
488 | WinPostMsg(hwndCreateBMP, WM_APPTERMINATENOTIFY,MPFROMP(pCreateBMP), MPFROM2SHORT(0, ACKEY_CREATE_SMALLBITMAP));
|
---|
489 |
|
---|
490 | return NULLHANDLE;
|
---|
491 | }
|
---|
492 | /* Return statement to be customized: */
|
---|
493 | return _hBitmapSmall;
|
---|
494 | }
|
---|
495 |
|
---|
496 |
|
---|
497 | SOM_Scope void SOMLINK cwimg_cwmmFreeBitmaps(MMImage *somSelf)
|
---|
498 | {
|
---|
499 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
500 | MMImageMethodDebug("MMImage","cwimg_cwmmFreeBitmaps");
|
---|
501 |
|
---|
502 |
|
---|
503 | if(_pBmpInfoHeader2) {
|
---|
504 | _wpFreeMem(somSelf, _pBmpInfoHeader2);
|
---|
505 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
506 | _chrIOProcName[0]=0;
|
---|
507 | }
|
---|
508 |
|
---|
509 | if(_hBitmap) {
|
---|
510 | GpiDeleteBitmap(_hBitmap);
|
---|
511 | _hBitmap=NULLHANDLE;
|
---|
512 | }
|
---|
513 |
|
---|
514 | _cwmmFreeSmallBitmap(somSelf);
|
---|
515 | }
|
---|
516 |
|
---|
517 | /*
|
---|
518 | * The prototype for cwimg_cwmmFreeSmallBitmap was replaced by the following prototype:
|
---|
519 | */
|
---|
520 | SOM_Scope void SOMLINK cwimg_cwmmFreeSmallBitmap(MMImage *somSelf)
|
---|
521 | {
|
---|
522 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
523 | MMImageMethodDebug("MMImage","cwimg_cwmmFreeSmallBitmap");
|
---|
524 |
|
---|
525 | if(_hBitmapSmall) {
|
---|
526 | GpiDeleteBitmap(_hBitmapSmall);
|
---|
527 | _hBitmapSmall=NULLHANDLE;
|
---|
528 | _ulSizeSmallBitmap=0;
|
---|
529 | }
|
---|
530 | }
|
---|
531 |
|
---|
532 | /* New with V0.2.5, CW 2003/01/02 */
|
---|
533 | SOM_Scope ULONG SOMLINK cwimg_cwmmQueryImageInfo(MMImage *somSelf,
|
---|
534 | char** chrString,
|
---|
535 | ULONG ulSize,
|
---|
536 | int iWhich)
|
---|
537 | {
|
---|
538 | PBITMAPINFOHEADER2 pBmpInfoHdr2=NULLHANDLE;
|
---|
539 | ULONG ulWidth, ulHeight, ulDepth;
|
---|
540 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
541 | MMImageMethodDebug("MMImage","cwimg_cwmmQueryImageInfo");
|
---|
542 |
|
---|
543 | pBmpInfoHdr2=(PBITMAPINFOHEADER2) _wpQueryBitmapInfoHeader(somSelf);
|
---|
544 |
|
---|
545 | if(!pBmpInfoHdr2)
|
---|
546 | return 0;
|
---|
547 |
|
---|
548 | if(pBmpInfoHdr2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
549 | ulWidth=pBmpInfoHdr2->cx;
|
---|
550 | ulHeight=pBmpInfoHdr2->cy;
|
---|
551 | ulDepth=pBmpInfoHdr2->cBitCount;
|
---|
552 | }
|
---|
553 | else {
|
---|
554 | PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)pBmpInfoHdr2;
|
---|
555 | ulWidth=pBmpInfoHdr->cx;
|
---|
556 | ulHeight=pBmpInfoHdr->cy;
|
---|
557 | ulDepth=pBmpInfoHdr->cBitCount;
|
---|
558 | }
|
---|
559 | switch(iWhich)
|
---|
560 | {
|
---|
561 | case IDINFO_WIDTH:
|
---|
562 | return ulWidth;
|
---|
563 | case IDINFO_HEIGHT:
|
---|
564 | return ulHeight;
|
---|
565 | case IDINFO_BPP:
|
---|
566 | return ulDepth;
|
---|
567 | case IDINFO_FORMAT:
|
---|
568 | {
|
---|
569 | char *chr;
|
---|
570 | /* Image format */
|
---|
571 | if(!chrString)
|
---|
572 | return 0;
|
---|
573 | chr=*chrString;
|
---|
574 | strncpy(chr, _chrIOProcName, ulSize);
|
---|
575 | chr[ulSize-1]=0;
|
---|
576 | if(chr[0]==0)
|
---|
577 | return 0;
|
---|
578 | else
|
---|
579 | return 1;
|
---|
580 | }
|
---|
581 | default:
|
---|
582 | break;
|
---|
583 | }
|
---|
584 | return 0;
|
---|
585 | }
|
---|
586 |
|
---|
587 | /*
|
---|
588 | * The prototype for cwimg_wpQueryBitmapHandle was replaced by the following prototype:
|
---|
589 | */
|
---|
590 | SOM_Scope BOOL SOMLINK cwimg_wpQueryBitmapHandle(MMImage *somSelf,
|
---|
591 | HBITMAP* phBitmap,
|
---|
592 | HPAL* phPalette,
|
---|
593 | ULONG ulWidth,
|
---|
594 | ULONG ulHeight,
|
---|
595 | ULONG ulFlags,
|
---|
596 | long lBackgroundColor,
|
---|
597 | BOOL* pbQuitEarly)
|
---|
598 | {
|
---|
599 | ULONG ulSize;
|
---|
600 | char chrName[CCHMAXPATH];
|
---|
601 |
|
---|
602 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
603 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapHandle");
|
---|
604 |
|
---|
605 | /* Check parameter */
|
---|
606 | if(!phBitmap)
|
---|
607 | return FALSE;
|
---|
608 |
|
---|
609 | if(!_wpReadImageFile(somSelf))
|
---|
610 | return FALSE;
|
---|
611 |
|
---|
612 |
|
---|
613 | *phBitmap=NULLHANDLE;
|
---|
614 | if(phPalette)
|
---|
615 | *phPalette=NULLHANDLE;
|
---|
616 |
|
---|
617 | ulSize=sizeof(chrName);
|
---|
618 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
619 | return FALSE;
|
---|
620 |
|
---|
621 |
|
---|
622 | TRY_LOUD(QRY_HBM) {
|
---|
623 | *phBitmap=createNewBitmap ( _hBitmap, (PBITMAPINFOHEADER2) _pBmpInfoHeader2,
|
---|
624 | ulWidth, ulHeight , pbQuitEarly);
|
---|
625 | }
|
---|
626 | CATCH(QRY_HBM)
|
---|
627 | {
|
---|
628 | *phBitmap=NULLHANDLE;
|
---|
629 |
|
---|
630 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling createNewBitmap().\n",
|
---|
631 | __FUNCTION__, __FILE__, __LINE__);
|
---|
632 | SysWriteToTrapLog("Image file: %s\n\n",
|
---|
633 | chrName);
|
---|
634 | } END_CATCH;
|
---|
635 |
|
---|
636 | if(!*phBitmap)
|
---|
637 | return FALSE;
|
---|
638 |
|
---|
639 | return TRUE;
|
---|
640 | }
|
---|
641 |
|
---|
642 | /*
|
---|
643 | * The prototype for cwimg_wpQueryBitmapInfoHeader was replaced by the following prototype:
|
---|
644 | */
|
---|
645 | SOM_Scope PBYTE SOMLINK cwimg_wpQueryBitmapInfoHeader(MMImage *somSelf)
|
---|
646 | {
|
---|
647 | ULONG ulSize;
|
---|
648 | char chrName[CCHMAXPATH];
|
---|
649 | PBYTE pByte;
|
---|
650 | BOOL bGotHeader=FALSE;
|
---|
651 |
|
---|
652 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
653 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapInfoHeader");
|
---|
654 |
|
---|
655 | /* This is necessary for newly created files. */
|
---|
656 | if(!_wpIsObjectInitialized(somSelf))
|
---|
657 | return NULLHANDLE;
|
---|
658 |
|
---|
659 | #ifdef DEBUG
|
---|
660 | ulSize=sizeof(chrName);
|
---|
661 | if(_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
662 | HlpWriteToTrapLog("In _wpQueryBitmapInfoHeader() for %s\n", chrName);
|
---|
663 | else
|
---|
664 | HlpWriteToTrapLog("In _wpQueryBitmapInfoHeader(), filename unknown\n");
|
---|
665 | #endif
|
---|
666 |
|
---|
667 | if(_pBmpInfoHeader2)
|
---|
668 | return _pBmpInfoHeader2;
|
---|
669 |
|
---|
670 | if(_bNoIOProcAvailable)
|
---|
671 | return NULL; /* No IO-proc for this image format. Don't try again in the future. */
|
---|
672 |
|
---|
673 | ulSize=sizeof(chrName);
|
---|
674 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
675 | return NULL;
|
---|
676 |
|
---|
677 | #ifdef DEBUG
|
---|
678 | HlpWriteToTrapLog("_wpQueryBitmapInfoHeader(), reading header from file: %s\n",
|
---|
679 | chrName);
|
---|
680 | #endif
|
---|
681 |
|
---|
682 | if((pByte=_wpAllocMem(somSelf, sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2), &ulSize))==NULLHANDLE)
|
---|
683 | return NULL;
|
---|
684 |
|
---|
685 | TRY_LOUD(GET_BMPIH) {
|
---|
686 | bGotHeader=getBmpInfoHeader( (PBITMAPINFOHEADER2) pByte, chrName, _chrIOProcName,
|
---|
687 | sizeof(_chrIOProcName), &_bNoIOProcAvailable);
|
---|
688 | }
|
---|
689 | CATCH(GET_BMPIH)
|
---|
690 | {
|
---|
691 | #if 0
|
---|
692 | if(MBID_YES==showMsgBoxFlag(IDSTR_CWIMAGETITLE, IDSTR_IMGIOPROCCRASH, queryModuleHandle(),
|
---|
693 | MB_YESNO | MB_MOVEABLE | MB_WARNING))
|
---|
694 | exit(0);
|
---|
695 | #endif
|
---|
696 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling getBmpInfoHeader().\n",
|
---|
697 | __FUNCTION__, __FILE__, __LINE__);
|
---|
698 | SysWriteToTrapLog("Image file: %s\n\n",
|
---|
699 | chrName);
|
---|
700 |
|
---|
701 | } END_CATCH;
|
---|
702 |
|
---|
703 | #ifdef DEBUG
|
---|
704 | if(bGotHeader)
|
---|
705 | HlpWriteToTrapLog("Got header...\n");
|
---|
706 | else
|
---|
707 | HlpWriteToTrapLog("Error with header...\n");
|
---|
708 | #endif
|
---|
709 |
|
---|
710 | if(!bGotHeader) {
|
---|
711 | _wpFreeMem(somSelf, pByte);
|
---|
712 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
713 | _chrIOProcName[0]=0;
|
---|
714 | return NULL;
|
---|
715 | }
|
---|
716 | _pBmpInfoHeader2=pByte;
|
---|
717 | /* Update instance data */
|
---|
718 | if(((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
719 | _ulWidth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cx;
|
---|
720 | _ulHeight=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cy;
|
---|
721 | _ulDepth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cBitCount;
|
---|
722 | }
|
---|
723 | else {
|
---|
724 | PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)_pBmpInfoHeader2;
|
---|
725 | _ulWidth=pBmpInfoHdr->cx;
|
---|
726 | _ulHeight=pBmpInfoHdr->cy;
|
---|
727 | _ulDepth=pBmpInfoHdr->cBitCount;
|
---|
728 | }
|
---|
729 |
|
---|
730 | return (PBYTE) _pBmpInfoHeader2;
|
---|
731 | }
|
---|
732 |
|
---|
733 | /*
|
---|
734 | * The prototype for cwimg_wpQueryBitmapData was replaced by the following prototype:
|
---|
735 | */
|
---|
736 | SOM_Scope PBYTE SOMLINK cwimg_wpQueryBitmapData(MMImage *somSelf,
|
---|
737 | ULONG* pulSize)
|
---|
738 | {
|
---|
739 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
740 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapData");
|
---|
741 |
|
---|
742 | NOT_IMPLEMENTED
|
---|
743 |
|
---|
744 | return (MMImage_parent_WPImageFile_wpQueryBitmapData(somSelf,
|
---|
745 | pulSize));
|
---|
746 | }
|
---|
747 |
|
---|
748 | /*
|
---|
749 | * The prototype for cwimg_wpSetBitmapData was replaced by the following prototype:
|
---|
750 | */
|
---|
751 | SOM_Scope BOOL SOMLINK cwimg_wpSetBitmapData(MMImage *somSelf,
|
---|
752 | PBYTE pBitmapData,
|
---|
753 | ULONG ulSize)
|
---|
754 | {
|
---|
755 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
756 | MMImageMethodDebug("MMImage","cwimg_wpSetBitmapData");
|
---|
757 |
|
---|
758 | NOT_IMPLEMENTED
|
---|
759 |
|
---|
760 | #if 0
|
---|
761 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
762 | "This function is not available. Please tell the author the steps causing this message box so the function may be implemented.",
|
---|
763 | "cwimg_wpSetBitmapData",
|
---|
764 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
|
---|
765 | #endif
|
---|
766 |
|
---|
767 | return (MMImage_parent_WPImageFile_wpSetBitmapData(somSelf,
|
---|
768 | pBitmapData,
|
---|
769 | ulSize));
|
---|
770 | }
|
---|
771 |
|
---|
772 | /*
|
---|
773 | * The prototype for cwimg_wpReadImageFile was replaced by the following prototype:
|
---|
774 | */
|
---|
775 | SOM_Scope BOOL SOMLINK cwimg_wpReadImageFile(MMImage *somSelf)
|
---|
776 | {
|
---|
777 | char chrName[CCHMAXPATH];
|
---|
778 | ULONG ulSize;
|
---|
779 | BOOL bGotHeader=FALSE;
|
---|
780 |
|
---|
781 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
782 | MMImageMethodDebug("MMImage","cwimg_wpReadImageFile");
|
---|
783 |
|
---|
784 | if(!_wpIsObjectInitialized(somSelf))
|
---|
785 | return NULLHANDLE;
|
---|
786 |
|
---|
787 | if(_hBitmap)
|
---|
788 | return TRUE;
|
---|
789 |
|
---|
790 | ulSize=sizeof(chrName);
|
---|
791 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
792 | return FALSE;
|
---|
793 |
|
---|
794 | #ifdef DEBUG
|
---|
795 | HlpWriteToTrapLog("In _wpReadImageFile(), file: %s \n",
|
---|
796 | chrName);
|
---|
797 | #endif
|
---|
798 |
|
---|
799 | TRY_LOUD(LOAD_BMP) {
|
---|
800 | if(_wpQueryBitmapInfoHeader(somSelf))
|
---|
801 | bGotHeader=TRUE;
|
---|
802 | }
|
---|
803 | CATCH(LOAD_BMP)
|
---|
804 | {
|
---|
805 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling _wpQueryBitmapInfoHeader().\n",
|
---|
806 | __FUNCTION__, __FILE__, __LINE__);
|
---|
807 | SysWriteToTrapLog("Image file: %s\n",
|
---|
808 | chrName);
|
---|
809 | }END_CATCH;
|
---|
810 |
|
---|
811 | if(!bGotHeader)
|
---|
812 | return FALSE;
|
---|
813 | _hBitmap=NULLHANDLE;
|
---|
814 |
|
---|
815 | TRY_LOUD(LOAD_BMP2) {
|
---|
816 | _hBitmap=loadBitmap ( chrName , (PBITMAPINFOHEADER2) _pBmpInfoHeader2);
|
---|
817 | }
|
---|
818 | CATCH(LOAD_BMP2)
|
---|
819 | {
|
---|
820 | SysWriteToTrapLog("\nTrap occured in %s (LOAD_BMP2), file %s, around line %d while calling _wpQueryBitmapInfoHeader().\n",
|
---|
821 | __FUNCTION__, __FILE__, __LINE__);
|
---|
822 | } END_CATCH;
|
---|
823 |
|
---|
824 | if(!_hBitmap) {
|
---|
825 | return FALSE;
|
---|
826 | }
|
---|
827 |
|
---|
828 | return TRUE;
|
---|
829 | }
|
---|
830 |
|
---|
831 |
|
---|
832 | SOM_Scope BOOL SOMLINK cwimg_wpWriteImageFile(MMImage *somSelf)
|
---|
833 | {
|
---|
834 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
835 | MMImageMethodDebug("MMImage","cwimg_wpWriteImageFile");
|
---|
836 |
|
---|
837 | NOT_IMPLEMENTED
|
---|
838 |
|
---|
839 | #if 0
|
---|
840 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
841 | "This function is not available. Please tell the author the steps causing this message box so the function may be implemented.",
|
---|
842 | "cwimg_wpWriteImageFile",
|
---|
843 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
|
---|
844 | #endif
|
---|
845 |
|
---|
846 | return (MMImage_parent_WPImageFile_wpWriteImageFile(somSelf));
|
---|
847 | }
|
---|
848 |
|
---|
849 | /*
|
---|
850 | * wpInitData: override; Not used. Default is instance var initializing to zero and that's what we need.
|
---|
851 | */
|
---|
852 |
|
---|
853 |
|
---|
854 | SOM_Scope void SOMLINK cwimg_wpUnInitData(MMImage *somSelf)
|
---|
855 | {
|
---|
856 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
857 | MMImageMethodDebug("MMImage","cwimg_wpUnInitData");
|
---|
858 |
|
---|
859 | if(_pBmpInfoHeader2) {
|
---|
860 | _wpFreeMem(somSelf, _pBmpInfoHeader2);
|
---|
861 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
862 | }
|
---|
863 | /* This frees all bitmaps. Small for icons and the normal size one */
|
---|
864 | _cwmmFreeBitmaps(somSelf);
|
---|
865 | MMImage_parent_WPImageFile_wpUnInitData(somSelf);
|
---|
866 | }
|
---|
867 |
|
---|
868 | /*
|
---|
869 | FIXME:
|
---|
870 |
|
---|
871 | This function isn't thread safe because of one global memory area. It is supposed to be
|
---|
872 | called from the wpPopupMenu() method. This method can only be called once at
|
---|
873 | a time, so that's not a problem. It may become a problem if this function is also
|
---|
874 | called from somewhere else. The global mem pointer is used by the image class and the
|
---|
875 | audio class.
|
---|
876 | */
|
---|
877 | BOOL insertIOProcMenuItems( HWND hwndMenu )
|
---|
878 | {
|
---|
879 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
---|
880 | MMFORMATINFO mmFormatInfo;
|
---|
881 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
882 | ULONG ulReturnCode;
|
---|
883 | LONG lFormatsRead;
|
---|
884 | LONG index;
|
---|
885 | LONG lBytesRead;
|
---|
886 | HWND hwndSubMenu;
|
---|
887 | MENUITEM mi;
|
---|
888 |
|
---|
889 | if(g_pmmFormatInfoArray)
|
---|
890 | free(g_pmmFormatInfoArray);
|
---|
891 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
892 |
|
---|
893 | memset( &mmFormatInfo,
|
---|
894 | '\0',
|
---|
895 | sizeof(MMFORMATINFO) );
|
---|
896 |
|
---|
897 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
898 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
|
---|
899 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
900 | &lNumIOProcs,
|
---|
901 | 0,
|
---|
902 | 0 );
|
---|
903 |
|
---|
904 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
905 | {
|
---|
906 | /* Error - mmioQueryFormatCount failed. */
|
---|
907 | return FALSE;
|
---|
908 | }
|
---|
909 |
|
---|
910 | /*
|
---|
911 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
912 | */
|
---|
913 | g_pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
914 | if( g_pmmFormatInfoArray == NULL )
|
---|
915 | {
|
---|
916 | /* Could not allocate enough memory for mmFormatInfo array. */
|
---|
917 | return FALSE;
|
---|
918 | }
|
---|
919 |
|
---|
920 | /*
|
---|
921 | * call mmioGetFormats to get info on the formats supported.
|
---|
922 | */
|
---|
923 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
924 | lNumIOProcs,
|
---|
925 | g_pmmFormatInfoArray,
|
---|
926 | &lFormatsRead,
|
---|
927 | 0,
|
---|
928 | 0 );
|
---|
929 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
930 | {
|
---|
931 | /*
|
---|
932 | * mmioGetFormats failed.
|
---|
933 | */
|
---|
934 | free(g_pmmFormatInfoArray);
|
---|
935 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
936 | return FALSE;
|
---|
937 | }
|
---|
938 |
|
---|
939 | if( lFormatsRead != lNumIOProcs )
|
---|
940 | {
|
---|
941 | /*
|
---|
942 | * Error in MMIO - number of formats read in by
|
---|
943 | * mmioGetFormats is not equal to number of formats
|
---|
944 | * found by mmioQueryFormatCount.
|
---|
945 | */
|
---|
946 | free(g_pmmFormatInfoArray);
|
---|
947 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
948 | return FALSE;
|
---|
949 | }
|
---|
950 |
|
---|
951 | // Create Empty Submenu //
|
---|
952 | hwndSubMenu=WinCreateWindow(hwndMenu,WC_MENU,"",0,
|
---|
953 | 0,0,0,0,
|
---|
954 | hwndMenu,//Owner. If set, this window
|
---|
955 | //is destroyed if owner is destroyed
|
---|
956 | HWND_TOP,
|
---|
957 | ID_MENU_CONVERT,//menuid
|
---|
958 | NULL,NULL);
|
---|
959 |
|
---|
960 | mi.iPosition=MIT_END;
|
---|
961 | mi.afStyle=MIS_TEXT;//|MIS_SUBMENU;
|
---|
962 | mi.id=ID_MENU_CONVERT;
|
---|
963 | mi.afAttribute=NULLHANDLE;
|
---|
964 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
---|
965 | mi.hItem=NULLHANDLE;
|
---|
966 | mi.hwndSubMenu=hwndSubMenu;
|
---|
967 |
|
---|
968 | if(!getMessage(szBuffer, IDSTR_MENU_CONVERT, sizeof(szBuffer), queryResModuleHandle(), HWND_DESKTOP))
|
---|
969 | sprintf(szBuffer,"~Convert to");
|
---|
970 | WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&mi,
|
---|
971 | (MPARAM)szBuffer);
|
---|
972 |
|
---|
973 | pmmFormatInfoArray=g_pmmFormatInfoArray;
|
---|
974 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
975 | {
|
---|
976 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
---|
977 |
|
---|
978 | /* Insert NULL string terminator */
|
---|
979 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
---|
980 |
|
---|
981 | /* Compressed TIF is not supported because the Warp 4 IO-Procs are
|
---|
982 | broken. */
|
---|
983 | // HlpWriteToTrapLog("--------- IO-Proc: %s, Name: %s\n", pmmFormatInfoArray->szDefaultFormatExt,
|
---|
984 | // szBuffer);
|
---|
985 |
|
---|
986 | if(pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFMC",MMIO_TOUPPER) &&
|
---|
987 | pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFIC",MMIO_TOUPPER) &&
|
---|
988 | (pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED))
|
---|
989 | {
|
---|
990 | /* Add menu item */
|
---|
991 | /* Fill the MENUITEM structure */
|
---|
992 | mi.iPosition=MIT_END;
|
---|
993 | mi.afStyle=MIS_TEXT|MIS_SUBMENU;
|
---|
994 | mi.id=ID_ITEM_FIRSTCONVERT+index;/* Create menu id */
|
---|
995 | mi.afAttribute=NULLHANDLE;
|
---|
996 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
---|
997 | mi.hItem=NULLHANDLE;
|
---|
998 | WinSendMsg(hwndSubMenu, MM_INSERTITEM,(MPARAM)&mi,
|
---|
999 | (MPARAM)szBuffer);
|
---|
1000 | }
|
---|
1001 | /*
|
---|
1002 | * advance to next entry in mmFormatInfo array
|
---|
1003 | */
|
---|
1004 | pmmFormatInfoArray++;
|
---|
1005 | }
|
---|
1006 | return TRUE;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 |
|
---|
1010 |
|
---|
1011 | /*
|
---|
1012 | * wpInitData: override; Not used. Default is instance var initializing to zero and that's what we need.
|
---|
1013 | */
|
---|
1014 |
|
---|
1015 | SOM_Scope ULONG SOMLINK cwimg_wpQueryDefaultView(MMImage *somSelf)
|
---|
1016 | {
|
---|
1017 | ULONG ulReturn;
|
---|
1018 |
|
---|
1019 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1020 | MMImageMethodDebug("MMImage","cwimg_wpQueryDefaultView");
|
---|
1021 |
|
---|
1022 | ulReturn=(MMImage_parent_WPImageFile_wpQueryDefaultView(somSelf));
|
---|
1023 |
|
---|
1024 | if(ulReturn==OPEN_RUNNING)
|
---|
1025 | {
|
---|
1026 | ULONG ulHowMatched=1;
|
---|
1027 | char chrID[100];
|
---|
1028 | /* Check if associated program is still available */
|
---|
1029 | if(!_wpQueryAssociatedProgram(somSelf, OPEN_RUNNING, &ulHowMatched,
|
---|
1030 | chrID, sizeof(chrID),(PSZ)-1))
|
---|
1031 | return ID_MENU_IMGEDITOR; /* The associated progarm is lost */
|
---|
1032 | }
|
---|
1033 | return ulReturn;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | /*
|
---|
1037 | * The prototype for cwimg_wpModifyPopupMenu was replaced by the following prototype:
|
---|
1038 | */
|
---|
1039 | SOM_Scope BOOL SOMLINK cwimg_wpModifyPopupMenu(MMImage *somSelf,
|
---|
1040 | HWND hwndMenu,
|
---|
1041 | HWND hwndCnr,
|
---|
1042 | ULONG iPosition)
|
---|
1043 | {
|
---|
1044 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1045 | MMImageMethodDebug("MMImage","cwimg_wpModifyPopupMenu");
|
---|
1046 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_IMGEDITOR, 1);
|
---|
1047 |
|
---|
1048 | TRY_LOUD(IMAGE_INSERTPOPUPMENU) {
|
---|
1049 | /* Insert image info */
|
---|
1050 | if(_ulWidth!=0 && _ulHeight!=0 && _ulDepth!=0)
|
---|
1051 | {
|
---|
1052 | char text[120];
|
---|
1053 | char menuText[200];
|
---|
1054 | MENUITEM menuItem;
|
---|
1055 |
|
---|
1056 | if(!getMessage(text, IDSTR_MENU_IMAGEINFO, sizeof(text), queryResModuleHandle(), hwndMenu))
|
---|
1057 | strcpy(text, "Image information: %d x %d x %d");
|
---|
1058 |
|
---|
1059 | sprintf(menuText, text, _ulWidth, _ulHeight, _ulDepth);//create menuitem
|
---|
1060 |
|
---|
1061 | //insert size menuitem in popupmenu
|
---|
1062 |
|
---|
1063 | menuItem.iPosition=MIT_END;
|
---|
1064 | menuItem.afStyle=MIS_TEXT|MIS_STATIC;
|
---|
1065 | menuItem.afAttribute=0;
|
---|
1066 | menuItem.id=ID_MENU_IMAGEINFO;
|
---|
1067 | menuItem.hwndSubMenu=NULLHANDLE;
|
---|
1068 | menuItem.hItem=0;
|
---|
1069 | WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&menuItem,(MPARAM)&menuText);
|
---|
1070 | }
|
---|
1071 | /* Insert all known image I/O procs */
|
---|
1072 | insertIOProcMenuItems( hwndMenu );
|
---|
1073 | menuInsertMenuSeparator(hwndMenu, NULLHANDLE, MIT_END );
|
---|
1074 |
|
---|
1075 | }/* TRY_LOUD */
|
---|
1076 | CATCH(IMAGE_INSERTPOPUPMENU)
|
---|
1077 | {
|
---|
1078 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
---|
1079 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1080 | } END_CATCH;
|
---|
1081 |
|
---|
1082 | return (MMImage_parent_WPImageFile_wpModifyPopupMenu(somSelf,
|
---|
1083 | hwndMenu,
|
---|
1084 | hwndCnr,
|
---|
1085 | iPosition));
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 |
|
---|
1089 | /*
|
---|
1090 | * The prototype for cwimg_wpMenuItemSelected was replaced by the following prototype:
|
---|
1091 | */
|
---|
1092 | SOM_Scope BOOL SOMLINK cwimg_wpMenuItemSelected(MMImage *somSelf,
|
---|
1093 | HWND hwndFrame,
|
---|
1094 | ULONG ulMenuId)
|
---|
1095 | {
|
---|
1096 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1097 | MMImageMethodDebug("MMImage","cwimg_wpMenuItemSelected");
|
---|
1098 |
|
---|
1099 | if(ulMenuId>=ID_ITEM_FIRSTCONVERT && ulMenuId<=ID_ITEM_FIRSTCONVERT+lNumIOProcs-1)
|
---|
1100 | {
|
---|
1101 | char chrEditor[CCHMAXPATH]={0};
|
---|
1102 | char chrParams[2*CCHMAXPATH]="\"";
|
---|
1103 | char *chrPtr=chrParams;
|
---|
1104 | ULONG ulSize;
|
---|
1105 | ULONG ulRc;
|
---|
1106 |
|
---|
1107 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageconverter", "", chrEditor,
|
---|
1108 | sizeof(chrEditor));
|
---|
1109 | chrPtr++;
|
---|
1110 | ulSize=sizeof(chrParams);
|
---|
1111 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
---|
1112 | strcat(chrPtr,"\" \"");
|
---|
1113 | chrPtr=strrchr(chrPtr, 0);
|
---|
1114 | mmioGetFormatName(&g_pmmFormatInfoArray[ulMenuId-ID_ITEM_FIRSTCONVERT], chrPtr,(LONG*) &ulSize, 0L, 0L);
|
---|
1115 | *( chrPtr + ulSize ) = (CHAR)NULL;
|
---|
1116 | strcat(chrPtr,"\"");
|
---|
1117 |
|
---|
1118 | if((ulRc=launchPMProg("", chrEditor, chrParams, somSelf, ulMenuId-ID_ITEM_FIRSTCONVERT))==NULLHANDLE) {
|
---|
1119 | /* Error */
|
---|
1120 | return TRUE;
|
---|
1121 | }
|
---|
1122 | return TRUE;
|
---|
1123 | }
|
---|
1124 | switch(ulMenuId)
|
---|
1125 | {
|
---|
1126 | case ID_MENU_IMGEDITOR:
|
---|
1127 | _wpViewObject(somSelf, NULLHANDLE, ulMenuId, 0);
|
---|
1128 | return TRUE;
|
---|
1129 | default:
|
---|
1130 | break;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | return (MMImage_parent_WPImageFile_wpMenuItemSelected(somSelf,
|
---|
1134 | hwndFrame,
|
---|
1135 | ulMenuId));
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | /*
|
---|
1139 | * The prototype for cwimg_wpOpen was replaced by the following prototype:
|
---|
1140 | */
|
---|
1141 | SOM_Scope HWND SOMLINK cwimg_wpOpen(MMImage *somSelf, HWND hwndCnr,
|
---|
1142 | ULONG ulView, ULONG param)
|
---|
1143 | {
|
---|
1144 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
1145 | MMImageMethodDebug("MMImage","cwimg_wpOpen");
|
---|
1146 |
|
---|
1147 | switch(ulView)
|
---|
1148 | {
|
---|
1149 | case ID_MENU_IMGEDITOR:
|
---|
1150 | /*case 0xbc2b: editor */
|
---|
1151 | {
|
---|
1152 | char chrEditor[CCHMAXPATH]={0};
|
---|
1153 | char chrParams[CCHMAXPATH+2]="\"";
|
---|
1154 | char chrTitle[50];
|
---|
1155 | char *chrPtr=chrParams;
|
---|
1156 | ULONG ulSize;
|
---|
1157 | ULONG ulRc;
|
---|
1158 |
|
---|
1159 | if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageeditor", NULLHANDLE, chrEditor,
|
---|
1160 | sizeof(chrEditor)))
|
---|
1161 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "ib", NULLHANDLE, chrEditor,
|
---|
1162 | sizeof(chrEditor));
|
---|
1163 |
|
---|
1164 | chrPtr++;
|
---|
1165 | ulSize=sizeof(chrParams)-2;
|
---|
1166 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
---|
1167 | strcat(chrPtr,"\"");
|
---|
1168 |
|
---|
1169 | if(!getMessage(chrTitle, IDSTR_IMGEDITORTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1170 | strcpy(chrTitle, "Editor");
|
---|
1171 |
|
---|
1172 | if((ulRc=launchPMProg( chrTitle, chrEditor, chrParams, somSelf, ulView))==NULLHANDLE) {
|
---|
1173 | return NULLHANDLE;
|
---|
1174 | }
|
---|
1175 | return NULLHANDLE;
|
---|
1176 | }
|
---|
1177 | default:
|
---|
1178 | break;
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | return (MMImage_parent_WPImageFile_wpOpen(somSelf, hwndCnr,
|
---|
1182 | ulView, param));
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 |
|
---|
1186 | /*
|
---|
1187 | * The prototype for cwimg_wpAddSettingsPages was replaced by the following prototype:
|
---|
1188 | */
|
---|
1189 | SOM_Scope BOOL SOMLINK cwimg_wpAddSettingsPages(MMImage *somSelf,
|
---|
1190 | HWND hwndNotebook)
|
---|
1191 | {
|
---|
1192 | BOOL rc;
|
---|
1193 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1194 | MMImageMethodDebug("MMImage","cwimg_wpAddSettingsPages");
|
---|
1195 |
|
---|
1196 | rc=(MMImage_parent_WPImageFile_wpAddSettingsPages(somSelf,
|
---|
1197 | hwndNotebook));
|
---|
1198 | return rc | (_cwmmAddImageInformationPage(somSelf, hwndNotebook));
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 |
|
---|
1202 | /*
|
---|
1203 | * The prototype for cwimg_wpQueryDetailsData was replaced by the following prototype:
|
---|
1204 | */
|
---|
1205 | SOM_Scope ULONG SOMLINK cwimg_wpQueryDetailsData(MMImage *somSelf,
|
---|
1206 | PVOID* ppDetailsData,
|
---|
1207 | PULONG pcp)
|
---|
1208 | {
|
---|
1209 | BOOL rcParent;
|
---|
1210 | PIMAGEDETAILS pImageDetails;
|
---|
1211 |
|
---|
1212 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1213 | MMImageMethodDebug("MMImage","cwimg_wpQueryDetailsData");
|
---|
1214 |
|
---|
1215 | /* Fill parent info */
|
---|
1216 | rcParent=(MMImage_parent_WPImageFile_wpQueryDetailsData(somSelf,
|
---|
1217 | ppDetailsData,
|
---|
1218 | pcp));
|
---|
1219 |
|
---|
1220 | /* The WPS asks for data to be displayed */
|
---|
1221 | if(ppDetailsData)
|
---|
1222 | {
|
---|
1223 | ULONG ulWidth, ulHeight, ulDepth;
|
---|
1224 |
|
---|
1225 | PBITMAPINFOHEADER2 pBmpInfoHeader2=NULLHANDLE;
|
---|
1226 |
|
---|
1227 | #if 0
|
---|
1228 | if(_bUseNewClsFeatures) /* Read info from CD only if allowed. The check if the object
|
---|
1229 | is on CD is done in wpRestore() */
|
---|
1230 | pBmpInfoHeader2=(PBITMAPINFOHEADER2) _wpQueryBitmapInfoHeader(somSelf);
|
---|
1231 | #endif
|
---|
1232 |
|
---|
1233 | pBmpInfoHeader2=(PBITMAPINFOHEADER2)_pBmpInfoHeader2;
|
---|
1234 |
|
---|
1235 | if(pBmpInfoHeader2) {
|
---|
1236 | //DosBeep(1500,200);
|
---|
1237 | if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
1238 | ulWidth=pBmpInfoHeader2->cx;
|
---|
1239 | ulHeight=pBmpInfoHeader2->cy;
|
---|
1240 | ulDepth=pBmpInfoHeader2->cBitCount;
|
---|
1241 | }
|
---|
1242 | else {
|
---|
1243 | PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
|
---|
1244 | ulWidth=pBmpInfoHeader->cx;
|
---|
1245 | ulHeight=pBmpInfoHeader->cy;
|
---|
1246 | ulDepth=pBmpInfoHeader->cBitCount;
|
---|
1247 | }
|
---|
1248 | }
|
---|
1249 | else
|
---|
1250 | {
|
---|
1251 | ulWidth=_ulWidth;
|
---|
1252 | ulHeight=_ulHeight;
|
---|
1253 | ulDepth=_ulDepth;
|
---|
1254 | }
|
---|
1255 | /* Fill the structure with the info to be displayed */
|
---|
1256 | pImageDetails=(PIMAGEDETAILS)*ppDetailsData;
|
---|
1257 | pImageDetails->ulWidth=ulWidth;
|
---|
1258 | pImageDetails->ulHeight=ulHeight;
|
---|
1259 | pImageDetails->ulDepth=ulDepth;
|
---|
1260 | pImageDetails->pszFormat=_chrIOProcName;
|
---|
1261 |
|
---|
1262 | *ppDetailsData=((PBYTE) (*ppDetailsData))+sizeof(*pImageDetails);
|
---|
1263 | }
|
---|
1264 | else
|
---|
1265 | {
|
---|
1266 | /* Buffer size is queried */
|
---|
1267 | if(pcp)
|
---|
1268 | *pcp+=sizeof(*pImageDetails);
|
---|
1269 | }
|
---|
1270 | return rcParent;
|
---|
1271 | }
|
---|
1272 |
|
---|
1273 | /*
|
---|
1274 | * The prototype for cwimg_wpRestoreState was replaced by the following prototype:
|
---|
1275 | */
|
---|
1276 | SOM_Scope BOOL SOMLINK cwimg_wpRestoreState(MMImage *somSelf,
|
---|
1277 | ULONG ulReserved)
|
---|
1278 | {
|
---|
1279 | BOOL bReRead=FALSE;
|
---|
1280 |
|
---|
1281 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1282 | MMImageMethodDebug("MMImage","cwimg_wpRestoreState");
|
---|
1283 |
|
---|
1284 | _bUseNewClsFeatures=TRUE;
|
---|
1285 |
|
---|
1286 | if(cwObjectIsOnCD(somSelf)) {
|
---|
1287 | /* The object is on CD. Check if we should use the new class features */
|
---|
1288 | if(!PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", IMAGECLS_FEATURES_ON_CD_KEY, 0))
|
---|
1289 | _bUseNewClsFeatures=FALSE;
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | /* Use cached image size so the values are shown in details view on first opening of a folder. The problem is that
|
---|
1293 | wpQueryDetailsData() is called before the object data is fully initialized. wpIsObjectInitialized() returns
|
---|
1294 | TRUE but wpQueryRealName() fails at that early stage so it's impossible to read the image data from the file (because
|
---|
1295 | the filename is unknown). Querying the image data in wpObjectReady() is to late because that method is called after
|
---|
1296 | wpQueryDetailsData(). In wpObjectReady the image header will be read in. */
|
---|
1297 |
|
---|
1298 | /* Query the image info */
|
---|
1299 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_FILESIZE, &_ulFileSize))
|
---|
1300 | bReRead=TRUE;
|
---|
1301 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_WIDTH, &_ulWidth))
|
---|
1302 | bReRead=TRUE;
|
---|
1303 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_HEIGHT, &_ulHeight))
|
---|
1304 | bReRead=TRUE;
|
---|
1305 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_DEPTH, &_ulDepth))
|
---|
1306 | bReRead=TRUE;
|
---|
1307 | if(_ulWidth==0 || _ulHeight==0 || _ulDepth!=0)
|
---|
1308 | bReRead=TRUE;
|
---|
1309 | // if(_bUseNewClsFeatures) /* Read info from CD only if allowed. The check if the object
|
---|
1310 | // is on CD is done in wpRestore() */
|
---|
1311 | // _wpQueryBitmapInfoHeader(somSelf);
|
---|
1312 | //DosBeep(5000,200);
|
---|
1313 | return (MMImage_parent_WPImageFile_wpRestoreState(somSelf,
|
---|
1314 | ulReserved));
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 | void mmRefreshRecords(MMImage *somSelf)
|
---|
1318 | {
|
---|
1319 | PUSEITEM pUse;
|
---|
1320 |
|
---|
1321 | for(pUse=_wpFindUseItem(somSelf, USAGE_RECORD/*VIEW_CONTENTS|VIEW_DETAILS|VIEW_TREE*/, NULL );pUse;
|
---|
1322 | pUse=_wpFindUseItem(somSelf, USAGE_RECORD/* VIEW_CONTENTS|VIEW_DETAILS|VIEW_TREE*/, pUse ))
|
---|
1323 | {
|
---|
1324 | PRECORDITEM pRecordItem=(PRECORDITEM)++pUse;
|
---|
1325 | WinPostMsg(pRecordItem->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pRecordItem->pRecord),
|
---|
1326 | MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
1327 | }/* for() */
|
---|
1328 | }
|
---|
1329 |
|
---|
1330 | SOM_Scope BOOL SOMLINK cwimg_wpSetup(MMImage *somSelf, PSZ pszSetupString)
|
---|
1331 | {
|
---|
1332 | char buffer[CCHMAXPATH];
|
---|
1333 | ULONG bufferSize;
|
---|
1334 |
|
---|
1335 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1336 | MMImageMethodDebug("MMImage","cwimg_wpSetup");
|
---|
1337 |
|
---|
1338 |
|
---|
1339 | /* Refresh */
|
---|
1340 | bufferSize=sizeof(buffer);
|
---|
1341 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMREFRESH, buffer,&bufferSize))
|
---|
1342 | {
|
---|
1343 | _cwmmFreeBitmaps(somSelf);
|
---|
1344 | #if 0
|
---|
1345 | _cwmmQuerySmallBitmapHandle(somSelf,
|
---|
1346 | 0,
|
---|
1347 | NULLHANDLE,
|
---|
1348 | 0);
|
---|
1349 | #endif
|
---|
1350 | mmRefreshRecords(somSelf);
|
---|
1351 | // _wpCnrRefreshDetails(somSelf);
|
---|
1352 | }
|
---|
1353 |
|
---|
1354 | return (MMImage_parent_WPImageFile_wpSetup(somSelf, pszSetupString));
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 |
|
---|
1358 | SOM_Scope void SOMLINK cwimg_wpObjectReady(MMImage *somSelf,
|
---|
1359 | ULONG ulCode, WPObject* refObject)
|
---|
1360 | {
|
---|
1361 | PCREATEBMPINFO pCreateBMP;
|
---|
1362 | ULONG ulError;
|
---|
1363 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1364 | MMImageMethodDebug("MMImage","cwimg_wpObjectReady");
|
---|
1365 |
|
---|
1366 | MMImage_parent_WPImageFile_wpObjectReady(somSelf, ulCode,
|
---|
1367 | refObject);
|
---|
1368 |
|
---|
1369 | /* Get image info asynchronous to replace cached image size read in from EA which
|
---|
1370 | may not be accurate. */
|
---|
1371 | /* Allocate memory for small bitmap info for the thread */
|
---|
1372 | if(hwndCreateBMP && (pCreateBMP=(PCREATEBMPINFO)_wpAllocMem(somSelf, sizeof(CREATEBMPINFO),&ulError))!=NULLHANDLE)
|
---|
1373 | {
|
---|
1374 | /* Only the object pointer is used */
|
---|
1375 | pCreateBMP->wpObject=somSelf;
|
---|
1376 |
|
---|
1377 | // WinPostMsg(hwndCreateBMP, WM_APPTERMINATENOTIFY,MPFROMP(pCreateBMP), MPFROM2SHORT(0, ACKEY_QUERY_BITMAPINFO));
|
---|
1378 | }
|
---|
1379 | /* Refresh records in all views */
|
---|
1380 | //mmRefreshRecords(somSelf);
|
---|
1381 |
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | static BOOL _getMissingExtFromImageIOProc(void)
|
---|
1385 | {
|
---|
1386 | MMFORMATINFO mmFormatInfo;
|
---|
1387 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
1388 | void * memPtr;
|
---|
1389 | ULONG ulReturnCode;
|
---|
1390 | LONG lFormatsRead;
|
---|
1391 | LONG index;
|
---|
1392 |
|
---|
1393 | memset( &mmFormatInfo,
|
---|
1394 | '\0',
|
---|
1395 | sizeof(MMFORMATINFO) );
|
---|
1396 |
|
---|
1397 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
1398 | mmFormatInfo.ulFlags|=MMIO_CANREADTRANSLATED;/* Read !!!*/
|
---|
1399 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
1400 | &lNumIOProcs,
|
---|
1401 | 0,
|
---|
1402 | 0 );
|
---|
1403 |
|
---|
1404 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1405 | {
|
---|
1406 | /*
|
---|
1407 | * Error - mmioQueryFormatCount failed.
|
---|
1408 | */
|
---|
1409 | return FALSE;
|
---|
1410 | }
|
---|
1411 |
|
---|
1412 | /*
|
---|
1413 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
1414 | */
|
---|
1415 | pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
1416 | memPtr=pmmFormatInfoArray;
|
---|
1417 | if( pmmFormatInfoArray == NULL )
|
---|
1418 | {
|
---|
1419 | /*
|
---|
1420 | * Could not allocate enough memory for mmFormatInfo array.
|
---|
1421 | */
|
---|
1422 | return FALSE;
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 | /*
|
---|
1426 | * call mmioGetFormats to get info on the formats supported.
|
---|
1427 | */
|
---|
1428 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
1429 | lNumIOProcs,
|
---|
1430 | pmmFormatInfoArray,
|
---|
1431 | &lFormatsRead,
|
---|
1432 | 0,
|
---|
1433 | 0 );
|
---|
1434 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1435 | {
|
---|
1436 | /*
|
---|
1437 | * mmioGetFormats failed.
|
---|
1438 | */
|
---|
1439 | free(pmmFormatInfoArray);
|
---|
1440 | return FALSE;
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | if( lFormatsRead != lNumIOProcs )
|
---|
1444 | {
|
---|
1445 | /*
|
---|
1446 | * Error in MMIO - number of formats read in by
|
---|
1447 | * mmioGetFormats is not equal to number of formats
|
---|
1448 | * found by mmioQueryFormatCount.
|
---|
1449 | */
|
---|
1450 | free(pmmFormatInfoArray);
|
---|
1451 | return FALSE;
|
---|
1452 | }
|
---|
1453 |
|
---|
1454 |
|
---|
1455 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
1456 | {
|
---|
1457 | /* Now scan the whole image proc array */
|
---|
1458 |
|
---|
1459 | if(!strstr(chrMMImageKnownExt, pmmFormatInfoArray->szDefaultFormatExt)) {
|
---|
1460 | /* This extension is yet unknown */
|
---|
1461 | if(chrMMImageExt[0]==0) {
|
---|
1462 | sprintf(chrMMImageExt,"*.%s", pmmFormatInfoArray->szDefaultFormatExt);
|
---|
1463 | // fFirstExt=FALSE;
|
---|
1464 | }
|
---|
1465 | else {
|
---|
1466 | strncat(chrMMImageExt,",*.",sizeof(chrMMImageExt)-1-strlen(chrMMImageExt));
|
---|
1467 | strncat(chrMMImageExt, pmmFormatInfoArray->szDefaultFormatExt, sizeof(chrMMImageExt)-1-strlen(chrMMImageExt));
|
---|
1468 | }
|
---|
1469 | // HlpWriteToTrapLog("Known Extension: %s\n", chrMMImageKnownExt);
|
---|
1470 | // HlpWriteToTrapLog("Extension: %s\n", chrMMImageExt);
|
---|
1471 | }
|
---|
1472 | /*
|
---|
1473 | * advance to next entry in mmFormatInfo array
|
---|
1474 | */
|
---|
1475 | pmmFormatInfoArray++;
|
---|
1476 | }
|
---|
1477 | free(memPtr);
|
---|
1478 |
|
---|
1479 | return FALSE;
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | SOM_Scope BOOL SOMLINK cwimg_wpSaveState(MMImage *somSelf)
|
---|
1483 | {
|
---|
1484 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1485 | MMImageMethodDebug("MMImage","cwimg_wpSaveState");
|
---|
1486 |
|
---|
1487 | /* Cache the image size so the values are shown in details view on first opening of a folder. The problem is that
|
---|
1488 | wpQueryDetailsData() is called before the object data is fully initialized. wpIsObjectInitialized() returns
|
---|
1489 | TRUE but wpQueryRealName() fails at that early stage so it's impossible to read the image data from the file (because
|
---|
1490 | the filename is unknown). Querying the image data in wpObjectReady() is to late because this method is called after
|
---|
1491 | wpQueryDetailsData(). */
|
---|
1492 | if(_pBmpInfoHeader2) {
|
---|
1493 | if(((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
1494 | _wpSaveLong(somSelf, "CWImage", KEY_WIDTH, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cx);
|
---|
1495 | _wpSaveLong(somSelf, "CWImage", KEY_HEIGHT, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cy);
|
---|
1496 | _wpSaveLong(somSelf, "CWImage", KEY_DEPTH, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cBitCount);
|
---|
1497 | }
|
---|
1498 | else {
|
---|
1499 | PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)_pBmpInfoHeader2;
|
---|
1500 |
|
---|
1501 | _wpSaveLong(somSelf, "CWImage", KEY_WIDTH, pBmpInfoHeader->cx);
|
---|
1502 | _wpSaveLong(somSelf, "CWImage", KEY_HEIGHT, pBmpInfoHeader->cy);
|
---|
1503 | _wpSaveLong(somSelf, "CWImage", KEY_DEPTH, pBmpInfoHeader->cBitCount);
|
---|
1504 | }
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | return (MMImage_parent_WPImageFile_wpSaveState(somSelf));
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 |
|
---|
1511 | /*
|
---|
1512 | * The prototype for cwimgM_wpclsInitData was replaced by the following prototype:
|
---|
1513 | */
|
---|
1514 | SOM_Scope void SOMLINK cwimgM_wpclsInitData(M_MMImage *somSelf)
|
---|
1515 | {
|
---|
1516 | PCLASSFIELDINFO pCfi;
|
---|
1517 | USHORT i;
|
---|
1518 | static BOOL bGotImgExt=FALSE;
|
---|
1519 |
|
---|
1520 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
1521 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsInitData");
|
---|
1522 |
|
---|
1523 | /* Get extensions of additional image procs not represented by a class.
|
---|
1524 | Strangely enough wpclsQueryInstanceFilter() is called during wpclsInitData() so
|
---|
1525 | we query the extensions here before calling the parent so we have the information. */
|
---|
1526 | if(!bGotImgExt)
|
---|
1527 | {
|
---|
1528 | /* Get user supplied extensions e.g. *.JPE*/
|
---|
1529 | getStringFromRexxScript("imageadd.rx", chrMMImageExt, sizeof(chrMMImageExt));
|
---|
1530 |
|
---|
1531 | /* Get all already handled extensions */
|
---|
1532 | getStringFromRexxScript("imageext.rx", chrMMImageKnownExt, sizeof(chrMMImageKnownExt));
|
---|
1533 | /* Now check installed IO procs for other exts and add them to the filter list */
|
---|
1534 | _getMissingExtFromImageIOProc();
|
---|
1535 | bGotImgExt=TRUE;
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | M_MMImage_parent_M_WPImageFile_wpclsInitData(somSelf);
|
---|
1539 |
|
---|
1540 | if(!globalHab)
|
---|
1541 | globalHab=WinQueryAnchorBlock(HWND_DESKTOP);
|
---|
1542 |
|
---|
1543 | if(!getMessage(chrHelpLibrary, IDSTR_HELPLIBRARY, sizeof(chrHelpLibrary),
|
---|
1544 | queryModuleHandle(), HWND_DESKTOP))
|
---|
1545 | strcpy(chrHelpLibrary,"MMPARTS.HLP");
|
---|
1546 |
|
---|
1547 | /* Load strings for details titles */
|
---|
1548 | if(getMessage(chrWidth, IDSTR_IMAGEDETAIL_WIDTH, sizeof(chrWidth), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1549 | pszImageColTitles[0]=chrWidth;
|
---|
1550 | if(getMessage(chrHeight, IDSTR_IMAGEDETAIL_HEIGHT, sizeof(chrHeight), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1551 | pszImageColTitles[1]=chrHeight;
|
---|
1552 | if(getMessage(chrDepth, IDSTR_IMAGEDETAIL_DEPTH, sizeof(chrDepth), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1553 | pszImageColTitles[2]=chrDepth;
|
---|
1554 | if(getMessage(chrFormat, IDSTR_IMAGEDETAIL_FORMAT, sizeof(chrFormat), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1555 | pszImageColTitles[3]=chrFormat;
|
---|
1556 |
|
---|
1557 | /* Setup the static data for the details view */
|
---|
1558 | for(i=0,pCfi=cfiImageFieldInfo;i<NUM_IMAGE_DETAILS_FIELDS;i++,pCfi++)
|
---|
1559 | {
|
---|
1560 | memset((PCH)pCfi,0,sizeof(CLASSFIELDINFO));
|
---|
1561 |
|
---|
1562 | pCfi->cb=sizeof(CLASSFIELDINFO);
|
---|
1563 | pCfi->flData=CFA_LEFT|CFA_SEPARATOR|CFA_FIREADONLY;
|
---|
1564 | pCfi->flTitle=CFA_CENTER|CFA_SEPARATOR|CFA_HORZSEPARATOR|CFA_STRING|CFA_FITITLEREADONLY;
|
---|
1565 | pCfi->pNextFieldInfo=pCfi+1;
|
---|
1566 | pCfi->pTitleData=(PVOID)pszImageColTitles[i];
|
---|
1567 | pCfi->flCompare=COMPARE_SUPPORTED|SORTBY_SUPPORTED;
|
---|
1568 |
|
---|
1569 | switch(i)
|
---|
1570 | {
|
---|
1571 | case 0: /* Width */
|
---|
1572 | pCfi->flData|=CFA_ULONG;
|
---|
1573 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS, ulWidth));
|
---|
1574 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
1575 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
1576 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
1577 | break;
|
---|
1578 | case 1: /* Height */
|
---|
1579 | pCfi->flData|=CFA_ULONG;
|
---|
1580 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulHeight));
|
---|
1581 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
1582 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
1583 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
1584 | break;
|
---|
1585 | case 2: /* Depth */
|
---|
1586 | pCfi->flData|=CFA_ULONG;
|
---|
1587 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulDepth));
|
---|
1588 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
1589 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
1590 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
1591 | break;
|
---|
1592 | case 3: /* Format */
|
---|
1593 | pCfi->flData|=CFA_STRING;
|
---|
1594 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,pszFormat));
|
---|
1595 | pCfi->ulLenFieldData=sizeof(PSZ);
|
---|
1596 | pCfi->DefaultComparison=CMP_EQUAL;
|
---|
1597 | break;
|
---|
1598 | }/* switch(i) */
|
---|
1599 | }/* for() */
|
---|
1600 | cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS].pNextFieldInfo=NULL;
|
---|
1601 | if(!hwndCreateBMP)
|
---|
1602 | _beginthread(createBMPThreadFunc,NULL,8192*10, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
1603 | }
|
---|
1604 |
|
---|
1605 |
|
---|
1606 | /*
|
---|
1607 | * The prototype for cwimgM_wpclsQueryDefaultView was replaced by the following prototype:
|
---|
1608 | */
|
---|
1609 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryDefaultView(M_MMImage *somSelf)
|
---|
1610 | {
|
---|
1611 | #if 0
|
---|
1612 | char chrID[120];
|
---|
1613 | WPObject *wpObject;
|
---|
1614 | HOBJECT hObject;
|
---|
1615 | #endif
|
---|
1616 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
1617 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryDefaultView");
|
---|
1618 |
|
---|
1619 | // sprintf(chrID, "<MMPM2_MM%sTEMPLATE>", _wpclsQueryInstanceType(somSelf));
|
---|
1620 | //HlpWriteToTrapLog("%s\n", chrID);
|
---|
1621 | #if 0
|
---|
1622 | if((hObject=WinQueryObject(chrID))!=NULLHANDLE)
|
---|
1623 | DosBeep(5000, 500);
|
---|
1624 | // _wpclsQueryObject(somSelf, hObject);
|
---|
1625 | if((wpObject=_wpclsQueryObjectFromPath(somSelf, chrID))!=NULLHANDLE)
|
---|
1626 | {
|
---|
1627 | ULONG ulHowMatched=1;
|
---|
1628 |
|
---|
1629 | DosBeep(5000, 1000);
|
---|
1630 | /* Template found. Now query associated program */
|
---|
1631 | if(_wpQueryAssociatedProgram(wpObject, VIEW_RUNNING, &ulHowMatched,
|
---|
1632 | chrID, sizeof(chrID),(PSZ)-1))
|
---|
1633 | DosBeep(500, 1000);
|
---|
1634 | }
|
---|
1635 | #endif
|
---|
1636 | /* Create default templates. We do it here because we need an object to query the associated
|
---|
1637 | program (if any) when the system asks for the default view. */
|
---|
1638 | return OPEN_RUNNING;
|
---|
1639 | // return ID_MENU_IMGEDITOR;
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 |
|
---|
1643 | BOOL checkImageIOProc(char * chrExt)
|
---|
1644 | {
|
---|
1645 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
---|
1646 | MMFORMATINFO mmFormatInfo;
|
---|
1647 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
1648 | void * memPtr;
|
---|
1649 | ULONG ulReturnCode;
|
---|
1650 | LONG lFormatsRead;
|
---|
1651 | LONG index;
|
---|
1652 | LONG lBytesRead;
|
---|
1653 |
|
---|
1654 | memset( &mmFormatInfo,
|
---|
1655 | '\0',
|
---|
1656 | sizeof(MMFORMATINFO) );
|
---|
1657 |
|
---|
1658 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
1659 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
|
---|
1660 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
1661 | &lNumIOProcs,
|
---|
1662 | 0,
|
---|
1663 | 0 );
|
---|
1664 |
|
---|
1665 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1666 | {
|
---|
1667 | /*
|
---|
1668 | * Error - mmioQueryFormatCount failed.
|
---|
1669 | */
|
---|
1670 | return FALSE;
|
---|
1671 | }
|
---|
1672 |
|
---|
1673 | /*
|
---|
1674 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
1675 | */
|
---|
1676 | pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
1677 | memPtr=pmmFormatInfoArray;
|
---|
1678 | if( pmmFormatInfoArray == NULL )
|
---|
1679 | {
|
---|
1680 | /*
|
---|
1681 | * Could not allocate enough memory for mmFormatInfo array.
|
---|
1682 | */
|
---|
1683 | return FALSE;
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | /*
|
---|
1687 | * call mmioGetFormats to get info on the formats supported.
|
---|
1688 | */
|
---|
1689 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
1690 | lNumIOProcs,
|
---|
1691 | pmmFormatInfoArray,
|
---|
1692 | &lFormatsRead,
|
---|
1693 | 0,
|
---|
1694 | 0 );
|
---|
1695 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1696 | {
|
---|
1697 | /*
|
---|
1698 | * mmioGetFormats failed.
|
---|
1699 | */
|
---|
1700 | free(pmmFormatInfoArray);
|
---|
1701 | return FALSE;
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 | if( lFormatsRead != lNumIOProcs )
|
---|
1705 | {
|
---|
1706 | /*
|
---|
1707 | * Error in MMIO - number of formats read in by
|
---|
1708 | * mmioGetFormats is not equal to number of formats
|
---|
1709 | * found by mmioQueryFormatCount.
|
---|
1710 | */
|
---|
1711 | free(pmmFormatInfoArray);
|
---|
1712 | return FALSE;
|
---|
1713 | }
|
---|
1714 |
|
---|
1715 |
|
---|
1716 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
1717 | {
|
---|
1718 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
---|
1719 |
|
---|
1720 | /* Insert NULL string terminator */
|
---|
1721 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
---|
1722 |
|
---|
1723 | /* Compressed TIF is not supported because the Warp 4 IO-Procs are
|
---|
1724 | broken. */
|
---|
1725 | //HlpWriteToTrapLog("--------- Ext: %s, IO-Proc: %s, Name: %s\n",
|
---|
1726 | //chrExt, pmmFormatInfoArray->szDefaultFormatExt,
|
---|
1727 | // szBuffer);
|
---|
1728 |
|
---|
1729 | if(pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFMC",MMIO_TOUPPER) &&
|
---|
1730 | pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFIC",MMIO_TOUPPER) &&
|
---|
1731 | (pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED))
|
---|
1732 | {
|
---|
1733 | if(strstr(chrExt, pmmFormatInfoArray->szDefaultFormatExt)) {
|
---|
1734 | //HlpWriteToTrapLog("******* Ext given: %s IO-Proc: %s\n", chrExt, pmmFormatInfoArray->szDefaultFormatExt);
|
---|
1735 | free(memPtr);
|
---|
1736 | return TRUE;
|
---|
1737 | }
|
---|
1738 | }
|
---|
1739 | /*
|
---|
1740 | * advance to next entry in mmFormatInfo array
|
---|
1741 | */
|
---|
1742 | pmmFormatInfoArray++;
|
---|
1743 | }
|
---|
1744 | free(memPtr);
|
---|
1745 |
|
---|
1746 | return FALSE;
|
---|
1747 | }
|
---|
1748 |
|
---|
1749 | SOM_Scope BOOL SOMLINK cwimgM_wpclsCreateDefaultTemplates(M_MMImage *somSelf,
|
---|
1750 | WPObject* Folder)
|
---|
1751 | {
|
---|
1752 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
1753 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsCreateDefaultTemplates");
|
---|
1754 |
|
---|
1755 | //HlpWriteToTrapLog("Class title: %s\n", _wpclsQueryTitle(somSelf));
|
---|
1756 |
|
---|
1757 | /* The FOURCC of the JPEG-IO proc is JPEG so we have to create that template
|
---|
1758 | in the JPG class. */
|
---|
1759 |
|
---|
1760 | if(checkImageIOProc( _wpclsQueryInstanceFilter(somSelf))) {
|
---|
1761 | // WPFolder* wpFolder;
|
---|
1762 | // wpFolder=_wpclsQueryFolder(somSelf, "<MMPM2_MMTEMPLATEFOLDER>", FALSE);
|
---|
1763 | // return M_MMAudio_parent_M_MMDataFile_wpclsCreateDefaultTemplates(somSelf, wpFolder);
|
---|
1764 | // HlpWriteToTrapLog("Create template for: %s\n", _wpclsQueryTitle(somSelf));
|
---|
1765 | // HlpWriteToTrapLog("Create template for: %s\n", _somGetClassName(somSelf) );
|
---|
1766 | mmclsCreateTheDefaultTemplate(somSelf, Folder);
|
---|
1767 | return TRUE;
|
---|
1768 | }
|
---|
1769 |
|
---|
1770 | return TRUE;
|
---|
1771 | }
|
---|
1772 |
|
---|
1773 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryStyle(M_MMImage *somSelf)
|
---|
1774 | {
|
---|
1775 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
1776 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryStyle");
|
---|
1777 |
|
---|
1778 | return CLSSTYLE_NEVERPRINT;
|
---|
1779 | // return (M_MMImage_parent_M_WPImageFile_wpclsQueryStyle(somSelf));
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | /*
|
---|
1783 | * The prototype for cwimgM_wpclsQueryTitle was replaced by the following prototype:
|
---|
1784 | */
|
---|
1785 | SOM_Scope PSZ SOMLINK cwimgM_wpclsQueryTitle(M_MMImage *somSelf)
|
---|
1786 | {
|
---|
1787 | static char chrTitle[20]={0};
|
---|
1788 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
1789 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryTitle");
|
---|
1790 |
|
---|
1791 | if(chrTitle[0]==0)
|
---|
1792 | if(!getMessage(chrTitle, IDSTR_CWIMAGETITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1793 | strcpy(chrTitle,"Digital Image");
|
---|
1794 |
|
---|
1795 | return chrTitle;
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 | /*
|
---|
1799 | * The prototype for cwimgM_wpclsQueryIconData was replaced by the following prototype:
|
---|
1800 | */
|
---|
1801 | /*
|
---|
1802 | * wpclsQueryDefaultHelp: override;
|
---|
1803 | */
|
---|
1804 |
|
---|
1805 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryIconData(M_MMImage *somSelf,
|
---|
1806 | PICONINFO pIconInfo)
|
---|
1807 | {
|
---|
1808 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
1809 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryIconData");
|
---|
1810 |
|
---|
1811 | if (pIconInfo) {
|
---|
1812 | pIconInfo->fFormat = ICON_RESOURCE;
|
---|
1813 | pIconInfo->hmod = queryModuleHandle();
|
---|
1814 | pIconInfo->resid = ID_ICONCWIMAGEFILE;
|
---|
1815 | } /* endif */
|
---|
1816 |
|
---|
1817 | return ( sizeof(ICONINFO) );
|
---|
1818 | }
|
---|
1819 |
|
---|
1820 | /*
|
---|
1821 | * The prototype for cwimgM_wpclsQueryDetailsInfo was replaced by the following prototype:
|
---|
1822 | */
|
---|
1823 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryDetailsInfo(M_MMImage *somSelf,
|
---|
1824 | PCLASSFIELDINFO* ppClassFieldInfo,
|
---|
1825 | PULONG pSize)
|
---|
1826 | {
|
---|
1827 | ULONG cParentColumns;
|
---|
1828 | PCLASSFIELDINFO pCfi;
|
---|
1829 | int i;
|
---|
1830 |
|
---|
1831 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
1832 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryDetailsInfo");
|
---|
1833 |
|
---|
1834 | cParentColumns= (M_MMImage_parent_M_WPImageFile_wpclsQueryDetailsInfo(somSelf,
|
---|
1835 | ppClassFieldInfo,
|
---|
1836 | pSize));
|
---|
1837 | if(pSize)
|
---|
1838 | *pSize+=sizeof(IMAGEDETAILS);
|
---|
1839 |
|
---|
1840 | if(ppClassFieldInfo)
|
---|
1841 | {
|
---|
1842 | if(*ppClassFieldInfo)
|
---|
1843 | {
|
---|
1844 | pCfi=*ppClassFieldInfo;
|
---|
1845 | for(i=0; i<cParentColumns;i++)
|
---|
1846 | pCfi=(pCfi->pNextFieldInfo ? pCfi->pNextFieldInfo: pCfi);
|
---|
1847 |
|
---|
1848 | pCfi->pNextFieldInfo=cfiImageFieldInfo;
|
---|
1849 | }
|
---|
1850 | else
|
---|
1851 | *ppClassFieldInfo=cfiImageFieldInfo;
|
---|
1852 | }
|
---|
1853 | return (cParentColumns+NUM_IMAGE_DETAILS_FIELDS);
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 |
|
---|
1857 |
|
---|
1858 | SOM_Scope PSZ SOMLINK cwimgM_wpclsQueryInstanceFilter(M_MMImage *somSelf)
|
---|
1859 | {
|
---|
1860 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
1861 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryInstanceFilter");
|
---|
1862 |
|
---|
1863 | //return "*.png,*.sdf,*.klj,*jpe,*.zui";
|
---|
1864 | return chrMMImageExt;
|
---|
1865 | /* return (M_MMImage_parent_M_WPImageFile_wpclsQueryInstanceFilter(somSelf));*/
|
---|
1866 | }
|
---|
1867 |
|
---|