]> git.sesse.net Git - vlc/blob - modules/gui/wince/wince.h
* modules/gui/wince: added a popup menu for the main interface.
[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(){ 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     void TogglePlayButton( int i_playing_status );
143
144     HWND hwndMain;      // Handle to the main window.
145
146     HWND hwndCB;        // Handle to the command bar (contains menu)
147     HWND hwndTB;        // Handle to the toolbar.
148     HWND hwndSlider;       // Handle to the Sliderbar.
149     HWND hwndLabel;
150     HWND hwndVol;          // Handle to the volume trackbar.
151     HWND hwndSB;        // Handle to the status bar.
152     HMENU hPopUpMenu;
153     HMENU hMenu;
154     FileInfo *fi; // pas besoin de la plupart de ses attributs
155     Messages *hmsg;
156     PrefsDialog *pref;
157     Playlist *pl;
158     Timer *ti;
159     OpenDialog *open;
160     CBaseWindow *video;
161     HWND hwndVideo;
162
163 protected:
164
165     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
166
167     void OnOpenFileSimple( void );
168     void OnPlayStream( void );
169     void OnVideoOnTop( void );
170
171     void OnSliderUpdate( int wp );
172     void OnChange( int wp );
173     void Change( int i_volume );
174     void OnStopStream( void );
175     void OnPrevStream( void );
176     void OnNextStream( void );
177     void OnSlowStream( void );
178     void OnFastStream( void );
179
180     int i_old_playing_status;
181 };
182
183 /* File Info */
184 class FileInfo : public CBaseWindow
185 {
186 public:
187     /* Constructor */
188     FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst );
189     virtual ~FileInfo(){};
190
191 protected:
192
193     HWND hwnd_fileinfo;                 // handle to fileinfo window
194     HWND hwndTV;                                // handle to tree-view control 
195
196     TCHAR szFileInfoClassName[100];     // Main window class name
197     TCHAR szFileInfoTitle[100];         // Main window name
198
199     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
200     void UpdateFileInfo( HWND );
201     BOOL CreateTreeView( HWND );
202 };
203
204 /* Messages */
205 class Messages : public CBaseWindow
206 {
207 public:
208     /* Constructor */
209     Messages( intf_thread_t *_p_intf, HINSTANCE _hInst );
210     virtual ~Messages(){};
211
212 protected:
213
214     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
215
216     HWND hListView;
217     void UpdateLog(void);
218
219     vlc_bool_t b_verbose;
220 };
221
222 /* ItemInfo Dialog */
223 class ItemInfoDialog : public CBaseWindow
224 {
225 public:
226     /* Constructor */
227     ItemInfoDialog( intf_thread_t *, HINSTANCE, playlist_item_t * );
228     virtual ~ItemInfoDialog(){};
229
230 protected:
231
232     intf_thread_t *p_intf;
233     HWND hwndCB;        // Handle to the command bar (but no menu)
234
235     playlist_item_t *p_item;
236
237     /* Event handlers (these functions should _not_ be virtual) */
238     void OnOk();
239     void UpdateInfo();
240
241     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
242
243     /* Controls for the iteminfo dialog box */
244     HWND uri_label;
245     HWND uri_text;
246
247     HWND name_label;
248     HWND name_text;
249
250     HWND checkbox_label;
251     HWND enabled_checkbox;
252
253     HWND info_tree;
254 };
255
256 /* Open Dialog */
257 class SubsFileDialog;
258 class OpenDialog : public CBaseWindow
259 {
260 public:
261     /* Constructor */
262     OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
263                 int _i_access_method, int _i_arg, int _i_method );
264     virtual ~OpenDialog(){};
265
266     void UpdateMRL();
267     void UpdateMRL( int i_access_method );
268
269 protected:
270
271     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
272
273     HWND mrl_box;
274     HWND mrl_label;
275     HWND mrl_combo;
276     HWND label;
277
278     HWND notebook;
279
280     HWND file_combo;
281     HWND browse_button;
282     HWND subsfile_checkbox;
283     HWND subsfile_label;
284     HWND subsfile_button;
285     SubsFileDialog *subsfile_dialog;
286
287     HWND net_radios[4];
288     HWND net_label[4];
289
290     HWND net_port_label[4];
291     HWND net_ports[4];
292     HWND hUpdown[4];
293     int i_net_ports[4];
294
295     HWND net_addrs_label[4];
296     HWND net_addrs[4];
297         
298     int i_current_access_method;
299     int i_method; /* Normal or for the stream dialog ? */
300     int i_open_arg;
301     int i_net_type;
302         
303     void FilePanel( HWND hwnd );
304     void NetPanel( HWND hwnd );
305
306     void OnSubsFileEnable();
307     void OnSubsFileSettings( HWND hwnd );
308
309     void OnPageChange();
310
311     void OnFilePanelChange();
312     void OnFileBrowse();
313     void OnNetPanelChange( int event );
314     void OnNetTypeChange( int event );
315     void DisableNETCtrl();
316
317     void OnOk();
318
319     vector<string> mrl;
320     vector<string> subsfile_mrl;
321 };
322
323 /* Subtitles File Dialog */
324 class SubsFileDialog: public CBaseWindow
325 {
326 public:
327     /* Constructor */
328     SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
329     virtual ~SubsFileDialog(){};
330
331     vector<string> subsfile_mrl;
332
333 protected:
334     friend class OpenDialog;
335
336     HWND file_box;
337     HWND file_combo;
338     HWND browse_button;
339
340     HWND enc_box;
341     HWND enc_label;
342     HWND encoding_combo;
343
344     HWND misc_box;
345     HWND delay_label;
346     HWND delay_edit;
347     HWND delay_spinctrl;
348     HWND fps_label;
349     HWND fps_edit;
350     HWND fps_spinctrl;
351
352     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
353
354     /* Event handlers (these functions should _not_ be virtual) */
355     void OnFileBrowse();
356 };
357
358 /* Playlist */
359 class Playlist : public CBaseWindow
360 {
361 public:
362     /* Constructor */
363     Playlist( intf_thread_t *_p_intf, HINSTANCE _hInst );
364     virtual ~Playlist(){};
365
366 protected:
367
368     bool b_need_update;
369     vlc_mutex_t lock;
370
371     int i_title_sorted;
372     int i_author_sorted;
373
374     HWND hwndCB;        // Handle to the command bar (contains menu)
375     HWND hwndTB;        // Handle to the toolbar.
376     HWND hListView;
377
378     void UpdatePlaylist();
379     void Rebuild();
380     void UpdateItem( int );
381     LRESULT ProcessCustomDraw( LPARAM lParam );
382     void HandlePopupMenu( HWND hwnd, POINT point);
383
384     void DeleteItem( int item );
385
386     void OnOpen();
387     void OnSave();
388     void OnAddFile( vlc_bool_t );
389     void OnAddMRL();
390
391     void OnDeleteSelection();
392     void OnInvertSelection();
393     void OnEnableSelection();
394     void OnDisableSelection();
395     void OnSelectAll();
396     void OnActivateItem( int i_item );
397     void ShowInfos( HWND hwnd, int i_item );
398
399     void OnUp();
400     void OnDown();
401
402     void OnRandom();
403     void OnLoop();
404     void OnRepeat();
405
406     void OnSort( UINT event );
407     void OnColSelect( int iSubItem );
408
409     void OnPopupPlay();
410     void OnPopupDel();
411     void OnPopupEna();
412     void OnPopupInfo( HWND hwnd );
413
414     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
415 };
416
417 /* Timer */
418 class Timer
419 {
420 public:
421     /* Constructor */
422     Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface);
423     virtual ~Timer();
424     void Notify( void ); 
425
426 private:
427     intf_thread_t *p_intf;
428     Interface *p_main_interface;
429     //Interface *p_main_interface;
430     int i_old_playing_status;
431     int i_old_rate;
432 };
433
434 /* Menus */
435 void RefreshSettingsMenu( intf_thread_t *_p_intf, HMENU hMenu );
436 void RefreshAudioMenu( intf_thread_t *_p_intf, HMENU hMenu );
437 void RefreshVideoMenu( intf_thread_t *_p_intf, HMENU hMenu );
438 void RefreshNavigMenu( intf_thread_t *_p_intf, HMENU hMenu );
439 void RefreshMenu( intf_thread_t *, vector<MenuItemExt*> *, HMENU, int,
440                   char **, int *, int );
441 int wce_GetMenuItemCount( HMENU );
442 void CreateMenuItem( intf_thread_t *, vector<MenuItemExt*> *, HMENU, char *,
443                      vlc_object_t *, int * );
444 HMENU CreateChoicesMenu( intf_thread_t *, vector<MenuItemExt*> *, char *, 
445                          vlc_object_t *, int * );
446 void OnMenuEvent( intf_thread_t *, int );
447
448 /*****************************************************************************
449  * A small helper class which encapsulate wxMenuitem with some other useful
450  * things.
451  *****************************************************************************/
452 class MenuItemExt
453 {
454 public:
455     /* Constructor */
456     MenuItemExt( intf_thread_t *_p_intf, int _id, char *_psz_var,
457                  int _i_object_id, vlc_value_t _val, int _i_val_type );
458
459     virtual ~MenuItemExt();
460
461     int id;
462     intf_thread_t *p_intf;
463     char *psz_var;
464     int  i_val_type;
465     int  i_object_id;
466     vlc_value_t val;
467
468 private:
469
470 };
471
472
473 /* Preferences Dialog */
474 /* Preferences Dialog */
475 class PrefsTreeCtrl;
476 class PrefsDialog: public CBaseWindow
477 {
478 public:
479     /* Constructor */
480     PrefsDialog( intf_thread_t *_p_intf, HINSTANCE _hInst );
481     virtual ~PrefsDialog(){};
482
483 protected:
484
485     /* Event handlers (these functions should _not_ be virtual) */
486     void OnOk( void );
487     /*void OnCancel( UINT event );
488     void OnSave( UINT event );
489     void OnResetAll( UINT event );
490     void OnAdvanced( UINT event );*/
491
492     HWND save_button;
493     HWND reset_button;
494     HWND advanced_checkbox;
495     HWND advanced_label;
496
497     PrefsTreeCtrl *prefs_tree;
498
499     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
500 };
501
502 /*****************************************************************************
503  * A small helper function for utf8 <-> unicode conversions
504  *****************************************************************************/
505 #ifdef UNICODE
506     static wchar_t pwsz_mbtow[2048];
507     static char psz_wtomb[2048];
508     static inline wchar_t *_FROMMB( const char *psz_in )
509     {
510         mbstowcs( pwsz_mbtow, psz_in, 2048 );
511         pwsz_mbtow[2048-1] = 0;
512         return pwsz_mbtow;
513     }
514     static inline char *_TOMB( const wchar_t *pwsz_in )
515     {
516         wcstombs( psz_wtomb, pwsz_in, 2048 );
517         psz_wtomb[2048-1] = 0;
518         return psz_wtomb;
519     }
520 #else
521 #   define _FROMMB(a) a
522 #   define _TOMB(a) a
523 #endif
524
525 #if defined( ENABLE_NLS ) && defined( ENABLE_UTF8 )
526 #   define ISUTF8 1
527 #else // ENABLE_NLS && ENABLE_UTF8
528 #   define ISUTF8 0
529 #endif
530
531 /*****************************************************************************
532  * Misc definitions (mainly from aygshell.h)
533  *****************************************************************************/
534 #define _WIN32_IE 0x0500
535
536 #define SHFS_HIDESIPBUTTON          0x0008
537 #define SHIDIM_FLAGS                0x0001
538 #define SHIDIF_DONEBUTTON           0x0001
539 #define SHIDIF_SIPDOWN              0x0008
540 #define SHIDIF_FULLSCREENNOMENUBAR  0x0010
541 #define SHCMBF_HMENU                0x0010
542 #define SHCMBF_EMPTYBAR             0x0001
543 #define SHFS_SHOWSIPBUTTON          0x0004
544 #define GN_CONTEXTMENU              1000
545 #define SHRG_RETURNCMD              0x0001
546 #define SHRG_NOTIFYPARENT           0x0002
547 #define SHCMBM_GETSUBMENU           (WM_USER + 401)
548 #define SHCMBM_GETMENU              (WM_USER + 402)
549 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
550 #define TBSTYLE_NO_DROPDOWN_ARROW   0x0080
551 #endif
552 #define lstrlenW wcslen
553 #define SHGetMenu(hwnd) \
554     (HMENU)SendMessage((hwnd), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0)
555 #define TrackPopupMenu(hm,u,x,y,r,hw,p) \
556     TrackPopupMenuEx((hm),(u),(x),(y),(hw),0)
557
558 extern "C" {
559     typedef struct tagSHMENUBARINFO
560     {
561         DWORD cbSize;
562         HWND hwndParent;
563         DWORD dwFlags;
564         UINT nToolBarId;
565         HINSTANCE hInstRes;
566         int nBmpId;
567         int cBmpImages;
568         HWND hwndMB;
569         COLORREF clrBk;
570     } SHMENUBARINFO, *PSHMENUBARINFO;
571
572     BOOL SHCreateMenuBar( SHMENUBARINFO *pmbi );
573     BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
574
575     typedef struct tagSHINITDLGINFO
576     {
577         DWORD dwMask;
578         HWND  hDlg;
579         DWORD dwFlags;
580     } SHINITDLGINFO, *PSHINITDLGINFO;
581
582     BOOL SHInitDialog(PSHINITDLGINFO pshidi);
583
584     typedef struct tagNMRGINFO
585     {
586         NMHDR hdr;
587         POINT ptAction;
588         DWORD dwItemSpec;
589     } NMRGINFO, *PNMRGINFO;
590
591     BOOL WINAPI CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
592
593     typedef struct tagSHRGI
594     {
595         DWORD cbSize;
596         HWND hwndClient;
597         POINT ptDown;
598         DWORD dwFlags;
599     } SHRGINFO, *PSHRGINFO;
600
601     DWORD SHRecognizeGesture(SHRGINFO *shrg);
602 }
603
604 #if defined( WIN32 ) && !defined( UNDER_CE )
605 #   define SHFullScreen(a,b)
606 #   define SHInitDialog(a)
607 #   define SHCreateMenuBar(a) 1
608 #   define SHRecognizeGesture(a) 0
609 #endif
610
611 #endif //WINCE_RESOURCE
612
613 #define IDD_ABOUT                       101
614 #define IDI_ICON1                       102
615 #define IDB_BITMAP1                     103
616 #define IDB_BITMAP2                     111
617 #define IDR_MENUBAR1                    113
618 #define IDD_FILEINFO                    118
619 #define IDD_DUMMY                       118
620 #define IDD_MESSAGES                    119
621 #define IDR_MENUBAR                     120
622 #define IDR_MENUBAR2                    121
623 #define IDD_PLAYLIST                    122
624 #define IDB_BITMAP3                     123
625 #define IDD_ITEMINFO                    124
626 #define IDCLEAR                         1001
627 #define IDSAVEAS                        1002
628 #define ID_FILE                         40028
629 #define ID_VIEW                         40030
630 #define ID_SETTINGS                     40032
631 #define ID_AUDIO                        40034
632 #define ID_EMPTY                        40034
633 #define ID_VIDEO                        40036
634 #define ID_NAVIGATION                   40038
635 #define IDM_FILE                        40042
636 #define IDM_VIEW                        40044
637 #define IDM_SETTINGS                    40046
638 #define IDM_AUDIO                       40048
639 #define IDM_VIDEO                       40050
640 #define IDM_NAVIGATION                  40053
641 #define ID_FILE_QUICKOPEN               40057
642 #define ID_FILE_OPENFILE                40058
643 #define ID_FILE_OPENNET                 40059
644 #define ID_FILE_EXIT                    40061
645 #define ID_VIEW_PLAYLIST                40063
646 #define ID_VIEW_MESSAGES                40064
647 #define ID_VIEW_MEDIAINFO               40065
648 #define ID_VIEW_STREAMINFO              40066
649 #define ID_PREFERENCES                  40071
650 #define ID_FILE_ABOUT                   40069
651 #define IDM_MANAGE                      40087
652 #define IDM_SORT                        40088
653 #define IDM_SEL                         40089
654 #define ID_SORT_AUTHOR                  40091
655 #define ID_SORT_RAUTHOR                 40092
656 #define ID_SORT_SHUFFLE                 40095
657 #define ID_SEL_INVERT                   40096
658 #define ID_SEL_DELETE                   40097
659 #define ID_SEL_SELECTALL                40098
660 #define ID_SEL_ENABLE                   40100
661 #define ID_SEL_DISABLE                  40101
662 #define ID_SORT_TITLE                   40102
663 #define ID_SORT_RTITLE                  40103
664 #define ID_MANAGE_ADDFILE               40104
665 #define ID_MANAGE_ADDDIRECTORY          40105
666 #define ID_MANAGE_ADDMRL                40106
667 #define ID_MANAGE_OPENPL                40107
668 #define ID_MANAGE_SAVEPL                40108
669 #define StopStream_Event                57601
670 #define PlayStream_Event                57602
671 #define PrevStream_Event                57603
672 #define NextStream_Event                57604
673 #define SlowStream_Event                57605
674 #define FastStream_Event                57606