source: trunk/mediafolder/c/mediafldr/mediadialogprocs.cpp@ 2

Last change on this file since 2 was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 91.7 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 2002-2004
3 * It is part of the MediaFolder package
4 */
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#define INCL_GPI
21#define INCL_GPILCIDS
22#define INCL_GPIPRIMITIVES
23#define INCL_GPIBITMAPS
24#define INCL_SW
25#define INCL_REXXSAA
26
27#include "mediafolder.hh"
28#include "mediafolderres.h"
29
30#include "sys_funcs.h"
31#include "menu_funcs.h"
32
33#include "launchpad.hh"
34
35//#pragma SOMAsDefault(pop)
36#include <rexxsaa.h> /* needed for RexxStart() */
37
38#include <stdio.h>
39#include <stdlib.h>
40//#pragma SOMAsDefault(on)
41
42#include "menufolder.hh"
43
44typedef BOOL SOMLINK somTP_CWMenuFolder_mfCheckMenuItems(CWMenuFolder *somSelf,
45 WPObject* wpObject,
46 ULONG ulMenuId);
47typedef somTP_CWMenuFolder_mfCheckMenuItems *somTD_CWMenuFolder_mfCheckMenuItems;
48
49typedef BOOL SOMLINK somTP_CWMenuFolder_mfCheckSkriptMenuItems(CWMenuFolder *somSelf,
50 WPObject* wpObject,
51 ULONG ulMenuId,
52 HWND hwndFrame);
53typedef somTP_CWMenuFolder_mfCheckSkriptMenuItems *somTD_CWMenuFolder_mfCheckSkriptMenuItems;
54
55
56PFNWP oldProc; //Old proc from subclassed shadow
57HWND hwndShadow;// The handle of the help window
58extern PFNWP oldButtonProc2; //place for original button-procedure
59extern HWND hwndBubbleWindow;// The handle of the help window
60#define WM_NEWBUBBLE WM_USER+100 //Use ATOM later
61#define xVal 12 //x-distance of Bubble
62#define yVal 8 //y-distance of Bubble
63char chrTBFlyFontName[CCHMAXPATH]="9.WarpSans";/* Font for toolbar fly over help */
64RGB rgbTBFlyForeground={0};
65RGB rgbTBFlyBackground={180,255,255};
66BOOL bTBFlyOverEnabled=TRUE;
67int iTBFlyOverDelay=250;
68
69/* Pointer into window words */
70extern ULONG ulQWP_CONTAINERPROC;
71extern ULONG ulQWP_THISPTR;
72extern ULONG ulQWL_TOPCTRLHWND;
73extern ULONG ulQWL_BOTTOMCTRLHWND;
74extern ULONG ulQWL_RIGHTCTRLHWND;
75extern ULONG ulQWL_LEFTCTRLHWND;
76
77extern char chrInstallDir[CCHMAXPATH];
78extern CONTROLINFO ciControls[];
79extern LOADEDBITMAP allBMPs[];
80extern PFNWP pfnwpGenericFrame;
81extern PFNWP oldStaticTextProc;
82extern LPList* lplAllLPads;
83
84/* Extern */
85//extern ULONG cwQueryOSRelease();
86extern BOOL cwMoveNotebookButtonsWarp4(HWND hwndDlg, USHORT usID, USHORT usDelta);
87void sendConfig();
88ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
89 char* title, ULONG ulTitleID, LONG lSizeTitle,
90 HMODULE hResource, HWND hwnd, ULONG ulFlags);
91BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
92
93void handleWindowPosChanged(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);/* In dataCddialogProcs.cpp */
94void writeLogPrintf(char* logFile, char* format, ...);
95void HlpWriteToTrapLog(const char* chrFormat, ...);
96HMODULE queryResModuleHandle(void);
97void callMediaFolderMethod(CWMediaFolder *thisPtr, ULONG ulAction, ULONG ulData);
98
99MRESULT paintControls(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
100BOOL paintHilitedControl(HWND hwnd, USHORT usControl, BOOL bHilite);
101void adjustDialogControlPos(HWND hwnd);
102MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id);
103void setPlayTimeText(CWMediaFolder *thisPtr);
104void togglePlayTimeDisplayVisibility(CWMediaFolder *thisPtr);
105winSetVolumeSlider(CWMediaFolder *thisPtr);
106winCheckRepeatButton(CWMediaFolder *thisPtr);
107void contextMenu(HWND hwnd, USHORT usItem, BOOL fCheckItem);
108
109MRESULT EXPENTRY staticTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
110extern void _Optlink openThreadFunc (void *arg);
111
112extern SOMClass* cwGetSomClass(char* chrClassName);
113
114/* Local */
115MRESULT EXPENTRY topCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
116
117/*****************************************************/
118/* */
119/* New container procedure so tabbing to the play */
120/* control dialog works. */
121/* */
122/*****************************************************/
123MRESULT EXPENTRY mediaFldrContainerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
124{
125 CWMediaFolder* thisPtr;
126 HWND hwndDialog;
127 PFNWP pfnwpContainer;
128
129 switch(msg)
130 {
131 case WM_CHAR:
132 /* handle TAB keys so user may tab from the container to the frame controls */
133 if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
134 {
135 if(SHORT2FROMMP(mp2)==VK_TAB && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
136 /* Always forward tab to the top middle framecontrol */
137 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)/* The frame */
138 {
139 /* Get HWND of top middle dialog */
140 if((hwndDialog=WinWindowFromID(WinWindowFromID(hwndDialog,IDDLG_TOPFRAME),IDDLG_TOPMIDDLE))!=NULLHANDLE)
141 {
142 if((hwndDialog=WinWindowFromID(hwndDialog,IDPB_SKIPBACK))!=NULLHANDLE)
143 if(WinSetFocus(HWND_DESKTOP,hwndDialog))
144 return (MRESULT)TRUE;
145 }
146 }
147 break;/* error: fall to the window proc */
148 }
149 else if(SHORT2FROMMP(mp2)==VK_BACKTAB && !(SHORT1FROMMP(mp1) & KC_KEYUP) )
150 {
151 /* Check for key down to make sure the focus doesn't switch immediately to the next
152 frame control when just coming from another control. Only if the user hits tab
153 again in the container the focus switches. */
154 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
155 {
156 /* Get HWND of top middle dialog */
157 if((hwndDialog=WinWindowFromID(WinWindowFromID(hwndDialog,IDDLG_TOPFRAME),IDDLG_TOPMIDDLE))!=NULLHANDLE)
158 {
159 if((hwndDialog=WinWindowFromID(hwndDialog,IDSL_POSBAR))!=NULLHANDLE)
160 if(WinSetFocus(HWND_DESKTOP,hwndDialog))
161 return (MRESULT)TRUE;
162 }
163 }
164 }
165 break;/* error: fall to the window proc */
166 }
167 break;
168
169 /*****************************************************/
170 /* Show a busy dialog if necessary. */
171 /*****************************************************/
172 case WM_MOUSEMOVE:
173 /* Get frame handle */
174 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
175 {
176 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,ulQWP_THISPTR);
177 if(somIsObj(thisPtr))
178 if(thisPtr->mfData)
179 /* A thread for calculating the size is running so show the wait ptr. */
180 if(thisPtr->mfData->bProcessing==TRUE) {
181 HPOINTER hptr=WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
182 if(hptr) {
183 WinSetPointer(HWND_DESKTOP, hptr);
184 return MRTRUE;
185 }
186 }
187
188#if 0
189 if((hwndDialog=WinWindowFromID(hwndDialog,IDDLG_TOPFRAME))!=NULLHANDLE)
190 {
191 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
192 if(somIsObj(thisPtr))
193 if(thisPtr->mfData)
194 /* A thread for calculating the size is running so show the wait ptr. */
195 if(thisPtr->mfData->bProcessing==TRUE) {
196 HPOINTER hptr=WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
197 if(hptr) {
198 WinSetPointer(HWND_DESKTOP, hptr);
199 return MRTRUE;
200 }
201 }
202 }
203#endif
204 }
205 break;
206 default:
207 break;
208 }
209 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE) {
210 pfnwpContainer=(PFNWP)WinQueryWindowULong( hwndDialog, ulQWP_CONTAINERPROC);
211 if(pfnwpContainer)
212 return pfnwpContainer(hwnd, msg, mp1, mp2);
213 }
214
215#if 0
216 /* Any other message is handled by the folder container procedure */
217 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
218 {
219 if((hwndDialog=WinWindowFromID(hwndDialog,IDDLG_TOPFRAME))!=NULLHANDLE)
220 {
221 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
222 if(somIsObj(thisPtr))
223 if(thisPtr->pfnwpContainer)
224 return thisPtr->pfnwpContainer(hwnd, msg, mp1, mp2);
225 }
226 }
227#endif
228 return WinDefWindowProc(hwnd, msg, mp1, mp2);
229}
230
231/************************************************************
232 * *
233 * This frame proc handles the about menuitem of the *
234 * Warp 4 menu bar and removes the Tree view item. *
235 * *
236************************************************************/
237MRESULT EXPENTRY mediaFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
238{
239 CWMediaFolder* thisPtr;
240 HWND hwndDialog;
241 MENUITEM mi;
242 char text[100];
243
244 switch (msg)
245 {
246 case WM_INITMENU:
247 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,ulQWP_THISPTR);
248 if(somIsObj(thisPtr)) {
249 HMODULE hResource=queryResModuleHandle();
250 switch(thisPtr->usLastSelMenuItem)
251 {
252 //#ifndef ECS
253 /* The eCS version doesn't have an 'About menu' */
254 case 0x2d3:/* Help menu */
255 {
256 if(hResource) {
257 /* insert separator */
258 menuInsertMenuSeparator(HWNDFROMMP(mp2), NULL, MIT_END);
259 /* Insert 'About' item */
260 getMessage(text, IDSTR_MENUABOUT ,sizeof(text), hResource, hwnd);
261 menuInsertMenuItem(HWNDFROMMP(mp2), NULL, MIT_END, ID_ABOUTITEM, text);
262 break;
263 }
264 break;
265 }
266 //#endif
267
268 case 0x68:
269 /* Remove change to Tree from menubar menu */
270 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(717,TRUE),0);
271 /* V0.2.8 (07.09.2003):
272 Removed icon view item from menu. Icon view is no longer supported by
273 the media folder.*/
274
275 /* Remove change to Icon view from menubar menu */
276 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x2cc,TRUE),0);
277
278 break;
279
280 case 0x2d1:
281 /* Remove change to Tree from menubar menu */
282 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(717,TRUE),0);
283 /* V0.2.8 (07.09.2003):
284 Removed icon view item from menu. Icon view is no longer supported by
285 the media folder.*/
286 /* Remove change to Icon view from menubar menu */
287 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x2cc,TRUE),0);
288
289 /* Insert the new 'compact' view item */
290 if(hResource) {
291 SHORT sItem;
292 /* Insert 'Compact' item */
293 getMessage(text, IDSTR_MENUCOMPACT ,sizeof(text), hResource, hwnd);
294 sItem=menuInsertMenuItem( HWNDFROMMP(mp2), NULL, 1, ID_MENUVIEWCOMPACT, text);
295 if(sItem!=MIT_MEMERROR && sItem!=MIT_ERROR)
296 {
297 /* Disable menu if already in compact view */
298 if(thisPtr->cwQueryMFldrFlags() & MFLDR_VIEW_COMPACT) {
299 WinEnableMenuItem(HWNDFROMMP(mp2), ID_MENUVIEWCOMPACT, FALSE);
300 /* Enable details view item */
301 WinEnableMenuItem(HWNDFROMMP(mp2), 0x2ce, TRUE);
302 }
303 }
304 }
305 break;
306 default:
307 break;
308 }
309
310 }
311#if 0
312 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
313 {
314 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
315 if(somIsObj(thisPtr)) {
316 HMODULE hResource=queryResModuleHandle();
317 switch(thisPtr->usLastSelMenuItem)
318 {
319 case 0x2d3:/* Help menu */
320 {
321 if(hResource) {
322 /* insert separator */
323 cwInsertMenuSeparator(MIT_END, HWNDFROMMP(mp2), NULL);
324 /* Insert 'About' item */
325 getMessage(text, IDSTR_MENUABOUT ,sizeof(text), hResource, hwnd);
326 cwInsertMenuItem(MIT_END, HWNDFROMMP(mp2), NULL, ID_ABOUTITEM, text);
327 break;
328 }
329 break;
330 }
331 case 0x2d1:
332 /* Remove change to Tree from menubar menu */
333 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(717,TRUE),0);
334 /* Insert the new 'compact' view item */
335 if(hResource) {
336 /* Insert 'Compact' item */
337 getMessage(text, IDSTR_MENUCOMPACT ,sizeof(text), hResource, hwnd);
338 cwInsertMenuItem( 1, HWNDFROMMP(mp2), NULL, ID_MENUVIEWCOMPACT, text);
339 }
340 break;
341 default:
342 break;
343 }
344 }
345 }
346#endif
347 break;
348 case WM_COMMAND:
349 if(SHORT1FROMMP(mp2)==CMDSRC_MENU) {
350 if(SHORT1FROMMP(mp1)>=FIRSTUSERITEM) {
351 BOOL bHandled=FALSE;
352
353 TRY_LOUD(AF_MENU) {
354 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,ulQWP_THISPTR);
355 if(somIsObj(thisPtr)) {
356 CWMenuFolder * wpFolder;
357 HOBJECT hObject;
358 somId id;
359
360 somTD_CWMenuFolder_mfCheckSkriptMenuItems methodPtr;
361 M_WPObject *m_wpObject;
362
363 // bHandled=thisPtr->cwCheckUserMenuItems(SKRIPTFOLDER_MEDIAFOLDER, SHORT1FROMMP(mp1));
364 if(!bHandled)
365 bHandled=thisPtr->cwCheckUserMenuItems(USERMENUFOLDER_MEDIAFOLDER , SHORT1FROMMP(mp1));
366 }/* if(somIsObj(thisPtr)) */
367 }
368 CATCH(AF_MENU)
369 {
370 } END_CATCH;
371
372#if 0
373 TRY_LOUD(AF_MENU) {
374 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
375 {
376 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
377 if(somIsObj(thisPtr)) {
378
379 CWMenuFolder * wpFolder;
380 HOBJECT hObject;
381 somId id;
382 somTD_CWMenuFolder_mfCheckSkriptMenuItems methodPtr;
383 M_WPObject *m_wpObject;
384
385 // bHandled=thisPtr->cwCheckUserMenuItems(SKRIPTFOLDER_MEDIAFOLDER, SHORT1FROMMP(mp1));
386 if(!bHandled)
387 bHandled=thisPtr->cwCheckUserMenuItems(USERMENUFOLDER_MEDIAFOLDER , SHORT1FROMMP(mp1));
388 }/* if(somIsObj(thisPtr)) */
389 }/* Dialog window */
390 }
391 CATCH(AF_MENU)
392 {
393 } END_CATCH;
394#endif
395
396 if(bHandled)
397 return (MRESULT) 0;
398 }
399 }
400 break;
401
402 case WM_MENUSELECT:
403 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,ulQWP_THISPTR);
404 if(somIsObj(thisPtr))
405 thisPtr->usLastSelMenuItem=SHORT1FROMMP(mp1);
406 break;
407 default:
408 break;
409 }
410 /* Any other message is handled by the folder frame procedure */
411 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,ulQWP_THISPTR);
412 if(somIsObj(thisPtr))
413 if(thisPtr->pfnwpFrame)
414 return thisPtr->pfnwpFrame(hwnd, msg, mp1, mp2);
415
416 return pfnwpGenericFrame(hwnd, msg, mp1, mp2);
417}
418
419/************************************************************
420 * *
421 * This dialog proc handles the playcontrol area at the *
422 * top. *
423 * *
424 ************************************************************/
425MRESULT EXPENTRY playControlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
426{
427 CWMediaFolder *thisPtr;
428 static BOOL bPosDragging=FALSE;
429
430 switch(msg)
431 {
432 /*****************************************************/
433 /* Init the dialog */
434 /*****************************************************/
435 case WM_INITDLG :
436
437 WinDefDlgProc(hwnd, msg, mp1, mp2);
438
439 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
440 thisPtr=(CWMediaFolder*) PVOIDFROMMP(mp2);
441 adjustDialogControlPos(hwnd);
442
443 if(SysQueryOSRelease()>=40) {
444 WinSetPresParam(hwnd,
445 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
446 DEFAULT_DIALOG_FONT );
447 }
448
449 if(somIsObj(thisPtr)) {
450 WinSendMsg( WinWindowFromID(hwnd, IDSL_VOLUME),
451 SLM_SETSLIDERINFO,
452 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
453 MPFROMLONG( thisPtr->ulVolume));
454 /* Set position slider */
455 WinSendMsg( WinWindowFromID(hwnd, IDPB_POSBAR),
456 SLM_SETSLIDERINFO,
457 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
458 MPFROMLONG(0));
459
460 /* Set repeat check button if necessary */
461#if 0
462 /* This Does not work... Probably because hwndTopMiddle isn't set in the
463 instance data yet. Left in here so it isn't forgotten... */
464 winCheckRepeatButton(thisPtr);
465 winSetVolumeSlider(thisPtr);
466#endif
467
468 if(thisPtr->ulFlags&FLAG_REPEAT)
469 WinCheckButton(hwnd, IDCB_REPEAT,1);
470 if(thisPtr->ulFlags&FLAG_RANDOM)
471 WinCheckButton(hwnd, IDCB_RANDOM,1);
472
473
474 if(thisPtr->mfData)
475 WinSetPresParam(WinWindowFromID(hwnd, IDST_PLAYTIME),
476 PP_FONTNAMESIZE,(ULONG)sizeof(thisPtr->mfData->chrPlayTimeFont),
477 thisPtr->mfData->chrPlayTimeFont);
478 }
479 return (MRESULT)FALSE;
480 /*****************************************************/
481 /* The dialog is about to be destroyed */
482 /*****************************************************/
483 case WM_DESTROY:
484 {
485 ULONG attrFound;
486
487 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
488 if(somIsObj(thisPtr)) {
489 if(thisPtr->mfData)
490 // Query the playtime font
491 WinQueryPresParam(WinWindowFromID(hwnd, IDST_PLAYTIME),
492 PP_FONTNAMESIZE,0, &attrFound,sizeof(thisPtr->mfData->chrPlayTimeFont),
493 thisPtr->mfData->chrPlayTimeFont, QPF_NOINHERIT);
494 }
495 break;
496 }
497 /*****************************************************/
498 /* Paint the background */
499 /*****************************************************/
500 case WM_PAINT:
501 {
502 SWP swp;
503 RECTL rcl;
504 HPS hps;
505
506 WinQueryWindowPos(hwnd,&swp);
507 if(swp.fl & SWP_MINIMIZE)
508 break;
509 hps = WinBeginPaint( hwnd, NULLHANDLE, &rcl );
510 WinDrawBitmap(hps, allBMPs[MAIN_BMP_IDX].hbm,
511 &rcl,
512 (PPOINTL)&rcl,
513 0, 0,
514 DBM_IMAGEATTRS);
515 WinQueryWindowRect(hwnd, &rcl);
516 WinEndPaint( hps );
517 return FALSE;
518 }
519 /*****************************************************/
520 /* The following two messages are for device sharing */
521 /*****************************************************/
522 case WM_ACTIVATE:
523 if(SHORT1FROMMP(mp1)){
524 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
525 if(somIsObj(thisPtr)){
526 char chrCommand[100];
527
528 if(thisPtr->mrcPlaying) {
529 sprintf(chrCommand,"ACQUIRE wave%d QUEUE wait", thisPtr->iWave);
530 mciSendString(chrCommand, NULL, 0, 0, 0);
531 }
532 }
533 }
534 break;
535 case MM_MCIPASSDEVICE:
536 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
537 if(somIsObj(thisPtr)){
538 HWND hwndFrame=WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT);
539 switch(SHORT1FROMMP(mp2))
540 {
541 case MCI_GAINING_USE:
542 thisPtr->bPaused=FALSE;/* The time display will not be increased */
543 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE, FALSE);
544 return (MRESULT)0;
545 case MCI_LOSING_USE:
546 thisPtr->bPaused=TRUE;
547 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, FALSE);
548 return (MRESULT)0;
549 default:
550 break;
551 }
552 }
553 break;
554 /*****************************************************/
555 /* Set the time in the palytime display. */
556 /* SETPOSITIONADVICE does not work for some reason, */
557 /* so a timer is used. Yes, it's quit cumbersome... */
558 /*****************************************************/
559 case WM_TIMER:
560 if(SHORT1FROMMP(mp1)==IDTIMER_PLAY) {
561 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
562 if(somIsObj(thisPtr)){
563 char chrCommand[50];
564 char retMsg[20];
565 ULONG rc;
566
567 if(!thisPtr->bPaused) {
568 /* Adjust position info if not paused. */
569 thisPtr->ulPos++;
570 if(thisPtr->ulPos*1000>thisPtr->ulTotalLength)
571 thisPtr->ulPos=thisPtr->ulTotalLength/1000;/* Prevent wrong time if timer info isn't accurate.
572 I know all this timing stuff is an ugly thing. */
573
574 if(!bPosDragging) {
575 ULONG ulInc=thisPtr->ulTotalLength/1000;
576 setPlayTimeText(thisPtr); /* Set time display */
577 /* Catch potential division by zero trap */
578 if(ulInc)
579 ulInc=thisPtr->ulPos*100/ulInc;
580 else
581 ulInc=100;
582 /* Set slider position */
583 WinPostMsg( WinWindowFromID(hwnd, IDSL_POSBAR),
584 SLM_SETSLIDERINFO,
585 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
586 MPFROMLONG(ulInc));
587 }
588 thisPtr->cwPlayTimeCallback(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT), thisPtr->ulPos);
589 /* Blink play control */
590 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, thisPtr->ulPos%2);
591 }
592 else {
593 /* Currently pausing */
594 togglePlayTimeDisplayVisibility(thisPtr);
595 paintHilitedControl( WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE,
596 WinIsWindowVisible(WinWindowFromID(thisPtr->hwndTopMiddle, IDST_PLAYTIME)));
597 }
598 }
599 return (MRESULT)0;
600 }
601 break;
602 /*****************************************************/
603 /* Draw the sliders. */
604 /*****************************************************/
605 case WM_DRAWITEM:
606 switch(SHORT1FROMMP(mp1))
607 {
608 case IDSL_POSBAR:
609 case IDSL_VOLUME:
610 return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
611 default:
612 break;
613 }
614 break;
615 /*****************************************************/
616 /* Control messages */
617 /*****************************************************/
618 case WM_CONTROL:
619 {
620 SWP swp;
621 char chrCommand[50];
622 char retMsg[20];
623
624 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
625 if(somIsObj(thisPtr)){
626 switch(SHORT1FROMMP(mp1))
627 {
628 case IDCB_REPEAT:
629 if(SHORT2FROMMP(mp1)== BN_CLICKED) {
630 if(WinQueryButtonCheckstate(hwnd,IDCB_REPEAT) & 1) {
631 thisPtr->ulFlags|=FLAG_REPEAT;
632 }
633 else {
634 thisPtr->ulFlags&=~FLAG_REPEAT;
635 }
636 }
637 return (MRESULT) FALSE;
638 break;
639 case IDCB_RANDOM:
640 if(SHORT2FROMMP(mp1)== BN_CLICKED) {
641 if(WinQueryButtonCheckstate(hwnd,IDCB_RANDOM) & 1) {
642 thisPtr->ulFlags|=FLAG_RANDOM;
643 }
644 else {
645 thisPtr->ulFlags&=~FLAG_RANDOM;
646 }
647 }
648 return (MRESULT) FALSE;
649 break;
650 default:
651 break;
652 }
653 switch(SHORT2FROMMP(mp1))
654 {
655 case BN_PAINT:
656 /* Paint the custom controls (buttons, sliders ) */
657 WinQueryWindowPos(hwnd,&swp);
658 if(swp.fl & SWP_MINIMIZE)
659 break;
660 return paintControls(hwnd, msg, mp1, mp2);
661 /*****************************************************/
662 /* Handle position and volume changes. */
663 /*****************************************************/
664 case SLN_SLIDERTRACK:
665 {
666 switch(SHORT1FROMMP(mp1))
667 {
668 case IDSL_VOLUME:
669 {
670 ULONG ulValue;
671
672 ulValue=LONGFROMMP(mp2);
673 thisPtr->ulVolume=ulValue;
674 sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d WAIT", thisPtr->iWave, thisPtr->ulVolume);
675 mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
676 break;
677 }
678 case IDSL_POSBAR:
679 {
680 static lLastPos=0;
681 long lPos=LONGFROMMP(mp2);
682
683 bPosDragging=TRUE;
684 lPos*=thisPtr->ulTotalLength/100;
685 if(lPos/1000!=lLastPos) {
686 /* Prevent flickering */
687 sprintf(chrCommand, "%d:%02d", lPos/1000/60, (lPos/1000)%60);
688 WinSetWindowText(WinWindowFromID(hwnd, IDST_PLAYTIME), chrCommand);
689 lLastPos=lPos/1000;
690 }
691 break;
692 }
693 default:
694 break;
695 }/* switch */
696 return (MRESULT) 0;
697 break;
698 }
699 case SLN_CHANGE:
700 {
701 switch(SHORT1FROMMP(mp1))
702 {
703 case IDSL_VOLUME:
704 ULONG ulValue;
705
706 ulValue=LONGFROMMP(mp2);
707 thisPtr->ulVolume=ulValue;
708 sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d WAIT", thisPtr->iWave, thisPtr->ulVolume);
709 mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
710 thisPtr->wpSaveDeferred();
711 break;
712 case IDSL_POSBAR:
713 {
714 ULONG rc;
715 long lPos=LONGFROMMP(mp2);
716
717 bPosDragging=FALSE;
718 lPos*=1000;
719 lPos*=thisPtr->ulTotalLength/100;
720 lPos/=1000;// Use only full seconds
721
722 /* Set time display first */
723
724 thisPtr->cwSeekAudioFile(lPos);
725 /* restart timer */
726 WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, IDTIMER_PLAY, PLAYTIMER_DELAY);
727 thisPtr->ulPos=lPos/1000;
728 break;
729 }
730 default:
731 break;
732 }/* switch */
733 return (MRESULT)TRUE;
734 }
735 default:
736 break;
737 }/* switch */
738 break;
739 }
740 }/* WM_CONTROL */
741
742 /*****************************************************/
743 /* Handle push button messages. */
744 /*****************************************************/
745 case WM_COMMAND:
746 /* The play control handling for starting, stopping etc. */
747 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
748 if(somIsObj(thisPtr)){
749 HWND hwndFrame=WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT);
750 switch(SHORT1FROMMP(mp1))
751 {
752 case IDPB_PLAY:
753 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE, FALSE);
754 callMediaFolderMethod(thisPtr, PLAY_FIRST, 0);
755 break;
756 case IDPB_STOP:
757 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, FALSE);
758 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE, FALSE);
759 callMediaFolderMethod(thisPtr, STOP_TRACK, 0);
760 break;
761 case IDPB_SKIPFORWARD:
762 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, FALSE);
763 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE, FALSE);
764 callMediaFolderMethod(thisPtr, PLAY_NEXT, 0);
765 break;
766 case IDPB_SKIPBACK:
767 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, FALSE);
768 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PAUSE), IDPB_PAUSE, FALSE);
769 callMediaFolderMethod(thisPtr, PLAY_PREV, 0);
770 break;
771 case IDPB_PAUSE:
772 paintHilitedControl(WinWindowFromID(hwnd, IDPB_PLAY), IDPB_PLAY, FALSE);
773 callMediaFolderMethod(thisPtr, PAUSE_TRACK, 0);
774 break;
775 /* Popup menu over time control */
776 case ID_MENUITEMELAPSED:
777 thisPtr->usWhichDisplay=DISPLAY_TIMEELAPSED;
778 setPlayTimeText(thisPtr);
779 break;
780 case ID_MENUITEMREMAINING:
781 thisPtr->usWhichDisplay=DISPLAY_TIMEREMAINING;
782 setPlayTimeText(thisPtr);
783 break;
784 case ID_MENUITEMID3:
785 thisPtr->usWhichDisplay=DISPLAY_TIMEID3;
786 WinSetWindowULong(WinWindowFromID(thisPtr->hwndTopMiddle, IDST_PLAYTIME), QWL_USER, 0);
787 setPlayTimeText(thisPtr);
788 break;
789 default:
790 break;
791 }/* switch() */
792 }/* somIsObj()*/
793 return (MRESULT)FALSE;
794
795 /*****************************************************/
796 /* Make sure tabbing works. */
797 /*****************************************************/
798 case WM_CHAR:
799 if(SHORT1FROMMP(mp1) & KC_ALT) { // Send keys with ALT modifier to the folder
800 HWND hwndTemp;
801 // Save control with focus
802 hwndTemp=WinQueryFocus(HWND_DESKTOP);
803 // Set focus to container so the key will be processed as usual
804 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),FID_CLIENT));
805 // Set saved control as old focus owner so it will get the focus back when necessary, not the container
806 WinSetWindowULong(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),QWL_HWNDFOCUSSAVE,hwndTemp);
807 return WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),FID_CLIENT),msg,mp1,mp2);
808 }
809 else if((SHORT1FROMMP(mp1) & KC_VIRTUALKEY)== KC_VIRTUALKEY)
810 {
811 if(SHORT2FROMMP(mp2)==VK_TAB ) {
812 if(WinQueryFocus(HWND_DESKTOP)==WinWindowFromID(hwnd,IDSL_POSBAR)) {
813 // Set focus to container
814 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),
815 FID_CLIENT));
816 return (MRESULT)TRUE;
817 }
818 }/* if(SHORT2FROMMP(mp2)==VK_TAB ) */
819 else if(SHORT2FROMMP(mp2)==VK_BACKTAB )
820 {
821 if(WinQueryFocus(HWND_DESKTOP)==WinWindowFromID(hwnd,IDPB_SKIPBACK)) {
822 // Set focus to container
823 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),
824 FID_CLIENT));
825 return (MRESULT)TRUE;
826 }
827 }
828 }/* else if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY) */
829 break;
830#if 0
831 case WM_CONTEXTMENU:
832 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
833 if(somIsObj(thisPtr)){
834 POINTL ptl;
835 HWND hwndClient=WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT),FID_CLIENT);
836 WinQueryPointerPos(HWND_DESKTOP, &ptl) ;
837 WinMapWindowPoints(HWND_DESKTOP, hwndClient, &ptl, 1);
838
839 thisPtr->wpDisplayMenu(hwndClient, NULLHANDLE, &ptl,MENU_OBJECTPOPUP,NULL);
840 }
841 return MRFALSE;
842#endif
843 /*****************************************************/
844 /* Handle playtime display switching. */
845 /* The messages are coming from the static text. */
846 /*****************************************************/
847 case WM_APPTERMINATENOTIFY:
848 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
849 if(somIsObj(thisPtr)){
850 switch(SHORT1FROMMP(mp1))
851 {
852 case NOTIFY_CLICK:
853 /* Clicked on the playtime display */
854 thisPtr->usWhichDisplay++;
855 if(thisPtr->usWhichDisplay>2)
856 thisPtr->usWhichDisplay=0;
857 if(thisPtr->usWhichDisplay==2)
858 WinSetWindowULong(WinWindowFromID(thisPtr->hwndTopMiddle, IDST_PLAYTIME), QWL_USER, 0);
859 setPlayTimeText(thisPtr);
860 return MRFALSE;
861 case NOTIFY_CONTEXT:
862 /* Show context menu. */
863 contextMenu(hwnd, thisPtr->usWhichDisplay+ID_MENUITEMELAPSED, TRUE);
864 return MRFALSE;
865 default:
866 break;
867 }
868 }
869 return MRFALSE;
870
871#if 0
872 case MM_MCIPOSITIONCHANGE:
873 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
874 if(somIsObj(thisPtr)){
875 char chrCommand[50];
876 char retMsg[20];
877 char retMsg2[20];
878 int iTime;
879 ULONG rc;
880 /* Restart check timer */
881 WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, IDTIMER_PLAY, PLAYTIMER_DELAY);
882 sprintf(chrCommand,"STATUS wave%d POSITION WAIT", thisPtr->iWave);
883 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
884 if((rc & 0x0000ffff)==MCIERR_SUCCESS) {
885 iTime=atoi(retMsg);
886 /* Set time display */
887 sprintf(chrCommand,"%d:%02d %d:%02d -%d:%02d",thisPtr->ulTotalLength/1000/60,(thisPtr->ulTotalLength/1000)%60,
888 (iTime+thisPtr->ulStartPosition)/1000/60,((iTime+thisPtr->ulStartPosition)/1000)%60,
889 (thisPtr->ulTotalLength-(iTime+thisPtr->ulStartPosition))/1000/60,
890 ((thisPtr->ulTotalLength-(iTime+thisPtr->ulStartPosition))/1000)%60);
891 WinSetWindowText(WinWindowFromID(hwnd, IDST_PLAYTIME), chrCommand);
892 WinPostMsg( WinWindowFromID(hwnd, IDPB_POSBAR),
893 SLM_SETSLIDERINFO,
894 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
895 MPFROMLONG( (LONG)((iTime/10)/(thisPtr->ulTotalLength/1000))));
896 }
897 else {
898 char retError[1024];
899 mciGetErrorString(rc, retError, 1024);
900 sprintf(chrCommand,"%s", retMsg);
901 WinSetWindowText(WinWindowFromID(hwnd, IDST_PLAYTIME), chrCommand);
902 }
903 }
904 break;
905#endif
906 default:
907 break;
908 }
909 return WinDefDlgProc(hwnd, msg, mp1, mp2);
910}
911
912/************************************************************
913 * *
914 * This procedure calculates the positions for the custom *
915 * frame controls. *
916 * PM uses the pos to calculate the area which needs *
917 * repainting and the pos of each control. Using this code *
918 * prevents flickering. *
919 * *
920 ************************************************************/
921MRESULT handleCalcValidRects(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
922{
923 PRECTL pRectl, pRectlNew;
924 PSWP pswp;
925 POINTL ptl;
926
927 pswp=(PSWP)mp2;
928 if(pswp->fl&SWP_SIZE) {
929 pRectl=(PRECTL)mp1;
930 pRectlNew=pRectl;
931 pRectlNew++;
932
933 if(pRectlNew->xRight!=pRectl->xRight) {
934 if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
935 pRectl->xRight-=ptl.x;
936 }else {
937 /* Ok, then use some defaults. Better than nothing... */
938 pRectl->xRight-=4;
939 }
940 pRectlNew->xRight=pRectl->xRight;
941 return (MRESULT)0;
942 }
943 else if(pRectlNew->xLeft<pRectl->xLeft) {
944 if(WinSendMsg(hwnd,WM_QUERYBORDERSIZE,(MPARAM)&ptl,0)) {
945 pRectl->xLeft+=ptl.x;
946 }else {
947 /* Ok, then use some defaults. Better than nothing... */
948 pRectl->xLeft+=4;
949 }
950 pRectlNew->xLeft=pRectl->xLeft;
951 return (MRESULT)0;
952 }
953 else if(pRectlNew->xLeft<pRectl->xLeft) {
954 pRectlNew->xLeft=pRectl->xLeft;
955
956 return (MRESULT)0;
957 } else if(pRectlNew->yBottom!=pRectl->yBottom || pRectlNew->yTop!=pRectl->yTop) {
958 pRectlNew->yTop=pRectl->yTop;
959 pRectlNew->yBottom=pRectl->yBottom;
960 return (MRESULT)0;
961 }
962 }
963 return (MRESULT)0;
964}
965
966
967/************************************************************
968 * *
969 * When sizing and moving the folder the custom frame *
970 * controls must be moved too so they keep their visual *
971 * position with respect to the left border of the folder. *
972 * *
973 ************************************************************/
974void handleWindowPosChanged(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
975{
976 PSWP pswp=(PSWP)mp1;
977
978 if((pswp->fl & SWP_SIZE)&&!(pswp->fl & SWP_SHOW)) {
979 SWP swp;
980 HENUM hEnum;
981 HWND hwndClient;
982 PSWP pswpOld;
983 int xPos, yPos;
984 ULONG ulStyle;
985
986 pswpOld=pswp;
987 pswpOld++;
988
989 ulStyle=WinQueryWindowULong(WinQueryWindow(hwnd,QW_PARENT),QWL_STYLE);
990 if(!(ulStyle & WS_MINIMIZED) && !(ulStyle & WS_MAXIMIZED) ) {
991
992 if(pswpOld->x != pswp->x || 1) {
993 if((pswpOld->cx!=0)) {
994 xPos=(pswpOld->x > pswp->x ? pswpOld->x-pswp->x : 0);
995 // yPos=(pswpOld->y > pswp->y ? pswpOld->y-pswp->y : 0);
996 }
997 else {
998 xPos=0;
999 }
1000 if(pswp->cx<=allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx)
1001 WinSetWindowPos(WinWindowFromID(hwnd, IDDLG_TOPMIDDLE), NULLHANDLE, 0, 0, 0, 0, SWP_MOVE);
1002 else
1003 WinSetWindowPos(WinWindowFromID(hwnd, IDDLG_TOPMIDDLE), NULLHANDLE, (pswp->cx-allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx)/2,
1004 0, 0, 0, SWP_MOVE);
1005#if 0
1006 /* Move all client windows so they keep their distance to the left border */
1007 hEnum=WinBeginEnumWindows(hwnd);
1008 while((hwndClient=WinGetNextWindow(hEnum))!=NULLHANDLE) {
1009 if(WinQueryWindowULong())
1010 WinQueryWindowPos(hwndClient,&swp);
1011 WinSetWindowPos(hwndClient, NULLHANDLE, swp.x-xPos, (pswp->cy-swp.cy)/2/*swp.y-yPos*/, 0, 0, SWP_MOVE);
1012 }/* while */
1013 WinEndEnumWindows(hEnum);
1014#endif
1015 }
1016 }
1017 }
1018}
1019
1020
1021/****************************************************************************/
1022/* */
1023/* This procedure handles the frame extension of the folder at the top */
1024/* */
1025/* The playcontrol dialog is a child of this 'background' dialog. */
1026/* */
1027/****************************************************************************/
1028MRESULT EXPENTRY topCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1029{
1030 CWMediaFolder *thisPtr;
1031 char name[CCHMAXPATH];
1032 ULONG ulNameSize;
1033 SIZEL sizel;
1034 ULONG ulFlags;
1035 HWND hwndTemp;
1036 POINTL ptl;
1037 SHORT a,b;
1038 HOBJECT hObject;
1039
1040 switch(msg)
1041 {
1042 /*****************************************************/
1043 /* Init the dialog */
1044 /*****************************************************/
1045 case WM_INITDLG :
1046 {
1047 ULONG ulStyle;
1048 SWP swp;
1049
1050 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
1051 thisPtr=(CWMediaFolder*) PVOIDFROMMP(mp2);
1052
1053 hwndTemp=WinLoadDlg(hwnd, hwnd, playControlDialogProc, queryResModuleHandle(),
1054 IDDLG_TOPMIDDLE ,thisPtr);
1055 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp);
1056 /**!!!!!!!!!! BORDERSIZE !!!!!!!!!! **/
1057 WinSetWindowPos(hwndTemp, NULL, (swp.cx-allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx)/2, 0,
1058 allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx, allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy, SWP_SIZE|SWP_MOVE|SWP_SHOW);
1059 thisPtr->hwndTopMiddle=hwndTemp;
1060 /* Set dialog font to WarpSans for Warp 4 and above */
1061 if(SysQueryOSRelease()>=40) {
1062 WinSetPresParam(hwnd,
1063 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
1064 DEFAULT_DIALOG_FONT );
1065 }
1066 return (MRESULT)FALSE;
1067 }
1068 case WM_CALCVALIDRECTS:
1069 {
1070 if(WinIsWindowVisible(hwnd))
1071 return handleCalcValidRects(hwnd, msg, mp1, mp2);
1072 break;
1073 }
1074 case WM_WINDOWPOSCHANGED:
1075 {
1076 /* Move the clients of the framecontrol so they keep their distance to the left */
1077 handleWindowPosChanged(hwnd, msg, mp1, mp2);
1078 break;
1079 }
1080 case WM_CHAR:
1081 // Set focus to container so the key will be processed as usual
1082 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT));
1083 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT),msg,mp1,mp2);
1084
1085 /*****************************************************/
1086 /* Paint the background. */
1087 /*****************************************************/
1088 case WM_PAINT:
1089 HPS hps;
1090 RECTL rcl, rclSave, rclSource;
1091 SWP swp;
1092
1093 hps=WinBeginPaint(hwnd, NULLHANDLE,NULL);
1094 /* Get Window size */
1095 WinQueryWindowRect(hwnd, &rcl);
1096 rclSave=rcl;
1097 /* Get size and pos of control area */
1098 WinQueryWindowPos(WinWindowFromID(hwnd, IDDLG_TOPMIDDLE),&swp);
1099 /* Left area */
1100 rcl.xRight=swp.x;
1101 rclSource.xLeft=0;
1102 rclSource.yBottom=0;
1103 rclSource.yTop=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cy;
1104 rclSource.xRight=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cx;
1105 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPLEFT].hbm,
1106 &rclSource,
1107 (PPOINTL)&rclSave,
1108 0, 0,
1109 DBM_IMAGEATTRS | DBM_STRETCH);
1110
1111 /* Right area */
1112 rclSave.xLeft=swp.x+swp.cx;
1113 rclSource.xLeft=0;
1114 rclSource.yBottom=0;
1115 rclSource.yTop=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cy;
1116 rclSource.xRight=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx;
1117 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPRIGHT].hbm,
1118 &rclSource,
1119 (PPOINTL)&rclSave,
1120 0, 0,
1121 DBM_IMAGEATTRS | DBM_STRETCH);
1122
1123 WinEndPaint(hps);
1124 return (MRESULT) 0;
1125 case WM_COMMAND:
1126 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
1127 if(somIsObj(thisPtr)){
1128 switch(SHORT1FROMMP(mp1))
1129 {
1130 case IDPB_PAUSE:
1131 {
1132#if 0
1133 CNRINFO cnrInfo;
1134 HWND hwndContainer;
1135 FIELDINFO fi;
1136 PFIELDINFO pfi, pfiFirst;
1137 char text[200];
1138 int numLeft=0;
1139 int numRight=0;
1140 int numVisLeft=0;
1141 int numVisRight=0;
1142 int a=0;
1143 LONG lWidth[100];
1144 HPS hps;
1145 FONTMETRICS fm={0};
1146 RECTL rcl2;
1147 ULONG attrFound;
1148 char chrFontName[50];
1149 char *chrPtr;
1150
1151 THREADPARAMS* pTp;
1152 ULONG ulErr;
1153
1154 return (MRESULT)0;
1155
1156 pTp=(THREADPARAMS*)thisPtr->wpAllocMem(sizeof(THREADPARAMS), &ulErr);
1157 pTp->thisPtr=thisPtr;
1158 pTp->hwndFrame=WinQueryWindow(hwnd, QW_PARENT);
1159
1160 // _beginthread(rexxThreadFunc,NULL,8192*16,(void*)pTp); //Fehlerbehandlung fehlt
1161 hwndContainer=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), FID_CLIENT);
1162 return (MRESULT)0;
1163 WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
1164 MPFROMLONG(sizeof(cnrInfo)));
1165
1166 pfi=(PFIELDINFO)WinSendMsg(hwndContainer,CM_QUERYDETAILFIELDINFO, NULLHANDLE,
1167 MPFROMSHORT(CMA_FIRST));
1168 if(!pfi)
1169 return (MRESULT)0;
1170 lWidth[a]=(LONG)WinSendMsg(hwndContainer,CM_QUERYDETAILFIELDINFO, MPFROMP(pfi),
1171 MPFROMLONG(0x200));
1172 pfiFirst=pfi;
1173 numRight++;
1174 a++;
1175 if(!(pfi->flData & CFA_INVISIBLE))
1176 numVisRight++;
1177 while(pfi){
1178 if(pfi==cnrInfo.pFieldInfoLast) {
1179 numLeft=numRight;
1180 numRight=0;
1181 numVisLeft=numVisRight;
1182 numVisRight=0;
1183 }
1184 pfi=(PFIELDINFO)WinSendMsg(hwndContainer,CM_QUERYDETAILFIELDINFO, MPFROMP(pfi),
1185 MPFROMSHORT(CMA_NEXT));
1186 if(pfi) {
1187 lWidth[a]=(LONG)WinSendMsg(hwndContainer,CM_QUERYDETAILFIELDINFO, MPFROMP(pfi),
1188 MPFROMLONG(0x200));
1189 a++;
1190 numRight++;
1191 if(!(pfi->flData & CFA_INVISIBLE))
1192 numVisRight++;
1193 }
1194 }
1195
1196 pfi=pfiFirst;
1197 // Query the current font
1198 WinQueryPresParam(hwndContainer,
1199 PP_FONTNAMESIZE,0,&attrFound,sizeof(chrFontName),
1200 chrFontName,QPF_NOINHERIT);
1201 /* 0 means error */
1202 fm.lEmHeight=atol(chrFontName);
1203 if((chrPtr=strchr(chrFontName, '.'))!=NULLHANDLE)
1204 chrPtr++;
1205
1206 hps=WinGetPS(hwndContainer);
1207 strcpy(fm.szFacename, chrPtr);
1208
1209 GpiQueryFontMetrics(hps,sizeof(fm),&fm);
1210
1211 WinReleasePS(hps);
1212 sprintf(text,"%s num: %d CFA_OWNER: %s numLeft: %d numRight: %d numVisLeft: %d numVisRight: %d",
1213 pfi->pTitleData,
1214 cnrInfo.cFields,
1215 (pfi->flData & CFA_OWNER ? "Yes": "No"),
1216 numLeft, numRight,numVisLeft, numVisRight);
1217 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
1218
1219 WinSendMsg(hwndContainer, CM_QUERYVIEWPORTRECT, MPFROMP(&rcl) , MPFROM2SHORT(CMA_WORKSPACE, FALSE));
1220 WinSendMsg(hwndContainer, CM_QUERYVIEWPORTRECT, MPFROMP(&rcl2) , MPFROM2SHORT(CMA_WINDOW, FALSE));
1221
1222 sprintf(text,"%d %d %d %d %d %d %d average: %d average*3 %d rcl.xLeft: %d rcl.xRight %d %d rcl2.xLeft: %d rcl2.xRight %d %d",
1223 lWidth[0], lWidth[1], lWidth[2], lWidth[3], lWidth[4],
1224 lWidth[5], lWidth[6],
1225 fm.lAveCharWidth, fm.lAveCharWidth*3 , rcl.xLeft,rcl.xRight, rcl.xRight-rcl.xLeft
1226 , rcl2.xLeft,rcl2.xRight, rcl2.xRight-rcl2.xLeft);
1227
1228 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
1229 // DosBeep(5000,300);
1230 return (MRESULT)0;
1231
1232 // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Noch nicht implementiert..", "", 1234, MB_OK|MB_MOVEABLE);
1233 char chrCommand[200];
1234 PUSEITEM pUseItem;
1235 PVIEWITEM pViewItem;
1236 PVIEWITEM pView;
1237 WPObject *wpObj;
1238 WPObject *wpObject;
1239
1240 PMINIRECORDCORE mrc;
1241 M_WPObject *mWPObject;
1242
1243 hwndContainer=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), FID_CLIENT);
1244 mWPObject=thisPtr->wpQueryFldrDetailsClass();
1245
1246 /* Selected object */
1247 /* Get first selected container item of our folder */
1248 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS, MPFROMSHORT(CMA_FIRST),
1249 MPFROMSHORT(CRA_SELECTED));
1250
1251 while(mrc) {
1252 wpObj=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
1253 wpObject=thisPtr->cwGetFileSystemObject(wpObj);
1254 if(wpObject!=wpObj && wpObject) {
1255 if(somIsObj(wpObject)) {
1256 if(wpObject->somIsA(mWPObject)) {
1257 ULONG ulFieldSize=0;
1258 /* Fieldinfosize */
1259 ULONG ulCols=mWPObject->wpclsQueryDetailsInfo(NULL, &ulFieldSize);
1260 ULONG ulDataSize=0;
1261 PBYTE memFieldPtr, memFieldPtrSave;
1262 static PBYTE memPtr, memPtrSave;
1263 ULONG ulRC;
1264 PCLASSFIELDINFO pcfi;
1265 PFIELDINFO pfi;
1266 int a;
1267 PSZ *theStrings;
1268 PBYTE bPtr;
1269
1270 /* Detailsdata size */
1271 wpObject->wpQueryDetailsData(NULL, &ulDataSize);
1272
1273 /* For now some safety */
1274 ulDataSize*=4;
1275
1276 if((memFieldPtr=thisPtr->wpAllocMem(ulFieldSize, &ulRC))!=NULLHANDLE) {
1277 memFieldPtrSave=memFieldPtr;
1278 mWPObject->wpclsQueryDetailsInfo( (PCLASSFIELDINFO*)&memFieldPtr, &ulFieldSize);
1279 if((memPtr=thisPtr->wpAllocMem(ulDataSize, &ulRC))!=NULLHANDLE) {
1280 memPtrSave=memPtr;
1281 memset(memPtr, 0, ulDataSize);
1282
1283 /* Query details data */
1284 wpObject->wpQueryDetailsData( (PPVOID)&memPtr, &ulDataSize);
1285 pcfi=(PCLASSFIELDINFO)memFieldPtr;
1286 pcfi=pcfi->pNextFieldInfo;
1287
1288 /* Get first fieldinfo */
1289 pfi=(PFIELDINFO)WinSendMsg(hwndContainer,CM_QUERYDETAILFIELDINFO, MPFROMLONG(0L),
1290 MPFROMSHORT(CMA_FIRST));
1291 memPtr=memPtrSave;
1292 PSZ* ptr;
1293 PSZ* mrcPtr;
1294 for(a=1, pcfi=(PCLASSFIELDINFO)memFieldPtr,ptr=(PSZ*)memPtr;
1295 a<=ulCols && pcfi && pfi;
1296 pfi=pfi->pNextFieldInfo, pcfi=pcfi->pNextFieldInfo,a++)
1297 {
1298 PFIELDINFO pfi2=NULL;
1299 PBYTE temp;
1300 PBYTE temp2;
1301 temp=(PBYTE)mrc;
1302 temp2=temp;
1303 temp+=pfi->offStruct;
1304 mrcPtr=(PSZ*)temp;
1305
1306 if(pfi->offStruct >= mrc->cb) {
1307 /* do something here */
1308 if(a==7) {
1309 *mrcPtr=*ptr;
1310 // pfi->flData&=~(CFA_OWNER|CFA_IGNORE);
1311 // pfi->flData&=~(CFA_OWNER);
1312 }
1313 mrcPtr++;
1314 ptr++;
1315 }/* offStruct*/
1316 }/* for pcfi */
1317 DosBeep(5000, 50);
1318 thisPtr->wpFreeMem(memPtrSave);
1319 }
1320 thisPtr->wpFreeMem(memFieldPtrSave);
1321 }
1322 }/* somIsA */
1323 }/* somIsObj */
1324 }
1325 /* Get next container item of our folder */
1326 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,mrc,
1327 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
1328 };/* mrc */
1329
1330
1331 WinSendMsg(hwndContainer,CM_INVALIDATERECORD, NULL,
1332 MPFROM2SHORT(0, CMA_TEXTCHANGED));
1333 DosBeep(500,300);
1334
1335#if 0
1336 sprintf(chrCommand, "a: %d: Title: %s ptr: %lx *ptr: %lx ,*bPtr: %lx, offset: %x cb: %x",
1337 a, pcfi->pTitleData, ptr, *ptr, *ptrMrc , pfi->offStruct, mrc->cb
1338 );
1339 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "", 1234, MB_OK|MB_MOVEABLE);
1340
1341 if(a==6) {
1342 sprintf(chrCommand,
1343 "a: %d: Title: %s ptr: %lx *ptr: %lx ,*bPtr: %lx, %s offset: %x flData: %x %x",
1344 a, pcfi->pTitleData, ptr, *ptr, *ptrMrc , *ptr, pfi->offStruct
1345 ,pfi->flData ,mrc->cb);
1346 //WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "6", 1234, MB_OK|MB_MOVEABLE);
1347 // *ptrMrc="00:00";
1348 /* Make column visible */
1349 // pfi->flData |=(CFA_STRING | CFA_FIREADONLY);
1350 }/* a */
1351 if(a==26) {
1352 PSZ* ptr;
1353 PSZ* ptrMrc;
1354
1355 DosBeep(500, 20);
1356 bPtr=(BYTE*) mrc;
1357 bPtr+=pfi->offStruct;
1358 ptr=(PSZ*)memPtr;
1359 ptrMrc=(PSZ*)bPtr;
1360 *ptrMrc=*ptr;
1361 *ptrMrc="00:00";
1362 }/* a */
1363#endif
1364#if 0
1365 /* Get first selected container item of our folder */
1366 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS, MPFROMSHORT(CMA_FIRST),
1367 MPFROMSHORT(CRA_SELECTED));
1368 if(mrc) {
1369 wpObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
1370 if(somIsObj(wpObject)) {
1371 DosBeep(5000,300);
1372 for(pView=wpObject->wpFindViewItem( 0xFFFFFFFF, NULL );pView;
1373 pView=NULLHANDLE/*wpObject->wpFindViewItem( 0xFFFFFFFF, pView )*/)
1374 {
1375
1376 }
1377 DosBeep(500,300);
1378 }
1379 }
1380#endif
1381 break;
1382#endif
1383 }
1384 default:
1385 break;
1386 }
1387 }
1388 return (MRESULT) TRUE;
1389default:
1390 break;
1391}
1392return WinDefDlgProc(hwnd, msg, mp1, mp2);
1393}
1394
1395
1396MRESULT EXPENTRY leftCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1397{
1398 CWMediaFolder *thisPtr;
1399
1400 char name[CCHMAXPATH];
1401 ULONG ulNameSize;
1402 SIZEL sizel;
1403 ULONG ulFlags;
1404 HWND hwndTemp;
1405 POINTL ptl;
1406 SHORT a,b;
1407 HOBJECT hObject;
1408 static PMINIRECORDCORE pmrcInserted=NULL;
1409
1410 switch(msg)
1411 {
1412 case WM_INITDLG :
1413 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
1414 thisPtr=(CWMediaFolder*) PVOIDFROMMP(mp2);
1415 if(somIsObj(thisPtr)) {
1416 WinSendMsg( WinWindowFromID(hwnd, IDSL_VOLUME),
1417 SLM_SETSLIDERINFO,
1418 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
1419 MPFROMLONG( thisPtr->ulVolume));
1420 }
1421 /* Set dialog font to WarpSans for Warp 4 and above */
1422 if(SysQueryOSRelease()>=40) {
1423 WinSetPresParam(hwnd,
1424 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
1425 DEFAULT_DIALOG_FONT );
1426 }
1427 return (MRESULT)FALSE;
1428 case WM_CHAR:
1429 // Set focus to container so the key will be processed as usual
1430 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT));
1431 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT),msg,mp1,mp2);
1432
1433 case WM_PAINT:
1434 {
1435 HPS hps;
1436 RECTL rcl, rclSource;
1437 POINTL ptl;
1438 LONG lTemp;
1439
1440 if(allBMPs[CTRLIDX_TOPLEFT].hbm) {
1441 hps=WinBeginPaint(hwnd, NULL, &rcl);
1442 rclSource.xLeft=0;
1443 rclSource.yBottom=0;
1444 rclSource.yTop=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cy;
1445 rclSource.xRight=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cx;
1446 lTemp=rcl.xLeft/rclSource.xRight;
1447 ptl.x=lTemp*rclSource.xRight;
1448 lTemp=rcl.yBottom/rclSource.yTop;
1449 lTemp*=rclSource.yTop;
1450 //WinFillRect(hps, &rcl, CLR_RED);
1451 while(ptl.x<rcl.xRight) {
1452 ptl.y=lTemp;
1453 while(ptl.y<rcl.yTop) {/* y direction */
1454 //DosBeep(5000,100);
1455 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPLEFT].hbm,
1456 &rclSource,
1457 (PPOINTL)&ptl,
1458 0, 0,
1459 DBM_IMAGEATTRS);
1460 ptl.y+=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cy;
1461 //DosSleep(200);
1462 };
1463 ptl.x+=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cx;
1464 };
1465 WinEndPaint(hps);
1466 return (MRESULT)0;
1467 }
1468 break;
1469 }
1470 case WM_CONTROL:
1471 switch(SHORT1FROMMP(mp1))
1472 {
1473 return (MRESULT)0;
1474 default:
1475 break;
1476 }
1477 break;
1478 case WM_COMMAND:
1479 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
1480 if(somIsObj(thisPtr)){
1481 switch(SHORT1FROMMP(mp1))
1482 {
1483 case IDPB_ADD:
1484 {
1485 HWND hwndContainer;
1486 HWND hwndInsert;
1487 PMINIRECORDCORE mrc;
1488
1489 WPObject *wpObject;
1490
1491 hwndContainer=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), FID_CLIENT);
1492 /* Get first selected container item of our folder */
1493 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS, MPFROMSHORT(CMA_FIRST),
1494 MPFROMSHORT(CRA_SELECTED));
1495 if(mrc)
1496 {
1497 DosBeep(5000, 500);
1498 wpObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
1499 if(somIsObj(wpObject)) {
1500 POINTL ptl= {40,40};
1501
1502 DosBeep(500, 500);
1503 hwndInsert=WinWindowFromID(hwnd, IDCNR_PLAYLIST);
1504 if(!pmrcInserted)
1505 DosBeep(5000, 500);
1506 pmrcInserted=wpObject->wpCnrInsertObject(hwndInsert, &ptl,NULL, NULL );
1507 }
1508 }
1509 break;
1510 }
1511 case IDPB_REMOVE:
1512 {
1513 HWND hwndInserted;
1514 WPObject *wpObject;
1515
1516 hwndInserted=WinWindowFromID(hwnd, IDCNR_PLAYLIST);
1517 if(pmrcInserted) {
1518 DosBeep(5000, 500);
1519 wpObject=(WPObject*)OBJECT_FROM_PREC(pmrcInserted);//Get object
1520 if(wpObject->wpCnrRemoveObject(hwndInserted))
1521 pmrcInserted=NULL;
1522 }
1523 break;
1524 }
1525 default:
1526 break;
1527 }
1528 }
1529 return (MRESULT) TRUE;
1530 default:
1531 break;
1532 }
1533 return WinDefDlgProc(hwnd, msg, mp1, mp2);
1534}
1535
1536ULONG modulo(ULONG start,ULONG* delta, ULONG max)
1537{
1538 while(start>max) {/* Probably slow for small bitmaps and wide screens. Anyone volunteering to write better code? */
1539 start-=max;
1540 };
1541 *delta=max-start;
1542 return start;
1543}
1544
1545/****************************************************************************/
1546/* */
1547/* This procedure handles the frame extension of the folder on the right */
1548/* */
1549/****************************************************************************/
1550MRESULT EXPENTRY rightCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1551{
1552 CWMediaFolder *thisPtr;
1553
1554 switch(msg)
1555 {
1556 case WM_INITDLG :
1557 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
1558 thisPtr=(CWMediaFolder*) PVOIDFROMMP(mp2);
1559 if(somIsObj(thisPtr)) {
1560 WinSendMsg( WinWindowFromID(hwnd, IDSL_VOLUME),
1561 SLM_SETSLIDERINFO,
1562 MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
1563 MPFROMLONG( thisPtr->ulVolume));
1564 }
1565 /* Set dialog font to WarpSans for Warp 4 and above */
1566 if(SysQueryOSRelease()>=40) {
1567 WinSetPresParam(hwnd,
1568 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
1569 DEFAULT_DIALOG_FONT );
1570 }
1571
1572 return (MRESULT)FALSE;
1573 case WM_CHAR:
1574 // Set focus to container so the key will be processed as usual
1575 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT));
1576 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT),msg,mp1,mp2);
1577 case WM_PAINT:
1578 {
1579 HPS hps;
1580 RECTL rcl, rclSource;
1581 POINTL ptl;
1582 LONG lTemp;
1583
1584 if(allBMPs[CTRLIDX_TOPRIGHT].hbm) {
1585 hps=WinBeginPaint(hwnd, NULL, &rcl);
1586 rclSource.xLeft=0;
1587 rclSource.yBottom=0;
1588 rclSource.yTop=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cy;
1589 rclSource.xRight=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx;
1590 lTemp=rcl.xLeft/rclSource.xRight;
1591 ptl.x=lTemp*rclSource.xRight;
1592 lTemp=rcl.yBottom/rclSource.yTop;
1593 lTemp*=rclSource.yTop;
1594 //WinFillRect(hps, &rcl, CLR_RED);
1595 while(ptl.x<rcl.xRight) {
1596 ptl.y=lTemp;
1597 while(ptl.y<rcl.yTop) {/* y direction */
1598 //DosBeep(5000,100);
1599 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPRIGHT].hbm,
1600 &rclSource,
1601 (PPOINTL)&ptl,
1602 0, 0,
1603 DBM_IMAGEATTRS);
1604 ptl.y+=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cy;
1605 //DosSleep(200);
1606 };
1607 ptl.x+=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx;
1608 };
1609 WinEndPaint(hps);
1610 return (MRESULT)0;
1611 }
1612 break;
1613 }
1614 case WM_CONTROL:
1615 switch(SHORT1FROMMP(mp1))
1616 {
1617
1618 return (MRESULT)0;
1619 default:
1620 break;
1621 }
1622 break;
1623 case WM_COMMAND:
1624 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
1625 if(somIsObj(thisPtr)){
1626 switch(SHORT1FROMMP(mp1))
1627 {
1628 default:
1629 break;
1630 }
1631 }
1632 return (MRESULT) TRUE;
1633 default:
1634 break;
1635 }
1636 return WinDefDlgProc(hwnd, msg, mp1, mp2);
1637}
1638
1639/****************************************************************************/
1640/* */
1641/* This procedure is used to position the controls on the bottom frame ctrl */
1642/* when the folder is sized or a new item is added to the launchpad. */
1643/* */
1644/****************************************************************************/
1645static void _setBottomCtrlClientsPos(HWND hwnd)
1646{
1647 HWND hwndClient;
1648 SWP swp, swp2;
1649
1650 WinQueryWindowPos(hwnd, &swp2);
1651 hwndClient=WinWindowFromID(hwnd, 1234);
1652 WinQueryWindowPos(hwndClient,&swp);
1653 WinSetWindowPos(hwndClient,NULLHANDLE, 20, 0,0,0,SWP_MOVE);
1654
1655 hwndClient=WinWindowFromID(hwnd, IDST_STATUSTEXT);
1656 WinSetWindowPos(hwndClient,NULLHANDLE, swp.cx+20+20, 0, swp2.cx-4,
1657 swp2.cy-2, SWP_MOVE|SWP_SIZE|SWP_SHOW);
1658}
1659
1660/****************************************************************************/
1661/* */
1662/* This procedure handles the frame extension of the folder at the bottom */
1663/* */
1664/****************************************************************************/
1665MRESULT EXPENTRY bottomCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1666{
1667 CWMediaFolder *thisPtr;
1668
1669 switch(msg)
1670 {
1671 case WM_INITDLG :
1672 {
1673 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
1674 thisPtr=(CWMediaFolder*) PVOIDFROMMP(mp2);
1675 /* Set dialog font to WarpSans for Warp 4 and above */
1676 if(SysQueryOSRelease()>=40) {
1677 WinSetPresParam(hwnd,
1678 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
1679 DEFAULT_DIALOG_FONT );
1680 }
1681 oldStaticTextProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_STATUSTEXT), staticTextProc);
1682
1683 /* Build launchpad control */
1684 if(somIsObj(thisPtr)) {
1685 SWP swp, swp2;
1686 char text[200];
1687 thisPtr->lPad=new launchPad(hwnd, hwnd, TRUE, (WPFolder*) PVOIDFROMMP(mp2), &lplAllLPads, NULLHANDLE, 0);
1688 WinQueryWindowPos(hwnd,&swp);
1689 if(thisPtr->lPad) {
1690 thisPtr->lPad->lpSetConfiguration(chrInstallDir, MEDIAFLDR_TBID);
1691 thisPtr->lPad->lpSetLaunchPadPos(NULLHANDLE, 20, 0,
1692 30 , swp.cy-2, SWP_SIZE | SWP_MOVE);
1693 thisPtr->lPad->lpFillPad();
1694 if(!getMessage(text, IDSTR_LAUNCHPADFLYOVER, sizeof(text), queryResModuleHandle(), hwnd))
1695 strncpy(text, "Launchpad: Drop objects here", sizeof(text));
1696 text[sizeof(text)-1]=0;
1697 thisPtr->lPad->lpSetFlyOverText(text);
1698 }
1699 }
1700 /* Start timer which triggers time calculation */
1701 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd, IDTIMER_STATUS, 300);
1702 return (MRESULT)FALSE;
1703 }
1704 case WM_TIMER:
1705 if(SHORT1FROMMP(mp1)==IDTIMER_STATUS) {
1706 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd,QWL_USER);
1707 if(somIsObj(thisPtr)){
1708 THREADPARAMS* pTp;
1709 ULONG ulErr;
1710 SWP swp;
1711 char text[100];
1712
1713 _setBottomCtrlClientsPos(hwnd);
1714 getMessage(text, IDSTR_STATUSCOLLECTING, sizeof(text), queryResModuleHandle(),hwnd);
1715 WinSetWindowText(WinWindowFromID(hwnd, IDST_STATUSTEXT), text);
1716 if(!(thisPtr->wpQueryFldrFlags() & FOI_POPULATEDWITHALL)) {
1717 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd, IDTIMER_STATUS, 300);
1718 return MRFALSE;
1719 }
1720 pTp=(THREADPARAMS*)thisPtr->wpAllocMem(sizeof(THREADPARAMS), &ulErr);
1721 pTp->thisPtr=thisPtr;
1722 pTp->hwndFrame=WinQueryWindow(hwnd, QW_PARENT);
1723 _beginthread(openThreadFunc,NULL,8192*16,(void*)pTp); //Fehlerbehandlung fehlt
1724 };
1725 WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, IDTIMER_STATUS);
1726 return MRFALSE;
1727 }
1728 break;
1729 case WM_CHAR:
1730 // Set focus to container so the key will be processed as usual
1731 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT));
1732 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT),msg,mp1,mp2);
1733 case WM_CALCVALIDRECTS:
1734 {
1735 if(WinIsWindowVisible(hwnd))
1736 return handleCalcValidRects(hwnd, msg, mp1, mp2);
1737 break;
1738 }
1739 case WM_WINDOWPOSCHANGED:
1740 {
1741 /* Move the clients of the framecontrol so they keep their distance to the left */
1742 PSWP pswp=(PSWP)mp1;
1743 if((pswp->fl & SWP_SIZE)&&!(pswp->fl & SWP_SHOW)) {
1744 PSWP pswpOld;
1745 ULONG ulStyle;
1746
1747 pswpOld=pswp;
1748 pswpOld++;
1749
1750 if(!(ulStyle & WS_MINIMIZED) && !(ulStyle & WS_MAXIMIZED) ) {
1751 HWND hwndClient;
1752 SWP swp, swp2;
1753
1754 hwndClient=WinWindowFromID(hwnd, 1234);
1755 WinQueryWindowPos(hwndClient,&swp);
1756 WinSetWindowPos(hwndClient,NULLHANDLE, 20, 0,0,0,SWP_MOVE);
1757
1758 hwndClient=WinWindowFromID(hwnd, IDST_STATUSTEXT);
1759 WinSetWindowPos(hwndClient,NULLHANDLE, swp.cx+20+20, 0, pswp->cx-4-20-swp.cx,
1760 pswp->cy-2, SWP_MOVE|SWP_SIZE);
1761 }
1762 }
1763 break;
1764 }
1765 case WM_APPTERMINATENOTIFY:
1766 if(SHORT1FROMMP(mp1)==NOTIFY_STARTSTATUSTIMER)
1767 {
1768 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd, IDTIMER_STATUS, 300);
1769 return MRFALSE;
1770 }
1771 break;
1772 case WM_PAINT:
1773 {
1774 HPS hps;
1775 RECTL rcl, rclSource;
1776 POINTL ptl;
1777 LONG lTemp;
1778
1779 if(allBMPs[CTRLIDX_BOTTOM].hbm) {
1780 hps=WinBeginPaint(hwnd, NULL, &rcl);
1781 rclSource.xLeft=0;
1782 rclSource.yBottom=0;
1783 rclSource.yTop=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cy;
1784 rclSource.xRight=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cx;
1785 lTemp=rcl.xLeft/rclSource.xRight;
1786 ptl.x=lTemp*rclSource.xRight;
1787 lTemp=rcl.yBottom/rclSource.yTop;
1788 lTemp*=rclSource.yTop;
1789 while(ptl.x<rcl.xRight) {
1790 ptl.y=lTemp;
1791 while(ptl.y<rcl.yTop) {/* y direction */
1792 WinDrawBitmap(hps, allBMPs[CTRLIDX_BOTTOM].hbm,
1793 &rclSource,
1794 (PPOINTL)&ptl,
1795 0, 0,
1796 DBM_IMAGEATTRS);
1797 ptl.y+=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cy;
1798 };
1799 ptl.x+=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cx;
1800 };
1801 WinEndPaint(hps);
1802 return (MRESULT)0;
1803 }
1804 break;
1805 }
1806 default:
1807 break;
1808 }
1809 return WinDefDlgProc(hwnd, msg, mp1, mp2);
1810}
1811
1812/*************************************************************/
1813/* This dialog procedure handles the toolbar page */
1814/*************************************************************/
1815MRESULT EXPENTRY settingsToolbarOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
1816 HINI hini;
1817 HOBJECT hObject;
1818 ULONG attrFound;
1819 ULONG len;
1820 char text[250];
1821 char title[250];
1822 CWMediaFolder* thisPtr;
1823
1824 switch(msg) {
1825#if 0
1826 case WM_INITDLG :
1827 WinSetWindowULong(hwnd,QWL_USER,LONGFROMMP(mp2));
1828 thisPtr=(CWMediaFolder*)LONGFROMMP(mp2);
1829 /* We have to initialize the dialog controls with the approbiate values */
1830
1831 if(somIsObj(thisPtr)) {
1832 // Set the focus on the demo area
1833 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD));
1834
1835 // Set the background colour of the demo area
1836 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1837 PP_BACKGROUNDCOLOR,(ULONG)sizeof(RGB), &(thisPtr->rgbTBFlyBackground) );
1838 // Set the foreground colour of the demo area
1839 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1840 PP_FOREGROUNDCOLOR,(ULONG)sizeof(RGB), &(thisPtr->rgbTBFlyForeground) );
1841
1842 // Set the font of the demo area
1843 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1844 PP_FONTNAMESIZE,(ULONG)sizeof(thisPtr->chrTBFlyFontName),
1845 thisPtr->chrTBFlyFontName );
1846
1847 if(thisPtr->bTBFlyOverEnabled) {
1848 WinCheckButton(hwnd, IDCB_ENABLETBFLYOVER, 1);
1849 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),TRUE);
1850 }
1851 else {
1852 WinCheckButton(hwnd, IDCB_ENABLETBFLYOVER, 0);
1853 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),FALSE);
1854 }
1855
1856 // Set the linits for the delay spin button
1857 WinSendMsg(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),
1858 SPBM_SETLIMITS,(MPARAM)MAXDELAY,(MPARAM)0);
1859 // Set the current value for delay
1860 WinSendMsg(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),
1861 SPBM_SETCURRENTVALUE,
1862 (MPARAM)thisPtr->iTBFlyOverDelay,
1863 (MPARAM)NULL);
1864 }
1865 /* Move default buttons on Warp 4 */
1866 cwMoveNotebookButtonsWarp4(hwnd, IDPB_COLORHELP, 20);
1867 WinSetWindowULong(WinQueryWindow(hwnd, QW_PARENT), QWL_HWNDFOCUSSAVE, hwnd);
1868 return (MRESULT) TRUE;
1869 case WM_DESTROY:
1870 WinSetFocus(WinQueryWindow(hwnd, QW_PARENT), TRUE);
1871 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd , QWL_USER);
1872 if(somIsObj(thisPtr)){
1873
1874 /* The notebook closes and gets destroyed */
1875 // Query the current background colour
1876 len=WinQueryPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1877 PP_BACKGROUNDCOLOR,0,&attrFound,sizeof(thisPtr->rgbTBFlyBackground),
1878 &(thisPtr->rgbTBFlyBackground),QPF_NOINHERIT);
1879 // Query the current font
1880 len=WinQueryPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1881 PP_FONTNAMESIZE,0,&attrFound,sizeof(thisPtr->chrTBFlyFontName),
1882 thisPtr->chrTBFlyFontName,QPF_NOINHERIT);
1883 // Query the current foreground colour
1884 len=WinQueryPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1885 PP_FOREGROUNDCOLOR,0,&attrFound,sizeof(thisPtr->rgbTBFlyForeground),
1886 &(thisPtr->rgbTBFlyForeground),QPF_NOINHERIT);
1887 // Query the enable state
1888 if(WinQueryButtonCheckstate(hwnd,IDCB_ENABLETBFLYOVER) & 1)
1889 thisPtr->bTBFlyOverEnabled=1;
1890 else
1891 thisPtr->bTBFlyOverEnabled=0;
1892
1893 // Query delay value
1894 WinSendMsg(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),
1895 SPBM_QUERYVALUE,(MPARAM)&(thisPtr->iTBFlyOverDelay),
1896 MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
1897
1898 // Save data
1899 thisPtr->wpSaveImmediate();
1900 }
1901 break;
1902#if 0
1903 case WM_CONTROL:
1904 /* The window controls send WM_CONTROL messages */
1905 switch(SHORT1FROMMP(mp1))
1906 {
1907 case IDCB_ENABLETBFLYOVER:
1908 if(WinQueryButtonCheckstate(hwnd,IDCB_ENABLETBFLYOVER) & 1)
1909 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),1);
1910 else
1911 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),0);
1912 break;
1913 default:
1914 break;
1915 } // end switch(SHORT1FROMMP(mp1))
1916 return (MRESULT)0;
1917 break;
1918#endif
1919 case WM_COMMAND :
1920 switch (SHORT1FROMMP(mp1)) {
1921 // Process commands here //
1922 case IDPB_COLORUNDO:
1923 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd , QWL_USER);
1924 if(somIsObj(thisPtr)){
1925 /* The undo button was clicked */
1926 // Set the background colour of the demo area
1927 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1928 PP_BACKGROUNDCOLOR,(ULONG)sizeof(thisPtr->rgbTBFlyBackground), &(thisPtr->rgbTBFlyBackground) );
1929 // Set the foreground colour of the demo area
1930 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1931 PP_FOREGROUNDCOLOR,(ULONG)sizeof(thisPtr->rgbTBFlyForeground), &(thisPtr->rgbTBFlyForeground) );
1932
1933 // Set the font of the demo area
1934 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1935 PP_FONTNAMESIZE,(ULONG)sizeof(thisPtr->chrTBFlyFontName),
1936 thisPtr->chrTBFlyFontName );
1937
1938 if(thisPtr->bTBFlyOverEnabled) {
1939 WinCheckButton(hwnd, IDCB_ENABLETBFLYOVER, 1);
1940 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),TRUE);
1941 }
1942 else {
1943 WinCheckButton(hwnd, IDCB_ENABLETBFLYOVER, 0);
1944 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),FALSE);
1945 }
1946
1947 // Set the current value for delay
1948 WinSendMsg(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),
1949 SPBM_SETCURRENTVALUE,
1950 (MPARAM)thisPtr->iTBFlyOverDelay,
1951 (MPARAM)NULL);
1952 }
1953 break;
1954 case IDPB_COLORSTANDARD:
1955 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwnd , QWL_USER);
1956 if(somIsObj(thisPtr)){
1957 /* The default button was clicked */
1958 thisPtr->rgbTBFlyBackground.bBlue=180; // Set the default colours
1959 thisPtr->rgbTBFlyBackground.bGreen=255;
1960 thisPtr->rgbTBFlyBackground.bRed=255;
1961 thisPtr->rgbTBFlyForeground.bBlue=0;
1962 thisPtr->rgbTBFlyForeground.bGreen=0;
1963 thisPtr->rgbTBFlyForeground.bRed=0;
1964 // Set the default font
1965 if(cwQueryOSRelease()>=40)
1966 strcpy((thisPtr->chrTBFlyFontName), DEFAULT_DIALOG_FONT);
1967 else
1968 strcpy((thisPtr->chrTBFlyFontName), DEFAULT_DIALOG_FONT_WARP3);
1969
1970 // Set the background colour of the demo area
1971 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1972 PP_BACKGROUNDCOLOR,(ULONG)sizeof(RGB), &thisPtr->rgbTBFlyBackground );
1973 // Set the foreground colour of the demo area
1974 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1975 PP_FOREGROUNDCOLOR,(ULONG)sizeof(RGB), &thisPtr->rgbTBFlyForeground );
1976 // Set the font of the demo area
1977 WinSetPresParam(WinWindowFromID(hwnd, IDST_TEXTDEMOFIELD),
1978 PP_FONTNAMESIZE,(ULONG)sizeof(thisPtr->chrTBFlyFontName),
1979 thisPtr->chrTBFlyFontName );
1980
1981 WinCheckButton(hwnd, IDCB_ENABLETBFLYOVER, 1);
1982 WinEnableWindow(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),TRUE);
1983
1984 // Set the value for delay
1985 WinSendMsg(WinWindowFromID(hwnd, IDSB_TBFLYOVERDELAY),
1986 SPBM_SETCURRENTVALUE,
1987 (MPARAM)DEFAULTDELAY,
1988 (MPARAM)NULL);
1989 }
1990 break;
1991 case IDPB_COLORPALETTE:
1992 /* Colour... button was clicked */
1993 // Open the colorpalette
1994 if((hObject=WinQueryObject("<WP_HIRESCLRPAL>"))!=NULL) {
1995 WinOpenObject(hObject,OPEN_DEFAULT,TRUE);
1996 }
1997 else {//Error, can't open the palette
1998 /* Show an error msg. */
1999 /*
2000 Text: "Can't open the color palette. It may have lost it's ID. Check your INI files."
2001 Title: "CD-Creator settings"
2002 */
2003 messageBox( text, IDSTRS_NOCOLORPALETTE , sizeof(text),
2004 title, IDSTRS_MEDIAFLDRSETTINGS , sizeof(title),
2005 queryResModuleHandle(), hwnd, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE);
2006
2007 }
2008 break;
2009 case IDPB_FONTPALETTE:
2010 /* Font... button was clicked */
2011 // Open the fontpalette
2012 if((hObject=WinQueryObject("<WP_FNTPAL>"))!=NULL) {
2013 WinOpenObject(hObject,OPEN_DEFAULT,TRUE);
2014 }
2015 else {//Error, can't open the palette
2016 /* Show an error msg. */
2017 /*
2018 Text: "Can't open the font palette. It may have lost it's ID. Check your INI files."
2019 Title: "CD-Creator settings"
2020 */
2021 messageBox( text, IDSTRS_NOFONTPALETTE , sizeof(text),
2022 title, IDSTRS_MEDIAFLDRSETTINGS , sizeof(title),
2023 queryResModuleHandle(), hwnd, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE);
2024 }
2025 break;
2026 default:
2027 break;
2028 }
2029 /* Don't call WinDefDlgProc here, or the dialog gets closed */
2030 return (MRESULT) TRUE;
2031#endif
2032 default:
2033 break;
2034 }
2035 // The WinDefDlgProc() handles the rest of the messages
2036 return WinDefDlgProc(hwnd, msg, mp1, mp2);
2037}
2038
2039
2040MRESULT EXPENTRY shadowProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
2041{
2042 switch (msg)
2043 {
2044 case WM_PAINT:
2045 {
2046 HPS hps;
2047 HPS hpsMem;
2048 BITMAPINFOHEADER2 bmpIH2;
2049 PBITMAPINFO2 pbmp2;
2050 char * chrBuff;
2051 PBYTE ptr;
2052 HDC hdcMem;
2053 HBITMAP hbm;
2054 ULONG ulCx, ulCy;
2055 SWP swp;
2056
2057 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE/*&rectl*/);
2058
2059 GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
2060 WinQueryWindowPos(hwnd, &swp);
2061
2062 ulCx=swp.cx;
2063 ulCy=swp.cy;
2064
2065 bmpIH2.cbFix=sizeof(BITMAPINFOHEADER2);
2066 bmpIH2.cx=ulCx;
2067 bmpIH2.cy=ulCy;
2068 bmpIH2.cPlanes=1;
2069 bmpIH2.cBitCount=8;
2070 bmpIH2.cbImage=(((ulCx*(1<<bmpIH2.cPlanes)*(1<<bmpIH2.cBitCount))+31)/32)*bmpIH2.cy;
2071
2072 chrBuff=(char*)malloc(bmpIH2.cbImage+sizeof(BITMAPINFO2)+256*sizeof(RGB2));
2073 pbmp2=(PBITMAPINFO2)chrBuff;
2074 memset(pbmp2, 0, sizeof(BITMAPINFO2)+256*sizeof(RGB2));
2075 ptr=chrBuff+sizeof(BITMAPINFO2)+256*sizeof(RGB2);
2076
2077 pbmp2->cbFix=sizeof(BITMAPINFO2);
2078 pbmp2->cx=ulCx;
2079 pbmp2->cy=ulCy;
2080 pbmp2->cPlanes=1;
2081 pbmp2->cBitCount=8;
2082 pbmp2->cbImage=((pbmp2->cx+31)/32)*pbmp2->cy;
2083 pbmp2->ulCompression=BCA_UNCOMP;
2084 pbmp2->ulColorEncoding=BCE_RGB;
2085
2086 hdcMem=DevOpenDC(WinQueryAnchorBlock(hwnd),OD_MEMORY,"*", 0L/*4L*/, (PDEVOPENDATA)NULLHANDLE/*pszData*/, NULLHANDLE);
2087 if(hdcMem) {
2088 SIZEL sizel= {0,0};
2089
2090 hpsMem=GpiCreatePS(WinQueryAnchorBlock(hwnd), hdcMem, &sizel, PU_PELS|GPIT_MICRO|GPIA_ASSOC);
2091 if(hpsMem)
2092 {
2093 hbm=GpiCreateBitmap(hpsMem, &bmpIH2, FALSE, NULL, pbmp2);
2094 if(hbm) {
2095 HPS hpsDesktop;
2096 POINTL ptl[3]={0};
2097 RGB2 *prgb2;
2098 int a, r,g,b;
2099
2100 hpsDesktop=WinGetScreenPS(HWND_DESKTOP);
2101 GpiSetBitmap(hpsMem, hbm);
2102
2103 ptl[0].x=0;
2104 ptl[0].y=0;
2105 ptl[1].x=0+ulCx;
2106 ptl[1].y=0+ulCy;
2107
2108 ptl[2].x=swp.x;
2109 ptl[2].y=swp.y;
2110
2111 if(GpiBitBlt(hpsMem, hpsDesktop, 3, ptl , ROP_SRCCOPY, BBO_IGNORE)==GPI_ERROR)
2112 {
2113 }
2114
2115 WinReleasePS(hpsDesktop);
2116
2117 if(GpiQueryBitmapBits(hpsMem, 0, ulCy, ptr, pbmp2)==GPI_ALTERROR)
2118 {
2119 // DosBeep(500,300);
2120 }
2121
2122 prgb2=(RGB2*)(++pbmp2);
2123 for(a=0;a<256; a++, prgb2++) {
2124 r=-50;
2125 g=-50;
2126 b=-50;
2127
2128 b+=prgb2->bBlue;
2129 g+=prgb2->bGreen;
2130 r+=prgb2->bRed;
2131 if(r>255)
2132 r=255;
2133 if(r<0)
2134 r=0;
2135 prgb2->bRed=r;
2136
2137 if(g>255)
2138 g=255;
2139 if(g<0)
2140 g=0;
2141 prgb2->bGreen=g;
2142
2143 if(b>255)
2144 b=255;
2145 if(b<0)
2146 b=0;
2147 prgb2->bBlue=b;
2148 }
2149
2150 if(GpiSetBitmapBits(hpsMem, 0, ulCy, ptr, --pbmp2)!=GPI_ALTERROR)
2151 {
2152 ptl[0].x=0;
2153 ptl[0].y=0;
2154 ptl[1].x=ulCx;
2155 ptl[1].y=ulCy;
2156 ptl[2].x=0;
2157 ptl[2].y=0;
2158
2159 GpiBitBlt(hps, hpsMem, 3, ptl , ROP_SRCCOPY, BBO_IGNORE);
2160 }
2161 GpiSetBitmap(hpsMem, NULLHANDLE);
2162 GpiDeleteBitmap(hbm);
2163 }/* hbm */
2164 GpiDestroyPS(hpsMem);
2165 }/* hpsMem */
2166 DevCloseDC(hdcMem);
2167 }/* if(hdcMem) */
2168 WinEndPaint(hps);
2169 free(chrBuff);
2170 return MRFALSE;
2171 }
2172 default:
2173 break;
2174 }
2175 return (*oldProc)(hwnd,msg,mp1,mp2);
2176}
2177
2178
2179/*****************************************************************************/
2180/* New button procedure with fly over help */
2181/*****************************************************************************/
2182MRESULT EXPENTRY newButtonProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
2183{
2184 static BOOL bBubbleOn=TRUE;
2185 POINTL ptl;
2186 HPS hps;
2187 FONTMETRICS fm;
2188 LONG ulWinTextLen;
2189 POINTL aptlPoints[TXTBOX_COUNT];
2190 RECTL rcl;
2191 LONG deltaX,deltaY;
2192 RGB rgb= {200,200,0};
2193 static USHORT id=0;//Initialisation new in V1.00a
2194 RECTL rclWork;
2195 HWND hwndStore;
2196 WPObject * wpObject;
2197
2198 switch (msg)
2199 {
2200 case WM_DESTROY:
2201 WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
2202 if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
2203 hwndBubbleWindow=0;
2204 /* Stop delay timer if running */
2205 WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,WinQueryWindowUShort(hwnd,QWS_ID));
2206 break;
2207 case WM_NEWBUBBLE:
2208 ULONG bubbleEnabled;
2209 HWND hwndStore;
2210 /* we have to build a new information window */
2211 if(hwndBubbleWindow){// if(){...} new in V1.00a
2212 WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
2213 hwndBubbleWindow=NULL;
2214 }
2215 // Query the pointer position
2216 WinQueryPointerPos(HWND_DESKTOP,&ptl);
2217 WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
2218 WinQueryWindowRect(hwnd,&rclWork);
2219 if(!hwndBubbleWindow
2220 && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
2221 && bTBFlyOverEnabled) {
2222
2223 static HWND hwndBubbleClient;
2224 ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
2225 char winText[255];
2226
2227 /* Get window text (It's the object title) for size calculating */
2228 WinQueryWindowText(hwnd,sizeof(winText),winText);
2229 ulWinTextLen=(LONG)strlen(winText); // Query text length
2230
2231 /* Delete 'Returns' in object title */
2232 char *pBuchst;
2233 char *pRest;
2234 pRest=winText;
2235 while((pBuchst=strchr(pRest,13))!=NULL) {
2236 *pBuchst=' ';
2237 pBuchst++;
2238 if(*pBuchst==10)
2239 *pBuchst=' ';
2240 pRest=pBuchst;
2241 }
2242
2243 /* Create help window */
2244 hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
2245 0,
2246 &style,
2247 WC_STATIC,
2248 "",
2249 SS_TEXT|DT_CENTER|DT_VCENTER,
2250 NULLHANDLE,
2251 400,
2252 &hwndBubbleClient);
2253 hwndShadow=WinCreateWindow(HWND_DESKTOP,
2254 WC_STATIC,
2255 "",
2256 SS_TEXT|DT_CENTER|DT_VCENTER,
2257 0, 0,
2258 0, 0,
2259 hwndBubbleWindow,
2260 hwndBubbleWindow,
2261 401,
2262 NULLHANDLE,
2263 NULLHANDLE);
2264 oldProc=WinSubclassWindow(hwndShadow, shadowProc);
2265
2266 // Set the font for the help
2267 WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
2268 sizeof(chrTBFlyFontName),
2269 chrTBFlyFontName);
2270 /* Calculate text size in pixel */
2271 hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
2272 GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
2273 WinEndPaint(hps);
2274
2275 /* Set colors */
2276 WinSetPresParam(hwndBubbleClient,
2277 PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
2278 &rgbTBFlyBackground );
2279 WinSetPresParam(hwndBubbleClient,
2280 PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
2281 &rgbTBFlyForeground );
2282
2283 /* Calculate bubble positon and show bubble */
2284 WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
2285 WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
2286 aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x
2287 > rcl.xRight
2288 ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7
2289 : deltaX=0 ;
2290
2291 aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y
2292 > rcl.yTop
2293 ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
2294 : deltaY=0 ;
2295 WinSetWindowPos(hwndBubbleWindow,
2296 HWND_TOP,
2297 ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,
2298 aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
2299 aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
2300 SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
2301
2302 WinSetWindowPos(hwndShadow,
2303 hwndBubbleWindow,
2304 ptl.x+xVal+deltaX+5
2305 ,ptl.y+yVal+deltaY-5,
2306 aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
2307 aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
2308 SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
2309
2310 /* Set bubble text */
2311 WinSetWindowText(hwndBubbleClient,winText);
2312 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35);
2313 } // end if(!hwndBubbleWindow)
2314 break;
2315 case WM_MOUSEMOVE:
2316 USHORT tempID;
2317 ULONG delayValue;
2318 delayValue=250;
2319
2320 tempID=WinQueryWindowUShort(hwnd,QWS_ID);/* get the id of the window under the pointer */
2321 if(id!=tempID) { // New Button?
2322 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
2323 id=tempID; // Save ID
2324 }
2325 else {
2326 if(!hwndBubbleWindow)WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
2327 }
2328 break;
2329 case WM_TIMER:
2330 switch (SHORT1FROMMP(mp1))
2331 {
2332 case 1: //Intervall timer
2333 /* Test pointer position */
2334 WinQueryPointerPos(HWND_DESKTOP,&ptl);
2335 WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
2336 WinQueryWindowRect(hwnd,&rclWork);
2337 if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
2338 { // Button has changed
2339 WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1); // stop the running timer
2340 if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */
2341 hwndBubbleWindow=0;
2342 id=0;
2343 }
2344 break;
2345 default:// delay over
2346 if (SHORT1FROMMP(mp1)==WinQueryWindowUShort(hwnd,QWS_ID)) {//our own timer. It has got the window id
2347 WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,SHORT1FROMMP(mp1));//Stop the delay timer
2348 /* Check the pointer position */
2349 WinQueryPointerPos(HWND_DESKTOP,&ptl);
2350 WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
2351 WinQueryWindowRect(hwnd,&rclWork);
2352 if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
2353 WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
2354 return (MRESULT)FALSE;
2355 }
2356 break;
2357 }
2358 break;
2359
2360 }
2361 // call the original button procedure to handle the rest of the messages
2362 return (*oldButtonProc2)(hwnd,msg,mp1,mp2);
2363};
2364
Note: See TracBrowser for help on using the repository browser.