source: trunk/mediafolder/c/m3ufolder/m3ufolderoverriddenwpmethods.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: 36.8 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 2002-2003
3 *
4 * It's part of the Media-Folder distribution
5 */
6
7#define INCL_DOSERRORS
8
9#define INCL_REXXSAA
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <ctype.h>
14#include "m3ufolder.hh"
15#include "except.h"
16#include <rexxsaa.h> /* needed for RexxStart() */
17
18#include "mediafolderres.h"
19#include "cwcdtrack.hh"
20
21#include "sys_funcs.h"
22#include "menu_funcs.h"
23
24extern BOOL g_fRegisteredWindowClass;
25extern ULONG g_ulFrameDataOffset;
26
27/* The following offsets are calclated in wpOpen() of media folder */
28extern ULONG ulQWP_CONTAINERPROC;
29extern ULONG ulQWP_THISPTR;
30extern ULONG ulQWL_TOPCTRLHWND;
31extern ULONG ulQWL_BOTTOMCTRLHWND;
32extern ULONG ulQWL_RIGHTCTRLHWND;
33extern ULONG ulQWL_LEFTCTRLHWND;
34
35#if 0
36/* For calling the method in the MMAudio 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. */
39typedef ULONG SOMLINK somTP_MMCDTrack_cwmmQueryTrackInfo(MMCDTrack *somSelf,
40 char** chrString,
41 ULONG ulSize,
42 int iWhich);
43typedef somTP_MMCDTrack_cwmmQueryTrackInfo *somTD_MMCDTrack_cwmmQueryTrackInfo;
44extern somTD_MMCDTrack_cwmmQueryTrackInfo methodPtrCDTrack;
45#endif
46
47extern LOADEDBITMAP allBMPs[];
48extern PFNWP pfnwpGenericFrame;
49extern char chrInstallDir[];
50
51BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
52ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
53 char* title, ULONG ulTitleID, LONG lSizeTitle,
54 HMODULE hResource, HWND hwnd, ULONG ulFlags);
55HMODULE queryResModuleHandle(void);
56void errorResource();
57
58MRESULT EXPENTRY topCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
59MRESULT EXPENTRY rightCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
60MRESULT EXPENTRY leftCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
61MRESULT EXPENTRY bottomCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
62MRESULT EXPENTRY mediaFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
63MRESULT EXPENTRY mediaFldrContainerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
64
65
66void _Optlink rexxThreadFunc (void *arg);
67
68SOMClass* somhlpGetSomClass(char* chrClassName);
69
70//void HlpWriteToTrapLog(const char* chrFormat, ...);
71
72#if 0
73void _Optlink rexxThreadFunc (void *arg)
74{
75 HAB hab;
76 HMQ hmq;
77 QMSG qmsg;
78 CWM3UFolder *thisPtr;
79 HWND hwnd;
80#if 0
81 char chrFileName[CCHMAXPATH];
82 char chrFolderName[CCHMAXPATH];
83 char chrRexxScript[CCHMAXPATH];
84#endif
85 char *chrFileName;
86 char *chrFolderName;
87 char *chrRexxScript;
88 ULONG ulSize;
89
90 thisPtr=(CWM3UFolder*)arg;
91 if(!somIsObj(thisPtr))
92 return;
93
94 if(!somIsObj(thisPtr->wpObjM3UFile))
95 return;
96
97 chrFileName=thisPtr->wpAllocMem( CCHMAXPATH*3+10 , &ulSize);
98 if(!chrFileName)
99 return;
100
101 chrFolderName=chrFileName+CCHMAXPATH+1;
102 chrRexxScript=chrFolderName+CCHMAXPATH+1;
103
104 ulSize=CCHMAXPATH;
105 if(!((WPFileSystem*)thisPtr->wpObjM3UFile)->wpQueryRealName(chrFileName, &ulSize, TRUE))
106 return;
107
108 ulSize=CCHMAXPATH;
109 if(!thisPtr->wpQueryRealName(chrFolderName, &ulSize, TRUE))
110 return;
111
112 hab=WinInitialize(0);
113 if(hab) {
114 hmq=WinCreateMsgQueue(hab,0);
115 if(hmq) {
116 RXSTRING arg[2]; /* argument string for REXX */
117 RXSTRING rexxretval; /* return value from REXX */
118 APIRET rc; /* return code from REXX */
119 SHORT rexxrc = 0; /* return code from function */
120
121
122 sprintf(chrRexxScript,"%s%s", chrInstallDir,RX_INSERT_PLAYLISTTRACKS);
123 //HlpWriteToTrapLog("chrRexxScript: %s\n", chrRexxScript);
124 /* By setting the strlength of the output RXSTRING to zero, we */
125 /* force the interpreter to allocate memory and return it to us. */
126 /* We could provide a buffer for the interpreter to use instead. */
127 rexxretval.strlength = 0L; /* initialize return to empty*/
128
129 MAKERXSTRING(arg[0], chrFileName, strlen(chrFileName));/* create input argument */
130 MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument */
131
132 TRY_LOUD(RX_START) {
133 /* Here we call the interpreter. We don't really need to use */
134 /* all the casts in this call; they just help illustrate */
135 /* the data types used. */
136 rc=RexxStart((LONG) 2, /* number of arguments */
137 (PRXSTRING) &arg, /* array of arguments */
138 (PSZ) chrRexxScript,/* name of REXX file */
139 // (PSZ) "H:\\cwmm\\mediafolder\\beep.cmd",/* name of REXX file */
140 (PRXSTRING) 0, /* No INSTORE used */
141 (PSZ) "CWRXX", /* Command env. name */
142 (LONG) RXSUBROUTINE, /* Code for how invoked */
143 (PRXSYSEXIT) 0, /* No EXITs on this call */
144 (PSHORT) &rexxrc, /* Rexx program output */
145 (PRXSTRING) &rexxretval ); /* Rexx program output */
146
147 if(rc) {
148 sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n",
149 "", rc*-1);
150 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrFileName, "", 1234, MB_OK|MB_MOVEABLE|MB_ERROR);
151 }
152 DosFreeMem(rexxretval.strptr); /* Release storage given to us by REXX. */
153 }
154 CATCH(RX_START)
155 {}END_CATCH;
156
157 WinDestroyMsgQueue(hmq);
158 }
159 WinTerminate(hab);
160 }
161 thisPtr->fContentsChanged=FALSE;
162 thisPtr->wpFreeMem((PBYTE)chrFileName);
163}
164
165BOOL CWM3UFolder::wpSetup(PSZ pSetupString)
166{
167 /**************************************************
168 * *
169 * *
170 **************************************************/
171 char buffer[25];
172 ULONG bufferSize;
173
174 /* Set object window HWND */
175 bufferSize=sizeof(buffer);
176 if(wpScanSetupString(pSetupString, "M3UOBJECTWINDOW", buffer,&bufferSize))
177 {
178 hwndObject=atol(buffer);
179 }
180
181 /* Set object pointer to M3U-File */
182 bufferSize=sizeof(buffer);
183 if(wpScanSetupString(pSetupString, "M3UOBJECTHANDLE", buffer,&bufferSize))
184 {
185 WPObject *wpObject;
186
187 wpObjM3UFile=NULLHANDLE;
188 wpObject=(WPObject*)atol(buffer);
189 if(somIsObj(wpObject))
190 wpObjM3UFile=wpObject;
191 }
192
193
194 /* FIXME: Use immediate parent here !!!! */
195 return CWMediaFolder::wpSetup(pSetupString);
196}
197#endif
198
199/*****************************************************/
200/* */
201/* New container procedure so tabbing to the play */
202/* control dialog works. */
203/* */
204/*****************************************************/
205MRESULT EXPENTRY m3uFldrContainerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
206{
207 CWMediaFolder* thisPtr;
208 HWND hwndDialog;
209 PFNWP pfnwpContainer;
210
211 switch(msg)
212 {
213 case WM_CONTROL:
214 if(SHORT2FROMMP(mp1)==CN_DROP) {
215 /* Get frame handle */
216 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
217 {
218 CWM3UFolder *thisPtr;
219 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,ulQWP_THISPTR);
220 if(somIsObj(thisPtr))
221 thisPtr->fContentsChanged=TRUE;
222 }
223 }
224 break;
225 default:
226 break;
227 }
228
229 /* Any other message is handled by the folder container procedure */
230 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE) {
231 pfnwpContainer=(PFNWP)WinQueryWindowULong( hwndDialog, ulQWP_CONTAINERPROC);
232 if(pfnwpContainer)
233 return pfnwpContainer(hwnd, msg, mp1, mp2);
234 }
235#if 0
236 if((hwndDialog=WinQueryWindow(hwnd,QW_PARENT))!=NULLHANDLE)
237 {
238 if((hwndDialog=WinWindowFromID(hwndDialog,IDDLG_TOPFRAME))!=NULLHANDLE)
239 {
240 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
241 if(somIsObj(thisPtr))
242 if(thisPtr->pfnwpContainer)
243 return thisPtr->pfnwpContainer(hwnd, msg, mp1, mp2);
244 }
245 }
246#endif
247
248 return WinDefWindowProc(hwnd, msg, mp1, mp2);
249}
250
251BOOL CWM3UFolder::cwInsertAllTracks(char* chrM3UFile)
252{
253 INSERTTRACKPARMS * threadParms;
254 ULONG ulError;
255
256 if((threadParms=(INSERTTRACKPARMS*)wpAllocMem(sizeof(INSERTTRACKPARMS), &ulError))==NULLHANDLE)
257 return FALSE;
258 threadParms->thisPtr=this;
259 sprintf(threadParms->chrRexxScript,"%s%s", chrInstallDir, RX_INSERT_PLAYLISTTRACKS);
260
261 _beginthread(rexxThreadFunc,NULL,8192*16,(void*)threadParms); //Fehlerbehandlung fehlt
262 return TRUE;
263}
264
265
266
267/****************************************************************************/
268/* */
269/* This procedure handles the frame extension of the folder at the top */
270/* */
271/* The playcontrol dialog is a child of this 'background' dialog. */
272/* */
273/****************************************************************************/
274MRESULT EXPENTRY m3uTopCtrlDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
275{
276
277 switch(msg)
278 {
279 /*****************************************************/
280 /* Init the dialog */
281 /*****************************************************/
282 case WM_INITDLG :
283 {
284 ULONG ulStyle;
285 SWP swp;
286
287 WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
288 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp);
289 /* Set dialog font to WarpSans for Warp 4 and above */
290 if(SysQueryOSRelease()>=40) {
291 WinSetPresParam(hwnd,
292 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
293 DEFAULT_DIALOG_FONT );
294 }
295 return (MRESULT)FALSE;
296 }
297 case WM_CHAR:
298 // Set focus to container so the key will be processed as usual
299 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT));
300 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT),msg,mp1,mp2);
301
302 /*****************************************************/
303 /* Paint the background. */
304 /*****************************************************/
305 case WM_PAINT:
306 {
307 HPS hps;
308 RECTL rcl, rclSave, rclSource;
309 SWP swp;
310
311 if(allBMPs[CTRLIDX_BOTTOM].hbm) {
312 POINTL ptl;
313 LONG lTemp;
314
315 hps=WinBeginPaint(hwnd, NULL, &rcl);
316 rclSource.xLeft=0;
317 rclSource.yBottom=0;
318 rclSource.yTop=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cy;
319 rclSource.xRight=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cx;
320 lTemp=rcl.xLeft/rclSource.xRight;
321 ptl.x=lTemp*rclSource.xRight;
322 lTemp=rcl.yBottom/rclSource.yTop;
323 lTemp*=rclSource.yTop;
324 while(ptl.x<rcl.xRight) {
325 ptl.y=lTemp;
326 while(ptl.y<rcl.yTop) {/* y direction */
327 WinDrawBitmap(hps, allBMPs[CTRLIDX_BOTTOM].hbm,
328 &rclSource,
329 (PPOINTL)&ptl,
330 0, 0,
331 DBM_IMAGEATTRS);
332 ptl.y+=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cy;
333 };
334 ptl.x+=allBMPs[CTRLIDX_BOTTOM].bmpInfoHdr.cx;
335 };
336 WinEndPaint(hps);
337 return (MRESULT)0;
338 }
339#if 0
340 hps=WinBeginPaint(hwnd, NULLHANDLE,NULL);
341 /* Get Window size */
342 WinQueryWindowRect(hwnd, &rcl);
343 rclSave=rcl;
344 /* Get size and pos of control area */
345 WinQueryWindowPos(WinWindowFromID(hwnd, IDDLG_TOPMIDDLE),&swp);
346 /* Left area */
347 rcl.xRight=swp.x;
348 rclSource.xLeft=0;
349 rclSource.yBottom=0;
350 rclSource.yTop=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cy;
351 rclSource.xRight=allBMPs[CTRLIDX_TOPLEFT].bmpInfoHdr.cx;
352 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPLEFT].hbm,
353 &rclSource,
354 (PPOINTL)&rclSave,
355 0, 0,
356 DBM_IMAGEATTRS | DBM_STRETCH);
357 //SysWriteToTrapLog("hbm: %x , yTop: %d xRight; %d\n", allBMPs[CTRLIDX_TOPLEFT].hbm, rclSource.yTop,rclSource.xRight);
358 // WinFillRect(hps, &rclSave, CLR_RED);
359 /* Right area */
360 rclSave.xLeft=swp.x+swp.cx;
361 rclSource.xLeft=0;
362 rclSource.yBottom=0;
363 rclSource.yTop=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cy;
364 rclSource.xRight=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx;
365 WinDrawBitmap(hps, allBMPs[CTRLIDX_TOPRIGHT].hbm,
366 &rclSource,
367 (PPOINTL)&rclSave,
368 0, 0,
369 DBM_IMAGEATTRS | DBM_STRETCH);
370 WinFillRect(hps, &rclSave, CLR_BLUE);
371 WinEndPaint(hps);
372 return (MRESULT) 0;
373#endif
374 break;
375 }
376 default:
377 break;
378 }
379 return WinDefDlgProc(hwnd, msg, mp1, mp2);
380}
381
382/************************************************************
383 * *
384 * This frame proc handles the about menuitem of the *
385 * Warp 4 menu bar and removes some menu items. *
386 * *
387************************************************************/
388MRESULT EXPENTRY m3uFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
389{
390 CWM3UFolder* thisPtr;
391 HWND hwndDialog;
392 MENUITEM mi;
393 char text[100];
394
395 switch (msg)
396 {
397 case WM_INITMENU:
398 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
399 {
400 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
401 if(somIsObj(thisPtr)) {
402
403 HMODULE hResource=queryResModuleHandle();
404 switch(thisPtr->usLastSelMenuItem)
405 {
406#ifndef ECS
407 case 0x2d3:/* Help menu */
408 {
409 if(hResource) {
410 /* insert separator */
411 menuInsertMenuSeparator(HWNDFROMMP(mp2), NULL, MIT_END);
412 /* Insert 'About' item */
413 getMessage(text, IDSTR_MENUABOUT ,sizeof(text), hResource, hwnd);
414 menuInsertMenuItem(HWNDFROMMP(mp2), NULL, MIT_END, ID_ABOUTITEM, text);
415 break;
416 }
417 break;
418 }
419#endif
420 case 0x2d1: /* View menu */
421 /* Remove change to Tree from menubar menu */
422 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(717,TRUE),0);
423 /* Icon view */
424 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x2cc,TRUE),0);
425 /* Arrange */
426 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x135,TRUE),0);
427 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x136,TRUE),0);
428 // WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x,TRUE),0);
429
430 break;
431 case 0x2d0: /* Edit menu */
432 /* Move */
433 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x6b,TRUE),0);
434 /* Insert */
435 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x2cb,TRUE),0);
436 /* Create shadow */
437 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x13c,TRUE),0);
438 /* Create */
439 WinSendMsg(HWNDFROMMP(mp2),MM_REMOVEITEM,MPFROM2SHORT(0x65,TRUE),0);
440 break;
441 default:
442 break;
443 }
444 }
445 }
446 break;
447 /* Prevent title changing by XWP */
448 case WM_SETWINDOWPARAMS:
449 {
450 PWNDPARAMS pwp=(PWNDPARAMS)PVOIDFROMMP(mp1);
451 if(!pwp)
452 break;
453 if(pwp->fsStatus!=WPM_TEXT)
454 break;
455
456 return MRFALSE;
457 }
458 case WM_COMMAND:
459 if(SHORT1FROMMP(mp2)==CMDSRC_MENU) {
460 switch(SHORT1FROMMP(mp1))
461 {
462 case ID_MENUITEMEXIT:
463 WinPostMsg(hwnd, WM_CLOSE, 0, 0);
464 return MRFALSE;
465 case ID_MENUITEMSAVE:
466 {
467 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
468 {
469 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
470 if(somIsObj(thisPtr)) {
471 thisPtr->cwSavePlaylist(NULLHANDLE, FALSE);
472 }
473 }
474 return MRFALSE;
475 }
476 default:
477 if(SHORT1FROMMP(mp1)>=FIRSTUSERITEM) {
478 BOOL bHandled=FALSE;
479
480 TRY_LOUD(AF_MENU) {
481#if 0
482 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
483 {
484 thisPtr=(CWMediaFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
485 if(somIsObj(thisPtr)) {
486
487 CWMenuFolder * wpFolder;
488 HOBJECT hObject;
489 somId id;
490 somTD_CWMenuFolder_mfCheckSkriptMenuItems methodPtr;
491 M_WPObject *m_wpObject;
492
493 if(!bHandled)
494 bHandled=thisPtr->cwCheckUserMenuItems(USERMENUFOLDER_MEDIAFOLDER , SHORT1FROMMP(mp1));
495 }/* if(somIsObj(thisPtr)) */
496 }/* Dialog window */
497#endif
498 }
499 CATCH(AF_MENU)
500 {
501 } END_CATCH;
502 if(bHandled)
503 return (MRESULT) 0;
504 }
505 break;
506 }/* switch() */
507 }
508 break;
509 case WM_MENUSELECT:
510 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
511 {
512 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
513 if(somIsObj(thisPtr)) {
514 thisPtr->usLastSelMenuItem=SHORT1FROMMP(mp1);
515 }
516 }
517 break;
518 case WM_CONTROL:
519 if(SHORT2FROMMP(mp1)==CN_DROP) {
520 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
521 {
522 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
523 if(somIsObj(thisPtr)) {
524 thisPtr->fContentsChanged=TRUE;
525 }
526 }
527 }
528 break;
529 default:
530 break;
531 }
532 /* Any other message is handled by the folder frame procedure */
533 if((hwndDialog=WinWindowFromID(hwnd,IDDLG_TOPFRAME))!=NULLHANDLE)
534 {
535 thisPtr=(CWM3UFolder*) WinQueryWindowULong(hwndDialog,QWL_USER);
536 if(somIsObj(thisPtr)) {
537 if(thisPtr->pfnwpFrame)
538 return thisPtr->pfnwpFrame(hwnd, msg, mp1, mp2);
539 }
540 }
541 return pfnwpGenericFrame(hwnd, msg, mp1, mp2);
542}
543
544
545HWND CWM3UFolder::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
546{
547 HWND hwnd;
548 HMODULE hResource=queryResModuleHandle();
549 SIZEL sizel={0};
550 HWND myFrameCtrlHWND;
551 RECTL rectl;
552 MENUITEM mi={0};
553 HWND hwndMenu;
554 int iItemCount=0;
555 char text[200];
556 SWP swp;
557
558 /* Reregister wpFolder window class on first opening */
559 /* We need this private code to have some private
560 window words */
561 if(!g_fRegisteredWindowClass)
562 {
563 CLASSINFO ci;
564
565 if(WinQueryClassInfo(WinQueryAnchorBlock(HWND_DESKTOP),
566 (PSZ)"wpFolder window",
567 &ci))
568 {
569 g_ulFrameDataOffset=ci.cbWindowData;
570 //g_pfnwpOrgFrameProc=ci.pfnWindowProc;
571 if (WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP),
572 (PSZ)"wpFolder window",
573 ci.pfnWindowProc,
574 ci.flClassStyle,
575 ci.cbWindowData + MFLDR_WINDOWBYTES))
576 {
577 /* */
578 ulQWP_CONTAINERPROC+=g_ulFrameDataOffset;
579 ulQWP_THISPTR+=g_ulFrameDataOffset;
580 ulQWL_TOPCTRLHWND+=g_ulFrameDataOffset;
581 ulQWL_BOTTOMCTRLHWND+=g_ulFrameDataOffset;
582 ulQWL_LEFTCTRLHWND+=g_ulFrameDataOffset;
583 ulQWL_RIGHTCTRLHWND+=g_ulFrameDataOffset;
584 g_fRegisteredWindowClass=TRUE;
585 }
586 }
587 }
588
589 /* Skip media folder. Because of this skip we had to register the window words here (see above).
590 It's not asured a Mediafolder was already opended. Normaly the window words are added in
591 wpOpen() of the Mediafolder.
592 FIXME: This only works if CWProgFolder->CWMediaFolder->CWM3UFolder is the class hierarchy */
593 hwnd=CWProgFolder::wpOpen(hwndCnr, ulView, ulParam);
594
595 /* Only subclass folder frames, not settings notebooks */
596 if(ulView!=OPEN_SETTINGS){
597 if(!hResource) {
598 errorResource();
599 return hwnd;
600 }
601
602 TRY_LOUD(M3UFLDR_OPEN) {
603 THREADPARAMS* pTp;
604 ULONG ulErr;
605
606 /* Remove the title added by XWP */
607 WinSetWindowText(hwnd, wpObjM3UFile->wpQueryTitle());
608 if(!getMessage(text, IDSTR_PLAYLISTVIEWTITLE, sizeof(text), queryResModuleHandle(), HWND_DESKTOP))
609 sprintf(text, "Playlist Editor");
610 /* Set view title. By doing this the frame title isn't 'Details' anymore */
611 wpRegisterView(hwnd, text);
612
613 if(!(ulFlags & FLAG_ALREADYSIZED)) {
614 /* Make sure on first open the container is visible */
615 SWP swp;
616 WinQueryWindowPos(hwnd, &swp);
617 WinSetWindowPos(hwnd, NULLHANDLE, swp.x, swp.y-100, swp.cx, swp.cy+100, SWP_SIZE|SWP_MOVE);
618 ulFlags|=FLAG_ALREADYSIZED;
619 }
620
621 /* Build new menu entries. */
622 myFrameCtrlHWND=WinWindowFromID(hwnd,FID_MENU);//Get menu hwnd
623 if(WinIsWindow(WinQueryAnchorBlock(hwnd), myFrameCtrlHWND)) {
624 /* Menu bar found */
625
626 /* Remove folder item from menubar menu */
627 WinSendMsg( myFrameCtrlHWND, MM_REMOVEITEM, MPFROM2SHORT(0x2cf,TRUE),0);
628
629 /* Insert file menu for the folder */
630 hwndMenu=WinLoadMenu(myFrameCtrlHWND, hResource, ID_MENUFILE);
631 /* Fill the MENUITEM structure */
632 mi.iPosition=0;
633 mi.afStyle=MIS_TEXT|MIS_SUBMENU;
634 mi.id=ID_MENUFILE;
635 mi.afAttribute=NULL;
636 mi.hwndSubMenu=hwndMenu;
637 mi.hItem=NULL;
638 /* Add the item to the folder menubar */
639 /* Text: "~File" */
640 getMessage(text, IDSTR_MENUFILE,sizeof(text), hResource, hwnd);
641 WinSendMsg(myFrameCtrlHWND,MM_INSERTITEM,MPFROMP(&mi),
642 (MPARAM)text);
643
644 /* Insert skript and user menu item if necessary */
645 if(WinSendMsg(myFrameCtrlHWND,MM_QUERYITEM,MPFROM2SHORT(ID_MBMENUSKRIPTS,FALSE),MPFROMP(&mi))) {
646 /* Script menu is inserted so WPS-Wizard is installed */
647 hwndMenu=mi.hwndSubMenu;
648 if(hwndMenu){
649 /* The class specific skript menu is inserted in class CWFolder */
650 /* Query the number of items in the menubar */
651 iItemCount=(int)WinSendMsg(hwndMenu,MM_QUERYITEMCOUNT,(MPARAM)0,
652 (MPARAM)0);
653 if(iItemCount)
654 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_M3UFOLDER, FIRSTUSERITEM, TRUE);
655 else
656 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_M3UFOLDER, FIRSTUSERITEM, FALSE);
657 }
658 }
659#if 0
660 else {
661 /* Load the user menu from the resource if WPS-Wizard is not installed. If installed the menu item
662 is added by WPS-Wizzard. */
663 hwndMenu=WinLoadMenu(myFrameCtrlHWND,hResource, ID_MBMENUSKRIPTS);
664 if(hwndMenu){
665 /* Query the number of items in the menu */
666 iItemCount=(int)WinSendMsg(hwndMenu,MM_QUERYITEMCOUNT,(MPARAM)0,
667 (MPARAM)0);
668
669 if(iItemCount)
670 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_M3UFOLDER, FIRSTUSERITEM, TRUE);
671 else
672 cwInsertUserMenuItems(hwndMenu, USERMENUFOLDER_M3UFOLDER, FIRSTUSERITEM, FALSE);
673
674 /* Query the number of items in the menubar */
675 iItemCount=(int)WinSendMsg(myFrameCtrlHWND,MM_QUERYITEMCOUNT,(MPARAM)0,
676 (MPARAM)0);
677
678 /* Fill the MENUITEM structure */
679 mi.iPosition=iItemCount-1;
680 mi.afStyle=MIS_TEXT|MIS_SUBMENU;
681 mi.id=ID_MBMENUSKRIPTS;
682 mi.afAttribute=NULL;
683 mi.hwndSubMenu=hwndMenu;
684 mi.hItem=NULL;
685 /* Add the Misc-tools item to the folder menubar */
686 /* Text: "Skripts and tools" */
687 getMessage(text, IDSTR_MENUSKRIPTS,sizeof(text), hResource, hwnd);
688 WinSendMsg(myFrameCtrlHWND,MM_INSERTITEM,MPFROMP(&mi),
689 (MPARAM)text);
690 }/* end of if(hwndMenu) */
691 }
692#endif
693 }
694
695 /* Now add the framecontrols */
696
697 /* This is the Top-frameCtrl. */
698 /* Load the dialog from the resource. The object pointer of this
699 folder is given to the dialog procedure (this). In WM_INITDLG
700 the procedure saves this pointer for later use. */
701 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd, m3uTopCtrlDialogProc,hResource,IDDLG_TOPFRAME ,this);
702 /* Save the HWND in the instance data */
703 // hwndTop=myFrameCtrlHWND;
704 /* Save the HWND in the Window words */
705 WinSetWindowULong( hwnd, ulQWL_TOPCTRLHWND, myFrameCtrlHWND);
706
707 if(myFrameCtrlHWND){
708 /* Query the size of the dialog */
709 WinQueryWindowRect(myFrameCtrlHWND,&rectl);
710 /* It's the top dialog so we need the height but not the width. The width
711 is always the width of the folder. */
712 // sizel.cy=rectl.yTop-rectl.yBottom;
713 sizel.cy=12;
714 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
715 FCTL_TOP means put it at the top of the folder.
716 After calling cwUpdateFrame(hwnd) it will be visible */
717 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_TOP,0);
718 }
719
720 /* Load the dialog from the resource. The object pointer of this
721 folder is given to the dialog procedure (this). In WM_INITDLG
722 the procedure saves this pointer for later use. */
723 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,leftCtrlDialogProc,hResource,IDDLG_LEFTFRAME ,this);
724 /* Save the HWND in the instance data */
725 // hwndLeft=myFrameCtrlHWND;
726 /* Save the HWND in the Window words */
727 WinSetWindowULong( hwnd, ulQWL_LEFTCTRLHWND, myFrameCtrlHWND);
728
729
730 if(myFrameCtrlHWND){
731 /* Query the size of the dialog */
732 WinQueryWindowRect(myFrameCtrlHWND, &rectl);
733 /* It's the right dialog so we need the width but not the height. */
734 sizel.cx=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx-1-7-2;//rectl.xRight-rectl.xLeft;
735 // sizel.cx=rectl.xRight-rectl.xLeft;
736 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
737 FCTL_RIGHT means put it at the RIGHT of the folder.
738 After calling cwUpdateFrame(hwnd) it will be visible */
739 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_LEFT, FCTL_POSABOVE|FCTL_POSBELOW);
740 }
741
742 /* Load the dialog from the resource. The object pointer of this
743 folder is given to the dialog procedure (this). In WM_INITDLG
744 the procedure saves this pointer for later use. */
745 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,rightCtrlDialogProc,hResource,IDDLG_FRAMERIGHT ,this);
746 /* Save the HWND in the instance data */
747 // hwndRight=myFrameCtrlHWND;
748 /* Save the HWND in the Window words */
749 WinSetWindowULong( hwnd, ulQWL_RIGHTCTRLHWND, myFrameCtrlHWND);
750
751 if(myFrameCtrlHWND){
752 CNRINFO cnrInfo;
753 HWND hwndContainer;
754 PVIEWITEM pView;
755
756 /* Query the size of the dialog */
757 WinQueryWindowRect(myFrameCtrlHWND, &rectl);
758 /* It's the right dialog so we need the width but not the height. */
759 sizel.cx=allBMPs[CTRLIDX_TOPRIGHT].bmpInfoHdr.cx-1-7-2;// rectl.xRight-rectl.xLeft;
760 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
761 FCTL_RIGHT means put it at the RIGHT of the folder.
762 After calling cwUpdateFrame(hwnd) it will be visible */
763 cwAddFrameCtl(hwnd, myFrameCtrlHWND, sizel, FCTL_RIGHT, FCTL_POSABOVE|FCTL_POSBELOW);
764
765 // hwndContainer=WinWindowFromID(myFrameCtrlHWND, IDCNR_PLAYLIST);
766 // WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
767 // MPFROMLONG(sizeof(cnrInfo)));
768 }/* if(hwndRight) */
769
770 /* Load the dialog from the resource. The object pointer of this
771 folder is given to the dialog procedure (this). In WM_INITDLG
772 the procedure saves this pointer for later use. */
773 myFrameCtrlHWND=WinLoadDlg(hwnd,hwnd,bottomCtrlDialogProc,hResource,IDDLG_BOTTOMFRAME ,this);
774 /* Save the HWND in the instance data */
775 hwndBottom=myFrameCtrlHWND;
776 /* Save the HWND in the Window words */
777 WinSetWindowULong( hwnd, ulQWL_BOTTOMCTRLHWND, myFrameCtrlHWND);
778
779 if(hwndBottom){
780 /* Query the size of the dialog */
781 WinQueryWindowRect(hwndBottom,&rectl);
782 //sizel.cy=20;
783 sizel.cy=rectl.yTop-rectl.yBottom-2;
784 // sizel.cy=allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy;
785 /* Call a method of CWProgFolder to add the dialog as a framecontrol.
786 FCTL_TOP means put it at the top of the folder.
787 After calling cwUpdateFrame(hwnd) it will be visible */
788 cwAddFrameCtl(hwnd, hwndBottom, sizel, FCTL_BOTTOM,0);
789 }
790
791 /* Refresh frame to show the new framecontrols */
792 cwUpdateFrame(hwnd);
793
794 /* Subclass frame */
795 pfnwpFrame=WinSubclassWindow(hwnd, m3uFrameProc);
796 pfnwpGenericFrame=pfnwpFrame;
797
798 /* Subclass container */
799 myFrameCtrlHWND=WinWindowFromID(hwnd,FID_CLIENT);//Get container hwnd
800 if(myFrameCtrlHWND){
801 PFNWP pfnwpContainer;
802 pfnwpContainer=WinSubclassWindow(myFrameCtrlHWND, m3uFldrContainerProc);
803 /* Save container proc in frame window words */
804 WinSetWindowULong( hwnd, ulQWP_CONTAINERPROC, (ULONG)pfnwpContainer);
805 }
806 cwInsertAllTracks(NULLHANDLE);
807 }
808 CATCH(M3UFLDR_OPEN)
809 {
810 SysWriteToTrapLog("\nTrap occured in %s, file: %s above line %d.\n",
811 __FUNCTION__, __FILE__, __LINE__);
812
813 } END_CATCH;
814
815 /* Make sure on open the container is visible */
816 WinQueryWindowPos(hwnd, &swp);
817 WinSetWindowPos(hwnd, NULLHANDLE, swp.x, swp.y-200, swp.cx, swp.cy+200, SWP_SIZE|SWP_MOVE);
818 }
819
820 return hwnd;
821}
822
823BOOL CWM3UFolder::wpDeleteFromContent(WPObject* Object)
824{
825 fContentsChanged=TRUE;
826 return CWMediaFolder::wpDeleteFromContent(Object);
827}
828
829MRESULT CWM3UFolder::wpDrop(HWND hwndCnr,PDRAGINFO pDragInfo,PDRAGITEM pDragItem)
830{
831 return CWMediaFolder::wpDrop(hwndCnr, pDragInfo, pDragItem);
832}
833
834void _Optlink saveThreadFunc (void *arg)
835{
836 HAB hab;
837 HMQ hmq;
838 QMSG qmsg;
839 CWM3UFolder *thisPtr;
840 HWND hwnd;
841 char chrFileName[CCHMAXPATH];
842 ULONG ulSize;
843 M3UTHREADPARMS *parms=(M3UTHREADPARMS*)arg;
844
845
846 if(!parms)
847 return;
848
849 thisPtr=(CWM3UFolder*)parms->thisPtr;
850 if(!somIsObj(thisPtr))
851 return;
852
853 if(!somIsObj(thisPtr->wpObjM3UFile))
854 return;
855
856 ulSize=sizeof(chrFileName);
857 if(!((WPFileSystem*)thisPtr->wpObjM3UFile)->wpQueryRealName(chrFileName, &ulSize, TRUE))
858 return;
859
860 hab=WinInitialize(0);
861 if(hab) {
862 hmq=WinCreateMsgQueue(hab,0);
863 if(hmq) {
864 FILE* fStream;
865
866 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), parms->hwndCnr))
867 {
868 /* Container handle is valid */
869 if((fStream=fopen(chrFileName, "w"))!=NULLHANDLE) /* Open the playlist file */
870 {
871 HWND hwndContainer=parms->hwndCnr;
872
873 for(;;)
874 {
875 PMINIRECORDCORE mrc;
876 WPObject * contentObject;
877 /* Get first container item of our folder */
878 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, MPFROMSHORT(CMA_FIRST),
879 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
880 if(!mrc || (int)mrc==-1)
881 break;
882
883 do {
884 contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
885 if(somIsObj(contentObject)) {
886 /* Get file system object or NULL */
887 if((contentObject=thisPtr->cwGetFileSystemObject(contentObject))==NULLHANDLE) {
888 /* Try next object */
889 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
890 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
891 continue;
892 }
893 }
894 else
895 break;/* Error */
896
897 /* Get the name of the audio file */
898 ulSize=sizeof(chrFileName);
899 ((WPFileSystem*)contentObject)->wpQueryRealName(chrFileName,&ulSize,TRUE);
900 /* Try next object */
901 fputs(chrFileName,fStream);
902 fputs("\n",fStream);
903 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
904 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
905 }while(mrc && (int)mrc!=-1);
906 break;
907 }/* for() */
908 }/* fopen() */
909 fclose(fStream);
910 }
911 WinDestroyMsgQueue(hmq);
912 }
913 WinTerminate(hab);
914 }
915 /* Mark as saved */
916 thisPtr->fContentsChanged=FALSE;
917 if(!parms->fSaveOnly) {
918 /* Close and destroy the folder if requested */
919 WinPostMsg(parms->hwndFrame, WM_CLOSE, 0, 0);
920 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), thisPtr->hwndObject))
921 WinPostMsg(thisPtr->hwndObject, WM_APPTERMINATENOTIFY, 0, 0);
922 }
923 thisPtr->wpFreeMem((PBYTE)parms);
924}
925
926BOOL CWM3UFolder::cwSavePlaylist(char* chrM3UFile, BOOL fClose)
927{
928 M3UTHREADPARMS* parms;
929 ULONG ulError;
930
931 if((parms=(M3UTHREADPARMS*)wpAllocMem(sizeof(M3UTHREADPARMS),&ulError))!=NULLHANDLE)
932 {
933 HWND hwnd;
934
935 memset(parms,0, sizeof(M3UTHREADPARMS));
936 parms->thisPtr=this;
937 if((hwnd=WinQueryWindow(hwndBottom,QW_PARENT))!=NULLHANDLE)
938 {
939 parms->hwndFrame=hwnd;
940 parms->hwndCnr=WinWindowFromID(hwnd, FID_CLIENT);
941 }
942 if(fClose)
943 fClosing=TRUE;
944 else
945 parms->fSaveOnly=TRUE;
946
947 _beginthread(saveThreadFunc,NULL,8192*16,(void*)parms); //Fehlerbehandlung fehlt
948 }
949 else {
950 /* FIXME: Error handling!*/
951 }
952 return TRUE;
953}
954
955BOOL CWM3UFolder::cwClose(HWND hwndFrame)
956{
957 SWP swp;
958
959 if(fClosing)
960 return TRUE;
961
962 if(fContentsChanged)
963 {
964 char text[200];
965 char title[50];
966 ULONG ulRc;
967 if((ulRc=messageBox( text, IDSTR_M3UCLOSETEXT, sizeof(text),
968 title, IDSTR_CLOSETITLE, sizeof(title),
969 queryResModuleHandle(),
970 HWND_DESKTOP,
971 MB_YESNOCANCEL|MB_MOVEABLE|MB_ICONQUESTION))==MBID_CANCEL)
972 return FALSE;
973 if(ulRc==MBID_YES) {
974 cwSavePlaylist(NULLHANDLE, TRUE);
975 return FALSE;
976 }
977 }
978 fClosing=TRUE;
979
980 if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), hwndObject)) {
981 WinPostMsg(hwndObject, WM_APPTERMINATENOTIFY, 0, 0);
982 }
983 return TRUE;
984}
985
986ULONG CWM3UFolder::wpFilterPopupMenu(ULONG ulFlags, HWND hwndCnr, BOOL fMultiSelect)
987{
988
989 return CTXT_HELP|CTXT_SORT|CTXT_SETTINGS|CTXT_REFRESH|CTXT_FIND;
990#if 0
991 return CWMediaFolder::wpFilterPopupMenu(ulFlags, hwndCnr, fMultiSelect)&
992 ~(CTXT_COPY|CTXT_ICON|CTXT_CHANGETOICON|CTXT_CHANGETOTREE|CTXT_CHANGETODETAILS);
993#endif
994}
995
996BOOL CWM3UFolder::wpModifyPopupMenu(HWND hwndMenu, HWND hwndCnr, ULONG ulPosition)
997{
998 WinSendMsg( hwndMenu, MM_REMOVEITEM, MPFROM2SHORT(0x2ca, TRUE),0);
999 return TRUE;
1000}
1001
1002
1003
1004
1005
1006
1007
1008
Note: See TracBrowser for help on using the repository browser.