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