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