1 |
|
---|
2 | /*
|
---|
3 | * (C) Chris Wohlgemuth 2002-2004
|
---|
4 | *
|
---|
5 | */
|
---|
6 | /*
|
---|
7 | * This program is free software; you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
10 | * any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with this program; see the file COPYING. If not, write to
|
---|
19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | */
|
---|
21 | /*
|
---|
22 | * If you need another license for your project/product (commercial,
|
---|
23 | * noncommercial, whatever) contact me at
|
---|
24 | *
|
---|
25 | * http://www.os2world.com/cdwriting
|
---|
26 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
---|
27 | *
|
---|
28 | */
|
---|
29 | /*
|
---|
30 | * This file was generated by the SOM Compiler and Emitter Framework.
|
---|
31 | * Generated using:
|
---|
32 | * SOM Emitter emitctm: 2.42
|
---|
33 | */
|
---|
34 |
|
---|
35 | #ifndef SOM_Module_cwimage_Source
|
---|
36 | #define SOM_Module_cwimage_Source
|
---|
37 | #endif
|
---|
38 | #define CWImage_Class_Source
|
---|
39 | #define M_CWImage_Class_Source
|
---|
40 |
|
---|
41 | #define INCL_DOS
|
---|
42 | #define INCL_DOSSEMAPHORES
|
---|
43 | #define INCL_DOSERRORS
|
---|
44 | #define INCL_GPI
|
---|
45 | #define INCL_PM
|
---|
46 | #define INCL_MMIOOS2
|
---|
47 | #include <os2.h>
|
---|
48 | #include <stdio.h>
|
---|
49 | #include "mmioos2.h"
|
---|
50 | #include "cwimage.ih"
|
---|
51 | #include "mmres.h"
|
---|
52 | #include "except.h"
|
---|
53 | #include "cwaudioinc.h"
|
---|
54 |
|
---|
55 | #include "sys_funcs.h"
|
---|
56 |
|
---|
57 | //#define DEBUG
|
---|
58 |
|
---|
59 | char notImplementedMsg[]= {"\nMethod not available while processing file %s: %s, file %s, around line %d.\n"};
|
---|
60 |
|
---|
61 | /* Set some default titles */
|
---|
62 | PSZ pszImageColTitles[NUM_IMAGE_DETAILS_FIELDS]= {"Width", "Height", "Depth", "Format"};
|
---|
63 |
|
---|
64 | char chrWidth[SIZE_TITLE]="";
|
---|
65 | char chrHeight[SIZE_TITLE]="";
|
---|
66 | char chrDepth[SIZE_TITLE]="";
|
---|
67 | char chrFormat[SIZE_TITLE]="";
|
---|
68 |
|
---|
69 | CLASSFIELDINFO cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS];
|
---|
70 |
|
---|
71 | /* Some methods are not yet implemented */
|
---|
72 | #define NOT_IMPLEMENTED DosBeep(1000, 100);\
|
---|
73 | DosBeep(2000, 100);\
|
---|
74 | DosBeep(3000, 100);\
|
---|
75 | DosBeep(4000, 100);\
|
---|
76 | DosBeep(3000, 100);\
|
---|
77 | DosBeep(2000, 100);\
|
---|
78 | DosBeep(1000, 100);\
|
---|
79 | SysWriteToTrapLog(notImplementedMsg,\
|
---|
80 | _wpQueryTitle(somSelf), __FUNCTION__, __FILE__, __LINE__);
|
---|
81 |
|
---|
82 |
|
---|
83 | extern HAB globalHab;
|
---|
84 | HWND hwndCreateBMP; /* Object window for small bitmap creation */
|
---|
85 | HWND g_hwndDeleteBMP; /* Object window for bitmap deletion */
|
---|
86 |
|
---|
87 | extern char classDLLPath[CCHMAXPATH];
|
---|
88 | extern char chrHelpLibrary[CCHMAXPATH];
|
---|
89 | PMMFORMATINFO g_pmmFormatInfoArray=NULLHANDLE;
|
---|
90 | LONG lNumIOProcs=0;/* Needed to know how many convert menus we have */
|
---|
91 |
|
---|
92 | char chrMMImageKnownExt[320]={0};/* Array holding the extensions we have a class for e.g. JPG. This
|
---|
93 | array will be filled using an external REXX script. Space for
|
---|
94 | 80 ext should be enough for now (4 bytes per ext e.g.: "JPG "<- note the space) */
|
---|
95 | char chrMMImageExt[200]={0};/* Array holding the extensions for wpclsQueryInstanceFilter(). Will be
|
---|
96 | filled during processing of wpclsInitData() */
|
---|
97 |
|
---|
98 |
|
---|
99 | ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters, WPObject *thisPtr, ULONG ulView);
|
---|
100 |
|
---|
101 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
102 | ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
|
---|
103 | char* title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
104 | HMODULE hResource, HWND hwnd, ULONG ulFlags);
|
---|
105 |
|
---|
106 | void writeLog(char* chrFormat, ...);
|
---|
107 | HMODULE queryResModuleHandle(void);
|
---|
108 | HMODULE queryModuleHandle(void);
|
---|
109 | PSZ queryModuleName(void);
|
---|
110 |
|
---|
111 | BOOL getBmpInfoHeader(PBITMAPINFOHEADER2 bmpih2, PSZ pszFileName, char* procName, ULONG ulLength, BOOL * bNoIOProcAvailable);
|
---|
112 | HBITMAP loadBitmap ( PSZ pszFileName, PBITMAPINFOHEADER2 pBMPInfoHeader2);
|
---|
113 | HBITMAP createNewBitmap ( HBITMAP hbm,
|
---|
114 | PBITMAPINFOHEADER2 pBmpInfoHeader2,
|
---|
115 | ULONG ulWidth,
|
---|
116 | ULONG ulHeight,
|
---|
117 | BOOL* pbQuitEarly);
|
---|
118 |
|
---|
119 | ULONG showMsgBox2(ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag);
|
---|
120 | ULONG showMsgBox(ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule);
|
---|
121 | BOOL cwObjectIsOnCD(WPObject * somSelf);
|
---|
122 | BOOL getStringFromRexxScript(PSZ rexxFile, char* chrResult, ULONG ulSize);
|
---|
123 |
|
---|
124 | BOOL mmclsCreateTheDefaultTemplate(M_WPObject *somSelf,
|
---|
125 | WPObject* Folder);
|
---|
126 |
|
---|
127 | MRESULT menuInsertMenuSeparator(HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition );
|
---|
128 |
|
---|
129 | /*
|
---|
130 | This Proc creates the small bitmaps for display on a separate thread.
|
---|
131 | It's used indirectly used by the lighttable folder when an attempt to
|
---|
132 | paint the bitmap is made. It will also generate bmps when WPS-wizard wants
|
---|
133 | to paint icons in the container.
|
---|
134 | */
|
---|
135 | MRESULT EXPENTRY createBMPObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
136 | {
|
---|
137 |
|
---|
138 | switch (msg)
|
---|
139 | {
|
---|
140 | case WM_APPTERMINATENOTIFY:
|
---|
141 | {
|
---|
142 | switch(SHORT2FROMMP(mp2))
|
---|
143 | {
|
---|
144 | case ACKEY_CREATE_SMALLBITMAP:
|
---|
145 | {
|
---|
146 | BOOL bLoaded=FALSE;
|
---|
147 | HBITMAP hbm;
|
---|
148 | PCREATEBMPINFO pCreateBMP=PVOIDFROMMP(mp1);
|
---|
149 | MMImageData *somThis;
|
---|
150 | WPObject *wpObject;
|
---|
151 | PMINIRECORDCORE pmrcToRefresh;
|
---|
152 |
|
---|
153 | if(!pCreateBMP)
|
---|
154 | return (MRESULT) FALSE;
|
---|
155 | #ifdef DEBUG
|
---|
156 | SysWriteToTrapLog("In %s, line %d\n", __FUNCTION__, __LINE__);
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | if(!somIsObj(pCreateBMP->wpObject))
|
---|
160 | return (MRESULT) FALSE;
|
---|
161 |
|
---|
162 | /*
|
---|
163 | V0.2.8, CW 2004/11/01
|
---|
164 |
|
---|
165 | It's possible that a lot of requests are issued to this thread while opening a folder.
|
---|
166 | These are qeued and in the meanwhile the user may have closed the folder.
|
---|
167 | */
|
---|
168 | if(!WinIsWindow(globalHab, pCreateBMP->hwndCnr))
|
---|
169 | return MRFALSE;
|
---|
170 |
|
---|
171 |
|
---|
172 | TRY_LOUD(BITMAP_OBJECT) {
|
---|
173 | somThis = MMImageGetData(pCreateBMP->wpObject);
|
---|
174 | pmrcToRefresh=pCreateBMP->pmrcToRefresh;
|
---|
175 | for(;;) {
|
---|
176 | RECTL rectl, rectl2;
|
---|
177 | if(WinSendMsg(pCreateBMP->hwndCnr, CM_QUERYVIEWPORTRECT, MPFROMP(&rectl2), MPFROM2SHORT(CMA_WORKSPACE, FALSE))) {
|
---|
178 |
|
---|
179 | /*
|
---|
180 | V0.2.8 CW 2004/11/01
|
---|
181 |
|
---|
182 | Only create small bitmaps for icons currently visible in the container. This is useful if the
|
---|
183 | user scrolls a folder and not every small bitmap is yet created.
|
---|
184 | */
|
---|
185 | if(pmrcToRefresh->ptlIcon.y+40 < rectl2.yBottom || pmrcToRefresh->ptlIcon.y > rectl2.yTop)
|
---|
186 | break;
|
---|
187 | if(pmrcToRefresh->ptlIcon.x+40 < rectl2.xLeft || pmrcToRefresh->ptlIcon.x > rectl2.xRight)
|
---|
188 | break;
|
---|
189 | }/* WinSendMsg() */
|
---|
190 |
|
---|
191 | _wpLockObject(pCreateBMP->wpObject);
|
---|
192 |
|
---|
193 | /* Check if in the meantime the bitmap was created */
|
---|
194 | if(!_hBitmapSmall) {
|
---|
195 | /*
|
---|
196 | FIXME:
|
---|
197 |
|
---|
198 | Not threadsafe!!!
|
---|
199 |
|
---|
200 | Use a private work alike for wpQueryBitmapHandle instead???
|
---|
201 |
|
---|
202 | Check if bitmap data already loaded. Keep the info so we don't discard the bitmap later on. Another
|
---|
203 | function may have requested the bitmap before. During wpQueryBitmapHandle() a normal size bitmap
|
---|
204 | is always created. We don't want to have memory wasted by the big one so it's discarded afterwards.
|
---|
205 | Not perfect, but works at the moment. Will be revamped later with automatic bitmap deletion. */
|
---|
206 | if(_hBitmap)
|
---|
207 | bLoaded=TRUE;
|
---|
208 |
|
---|
209 | if(_wpQueryBitmapHandle(pCreateBMP->wpObject,
|
---|
210 | &hbm,
|
---|
211 | NULLHANDLE,
|
---|
212 | pCreateBMP->ulWidth,
|
---|
213 | pCreateBMP->ulHeight,
|
---|
214 | 0, /* ulFlags*/
|
---|
215 | 0,
|
---|
216 | NULLHANDLE)) {
|
---|
217 | _hBitmapSmall=hbm;
|
---|
218 | _ulSizeSmallBitmap=pCreateBMP->ulHeight;
|
---|
219 | if(!bLoaded) {
|
---|
220 | /* The bitmap wasn't loaded so discard it now, we don't need it any more as we have
|
---|
221 | the small one. */
|
---|
222 | GpiDeleteBitmap(_hBitmap);
|
---|
223 | _hBitmap=NULLHANDLE;
|
---|
224 | }
|
---|
225 | }/* _wpQueryBitmapHandle() */
|
---|
226 | }
|
---|
227 | if(WinIsWindow(globalHab, pCreateBMP->hwndCnr) && pmrcToRefresh)
|
---|
228 | // WinPostMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
229 | WinSendMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
230 |
|
---|
231 | _wpUnlockObject(pCreateBMP->wpObject);
|
---|
232 | break;
|
---|
233 | }/* for */
|
---|
234 | }/* Try */
|
---|
235 | CATCH(BITMAP_OBJECT)
|
---|
236 | {
|
---|
237 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
---|
238 | __FUNCTION__, __FILE__, __LINE__);
|
---|
239 | _wpUnlockObject(pCreateBMP->wpObject); /* If we trapped in wpUnlockObject(), we will have a problem here... */
|
---|
240 | } END_CATCH;
|
---|
241 | // WinSendMsg(pCreateBMP->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pmrcToRefresh),MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
242 | // _wp_FreeMem(wpObject, (PBYTE)pCreateBMP);
|
---|
243 | free((PBYTE)pCreateBMP);
|
---|
244 |
|
---|
245 | return (MRESULT) FALSE;
|
---|
246 | }/* case ACKEY_CREATE_SMALLBITMAP */
|
---|
247 | case ACKEY_QUERY_BITMAPINFO:
|
---|
248 | {
|
---|
249 | PCREATEBMPINFO pCreateBMP=PVOIDFROMMP(mp1);
|
---|
250 | MMImageData *somThis;
|
---|
251 |
|
---|
252 | if(!pCreateBMP)
|
---|
253 | return (MRESULT) FALSE;
|
---|
254 | if(!somIsObj(pCreateBMP->wpObject))
|
---|
255 | return (MRESULT) FALSE;
|
---|
256 |
|
---|
257 | TRY_LOUD(BITMAPIH_OBJECT) {
|
---|
258 | somThis = MMImageGetData(pCreateBMP->wpObject);
|
---|
259 |
|
---|
260 | /* Check if in the meantime the bitmap was created */
|
---|
261 | if(!_pBmpInfoHeader2) {
|
---|
262 | _pBmpInfoHeader2=_wpQueryBitmapInfoHeader(pCreateBMP->wpObject);
|
---|
263 | /* Make sure the image size is cached in the EA */
|
---|
264 | if(_pBmpInfoHeader2)
|
---|
265 | _wpSaveDeferred(pCreateBMP->wpObject);
|
---|
266 | }
|
---|
267 | }/* Try */
|
---|
268 | CATCH(BITMAPIH_OBJECT)
|
---|
269 | {
|
---|
270 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while getting BMPINFOHEADER.\n",
|
---|
271 | __FUNCTION__, __FILE__, __LINE__);
|
---|
272 | } END_CATCH;
|
---|
273 | return (MRESULT) FALSE;
|
---|
274 | }
|
---|
275 | default:
|
---|
276 | break;
|
---|
277 | }/* switch(SHORT2FROMMP(mp2)) */
|
---|
278 | return (MRESULT) FALSE;
|
---|
279 | }/* case WM_APPTERMINATENOTIFY */
|
---|
280 | default:
|
---|
281 | break;
|
---|
282 | }
|
---|
283 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
284 | }
|
---|
285 |
|
---|
286 | /*
|
---|
287 |
|
---|
288 | This thread is started in cwimgM_wpclsInitData(M_MMImage *somSelf). It will create small bitmaps and reads
|
---|
289 | in the BITMAPINFOHEADER.
|
---|
290 |
|
---|
291 | */
|
---|
292 | void _Optlink createBMPThreadFunc (void *arg)
|
---|
293 | {
|
---|
294 |
|
---|
295 | HAB hab;
|
---|
296 | HMQ hmq;
|
---|
297 | QMSG qmsg;
|
---|
298 |
|
---|
299 | hab=WinInitialize(0);
|
---|
300 | if(hab) {
|
---|
301 | hmq=WinCreateMsgQueue(hab, 50);
|
---|
302 | if(hmq) {
|
---|
303 | hwndCreateBMP=WinCreateWindow(HWND_OBJECT,WC_STATIC,"coverObj",0,0,0,0,0,NULLHANDLE,HWND_BOTTOM,13343,NULL,NULL);
|
---|
304 | if(hwndCreateBMP) {
|
---|
305 | WinSubclassWindow(hwndCreateBMP,&createBMPObjectProc);
|
---|
306 | /* Window created. */
|
---|
307 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
|
---|
308 | WinDispatchMsg(hab,&qmsg);
|
---|
309 | WinDestroyWindow(hwndCreateBMP);
|
---|
310 | }
|
---|
311 | WinDestroyMsgQueue(hmq);
|
---|
312 | }
|
---|
313 | WinTerminate(hab);
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | ULONG ulNumBMPDelete=0;
|
---|
318 | #define IMGWM_DELETEBITMAP WM_USER+10
|
---|
319 |
|
---|
320 | MRESULT EXPENTRY deleteBMPObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
321 | {
|
---|
322 |
|
---|
323 | switch (msg)
|
---|
324 | {
|
---|
325 | case IMGWM_DELETEBITMAP:
|
---|
326 | {
|
---|
327 | MMImage* somSelf=PVOIDFROMMP(mp1);
|
---|
328 | if(somIsObj(somSelf)) {
|
---|
329 | #if 0
|
---|
330 | if(!_wpFindUseItem(somSelf, USAGE_RECORD, NULLHANDLE)) {
|
---|
331 | _cwmmFreeBitmaps(somSelf);
|
---|
332 | //DosBeep(5000, 20);
|
---|
333 | }
|
---|
334 | #endif
|
---|
335 | // DosBeep(5000, 10);
|
---|
336 | _cwmmFreeBitmaps(somSelf);
|
---|
337 | //SysWriteToTrapLog("Object is locked: %d\n", _wpIsLocked(somSelf));
|
---|
338 | /* Decrease delete request count */
|
---|
339 | ulNumBMPDelete--;
|
---|
340 | // SysWriteToTrapLog("Num requests left: %d\n", ulNumBMPDelete);
|
---|
341 | }
|
---|
342 | return FALSE;
|
---|
343 |
|
---|
344 | }
|
---|
345 | default:
|
---|
346 | break;
|
---|
347 | } /* msg */
|
---|
348 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
349 | }
|
---|
350 |
|
---|
351 | #define BMP_QUEUE_SIZE 100
|
---|
352 | #define BMP_DEL_UPPER 80 /* If number of delete request reaches this the thread is unlocked */
|
---|
353 | #define BMP_DEL_LOWER 50 /* After reaching this number of requests the thread goes back to sleep until the timeout comes. */
|
---|
354 | #define BMP_DEL_WAITTIME 10000 /* Default sleeptime of the thread thus checking for new delete requests with this interval */
|
---|
355 | #define BMP_DEL_MINAGE 8000 /* Min age of message before bitmaps are actually destroyed in the background */
|
---|
356 |
|
---|
357 | HEV hevDeleteBMP;
|
---|
358 |
|
---|
359 | /*
|
---|
360 |
|
---|
361 | This thread is started in cwimgM_wpclsInitData(M_MMImage *somSelf).
|
---|
362 |
|
---|
363 | This is the poor man's bitmap deletion thread. It wakes up every BMP_DELWAITTIME ms and
|
---|
364 | deletes bitmaps which are at least BMP_DELMINAGE ms not used.
|
---|
365 |
|
---|
366 | It will not reorder messages and will not remove duplicates (hence poor man's). So the
|
---|
367 | oldest delete request will be fullfilled even if in the meantime the bitmap was used and
|
---|
368 | a new request issued. Anyway bitmaps will NOT be destroyed, if the file is inserted into a
|
---|
369 | container! But overall it's way better than immediately delete BMPs after use because when
|
---|
370 | closing a folder maybe dozens of bitmaps must be removed at once.
|
---|
371 |
|
---|
372 | */
|
---|
373 | void _Optlink deleteBMPThreadFunc (void *arg)
|
---|
374 | {
|
---|
375 |
|
---|
376 | HAB hab;
|
---|
377 | HMQ hmq;
|
---|
378 | QMSG qmsg;
|
---|
379 | BOOL bSemCreated;
|
---|
380 | ULONG ulWaitTime=BMP_DEL_WAITTIME;
|
---|
381 |
|
---|
382 | hab=WinInitialize(0);
|
---|
383 | if(hab) {
|
---|
384 | hmq=WinCreateMsgQueue(hab, BMP_QUEUE_SIZE);
|
---|
385 | if(hmq) {
|
---|
386 | g_hwndDeleteBMP=WinCreateWindow(HWND_OBJECT,WC_STATIC,"delBMPObj",0,0,0,0,0,NULLHANDLE,HWND_BOTTOM,13343,NULL,NULL);
|
---|
387 | if(g_hwndDeleteBMP) {
|
---|
388 | WinSubclassWindow(g_hwndDeleteBMP,&deleteBMPObjectProc);
|
---|
389 | /* Lower priority to idle -5. Memory clean up shouldn't disturb the user */
|
---|
390 | // DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, -5, 0);
|
---|
391 |
|
---|
392 | /* Create event semaphore. This thread normally waits on this semaphore for several minutes. After the
|
---|
393 | timeout it fetches a pending msg and deletes the bitmap. If a lot of deletion request are sent, the
|
---|
394 | sending function posts the semaphore before the timeout and the oldest requests are handled immediately.
|
---|
395 |
|
---|
396 | The semaphore is reset when created.
|
---|
397 | */
|
---|
398 | bSemCreated=!DosCreateEventSem(NULL, &hevDeleteBMP, 0, FALSE);
|
---|
399 | /* Window created. Wait for msg. */
|
---|
400 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0)) {
|
---|
401 | BOOL bQuit;
|
---|
402 |
|
---|
403 | // SysWriteToTrapLog("\n\nGot first msg...\n");
|
---|
404 |
|
---|
405 | /* First message is always dispatched no matter how old */
|
---|
406 | WinDispatchMsg(hab,&qmsg);
|
---|
407 |
|
---|
408 | if(bSemCreated) {
|
---|
409 | ULONG ulPostCount;
|
---|
410 | BOOL bTimeError=FALSE;
|
---|
411 |
|
---|
412 | //SysWriteToTrapLog("Waiting on semaphore...\n");
|
---|
413 |
|
---|
414 | if(DosWaitEventSem(hevDeleteBMP, ulWaitTime)==ERROR_TIMEOUT) {
|
---|
415 | ULONG ulTime=WinGetCurrentTime(hab);
|
---|
416 |
|
---|
417 | //SysWriteToTrapLog("Sem timeout\n");
|
---|
418 |
|
---|
419 | //ulPostCount=0; /* only debug */
|
---|
420 | /* Check for pending messages */
|
---|
421 | while(WinPeekMsg(hab,&qmsg,(HWND)NULL,0,0, PM_NOREMOVE)) {
|
---|
422 |
|
---|
423 | //ulPostCount++;
|
---|
424 | //SysWriteToTrapLog(" Have msg %d\n", ulPostCount);
|
---|
425 |
|
---|
426 | /*
|
---|
427 | Check for system msgs and dispatch them.
|
---|
428 | */
|
---|
429 | if(qmsg.msg!=IMGWM_DELETEBITMAP) {
|
---|
430 | /* Get the message and quit if it's WM_QUIT (shouldn't happen though) */
|
---|
431 | if((bQuit=!WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))==TRUE)
|
---|
432 | break;
|
---|
433 | /* else dispatch and continue loop */
|
---|
434 | WinDispatchMsg(hab,&qmsg);
|
---|
435 | continue;
|
---|
436 | }
|
---|
437 | bTimeError=FALSE;
|
---|
438 | if(ulTime-qmsg.time > BMP_DEL_MINAGE) {
|
---|
439 | /* The message is old enough so get it and dispatch */
|
---|
440 | // SysWriteToTrapLog(" time > BMP_DEL_MINAGE\n");
|
---|
441 | WinGetMsg(hab,&qmsg,(HWND)NULL,0,0);
|
---|
442 | WinDispatchMsg(hab,&qmsg);
|
---|
443 | // SysWriteToTrapLog("Dispatched, next msg?\n");
|
---|
444 | ulWaitTime=BMP_DEL_WAITTIME;
|
---|
445 | }
|
---|
446 | else {
|
---|
447 | /* Message isn't old so wait until wait time is really over */
|
---|
448 | // SysWriteToTrapLog(" time to short!!!\n");
|
---|
449 | ulWaitTime=BMP_DEL_WAITTIME-(ulTime-qmsg.time);
|
---|
450 | bTimeError=TRUE;
|
---|
451 | break;
|
---|
452 | }
|
---|
453 | // SysWriteToTrapLog("Back to inner while...\n");
|
---|
454 | }/* while */
|
---|
455 | /*
|
---|
456 | FIXME:
|
---|
457 |
|
---|
458 | Make ist right and robust!
|
---|
459 |
|
---|
460 | Set counter to 0 if all messages are handled. This isn't correct, because it's not thread safe
|
---|
461 | but doesn't matter that much. In the worst case some messages are dispatched later but
|
---|
462 | it's not system critical at all. In wpUninitData() the bitmaps are deleted anyway.
|
---|
463 | */
|
---|
464 | if(!bTimeError)
|
---|
465 | ulNumBMPDelete=0; /* No messages in queue (but maybe another thread is just adding them...) */
|
---|
466 | } /* semaphore timeout */
|
---|
467 | else
|
---|
468 | {
|
---|
469 | /*
|
---|
470 | queue is almost full. The semaphore was posted by the function so
|
---|
471 | dispatch messages faster.
|
---|
472 | */
|
---|
473 | int a=0;
|
---|
474 | // SysWriteToTrapLog(" --Semaphore posted\n");
|
---|
475 | while((bQuit=!WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))==FALSE
|
---|
476 | && a < BMP_DEL_UPPER-BMP_DEL_LOWER) {
|
---|
477 | // SysWriteToTrapLog(" -- Got message, dispatching it...\n");
|
---|
478 | if(qmsg.msg==IMGWM_DELETEBITMAP)
|
---|
479 | a++;
|
---|
480 | WinDispatchMsg(hab,&qmsg);
|
---|
481 | // SysWriteToTrapLog("--Dispatching msg %d\n", a);
|
---|
482 | }/* while */
|
---|
483 | ulWaitTime=BMP_DEL_WAITTIME;
|
---|
484 | }
|
---|
485 | // if(WinQueryQueueInfo(hmq, &mqi, sizeof(MQINFO)))
|
---|
486 | // SysWriteToTrapLog("WinQueryQueueInfo succeeded.\n");
|
---|
487 | // if(!mqi.cmsgs)
|
---|
488 | // ulNumBMPDelete=mqi.cmsgs;
|
---|
489 | // SysWriteToTrapLog("Now resetting event semaphore\n");
|
---|
490 |
|
---|
491 | DosResetEventSem(hevDeleteBMP, &ulPostCount);
|
---|
492 | }/* bSemCreated */
|
---|
493 | if(bQuit)
|
---|
494 | break;
|
---|
495 | }/* while() */
|
---|
496 |
|
---|
497 | DosCloseEventSem(hevDeleteBMP);
|
---|
498 | WinDestroyWindow(g_hwndDeleteBMP);
|
---|
499 | }
|
---|
500 | WinDestroyMsgQueue(hmq);
|
---|
501 | }
|
---|
502 | WinTerminate(hab);
|
---|
503 | }
|
---|
504 | }
|
---|
505 |
|
---|
506 | void sendDeleteBMPMsg(MMImage* somSelf)
|
---|
507 | {
|
---|
508 | PUSEITEM pui;
|
---|
509 | /*
|
---|
510 | Unfortunately only bitmaps for real files are currently deleted. When using links in folders
|
---|
511 | the lock counter isn't touched so we don't get a notification.
|
---|
512 | _wpUnlockObject isn't called when links are going dormant (do they?) after closing the links folder.
|
---|
513 |
|
---|
514 | BTW XWorkplace (V1.0.0) keeps every object locked
|
---|
515 | after first touching it and NEVER completely unlocks it!
|
---|
516 | */
|
---|
517 | // SysWriteToTrapLog("Out side - %s %d\n", __FUNCTION__, ulNumBMPDelete);
|
---|
518 | if((pui=_wpFindUseItem(somSelf, USAGE_RECORD, NULLHANDLE))==NULLHANDLE) {
|
---|
519 | /* Check if queue is full. If yes post semaphore so the other thread cleans up. */
|
---|
520 | if(ulNumBMPDelete> BMP_DEL_UPPER) {
|
---|
521 | // SysWriteToTrapLog(" ---> Posting semaphore...\n");
|
---|
522 | DosPostEventSem(hevDeleteBMP);
|
---|
523 | /* Yield cpu so the delete thread may run */
|
---|
524 | DosSleep(20);
|
---|
525 | /* Thread isn't fast enough so delete the bitmap directly */
|
---|
526 | if(ulNumBMPDelete>BMP_QUEUE_SIZE-7) {
|
---|
527 | _cwmmFreeBitmaps(somSelf);
|
---|
528 | return;
|
---|
529 | }
|
---|
530 | }
|
---|
531 | ulNumBMPDelete++;
|
---|
532 | // SysWriteToTrapLog("%s %d\n", __FUNCTION__, ulNumBMPDelete);
|
---|
533 | WinPostMsg(g_hwndDeleteBMP, IMGWM_DELETEBITMAP, MPFROMP(somSelf), MPFROM2SHORT(0, ACKEY_CREATE_SMALLBITMAP));
|
---|
534 | }
|
---|
535 | }
|
---|
536 |
|
---|
537 | MRESULT EXPENTRY imageInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
538 | {
|
---|
539 | MMImage *cwImage;
|
---|
540 |
|
---|
541 | switch(msg) {
|
---|
542 | case WM_INITDLG :
|
---|
543 | cwImage=(MMImage*)LONGFROMMP(mp2);
|
---|
544 | if(somIsObj(cwImage)) {
|
---|
545 | MMImageData *somThis = MMImageGetData(cwImage);
|
---|
546 |
|
---|
547 | PBITMAPINFOHEADER2 pbmpih2;
|
---|
548 |
|
---|
549 | if((pbmpih2=(PBITMAPINFOHEADER2)_wpQueryBitmapInfoHeader(cwImage))!=NULLHANDLE)
|
---|
550 | {
|
---|
551 | char fName[CCHMAXPATH];
|
---|
552 | char chrTemplate[100];
|
---|
553 |
|
---|
554 | if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
555 | if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
|
---|
556 | queryResModuleHandle(), hwnd))
|
---|
557 | strcpy(chrTemplate, "%d Pixel");
|
---|
558 | sprintf(fName, chrTemplate, pbmpih2->cx);
|
---|
559 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
|
---|
560 |
|
---|
561 | sprintf(fName, chrTemplate, pbmpih2->cy);
|
---|
562 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
|
---|
563 |
|
---|
564 | if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
|
---|
565 | queryResModuleHandle(), hwnd))
|
---|
566 | strcpy(chrTemplate, "%d Bit");
|
---|
567 | sprintf(fName, chrTemplate, pbmpih2->cBitCount);
|
---|
568 | WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
|
---|
569 | }
|
---|
570 | else if(pbmpih2->cbFix==sizeof(BITMAPINFOHEADER)) {
|
---|
571 | /* We shouldn't get a BITMAPINFOHEADER here but who knows...*/
|
---|
572 | PBITMAPINFOHEADER pbmpih=(PBITMAPINFOHEADER)pbmpih2;
|
---|
573 | if(!getMessage(chrTemplate, IDSTR_SPRINTFPIXEL, sizeof(chrTemplate),
|
---|
574 | queryResModuleHandle(), hwnd))
|
---|
575 | strcpy(chrTemplate, "%d Pixel");
|
---|
576 | sprintf(fName, chrTemplate,pbmpih->cx);
|
---|
577 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEWIDTH),fName);
|
---|
578 |
|
---|
579 | sprintf(fName, chrTemplate, pbmpih->cy);
|
---|
580 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEHEIGHT),fName);
|
---|
581 |
|
---|
582 | if(!getMessage(chrTemplate, IDSTR_SPRINTFBIT, sizeof(chrTemplate),
|
---|
583 | queryResModuleHandle(), hwnd))
|
---|
584 | strcpy(chrTemplate, "%d Bit");
|
---|
585 | sprintf(fName, chrTemplate, pbmpih->cBitCount);
|
---|
586 | WinSetWindowText(WinWindowFromID(hwnd, IDST_COLORDEPTH),fName);
|
---|
587 | }
|
---|
588 |
|
---|
589 | WinSetWindowText(WinWindowFromID(hwnd, IDST_IMAGEFORMAT),_chrIOProcName);
|
---|
590 | }
|
---|
591 | }/* somIsObj() */
|
---|
592 | return (MRESULT)TRUE;
|
---|
593 | /* This prevents switching the notebook page behind the open folder */
|
---|
594 | case WM_WINDOWPOSCHANGED:
|
---|
595 | {
|
---|
596 | MRESULT mr;
|
---|
597 |
|
---|
598 | if(WinQueryFocus(HWND_DESKTOP)!=
|
---|
599 | WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
|
---|
600 | mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
|
---|
601 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
602 | return mr;
|
---|
603 | }
|
---|
604 | break;
|
---|
605 | }
|
---|
606 | case WM_FOCUSCHANGE:
|
---|
607 | {
|
---|
608 | if(!SHORT1FROMMP(mp2)) {
|
---|
609 | if(HWNDFROMMP(mp1)==hwnd) {
|
---|
610 | MRESULT mr;
|
---|
611 |
|
---|
612 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
613 | WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT),
|
---|
614 | WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
|
---|
615 | return mr;
|
---|
616 | }
|
---|
617 | }
|
---|
618 | break;
|
---|
619 | }
|
---|
620 | case WM_DESTROY:
|
---|
621 | /* The notebook closes and gets destroyed */
|
---|
622 | /* Set focus to desktop to prevent PM freeze */
|
---|
623 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
---|
624 | break;
|
---|
625 | default:
|
---|
626 | break;
|
---|
627 | }
|
---|
628 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
629 | }
|
---|
630 |
|
---|
631 | /*!*******************************************************/
|
---|
632 | /* */
|
---|
633 | /* @@DESC */
|
---|
634 | /* */
|
---|
635 | /* This instance method is called to allow the object */
|
---|
636 | /* to add the image information page to its Settings */
|
---|
637 | /* notebook. */
|
---|
638 | /* */
|
---|
639 | /* @@USAGE */
|
---|
640 | /* */
|
---|
641 | /* This method must only be called from within an */
|
---|
642 | /* override of wpAddSettingsPages(). */
|
---|
643 | /* */
|
---|
644 | /* @@PARAM */
|
---|
645 | /* */
|
---|
646 | /* MMImage *somSelf input */
|
---|
647 | /* */
|
---|
648 | /* Pointer to the object on which the method is being */
|
---|
649 | /* invoked. */
|
---|
650 | /* :p. */
|
---|
651 | /* Points to an object of class :hp2.MMImage:ehp2.. */
|
---|
652 | /* */
|
---|
653 | /* @@PARAM */
|
---|
654 | /* */
|
---|
655 | /* HWND hwndNotebook input */
|
---|
656 | /* */
|
---|
657 | /* Settings notebook handle. */
|
---|
658 | /* */
|
---|
659 | /* @@OVERRIDE */
|
---|
660 | /* */
|
---|
661 | /* This method should always be overridden in order to */
|
---|
662 | /* remove or replace the image information page from */
|
---|
663 | /* the object's Settings notbook. */
|
---|
664 | /* :p. */
|
---|
665 | /* To remove the page from the Settings notebook, the */
|
---|
666 | /* override method should return */
|
---|
667 | /* :hp1.SETTINGS_PAGE_REMOVED:ehp1. without calling the */
|
---|
668 | /* the parent method. To replace the page with another */
|
---|
669 | /* page, the override method should call the */
|
---|
670 | /* wpInsertSettingsPAge method without calling the */
|
---|
671 | /* parent method. */
|
---|
672 | /* */
|
---|
673 | /* @@RETURNS */
|
---|
674 | /* */
|
---|
675 | /* ULONG rc */
|
---|
676 | /* */
|
---|
677 | /* :parml compact tsize=15 break=none. */
|
---|
678 | /* :pt.0:pd.Error occurred */
|
---|
679 | /* :pt.PageId :pd.Identifier for the inserted page. */
|
---|
680 | /* :eparml. */
|
---|
681 | /* */
|
---|
682 | /*!!******************************************************/
|
---|
683 | SOM_Scope ULONG SOMLINK cwimg_cwmmAddImageInformationPage(MMImage *somSelf,
|
---|
684 | HWND hwndNotebook)
|
---|
685 | {
|
---|
686 | PAGEINFO pageinfo;
|
---|
687 | char pageName[100];
|
---|
688 |
|
---|
689 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
690 | MMImageMethodDebug("MMImage","cwimg_cwmmAddImageInformationPage");
|
---|
691 |
|
---|
692 | //Clear the pageinfo structure
|
---|
693 | memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
|
---|
694 | //Fill the pageinfo structure
|
---|
695 | pageinfo.cb = sizeof(PAGEINFO);
|
---|
696 | pageinfo.hwndPage = NULLHANDLE;
|
---|
697 | pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
|
---|
698 | pageinfo.usPageInsertFlags = BKA_FIRST;
|
---|
699 | //We want page numbers
|
---|
700 | pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
|
---|
701 | //The dialog procedure for this page
|
---|
702 | pageinfo.pfnwp = imageInfoDlgProc;
|
---|
703 | //The resource DLL
|
---|
704 | pageinfo.resid = queryResModuleHandle();
|
---|
705 | //The ID of the dialog template
|
---|
706 | pageinfo.dlgid = IDDLG_IMAGEINFOPAGE;
|
---|
707 | //We need a pointer to our WPS-object in the dialog procedure
|
---|
708 | //to call class functions
|
---|
709 | pageinfo.pCreateParams = somSelf;
|
---|
710 | //The ID of the help panel for this page
|
---|
711 | //pageinfo.idDefaultHelpPanel = IDDLG_GENERAL2PAGE;
|
---|
712 |
|
---|
713 | //Tell the WPS the help library name
|
---|
714 | pageinfo.pszHelpLibraryName = NULLHANDLE;
|
---|
715 | //We have a major tab so we need a name
|
---|
716 | /* pageName: "ISO filesystem" */
|
---|
717 | if(!getMessage(pageName, IDSTR_IMAGEINFOPAGENAME, sizeof(pageName), queryResModuleHandle(), hwndNotebook))
|
---|
718 | strcpy(pageName, "~Image information");
|
---|
719 | pageinfo.pszName = pageName;
|
---|
720 | //Insert the page into the settings notebook
|
---|
721 | return _wpInsertSettingsPage(somSelf,hwndNotebook,&pageinfo);
|
---|
722 |
|
---|
723 | }
|
---|
724 |
|
---|
725 | /*!*******************************************************/
|
---|
726 | /* */
|
---|
727 | /* @@DESC */
|
---|
728 | /* */
|
---|
729 | /* This instance method is called to get a small bitmap */
|
---|
730 | /* representing the image of this object. */
|
---|
731 | /* */
|
---|
732 | /* @@USAGE */
|
---|
733 | /* */
|
---|
734 | /* This method is called by a folder painting procedure */
|
---|
735 | /* when the objects image must be drawn as an icon in */
|
---|
736 | /* a folder. For example the lighttable folder uses this */
|
---|
737 | /* to get the bitmaps of image files. */
|
---|
738 | /* :p. */
|
---|
739 | /* This method is specifically designed for the mentioned*/
|
---|
740 | /* purpose. It is called with a pointer to the objects */
|
---|
741 | /* container record and the container handle. If the */
|
---|
742 | /* needed bitmap handle isn't already created, this */
|
---|
743 | /* will be done on a separate thread and afterwards the */
|
---|
744 | /* objects record will automatically updated with the */
|
---|
745 | /* new image. The caller doesn't has to wait for this and*/
|
---|
746 | /* has not to repeat the call if a NULLHANDLE is */
|
---|
747 | /* returned. */
|
---|
748 | /* */
|
---|
749 | /* @@PARAM */
|
---|
750 | /* */
|
---|
751 | /* MMImage *somSelf input */
|
---|
752 | /* */
|
---|
753 | /* Pointer to the object on which the method is being */
|
---|
754 | /* invoked. */
|
---|
755 | /* :p. */
|
---|
756 | /* Points to an object of class :hp2.MMImage:ehp2.. */
|
---|
757 | /* */
|
---|
758 | /* @@PARAM */
|
---|
759 | /* */
|
---|
760 | /* ULONG ulSize input */
|
---|
761 | /* */
|
---|
762 | /* Size of the bitmap. */
|
---|
763 | /* */
|
---|
764 | /* @@PARAM */
|
---|
765 | /* */
|
---|
766 | /* PMINIRECORDCORE pmrcToRefresh input */
|
---|
767 | /* */
|
---|
768 | /* The objects container record. This record will */
|
---|
769 | /* automatically be refreshed when the bitmap */
|
---|
770 | /* isn't already created. */
|
---|
771 | /* */
|
---|
772 | /* @@PARAM */
|
---|
773 | /* */
|
---|
774 | /* HWND hwndCnr input */
|
---|
775 | /* */
|
---|
776 | /* The container holding the object. After creating the */
|
---|
777 | /* bitmap the icon of the object in this container will */
|
---|
778 | /* be redrawn. */
|
---|
779 | /* */
|
---|
780 | /* @@OVERRIDE */
|
---|
781 | /* */
|
---|
782 | /* This method is generally not overridden. */
|
---|
783 | /* */
|
---|
784 | /* @@RETURNS */
|
---|
785 | /* */
|
---|
786 | /* HBITMAP hBitmap */
|
---|
787 | /* */
|
---|
788 | /* A bitmap handle of a small bitmap usable to be drawn */
|
---|
789 | /* as an objects representation in a folder. */
|
---|
790 | /* */
|
---|
791 | /*!!******************************************************/
|
---|
792 | SOM_Scope HBITMAP SOMLINK cwimg_cwmmQuerySmallBitmapHandle(MMImage *somSelf,
|
---|
793 | ULONG ulSize,
|
---|
794 | PMINIRECORDCORE pmrcToRefresh,
|
---|
795 | HWND hwndCnr)
|
---|
796 | {
|
---|
797 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
798 | MMImageMethodDebug("MMImage","cwimg_cwmmQuerySmallBitmap");
|
---|
799 |
|
---|
800 | // SysWriteToTrapLog("In %s, line %d. ulSize: %d\n", __FUNCTION__, __LINE__, ulSize);
|
---|
801 |
|
---|
802 |
|
---|
803 | #ifdef DEBUG
|
---|
804 | SysWriteToTrapLog("In %s, line %d. somself: 0x%x, ulSize: 0x%x, mrc: 0x%x, hwndCnr: 0x%x.\n",
|
---|
805 | __FUNCTION__, __LINE__, somSelf, ulSize, pmrcToRefresh, hwndCnr);
|
---|
806 |
|
---|
807 |
|
---|
808 | //SysWriteToTrapLog("In %s, line %d. ulSize: 0x%x, mrc: 0x%x, hwndCnr: 0x%x, _bNoIOProcAvailable: 0x%x, somSelf: 0x%x, somThis: 0x%x.\n",
|
---|
809 | // __FUNCTION__, __LINE__, ulSize, pmrcToRefresh, hwndCnr, _bNoIOProcAvailable, somSelf, somThis);
|
---|
810 | #endif
|
---|
811 |
|
---|
812 | if(_bNoIOProcAvailable)
|
---|
813 | return NULLHANDLE; /* No IO-proc for this image format. Don't try again in the future.
|
---|
814 | This var is set if we trapped during reading. */
|
---|
815 |
|
---|
816 | if(!_wpIsObjectInitialized(somSelf)) {
|
---|
817 | #ifdef DEBUG
|
---|
818 | SysWriteToTrapLog("In %s, line %d Object is not initialized\n", __FUNCTION__, __LINE__);
|
---|
819 | #endif
|
---|
820 | return NULLHANDLE;
|
---|
821 | }
|
---|
822 | #ifdef DEBUG
|
---|
823 | SysWriteToTrapLog("In %s, line %d\n", __FUNCTION__, __LINE__);
|
---|
824 | #endif
|
---|
825 |
|
---|
826 | if(ulSize<MAX_SIZE_SMALLBITMAP)
|
---|
827 | ulSize=MAX_SIZE_SMALLBITMAP;
|
---|
828 |
|
---|
829 | if(ulSize>_ulSizeSmallBitmap)
|
---|
830 | {
|
---|
831 | if(_hBitmapSmall) {
|
---|
832 | GpiDeleteBitmap(_hBitmapSmall);
|
---|
833 | _hBitmapSmall=NULLHANDLE;
|
---|
834 | }
|
---|
835 | }
|
---|
836 |
|
---|
837 | /*
|
---|
838 | FIXME: use WinIsWindow() here??
|
---|
839 | */
|
---|
840 | if(!_hBitmapSmall && hwndCreateBMP) {
|
---|
841 | ULONG ulError;
|
---|
842 | PCREATEBMPINFO pCreateBMP;
|
---|
843 | _ulSizeSmallBitmap=0;
|
---|
844 |
|
---|
845 | /* Allocate memory for small bitmap info for the thread */
|
---|
846 | // if((pCreateBMP=(PCREATEBMPINFO)_wp_AllocMem(somSelf, sizeof(CREATEBMPINFO),&ulError))==NULLHANDLE)
|
---|
847 | if((pCreateBMP=(PCREATEBMPINFO)malloc( sizeof(CREATEBMPINFO)))==NULLHANDLE)
|
---|
848 | return NULLHANDLE;
|
---|
849 |
|
---|
850 | pCreateBMP->ulWidth=ulSize;
|
---|
851 | pCreateBMP->ulHeight=ulSize;
|
---|
852 | pCreateBMP->wpObject=somSelf;
|
---|
853 | pCreateBMP->pmrcToRefresh=pmrcToRefresh;
|
---|
854 | pCreateBMP->hwndCnr=hwndCnr;
|
---|
855 |
|
---|
856 | #ifdef DEBUG
|
---|
857 | SysWriteToTrapLog("In %s, line %d. Sending msg to create thread.\n", __FUNCTION__, __LINE__);
|
---|
858 | #endif
|
---|
859 |
|
---|
860 | WinPostMsg(hwndCreateBMP, WM_APPTERMINATENOTIFY,MPFROMP(pCreateBMP), MPFROM2SHORT(0, ACKEY_CREATE_SMALLBITMAP));
|
---|
861 | return NULLHANDLE;
|
---|
862 | }
|
---|
863 | /* Return statement to be customized: */
|
---|
864 | return _hBitmapSmall;
|
---|
865 | }
|
---|
866 |
|
---|
867 |
|
---|
868 | SOM_Scope void SOMLINK cwimg_cwmmFreeBitmaps(MMImage *somSelf)
|
---|
869 | {
|
---|
870 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
871 | MMImageMethodDebug("MMImage","cwimg_cwmmFreeBitmaps");
|
---|
872 |
|
---|
873 |
|
---|
874 | if(_pBmpInfoHeader2) {
|
---|
875 | free(_pBmpInfoHeader2);
|
---|
876 | // _wp_FreeMem(somSelf, _pBmpInfoHeader2);
|
---|
877 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
878 | _chrIOProcName[0]=0;
|
---|
879 | }
|
---|
880 |
|
---|
881 | if(_hBitmap) {
|
---|
882 | GpiDeleteBitmap(_hBitmap);
|
---|
883 | _hBitmap=NULLHANDLE;
|
---|
884 | }
|
---|
885 |
|
---|
886 | _cwmmFreeSmallBitmap(somSelf);
|
---|
887 | }
|
---|
888 |
|
---|
889 | /*
|
---|
890 | * The prototype for cwimg_cwmmFreeSmallBitmap was replaced by the following prototype:
|
---|
891 | */
|
---|
892 | SOM_Scope void SOMLINK cwimg_cwmmFreeSmallBitmap(MMImage *somSelf)
|
---|
893 | {
|
---|
894 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
895 | MMImageMethodDebug("MMImage","cwimg_cwmmFreeSmallBitmap");
|
---|
896 |
|
---|
897 | /*
|
---|
898 | V0.2.8 CW 2004/11/01
|
---|
899 |
|
---|
900 | Added serialization using the object semaphore
|
---|
901 |
|
---|
902 |
|
---|
903 | if(!_wpRequestObjectMutexSem(somSelf, 2000))
|
---|
904 | return;
|
---|
905 | */
|
---|
906 | if(_hBitmapSmall) {
|
---|
907 |
|
---|
908 | GpiDeleteBitmap(_hBitmapSmall);
|
---|
909 | _hBitmapSmall=NULLHANDLE;
|
---|
910 | _ulSizeSmallBitmap=0;
|
---|
911 | }
|
---|
912 | // _wpReleaseObjectMutexSem(somSelf);
|
---|
913 | }
|
---|
914 |
|
---|
915 | /* New with V0.2.5, CW 2003/01/02 */
|
---|
916 | SOM_Scope ULONG SOMLINK cwimg_cwmmQueryImageInfo(MMImage *somSelf,
|
---|
917 | char** chrString,
|
---|
918 | ULONG ulSize,
|
---|
919 | int iWhich)
|
---|
920 | {
|
---|
921 | PBITMAPINFOHEADER2 pBmpInfoHdr2=NULLHANDLE;
|
---|
922 | ULONG ulWidth, ulHeight, ulDepth;
|
---|
923 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
924 | MMImageMethodDebug("MMImage","cwimg_cwmmQueryImageInfo");
|
---|
925 |
|
---|
926 | pBmpInfoHdr2=(PBITMAPINFOHEADER2) _wpQueryBitmapInfoHeader(somSelf);
|
---|
927 |
|
---|
928 | if(!pBmpInfoHdr2)
|
---|
929 | return 0;
|
---|
930 |
|
---|
931 | if(pBmpInfoHdr2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
932 | ulWidth=pBmpInfoHdr2->cx;
|
---|
933 | ulHeight=pBmpInfoHdr2->cy;
|
---|
934 | ulDepth=pBmpInfoHdr2->cBitCount;
|
---|
935 | }
|
---|
936 | else {
|
---|
937 | PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)pBmpInfoHdr2;
|
---|
938 | ulWidth=pBmpInfoHdr->cx;
|
---|
939 | ulHeight=pBmpInfoHdr->cy;
|
---|
940 | ulDepth=pBmpInfoHdr->cBitCount;
|
---|
941 | }
|
---|
942 | switch(iWhich)
|
---|
943 | {
|
---|
944 | case IDINFO_WIDTH:
|
---|
945 | return ulWidth;
|
---|
946 | case IDINFO_HEIGHT:
|
---|
947 | return ulHeight;
|
---|
948 | case IDINFO_BPP:
|
---|
949 | return ulDepth;
|
---|
950 | case IDINFO_FORMAT:
|
---|
951 | {
|
---|
952 | char *chr;
|
---|
953 | /* Image format */
|
---|
954 | if(!chrString)
|
---|
955 | return 0;
|
---|
956 | chr=*chrString;
|
---|
957 | strncpy(chr, _chrIOProcName, ulSize);
|
---|
958 | chr[ulSize-1]=0;
|
---|
959 | if(chr[0]==0)
|
---|
960 | return 0;
|
---|
961 | else
|
---|
962 | return 1;
|
---|
963 | }
|
---|
964 | default:
|
---|
965 | break;
|
---|
966 | }
|
---|
967 | return 0;
|
---|
968 | }
|
---|
969 |
|
---|
970 | SOM_Scope void SOMLINK cwimg_cwmmRequestBmpDeletion(MMImage *somSelf,
|
---|
971 | ULONG ulFlags)
|
---|
972 | {
|
---|
973 | PUSEITEM pui;
|
---|
974 | BOOL bDeleteBmp=FALSE;
|
---|
975 |
|
---|
976 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
977 | MMImageMethodDebug("MMImage","cwimg_cwmmRequestBmpDeletion");
|
---|
978 |
|
---|
979 |
|
---|
980 | /*
|
---|
981 | Unfortunately only bitmaps for real files are currently deleted. When using links in folders
|
---|
982 | the lock counter isn't touched so we don't get a notification.
|
---|
983 | _wpUnlockObject isn't called when links are going dormant (do they?) after closing the links folder.
|
---|
984 |
|
---|
985 | BTW XWorkplace (V1.0.0) keeps every object locked
|
---|
986 | after first touching it and NEVER completely unlocks it!
|
---|
987 | */
|
---|
988 | TRY_LOUD(BITMAP_DELETION) {
|
---|
989 | if((pui=_wpFindUseItem(somSelf, USAGE_RECORD, NULLHANDLE))==NULLHANDLE) {
|
---|
990 | bDeleteBmp=TRUE;
|
---|
991 | }
|
---|
992 | else {
|
---|
993 | /* There's at least one usage record. Check if the icon is visible */
|
---|
994 | RECTL rectl2;
|
---|
995 | PRECORDITEM pri=(PRECORDITEM)(++pui);
|
---|
996 |
|
---|
997 | /*
|
---|
998 | V0.2.9 CW 2004/11/12
|
---|
999 |
|
---|
1000 | Check if small bitmaps for icons are currently visible in any container. This is useful if the
|
---|
1001 | user scrolls a folder with a lot of pictures.
|
---|
1002 | */
|
---|
1003 | pui--;
|
---|
1004 | bDeleteBmp=TRUE;
|
---|
1005 | for(;pui ; pui=_wpFindUseItem(somSelf, USAGE_RECORD, pui)) {
|
---|
1006 | pri=(PRECORDITEM)(++pui);
|
---|
1007 | pui--;
|
---|
1008 | if(WinSendMsg(pri->hwndCnr, CM_QUERYVIEWPORTRECT, MPFROMP(&rectl2), MPFROM2SHORT(CMA_WORKSPACE, FALSE))) {
|
---|
1009 |
|
---|
1010 | if(pri->pRecord->ptlIcon.y >= rectl2.yBottom && pri->pRecord->ptlIcon.y <= rectl2.yTop &&
|
---|
1011 | pri->pRecord->ptlIcon.x >= rectl2.xLeft && pri->pRecord->ptlIcon.x < rectl2.xRight)
|
---|
1012 | bDeleteBmp=FALSE;
|
---|
1013 |
|
---|
1014 | }/* WinSendMsg() */
|
---|
1015 | }
|
---|
1016 | }/* else */
|
---|
1017 | }/* Try */
|
---|
1018 | CATCH(BITMAP_DELETION)
|
---|
1019 | {
|
---|
1020 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
---|
1021 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1022 | } END_CATCH;
|
---|
1023 |
|
---|
1024 | if(bDeleteBmp) {
|
---|
1025 | /* Check if queue is full. If yes post semaphore so the other thread cleans up. */
|
---|
1026 | if(ulNumBMPDelete> BMP_DEL_UPPER) {
|
---|
1027 | DosPostEventSem(hevDeleteBMP);
|
---|
1028 | /* Yield cpu so the delete thread may run */
|
---|
1029 | DosSleep(20);
|
---|
1030 | /* Thread isn't fast enough so delete the bitmap directly */
|
---|
1031 | if(ulNumBMPDelete>BMP_QUEUE_SIZE-7) {
|
---|
1032 | _cwmmFreeBitmaps(somSelf);
|
---|
1033 | return;
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 | ulNumBMPDelete++;
|
---|
1037 | WinPostMsg(g_hwndDeleteBMP, IMGWM_DELETEBITMAP, MPFROMP(somSelf), MPFROM2SHORT(0, ACKEY_CREATE_SMALLBITMAP));
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | /*
|
---|
1042 | * The prototype for cwimg_wpQueryBitmapHandle was replaced by the following prototype:
|
---|
1043 | */
|
---|
1044 | SOM_Scope BOOL SOMLINK cwimg_wpQueryBitmapHandle(MMImage *somSelf,
|
---|
1045 | HBITMAP* phBitmap,
|
---|
1046 | HPAL* phPalette,
|
---|
1047 | ULONG ulWidth,
|
---|
1048 | ULONG ulHeight,
|
---|
1049 | ULONG ulFlags,
|
---|
1050 | long lBackgroundColor,
|
---|
1051 | BOOL* pbQuitEarly)
|
---|
1052 | {
|
---|
1053 | ULONG ulSize;
|
---|
1054 | char chrName[CCHMAXPATH];
|
---|
1055 |
|
---|
1056 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1057 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapHandle");
|
---|
1058 |
|
---|
1059 | /* Check parameter */
|
---|
1060 | if(!phBitmap)
|
---|
1061 | return FALSE;
|
---|
1062 |
|
---|
1063 | if(!_wpReadImageFile(somSelf))
|
---|
1064 | return FALSE;
|
---|
1065 |
|
---|
1066 | *phBitmap=NULLHANDLE;
|
---|
1067 | if(phPalette)
|
---|
1068 | *phPalette=NULLHANDLE;
|
---|
1069 |
|
---|
1070 | ulSize=sizeof(chrName);
|
---|
1071 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
1072 | return FALSE;
|
---|
1073 |
|
---|
1074 |
|
---|
1075 | TRY_LOUD(QRY_HBM) {
|
---|
1076 | /* Create a new (maybe smaller) bitmap from the normal size bitmap */
|
---|
1077 | *phBitmap=createNewBitmap ( _hBitmap, (PBITMAPINFOHEADER2) _pBmpInfoHeader2,
|
---|
1078 | ulWidth, ulHeight , pbQuitEarly);
|
---|
1079 | }
|
---|
1080 | CATCH(QRY_HBM)
|
---|
1081 | {
|
---|
1082 | *phBitmap=NULLHANDLE;
|
---|
1083 |
|
---|
1084 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling createNewBitmap().\n",
|
---|
1085 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1086 | SysWriteToTrapLog("Image file: %s\n\n",
|
---|
1087 | chrName);
|
---|
1088 | } END_CATCH;
|
---|
1089 |
|
---|
1090 | if(!*phBitmap)
|
---|
1091 | return FALSE;
|
---|
1092 |
|
---|
1093 | return TRUE;
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | /*
|
---|
1097 | * The prototype for cwimg_wpQueryBitmapInfoHeader was replaced by the following prototype:
|
---|
1098 | */
|
---|
1099 | SOM_Scope PBYTE SOMLINK cwimg_wpQueryBitmapInfoHeader(MMImage *somSelf)
|
---|
1100 | {
|
---|
1101 | ULONG ulSize;
|
---|
1102 | char chrName[CCHMAXPATH];
|
---|
1103 | PBYTE pByte=NULLHANDLE;
|
---|
1104 | BOOL bGotHeader=FALSE;
|
---|
1105 | BOOL bSem;
|
---|
1106 |
|
---|
1107 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1108 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapInfoHeader");
|
---|
1109 |
|
---|
1110 | #ifdef DEBUG
|
---|
1111 | SysWriteToTrapLog("In _wpQueryBitmapInfoHeader(), line %d\n", __LINE__);
|
---|
1112 | #endif
|
---|
1113 |
|
---|
1114 | /* This is necessary for newly created files. */
|
---|
1115 | if(!_wpIsObjectInitialized(somSelf))
|
---|
1116 | return NULLHANDLE;
|
---|
1117 |
|
---|
1118 |
|
---|
1119 | #ifdef DEBUG
|
---|
1120 | ulSize=sizeof(chrName);
|
---|
1121 | if(_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
1122 | SysWriteToTrapLog("In _wpQueryBitmapInfoHeader() for %s\n", chrName);
|
---|
1123 | else
|
---|
1124 | SysWriteToTrapLog("In _wpQueryBitmapInfoHeader(), filename unknown\n");
|
---|
1125 | #endif
|
---|
1126 |
|
---|
1127 | if(_pBmpInfoHeader2)
|
---|
1128 | return _pBmpInfoHeader2;
|
---|
1129 |
|
---|
1130 | if(_bNoIOProcAvailable)
|
---|
1131 | return NULL; /* No IO-proc for this image format. Don't try again in the future. */
|
---|
1132 |
|
---|
1133 | /*
|
---|
1134 | Don't request the object sem here. The call may block at least when a light table
|
---|
1135 | folder tries to show the object.
|
---|
1136 | Problem is that there's a race condition with the code in the light table frame proc trying
|
---|
1137 | to get the bitmap header (now disabled if small bitmap can't be loaded) for newly inserted
|
---|
1138 | objects. As soon as _wpAllocMem() is called in the code below the WPS blocks. Probably there's
|
---|
1139 | a problem with inserting the USAGE_MEMORY item in the in use list while the folder is inserting
|
---|
1140 | a USAGE_RECORD item. One would assume requesting the mutex solves this but no go... The call
|
---|
1141 | to _wpRequestObjectMutexSem() just blocks for the specified timeout without returning the semaphor.
|
---|
1142 | Probably that's exactly what's happening in _wpAllocMem().
|
---|
1143 |
|
---|
1144 | bSem=_wpRequestObjectMutexSem(somSelf, 3000);//SEM_INDEFINITE_WAIT);
|
---|
1145 |
|
---|
1146 | */
|
---|
1147 |
|
---|
1148 | #if 0
|
---|
1149 | if(!_wpAssertObjectMutexSem(somSelf))
|
---|
1150 | {
|
---|
1151 | DosBeep(500, 130);
|
---|
1152 | #if 0
|
---|
1153 | // bSem=_wpRequestObjectMutexSem(somSelf, 3000);
|
---|
1154 | if(bSem)
|
---|
1155 | {
|
---|
1156 | DosBeep(5000, 130);
|
---|
1157 | _wpReleaseObjectMutexSem(somSelf);
|
---|
1158 | //return NULLHANDLE;
|
---|
1159 | }
|
---|
1160 | #endif
|
---|
1161 | }
|
---|
1162 | #endif
|
---|
1163 |
|
---|
1164 | TRY_LOUD(GET_BMPIH) {
|
---|
1165 | for(;;)
|
---|
1166 | {
|
---|
1167 |
|
---|
1168 | ulSize=sizeof(chrName);
|
---|
1169 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
1170 | break;
|
---|
1171 |
|
---|
1172 | // if((pByte=_wp_AllocMem(somSelf, sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2), &ulSize))==NULLHANDLE)
|
---|
1173 | if((pByte=malloc(sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2)))==NULLHANDLE)
|
---|
1174 | break;
|
---|
1175 |
|
---|
1176 | bGotHeader=getBmpInfoHeader( (PBITMAPINFOHEADER2) pByte, chrName, _chrIOProcName,
|
---|
1177 | sizeof(_chrIOProcName), &_bNoIOProcAvailable);
|
---|
1178 | break;
|
---|
1179 | }
|
---|
1180 | }
|
---|
1181 | CATCH(GET_BMPIH)
|
---|
1182 | {
|
---|
1183 | #if 0
|
---|
1184 | if(MBID_YES==showMsgBoxFlag(IDSTR_CWIMAGETITLE, IDSTR_IMGIOPROCCRASH, queryModuleHandle(),
|
---|
1185 | MB_YESNO | MB_MOVEABLE | MB_WARNING))
|
---|
1186 | exit(0);
|
---|
1187 | #endif
|
---|
1188 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling getBmpInfoHeader().\n",
|
---|
1189 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1190 | SysWriteToTrapLog("Image file: %s\n\n",
|
---|
1191 | chrName);
|
---|
1192 | } END_CATCH;
|
---|
1193 |
|
---|
1194 | #if 0
|
---|
1195 | if(bSem) {
|
---|
1196 | //DosBeep(5000, 50);
|
---|
1197 | _wpReleaseObjectMutexSem(somSelf);
|
---|
1198 | }
|
---|
1199 | #endif
|
---|
1200 |
|
---|
1201 | #ifdef DEBUG
|
---|
1202 | if(bGotHeader)
|
---|
1203 | SysWriteToTrapLog("%s Got header...\n", __FUNCTION__);
|
---|
1204 | else
|
---|
1205 | SysWriteToTrapLog("Error with header...\n");
|
---|
1206 | #endif
|
---|
1207 |
|
---|
1208 | if(!bGotHeader) {
|
---|
1209 | if(pByte)
|
---|
1210 | free(pByte);
|
---|
1211 | // _wp_FreeMem(somSelf, pByte);
|
---|
1212 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
1213 | _chrIOProcName[0]=0;
|
---|
1214 | return NULL;
|
---|
1215 | }
|
---|
1216 | _pBmpInfoHeader2=pByte;
|
---|
1217 | /* Update instance data */
|
---|
1218 | if(((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
1219 | _ulWidth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cx;
|
---|
1220 | _ulHeight=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cy;
|
---|
1221 | _ulDepth=((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cBitCount;
|
---|
1222 | }
|
---|
1223 | else {
|
---|
1224 | PBITMAPINFOHEADER pBmpInfoHdr=(PBITMAPINFOHEADER)_pBmpInfoHeader2;
|
---|
1225 | _ulWidth=pBmpInfoHdr->cx;
|
---|
1226 | _ulHeight=pBmpInfoHdr->cy;
|
---|
1227 | _ulDepth=pBmpInfoHdr->cBitCount;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | return (PBYTE) _pBmpInfoHeader2;
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | /*
|
---|
1234 | * The prototype for cwimg_wpQueryBitmapData was replaced by the following prototype:
|
---|
1235 | */
|
---|
1236 | SOM_Scope PBYTE SOMLINK cwimg_wpQueryBitmapData(MMImage *somSelf,
|
---|
1237 | ULONG* pulSize)
|
---|
1238 | {
|
---|
1239 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
1240 | MMImageMethodDebug("MMImage","cwimg_wpQueryBitmapData");
|
---|
1241 |
|
---|
1242 | NOT_IMPLEMENTED
|
---|
1243 |
|
---|
1244 | return (MMImage_parent_WPImageFile_wpQueryBitmapData(somSelf,
|
---|
1245 | pulSize));
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | /*
|
---|
1249 | * The prototype for cwimg_wpSetBitmapData was replaced by the following prototype:
|
---|
1250 | */
|
---|
1251 | SOM_Scope BOOL SOMLINK cwimg_wpSetBitmapData(MMImage *somSelf,
|
---|
1252 | PBYTE pBitmapData,
|
---|
1253 | ULONG ulSize)
|
---|
1254 | {
|
---|
1255 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
1256 | MMImageMethodDebug("MMImage","cwimg_wpSetBitmapData");
|
---|
1257 |
|
---|
1258 | NOT_IMPLEMENTED
|
---|
1259 |
|
---|
1260 | #if 0
|
---|
1261 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
1262 | "This function is not available. Please tell the author the steps causing this message box so the function may be implemented.",
|
---|
1263 | "cwimg_wpSetBitmapData",
|
---|
1264 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
|
---|
1265 | #endif
|
---|
1266 |
|
---|
1267 | return (MMImage_parent_WPImageFile_wpSetBitmapData(somSelf,
|
---|
1268 | pBitmapData,
|
---|
1269 | ulSize));
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | /*
|
---|
1273 | * The prototype for cwimg_wpReadImageFile was replaced by the following prototype:
|
---|
1274 | */
|
---|
1275 | SOM_Scope BOOL SOMLINK cwimg_wpReadImageFile(MMImage *somSelf)
|
---|
1276 | {
|
---|
1277 | char chrName[CCHMAXPATH];
|
---|
1278 | ULONG ulSize;
|
---|
1279 | BOOL bGotHeader=FALSE;
|
---|
1280 |
|
---|
1281 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1282 | MMImageMethodDebug("MMImage","cwimg_wpReadImageFile");
|
---|
1283 |
|
---|
1284 | if(!_wpIsObjectInitialized(somSelf))
|
---|
1285 | return NULLHANDLE;
|
---|
1286 |
|
---|
1287 | if(_hBitmap)
|
---|
1288 | return TRUE;
|
---|
1289 |
|
---|
1290 | ulSize=sizeof(chrName);
|
---|
1291 | if(!_wpQueryRealName(somSelf, chrName, &ulSize,TRUE))
|
---|
1292 | return FALSE;
|
---|
1293 |
|
---|
1294 | #ifdef DEBUG
|
---|
1295 | SysWriteToTrapLog("In _wpReadImageFile(), file: %s \n",
|
---|
1296 | chrName);
|
---|
1297 | #endif
|
---|
1298 |
|
---|
1299 | TRY_LOUD(LOAD_BMP) {
|
---|
1300 | if(_wpQueryBitmapInfoHeader(somSelf))
|
---|
1301 | bGotHeader=TRUE;
|
---|
1302 | }
|
---|
1303 | CATCH(LOAD_BMP)
|
---|
1304 | {
|
---|
1305 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d while calling _wpQueryBitmapInfoHeader().\n",
|
---|
1306 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1307 | SysWriteToTrapLog("Image file: %s\n",
|
---|
1308 | chrName);
|
---|
1309 | }END_CATCH;
|
---|
1310 |
|
---|
1311 | if(!bGotHeader)
|
---|
1312 | return FALSE;
|
---|
1313 | _hBitmap=NULLHANDLE;
|
---|
1314 |
|
---|
1315 | TRY_LOUD(LOAD_BMP2) {
|
---|
1316 | _hBitmap=loadBitmap ( chrName , (PBITMAPINFOHEADER2) _pBmpInfoHeader2);
|
---|
1317 | }
|
---|
1318 | CATCH(LOAD_BMP2)
|
---|
1319 | {
|
---|
1320 | SysWriteToTrapLog("\nTrap occured in %s (LOAD_BMP2), file %s, around line %d while calling _wpQueryBitmapInfoHeader()\nwith image file %s.\n",
|
---|
1321 | __FUNCTION__, __FILE__, __LINE__, chrName);
|
---|
1322 | SysWriteToTrapLog("Remembering file as invalid.\n");
|
---|
1323 | /*
|
---|
1324 | V0.2.8 CW 2004/11/01
|
---|
1325 |
|
---|
1326 | Mark file which caused a trap as invalid.
|
---|
1327 | */
|
---|
1328 | _bNoIOProcAvailable=TRUE;
|
---|
1329 | } END_CATCH;
|
---|
1330 |
|
---|
1331 | if(!_hBitmap) {
|
---|
1332 | return FALSE;
|
---|
1333 | }
|
---|
1334 |
|
---|
1335 | return TRUE;
|
---|
1336 | }
|
---|
1337 |
|
---|
1338 |
|
---|
1339 | SOM_Scope BOOL SOMLINK cwimg_wpWriteImageFile(MMImage *somSelf)
|
---|
1340 | {
|
---|
1341 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
1342 | MMImageMethodDebug("MMImage","cwimg_wpWriteImageFile");
|
---|
1343 |
|
---|
1344 | NOT_IMPLEMENTED
|
---|
1345 |
|
---|
1346 | #if 0
|
---|
1347 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
1348 | "This function is not available. Please tell the author the steps causing this message box so the function may be implemented.",
|
---|
1349 | "cwimg_wpWriteImageFile",
|
---|
1350 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
|
---|
1351 | #endif
|
---|
1352 |
|
---|
1353 | return (MMImage_parent_WPImageFile_wpWriteImageFile(somSelf));
|
---|
1354 | }
|
---|
1355 |
|
---|
1356 | /*
|
---|
1357 | * wpInitData: override; Not used. Default is instance var initializing to zero and that's what we need.
|
---|
1358 | */
|
---|
1359 |
|
---|
1360 |
|
---|
1361 | SOM_Scope void SOMLINK cwimg_wpUnInitData(MMImage *somSelf)
|
---|
1362 | {
|
---|
1363 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1364 | MMImageMethodDebug("MMImage","cwimg_wpUnInitData");
|
---|
1365 |
|
---|
1366 | if(_pBmpInfoHeader2) {
|
---|
1367 | free(_pBmpInfoHeader2);
|
---|
1368 | // _wp_FreeMem(somSelf, _pBmpInfoHeader2);
|
---|
1369 | _pBmpInfoHeader2=NULLHANDLE;
|
---|
1370 | }
|
---|
1371 | /* This frees all bitmaps. Small for icons and the normal size one */
|
---|
1372 | _cwmmFreeBitmaps(somSelf);
|
---|
1373 | MMImage_parent_WPImageFile_wpUnInitData(somSelf);
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | /*
|
---|
1377 | FIXME:
|
---|
1378 |
|
---|
1379 | This function isn't thread safe because of one global memory area. It is supposed to be
|
---|
1380 | called from the wpPopupMenu() method. This method can only be called once at
|
---|
1381 | a time, so that's not a problem. It may become a problem if this function is also
|
---|
1382 | called from somewhere else. The global mem pointer is used by the image class and the
|
---|
1383 | audio class.
|
---|
1384 | */
|
---|
1385 | BOOL insertIOProcMenuItems( HWND hwndMenu )
|
---|
1386 | {
|
---|
1387 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
---|
1388 | MMFORMATINFO mmFormatInfo;
|
---|
1389 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
1390 | ULONG ulReturnCode;
|
---|
1391 | LONG lFormatsRead;
|
---|
1392 | LONG index;
|
---|
1393 | LONG lBytesRead;
|
---|
1394 | HWND hwndSubMenu;
|
---|
1395 | MENUITEM mi;
|
---|
1396 |
|
---|
1397 | if(g_pmmFormatInfoArray)
|
---|
1398 | free(g_pmmFormatInfoArray);
|
---|
1399 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
1400 |
|
---|
1401 | memset( &mmFormatInfo,
|
---|
1402 | '\0',
|
---|
1403 | sizeof(MMFORMATINFO) );
|
---|
1404 |
|
---|
1405 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
1406 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
|
---|
1407 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
1408 | &lNumIOProcs,
|
---|
1409 | 0,
|
---|
1410 | 0 );
|
---|
1411 |
|
---|
1412 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1413 | {
|
---|
1414 | /* Error - mmioQueryFormatCount failed. */
|
---|
1415 | return FALSE;
|
---|
1416 | }
|
---|
1417 |
|
---|
1418 | /*
|
---|
1419 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
1420 | */
|
---|
1421 | g_pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
1422 | if( g_pmmFormatInfoArray == NULL )
|
---|
1423 | {
|
---|
1424 | /* Could not allocate enough memory for mmFormatInfo array. */
|
---|
1425 | return FALSE;
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | /*
|
---|
1429 | * call mmioGetFormats to get info on the formats supported.
|
---|
1430 | */
|
---|
1431 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
1432 | lNumIOProcs,
|
---|
1433 | g_pmmFormatInfoArray,
|
---|
1434 | &lFormatsRead,
|
---|
1435 | 0,
|
---|
1436 | 0 );
|
---|
1437 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1438 | {
|
---|
1439 | /*
|
---|
1440 | * mmioGetFormats failed.
|
---|
1441 | */
|
---|
1442 | free(g_pmmFormatInfoArray);
|
---|
1443 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
1444 | return FALSE;
|
---|
1445 | }
|
---|
1446 |
|
---|
1447 | if( lFormatsRead != lNumIOProcs )
|
---|
1448 | {
|
---|
1449 | /*
|
---|
1450 | * Error in MMIO - number of formats read in by
|
---|
1451 | * mmioGetFormats is not equal to number of formats
|
---|
1452 | * found by mmioQueryFormatCount.
|
---|
1453 | */
|
---|
1454 | free(g_pmmFormatInfoArray);
|
---|
1455 | g_pmmFormatInfoArray=NULLHANDLE;
|
---|
1456 | return FALSE;
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | // Create Empty Submenu //
|
---|
1460 | hwndSubMenu=WinCreateWindow(hwndMenu,WC_MENU,"",0,
|
---|
1461 | 0,0,0,0,
|
---|
1462 | hwndMenu,//Owner. If set, this window
|
---|
1463 | //is destroyed if owner is destroyed
|
---|
1464 | HWND_TOP,
|
---|
1465 | ID_MENU_CONVERT,//menuid
|
---|
1466 | NULL,NULL);
|
---|
1467 |
|
---|
1468 | mi.iPosition=MIT_END;
|
---|
1469 | mi.afStyle=MIS_TEXT;//|MIS_SUBMENU;
|
---|
1470 | mi.id=ID_MENU_CONVERT;
|
---|
1471 | mi.afAttribute=NULLHANDLE;
|
---|
1472 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
---|
1473 | mi.hItem=NULLHANDLE;
|
---|
1474 | mi.hwndSubMenu=hwndSubMenu;
|
---|
1475 |
|
---|
1476 | if(!getMessage(szBuffer, IDSTR_MENU_CONVERT, sizeof(szBuffer), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1477 | sprintf(szBuffer,"~Convert to");
|
---|
1478 | WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&mi,
|
---|
1479 | (MPARAM)szBuffer);
|
---|
1480 |
|
---|
1481 | pmmFormatInfoArray=g_pmmFormatInfoArray;
|
---|
1482 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
1483 | {
|
---|
1484 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
---|
1485 |
|
---|
1486 | /* Insert NULL string terminator */
|
---|
1487 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
---|
1488 |
|
---|
1489 | /* Compressed TIF is not supported because the Warp 4 IO-Procs are
|
---|
1490 | broken. */
|
---|
1491 | // HlpWriteToTrapLog("--------- IO-Proc: %s, Name: %s\n", pmmFormatInfoArray->szDefaultFormatExt,
|
---|
1492 | // szBuffer);
|
---|
1493 |
|
---|
1494 | if(pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFMC",MMIO_TOUPPER) &&
|
---|
1495 | pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFIC",MMIO_TOUPPER) &&
|
---|
1496 | (pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED))
|
---|
1497 | {
|
---|
1498 | /* Add menu item */
|
---|
1499 | /* Fill the MENUITEM structure */
|
---|
1500 | mi.iPosition=MIT_END;
|
---|
1501 | mi.afStyle=MIS_TEXT|MIS_SUBMENU;
|
---|
1502 | mi.id=ID_ITEM_FIRSTCONVERT+index;/* Create menu id */
|
---|
1503 | mi.afAttribute=NULLHANDLE;
|
---|
1504 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
---|
1505 | mi.hItem=NULLHANDLE;
|
---|
1506 | WinSendMsg(hwndSubMenu, MM_INSERTITEM,(MPARAM)&mi,
|
---|
1507 | (MPARAM)szBuffer);
|
---|
1508 | }
|
---|
1509 | /*
|
---|
1510 | * advance to next entry in mmFormatInfo array
|
---|
1511 | */
|
---|
1512 | pmmFormatInfoArray++;
|
---|
1513 | }
|
---|
1514 | return TRUE;
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 |
|
---|
1518 |
|
---|
1519 | /*
|
---|
1520 | * wpInitData: override; Not used. Default is instance var initializing to zero and that's what we need.
|
---|
1521 | */
|
---|
1522 |
|
---|
1523 | SOM_Scope ULONG SOMLINK cwimg_wpQueryDefaultView(MMImage *somSelf)
|
---|
1524 | {
|
---|
1525 | ULONG ulReturn;
|
---|
1526 |
|
---|
1527 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1528 | MMImageMethodDebug("MMImage","cwimg_wpQueryDefaultView");
|
---|
1529 |
|
---|
1530 | ulReturn=(MMImage_parent_WPImageFile_wpQueryDefaultView(somSelf));
|
---|
1531 |
|
---|
1532 | if(ulReturn==OPEN_RUNNING)
|
---|
1533 | {
|
---|
1534 | ULONG ulHowMatched=1;
|
---|
1535 | char chrID[100];
|
---|
1536 | /* Check if associated program is still available */
|
---|
1537 | if(!_wpQueryAssociatedProgram(somSelf, OPEN_RUNNING, &ulHowMatched,
|
---|
1538 | chrID, sizeof(chrID),(PSZ)-1))
|
---|
1539 | return ID_MENU_IMGEDITOR; /* The associated progarm is lost */
|
---|
1540 | }
|
---|
1541 | return ulReturn;
|
---|
1542 | }
|
---|
1543 |
|
---|
1544 | /*
|
---|
1545 | * The prototype for cwimg_wpModifyPopupMenu was replaced by the following prototype:
|
---|
1546 | */
|
---|
1547 | SOM_Scope BOOL SOMLINK cwimg_wpModifyPopupMenu(MMImage *somSelf,
|
---|
1548 | HWND hwndMenu,
|
---|
1549 | HWND hwndCnr,
|
---|
1550 | ULONG iPosition)
|
---|
1551 | {
|
---|
1552 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1553 | MMImageMethodDebug("MMImage","cwimg_wpModifyPopupMenu");
|
---|
1554 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_IMGEDITOR, 1);
|
---|
1555 |
|
---|
1556 | TRY_LOUD(IMAGE_INSERTPOPUPMENU) {
|
---|
1557 | /* Insert image info */
|
---|
1558 | if(_ulWidth!=0 && _ulHeight!=0 && _ulDepth!=0)
|
---|
1559 | {
|
---|
1560 | char text[120];
|
---|
1561 | char menuText[200];
|
---|
1562 | MENUITEM menuItem;
|
---|
1563 |
|
---|
1564 | if(!getMessage(text, IDSTR_MENU_IMAGEINFO, sizeof(text), queryResModuleHandle(), hwndMenu))
|
---|
1565 | strcpy(text, "Image information: %d x %d x %d");
|
---|
1566 |
|
---|
1567 | sprintf(menuText, text, _ulWidth, _ulHeight, _ulDepth);//create menuitem
|
---|
1568 |
|
---|
1569 | //insert size menuitem in popupmenu
|
---|
1570 |
|
---|
1571 | menuItem.iPosition=MIT_END;
|
---|
1572 | menuItem.afStyle=MIS_TEXT|MIS_STATIC;
|
---|
1573 | menuItem.afAttribute=0;
|
---|
1574 | menuItem.id=ID_MENU_IMAGEINFO;
|
---|
1575 | menuItem.hwndSubMenu=NULLHANDLE;
|
---|
1576 | menuItem.hItem=0;
|
---|
1577 | WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&menuItem,(MPARAM)&menuText);
|
---|
1578 | }
|
---|
1579 | /* Insert all known image I/O procs */
|
---|
1580 | insertIOProcMenuItems( hwndMenu );
|
---|
1581 | menuInsertMenuSeparator(hwndMenu, NULLHANDLE, MIT_END );
|
---|
1582 |
|
---|
1583 | }/* TRY_LOUD */
|
---|
1584 | CATCH(IMAGE_INSERTPOPUPMENU)
|
---|
1585 | {
|
---|
1586 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
---|
1587 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1588 | } END_CATCH;
|
---|
1589 |
|
---|
1590 | return (MMImage_parent_WPImageFile_wpModifyPopupMenu(somSelf,
|
---|
1591 | hwndMenu,
|
---|
1592 | hwndCnr,
|
---|
1593 | iPosition));
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 |
|
---|
1597 | /*
|
---|
1598 | * The prototype for cwimg_wpMenuItemSelected was replaced by the following prototype:
|
---|
1599 | */
|
---|
1600 | SOM_Scope BOOL SOMLINK cwimg_wpMenuItemSelected(MMImage *somSelf,
|
---|
1601 | HWND hwndFrame,
|
---|
1602 | ULONG ulMenuId)
|
---|
1603 | {
|
---|
1604 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1605 | MMImageMethodDebug("MMImage","cwimg_wpMenuItemSelected");
|
---|
1606 |
|
---|
1607 | if(ulMenuId>=ID_ITEM_FIRSTCONVERT && ulMenuId<=ID_ITEM_FIRSTCONVERT+lNumIOProcs-1)
|
---|
1608 | {
|
---|
1609 | char chrEditor[CCHMAXPATH]={0};
|
---|
1610 | char chrParams[2*CCHMAXPATH]="\"";
|
---|
1611 | char *chrPtr=chrParams;
|
---|
1612 | ULONG ulSize;
|
---|
1613 | ULONG ulRc;
|
---|
1614 |
|
---|
1615 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageconverter", "", chrEditor,
|
---|
1616 | sizeof(chrEditor));
|
---|
1617 | chrPtr++;
|
---|
1618 | ulSize=sizeof(chrParams);
|
---|
1619 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
---|
1620 | strcat(chrPtr,"\" \"");
|
---|
1621 | chrPtr=strrchr(chrPtr, 0);
|
---|
1622 | mmioGetFormatName(&g_pmmFormatInfoArray[ulMenuId-ID_ITEM_FIRSTCONVERT], chrPtr,(LONG*) &ulSize, 0L, 0L);
|
---|
1623 | *( chrPtr + ulSize ) = (CHAR)NULL;
|
---|
1624 | strcat(chrPtr,"\"");
|
---|
1625 |
|
---|
1626 | if((ulRc=launchPMProg("", chrEditor, chrParams, somSelf, ulMenuId-ID_ITEM_FIRSTCONVERT))==NULLHANDLE) {
|
---|
1627 | /* Error */
|
---|
1628 | return TRUE;
|
---|
1629 | }
|
---|
1630 | return TRUE;
|
---|
1631 | }
|
---|
1632 |
|
---|
1633 | switch(ulMenuId)
|
---|
1634 | {
|
---|
1635 | case ID_MENU_IMGEDITOR:
|
---|
1636 | _wpViewObject(somSelf, NULLHANDLE, ulMenuId, 0);
|
---|
1637 | return TRUE;
|
---|
1638 | default:
|
---|
1639 | break;
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | return (MMImage_parent_WPImageFile_wpMenuItemSelected(somSelf,
|
---|
1643 | hwndFrame,
|
---|
1644 | ulMenuId));
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | /*
|
---|
1648 | * The prototype for cwimg_wpOpen was replaced by the following prototype:
|
---|
1649 | */
|
---|
1650 | SOM_Scope HWND SOMLINK cwimg_wpOpen(MMImage *somSelf, HWND hwndCnr,
|
---|
1651 | ULONG ulView, ULONG param)
|
---|
1652 | {
|
---|
1653 | /* CWImageData *somThis = CWImageGetData(somSelf); */
|
---|
1654 | MMImageMethodDebug("MMImage","cwimg_wpOpen");
|
---|
1655 |
|
---|
1656 | switch(ulView)
|
---|
1657 | {
|
---|
1658 | case ID_MENU_IMGEDITOR:
|
---|
1659 | /*case 0xbc2b: editor */
|
---|
1660 | {
|
---|
1661 | char chrEditor[CCHMAXPATH]={0};
|
---|
1662 | char chrParams[CCHMAXPATH+2]="\"";
|
---|
1663 | char chrTitle[50];
|
---|
1664 | char *chrPtr=chrParams;
|
---|
1665 | ULONG ulSize;
|
---|
1666 | ULONG ulRc;
|
---|
1667 |
|
---|
1668 | // PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageeditor", "ib.exe", chrEditor,
|
---|
1669 | // sizeof(chrEditor)); /* Default is ib.exe */
|
---|
1670 | if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "imageeditor", NULLHANDLE, chrEditor,
|
---|
1671 | sizeof(chrEditor)))
|
---|
1672 | /* No user setting. Use default ib.exe copied by the installation program to another location. IF this setting is missing
|
---|
1673 | try the app from the path. */
|
---|
1674 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "ib", "ib.exe", chrEditor,
|
---|
1675 | sizeof(chrEditor));
|
---|
1676 |
|
---|
1677 |
|
---|
1678 | chrPtr++;
|
---|
1679 | ulSize=sizeof(chrParams)-2;
|
---|
1680 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
---|
1681 | strcat(chrPtr,"\"");
|
---|
1682 | if(!getMessage(chrTitle, IDSTR_IMGEDITORTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
---|
1683 | strcpy(chrTitle, "Editor");
|
---|
1684 |
|
---|
1685 | if((ulRc=launchPMProg( chrTitle, chrEditor, chrParams, somSelf, ulView))==NULLHANDLE) {
|
---|
1686 | return NULLHANDLE;
|
---|
1687 | }
|
---|
1688 | return NULLHANDLE;
|
---|
1689 | }
|
---|
1690 | default:
|
---|
1691 | break;
|
---|
1692 | }
|
---|
1693 |
|
---|
1694 | return (MMImage_parent_WPImageFile_wpOpen(somSelf, hwndCnr,
|
---|
1695 | ulView, param));
|
---|
1696 | }
|
---|
1697 |
|
---|
1698 |
|
---|
1699 | /*
|
---|
1700 | * The prototype for cwimg_wpAddSettingsPages was replaced by the following prototype:
|
---|
1701 | */
|
---|
1702 | SOM_Scope BOOL SOMLINK cwimg_wpAddSettingsPages(MMImage *somSelf,
|
---|
1703 | HWND hwndNotebook)
|
---|
1704 | {
|
---|
1705 | BOOL rc;
|
---|
1706 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1707 | MMImageMethodDebug("MMImage","cwimg_wpAddSettingsPages");
|
---|
1708 |
|
---|
1709 | rc=(MMImage_parent_WPImageFile_wpAddSettingsPages(somSelf,
|
---|
1710 | hwndNotebook));
|
---|
1711 | return rc | (_cwmmAddImageInformationPage(somSelf, hwndNotebook));
|
---|
1712 | }
|
---|
1713 |
|
---|
1714 |
|
---|
1715 | /*
|
---|
1716 | * The prototype for cwimg_wpQueryDetailsData was replaced by the following prototype:
|
---|
1717 | */
|
---|
1718 | SOM_Scope ULONG SOMLINK cwimg_wpQueryDetailsData(MMImage *somSelf,
|
---|
1719 | PVOID* ppDetailsData,
|
---|
1720 | PULONG pcp)
|
---|
1721 | {
|
---|
1722 | BOOL rcParent;
|
---|
1723 | PIMAGEDETAILS pImageDetails;
|
---|
1724 |
|
---|
1725 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1726 | MMImageMethodDebug("MMImage","cwimg_wpQueryDetailsData");
|
---|
1727 |
|
---|
1728 | /* Fill parent info */
|
---|
1729 | rcParent=(MMImage_parent_WPImageFile_wpQueryDetailsData(somSelf,
|
---|
1730 | ppDetailsData,
|
---|
1731 | pcp));
|
---|
1732 |
|
---|
1733 | /* The WPS asks for data to be displayed */
|
---|
1734 | if(ppDetailsData)
|
---|
1735 | {
|
---|
1736 | ULONG ulWidth, ulHeight, ulDepth;
|
---|
1737 |
|
---|
1738 | PBITMAPINFOHEADER2 pBmpInfoHeader2=NULLHANDLE;
|
---|
1739 |
|
---|
1740 | #if 0
|
---|
1741 | if(_bUseNewClsFeatures) /* Read info from CD only if allowed. The check if the object
|
---|
1742 | is on CD is done in wpRestore() */
|
---|
1743 | pBmpInfoHeader2=(PBITMAPINFOHEADER2) _wpQueryBitmapInfoHeader(somSelf);
|
---|
1744 | #endif
|
---|
1745 |
|
---|
1746 | pBmpInfoHeader2=(PBITMAPINFOHEADER2)_pBmpInfoHeader2;
|
---|
1747 |
|
---|
1748 | if(pBmpInfoHeader2) {
|
---|
1749 | //DosBeep(1500,200);
|
---|
1750 | if(pBmpInfoHeader2->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
1751 | ulWidth=pBmpInfoHeader2->cx;
|
---|
1752 | ulHeight=pBmpInfoHeader2->cy;
|
---|
1753 | ulDepth=pBmpInfoHeader2->cBitCount;
|
---|
1754 | }
|
---|
1755 | else {
|
---|
1756 | PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)pBmpInfoHeader2;
|
---|
1757 | ulWidth=pBmpInfoHeader->cx;
|
---|
1758 | ulHeight=pBmpInfoHeader->cy;
|
---|
1759 | ulDepth=pBmpInfoHeader->cBitCount;
|
---|
1760 | }
|
---|
1761 | }
|
---|
1762 | else
|
---|
1763 | {
|
---|
1764 | ulWidth=_ulWidth;
|
---|
1765 | ulHeight=_ulHeight;
|
---|
1766 | ulDepth=_ulDepth;
|
---|
1767 | }
|
---|
1768 | /* Fill the structure with the info to be displayed */
|
---|
1769 | pImageDetails=(PIMAGEDETAILS)*ppDetailsData;
|
---|
1770 | pImageDetails->ulWidth=ulWidth;
|
---|
1771 | pImageDetails->ulHeight=ulHeight;
|
---|
1772 | pImageDetails->ulDepth=ulDepth;
|
---|
1773 | pImageDetails->pszFormat=_chrIOProcName;
|
---|
1774 |
|
---|
1775 | *ppDetailsData=((PBYTE) (*ppDetailsData))+sizeof(*pImageDetails);
|
---|
1776 | }
|
---|
1777 | else
|
---|
1778 | {
|
---|
1779 | /* Buffer size is queried */
|
---|
1780 | if(pcp)
|
---|
1781 | *pcp+=sizeof(*pImageDetails);
|
---|
1782 | }
|
---|
1783 | return rcParent;
|
---|
1784 | }
|
---|
1785 |
|
---|
1786 | /*
|
---|
1787 | * The prototype for cwimg_wpRestoreState was replaced by the following prototype:
|
---|
1788 | */
|
---|
1789 | SOM_Scope BOOL SOMLINK cwimg_wpRestoreState(MMImage *somSelf,
|
---|
1790 | ULONG ulReserved)
|
---|
1791 | {
|
---|
1792 | BOOL bReRead=FALSE;
|
---|
1793 |
|
---|
1794 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1795 | MMImageMethodDebug("MMImage","cwimg_wpRestoreState");
|
---|
1796 |
|
---|
1797 | _bUseNewClsFeatures=TRUE;
|
---|
1798 |
|
---|
1799 | if(cwObjectIsOnCD(somSelf)) {
|
---|
1800 | /* The object is on CD. Check if we should use the new class features */
|
---|
1801 | if(!PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", IMAGECLS_FEATURES_ON_CD_KEY, 0))
|
---|
1802 | _bUseNewClsFeatures=FALSE;
|
---|
1803 | }
|
---|
1804 |
|
---|
1805 | /* Use cached image size so the values are shown in details view on first opening of a folder. The problem is that
|
---|
1806 | wpQueryDetailsData() is called before the object data is fully initialized. wpIsObjectInitialized() returns
|
---|
1807 | TRUE but wpQueryRealName() fails at that early stage so it's impossible to read the image data from the file (because
|
---|
1808 | the filename is unknown). Querying the image data in wpObjectReady() is to late because that method is called after
|
---|
1809 | wpQueryDetailsData(). In wpObjectReady the image header will be read in. */
|
---|
1810 |
|
---|
1811 | /* Query the image info */
|
---|
1812 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_FILESIZE, &_ulFileSize))
|
---|
1813 | bReRead=TRUE;
|
---|
1814 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_WIDTH, &_ulWidth))
|
---|
1815 | bReRead=TRUE;
|
---|
1816 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_HEIGHT, &_ulHeight))
|
---|
1817 | bReRead=TRUE;
|
---|
1818 | if(!_wpRestoreLong(somSelf, "CWImage", KEY_DEPTH, &_ulDepth))
|
---|
1819 | bReRead=TRUE;
|
---|
1820 | if(_ulWidth==0 || _ulHeight==0 || _ulDepth!=0)
|
---|
1821 | bReRead=TRUE;
|
---|
1822 | // if(_bUseNewClsFeatures) /* Read info from CD only if allowed. The check if the object
|
---|
1823 | // is on CD is done in wpRestore() */
|
---|
1824 | // _wpQueryBitmapInfoHeader(somSelf);
|
---|
1825 |
|
---|
1826 | return (MMImage_parent_WPImageFile_wpRestoreState(somSelf,
|
---|
1827 | ulReserved));
|
---|
1828 | }
|
---|
1829 |
|
---|
1830 | void mmRefreshRecords(MMImage *somSelf)
|
---|
1831 | {
|
---|
1832 | PUSEITEM pUse;
|
---|
1833 |
|
---|
1834 | for(pUse=_wpFindUseItem(somSelf, USAGE_RECORD/*VIEW_CONTENTS|VIEW_DETAILS|VIEW_TREE*/, NULL );pUse;
|
---|
1835 | pUse=_wpFindUseItem(somSelf, USAGE_RECORD/* VIEW_CONTENTS|VIEW_DETAILS|VIEW_TREE*/, pUse ))
|
---|
1836 | {
|
---|
1837 | PRECORDITEM pRecordItem=(PRECORDITEM)++pUse;
|
---|
1838 | WinPostMsg(pRecordItem->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pRecordItem->pRecord),
|
---|
1839 | MPFROM2SHORT(1,CMA_NOREPOSITION));
|
---|
1840 | }/* for() */
|
---|
1841 | }
|
---|
1842 |
|
---|
1843 | SOM_Scope BOOL SOMLINK cwimg_wpSetup(MMImage *somSelf, PSZ pszSetupString)
|
---|
1844 | {
|
---|
1845 | char buffer[CCHMAXPATH];
|
---|
1846 | ULONG bufferSize;
|
---|
1847 |
|
---|
1848 | /* MMImageData *somThis = MMImageGetData(somSelf);*/
|
---|
1849 | MMImageMethodDebug("MMImage","cwimg_wpSetup");
|
---|
1850 |
|
---|
1851 |
|
---|
1852 | /* Refresh */
|
---|
1853 | bufferSize=sizeof(buffer);
|
---|
1854 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMREFRESH, buffer,&bufferSize))
|
---|
1855 | {
|
---|
1856 | _cwmmFreeBitmaps(somSelf);
|
---|
1857 | #if 0
|
---|
1858 | _cwmmQuerySmallBitmapHandle(somSelf,
|
---|
1859 | 0,
|
---|
1860 | NULLHANDLE,
|
---|
1861 | 0);
|
---|
1862 | #endif
|
---|
1863 | mmRefreshRecords(somSelf);
|
---|
1864 | // _wpCnrRefreshDetails(somSelf);
|
---|
1865 | }
|
---|
1866 |
|
---|
1867 | return (MMImage_parent_WPImageFile_wpSetup(somSelf, pszSetupString));
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 |
|
---|
1871 | SOM_Scope void SOMLINK cwimg_wpObjectReady(MMImage *somSelf,
|
---|
1872 | ULONG ulCode, WPObject* refObject)
|
---|
1873 | {
|
---|
1874 | PCREATEBMPINFO pCreateBMP;
|
---|
1875 | ULONG ulError;
|
---|
1876 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
1877 | MMImageMethodDebug("MMImage","cwimg_wpObjectReady");
|
---|
1878 |
|
---|
1879 | MMImage_parent_WPImageFile_wpObjectReady(somSelf, ulCode,
|
---|
1880 | refObject);
|
---|
1881 | /* Get image info asynchronous to replace cached image size read in from EA which
|
---|
1882 | may not be accurate. */
|
---|
1883 | /* Allocate memory for small bitmap info for the thread */
|
---|
1884 | #if 0
|
---|
1885 | if(hwndCreateBMP && (pCreateBMP=(PCREATEBMPINFO)_wpAllocMem(somSelf, sizeof(CREATEBMPINFO),&ulError))!=NULLHANDLE)
|
---|
1886 | {
|
---|
1887 | /* Only the object pointer is used */
|
---|
1888 | pCreateBMP->wpObject=somSelf;
|
---|
1889 |
|
---|
1890 | // WinPostMsg(hwndCreateBMP, WM_APPTERMINATENOTIFY,MPFROMP(pCreateBMP), MPFROM2SHORT(0, ACKEY_QUERY_BITMAPINFO));
|
---|
1891 | }
|
---|
1892 | #endif
|
---|
1893 | /* Refresh records in all views */
|
---|
1894 | //mmRefreshRecords(somSelf);
|
---|
1895 |
|
---|
1896 | }
|
---|
1897 |
|
---|
1898 | static BOOL _getMissingExtFromImageIOProc(void)
|
---|
1899 | {
|
---|
1900 | MMFORMATINFO mmFormatInfo;
|
---|
1901 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
1902 | void * memPtr;
|
---|
1903 | ULONG ulReturnCode;
|
---|
1904 | LONG lFormatsRead;
|
---|
1905 | LONG index;
|
---|
1906 |
|
---|
1907 | memset( &mmFormatInfo,
|
---|
1908 | '\0',
|
---|
1909 | sizeof(MMFORMATINFO) );
|
---|
1910 |
|
---|
1911 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
1912 | mmFormatInfo.ulFlags|=MMIO_CANREADTRANSLATED;/* Read !!!*/
|
---|
1913 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
1914 | &lNumIOProcs,
|
---|
1915 | 0,
|
---|
1916 | 0 );
|
---|
1917 |
|
---|
1918 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1919 | {
|
---|
1920 | /*
|
---|
1921 | * Error - mmioQueryFormatCount failed.
|
---|
1922 | */
|
---|
1923 | return FALSE;
|
---|
1924 | }
|
---|
1925 |
|
---|
1926 | /*
|
---|
1927 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
1928 | */
|
---|
1929 | pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
1930 | memPtr=pmmFormatInfoArray;
|
---|
1931 | if( pmmFormatInfoArray == NULL )
|
---|
1932 | {
|
---|
1933 | /*
|
---|
1934 | * Could not allocate enough memory for mmFormatInfo array.
|
---|
1935 | */
|
---|
1936 | return FALSE;
|
---|
1937 | }
|
---|
1938 |
|
---|
1939 | /*
|
---|
1940 | * call mmioGetFormats to get info on the formats supported.
|
---|
1941 | */
|
---|
1942 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
1943 | lNumIOProcs,
|
---|
1944 | pmmFormatInfoArray,
|
---|
1945 | &lFormatsRead,
|
---|
1946 | 0,
|
---|
1947 | 0 );
|
---|
1948 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
1949 | {
|
---|
1950 | /*
|
---|
1951 | * mmioGetFormats failed.
|
---|
1952 | */
|
---|
1953 | free(pmmFormatInfoArray);
|
---|
1954 | return FALSE;
|
---|
1955 | }
|
---|
1956 |
|
---|
1957 | if( lFormatsRead != lNumIOProcs )
|
---|
1958 | {
|
---|
1959 | /*
|
---|
1960 | * Error in MMIO - number of formats read in by
|
---|
1961 | * mmioGetFormats is not equal to number of formats
|
---|
1962 | * found by mmioQueryFormatCount.
|
---|
1963 | */
|
---|
1964 | free(pmmFormatInfoArray);
|
---|
1965 | return FALSE;
|
---|
1966 | }
|
---|
1967 |
|
---|
1968 |
|
---|
1969 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
1970 | {
|
---|
1971 | /* Now scan the whole image proc array */
|
---|
1972 |
|
---|
1973 | if(!strstr(chrMMImageKnownExt, pmmFormatInfoArray->szDefaultFormatExt)) {
|
---|
1974 | /* This extension is yet unknown */
|
---|
1975 | if(chrMMImageExt[0]==0) {
|
---|
1976 | sprintf(chrMMImageExt,"*.%s", pmmFormatInfoArray->szDefaultFormatExt);
|
---|
1977 | // fFirstExt=FALSE;
|
---|
1978 | }
|
---|
1979 | else {
|
---|
1980 | strncat(chrMMImageExt,",*.",sizeof(chrMMImageExt)-1-strlen(chrMMImageExt));
|
---|
1981 | strncat(chrMMImageExt, pmmFormatInfoArray->szDefaultFormatExt, sizeof(chrMMImageExt)-1-strlen(chrMMImageExt));
|
---|
1982 | }
|
---|
1983 | // HlpWriteToTrapLog("Known Extension: %s\n", chrMMImageKnownExt);
|
---|
1984 | // HlpWriteToTrapLog("Extension: %s\n", chrMMImageExt);
|
---|
1985 | }
|
---|
1986 | /*
|
---|
1987 | * advance to next entry in mmFormatInfo array
|
---|
1988 | */
|
---|
1989 | pmmFormatInfoArray++;
|
---|
1990 | }
|
---|
1991 | free(memPtr);
|
---|
1992 |
|
---|
1993 | return FALSE;
|
---|
1994 | }
|
---|
1995 |
|
---|
1996 | /*
|
---|
1997 | * wpCnrRemoveObject : override;
|
---|
1998 | */
|
---|
1999 |
|
---|
2000 | /*
|
---|
2001 | * wpFormatDragItem : override;
|
---|
2002 | */
|
---|
2003 |
|
---|
2004 | SOM_Scope BOOL SOMLINK cwimg_wpSaveState(MMImage *somSelf)
|
---|
2005 | {
|
---|
2006 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
2007 | MMImageMethodDebug("MMImage","cwimg_wpSaveState");
|
---|
2008 |
|
---|
2009 | /* Cache the image size so the values are shown in details view on first opening of a folder. The problem is that
|
---|
2010 | wpQueryDetailsData() is called before the object data is fully initialized. wpIsObjectInitialized() returns
|
---|
2011 | TRUE but wpQueryRealName() fails at that early stage so it's impossible to read the image data from the file (because
|
---|
2012 | the filename is unknown). Querying the image data in wpObjectReady() is to late because this method is called after
|
---|
2013 | wpQueryDetailsData(). */
|
---|
2014 | if(_pBmpInfoHeader2) {
|
---|
2015 | if(((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cbFix==sizeof(BITMAPINFOHEADER2)) {
|
---|
2016 | _wpSaveLong(somSelf, "CWImage", KEY_WIDTH, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cx);
|
---|
2017 | _wpSaveLong(somSelf, "CWImage", KEY_HEIGHT, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cy);
|
---|
2018 | _wpSaveLong(somSelf, "CWImage", KEY_DEPTH, ((PBITMAPINFOHEADER2)_pBmpInfoHeader2)->cBitCount);
|
---|
2019 | }
|
---|
2020 | else {
|
---|
2021 | PBITMAPINFOHEADER pBmpInfoHeader=(PBITMAPINFOHEADER)_pBmpInfoHeader2;
|
---|
2022 |
|
---|
2023 | _wpSaveLong(somSelf, "CWImage", KEY_WIDTH, pBmpInfoHeader->cx);
|
---|
2024 | _wpSaveLong(somSelf, "CWImage", KEY_HEIGHT, pBmpInfoHeader->cy);
|
---|
2025 | _wpSaveLong(somSelf, "CWImage", KEY_DEPTH, pBmpInfoHeader->cBitCount);
|
---|
2026 | }
|
---|
2027 | }
|
---|
2028 | return (MMImage_parent_WPImageFile_wpSaveState(somSelf));
|
---|
2029 | }
|
---|
2030 |
|
---|
2031 | #if 0
|
---|
2032 | SOM_Scope BOOL SOMLINK cwimg_wpFormatDragItem(MMImage *somSelf,
|
---|
2033 | PDRAGITEM pdrgItem)
|
---|
2034 | {
|
---|
2035 | BOOL rc;
|
---|
2036 |
|
---|
2037 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
2038 | MMImageMethodDebug("MMImage","cwimg_wpFormatDragItem");
|
---|
2039 |
|
---|
2040 | rc= (MMImage_parent_WPImageFile_wpFormatDragItem(somSelf,
|
---|
2041 | pdrgItem));
|
---|
2042 | DosBeep(500,10);
|
---|
2043 | SysWriteToTrapLog("%d\n",pdrgItem->cxOffset);
|
---|
2044 | pdrgItem->cxOffset+=60;
|
---|
2045 | return rc;
|
---|
2046 | }
|
---|
2047 | #endif
|
---|
2048 |
|
---|
2049 | SOM_Scope BOOL SOMLINK cwimg_wpUnlockObject(MMImage *somSelf)
|
---|
2050 | {
|
---|
2051 | MMImageData *somThis = MMImageGetData(somSelf);
|
---|
2052 | MMImageMethodDebug("MMImage","cwimg_wpUnlockObject");
|
---|
2053 |
|
---|
2054 | /*
|
---|
2055 | Call a function which checks if the bitmaps of this object may be deleted in the background.
|
---|
2056 | The call is here because this method is called for every object in a folder whenever a folder
|
---|
2057 | is closed.
|
---|
2058 | If the folder is closed it's likely the bitmaps may be obsolete. A check for USAGE_RECORD items
|
---|
2059 | will be done on another thread.
|
---|
2060 |
|
---|
2061 | wpDeleteFromObjUseList() seems to be the more natural place to do this but the method is not called
|
---|
2062 | when an object is removed from a container. Also wpCnrRemoveObject() doesn't work because the WPS seems
|
---|
2063 | to use wpclsRemoveObjects() to remove all objects when closing folders.
|
---|
2064 |
|
---|
2065 | XWP (at least up to 1.02) keeps every object locked, so we can't just check the lock state by
|
---|
2066 | querying wpIsObjectLocked(). That's the reason we jump through loops here :-(.
|
---|
2067 |
|
---|
2068 | */
|
---|
2069 | if(_hBitmap || _hBitmapSmall)
|
---|
2070 | sendDeleteBMPMsg(somSelf);
|
---|
2071 |
|
---|
2072 | return (MMImage_parent_WPImageFile_wpUnlockObject(somSelf));
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 |
|
---|
2076 |
|
---|
2077 |
|
---|
2078 |
|
---|
2079 |
|
---|
2080 |
|
---|
2081 |
|
---|
2082 | /*
|
---|
2083 | * The prototype for cwimgM_wpclsInitData was replaced by the following prototype:
|
---|
2084 | */
|
---|
2085 | SOM_Scope void SOMLINK cwimgM_wpclsInitData(M_MMImage *somSelf)
|
---|
2086 | {
|
---|
2087 | PCLASSFIELDINFO pCfi;
|
---|
2088 | USHORT i;
|
---|
2089 | static BOOL bGotImgExt=FALSE;
|
---|
2090 |
|
---|
2091 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
2092 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsInitData");
|
---|
2093 |
|
---|
2094 | /* Get extensions of additional image procs not represented by a class.
|
---|
2095 | Strangely enough wpclsQueryInstanceFilter() is called during wpclsInitData() so
|
---|
2096 | we query the extensions here before calling the parent so we have the information. */
|
---|
2097 | if(!bGotImgExt)
|
---|
2098 | {
|
---|
2099 | /* Get user supplied extensions e.g. *.JPE*/
|
---|
2100 | getStringFromRexxScript("imageadd.rx", chrMMImageExt, sizeof(chrMMImageExt));
|
---|
2101 |
|
---|
2102 | /* Get all already handled extensions */
|
---|
2103 | getStringFromRexxScript("imageext.rx", chrMMImageKnownExt, sizeof(chrMMImageKnownExt));
|
---|
2104 | /* Now check installed IO procs for other exts and add them to the filter list */
|
---|
2105 | _getMissingExtFromImageIOProc();
|
---|
2106 | bGotImgExt=TRUE;
|
---|
2107 | }
|
---|
2108 |
|
---|
2109 | M_MMImage_parent_M_WPImageFile_wpclsInitData(somSelf);
|
---|
2110 |
|
---|
2111 | if(!globalHab)
|
---|
2112 | globalHab=WinQueryAnchorBlock(HWND_DESKTOP);
|
---|
2113 |
|
---|
2114 | if(!getMessage(chrHelpLibrary, IDSTR_HELPLIBRARY, sizeof(chrHelpLibrary),
|
---|
2115 | queryModuleHandle(), HWND_DESKTOP))
|
---|
2116 | strcpy(chrHelpLibrary,"MMPARTS.HLP");
|
---|
2117 |
|
---|
2118 | /* Load strings for details titles */
|
---|
2119 | if(getMessage(chrWidth, IDSTR_IMAGEDETAIL_WIDTH, sizeof(chrWidth), queryResModuleHandle(), HWND_DESKTOP))
|
---|
2120 | pszImageColTitles[0]=chrWidth;
|
---|
2121 | if(getMessage(chrHeight, IDSTR_IMAGEDETAIL_HEIGHT, sizeof(chrHeight), queryResModuleHandle(), HWND_DESKTOP))
|
---|
2122 | pszImageColTitles[1]=chrHeight;
|
---|
2123 | if(getMessage(chrDepth, IDSTR_IMAGEDETAIL_DEPTH, sizeof(chrDepth), queryResModuleHandle(), HWND_DESKTOP))
|
---|
2124 | pszImageColTitles[2]=chrDepth;
|
---|
2125 | if(getMessage(chrFormat, IDSTR_IMAGEDETAIL_FORMAT, sizeof(chrFormat), queryResModuleHandle(), HWND_DESKTOP))
|
---|
2126 | pszImageColTitles[3]=chrFormat;
|
---|
2127 |
|
---|
2128 | /* Setup the static data for the details view */
|
---|
2129 | for(i=0,pCfi=cfiImageFieldInfo;i<NUM_IMAGE_DETAILS_FIELDS;i++,pCfi++)
|
---|
2130 | {
|
---|
2131 | memset((PCH)pCfi,0,sizeof(CLASSFIELDINFO));
|
---|
2132 |
|
---|
2133 | pCfi->cb=sizeof(CLASSFIELDINFO);
|
---|
2134 | pCfi->flData=CFA_LEFT|CFA_SEPARATOR|CFA_FIREADONLY;
|
---|
2135 | pCfi->flTitle=CFA_CENTER|CFA_SEPARATOR|CFA_HORZSEPARATOR|CFA_STRING|CFA_FITITLEREADONLY;
|
---|
2136 | pCfi->pNextFieldInfo=pCfi+1;
|
---|
2137 | pCfi->pTitleData=(PVOID)pszImageColTitles[i];
|
---|
2138 | pCfi->flCompare=COMPARE_SUPPORTED|SORTBY_SUPPORTED;
|
---|
2139 |
|
---|
2140 | switch(i)
|
---|
2141 | {
|
---|
2142 | case 0: /* Width */
|
---|
2143 | pCfi->flData|=CFA_ULONG;
|
---|
2144 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS, ulWidth));
|
---|
2145 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
2146 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
2147 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
2148 | break;
|
---|
2149 | case 1: /* Height */
|
---|
2150 | pCfi->flData|=CFA_ULONG;
|
---|
2151 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulHeight));
|
---|
2152 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
2153 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
2154 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
2155 | break;
|
---|
2156 | case 2: /* Depth */
|
---|
2157 | pCfi->flData|=CFA_ULONG;
|
---|
2158 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,ulDepth));
|
---|
2159 | pCfi->ulLenFieldData=sizeof(ULONG);
|
---|
2160 | pCfi->ulLenCompareValue=sizeof(ULONG);
|
---|
2161 | pCfi->DefaultComparison=CMP_GREATER;
|
---|
2162 | break;
|
---|
2163 | case 3: /* Format */
|
---|
2164 | pCfi->flData|=CFA_STRING;
|
---|
2165 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(IMAGEDETAILS,pszFormat));
|
---|
2166 | pCfi->ulLenFieldData=sizeof(PSZ);
|
---|
2167 | pCfi->DefaultComparison=CMP_EQUAL;
|
---|
2168 | break;
|
---|
2169 | }/* switch(i) */
|
---|
2170 | }/* for() */
|
---|
2171 | cfiImageFieldInfo[NUM_IMAGE_DETAILS_FIELDS].pNextFieldInfo=NULL;
|
---|
2172 | if(!hwndCreateBMP)
|
---|
2173 | _beginthread(createBMPThreadFunc,NULL,8192*20, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
2174 |
|
---|
2175 | if(!g_hwndDeleteBMP)
|
---|
2176 | _beginthread(deleteBMPThreadFunc,NULL,8192*10, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
2177 |
|
---|
2178 | }
|
---|
2179 |
|
---|
2180 |
|
---|
2181 | /*
|
---|
2182 | * The prototype for cwimgM_wpclsQueryDefaultView was replaced by the following prototype:
|
---|
2183 | */
|
---|
2184 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryDefaultView(M_MMImage *somSelf)
|
---|
2185 | {
|
---|
2186 | #if 0
|
---|
2187 | char chrID[120];
|
---|
2188 | WPObject *wpObject;
|
---|
2189 | HOBJECT hObject;
|
---|
2190 | #endif
|
---|
2191 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
2192 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryDefaultView");
|
---|
2193 |
|
---|
2194 | // sprintf(chrID, "<MMPM2_MM%sTEMPLATE>", _wpclsQueryInstanceType(somSelf));
|
---|
2195 | //HlpWriteToTrapLog("%s\n", chrID);
|
---|
2196 | #if 0
|
---|
2197 | if((hObject=WinQueryObject(chrID))!=NULLHANDLE)
|
---|
2198 | DosBeep(5000, 500);
|
---|
2199 | // _wpclsQueryObject(somSelf, hObject);
|
---|
2200 | if((wpObject=_wpclsQueryObjectFromPath(somSelf, chrID))!=NULLHANDLE)
|
---|
2201 | {
|
---|
2202 | ULONG ulHowMatched=1;
|
---|
2203 |
|
---|
2204 | DosBeep(5000, 1000);
|
---|
2205 | /* Template found. Now query associated program */
|
---|
2206 | if(_wpQueryAssociatedProgram(wpObject, VIEW_RUNNING, &ulHowMatched,
|
---|
2207 | chrID, sizeof(chrID),(PSZ)-1))
|
---|
2208 | DosBeep(500, 1000);
|
---|
2209 | }
|
---|
2210 | #endif
|
---|
2211 | /* Create default templates. We do it here because we need an object to query the associated
|
---|
2212 | program (if any) when the system asks for the default view. */
|
---|
2213 | return OPEN_RUNNING;
|
---|
2214 | // return ID_MENU_IMGEDITOR;
|
---|
2215 | }
|
---|
2216 |
|
---|
2217 |
|
---|
2218 | BOOL checkImageIOProc(char * chrExt)
|
---|
2219 | {
|
---|
2220 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
---|
2221 | MMFORMATINFO mmFormatInfo;
|
---|
2222 | PMMFORMATINFO pmmFormatInfoArray;
|
---|
2223 | void * memPtr;
|
---|
2224 | ULONG ulReturnCode;
|
---|
2225 | LONG lFormatsRead;
|
---|
2226 | LONG index;
|
---|
2227 | LONG lBytesRead;
|
---|
2228 |
|
---|
2229 | memset( &mmFormatInfo,
|
---|
2230 | '\0',
|
---|
2231 | sizeof(MMFORMATINFO) );
|
---|
2232 |
|
---|
2233 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_IMAGE;
|
---|
2234 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
|
---|
2235 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
---|
2236 | &lNumIOProcs,
|
---|
2237 | 0,
|
---|
2238 | 0 );
|
---|
2239 |
|
---|
2240 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
2241 | {
|
---|
2242 | /*
|
---|
2243 | * Error - mmioQueryFormatCount failed.
|
---|
2244 | */
|
---|
2245 | return FALSE;
|
---|
2246 | }
|
---|
2247 |
|
---|
2248 | /*
|
---|
2249 | * Allocate enough memory for n number of FormatInfo blocks
|
---|
2250 | */
|
---|
2251 | pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
---|
2252 | memPtr=pmmFormatInfoArray;
|
---|
2253 | if( pmmFormatInfoArray == NULL )
|
---|
2254 | {
|
---|
2255 | /*
|
---|
2256 | * Could not allocate enough memory for mmFormatInfo array.
|
---|
2257 | */
|
---|
2258 | return FALSE;
|
---|
2259 | }
|
---|
2260 |
|
---|
2261 | /*
|
---|
2262 | * call mmioGetFormats to get info on the formats supported.
|
---|
2263 | */
|
---|
2264 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
---|
2265 | lNumIOProcs,
|
---|
2266 | pmmFormatInfoArray,
|
---|
2267 | &lFormatsRead,
|
---|
2268 | 0,
|
---|
2269 | 0 );
|
---|
2270 | if( ulReturnCode != MMIO_SUCCESS )
|
---|
2271 | {
|
---|
2272 | /*
|
---|
2273 | * mmioGetFormats failed.
|
---|
2274 | */
|
---|
2275 | free(pmmFormatInfoArray);
|
---|
2276 | return FALSE;
|
---|
2277 | }
|
---|
2278 |
|
---|
2279 | if( lFormatsRead != lNumIOProcs )
|
---|
2280 | {
|
---|
2281 | /*
|
---|
2282 | * Error in MMIO - number of formats read in by
|
---|
2283 | * mmioGetFormats is not equal to number of formats
|
---|
2284 | * found by mmioQueryFormatCount.
|
---|
2285 | */
|
---|
2286 | free(pmmFormatInfoArray);
|
---|
2287 | return FALSE;
|
---|
2288 | }
|
---|
2289 |
|
---|
2290 |
|
---|
2291 | for ( index = 0; index <lNumIOProcs; index++ )
|
---|
2292 | {
|
---|
2293 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
---|
2294 |
|
---|
2295 | /* Insert NULL string terminator */
|
---|
2296 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
---|
2297 |
|
---|
2298 | /* Compressed TIF is not supported because the Warp 4 IO-Procs are
|
---|
2299 | broken. */
|
---|
2300 | //HlpWriteToTrapLog("--------- Ext: %s, IO-Proc: %s, Name: %s\n",
|
---|
2301 | //chrExt, pmmFormatInfoArray->szDefaultFormatExt,
|
---|
2302 | // szBuffer);
|
---|
2303 |
|
---|
2304 | if(pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFMC",MMIO_TOUPPER) &&
|
---|
2305 | pmmFormatInfoArray->fccIOProc!=mmioStringToFOURCC("TFIC",MMIO_TOUPPER) &&
|
---|
2306 | (pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED))
|
---|
2307 | {
|
---|
2308 | if(strstr(chrExt, pmmFormatInfoArray->szDefaultFormatExt)) {
|
---|
2309 | //HlpWriteToTrapLog("******* Ext given: %s IO-Proc: %s\n", chrExt, pmmFormatInfoArray->szDefaultFormatExt);
|
---|
2310 | free(memPtr);
|
---|
2311 | return TRUE;
|
---|
2312 | }
|
---|
2313 | }
|
---|
2314 | /*
|
---|
2315 | * advance to next entry in mmFormatInfo array
|
---|
2316 | */
|
---|
2317 | pmmFormatInfoArray++;
|
---|
2318 | }
|
---|
2319 | free(memPtr);
|
---|
2320 |
|
---|
2321 | return FALSE;
|
---|
2322 | }
|
---|
2323 |
|
---|
2324 | SOM_Scope BOOL SOMLINK cwimgM_wpclsCreateDefaultTemplates(M_MMImage *somSelf,
|
---|
2325 | WPObject* Folder)
|
---|
2326 | {
|
---|
2327 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
2328 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsCreateDefaultTemplates");
|
---|
2329 |
|
---|
2330 | //HlpWriteToTrapLog("Class title: %s\n", _wpclsQueryTitle(somSelf));
|
---|
2331 |
|
---|
2332 | /* The FOURCC of the JPEG-IO proc is JPEG so we have to create that template
|
---|
2333 | in the JPG class. */
|
---|
2334 |
|
---|
2335 | if(checkImageIOProc( _wpclsQueryInstanceFilter(somSelf))) {
|
---|
2336 | // WPFolder* wpFolder;
|
---|
2337 | // wpFolder=_wpclsQueryFolder(somSelf, "<MMPM2_MMTEMPLATEFOLDER>", FALSE);
|
---|
2338 | // return M_MMAudio_parent_M_MMDataFile_wpclsCreateDefaultTemplates(somSelf, wpFolder);
|
---|
2339 | // HlpWriteToTrapLog("Create template for: %s\n", _wpclsQueryTitle(somSelf));
|
---|
2340 | // HlpWriteToTrapLog("Create template for: %s\n", _somGetClassName(somSelf) );
|
---|
2341 | mmclsCreateTheDefaultTemplate(somSelf, Folder);
|
---|
2342 | return TRUE;
|
---|
2343 | }
|
---|
2344 |
|
---|
2345 | return TRUE;
|
---|
2346 | }
|
---|
2347 |
|
---|
2348 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryStyle(M_MMImage *somSelf)
|
---|
2349 | {
|
---|
2350 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
2351 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryStyle");
|
---|
2352 |
|
---|
2353 | return CLSSTYLE_NEVERPRINT;
|
---|
2354 | // return (M_MMImage_parent_M_WPImageFile_wpclsQueryStyle(somSelf));
|
---|
2355 | }
|
---|
2356 |
|
---|
2357 | /*
|
---|
2358 | * The prototype for cwimgM_wpclsQueryTitle was replaced by the following prototype:
|
---|
2359 | */
|
---|
2360 | SOM_Scope PSZ SOMLINK cwimgM_wpclsQueryTitle(M_MMImage *somSelf)
|
---|
2361 | {
|
---|
2362 | static char chrTitle[20]={0};
|
---|
2363 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
2364 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryTitle");
|
---|
2365 |
|
---|
2366 | if(chrTitle[0]==0)
|
---|
2367 | if(!getMessage(chrTitle, IDSTR_CWIMAGETITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
---|
2368 | strcpy(chrTitle,"Digital Image");
|
---|
2369 |
|
---|
2370 | return chrTitle;
|
---|
2371 | }
|
---|
2372 |
|
---|
2373 | /*
|
---|
2374 | * The prototype for cwimgM_wpclsQueryIconData was replaced by the following prototype:
|
---|
2375 | */
|
---|
2376 | /*
|
---|
2377 | * wpclsQueryDefaultHelp: override;
|
---|
2378 | */
|
---|
2379 |
|
---|
2380 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryIconData(M_MMImage *somSelf,
|
---|
2381 | PICONINFO pIconInfo)
|
---|
2382 | {
|
---|
2383 | HMODULE hmod;
|
---|
2384 |
|
---|
2385 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
2386 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryIconData");
|
---|
2387 |
|
---|
2388 | hmod=queryModuleHandle();
|
---|
2389 | if(!hmod)
|
---|
2390 | return M_MMImage_parent_M_WPImageFile_wpclsQueryIconData(somSelf, pIconInfo);
|
---|
2391 |
|
---|
2392 | if (pIconInfo) {
|
---|
2393 | pIconInfo->fFormat = ICON_RESOURCE;
|
---|
2394 | pIconInfo->hmod = hmod;
|
---|
2395 | pIconInfo->resid = ID_ICONCWIMAGEFILE;
|
---|
2396 | } /* endif */
|
---|
2397 |
|
---|
2398 | return ( sizeof(ICONINFO) );
|
---|
2399 | }
|
---|
2400 |
|
---|
2401 | /*
|
---|
2402 | * The prototype for cwimgM_wpclsQueryDetailsInfo was replaced by the following prototype:
|
---|
2403 | */
|
---|
2404 | SOM_Scope ULONG SOMLINK cwimgM_wpclsQueryDetailsInfo(M_MMImage *somSelf,
|
---|
2405 | PCLASSFIELDINFO* ppClassFieldInfo,
|
---|
2406 | PULONG pSize)
|
---|
2407 | {
|
---|
2408 | ULONG cParentColumns;
|
---|
2409 | PCLASSFIELDINFO pCfi;
|
---|
2410 | int i;
|
---|
2411 |
|
---|
2412 | /* M_CWImageData *somThis = M_CWImageGetData(somSelf); */
|
---|
2413 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryDetailsInfo");
|
---|
2414 |
|
---|
2415 | cParentColumns= (M_MMImage_parent_M_WPImageFile_wpclsQueryDetailsInfo(somSelf,
|
---|
2416 | ppClassFieldInfo,
|
---|
2417 | pSize));
|
---|
2418 | if(pSize)
|
---|
2419 | *pSize+=sizeof(IMAGEDETAILS);
|
---|
2420 |
|
---|
2421 | if(ppClassFieldInfo)
|
---|
2422 | {
|
---|
2423 | if(*ppClassFieldInfo)
|
---|
2424 | {
|
---|
2425 | pCfi=*ppClassFieldInfo;
|
---|
2426 | for(i=0; i<cParentColumns;i++)
|
---|
2427 | pCfi=(pCfi->pNextFieldInfo ? pCfi->pNextFieldInfo: pCfi);
|
---|
2428 |
|
---|
2429 | pCfi->pNextFieldInfo=cfiImageFieldInfo;
|
---|
2430 | }
|
---|
2431 | else
|
---|
2432 | *ppClassFieldInfo=cfiImageFieldInfo;
|
---|
2433 | }
|
---|
2434 | return (cParentColumns+NUM_IMAGE_DETAILS_FIELDS);
|
---|
2435 | }
|
---|
2436 |
|
---|
2437 |
|
---|
2438 |
|
---|
2439 | SOM_Scope PSZ SOMLINK cwimgM_wpclsQueryInstanceFilter(M_MMImage *somSelf)
|
---|
2440 | {
|
---|
2441 | /* M_MMImageData *somThis = M_MMImageGetData(somSelf); */
|
---|
2442 | M_MMImageMethodDebug("M_MMImage","cwimgM_wpclsQueryInstanceFilter");
|
---|
2443 |
|
---|
2444 | //return "*.png,*.sdf,*.klj,*jpe,*.zui";
|
---|
2445 | return chrMMImageExt;
|
---|
2446 | /* return (M_MMImage_parent_M_WPImageFile_wpclsQueryInstanceFilter(somSelf));*/
|
---|
2447 | }
|
---|
2448 |
|
---|