]> git.sesse.net Git - vlc/blob - modules/gui/wince/wince.h
19657978b3e978950dbd5e836c3d7227a04f205c
[vlc] / modules / gui / wince / wince.h
1 /*****************************************************************************
2  * wince.h: private WinCE interface descriptor
3  *****************************************************************************
4  * Copyright (C) 1999-2004 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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 #include <vlc_messages.h>
44
45 #include <stdio.h>
46 #include <string>
47 #include <vector>
48 using namespace std;
49
50 class CBaseWindow;
51 class MenuItemExt;
52 class VideoWindow;
53
54 /*****************************************************************************
55  * intf_sys_t: description and status of wxwindows interface
56  *****************************************************************************/
57 struct intf_sys_t
58 {
59     /* the parent window */
60     CBaseWindow         *p_window;
61
62     /* special actions */
63     bool          b_playing;
64
65     /* The input thread */
66     input_thread_t *    p_input;
67
68     /* The slider */
69     int                 i_slider_pos;                     /* slider position */
70     int                 i_slider_oldpos;                /* previous position */
71     bool          b_slider_free;                      /* slider status */
72
73
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     /* Dynamic Menu management */
83     vector<MenuItemExt*> *p_audio_menu;
84     vector<MenuItemExt*> *p_video_menu;
85     vector<MenuItemExt*> *p_navig_menu;
86     vector<MenuItemExt*> *p_settings_menu;
87
88     VideoWindow          *p_video_window;
89
90     HANDLE   thread_ready;
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( intf_thread_t *, CBaseWindow *, HINSTANCE );
143     ~Interface();
144
145     BOOL InitInstance();
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     bool 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 struct msg_cb_data_t
218 {
219     Messages *self;
220 };
221
222 /* Messages */
223 class Messages : public CBaseWindow
224 {
225 public:
226     /* Constructor */
227     Messages( intf_thread_t *, CBaseWindow *, HINSTANCE );
228      ~Messages();
229
230     static void sinkMessage (msg_cb_data_t *, msg_item_t *, unsigned);
231     void sinkMessage (msg_item_t *item, unsigned);
232
233 protected:
234
235     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
236
237     /* The messages window */
238     msg_subscription_t* sub;                  /* message bank subscription */
239     msg_cb_data_t *cb_data;
240     HWND hListView;
241     bool b_verbose;
242 };
243
244 /* ItemInfo Dialog */
245 class ItemInfoDialog : public CBaseWindow
246 {
247 public:
248     /* Constructor */
249     ItemInfoDialog( intf_thread_t *, CBaseWindow *,
250                     HINSTANCE, playlist_item_t * );
251     virtual ~ItemInfoDialog(){};
252
253 protected:
254
255     intf_thread_t *p_intf;
256     HWND hwndCB;        // Handle to the command bar (but no menu)
257
258     playlist_item_t *p_item;
259
260     /* Event handlers (these functions should _not_ be virtual) */
261     void OnOk();
262     void UpdateInfo();
263
264     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
265
266     /* Controls for the iteminfo dialog box */
267     HWND uri_label;
268     HWND uri_text;
269
270     HWND name_label;
271     HWND name_text;
272
273     HWND checkbox_label;
274     HWND enabled_checkbox;
275
276     HWND info_tree;
277 };
278
279 /* Open Dialog */
280 class SubsFileDialog;
281 class OpenDialog : public CBaseWindow
282 {
283 public:
284     /* Constructor */
285     OpenDialog( intf_thread_t *, CBaseWindow *, HINSTANCE, int, int );
286     virtual ~OpenDialog(){};
287
288     void UpdateMRL();
289     void UpdateMRL( int i_access_method );
290
291     HWND file_combo;
292
293 protected:
294
295     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
296
297     HWND mrl_box;
298     HWND mrl_label;
299     HWND mrl_combo;
300     HWND label;
301
302     HWND notebook;
303
304     HWND browse_button;
305     HWND subsfile_checkbox;
306     HWND subsfile_label;
307     HWND subsfile_button;
308     SubsFileDialog *subsfile_dialog;
309
310     HWND net_radios[4];
311     HWND net_label[4];
312
313     HWND net_port_label[4];
314     HWND net_ports[4];
315     HWND hUpdown[4];
316     int i_net_ports[4];
317
318     HWND net_addrs_label[4];
319     HWND net_addrs[4];
320
321     int i_open_arg;
322     int i_access;
323     int i_net_type;
324
325     void FilePanel( HWND hwnd );
326     void NetPanel( HWND hwnd );
327
328     void OnSubsFileEnable();
329     void OnSubsFileSettings( HWND hwnd );
330
331     void OnPageChange();
332
333     void OnFilePanelChange();
334     void OnFileBrowse();
335     void OnNetPanelChange( int event );
336     void OnNetTypeChange( int event );
337     void DisableNETCtrl();
338
339     void OnOk();
340
341     vector<string> mrl;
342     vector<string> subsfile_mrl;
343 };
344
345 /* Subtitles File Dialog */
346 class SubsFileDialog: public CBaseWindow
347 {
348 public:
349     /* Constructor */
350     SubsFileDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
351     virtual ~SubsFileDialog(){};
352
353     vector<string> subsfile_mrl;
354     HWND file_combo;
355
356 protected:
357     friend class OpenDialog;
358
359     HWND file_box;
360     HWND browse_button;
361
362     HWND enc_box;
363     HWND enc_label;
364     HWND encoding_combo;
365
366     HWND misc_box;
367     HWND delay_label;
368     HWND delay_edit;
369     HWND delay_spinctrl;
370     HWND fps_label;
371     HWND fps_edit;
372     HWND fps_spinctrl;
373
374     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
375
376     /* Event handlers (these functions should _not_ be virtual) */
377     void OnFileBrowse();
378 };
379
380 /* Playlist */
381 class Playlist : public CBaseWindow
382 {
383 public:
384     /* Constructor */
385     Playlist( intf_thread_t *, CBaseWindow *, HINSTANCE );
386     virtual ~Playlist(){};
387
388     void UpdatePlaylist();
389     void ShowPlaylist( bool );
390
391 protected:
392
393     bool b_need_update;
394     vlc_mutex_t lock;
395
396     int i_title_sorted;
397     int i_author_sorted;
398
399     HWND hwndCB;        // Handle to the command bar (contains menu)
400     HWND hwndTB;        // Handle to the toolbar.
401     HWND hListView;
402
403     void Rebuild();
404     void UpdateItem( int );
405     LRESULT ProcessCustomDraw( LPARAM lParam );
406     void HandlePopupMenu( HWND hwnd, POINT point);
407
408     void DeleteItem( int item );
409
410     void OnOpen();
411     void OnSave();
412
413     void OnDeleteSelection();
414     void OnInvertSelection();
415     void OnEnableSelection();
416     void OnDisableSelection();
417     void OnSelectAll();
418     void OnActivateItem( int i_item );
419     void ShowInfos( HWND hwnd, int i_item );
420
421     void OnUp();
422     void OnDown();
423
424     void OnRandom();
425     void OnLoop();
426     void OnRepeat();
427
428     void OnSort( UINT event );
429     void OnColSelect( int iSubItem );
430
431     void OnPopupPlay();
432     void OnPopupDel();
433     void OnPopupEna();
434     void OnPopupInfo( HWND hwnd );
435
436     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
437 };
438
439 /* Timer */
440 class Timer
441 {
442 public:
443     /* Constructor */
444     Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface );
445     virtual ~Timer();
446     void Notify( void );
447
448 private:
449     intf_thread_t *p_intf;
450     Interface *p_main_interface;
451     //Interface *p_main_interface;
452     int i_old_playing_status;
453     int i_old_rate;
454 };
455
456 /* Menus */
457 void RefreshSettingsMenu( intf_thread_t *_p_intf, HMENU hMenu );
458 void RefreshAudioMenu( intf_thread_t *_p_intf, HMENU hMenu );
459 void RefreshVideoMenu( intf_thread_t *_p_intf, HMENU hMenu );
460 void RefreshNavigMenu( intf_thread_t *_p_intf, HMENU hMenu );
461 void RefreshMenu( intf_thread_t *, vector<MenuItemExt*> *, HMENU, int,
462                   char **, vlc_object_t **, int );
463 int wce_GetMenuItemCount( HMENU );
464 void CreateMenuItem( intf_thread_t *, vector<MenuItemExt*> *, HMENU, char *,
465                      vlc_object_t *, int * );
466 HMENU CreateChoicesMenu( intf_thread_t *, vector<MenuItemExt*> *, char *,
467                          vlc_object_t *, int * );
468 void OnMenuEvent( intf_thread_t *, int );
469
470 /*****************************************************************************
471  * A small helper class which encapsulate wxMenuitem with some other useful
472  * things.
473  *****************************************************************************/
474 class MenuItemExt
475 {
476 public:
477     /* Constructor */
478     MenuItemExt( intf_thread_t *_p_intf, int _id, char *_psz_var,
479                  vlc_object_t * p_object, vlc_value_t _val, int _i_val_type );
480
481     virtual ~MenuItemExt();
482
483     static void ClearList( vector<MenuItemExt*> * );
484
485     int id;
486     intf_thread_t *p_intf;
487     char *psz_var;
488     int  i_val_type;
489     vlc_object_t * p_object;
490     vlc_value_t val;
491
492 private:
493
494 };
495
496
497 /* Preferences Dialog */
498 /* Preferences Dialog */
499 class PrefsTreeCtrl;
500 class PrefsDialog: public CBaseWindow
501 {
502 public:
503     /* Constructor */
504     PrefsDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
505     virtual ~PrefsDialog(){};
506
507 protected:
508
509     /* Event handlers (these functions should _not_ be virtual) */
510     void OnOk( void );
511     /*void OnCancel( UINT event );
512     void OnSave( UINT event );
513     void OnResetAll( UINT event );
514     void OnAdvanced( UINT event );*/
515
516     HWND save_button;
517     HWND reset_button;
518     HWND advanced_checkbox;
519     HWND advanced_label;
520
521     PrefsTreeCtrl *prefs_tree;
522
523     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
524 };
525
526 /*****************************************************************************
527  * A small helper function for utf8 <-> unicode conversions
528  *****************************************************************************/
529 #ifdef UNICODE
530     extern wchar_t pwsz_mbtow_wince[2048];
531     extern char psz_wtomb_wince[2048];
532     static inline wchar_t *_FROMMB( const char *psz_in )
533     {
534         mbstowcs( pwsz_mbtow_wince, psz_in, 2048 );
535         pwsz_mbtow_wince[2048-1] = 0;
536         return pwsz_mbtow_wince;
537     }
538     static inline char *_TOMB( const wchar_t *pwsz_in )
539     {
540         wcstombs( psz_wtomb_wince, pwsz_in, 2048 );
541         psz_wtomb_wince[2048-1] = 0;
542         return psz_wtomb_wince;
543     }
544 #else
545 #   define _FROMMB(a) a
546 #   define _TOMB(a) a
547 #endif
548
549 /*****************************************************************************
550  * Misc definitions (mainly from aygshell.h)
551  *****************************************************************************/
552 #define _WIN32_IE 0x0500
553
554 #define SHFS_SHOWSIPBUTTON          0x0004
555 #define SHFS_HIDESIPBUTTON          0x0008
556 #define SHIDIM_FLAGS                0x0001
557 #define SHIDIF_DONEBUTTON           0x0001
558 #define SHIDIF_SIPDOWN              0x0008
559 #define SHIDIF_FULLSCREENNOMENUBAR  0x0010
560 #define SHCMBF_HMENU                0x0010
561 #define SHCMBF_EMPTYBAR             0x0001
562 #define GN_CONTEXTMENU              1000
563 #define SHRG_RETURNCMD              0x0001
564 #define SHRG_NOTIFYPARENT           0x0002
565 #define SHCMBM_GETSUBMENU           (WM_USER + 401)
566 #define SHCMBM_GETMENU              (WM_USER + 402)
567 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
568 #define TBSTYLE_NO_DROPDOWN_ARROW   0x0080
569 #endif
570 #define lstrlenW wcslen
571 #define SHGetMenu(hwnd) \
572     (HMENU)SendMessage((hwnd), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0)
573 #define TrackPopupMenu(hm,u,x,y,r,hw,p) \
574     TrackPopupMenuEx((hm),(u),(x),(y),(hw),0)
575
576 extern "C" {
577     typedef struct tagSHMENUBARINFO
578     {
579         DWORD cbSize;
580         HWND hwndParent;
581         DWORD dwFlags;
582         UINT nToolBarId;
583         HINSTANCE hInstRes;
584         int nBmpId;
585         int cBmpImages;
586         HWND hwndMB;
587         COLORREF clrBk;
588     } SHMENUBARINFO, *PSHMENUBARINFO;
589
590     BOOL SHCreateMenuBar( SHMENUBARINFO *pmbi );
591     BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
592
593     typedef struct tagSHINITDLGINFO
594     {
595         DWORD dwMask;
596         HWND  hDlg;
597         DWORD dwFlags;
598     } SHINITDLGINFO, *PSHINITDLGINFO;
599
600     BOOL SHInitDialog(PSHINITDLGINFO pshidi);
601
602     typedef struct tagNMRGINFO
603     {
604         NMHDR hdr;
605         POINT ptAction;
606         DWORD dwItemSpec;
607     } NMRGINFO, *PNMRGINFO;
608
609     BOOL WINAPI CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
610
611     typedef struct tagSHRGI
612     {
613         DWORD cbSize;
614         HWND hwndClient;
615         POINT ptDown;
616         DWORD dwFlags;
617     } SHRGINFO, *PSHRGINFO;
618
619     DWORD SHRecognizeGesture(SHRGINFO *shrg);
620
621     typedef enum tagSIPSTATE
622     {
623         SIP_UP = 0,
624         SIP_DOWN,
625         SIP_FORCEDOWN,
626         SIP_UNCHANGED,
627         SIP_INPUTDIALOG,
628     } SIPSTATE;
629
630     BOOL SHSipPreference(HWND, SIPSTATE);
631
632     BOOL SHSipInfo(UINT, UINT, PVOID, UINT);
633
634     typedef struct
635     {
636         DWORD cbSize;
637         DWORD fdwFlags;
638         RECT rcVisibleDesktop;
639         RECT rcSipRect;
640         DWORD dwImDataSize;
641         VOID *pvImData;
642     } SIPINFO;
643 }
644
645 #if defined( WIN32 ) && !defined( UNDER_CE )
646 #   define SHFullScreen(a,b)
647 #   define SHInitDialog(a)
648 #   define SHCreateMenuBar(a) 1
649 #   define SHRecognizeGesture(a) 0
650 #   define SHSipPreference(a,b)
651
652 #   define SHSipInfo(a,b,c,d) 0
653 #endif
654
655 #endif //WINCE_RESOURCE
656
657 #define IDD_ABOUT                       101
658 #define IDI_ICON1                       102
659 #define IDB_BITMAP1                     103
660 #define IDB_BITMAP2                     111
661 #define IDR_MENUBAR1                    113
662 #define IDD_FILEINFO                    118
663 #define IDD_DUMMY                       118
664 #define IDD_MESSAGES                    119
665 #define IDR_MENUBAR                     120
666 #define IDR_MENUBAR2                    121
667 #define IDD_PLAYLIST                    122
668 #define IDB_BITMAP3                     123
669 #define IDD_ITEMINFO                    124
670 #define IDCLEAR                         1001
671 #define IDSAVEAS                        1002
672 #define ID_FILE                         40028
673 #define ID_VIEW                         40030
674 #define ID_SETTINGS                     40032
675 #define ID_AUDIO                        40034
676 #define ID_EMPTY                        40034
677 #define ID_VIDEO                        40036
678 #define ID_NAVIGATION                   40038
679 #define IDM_FILE                        40042
680 #define IDM_VIEW                        40044
681 #define IDM_SETTINGS                    40046
682 #define IDM_AUDIO                       40048
683 #define IDM_VIDEO                       40050
684 #define IDM_NAVIGATION                  40053
685 #define ID_FILE_QUICKOPEN               40057
686 #define ID_FILE_OPENFILE                40058
687 #define ID_FILE_OPENDIR                 40059
688 #define ID_FILE_OPENNET                 40060
689 #define ID_FILE_EXIT                    40061
690 #define ID_VIEW_PLAYLIST                40063
691 #define ID_VIEW_MESSAGES                40064
692 #define ID_VIEW_MEDIAINFO               40065
693 #define ID_VIEW_STREAMINFO              40066
694 #define ID_PREFERENCES                  40071
695 #define ID_FILE_ABOUT                   40069
696 #define IDM_MANAGE                      40087
697 #define IDM_SORT                        40088
698 #define IDM_SEL                         40089
699 #define ID_SORT_AUTHOR                  40091
700 #define ID_SORT_RAUTHOR                 40092
701 #define ID_SORT_SHUFFLE                 40095
702 #define ID_SEL_INVERT                   40096
703 #define ID_SEL_DELETE                   40097
704 #define ID_SEL_SELECTALL                40098
705 #define ID_SEL_ENABLE                   40100
706 #define ID_SEL_DISABLE                  40101
707 #define ID_SORT_TITLE                   40102
708 #define ID_SORT_RTITLE                  40103
709 #define ID_MANAGE_ADDFILE               40104
710 #define ID_MANAGE_ADDDIRECTORY          40105
711 #define ID_MANAGE_ADDMRL                40106
712 #define ID_MANAGE_OPENPL                40107
713 #define ID_MANAGE_SAVEPL                40108
714 #define StopStream_Event                57601
715 #define PlayStream_Event                57602
716 #define PrevStream_Event                57603
717 #define NextStream_Event                57604
718 #define SlowStream_Event                57605
719 #define FastStream_Event                57606