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

Last change on this file since 133 was 133, checked in by gyoung, 21 months ago

Merge Lar's 2.9 branch into the trunk

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