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