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