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