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