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