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