00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WINCE_RESOURCE
00026
00027 #define SLIDER_HEIGHT 50
00028 #define SLIDER_MAX_POS 10000
00029 #define MENU_HEIGHT 26
00030
00031 #define FILE_ACCESS 1
00032 #define NET_ACCESS 2
00033
00034 #define OPEN_NORMAL 0
00035 #define OPEN_STREAM 1
00036
00037 #if defined( UNDER_CE ) && defined(__MINGW32__)
00038
00039 # define _off_t long
00040 #endif
00041
00042 #include <vlc_keys.h>
00043 #include <vlc_messages.h>
00044
00045 #include <stdio.h>
00046 #include <string>
00047 #include <vector>
00048 using namespace std;
00049
00050 class CBaseWindow;
00051 class MenuItemExt;
00052 class VideoWindow;
00053
00054
00055
00056
00057 struct intf_sys_t
00058 {
00059
00060 CBaseWindow *p_window;
00061
00062
00063 bool b_playing;
00064
00065
00066 input_thread_t * p_input;
00067
00068
00069 int i_slider_pos;
00070 int i_slider_oldpos;
00071 bool b_slider_free;
00072
00073
00074
00075
00076 int i_playing;
00077
00078
00079 void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
00080 intf_dialog_args_t *p_arg );
00081
00082
00083 vector<MenuItemExt*> *p_audio_menu;
00084 vector<MenuItemExt*> *p_video_menu;
00085 vector<MenuItemExt*> *p_navig_menu;
00086 vector<MenuItemExt*> *p_settings_menu;
00087
00088 VideoWindow *p_video_window;
00089
00090 HANDLE thread_ready;
00091 };
00092
00093
00094
00095
00096
00097 class CBaseWindow
00098 {
00099 public:
00100 CBaseWindow( intf_thread_t *_p_intf = 0, CBaseWindow *_p_parent = 0,
00101 HINSTANCE _hInst = 0 )
00102 : hWnd(0), hInst(_hInst), p_parent(_p_parent), p_intf(_p_intf) {};
00103 virtual ~CBaseWindow() {};
00104
00105 HWND hWnd;
00106
00107 static LRESULT CALLBACK BaseWndProc( HWND, UINT, WPARAM, LPARAM );
00108 static int CreateDialogBox( HWND, CBaseWindow * );
00109
00110 HWND GetHandle() { return hWnd; }
00111 BOOL Show( BOOL b_show ) { return (hWnd && ShowWindow(hWnd, b_show)); }
00112 BOOL IsShown( void ) { return (hWnd && IsWindowVisible(hWnd)); }
00113
00114 protected:
00115
00116 HINSTANCE hInst;
00117 HWND hwndCB;
00118
00119 HINSTANCE GetInstance () const { return hInst; }
00120 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM ) { return 0; };
00121
00122 CBaseWindow *p_parent;
00123 intf_thread_t *p_intf;
00124 };
00125
00126 class FileInfo;
00127 class Messages;
00128 class Playlist;
00129 class Timer;
00130 class OpenDialog;
00131 class PrefsDialog;
00132
00133 CBaseWindow *CreateDialogsProvider( intf_thread_t *, CBaseWindow *, HINSTANCE);
00134 CBaseWindow *CreateVideoWindow( intf_thread_t *, HWND );
00135 void PopupMenu( intf_thread_t *, HWND, POINT );
00136
00137
00138 class Interface : public CBaseWindow
00139 {
00140 public:
00141
00142 Interface( intf_thread_t *, CBaseWindow *, HINSTANCE );
00143 ~Interface();
00144
00145 BOOL InitInstance();
00146
00147 HWND CreateMenuBar( HWND, HINSTANCE );
00148 void TogglePlayButton( int i_playing_status );
00149 void Update();
00150
00151 HWND hwndMain;
00152
00153 HWND hwndCB;
00154 HWND hwndTB;
00155 HWND hwndSlider;
00156 HWND hwndLabel;
00157 HWND hwndVol;
00158 HWND hwndSB;
00159 HMENU hPopUpMenu;
00160 HMENU hMenu;
00161
00162 Timer *timer;
00163 CBaseWindow *video;
00164
00165 protected:
00166
00167 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00168
00169 void OnShowDialog( int );
00170
00171 void OnPlayStream( void );
00172 void OnStopStream( void );
00173 void OnPrevStream( void );
00174 void OnNextStream( void );
00175 void OnSlowStream( void );
00176 void OnFastStream( void );
00177
00178 void OnVideoOnTop( void );
00179 void OnSliderUpdate( int wp );
00180 void OnChange( int wp );
00181 void VolumeChange( int i_volume );
00182 void VolumeUpdate( void );
00183
00184 int i_old_playing_status;
00185
00186 private:
00187 HMENU menu_settings;
00188 HMENU menu_video;
00189 HMENU menu_audio;
00190 HMENU menu_navigation;
00191
00192 bool b_volume_hold;
00193 };
00194
00195
00196 class FileInfo : public CBaseWindow
00197 {
00198 public:
00199
00200 FileInfo( intf_thread_t *, CBaseWindow *, HINSTANCE );
00201 virtual ~FileInfo(){};
00202
00203 void UpdateFileInfo(void);
00204
00205 protected:
00206
00207 HWND hwnd_fileinfo;
00208 HWND hwndTV;
00209
00210 TCHAR szFileInfoClassName[100];
00211 TCHAR szFileInfoTitle[100];
00212
00213 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00214 BOOL CreateTreeView( HWND );
00215 };
00216
00217 struct msg_cb_data_t
00218 {
00219 Messages *self;
00220 };
00221
00222
00223 class Messages : public CBaseWindow
00224 {
00225 public:
00226
00227 Messages( intf_thread_t *, CBaseWindow *, HINSTANCE );
00228 ~Messages();
00229
00230 static void sinkMessage (msg_cb_data_t *, msg_item_t *, unsigned);
00231 void sinkMessage (msg_item_t *item, unsigned);
00232
00233 protected:
00234
00235 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00236
00237
00238 msg_subscription_t* sub;
00239 msg_cb_data_t *cb_data;
00240 HWND hListView;
00241 bool b_verbose;
00242 };
00243
00244
00245 class ItemInfoDialog : public CBaseWindow
00246 {
00247 public:
00248
00249 ItemInfoDialog( intf_thread_t *, CBaseWindow *,
00250 HINSTANCE, playlist_item_t * );
00251 virtual ~ItemInfoDialog(){};
00252
00253 protected:
00254
00255 intf_thread_t *p_intf;
00256 HWND hwndCB;
00257
00258 playlist_item_t *p_item;
00259
00260
00261 void OnOk();
00262 void UpdateInfo();
00263
00264 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00265
00266
00267 HWND uri_label;
00268 HWND uri_text;
00269
00270 HWND name_label;
00271 HWND name_text;
00272
00273 HWND checkbox_label;
00274 HWND enabled_checkbox;
00275
00276 HWND info_tree;
00277 };
00278
00279
00280 class SubsFileDialog;
00281 class OpenDialog : public CBaseWindow
00282 {
00283 public:
00284
00285 OpenDialog( intf_thread_t *, CBaseWindow *, HINSTANCE, int, int );
00286 virtual ~OpenDialog(){};
00287
00288 void UpdateMRL();
00289 void UpdateMRL( int i_access_method );
00290
00291 HWND file_combo;
00292
00293 protected:
00294
00295 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00296
00297 HWND mrl_box;
00298 HWND mrl_label;
00299 HWND mrl_combo;
00300 HWND label;
00301
00302 HWND notebook;
00303
00304 HWND browse_button;
00305 HWND subsfile_checkbox;
00306 HWND subsfile_label;
00307 HWND subsfile_button;
00308 SubsFileDialog *subsfile_dialog;
00309
00310 HWND net_radios[4];
00311 HWND net_label[4];
00312
00313 HWND net_port_label[4];
00314 HWND net_ports[4];
00315 HWND hUpdown[4];
00316 int i_net_ports[4];
00317
00318 HWND net_addrs_label[4];
00319 HWND net_addrs[4];
00320
00321 int i_open_arg;
00322 int i_access;
00323 int i_net_type;
00324
00325 void FilePanel( HWND hwnd );
00326 void NetPanel( HWND hwnd );
00327
00328 void OnSubsFileEnable();
00329 void OnSubsFileSettings( HWND hwnd );
00330
00331 void OnPageChange();
00332
00333 void OnFilePanelChange();
00334 void OnFileBrowse();
00335 void OnNetPanelChange( int event );
00336 void OnNetTypeChange( int event );
00337 void DisableNETCtrl();
00338
00339 void OnOk();
00340
00341 vector<string> mrl;
00342 vector<string> subsfile_mrl;
00343 };
00344
00345
00346 class SubsFileDialog: public CBaseWindow
00347 {
00348 public:
00349
00350 SubsFileDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
00351 virtual ~SubsFileDialog(){};
00352
00353 vector<string> subsfile_mrl;
00354 HWND file_combo;
00355
00356 protected:
00357 friend class OpenDialog;
00358
00359 HWND file_box;
00360 HWND browse_button;
00361
00362 HWND enc_box;
00363 HWND enc_label;
00364 HWND encoding_combo;
00365
00366 HWND misc_box;
00367 HWND delay_label;
00368 HWND delay_edit;
00369 HWND delay_spinctrl;
00370 HWND fps_label;
00371 HWND fps_edit;
00372 HWND fps_spinctrl;
00373
00374 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00375
00376
00377 void OnFileBrowse();
00378 };
00379
00380
00381 class Playlist : public CBaseWindow
00382 {
00383 public:
00384
00385 Playlist( intf_thread_t *, CBaseWindow *, HINSTANCE );
00386 virtual ~Playlist(){};
00387
00388 void UpdatePlaylist();
00389 void ShowPlaylist( bool );
00390
00391 protected:
00392
00393 bool b_need_update;
00394 vlc_mutex_t lock;
00395
00396 int i_title_sorted;
00397 int i_author_sorted;
00398
00399 HWND hwndCB;
00400 HWND hwndTB;
00401 HWND hListView;
00402
00403 void Rebuild();
00404 void UpdateItem( int );
00405 LRESULT ProcessCustomDraw( LPARAM lParam );
00406 void HandlePopupMenu( HWND hwnd, POINT point);
00407
00408 void DeleteItem( input_item_t * item );
00409
00410 void OnOpen();
00411 void OnSave();
00412
00413 void OnDeleteSelection();
00414 void OnInvertSelection();
00415 void OnEnableSelection();
00416 void OnDisableSelection();
00417 void OnSelectAll();
00418 void OnActivateItem( int i_item );
00419 void ShowInfos( HWND hwnd, int i_item );
00420
00421 void OnUp();
00422 void OnDown();
00423
00424 void OnRandom();
00425 void OnLoop();
00426 void OnRepeat();
00427
00428 void OnSort( UINT event );
00429 void OnColSelect( int iSubItem );
00430
00431 void OnPopupPlay();
00432 void OnPopupDel();
00433 void OnPopupEna();
00434 void OnPopupInfo( HWND hwnd );
00435
00436 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00437 };
00438
00439
00440 class Timer
00441 {
00442 public:
00443
00444 Timer( intf_thread_t *p_intf, HWND hwnd, Interface *_p_main_interface );
00445 virtual ~Timer();
00446 void Notify( void );
00447
00448 private:
00449 intf_thread_t *p_intf;
00450 Interface *p_main_interface;
00451
00452 int i_old_playing_status;
00453 int i_old_rate;
00454 };
00455
00456
00457 void RefreshSettingsMenu( intf_thread_t *_p_intf, HMENU hMenu );
00458 void RefreshAudioMenu( intf_thread_t *_p_intf, HMENU hMenu );
00459 void RefreshVideoMenu( intf_thread_t *_p_intf, HMENU hMenu );
00460 void RefreshNavigMenu( intf_thread_t *_p_intf, HMENU hMenu );
00461 void RefreshMenu( intf_thread_t *, vector<MenuItemExt*> *, HMENU, int,
00462 char **, vlc_object_t **, int );
00463 int wce_GetMenuItemCount( HMENU );
00464 void CreateMenuItem( intf_thread_t *, vector<MenuItemExt*> *, HMENU, char *,
00465 vlc_object_t *, int * );
00466 HMENU CreateChoicesMenu( intf_thread_t *, vector<MenuItemExt*> *, char *,
00467 vlc_object_t *, int * );
00468 void OnMenuEvent( intf_thread_t *, int );
00469
00470
00471
00472
00473
00474 class MenuItemExt
00475 {
00476 public:
00477
00478 MenuItemExt( intf_thread_t *_p_intf, int _id, char *_psz_var,
00479 vlc_object_t * p_object, vlc_value_t _val, int _i_val_type );
00480
00481 virtual ~MenuItemExt();
00482
00483 static void ClearList( vector<MenuItemExt*> * );
00484
00485 int id;
00486 intf_thread_t *p_intf;
00487 char *psz_var;
00488 int i_val_type;
00489 vlc_object_t * p_object;
00490 vlc_value_t val;
00491
00492 private:
00493
00494 };
00495
00496
00497
00498
00499 class PrefsTreeCtrl;
00500 class PrefsDialog: public CBaseWindow
00501 {
00502 public:
00503
00504 PrefsDialog( intf_thread_t *, CBaseWindow *, HINSTANCE );
00505 virtual ~PrefsDialog(){};
00506
00507 protected:
00508
00509
00510 void OnOk( void );
00511
00512
00513
00514
00515
00516 HWND save_button;
00517 HWND reset_button;
00518 HWND advanced_checkbox;
00519 HWND advanced_label;
00520
00521 PrefsTreeCtrl *prefs_tree;
00522
00523 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00524 };
00525
00526
00527
00528
00529 #ifdef UNICODE
00530 extern wchar_t pwsz_mbtow_wince[2048];
00531 extern char psz_wtomb_wince[2048];
00532 static inline wchar_t *_FROMMB( const char *psz_in )
00533 {
00534 mbstowcs( pwsz_mbtow_wince, psz_in, 2048 );
00535 pwsz_mbtow_wince[2048-1] = 0;
00536 return pwsz_mbtow_wince;
00537 }
00538 static inline char *_TOMB( const wchar_t *pwsz_in )
00539 {
00540 wcstombs( psz_wtomb_wince, pwsz_in, 2048 );
00541 psz_wtomb_wince[2048-1] = 0;
00542 return psz_wtomb_wince;
00543 }
00544 #else
00545 # define _FROMMB(a) a
00546 # define _TOMB(a) a
00547 #endif
00548
00549
00550
00551
00552 #define _WIN32_IE 0x0500
00553
00554 #define SHFS_SHOWSIPBUTTON 0x0004
00555 #define SHFS_HIDESIPBUTTON 0x0008
00556 #define SHIDIM_FLAGS 0x0001
00557 #define SHIDIF_DONEBUTTON 0x0001
00558 #define SHIDIF_SIPDOWN 0x0008
00559 #define SHIDIF_FULLSCREENNOMENUBAR 0x0010
00560 #define SHCMBF_HMENU 0x0010
00561 #define SHCMBF_EMPTYBAR 0x0001
00562 #define GN_CONTEXTMENU 1000
00563 #define SHRG_RETURNCMD 0x0001
00564 #define SHRG_NOTIFYPARENT 0x0002
00565 #define SHCMBM_GETSUBMENU (WM_USER + 401)
00566 #define SHCMBM_GETMENU (WM_USER + 402)
00567 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
00568 #define TBSTYLE_NO_DROPDOWN_ARROW 0x0080
00569 #endif
00570 #define lstrlenW wcslen
00571 #define SHGetMenu(hwnd) \
00572 (HMENU)SendMessage((hwnd), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0)
00573 #define TrackPopupMenu(hm,u,x,y,r,hw,p) \
00574 TrackPopupMenuEx((hm),(u),(x),(y),(hw),0)
00575
00576 extern "C" {
00577 typedef struct tagSHMENUBARINFO
00578 {
00579 DWORD cbSize;
00580 HWND hwndParent;
00581 DWORD dwFlags;
00582 UINT nToolBarId;
00583 HINSTANCE hInstRes;
00584 int nBmpId;
00585 int cBmpImages;
00586 HWND hwndMB;
00587 COLORREF clrBk;
00588 } SHMENUBARINFO, *PSHMENUBARINFO;
00589
00590 BOOL SHCreateMenuBar( SHMENUBARINFO *pmbi );
00591 BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
00592
00593 typedef struct tagSHINITDLGINFO
00594 {
00595 DWORD dwMask;
00596 HWND hDlg;
00597 DWORD dwFlags;
00598 } SHINITDLGINFO, *PSHINITDLGINFO;
00599
00600 BOOL SHInitDialog(PSHINITDLGINFO pshidi);
00601
00602 typedef struct tagNMRGINFO
00603 {
00604 NMHDR hdr;
00605 POINT ptAction;
00606 DWORD dwItemSpec;
00607 } NMRGINFO, *PNMRGINFO;
00608
00609 BOOL WINAPI CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
00610
00611 typedef struct tagSHRGI
00612 {
00613 DWORD cbSize;
00614 HWND hwndClient;
00615 POINT ptDown;
00616 DWORD dwFlags;
00617 } SHRGINFO, *PSHRGINFO;
00618
00619 DWORD SHRecognizeGesture(SHRGINFO *shrg);
00620
00621 typedef enum tagSIPSTATE
00622 {
00623 SIP_UP = 0,
00624 SIP_DOWN,
00625 SIP_FORCEDOWN,
00626 SIP_UNCHANGED,
00627 SIP_INPUTDIALOG,
00628 } SIPSTATE;
00629
00630 BOOL SHSipPreference(HWND, SIPSTATE);
00631
00632 BOOL SHSipInfo(UINT, UINT, PVOID, UINT);
00633
00634 typedef struct
00635 {
00636 DWORD cbSize;
00637 DWORD fdwFlags;
00638 RECT rcVisibleDesktop;
00639 RECT rcSipRect;
00640 DWORD dwImDataSize;
00641 VOID *pvImData;
00642 } SIPINFO;
00643 }
00644
00645 #if defined( WIN32 ) && !defined( UNDER_CE )
00646 # define SHFullScreen(a,b)
00647 # define SHInitDialog(a)
00648 # define SHCreateMenuBar(a) 1
00649 # define SHRecognizeGesture(a) 0
00650 # define SHSipPreference(a,b)
00651
00652 # define SHSipInfo(a,b,c,d) 0
00653 #endif
00654
00655 #endif //WINCE_RESOURCE
00656
00657 #define IDD_ABOUT 101
00658 #define IDI_ICON1 102
00659 #define IDB_BITMAP1 103
00660 #define IDB_BITMAP2 111
00661 #define IDR_MENUBAR1 113
00662 #define IDD_FILEINFO 118
00663 #define IDD_DUMMY 118
00664 #define IDD_MESSAGES 119
00665 #define IDR_MENUBAR 120
00666 #define IDR_MENUBAR2 121
00667 #define IDD_PLAYLIST 122
00668 #define IDB_BITMAP3 123
00669 #define IDD_ITEMINFO 124
00670 #define IDCLEAR 1001
00671 #define IDSAVEAS 1002
00672 #define ID_FILE 40028
00673 #define ID_VIEW 40030
00674 #define ID_SETTINGS 40032
00675 #define ID_AUDIO 40034
00676 #define ID_EMPTY 40034
00677 #define ID_VIDEO 40036
00678 #define ID_NAVIGATION 40038
00679 #define IDM_FILE 40042
00680 #define IDM_VIEW 40044
00681 #define IDM_SETTINGS 40046
00682 #define IDM_AUDIO 40048
00683 #define IDM_VIDEO 40050
00684 #define IDM_NAVIGATION 40053
00685 #define ID_FILE_QUICKOPEN 40057
00686 #define ID_FILE_OPENFILE 40058
00687 #define ID_FILE_OPENDIR 40059
00688 #define ID_FILE_OPENNET 40060
00689 #define ID_FILE_EXIT 40061
00690 #define ID_VIEW_PLAYLIST 40063
00691 #define ID_VIEW_MESSAGES 40064
00692 #define ID_VIEW_MEDIAINFO 40065
00693 #define ID_VIEW_STREAMINFO 40066
00694 #define ID_PREFERENCES 40071
00695 #define ID_FILE_ABOUT 40069
00696 #define IDM_MANAGE 40087
00697 #define IDM_SORT 40088
00698 #define IDM_SEL 40089
00699 #define ID_SORT_AUTHOR 40091
00700 #define ID_SORT_RAUTHOR 40092
00701 #define ID_SORT_SHUFFLE 40095
00702 #define ID_SEL_INVERT 40096
00703 #define ID_SEL_DELETE 40097
00704 #define ID_SEL_SELECTALL 40098
00705 #define ID_SEL_ENABLE 40100
00706 #define ID_SEL_DISABLE 40101
00707 #define ID_SORT_TITLE 40102
00708 #define ID_SORT_RTITLE 40103
00709 #define ID_MANAGE_ADDFILE 40104
00710 #define ID_MANAGE_ADDDIRECTORY 40105
00711 #define ID_MANAGE_ADDMRL 40106
00712 #define ID_MANAGE_OPENPL 40107
00713 #define ID_MANAGE_SAVEPL 40108
00714 #define StopStream_Event 57601
00715 #define PlayStream_Event 57602
00716 #define PrevStream_Event 57603
00717 #define NextStream_Event 57604
00718 #define SlowStream_Event 57605
00719 #define FastStream_Event 57606