]> git.sesse.net Git - vlc/blob - modules/gui/wince/wince.h
* modules/gui/wince: fixed bunch of bugs and memory leaks.
[vlc] / modules / gui / wince / wince.h
1 /*****************************************************************************
2  * wince.h: private WinCE interface descriptor
3  *****************************************************************************
4  * Copyright (C) 1999-2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Marodon Cedric <cedric_marodon@yahoo.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef WINCE_RESOURCE
26
27 #define SLIDER_HEIGHT 50
28 #define SLIDER_MAX_POS 10000
29 #define MENU_HEIGHT 26
30
31 #define FILE_ACCESS 1
32 #define NET_ACCESS 2
33
34 #define OPEN_NORMAL 0
35 #define OPEN_STREAM 1
36
37 #if defined( UNDER_CE ) && defined(__MINGW32__)
38     /* This is a gross hack for the wince gcc cross-compiler */
39 #   define _off_t long
40 #endif
41
42 #include "vlc_keys.h"
43
44 #include <stdio.h>
45 #include <string>
46 #include <vector>
47 using namespace std; 
48
49 class CBaseWindow;
50 class MenuItemExt;
51 class VideoWindow;
52
53 /*****************************************************************************
54  * intf_sys_t: description and status of wxwindows interface
55  *****************************************************************************/
56 struct intf_sys_t
57 {
58     /* special actions */
59     vlc_bool_t          b_playing;
60
61     /* The input thread */
62     input_thread_t *    p_input;
63
64     /* The slider */
65     int                 i_slider_pos;                     /* slider position */
66     int                 i_slider_oldpos;                /* previous position */
67     vlc_bool_t          b_slider_free;                      /* slider status */
68
69     /* The messages window */
70     msg_subscription_t* p_sub;                  /* message bank subscription */
71
72     /* Playlist management */
73     int                 i_playing;                 /* playlist selected item */
74
75     /* Send an event to show a dialog */
76     void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
77                              intf_dialog_args_t *p_arg );
78
79     CBaseWindow *p_main_window;
80
81     /* Dynamic Menu management */
82     vector<MenuItemExt*> *p_audio_menu;
83     vector<MenuItemExt*> *p_video_menu;
84     vector<MenuItemExt*> *p_navig_menu;
85     vector<MenuItemExt*> *p_settings_menu;
86
87     VideoWindow          *p_video_window;
88
89     /* GetOpenFileName replacement */
90     BOOL (WINAPI *GetOpenFile)(void *);
91     HMODULE h_gsgetfile_dll;
92 };
93
94 #define GetOpenFile(a) p_intf->p_sys->GetOpenFile(a)
95
96 /*****************************************************************************
97  * Prototypes
98  *****************************************************************************/
99
100 class CBaseWindow
101 {
102 public:
103     CBaseWindow() : hWnd(0), hInst(0) {};
104     virtual ~CBaseWindow() {};
105
106     HWND hWnd;                // The main window handle
107
108     static LRESULT CALLBACK BaseWndProc( HWND, UINT, WPARAM, LPARAM );
109     static int CreateDialogBox( HWND, CBaseWindow * );
110
111 protected:
112
113     HINSTANCE       hInst;               // The current instance
114     HWND            hwndCB;              // The command bar handle
115
116     HINSTANCE       GetInstance () const { return hInst; }
117     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM ) { return 0; };
118
119     intf_thread_t *p_intf;
120 };
121
122 class FileInfo;
123 class Messages;
124 class Playlist;
125 class Timer;
126 class OpenDialog;
127 class PrefsDialog;
128
129 CBaseWindow *CreateVideoWindow( intf_thread_t *, HWND );
130 void PopupMenu( intf_thread_t *, HWND, POINT );
131
132 /* Main Interface */
133 class Interface : public CBaseWindow
134 {
135 public:
136     /* Constructor */
137     Interface();
138     ~Interface();
139
140     BOOL InitInstance( HINSTANCE, intf_thread_t * );
141
142     HWND CreateMenuBar( HWND, HINSTANCE );
143     void TogglePlayButton( int i_playing_status );
144
145     HWND hwndMain;      // Handle to the main window.
146
147     HWND hwndCB;        // Handle to the command bar (contains menu)
148     HWND hwndTB;        // Handle to the toolbar.
149     HWND hwndSlider;       // Handle to the Sliderbar.
150     HWND hwndLabel;
151     HWND hwndVol;          // Handle to the volume trackbar.
152     HWND hwndSB;        // Handle to the status bar.
153     HMENU hPopUpMenu;
154     HMENU hMenu;
155
156     FileInfo *fileinfo;
157     Messages *messages;
158     PrefsDialog *preferences;
159     Playlist *playlist;
160     Timer *timer;
161     OpenDialog *open;
162     CBaseWindow *video;
163
164 protected:
165
166     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
167
168     void OnOpenFileSimple( void );
169     void OnPlayStream( void );
170     void OnVideoOnTop( void );
171
172     void OnSliderUpdate( int wp );
173     void OnChange( int wp );
174     void Change( int i_volume );
175     void OnStopStream( void );
176     void OnPrevStream( void );
177     void OnNextStream( void );
178     void OnSlowStream( void );
179     void OnFastStream( void );
180
181     int i_old_playing_status;
182
183 private:
184     HMENU menu_settings;
185     HMENU menu_video;
186     HMENU menu_audio;
187     HMENU menu_navigation;
188 };
189
190 /* File Info */
191 class FileInfo : public CBaseWindow
192 {
193 public:
194     /* Constructor */
195     FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst );
196     virtual ~FileInfo(){};
197
198 protected:
199
200     HWND hwnd_fileinfo;                 // handle to fileinfo window
201     HWND hwndTV;                                // handle to tree-view control 
202
203     TCHAR szFileInfoClassName[100];     // Main window class name
204     TCHAR szFileInfoTitle[100];         // Main window name
205
206     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
207     void UpdateFileInfo( HWND );
208     BOOL CreateTreeView( HWND );
209 };
210
211 /* Messages */
212 class Messages : public CBaseWindow
213 {
214 public:
215     /* Constructor */
216     Messages( intf_thread_t *_p_intf, HINSTANCE _hInst );
217     virtual ~Messages(){};
218
219 protected:
220
221     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
222
223     HWND hListView;
224     void UpdateLog(void);
225
226     vlc_bool_t b_verbose;
227 };
228
229 /* ItemInfo Dialog */
230 class ItemInfoDialog : public CBaseWindow
231 {
232 public:
233     /* Constructor */
234     ItemInfoDialog( intf_thread_t *, HINSTANCE, playlist_item_t * );
235     virtual ~ItemInfoDialog(){};
236
237 protected:
238
239     intf_thread_t *p_intf;
240     HWND hwndCB;        // Handle to the command bar (but no menu)
241
242     playlist_item_t *p_item;
243
244     /* Event handlers (these functions should _not_ be virtual) */
245     void OnOk();
246     void UpdateInfo();
247
248     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
249
250     /* Controls for the iteminfo dialog box */
251     HWND uri_label;
252     HWND uri_text;
253
254     HWND name_label;
255     HWND name_text;
256
257     HWND checkbox_label;
258     HWND enabled_checkbox;
259
260     HWND info_tree;
261 };
262
263 /* Open Dialog */
264 class SubsFileDialog;
265 class OpenDialog : public CBaseWindow
266 {
267 public:
268     /* Constructor */
269     OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
270                 int _i_access_method, int _i_arg, int _i_method );
271     virtual ~OpenDialog(){};
272
273     void UpdateMRL();
274     void UpdateMRL( int i_access_method );
275
276 protected:
277
278     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
279
280     HWND mrl_box;
281     HWND mrl_label;
282     HWND mrl_combo;
283     HWND label;
284
285     HWND notebook;
286
287     HWND file_combo;
288     HWND browse_button;
289     HWND subsfile_checkbox;
290     HWND subsfile_label;
291     HWND subsfile_button;
292     SubsFileDialog *subsfile_dialog;
293
294     HWND net_radios[4];
295     HWND net_label[4];
296
297     HWND net_port_label[4];
298     HWND net_ports[4];
299     HWND hUpdown[4];
300     int i_net_ports[4];
301
302     HWND net_addrs_label[4];
303     HWND net_addrs[4];
304         
305     int i_current_access_method;
306     int i_method; /* Normal or for the stream dialog ? */
307     int i_open_arg;
308     int i_net_type;
309         
310     void FilePanel( HWND hwnd );
311     void NetPanel( HWND hwnd );
312
313     void OnSubsFileEnable();
314     void OnSubsFileSettings( HWND hwnd );
315
316     void OnPageChange();
317
318     void OnFilePanelChange();
319     void OnFileBrowse();
320     void OnNetPanelChange( int event );
321     void OnNetTypeChange( int event );
322     void DisableNETCtrl();
323
324     void OnOk();
325
326     vector<string> mrl;
327     vector<string> subsfile_mrl;
328 };
329
330 /* Subtitles File Dialog */
331 class SubsFileDialog: public CBaseWindow
332 {
333 public:
334     /* Constructor */
335     SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
336     virtual ~SubsFileDialog(){};
337
338     vector<string> subsfile_mrl;
339
340 protected:
341     friend class OpenDialog;
342
343     HWND file_box;
344     HWND file_combo;
345     HWND browse_button;
346
347     HWND enc_box;
348     HWND enc_label;
349     HWND encoding_combo;
350
351     HWND misc_box;
352     HWND delay_label;
353     HWND delay_edit;
354     HWND delay_spinctrl;
355     HWND fps_label;
356     HWND fps_edit;
357     HWND fps_spinctrl;
358
359     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
360
361     /* Event handlers (these functions should _not_ be virtual) */
362     void OnFileBrowse();
363 };
364
365 /* Playlist */
366 class Playlist : public CBaseWindow
367 {
368 public:
369     /* Constructor */
370     Playlist( intf_thread_t *_p_intf, HINSTANCE _hInst );
371     virtual ~Playlist(){};
372
373 protected:
374
375     bool b_need_update;
376     vlc_mutex_t lock;
377
378     int i_title_sorted;
379     int i_author_sorted;
380
381     HWND hwndCB;        // Handle to the command bar (contains menu)
382     HWND hwndTB;        // Handle to the toolbar.
383     HWND hListView;
384
385     void UpdatePlaylist();
386     void Rebuild();
387     void UpdateItem( int );
388     LRESULT ProcessCustomDraw( LPARAM lParam );
389     void HandlePopupMenu( HWND hwnd, POINT point);
390
391     void DeleteItem( int item );
392
393     void OnOpen();
394     void OnSave();
395     void OnAddFile();
396     void OnAddMRL();
397
398     void OnDeleteSelection();
399     void OnInvertSelection();
400     void OnEnableSelection();
401     void OnDisableSelection();
402     void OnSelectAll();
403     void OnActivateItem( int i_item );
404     void ShowInfos( HWND hwnd, int i_item );
405
406     void OnUp();
407     void OnDown();
408
409     void OnRandom();
410     void OnLoop();
411     void OnRepeat();
412
413     void OnSort( UINT event );
414     void OnColSelect( int iSubItem );
415
416     void OnPopupPlay();
417     void OnPopupDel();
418     void OnPopupEna();
419     void OnPopupInfo( HWND hwnd );
420
421     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
422 };
423
424 /* Timer */
425 class Timer
426 {
427 public:
428     /* Constructor */
429     Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface);
430     virtual ~Timer();
431     void Notify( void ); 
432
433 private:
434     intf_thread_t *p_intf;
435     Interface *p_main_interface;
436     //Interface *p_main_interface;
437     int i_old_playing_status;
438     int i_old_rate;
439 };
440
441 /* Menus */
442 void RefreshSettingsMenu( intf_thread_t *_p_intf, HMENU hMenu );
443 void RefreshAudioMenu( intf_thread_t *_p_intf, HMENU hMenu );
444 void RefreshVideoMenu( intf_thread_t *_p_intf, HMENU hMenu );
445 void RefreshNavigMenu( intf_thread_t *_p_intf, HMENU hMenu );
446 void RefreshMenu( intf_thread_t *, vector<MenuItemExt*> *, HMENU, int,
447                   char **, int *, int );
448 int wce_GetMenuItemCount( HMENU );
449 void CreateMenuItem( intf_thread_t *, vector<MenuItemExt*> *, HMENU, char *,
450                      vlc_object_t *, int * );
451 HMENU CreateChoicesMenu( intf_thread_t *, vector<MenuItemExt*> *, char *, 
452                          vlc_object_t *, int * );
453 void OnMenuEvent( intf_thread_t *, int );
454
455 /*****************************************************************************
456  * A small helper class which encapsulate wxMenuitem with some other useful
457  * things.
458  *****************************************************************************/
459 class MenuItemExt
460 {
461 public:
462     /* Constructor */
463     MenuItemExt( intf_thread_t *_p_intf, int _id, char *_psz_var,
464                  int _i_object_id, vlc_value_t _val, int _i_val_type );
465
466     virtual ~MenuItemExt();
467
468     static void ClearList( vector<MenuItemExt*> * );
469
470     int id;
471     intf_thread_t *p_intf;
472     char *psz_var;
473     int  i_val_type;
474     int  i_object_id;
475     vlc_value_t val;
476
477 private:
478
479 };
480
481
482 /* Preferences Dialog */
483 /* Preferences Dialog */
484 class PrefsTreeCtrl;
485 class PrefsDialog: public CBaseWindow
486 {
487 public:
488     /* Constructor */
489     PrefsDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
490     virtual ~PrefsDialog(){};
491
492 protected:
493
494     /* Event handlers (these functions should _not_ be virtual) */
495     void OnOk( void );
496     /*void OnCancel( UINT event );
497     void OnSave( UINT event );
498     void OnResetAll( UINT event );
499     void OnAdvanced( UINT event );*/
500
501     HWND save_button;
502     HWND reset_button;
503     HWND advanced_checkbox;
504     HWND advanced_label;
505
506     PrefsTreeCtrl *prefs_tree;
507
508     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
509 };
510
511 /*****************************************************************************
512  * A small helper function for utf8 <-> unicode conversions
513  *****************************************************************************/
514 #ifdef UNICODE
515     extern wchar_t pwsz_mbtow_wince[2048];
516     extern char psz_wtomb_wince[2048];
517     static inline wchar_t *_FROMMB( const char *psz_in )
518     {
519         mbstowcs( pwsz_mbtow_wince, psz_in, 2048 );
520         pwsz_mbtow_wince[2048-1] = 0;
521         return pwsz_mbtow_wince;
522     }
523     static inline char *_TOMB( const wchar_t *pwsz_in )
524     {
525         wcstombs( psz_wtomb_wince, pwsz_in, 2048 );
526         psz_wtomb_wince[2048-1] = 0;
527         return psz_wtomb_wince;
528     }
529 #else
530 #   define _FROMMB(a) a
531 #   define _TOMB(a) a
532 #endif
533
534 #if defined( ENABLE_NLS ) && defined( ENABLE_UTF8 )
535 #   define ISUTF8 1
536 #else // ENABLE_NLS && ENABLE_UTF8
537 #   define ISUTF8 0
538 #endif
539
540 /*****************************************************************************
541  * Misc definitions (mainly from aygshell.h)
542  *****************************************************************************/
543 #define _WIN32_IE 0x0500
544
545 #define SHFS_HIDESIPBUTTON          0x0008
546 #define SHIDIM_FLAGS                0x0001
547 #define SHIDIF_DONEBUTTON           0x0001
548 #define SHIDIF_SIPDOWN              0x0008
549 #define SHIDIF_FULLSCREENNOMENUBAR  0x0010
550 #define SHCMBF_HMENU                0x0010
551 #define SHCMBF_EMPTYBAR             0x0001
552 #define SHFS_SHOWSIPBUTTON          0x0004
553 #define GN_CONTEXTMENU              1000
554 #define SHRG_RETURNCMD              0x0001
555 #define SHRG_NOTIFYPARENT           0x0002
556 #define SHCMBM_GETSUBMENU           (WM_USER + 401)
557 #define SHCMBM_GETMENU              (WM_USER + 402)
558 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
559 #define TBSTYLE_NO_DROPDOWN_ARROW   0x0080
560 #endif
561 #define lstrlenW wcslen
562 #define SHGetMenu(hwnd) \
563     (HMENU)SendMessage((hwnd), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0)
564 #define TrackPopupMenu(hm,u,x,y,r,hw,p) \
565     TrackPopupMenuEx((hm),(u),(x),(y),(hw),0)
566
567 extern "C" {
568     typedef struct tagSHMENUBARINFO
569     {
570         DWORD cbSize;
571         HWND hwndParent;
572         DWORD dwFlags;
573         UINT nToolBarId;
574         HINSTANCE hInstRes;
575         int nBmpId;
576         int cBmpImages;
577         HWND hwndMB;
578         COLORREF clrBk;
579     } SHMENUBARINFO, *PSHMENUBARINFO;
580
581     BOOL SHCreateMenuBar( SHMENUBARINFO *pmbi );
582     BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
583
584     typedef struct tagSHINITDLGINFO
585     {
586         DWORD dwMask;
587         HWND  hDlg;
588         DWORD dwFlags;
589     } SHINITDLGINFO, *PSHINITDLGINFO;
590
591     BOOL SHInitDialog(PSHINITDLGINFO pshidi);
592
593     typedef struct tagNMRGINFO
594     {
595         NMHDR hdr;
596         POINT ptAction;
597         DWORD dwItemSpec;
598     } NMRGINFO, *PNMRGINFO;
599
600     BOOL WINAPI CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
601
602     typedef struct tagSHRGI
603     {
604         DWORD cbSize;
605         HWND hwndClient;
606         POINT ptDown;
607         DWORD dwFlags;
608     } SHRGINFO, *PSHRGINFO;
609
610     DWORD SHRecognizeGesture(SHRGINFO *shrg);
611 }
612
613 #if defined( WIN32 ) && !defined( UNDER_CE )
614 #   define SHFullScreen(a,b)
615 #   define SHInitDialog(a)
616 #   define SHCreateMenuBar(a) 1
617 #   define SHRecognizeGesture(a) 0
618 #endif
619
620 #endif //WINCE_RESOURCE
621
622 #define IDD_ABOUT                       101
623 #define IDI_ICON1                       102
624 #define IDB_BITMAP1                     103
625 #define IDB_BITMAP2                     111
626 #define IDR_MENUBAR1                    113
627 #define IDD_FILEINFO                    118
628 #define IDD_DUMMY                       118
629 #define IDD_MESSAGES                    119
630 #define IDR_MENUBAR                     120
631 #define IDR_MENUBAR2                    121
632 #define IDD_PLAYLIST                    122
633 #define IDB_BITMAP3                     123
634 #define IDD_ITEMINFO                    124
635 #define IDCLEAR                         1001
636 #define IDSAVEAS                        1002
637 #define ID_FILE                         40028
638 #define ID_VIEW                         40030
639 #define ID_SETTINGS                     40032
640 #define ID_AUDIO                        40034
641 #define ID_EMPTY                        40034
642 #define ID_VIDEO                        40036
643 #define ID_NAVIGATION                   40038
644 #define IDM_FILE                        40042
645 #define IDM_VIEW                        40044
646 #define IDM_SETTINGS                    40046
647 #define IDM_AUDIO                       40048
648 #define IDM_VIDEO                       40050
649 #define IDM_NAVIGATION                  40053
650 #define ID_FILE_QUICKOPEN               40057
651 #define ID_FILE_OPENFILE                40058
652 #define ID_FILE_OPENNET                 40059
653 #define ID_FILE_EXIT                    40061
654 #define ID_VIEW_PLAYLIST                40063
655 #define ID_VIEW_MESSAGES                40064
656 #define ID_VIEW_MEDIAINFO               40065
657 #define ID_VIEW_STREAMINFO              40066
658 #define ID_PREFERENCES                  40071
659 #define ID_FILE_ABOUT                   40069
660 #define IDM_MANAGE                      40087
661 #define IDM_SORT                        40088
662 #define IDM_SEL                         40089
663 #define ID_SORT_AUTHOR                  40091
664 #define ID_SORT_RAUTHOR                 40092
665 #define ID_SORT_SHUFFLE                 40095
666 #define ID_SEL_INVERT                   40096
667 #define ID_SEL_DELETE                   40097
668 #define ID_SEL_SELECTALL                40098
669 #define ID_SEL_ENABLE                   40100
670 #define ID_SEL_DISABLE                  40101
671 #define ID_SORT_TITLE                   40102
672 #define ID_SORT_RTITLE                  40103
673 #define ID_MANAGE_ADDFILE               40104
674 #define ID_MANAGE_ADDDIRECTORY          40105
675 #define ID_MANAGE_ADDMRL                40106
676 #define ID_MANAGE_OPENPL                40107
677 #define ID_MANAGE_SAVEPL                40108
678 #define StopStream_Event                57601
679 #define PlayStream_Event                57602
680 #define PrevStream_Event                57603
681 #define NextStream_Event                57604
682 #define SlowStream_Event                57605
683 #define FastStream_Event                57606