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