source: trunk/mediafolder/c/m3ufolder/m3ufolderoverriddenwpmethods.cpp@ 181

Last change on this file since 181 was 181, checked in by gyoung, 15 months ago

Add a separator to M3U list and Media Player help menu

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