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