source: trunk/mediafolder/c/mediafldr/mediafolderoverridenwpmethods.cpp@ 3

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

Import modifications from cwmm-eCS-Refresh-13_05_05.zip dated 2005-05-13

File size: 52.4 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 2002
3 *
4 * It's part of the Media-Folder distribution
5 */
6/*
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#define INCL_DOSERRORS
23#define INCL_DOSERRORS
24#define INCL_GPIBITMAPS
25
26#include "mediafolder.hh"
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include "mediafolderres.h"
31#include "menufolder.hh"
32
33#include "sys_funcs.h"
34
35/* typedef for somTP_MMAudio_cwmmQueryTrackInfo */
36/* For calling the method in the CWAudio class. Linking to the DLL would require the
37 new audio classes. By dynamically querying the method the media folder works without
38 installing the audio classes. */
39#include "cwmmquerytrackinfo.h"
40
41extern LOADEDBITMAP allBMPs[];
42extern somTD_MMAudio_cwmmQueryTrackInfo methodPtr;
43
44BOOL g_fRegisteredWindowClass=FALSE;
45ULONG g_ulFrameDataOffset=0;
46
47/* The following offsets will be calclated in wpOpen() */
48ULONG ulQWP_CONTAINERPROC=0;
49ULONG ulQWP_THISPTR=4;
50ULONG ulQWL_TOPCTRLHWND=8;
51ULONG ulQWL_BOTTOMCTRLHWND=12;
52ULONG ulQWL_RIGHTCTRLHWND=16;
53ULONG ulQWL_LEFTCTRLHWND=20;
54
55PFNWP pfnwpGenericFrame;
56
57void errorResource();
58ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
59 char* title, ULONG ulTitleID, LONG lSizeTitle,
60 HMODULE hResource, HWND hwnd, ULONG ulFlags);
61void getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
62void sendCommand(char *chrObject, char* command);
63HMODULE queryResModuleHandle(void);
64
65MRESULT EXPENTRY topCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
66MRESULT EXPENTRY rightCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
67MRESULT EXPENTRY leftCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
68MRESULT EXPENTRY bottomCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
69MRESULT EXPENTRY mediaFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
70MRESULT EXPENTRY mediaFldrContainerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
71/* This function sets the repeat button checkstate */
72void winCheckRepeatButton(CWMediaFolder *thisPtr);
73/* This function sets the position of the volume slider */
74void winSetVolumeSlider(CWMediaFolder *thisPtr);
75HWND playTimeControlFromFrameHWND(HWND hwndFrame);
76HWND bottomControlFromFrameHWND(HWND hwndFrame);
77HWND playControlDialogFromFrameHWND(HWND hwndFrame);
78HWND topControlFromFrameHWND(HWND hwndFrame);
79
80extern void _Optlink playThreadFunc (void *arg);/* Every folder has one running play thread to handle play commands */
81
82MRESULT cwInsertMenuSeparator(int iPosition, HWND hwndMenu, HWND hwndSubMenu);
83
84SOMClass* somhlpQueryMMAudioClass(void);
85SOMClass* somhlpGetSomClass(char* chrClassName);
86BOOL somhlpQueryCWAudioMethodPtr(CWMediaFolder *thisPtr);
87
88/* ID tag defines */
89#define IDINFO_NAME 1
90#define IDINFO_ARTIST 2
91#define IDINFO_ALBUM 3
92#define IDINFO_YEAR 4
93#define IDINFO_COMMENT 5
94#define IDINFO_GENRE 6
95
96#define IDINFO_PLAYTIME 7
97#define IDINFO_BPS 8
98#define IDINFO_SAMPLERATE 9
99#define IDINFO_CHANNELS 10
100
101#define IDINFO_LASTINFO 10
102
103/***************************************************************/
104/* */
105/* This thread calculates the size of the audio files in this */
106/* folder. It is started by the status line dialog after the */
107/* folder is opened. */
108/* */
109/***************************************************************/
110void _Optlink openThreadFunc (void *arg)
111{
112 HAB hab;
113 HMQ hmq;
114 QMSG qmsg;
115 THREADPARAMS* tPt;
116 CWMediaFolder *thisPtr;
117 MMAudio* cwAudio;
118
119 tPt=(THREADPARAMS*) arg;
120 if(!tPt)
121 return;
122 thisPtr=(CWMediaFolder*)tPt->thisPtr; //Pointer auf CWMediaFolder-Object
123 if(!somIsObj(thisPtr))
124 return;
125
126 hab=WinInitialize(0);
127 if(hab) {
128 hmq=WinCreateMsgQueue(hab,0);
129 if(hmq) {
130 WPObject *wpObject;
131 WPObject *fsObject;
132 HWND hwndContainer;
133 CNRINFO cnrInfo;
134 char text[100];
135 char time[50];
136 int iNum=0;
137 somId mySomId;
138 SOMClass *cwAudioClass=somhlpGetSomClass("MMAudio");
139 ULONG ulSize=0;
140 ULONG ulSecs=0;
141
142 TRY_LOUD(MEDIAFLDR_OPEN_THREAD) {
143 /* Wait until folder is populated */
144 while(!(thisPtr->wpQueryFldrFlags() & FOI_POPULATEDWITHALL))
145 DosSleep(300);
146
147 hwndContainer=WinWindowFromID(tPt->hwndFrame, FID_CLIENT);
148 WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
149 MPFROMLONG(sizeof(cnrInfo)));
150
151 /* Get class object of MMAudio. We need it so we can check if a file is an audio file. */
152 if(somIsObj(cwAudioClass)) {
153 /* We have the class object */
154 char chrBuf[2];
155 /* Get first object in the container */
156 wpObject=thisPtr->wpQueryContent(NULLHANDLE, QC_FIRST);
157 /* Works only for size < 4Gb up to now */
158 while(wpObject)
159 {
160 /* Follow shadows to the filesystem object (if any) */
161 if((fsObject=thisPtr->cwGetFileSystemObject(wpObject))!=NULLHANDLE){/* Filesystem object or NULL */
162 /* Check if the file is an audio file */
163 if(fsObject->somIsA(cwAudioClass)) {
164 /* It's an audio file */
165 if(!methodPtr)
166 somhlpQueryCWAudioMethodPtr(thisPtr);
167 ulSize+=((WPFileSystem*)fsObject)->wpQueryFileSize();
168 iNum++;
169 if(methodPtr)/* Query playtime in secs */
170 ulSecs+=methodPtr((MMAudio*)fsObject, NULLHANDLE, 0, IDINFO_PLAYTIME);
171 }
172 }
173 wpObject=thisPtr->wpQueryContent(wpObject, QC_NEXT);
174 };/* while(wpObject) */
175
176 if(thisPtr->mfData) {
177 thisPtr->mfData->ulTotalTime=ulSecs;
178 thisPtr->mfData->ulNumTracks=iNum;
179 thisPtr->mfData->ulSize=ulSize;
180 thisPtr->mfData->bOpened=TRUE;
181 }
182 /* Set status line text */
183 thisPtr->cwSetStatusLineText(NULLHANDLE);
184 }/* if(somIsObj(cwAudioClass)) */
185 else
186 {
187 /* Error */
188 /* !!!!!!!!!!! Insert messagebox here. !!!!!!!!!!!!!!!*/
189 }
190 }
191 CATCH(MEDIAFLDR_OPEN_THREAD)
192 {
193 SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
194 __FUNCTION__, __FILE__, __LINE__);
195 } END_CATCH;
196
197 WinDestroyMsgQueue(hmq);
198 }
199 WinTerminate(hab);
200 }
201
202 thisPtr->wpFreeMem((PBYTE)tPt);
203}
204
205
206BOOL CWMediaFolder::wpAddToContent(WPObject* Object)
207{
208 WPFileSystem *fsObject;
209 char time[200];
210 ULONG ulSecs;
211 BOOL rc;
212 static int iCounter=0;
213
214 rc=CWProgFolder::wpAddToContent(Object);
215
216 if(mfData)
217 if(mfData->bOpened)/* Only post notification if the folder was already populated. On first
218 opening a separate thread calculates the contents. */
219 WinPostMsg(hwndBottom, WM_APPTERMINATENOTIFY,MPFROMSHORT(NOTIFY_STARTSTATUSTIMER), 0L);
220
221 iCounter++;
222 if(iCounter==10) {
223 DosSleep(30);/* Yield processor to another thread to prevent WPS blocking */
224 iCounter=0;
225 }
226 return rc;
227 /* On first opening a separate thread calculates the playtime. Doing it this way we don't
228 update the statusbar for every single object. */
229}
230
231BOOL CWMediaFolder::wpDeleteFromContent(WPObject* Object)
232{
233 WPFileSystem *fsObject;
234 char time[200];
235 ULONG ulSecs;
236
237 if(!methodPtr)
238 somhlpQueryCWAudioMethodPtr(this);
239
240 if(methodPtr){
241 if((fsObject=(WPFileSystem*)cwGetFileSystemObject(Object))!=NULLHANDLE){/* Filesystem object or NULL */
242 if(mfData) {
243 /* Query playtime in secs */
244 mfData->ulTotalTime-=methodPtr((MMAudio*)fsObject, NULLHANDLE, 0, IDINFO_PLAYTIME);
245 mfData->ulNumTracks-=1;
246 mfData->ulSize-=fsObject->wpQueryFileSize();
247 cwSetStatusLineText(NULLHANDLE);
248 }
249 }
250 }
251 return CWProgFolder::wpDeleteFromContent(Object);
252}
253
254HWND CWMediaFolder::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
255{
256 HWND hwnd;
257 SIZEL sizel={0};
258 HWND myFrameCtrlHWND;
259 RECTL rectl;
260 MENUITEM mi={0};
261 HWND hwndMenu;
262 int iItemCount=0;
263 char text[200];
264 HMODULE hResource=queryResModuleHandle();
265
266 /* Reregister wpFolder window class on first opening */
267 /* We need this private code to have some private
268 window words */
269 if(!g_fRegisteredWindowClass)
270 {
271 CLASSINFO ci;
272
273 if(WinQueryClassInfo(WinQueryAnchorBlock(HWND_DESKTOP),
274 (PSZ)"wpFolder window",
275 &ci))
276 {
277 g_ulFrameDataOffset=ci.cbWindowData;
278 //g_pfnwpOrgFrameProc=ci.pfnWindowProc;
279 if (WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP),
280 (PSZ)"wpFolder window",
281 ci.pfnWindowProc,
282 ci.flClassStyle,
283 ci.cbWindowData + MFLDR_WINDOWBYTES))
284 {
285 /* */
286 ulQWP_CONTAINERPROC+=g_ulFrameDataOffset;
287 ulQWP_THISPTR+=g_ulFrameDataOffset;
288 ulQWL_TOPCTRLHWND+=g_ulFrameDataOffset;
289 ulQWL_BOTTOMCTRLHWND+=g_ulFrameDataOffset;
290 ulQWL_LEFTCTRLHWND+=g_ulFrameDataOffset;
291 ulQWL_RIGHTCTRLHWND+=g_ulFrameDataOffset;
292 g_fRegisteredWindowClass=TRUE;
293 }
294 }
295 }
296
297 /* Prevent opening in tree view */
298 if(ulView==OPEN_TREE || ulView==OPEN_CONTENTS)
299 return NULLHANDLE;
300
301#if 0
302 for(pViewItem=wpFindViewItem(VIEW_ANY, NULLHANDLE); pViewItem; pViewItem=wpFindViewItem(VIEW_ANY, pViewItem))
303 iItemCount+=1;
304#endif
305
306 /* Only one open window for now */
307 if(hwndMFldrFrame && ulView!=OPEN_SETTINGS)
308 return NULLHANDLE;
309
310 /* Call parent to build folder window */
311 hwnd=CWProgFolder::wpOpen(hwndCnr, ulView, ulParam);
312
313 /* Save this ptr */
314 // WinSetWindowULong( hwnd, ulQWP_THISPTR, (ULONG)this);
315
316 /* Only subclass folder frames, not settings notebooks */
317 if(ulView!=OPEN_SETTINGS){
318 if(!hResource) {
319 errorResource();
320 return hwnd;
321 }
322
323 /* Save this ptr */
324 WinSetWindowULong( hwnd, ulQWP_THISPTR, (ULONG)this); /* Moved from outside the if clause */
325
326 hwndMFldrFrame=hwnd;
327
328 TRY_LOUD(MEDIAFLDR_OPEN) {
329 THREADPARAMS* pTp;
330 ULONG ulErr;
331 BOOL bDisabled=FALSE;
332
333 if(!(ulFlags & FLAG_ALREADYSIZED)) {
334 /* Make sure on first open the container is visible */
335 SWP swp;
336 /* Prevent window flickering while resizing */
337 WinEnableWindowUpdate(hwnd, FALSE);
338 bDisabled=TRUE;
339 WinQueryWindowPos(hwnd, &swp);
340 WinSetWindowPos(hwnd, NULLHANDLE, swp.x, swp.y-100, swp.cx, swp.cy+100, SWP_SIZE|SWP_MOVE);
341 ulFlags|=FLAG_ALREADYSIZED;
342 }
343
344 /* Build new menu entries. */
345 myFrameCtrlHWND=WinWindowFromID(hwnd,FID_MENU);//Get menu hwnd
346 if(WinIsWindow(WinQueryAnchorBlock(hwnd), myFrameCtrlHWND)) {
347 /* Menu bar found */
348 if(WinSendMsg(myFrameCtrlHWND,MM_QUERYITEM,MPFROM2SHORT(ID_MBMENUSKRIPTS,FALSE),MPFROMP(&mi))) {
349 /* Script menu is inserted so WPS-Wizard is installed */
350 hwndMenu=mi.hwndSubMenu;
351 if(hwndMenu){
352 // ULONG ulItemId;
353 // ulItemId=cwInsertUserMenuItems(hwndMenu, SKRIPTFOLDER_MEDIAFOLDER, FIRSTUSERITEM, FALSE);
354 /* sprintf(text, " %x",ulItemId);
355 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "",
356 1234, MB_OK|MB_MOVEABLE);
357 */
358
359 /* The class specific skript menu is inserted in class CWFolder */
360 /* Query the number of items in the menubar */
361 iItemCount=(int)WinSendMsg(hwndMenu,MM_QUERYITEMCOUNT,(MPARAM)0,
362 (MPARAM)0);
363 if(iItemCount)
364 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_MEDIAFOLDER, FIRSTUSERITEM, TRUE);
365 else
366 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_MEDIAFOLDER, FIRSTUSERITEM, FALSE);
367 }
368 }
369#ifndef ECS
370 else {
371 /* Load the user menu from the resource if WPS-Wizard is not installed. If installed the menu item
372 is added by WPS-Wizzard. */
373 hwndMenu=WinLoadMenu(myFrameCtrlHWND,hResource, ID_MBMENUSKRIPTS);
374 if(hwndMenu){
375 // ULONG ulItemId;
376 // ulItemId=cwInsertUserMenuItems(hwndMenu, SKRIPTFOLDER_MEDIAFOLDER, FIRSTUSERITEM, FALSE);
377 /* sprintf(text, " %x",ulItemId);
378 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "",
379 1234, MB_OK|MB_MOVEABLE);
380 */
381 /* Query the number of items in the menu */
382 iItemCount=(int)WinSendMsg(hwndMenu,MM_QUERYITEMCOUNT,(MPARAM)0,
383 (MPARAM)0);
384
385 if(iItemCount)
386 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_MEDIAFOLDER, FIRSTUSERITEM, TRUE);
387 else
388 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_MEDIAFOLDER, FIRSTUSERITEM, FALSE);
389
390 /* Query the number of items in the menubar */
391 iItemCount=(int)WinSendMsg(myFrameCtrlHWND,MM_QUERYITEMCOUNT,(MPARAM)0,
392 (MPARAM)0);
393
394 /* Fill the MENUITEM structure */
395 mi.iPosition=iItemCount-1;
396 mi.afStyle=MIS_TEXT|MIS_SUBMENU;
397 mi.id=ID_MBMENUSKRIPTS;
398 mi.afAttribute=NULL;
399 mi.hwndSubMenu=hwndMenu;
400 mi.hItem=NULL;
401 /* Add the Misc-tools item to the folder menubar */
402 /* Text: "Skripts and tools" */
403 getMessage(text, IDSTR_MENUSKRIPTS,sizeof(text), hResource, hwnd);
404 WinSendMsg(myFrameCtrlHWND,MM_INSERTITEM,MPFROMP(&mi),
405 (MPARAM)text);
406 }/* end of if(hwndMenu) */
407 }
408#endif
409 }/* menu hwnd */
410
411 //#if 0
412 /* Subclass container for tabbing */
413 myFrameCtrlHWND=WinWindowFromID(hwnd,FID_CLIENT);//Get container hwnd
414 if(myFrameCtrlHWND){
415 PFNWP pfnwpContainer;
416 pfnwpContainer=WinSubclassWindow(myFrameCtrlHWND, mediaFldrContainerProc);
417 /* Save container proc in frame window words */
418 WinSetWindowULong( hwnd, ulQWP_CONTAINERPROC, (ULONG)pfnwpContainer);
419 }
420
421 //#endif
422 /* Now add the framecontrols */
423
424 /* This is the Top-frameCtrl. */
425 /* Load the dialog from the resource. The object pointer of this
426 folder is given to the dialog procedure (this). In WM_INITDLG
427 the procedure saves this pointer for later use. */
428 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,topCtrlDialogProc,hResource,IDDLG_TOPFRAME ,this);
429 /* Save the HWND in the Window words */
430 WinSetWindowULong( hwnd, ulQWL_TOPCTRLHWND, myFrameCtrlHWND);
431
432 if(myFrameCtrlHWND){
433 /* Query the size of the dialog */
434 WinQueryWindowRect(myFrameCtrlHWND, &rectl);
435 /* It's the top dialog so we need the height but not the width. The width
436 is always the width of the folder. */
437 sizel.cy=allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy;
438 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
439 FCTL_TOP means put it at the top of the folder.
440 After calling cwUpdateFrame(hwnd) it will be visible */
441 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_TOP,0);
442 }
443
444
445 /* Load the dialog from the resource. The object pointer of this
446 folder is given to the dialog procedure (this). In WM_INITDLG
447 the procedure saves this pointer for later use. */
448 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,leftCtrlDialogProc,hResource,IDDLG_LEFTFRAME ,this);
449 /* Save the HWND in the Window words */
450 WinSetWindowULong( hwnd, ulQWL_LEFTCTRLHWND, myFrameCtrlHWND);
451
452 if(myFrameCtrlHWND){
453 /* Query the size of the dialog */
454 WinQueryWindowRect(myFrameCtrlHWND, &rectl);
455 /* It's the right dialog so we need the width but not the height. */
456 sizel.cx=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx-1-7-2;//rectl.xRight-rectl.xLeft;
457 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
458 FCTL_RIGHT means put it at the RIGHT of the folder.
459 After calling cwUpdateFrame(hwnd) it will be visible */
460 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_LEFT, FCTL_POSABOVE|FCTL_POSBELOW);
461 }
462
463 /* Load the dialog from the resource. The object pointer of this
464 folder is given to the dialog procedure (this). In WM_INITDLG
465 the procedure saves this pointer for later use. */
466 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,rightCtrlDialogProc,hResource,IDDLG_FRAMERIGHT ,this);
467 /* Save the HWND in the Window words */
468 WinSetWindowULong( hwnd, ulQWL_RIGHTCTRLHWND, myFrameCtrlHWND);
469
470 if(myFrameCtrlHWND){
471 CNRINFO cnrInfo;
472 HWND hwndContainer;
473 PVIEWITEM pView;
474
475 /* Query the size of the dialog */
476 WinQueryWindowRect(myFrameCtrlHWND, &rectl);
477 /* It's the right dialog so we need the width but not the height. */
478 sizel.cx=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx-1-7-2;// rectl.xRight-rectl.xLeft;
479 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
480 FCTL_RIGHT means put it at the RIGHT of the folder.
481 After calling cwUpdateFrame(hwnd) it will be visible */
482 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_RIGHT, FCTL_POSABOVE|FCTL_POSBELOW);
483
484 hwndContainer=WinWindowFromID(myFrameCtrlHWND, IDCNR_PLAYLIST);
485 WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
486 MPFROMLONG(sizeof(cnrInfo)));
487 }/* if(hwndRight) */
488
489
490 /* Load the dialog from the resource. The object pointer of this
491 folder is given to the dialog procedure (this). In WM_INITDLG
492 the procedure saves this pointer for later use. */
493 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,bottomCtrlDialogProc,hResource,IDDLG_BOTTOMFRAME ,this);
494 /* Save the HWND in the instance data */
495 hwndBottom=myFrameCtrlHWND;
496 /* Save the HWND in the Window words */
497 WinSetWindowULong( hwnd, ulQWL_BOTTOMCTRLHWND, myFrameCtrlHWND);
498
499 if(hwndBottom){
500 /* Query the size of the dialog */
501 WinQueryWindowRect(hwndBottom,&rectl);
502 //sizel.cy=20;
503 sizel.cy=rectl.yTop-rectl.yBottom-2;
504 // sizel.cy=allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy;
505 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
506 FCTL_TOP means put it at the top of the folder.
507 After calling cwUpdateFrame(hwnd) it will be visible */
508 cwAddFrameCtl(hwnd, hwndBottom, sizel, FCTL_BOTTOM,0);
509 }
510
511 if(bDisabled) {
512 WinEnableWindowUpdate(hwnd, TRUE);
513 }
514
515 /* Refresh frame to show the new framecontrols */
516 cwUpdateFrame(hwnd);
517
518 pfnwpFrame=WinSubclassWindow(hwnd, mediaFrameProc);
519 pfnwpGenericFrame=pfnwpFrame;
520
521 /* Start play thread handling user input */
522 pTp=(THREADPARAMS*)this->wpAllocMem(sizeof(THREADPARAMS), &ulErr);
523 if(pTp) {
524 pTp->thisPtr=this;
525 pTp->hwndFrame=hwnd;
526 _beginthread(playThreadFunc,NULL,8192*16,(void*)pTp); //Fehlerbehandlung fehlt
527 }
528 }
529 CATCH(MEDIAFLDR_OPEN)
530 {
531 SysWriteToTrapLog("\nTrap occured in %s, file: %s above line %d.\n",
532 __FUNCTION__, __FILE__, __LINE__);
533
534 } END_CATCH;
535 }
536 return hwnd;
537}
538
539/**************************************************************/
540/* */
541/* This thread handles the about dialog. */
542/* */
543/**************************************************************/
544void _Optlink aboutThreadFunc (void *arg)
545{
546 HAB hab;
547 HMQ hmq;
548 QMSG qmsg;
549 CWMediaFolder *thisPtr;
550
551 thisPtr=(CWMediaFolder*)arg; //Pointer auf CWMediaFolder-Object
552 hab=WinInitialize(0);
553 if(hab) {
554 hmq=WinCreateMsgQueue(hab,0);
555 if(hmq) {
556 /* Call the method from CWProgFolder */
557 thisPtr->cwShowAboutDlg(queryResModuleHandle(), IDDLG_ABOUT);
558 WinDestroyMsgQueue(hmq);
559 }
560 WinTerminate(hab);
561 }
562}
563
564/**************************************************************/
565/* */
566/* Override method: */
567/* */
568/**************************************************************/
569BOOL CWMediaFolder::wpSetupOnce(PSZ pSetupString)
570{
571 BOOL rcParent=FALSE;
572 char buffer[CCHMAXPATH];
573 ULONG bufferSize;
574 int iIndex;
575
576 rcParent=CWProgFolder::wpSetupOnce(pSetupString);
577
578 /* Doing our own setup here if not done by the user. */
579 /* Set volume */
580 bufferSize=sizeof(buffer);
581 if(!wpScanSetupString(pSetupString, MEDIAFLDR_VOLUME, buffer,&bufferSize))
582 {
583 ulVolume=70;
584 /* Set position of slider bar */
585 winSetVolumeSlider(this);
586 }
587
588 bufferSize=sizeof(buffer);
589 if(!wpScanSetupString(pSetupString,"DEFAULTVIEW",buffer,&bufferSize))
590 wpSetup( "DEFAULTVIEW=DETAILS");/* Fill in defaults */
591
592 bufferSize=sizeof(buffer);
593 if(!wpScanSetupString(pSetupString,"ICONVIEW",buffer,&bufferSize))
594 wpSetup( "ICONVIEW=NONFLOWED,MINI");/* Fill in defaults */
595
596 /* Size and position of the folder window */
597 bufferSize=sizeof(buffer);
598 if(!wpScanSetupString(pSetupString,"ICONVIEWPOS",buffer,&bufferSize))
599 wpSetup( "ICONVIEWPOS=20,10,60,75");/* Fill in defaults */
600
601 /* Set folder details- and sortclass to CWAudioShadow so track infos are shown */
602 bufferSize=sizeof(buffer);
603 if(!wpScanSetupString(pSetupString,"DETAILSCLASS",buffer,&bufferSize))
604 wpSetup("DETAILSCLASS=CWAudioShadow");/* Fill in defaults */
605
606 bufferSize=sizeof(buffer);
607 if(!wpScanSetupString(pSetupString,"SORTCLASS",buffer,&bufferSize))
608 wpSetup("SORTCLASS=CWAudioShadow");/* Fill in defaults */
609
610 /* This works only on Warp 4 and above */
611 bufferSize=sizeof(buffer);
612 if(!wpScanSetupString(pSetupString,"DETAILSTODISPLAY",buffer,&bufferSize))
613 /* This works only on Warp 4 and above */
614 wpSetup("DETAILSTODISPLAY=0,1,4,12,13,14,15,16,17,18,19,20,21");/* Fill in defaults */
615
616 /* This works only on Warp 4 and above */
617 bufferSize=sizeof(buffer);
618 if(!wpScanSetupString(pSetupString,"SORTBYATTR",buffer,&bufferSize))
619 /* This works only on Warp 4 and above */
620 wpSetup("SORTBYATTR=6,24,25,26,27,28,29,30,31,32,33");/* Fill in defaults */
621
622 return rcParent;
623}
624
625static HWND _findOpenMediaFldrViewHWND(CWMediaFolder *thisPtr)
626{
627 PVIEWITEM pViewItem;
628
629 /* Check if we close a settings view or a folder view. */
630 pViewItem=thisPtr->wpFindViewItem(VIEW_DETAILS|VIEW_CONTENTS, NULLHANDLE);
631 if(pViewItem)
632 return pViewItem->handle;
633
634 return NULLHANDLE;
635}
636
637/**************************************************************/
638/* */
639/* Override method: */
640/* */
641/**************************************************************/
642BOOL CWMediaFolder::wpSetup(PSZ pSetupString)
643{
644 char buffer[CCHMAXPATH];
645 ULONG bufferSize;
646 int tid;
647
648 bufferSize=sizeof(buffer);
649 if(wpScanSetupString(pSetupString, MEDIAFLDR_PLAY_FIRST, buffer,&bufferSize))
650 {
651 HWND hwndFrame=_findOpenMediaFldrViewHWND(this);
652 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame)) {
653 HWND hwndCnr=WinWindowFromID(hwndFrame, FID_CLIENT);
654 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndCnr)) {
655 PRECORDCORE prc;
656 prc=(PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, 0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
657 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(prc), MPFROM2SHORT(TRUE, CRA_SELECTED));
658 }
659 cwPlayAudioFile( hwndFrame, PLAY_FIRST);
660 }
661 }
662 bufferSize=sizeof(buffer);
663 if(wpScanSetupString(pSetupString, MEDIAFLDR_PLAY, buffer,&bufferSize))
664 {
665 HWND hwndFrame=_findOpenMediaFldrViewHWND(this);
666 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame))
667 cwPlayAudioFile( hwndFrame, PLAY_FIRST);
668 }
669 bufferSize=sizeof(buffer);
670 if(wpScanSetupString(pSetupString, MEDIAFLDR_STOP, buffer,&bufferSize))
671 {
672 HWND hwndFrame=_findOpenMediaFldrViewHWND(this);
673 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame))
674 cwStopAudioFile( hwndFrame);
675 }
676 bufferSize=sizeof(buffer);
677 if(wpScanSetupString(pSetupString, MEDIAFLDR_NEXT, buffer,&bufferSize))
678 {
679 HWND hwndFrame=_findOpenMediaFldrViewHWND(this);
680 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame))
681 cwPlayAudioFile( hwndFrame, PLAY_NEXT);
682 }
683 bufferSize=sizeof(buffer);
684 if(wpScanSetupString(pSetupString, MEDIAFLDR_PREV, buffer,&bufferSize))
685 {
686 HWND hwndFrame=_findOpenMediaFldrViewHWND(this);
687 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame))
688 cwPlayAudioFile( hwndFrame, PLAY_PREV);
689 }
690
691 /* Set volume */
692 bufferSize=sizeof(buffer);
693 if(wpScanSetupString(pSetupString, MEDIAFLDR_VOLUME, buffer,&bufferSize))
694 {
695 ulVolume=atol(buffer);
696 if(ulVolume<0)
697 ulVolume=0;
698 else if(ulVolume>100)
699 ulVolume=100;
700 /* Set position of slider bar */
701 winSetVolumeSlider(this);
702 }
703 /* Set repeat */
704 bufferSize=sizeof(buffer);
705 if(wpScanSetupString(pSetupString, MEDIAFLDR_REPEAT, buffer,&bufferSize))
706 {
707 switch(atol(buffer))
708 {
709 case 0:
710 ulFlags&=~FLAG_REPEAT;
711 winCheckRepeatButton(this);
712 break;
713 case 1:
714 ulFlags|=FLAG_REPEAT;
715 winCheckRepeatButton(this);
716 break;
717 }
718 ulVolume=atol(buffer);
719 }
720
721 /* Set object window HWND */
722 bufferSize=sizeof(buffer);
723 if(wpScanSetupString(pSetupString, "M3UOBJECTWINDOW", buffer,&bufferSize))
724 {
725 hwndObject=atol(buffer);
726 }
727
728 /* Set object pointer to M3U-File */
729 bufferSize=sizeof(buffer);
730 if(wpScanSetupString(pSetupString, "M3UOBJECTHANDLE", buffer,&bufferSize))
731 {
732 WPObject *wpObject;
733
734 wpObjM3UFile=NULLHANDLE;
735 wpObject=(WPObject*)atol(buffer);
736 if(somIsObj(wpObject))
737 wpObjM3UFile=wpObject;
738 }
739
740 /* Insert tracks */
741 bufferSize=sizeof(buffer);
742 if(wpScanSetupString(pSetupString, "INSERTTRACKS", buffer,&bufferSize))
743 {
744 cwInsertAllTracks(NULLHANDLE);
745 }
746
747 /* FIXME: Use immediate parent here !!!! */
748 return CWProgFolder::wpSetup(pSetupString);
749}
750
751
752/**************************************************************/
753/* */
754/* Added with V0.2.8 (07.09.2003) */
755/* */
756/* This method is only overriden to set a flag in the instance*/
757/* data so the wpInsertSettingsPage() method knows when */
758/* the details page is inserted. */
759/* */
760/* This is done because the details page needs a major tab */
761/* when the icon page is removed. The necessary style bit */
762/* is set in wpInsertSettingsPage(). */
763/* */
764/**************************************************************/
765ULONG CWMediaFolder::wpAddFolderView3Page(HWND hwndNotebook)
766{
767 ULONG rc;
768
769 /* Mark in the instance data from where we're coming */
770 ulPrivFlags|=MFLDR_CURACTION_ADDFOLDERVIEW3;
771
772 rc=CWProgFolder::wpAddFolderView3Page(hwndNotebook);
773
774 ulPrivFlags&= ~MFLDR_CURACTION_ADDFOLDERVIEW3;
775 return rc;
776}
777
778/**************************************************************/
779/* */
780/* Override method: Remove the Icon view settings page. */
781/* */
782/* Added with V0.2.8 (07.09.2003) */
783/**************************************************************/
784ULONG CWMediaFolder::wpAddFolderView1Page(HWND hwndNotebook)
785{
786 /*
787 Removing this page also means removing the XWorkplace
788 view page. It would be possible to call the XWP method
789 directly to insert it's page but unfortunately XWP is a moving
790 target without frozen interfaces/methods so every new
791 XWP release is likely to break any code relying on certain
792 XWP features so nothing is done to keep the XWP pages.
793 */
794 return SETTINGS_PAGE_REMOVED;
795}
796
797/**************************************************************/
798/* */
799/* Override method: Remove the tree view settings page. */
800/* */
801/**************************************************************/
802ULONG CWMediaFolder::wpAddFolderView2Page(HWND hwndNotebook)
803{
804 return SETTINGS_PAGE_REMOVED;
805}
806
807/**************************************************************/
808/* */
809/* Added with V0.2.8 (07.09.2003) */
810/* */
811/* Overriden to give the details view page a major tab */
812/* because the icon view page is removed. */
813/* */
814/* */
815/**************************************************************/
816ULONG CWMediaFolder::wpInsertSettingsPage(HWND hwndNotebook, PPAGEINFO ppageinfo)
817{
818 somId mySomId;
819
820 /* V0.2.8 (07.09.2003):
821
822 Removing the icon page isn't that easy because if doing so we lose the major tab
823 and the details page will become a second background page.
824 So in wpAddFolderView3Page() we set a flag in the instance data telling us here
825 from where we are coming. The BKA_MAJOR style bit is switched on so
826 a tab is displayed.
827 This is only part of the solution because normaly there's no name for
828 the details view page. So a string must be loaded and inserted into the
829 ppageinfo.
830
831 */
832 if(ulPrivFlags & MFLDR_CURACTION_ADDFOLDERVIEW3) /* Check if called from wpAddFolderView3Page() */
833 {
834 char chr[50]="~View";
835
836 /* Get title for the page */
837 getMessage(chr, IDSTR_VIEWPAGENAME, sizeof(chr), queryResModuleHandle(), hwndNotebook);
838
839 ppageinfo->usPageStyleFlags|=BKA_MAJOR; /* Switch on major tab */
840 ppageinfo->pszName=chr;
841 }
842 /*
843
844 Climb up the list of parents to make sure we call the right
845 method if the parent was replaced. Otherwise we may skip a replacement class
846 and call CWProgFolder directly.
847
848 */
849 if((mySomId=somIdFromString("wpInsertSettingsPage"))!=NULLHANDLE) {
850 ULONG rc;
851 rc=((somTD_WPObject_wpInsertSettingsPage)
852 somParentNumResolve(__ClassObject->somGetPClsMtabs(),
853 1,
854 __ClassObject->
855 somGetMethodToken(mySomId))
856 )(this, hwndNotebook, ppageinfo);
857 SOMFree(mySomId);
858 return rc;
859 }
860 else
861 return CWProgFolder::wpInsertSettingsPage(hwndNotebook, ppageinfo);
862}
863
864
865/**************************************************************/
866/* Override function: Add the 'About' and the 'Compact' menu */
867/* items. */
868/**************************************************************/
869BOOL CWMediaFolder::wpMenuItemSelected(HWND hwndFrame,ULONG ulMenuId)
870{
871 BOOL rcParent;
872 int tid;
873
874 switch(ulMenuId)
875 {
876 //#ifndef ECS
877 case ID_ABOUTITEM:
878 tid=_beginthread(aboutThreadFunc,NULL,8192*8,this); //Fehlerbehandlung fehlt
879 return TRUE;
880 //#endif
881 case 0x2ce: /* Detail view */
882 /* Call parent */
883#if 0
884 if(cwUnshrinkFolder(hwndFrame))
885 ulPrivFlags&=MFLDR_CHANGING_VIEW; /* Mark that we are changing views.
886 This flag is checked in CWCDFldr::wpRefresh() to know if it's
887 necessary to reinsert the tracks */
888#endif
889 rcParent=CWProgFolder::wpMenuItemSelected(hwndFrame, ulMenuId);
890 cwUnshrinkFolder(hwndFrame);
891 ulPrivFlags&= ~MFLDR_VIEW_COMPACT;
892 return rcParent;
893 case ID_MENUVIEWCOMPACT: /* Compact view */
894 if(cwShrinkFolderToCompact(hwndFrame)) {
895 /* Mark that we are in compact view. May be removed later when 'Compact'
896 is an 'official' view?
897 */
898 ulPrivFlags|=MFLDR_VIEW_COMPACT;
899 }
900 return TRUE;
901 default:
902 break;
903 }
904
905 /* Call parent */
906 rcParent=CWProgFolder::wpMenuItemSelected(hwndFrame, ulMenuId);
907 return rcParent;
908}
909
910/************************************************/
911/* Override function: Add the 'About' and the */
912/* 'Compact' menu items. */
913/************************************************/
914BOOL CWMediaFolder::wpModifyPopupMenu(HWND hwndMenu, HWND hwndCnr, ULONG ulPosition)
915{
916 HMODULE hResource=queryResModuleHandle();
917
918 if(hResource) {
919 //#ifndef ECS
920 /* Insert the 'About'-Item */
921 wpInsertPopupMenuItems(hwndMenu,-1,hResource,ID_MENUABOUT,WPMENUID_HELP);
922 //#endif
923
924 /* Insert the new 'Compact' view item but only if folder not already in compact view.
925 By doing that the 'compact' menu item doesn't show in the Sysmenu of the folder when
926 folder is shrinked.
927 */
928 if(!(cwQueryMFldrFlags() & MFLDR_VIEW_COMPACT))
929 wpInsertPopupMenuItems(hwndMenu,1,hResource, ID_MENUVIEWCOMPACT, MENUID_VIEW);
930 }
931 return CWProgFolder::wpModifyPopupMenu( hwndMenu, hwndCnr, ulPosition);
932}
933
934/************************************************/
935/* Override function: Remove the tree view open */
936/* item from the menu. */
937/************************************************/
938ULONG CWMediaFolder::wpFilterPopupMenu(ULONG ulFlags, HWND hwndCnr, BOOL fMultiSelect)
939{
940 somId mySomId;
941
942 /* V0.2.8 (07.09.2003):
943 Removed icon view item form menu. Icon view is no longer supported by
944 the media folder.
945
946 Changed to climb up the list of parents to make sure we call the right
947 method if the parent was replaced. Otherwise we may skip a replacement class
948 and call CWProgFolder directly.
949
950 */
951 if((mySomId=somIdFromString("wpFilterPopupMenu"))!=NULLHANDLE) {
952 ULONG rc;
953 rc=((somTD_WPObject_wpFilterPopupMenu)
954 somParentNumResolve(__ClassObject->somGetPClsMtabs(),
955 1,
956 __ClassObject->
957 somGetMethodToken(mySomId))
958 )(this, ulFlags, hwndCnr, fMultiSelect);
959 SOMFree(mySomId);
960 return rc & ~( CTXT_TREE | CTXT_ICON);
961 }
962 else
963 return CWProgFolder::wpFilterPopupMenu( ulFlags, hwndCnr, fMultiSelect) & ~( CTXT_TREE | CTXT_ICON);
964}
965
966//#if 0
967BOOL CWMediaFolder::wpRefresh(ULONG ulView, PVOID pReserved)
968{
969 somId mySomId;
970 ULONG rc;
971
972 if((mySomId=somIdFromString("wpRefresh"))!=NULLHANDLE) {
973 rc=((somTD_WPFileSystem_wpRefresh)
974 somParentNumResolve(__ClassObject->somGetPClsMtabs(),
975 1,
976 __ClassObject->
977 somGetMethodToken(mySomId))
978 )(this, ulView,pReserved);
979 SOMFree(mySomId);
980 }
981 else
982 rc=CWProgFolder::wpRefresh(ulView, pReserved);
983
984 /* Start timer which triggers time calculation */
985 WinStartTimer(WinQueryAnchorBlock(hwndBottom),hwndBottom, IDTIMER_STATUS, 300);
986 return rc;
987}
988//#endif
989
990BOOL CWMediaFolder::wpAddSettingsPages(HWND hwndNotebook)
991{
992 ULONG rc;
993 somId mySomId;
994
995 if((mySomId=somIdFromString("wpAddSettingsPages"))!=NULLHANDLE) {
996 rc=((somTD_WPObject_wpAddSettingsPages)
997 somParentNumResolve(__ClassObject->somGetPClsMtabs(),
998 1,
999 __ClassObject->
1000 somGetMethodToken(mySomId))
1001 )(this,hwndNotebook);
1002 SOMFree(mySomId);
1003 }
1004 else
1005 rc=CWProgFolder::wpAddSettingsPages(hwndNotebook);
1006
1007 if(!queryResModuleHandle()) {
1008 errorResource();
1009 return rc;
1010 }
1011 return(rc/* && cwAddToolbarOptionPage(hwndNotebook)*/);
1012}
1013
1014
1015MRESULT CWMediaFolder::wpDragOver(HWND hwndCnr,PDRAGINFO pDragInfo)
1016{
1017 WPObject *wpObject;
1018 WPFileSystem *wpFSObject;
1019 ULONG ulNum;
1020 ULONG a;
1021 MRESULT mr;
1022 SOMClass *mmAudioClass=somhlpQueryMMAudioClass();
1023 SOMClass *mmMIDIClass=somhlpGetSomClass("MMMIDI");
1024 SOMClass *cwAudioClass=somhlpGetSomClass("CWAudioShadow");
1025
1026
1027 mr=MRFROM2SHORT( DOR_DROP, DO_LINK);
1028 ulNum=DrgQueryDragitemCount(pDragInfo);/* Num items */
1029
1030 if(pDragInfo->usOperation!=DO_DEFAULT && pDragInfo->usOperation!=DO_LINK)
1031 // return MRFROM2SHORT( DOR_NEVERDROP, DO_MOVE);/* It's not an audio object */
1032 {
1033 /* Only CWAudioShadows may be copied or moved */
1034 for(a=0;a<ulNum && SHORT1FROMMR(mr)!=DOR_NEVERDROP; a++)
1035 {
1036 /* Check every object dragged */
1037 wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, a)->ulItemID);
1038 if(!wpObject->somIsA(cwAudioClass))
1039 {
1040 return MRFROM2SHORT( DOR_NEVERDROP, DO_MOVE);/* It's not an audio object */
1041 }
1042 }
1043 return MRFROM2SHORT( DOR_DROP, DO_MOVE);/* */
1044 return MRFROM2SHORT( DOR_DROP, pDragInfo->usOperation);/* */
1045 }
1046
1047
1048 for(a=0;a<ulNum && SHORT1FROMMR(mr)!=DOR_NEVERDROP; a++)
1049 {
1050 /* Check every object dragged */
1051 wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, a)->ulItemID);
1052 /* Get the filesystem object in case it's a shadow */
1053 wpFSObject=(WPFileSystem*)cwGetFileSystemObject(wpObject);
1054 if(!somIsObj(wpFSObject))
1055 return MRFROM2SHORT( DOR_NEVERDROP, DO_MOVE);/* It's not an object */
1056 if(!wpFSObject->somIsA(cwAudioClass) && !wpFSObject->somIsA(mmAudioClass) && !wpFSObject->somIsA(mmMIDIClass))
1057 return MRFROM2SHORT( DOR_NEVERDROP, DO_MOVE);/* It's not an audio object */
1058 }
1059 /* The following is necessary because for some reason hwndCnr and pDragInfo->hwndSource
1060 are equal when the dragged object resides in the same folder as the target and the target
1061 isn't opened yet. Without this check the dragged object would be moved not linked. */
1062 if(this->wpQueryFolder()==wpObject->wpQueryFolder())
1063 return MRFROM2SHORT(DOR_DROP,DO_LINK);
1064 /* Do not create shadows if the source is the current container */
1065 if(hwndCnr==pDragInfo->hwndSource)
1066 return MRFROM2SHORT( DOR_DROP, DO_MOVE);
1067
1068 return mr;
1069}
1070
1071void _Optlink dropThreadFunc (void *arg)
1072{
1073 HAB hab;
1074 HMQ hmq;
1075 QMSG qmsg;
1076 PDROPTHREADPARAMS threadParams;
1077 CWMediaFolder *thisPtr;
1078 MMAudio* cwAudio;
1079 HWND hwndCnr;
1080
1081 threadParams=(PDROPTHREADPARAMS) arg;
1082 if(!threadParams)
1083 return;
1084 thisPtr=(CWMediaFolder*)threadParams->thisPtr; //Pointer auf CWMediaFolder-Object
1085
1086 if(!somIsObj(thisPtr))
1087 return;
1088
1089 if(thisPtr->mfData)
1090 thisPtr->mfData->bProcessing=TRUE;
1091
1092 hab=WinInitialize(0);
1093 if(hab) {
1094 hmq=WinCreateMsgQueue(hab,0);
1095 if(hmq) {
1096 WPObject *wpObject;
1097 somId mySomId;
1098 M_WPObject *mAudioObject;
1099 SOMClass* scCWShadowClass;
1100 ULONG ulCount;
1101 ULONG ulNumObjects;
1102 /* Needed for specifying the drop point */
1103 POINTL ptl;
1104 PMINIRECORDCORE pmrc;
1105 CNRINFO cnrInfo;
1106 int ID;
1107 HWND hwndSource;
1108
1109 hwndCnr=threadParams->hwndCnr;
1110
1111 /* The objects are already checked by the wpDragOver() method. */
1112
1113 TRY_LOUD(MEDIAFLDR_DROP_THREAD) {
1114 hwndSource=threadParams->hwndSource;
1115 ulNumObjects=threadParams->ulNumObjects;
1116
1117 if((mySomId=somIdFromString(SHADOW_CLASS_NAME))!=NULLHANDLE) {
1118 WPFileSystem *wpFSObject;
1119 /* Get the CWAudioShadow class object */
1120 scCWShadowClass=(SOMClass*)SOMClassMgrObject->somClassFromId(mySomId);
1121 SOMFree(mySomId);
1122 /* Check shadow class */
1123 if(somIsObj(scCWShadowClass)) {
1124 if(hwndSource!=hwndCnr){/* Dropped on white space of an open folder */
1125 QUERYRECFROMRECT qRecRcl;
1126 ptl.x=threadParams->ptl.x;
1127 ptl.y=threadParams->ptl.y;
1128
1129 /* Map to CNR */
1130 WinMapWindowPoints(HWND_DESKTOP, hwndCnr,&ptl, 1);
1131 ptl.y+=10;
1132 /* Window below the mouse ptr. We need it to check if we are over the column title area. */
1133 ID=WinQueryWindowUShort(WinWindowFromPoint(hwndCnr,&ptl, TRUE),QWS_ID);
1134 ptl.y-=10;
1135
1136 /* Find the record near the drop point */
1137 qRecRcl.cb=sizeof(qRecRcl);
1138 qRecRcl.rect.yBottom=ptl.y-10;
1139 qRecRcl.rect.yTop=ptl.y;
1140 qRecRcl.rect.xLeft=ptl.x;
1141 qRecRcl.rect.xRight=ptl.x+10;
1142 qRecRcl.fsSearch=CMA_PARTIAL|CMA_ITEMORDER;
1143 pmrc=(PMINIRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORDFROMRECT,MPFROMLONG(CMA_FIRST),
1144 MPFROMP(&qRecRcl));
1145 WinSendMsg(hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnrInfo), MPFROMSHORT(sizeof(cnrInfo)));
1146 }/*if(hwndSource!=hwndCnr)*/
1147
1148 /* For all dropped objects */
1149 for(ulCount=0; ulCount<ulNumObjects; ulCount++) {
1150 if(ulCount%10)/* Redraw window every 10 objects */
1151 WinEnableWindowUpdate(hwndCnr, FALSE);
1152 else
1153 WinEnableWindowUpdate(hwndCnr, TRUE);
1154
1155 wpObject=(WPObject*) threadParams->wpObject[ulCount];
1156 /* Get the filesystem object in case it's a shadow */
1157 wpFSObject=(WPFileSystem*)thisPtr->cwGetFileSystemObject(wpObject);
1158 if(somIsObj(wpFSObject)){
1159 if(hwndSource==hwndCnr)/* The folder is closed or dropped on the folder icon. */
1160 wpFSObject->wpCreateShadowObjectExt(thisPtr, FALSE, "", (M_WPObject*)scCWShadowClass);
1161 else {
1162 /* Dropped on white space of the folder */
1163 WPObject *wpo;
1164 if(cnrInfo.flWindowAttr& CV_DETAIL)
1165 {
1166 /* Detailsview */
1167 RECORDINSERT recInsert;
1168
1169 recInsert.cb=sizeof(recInsert);
1170 recInsert.pRecordParent=NULL;
1171 recInsert.fInvalidateRecord=TRUE;
1172 recInsert.zOrder=CMA_TOP;
1173 recInsert.cRecordsInsert=1;
1174
1175 // WinEnableWindowUpdate(hwndCnr, FALSE);
1176 /* Create the shadow */
1177 // wpo=
1178 //wpFSObject->wpCreateShadowObject(thisPtr, FALSE);
1179 wpo=wpFSObject->wpCreateShadowObjectExt(thisPtr, FALSE, "",
1180 (M_WPObject*) scCWShadowClass);
1181 /* Move the record to the right position in the details view */
1182 if(somIsObj(wpo)) {
1183 wpo->wpCnrRemoveObject(hwndCnr);
1184 // WinEnableWindowUpdate(hwndCnr, TRUE);
1185 if(pmrc && ((int)pmrc)!=-1) {
1186 recInsert.pRecordOrder=(PRECORDCORE)pmrc;
1187 /* Insert at the right place. For some reason wpSetNextIconPos() does not work!? */
1188 wpo->wpCnrInsertObject(hwndCnr, &ptl, NULL, &recInsert);
1189 }
1190 else {
1191 /* No record found check if we are at the top or the bottom */
1192 if(ID!=0x7ff0 && ID!=0x7ff1)
1193 recInsert.pRecordOrder=(PRECORDCORE)CMA_END;
1194 else
1195 recInsert.pRecordOrder=(PRECORDCORE)CMA_FIRST;
1196 /* Insert at the right place. For some reason wpSetNextIconPos() does not work!? */
1197 wpo->wpCnrInsertObject(hwndCnr, &ptl, NULL, &recInsert);
1198 }
1199 }/* if(somIsObj(wpo)) */
1200 // WinEnableWindowUpdate(hwndCnr, TRUE);
1201 }/* if(cnrInfo.flWindowAttr& CV_DETAIL) */
1202 else
1203 /* Icon view */
1204 wpo=wpFSObject->wpCreateShadowObjectExt(thisPtr, FALSE, "", (M_WPObject*) scCWShadowClass);
1205 if(somIsObj(wpo))
1206 wpo->wpCnrRefreshDetails();
1207 }/* else(hwndSource==hwndCnr) */
1208 }/* if(somIsObj(wpFSObject)) */
1209 }/* for(ulCount=0;ulCount<ulNumObjects ; ulCount++) */
1210 WinEnableWindowUpdate(hwndCnr, TRUE);
1211 }/* if(somIsObj(scCWShadowClass)) */
1212 }/* if((mySomId=somIdFromString(SHADOW_CLASS_NAME))!=NULLHANDLE)*/
1213 }/* Try */
1214 CATCH(MEDIAFLDR_DROP_THREAD)
1215 {
1216 SysWriteToTrapLog("\nTrap occured in %s, file: %s, line %d.\n",
1217 __FUNCTION__, __FILE__, __LINE__);
1218 } END_CATCH;
1219
1220 WinDestroyMsgQueue(hmq);
1221 }
1222 WinTerminate(hab);
1223 }
1224 if(thisPtr->mfData)
1225 thisPtr->mfData->bProcessing=FALSE;
1226
1227 thisPtr->wpFreeMem((PBYTE)threadParams);
1228}
1229
1230
1231
1232MRESULT CWMediaFolder::wpDrop(HWND hwndCnr,PDRAGINFO pDragInfo,PDRAGITEM pDragItem)
1233{
1234 WPObject *wpObject;
1235 somId mySomId;
1236 M_WPObject *mAudioObject;
1237 SOMClass* scCWShadowClass;
1238 ULONG ulCount;
1239 ULONG ulNumObjects=DrgQueryDragitemCount(pDragInfo);
1240
1241 /* Needed for specifying the drop point */
1242 POINTL ptl;
1243 PMINIRECORDCORE pmrc;
1244 CNRINFO cnrInfo;
1245 int ID;
1246
1247 /* The objects are already checked by the wpDragOver() method. */
1248 TRY_LOUD(MEDIAFLDR_DROP) {
1249 PDROPTHREADPARAMS pThreadParams;
1250 ULONG ulErr;
1251 WPObject* wpObj;
1252
1253 /* DROPTHREADPARAMS already contains one WPObject var so only memory for ulNumObjects-1 must be added to the end */
1254 pThreadParams=(PDROPTHREADPARAMS)wpAllocMem(sizeof(DROPTHREADPARAMS)+(ulNumObjects-1)*sizeof(WPObject*), &ulErr);
1255 pThreadParams->hwndCnr=hwndCnr;
1256 pThreadParams->hwndSource=pDragInfo->hwndSource;
1257 pThreadParams->ulNumObjects=DrgQueryDragitemCount(pDragInfo);
1258 pThreadParams->thisPtr=this;
1259 pThreadParams->ptl.x=pDragInfo->xDrop;
1260 pThreadParams->ptl.y=pDragInfo->yDrop;
1261
1262 /* For all dropped objects */
1263 for(ulCount=0;ulCount<ulNumObjects ; ulCount++) {
1264 pThreadParams->wpObject[ulCount]=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
1265 }
1266 _beginthread(dropThreadFunc,NULL,8192*16,(void*)pThreadParams); //Fehlerbehandlung fehlt
1267 }
1268 CATCH(MEDIAFLDR_DROP)
1269 {
1270 SysWriteToTrapLog("\nTrap occured in %s, file: %s, around line %d.\n",
1271 __FUNCTION__, __FILE__, __LINE__);
1272 } END_CATCH;
1273
1274 DrgFreeDraginfo(pDragInfo);
1275 return (MRESULT)RC_DROP_DROPCOMPLETE;
1276}
1277
1278
1279BOOL CWMediaFolder::wpSaveState()
1280{
1281
1282 wpSaveLong("CWMediaFolder", KEY_VOLUME, ulVolume);
1283 // wpSaveData("CWMediaFolder", KEY_FLYBACKGROUND, (PBYTE)&rgbTBFlyBackground, sizeof(RGB));
1284 // wpSaveData("CWMediaFolder", KEY_FLYFOREGROUND, (PBYTE)&rgbTBFlyForeground,sizeof(RGB));
1285 // wpSaveString("CWMediaFolder", KEY_FLYFONT, (PBYTE)&chrTBFlyFontName);
1286 // wpSaveLong("CWMediaFolder", KEY_FLYENABLED,bTBFlyOverEnabled);
1287 // wpSaveLong("CWMediaFolder", KEY_FLYDELAY,iTBFlyOverDelay);
1288 wpSaveLong("CWMediaFolder", KEY_FLAGS, ulFlags);
1289 wpSaveLong("CWMediaFolder", KEY_DISPLAYTYPE, (LONG)usWhichDisplay);
1290 if(mfData)
1291 wpSaveString("CWMediaFolder", KEY_PLAYTIMEFONT, (PBYTE)&mfData->chrPlayTimeFont);
1292 return CWProgFolder::wpSaveState();
1293}
1294
1295BOOL CWMediaFolder::wpRestoreState(ULONG ulReserved)
1296{
1297 ULONG dataSize;
1298 ULONG ulActionButtons;
1299
1300
1301 if(!wpRestoreLong("CWMediaFolder", KEY_VOLUME, &ulVolume))
1302 ulVolume=75;
1303#if 0
1304 if(!wpRestoreLong("CWMediaFolder", KEY_FLYENABLED,&bTBFlyOverEnabled))
1305 bTBFlyOverEnabled=1;
1306 if(!wpRestoreLong("CWMediaFolder", KEY_FLYDELAY,(PULONG)&iTBFlyOverDelay))
1307 iTBFlyOverDelay=250;
1308#endif
1309 if(!wpRestoreLong("CWMediaFolder", KEY_FLAGS,(PULONG)&ulFlags))
1310 ulFlags=0;
1311 if(!wpRestoreLong("CWMediaFolder", KEY_DISPLAYTYPE,(PULONG)&dataSize))
1312 usWhichDisplay=0;
1313 else
1314 usWhichDisplay=(USHORT)dataSize;
1315
1316#if 0
1317 dataSize=sizeof(RGB);
1318 if(!wpRestoreData("CWMediaFolder", KEY_FLYBACKGROUND,(PBYTE)&rgbTBFlyBackground,&dataSize)) {
1319 rgbTBFlyBackground.bBlue=180;
1320 rgbTBFlyBackground.bGreen=255;
1321 rgbTBFlyBackground.bRed=255;
1322 }
1323
1324 dataSize=sizeof(RGB);
1325 if(!wpRestoreData("CWMediaFolder",KEY_FLYFOREGROUND,(PBYTE)&rgbTBFlyForeground,&dataSize)) {
1326 rgbTBFlyForeground.bRed=0;
1327 rgbTBFlyForeground.bGreen=0;
1328 rgbTBFlyForeground.bBlue=0;
1329 }
1330
1331 memset(chrTBFlyFontName,0,sizeof(chrTBFlyFontName));
1332 dataSize=sizeof(chrTBFlyFontName);
1333 if(!wpRestoreString("CWMediaFolder",KEY_FLYFONT,(PBYTE)&chrTBFlyFontName,&dataSize))
1334 memcpy(&chrTBFlyFontName,"8.Helv",sizeof("8.Helv"));
1335#endif
1336
1337 if(mfData)
1338 {
1339 dataSize=sizeof(mfData->chrPlayTimeFont);
1340 wpRestoreString("CWMediaFolder", KEY_PLAYTIMEFONT,(PBYTE)&mfData->chrPlayTimeFont, &dataSize);
1341 }
1342
1343 return CWProgFolder::wpRestoreState(ulReserved);
1344}
1345
1346
1347BOOL CWMediaFolder::cwClose(HWND hwndFrame)
1348{
1349 char text[200];
1350 char title[50];
1351 HWND hwndOwner=HWND_DESKTOP;
1352
1353 /* Check if we currently play a song */
1354 if(iWave) {
1355 PVIEWITEM pViewItem;
1356 int a=0;
1357
1358#if 0
1359 /* Check if we close a settings view or a folder view. */
1360 for(pViewItem=wpFindViewItem(VIEW_ANY, NULLHANDLE); pViewItem; pViewItem=wpFindViewItem(VIEW_ANY, pViewItem))
1361 a+=1;
1362 if(a!=1)
1363 return TRUE;
1364#endif
1365
1366 if(hwndFrame!=hwndMFldrFrame)
1367 return TRUE;
1368
1369 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndFrame))
1370 hwndOwner=hwndFrame;
1371
1372 if(messageBox( text, IDSTR_CLOSETEXT, sizeof(text),
1373 title, IDSTR_CLOSETITLE, sizeof(title),
1374 queryResModuleHandle(), hwndOwner, MB_YESNO|MB_MOVEABLE|MB_ICONQUESTION)==MBID_NO)
1375 return FALSE;
1376 }
1377 cwStopAudioFile(hwndFrame);
1378 /* Stop the playing thread */
1379 WinPostMsg(mfData->hwndPlayObject, WM_QUIT, 0, 0);
1380
1381 /* We were opened by an M3U file. Notify it that we're closing */
1382 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndObject)) {
1383 WinPostMsg(hwndObject, WM_APPTERMINATENOTIFY, 0, 0);
1384 }
1385
1386 ulPrivFlags&= ~MFLDR_VIEW_COMPACT;
1387 hwndMFldrFrame=NULL;
1388 wpSaveDeferred();
1389 return TRUE;
1390}
1391
1392void CWMediaFolder::wpInitData()
1393{
1394 ULONG ulErr;
1395 CWProgFolder::wpInitData();
1396 /* Get storage for private data. */
1397 if((mfData=(PMEDIAFLDRDATA)wpAllocMem(sizeof(MEDIAFLDRDATA), &ulErr))!=NULLHANDLE)
1398 memset((void*)mfData, 0, sizeof(MEDIAFLDRDATA));
1399
1400 ulPrivFlags=0;
1401
1402}
1403
1404void CWMediaFolder::wpUnInitData()
1405{
1406 wpFreeMem((PBYTE)mfData);
1407 CWProgFolder::wpUnInitData();
1408}
1409
Note: See TracBrowser for help on using the repository browser.