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