1 /*****************************************************************************
2 * interface.cpp: WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
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.
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.
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,
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
42 #define NUMIMAGES 9 // Number of buttons in the toolbar
43 #define IMAGEWIDTH 17 // Width of the buttons in the toolbar
44 #define IMAGEHEIGHT 16 // Height of the buttons in the toolbar
45 #define BUTTONWIDTH 0 // Width of the button images in the toolbar
46 #define BUTTONHEIGHT 0 // Height of the button images in the toolbar
47 #define ID_TOOLBAR 2000 // Identifier of the main tool bar
50 #define HELP_SIMPLE _T("Quick file open")
51 #define HELP_ADV _T("Advanced open")
52 #define HELP_FILE _T("Open a file")
53 #define HELP_DISC _T("Open Disc Media")
54 #define HELP_NET _T("Open a network stream")
55 #define HELP_SAT _T("Open a satellite stream")
56 #define HELP_EJECT _T("Eject the DVD/CD")
57 #define HELP_EXIT _T("Exit this program")
59 #define HELP_OTHER _T("Open other types of inputs")
61 #define HELP_PLAYLIST _T("Open the playlist")
62 #define HELP_LOGS _T("Show the program logs")
63 #define HELP_FILEINFO _T("Show information about the file being played")
65 #define HELP_PREFS _T("Go to the preferences menu")
66 #define EXTRA_PREFS _T("Shows the extended GUI")
68 #define HELP_ABOUT _T("About this program")
70 #define HELP_STOP _T("Stop")
72 #define HELP_PLAY _T("Play")
73 #define HELP_PAUSE _T("Pause")
74 #define HELP_PLO _T("Playlist")
75 #define HELP_PLP _T("Previous playlist item")
76 #define HELP_PLN _T("Next playlist item")
77 #define HELP_SLOW _T("Play slower")
78 #define HELP_FAST _T("Play faster")
80 // The TBBUTTON structure contains information the toolbar buttons.
81 static TBBUTTON tbButton[] =
83 {0, ID_FILE_QUICKOPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON},
84 {1, ID_FILE_OPENNET, TBSTATE_ENABLED, TBSTYLE_BUTTON},
85 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
86 {2, StopStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
87 {3, PlayStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
88 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
89 {4, ID_VIEW_PLAYLIST, TBSTATE_ENABLED, TBSTYLE_BUTTON},
90 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
91 {5, PrevStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
92 {6, NextStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
93 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
94 {7, SlowStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
95 {8, FastStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
99 TCHAR * szToolTips[] =
101 HELP_SIMPLE, HELP_NET, HELP_STOP, HELP_PLAY, HELP_PLO, HELP_PLP,
102 HELP_PLN, HELP_SLOW, HELP_FAST
105 /*****************************************************************************
107 *****************************************************************************/
108 BOOL Interface::InitInstance( HINSTANCE hInstance, intf_thread_t *_p_intf )
110 /* Initializations */
112 hwndMain = hwndCB = hwndTB = hwndSlider = hwndLabel = hwndVol = hwndSB = 0;
113 i_old_playing_status = PAUSE_S;
115 hInst = hInstance; // Store instance handle in our global variable
117 // Register window class
119 wc.style = CS_HREDRAW | CS_VREDRAW ;
120 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
124 wc.hInstance = hInstance;
126 wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
127 wc.lpszMenuName = NULL;
128 wc.lpszClassName = _T("VLC WinCE");
129 if( !RegisterClass( &wc ) ) return FALSE;
131 int i_style = WS_VISIBLE;
134 i_style |= WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
137 // Create main window
139 CreateWindow( _T("VLC WinCE"), _T("VLC media player"), i_style,
140 0, MENU_HEIGHT, CW_USEDEFAULT, CW_USEDEFAULT,
141 NULL, NULL, hInstance, (void *)this );
143 if( !hwndMain ) return FALSE;
145 ShowWindow( hwndMain, TRUE );
146 UpdateWindow( hwndMain );
151 /***********************************************************************
157 ***********************************************************************/
158 static HWND CreateMenuBar( HWND hwnd, HINSTANCE hInst )
162 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
163 mbi.cbSize = sizeof(SHMENUBARINFO);
164 mbi.hwndParent = hwnd;
165 mbi.hInstRes = hInst;
166 mbi.nToolBarId = IDR_MENUBAR;
168 if( !SHCreateMenuBar( &mbi ) )
170 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
175 tbbi.cbSize = sizeof(tbbi);
176 tbbi.dwMask = TBIF_LPARAM;
178 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_FILE, (LPARAM)&tbbi );
179 HMENU hmenu_file = (HMENU)tbbi.lParam;
180 RemoveMenu( hmenu_file, 0, MF_BYPOSITION );
181 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIEW, (LPARAM)&tbbi );
182 HMENU hmenu_view = (HMENU)tbbi.lParam;
183 RemoveMenu( hmenu_view, 0, MF_BYPOSITION );
184 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SETTINGS, (LPARAM)&tbbi );
185 HMENU hmenu_settings = (HMENU)tbbi.lParam;
188 HMENU hmenu_file = CreatePopupMenu();
189 HMENU hmenu_view = CreatePopupMenu();
190 HMENU hmenu_settings = CreatePopupMenu();
191 HMENU hmenu_audio = CreatePopupMenu();
192 HMENU hmenu_video = CreatePopupMenu();
193 HMENU hmenu_navigation = CreatePopupMenu();
196 AppendMenu( hmenu_file, MF_STRING, ID_FILE_QUICKOPEN,
197 _T("Quick &Open File") );
198 AppendMenu( hmenu_file, MF_SEPARATOR, 0, 0 );
199 AppendMenu( hmenu_file, MF_STRING, ID_FILE_OPENFILE,
201 AppendMenu( hmenu_file, MF_STRING, ID_FILE_OPENNET,
202 _T("Open Network Stream") );
203 AppendMenu( hmenu_file, MF_SEPARATOR, 0, 0 );
204 AppendMenu( hmenu_file, MF_STRING, ID_FILE_ABOUT,
206 AppendMenu( hmenu_file, MF_STRING, ID_FILE_EXIT,
209 AppendMenu( hmenu_view, MF_STRING, ID_VIEW_PLAYLIST,
211 AppendMenu( hmenu_view, MF_STRING, ID_VIEW_MESSAGES,
213 AppendMenu( hmenu_view, MF_STRING, ID_VIEW_STREAMINFO,
214 _T("&Stream and Media info") );
216 AppendMenu( hmenu_settings, MF_STRING, ID_SETTINGS_EXTEND,
217 _T("&Extended GUI") );
218 AppendMenu( hmenu_settings, MF_STRING, ID_SETTINGS_PREF,
219 _T("&Preferences...") );
226 HMENU hmenu = CreateMenu();
228 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_file, _T("File") );
229 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_view, _T("View") );
230 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_settings,
232 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_audio, _T("Audio") );
233 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_video, _T("Video") );
234 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_navigation,
237 SetMenu( hwnd, hmenu );
243 /***********************************************************************
248 Registers the TOOLBAR control class and creates a toolbar.
249 ***********************************************************************/
250 HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
256 INITCOMMONCONTROLSEX iccex;
257 iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
258 iccex.dwICC = ICC_BAR_CLASSES;
260 // Registers TOOLBAR control classes from the common control dll
261 InitCommonControlsEx (&iccex);
263 // Create the toolbar control
264 dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS |
265 WS_EX_OVERLAPPEDWINDOW | CCS_NOPARENTALIGN;
267 hwndTB = CreateToolbarEx( hwnd, dwStyle, 0, NUMIMAGES,
268 hInst, IDB_BITMAP1, tbButton, sizeof(tbButton) / sizeof(TBBUTTON),
269 BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
271 if( !hwndTB ) return NULL;
273 // Add ToolTips to the toolbar.
274 SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES,
275 (LPARAM)szToolTips );
277 // Reposition the toolbar.
278 GetClientRect( hwnd, &rect );
279 GetWindowRect( hwndTB, &rectTB );
280 MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT,
281 rect.right - rect.left, MENU_HEIGHT, TRUE );
286 /***********************************************************************
292 Registers the TRACKBAR_CLASS control class and creates a trackbar.
294 ***********************************************************************/
295 HWND CreateSliderBar( HWND hwnd, HINSTANCE hInst )
300 INITCOMMONCONTROLSEX iccex;
301 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
302 iccex.dwICC = ICC_BAR_CLASSES;
304 // Registers TRACKBAR_CLASS control classes from the common control dll
305 InitCommonControlsEx( &iccex );
307 hwndSlider = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
308 WS_CHILD | WS_VISIBLE | TBS_HORZ | WS_EX_OVERLAPPEDWINDOW |
309 TBS_BOTTOM, //|WS_CLIPSIBLINGS,
310 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
312 if( !hwndSlider ) return NULL;
314 SendMessage( hwndSlider, TBM_SETRANGEMIN, 1, 0 );
315 SendMessage( hwndSlider, TBM_SETRANGEMAX, 1, SLIDER_MAX_POS );
316 SendMessage( hwndSlider, TBM_SETPOS, 1, 0 );
318 // Reposition the trackbar
319 GetClientRect( hwnd, &rect );
320 MoveWindow( hwndSlider, rect.left,
321 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
322 rect.right - rect.left - 40, 30, TRUE );
324 ShowWindow( hwndSlider, SW_HIDE );
329 HWND CreateStaticText( HWND hwnd, HINSTANCE hInst )
334 hwndLabel = CreateWindowEx( 0, _T("STATIC"), _T("label"),
335 WS_CHILD | WS_VISIBLE | SS_CENTER ,
336 0, 0, 0, 0, hwnd, (HMENU)1980, hInst, NULL );
338 // Reposition the trackbar
339 GetClientRect( hwnd, &rect );
341 MoveWindow( hwndLabel, rect.left,
342 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT +30,
343 rect.right - rect.left - 40,
344 SLIDER_HEIGHT - 30, TRUE );
346 ShowWindow( hwndLabel, SW_HIDE );
351 /***********************************************************************
357 Registers the TRACKBAR_CLASS control class and creates a trackbar.
359 ***********************************************************************/
360 HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst )
365 INITCOMMONCONTROLSEX iccex;
366 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
367 iccex.dwICC = ICC_BAR_CLASSES;
369 // Registers TRACKBAR_CLASS control classes from the common control dll
370 InitCommonControlsEx( &iccex );
372 hwndVol = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
373 WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_RIGHT | TBS_AUTOTICKS |
374 WS_EX_OVERLAPPEDWINDOW, //|WS_CLIPSIBLINGS,
375 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
377 if( !hwndVol ) return NULL;
379 SendMessage( hwndVol, TBM_SETRANGEMIN, 1, 0 );
380 SendMessage( hwndVol, TBM_SETRANGEMAX, 1, 200 );
381 SendMessage( hwndVol, TBM_SETPOS, 1, 100 );
382 SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 );
384 // Reposition the trackbar
385 GetClientRect( hwnd, &rect );
386 MoveWindow( hwndVol, rect.right - rect.left - 40,
387 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
388 40, SLIDER_HEIGHT, TRUE );
390 ShowWindow( hwndVol, SW_HIDE );
395 /***********************************************************************
401 Registers the StatusBar control class and creates a Statusbar.
403 ***********************************************************************/
404 HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
410 INITCOMMONCONTROLSEX iccex;
411 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
412 iccex.dwICC = ICC_BAR_CLASSES;
414 // Registers Statusbar control classes from the common control dll
415 InitCommonControlsEx( &iccex );
417 // Create the statusbar control
418 dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NOPARENTALIGN;
420 hwndSB = CreateWindowEx( 0, STATUSCLASSNAME, NULL,
421 WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_BOTTOM |
422 TBS_RIGHT |WS_CLIPSIBLINGS,
423 0, 0, CW_USEDEFAULT, 50, hwnd, NULL, hInst, 0 );
425 if (!hwndSB ) return NULL;
427 // Get the coordinates of the parent window's client area.
428 GetClientRect( hwnd, &rect );
430 // allocate memory for the panes of status bar
432 int *indicators = new int[nopanes];
434 // set width for the panes
435 indicators[0] = 3 * ( rect.right - rect.left ) / 4;
436 indicators[1] = rect.right - rect.left;
438 // call functions to set style
439 SendMessage( hwndSB, SB_SETPARTS, (WPARAM)nopanes, (LPARAM)indicators );
444 /***********************************************************************
449 Creates a Dialog Box.
450 ***********************************************************************/
451 int CBaseWindow::CreateDialogBox( HWND hwnd, CBaseWindow *p_obj )
453 uint8_t p_buffer[sizeof(DLGTEMPLATE) + sizeof(WORD) * 4];
454 DLGTEMPLATE *p_dlg_template = (DLGTEMPLATE *)p_buffer;
455 memset( p_dlg_template, 0, sizeof(DLGTEMPLATE) + sizeof(WORD) * 4 );
457 // these values are arbitrary, they won't be used normally anyhow
458 p_dlg_template->x = 0; p_dlg_template->y = 0;
459 p_dlg_template->cx = 300; p_dlg_template->cy = 300;
460 p_dlg_template->style =
461 DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX;
463 return DialogBoxIndirectParam( GetModuleHandle(0), p_dlg_template, hwnd,
464 (DLGPROC)p_obj->BaseWndProc, (LPARAM)p_obj );
467 /***********************************************************************
472 Processes messages sent to the main window.
473 ***********************************************************************/
474 LRESULT CALLBACK CBaseWindow::BaseWndProc( HWND hwnd, UINT msg, WPARAM wParam,
479 // check to see if a copy of the 'this' pointer needs to be saved
480 if( msg == WM_CREATE )
482 p_obj = (CBaseWindow *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
483 SetWindowLong( hwnd, GWL_USERDATA,
484 (LONG)((LPCREATESTRUCT)lParam)->lpCreateParams );
489 if( msg == WM_INITDIALOG )
491 p_obj = (CBaseWindow *)lParam;
492 SetWindowLong( hwnd, GWL_USERDATA, lParam );
496 // Retrieve the pointer
497 p_obj = (CBaseWindow *)GetWindowLong( hwnd, GWL_USERDATA );
499 if( !p_obj ) return DefWindowProc( hwnd, msg, wParam, lParam );
501 // Filter message through child classes
502 return p_obj->WndProc( hwnd, msg, wParam, lParam );
505 /***********************************************************************
510 Processes messages sent to the main window.
511 ***********************************************************************/
512 LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
518 hwndCB = CreateMenuBar( hwnd, hInst );
519 hwndTB = CreateToolBar( hwnd, hInst );
520 hwndSlider = CreateSliderBar( hwnd, hInst );
521 hwndLabel = CreateStaticText( hwnd, hInst );
522 hwndVol = CreateVolTrackBar( hwnd, hInst );
524 hwndSB = CreateStatusBar( hwnd, hInst );
528 if( config_GetInt( p_intf, "wince-embed" ) )
529 video = CreateVideoWindow( p_intf, hwnd );
531 ti = new Timer(p_intf, hwnd, this);
533 // Hide the SIP button (WINCE only)
534 SetForegroundWindow( hwnd );
535 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
539 switch( GET_WM_COMMAND_ID(wp,lp) )
541 case ID_FILE_QUICKOPEN:
545 case ID_FILE_OPENFILE:
546 open = new OpenDialog( p_intf, hInst, FILE_ACCESS,
547 ID_FILE_OPENFILE, OPEN_NORMAL );
548 CreateDialogBox( hwnd, open );
552 case ID_FILE_OPENNET:
553 open = new OpenDialog( p_intf, hInst, NET_ACCESS, ID_FILE_OPENNET,
555 CreateDialogBox( hwnd, open );
559 case PlayStream_Event:
563 case StopStream_Event:
567 case PrevStream_Event:
571 case NextStream_Event:
575 case SlowStream_Event:
579 case FastStream_Event:
585 string about = (string)"VLC media player " PACKAGE_VERSION +
586 _("\n(WinCE interface)\n\n") +
587 _("(c) 1996-2005 - the VideoLAN Team\n\n") +
588 _("The VideoLAN team <videolan@videolan.org>\n"
589 "http://www.videolan.org/\n\n");
591 MessageBox( hwnd, _FROMMB(about.c_str()),
592 _T("About VLC media player"), MB_OK );
597 SendMessage( hwnd, WM_CLOSE, 0, 0 );
600 case ID_VIEW_STREAMINFO:
601 fi = new FileInfo( p_intf, hInst );
602 CreateDialogBox( hwnd, fi );
606 case ID_VIEW_MESSAGES:
607 hmsg = new Messages( p_intf, hInst );
608 CreateDialogBox( hwnd, hmsg );
612 case ID_VIEW_PLAYLIST:
613 pl = new Playlist( p_intf, hInst );
614 CreateDialogBox( hwnd, pl );
618 case ID_SETTINGS_PREF:
619 pref = new PrefsDialog( p_intf, hInst );
620 CreateDialogBox( hwnd, pref );
625 OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );
626 // we should test if it is a menu command
634 case WM_CTLCOLORSTATIC:
635 if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )
637 return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
639 if( (HWND)lp == hwndLabel )
641 SetBkColor( (HDC)wp, RGB (192, 192, 192) );
642 return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
647 if( (HWND)lp == hwndSlider ) OnSliderUpdate( wp );
651 if( (HWND)lp == hwndVol ) OnChange( wp );
654 case WM_INITMENUPOPUP:
655 RefreshSettingsMenu( p_intf,
656 (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
657 (LPARAM)IDM_SETTINGS ) );
658 RefreshAudioMenu( p_intf,
659 (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
660 (LPARAM)IDM_AUDIO ) );
661 RefreshVideoMenu( p_intf,
662 (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
663 (LPARAM)IDM_VIDEO ) );
664 RefreshNavigMenu( p_intf,
665 (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
666 (LPARAM)IDM_NAVIGATION ) );
669 // Undo the video display because menu is opened
670 // due to GAPI, menu top display is not assumed
671 // FIXME verify if p_child_window exits
672 SendMessage( p_intf->p_sys->p_video_window->p_child_window,
673 WM_INITMENUPOPUP, wp, lp );
677 /* InvalidateRect(hwnd, NULL, TRUE);
678 /UpdateWindow(hwndCB); // NULL*/
683 // Redo the video display because menu can be closed
684 // FIXME verify if p_child_window exits
685 if( (((NMHDR *)lp)->code) == NM_CUSTOMDRAW )
686 SendMessage( p_intf->p_sys->p_video_window->p_child_window,
693 MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);
697 DestroyWindow( hwndCB );
698 DestroyWindow( hwnd );
702 PostQuitMessage( 0 );
706 return DefWindowProc( hwnd, msg, wp, lp );
709 void Interface::OnOpenFileSimple( void )
712 TCHAR DateiName[80+1] = _T("\0");
713 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
715 playlist_t *p_playlist = (playlist_t *)
716 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
717 if( p_playlist == NULL ) return;
719 memset( &ofn, 0, sizeof(OPENFILENAME) );
720 ofn.lStructSize = sizeof(OPENFILENAME);
721 ofn.hwndOwner = NULL;
722 ofn.hInstance = hInst;
723 ofn.lpstrFilter = szFilter;
724 ofn.lpstrCustomFilter = NULL;
725 ofn.nMaxCustFilter = 0;
726 ofn.nFilterIndex = 1;
727 ofn.lpstrFile = (LPTSTR)DateiName;
729 ofn.lpstrFileTitle = NULL;
730 ofn.nMaxFileTitle = 40;
731 ofn.lpstrInitialDir = NULL;
732 ofn.lpstrTitle = _T("Quick Open File");
735 ofn.nFileExtension = 0;
736 ofn.lpstrDefExt = NULL;
739 ofn.lpTemplateName = NULL;
741 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
743 if( GetOpenFile( &ofn ) )
745 char *psz_filename = _TOMB(ofn.lpstrFile);
746 playlist_Add( p_playlist, psz_filename, psz_filename,
747 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
750 vlc_object_release( p_playlist );
753 void Interface::OnPlayStream( void )
755 playlist_t *p_playlist = (playlist_t *)
756 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
757 if( p_playlist == NULL ) return;
759 if( p_playlist->i_size && p_playlist->i_enabled )
763 input_thread_t *p_input = (input_thread_t *)
764 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
766 if( p_input == NULL )
768 /* No stream was playing, start one */
769 playlist_Play( p_playlist );
770 TogglePlayButton( PLAYING_S );
771 vlc_object_release( p_playlist );
775 var_Get( p_input, "state", &state );
777 if( state.i_int != PAUSE_S )
779 /* A stream is being played, pause it */
780 state.i_int = PAUSE_S;
784 /* Stream is paused, resume it */
785 state.i_int = PLAYING_S;
787 var_Set( p_input, "state", state );
789 TogglePlayButton( state.i_int );
790 vlc_object_release( p_input );
791 vlc_object_release( p_playlist );
795 /* If the playlist is empty, open a file requester instead */
796 vlc_object_release( p_playlist );
801 void Interface::TogglePlayButton( int i_playing_status )
803 TBREPLACEBITMAP tbrb;
804 tbrb.hInstOld = tbrb.hInstNew = (HINSTANCE) hInst;
805 tbrb.nButtons = NUMIMAGES;
807 if( i_playing_status == i_old_playing_status ) return;
809 if( i_playing_status == PLAYING_S )
811 tbrb.nIDOld = IDB_BITMAP2;
812 tbrb.nIDNew = IDB_BITMAP1;
814 SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
815 (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
819 tbrb.nIDOld = IDB_BITMAP1;
820 tbrb.nIDNew = IDB_BITMAP2;
822 SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
823 (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
826 UpdateWindow( hwndTB );
828 i_old_playing_status = i_playing_status;
831 void Interface::OnVideoOnTop( void )
835 vout_thread_t *p_vout = (vout_thread_t *)
836 vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
838 if( p_vout == NULL ) return;
840 if( var_Get( (vlc_object_t *)p_vout, "video-on-top", &val ) < 0 )
843 val.b_bool = !val.b_bool;
844 var_Set( (vlc_object_t *)p_vout, "video-on-top", val );
846 vlc_object_release( (vlc_object_t *)p_vout );
849 void Interface::OnSliderUpdate( int wp )
851 vlc_mutex_lock( &p_intf->change_lock );
852 input_thread_t *p_input = p_intf->p_sys->p_input;
854 int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 );
856 if( (int)LOWORD(wp) == SB_THUMBPOSITION ||
857 (int)LOWORD(wp) == SB_ENDSCROLL )
859 if( p_intf->p_sys->i_slider_pos != dwPos && p_input )
862 pos.f_float = (float)dwPos / (float)SLIDER_MAX_POS;
863 var_Set( p_input, "position", pos );
866 p_intf->p_sys->b_slider_free = VLC_TRUE;
870 p_intf->p_sys->b_slider_free = VLC_FALSE;
874 /* Update stream date */
875 char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
878 i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
879 secstotimestr( psz_total, i_seconds );
881 i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );
882 secstotimestr( psz_time, i_seconds );
884 SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,
885 (LPARAM)_FROMMB(psz_time) );
889 vlc_mutex_unlock( &p_intf->change_lock );
892 void Interface::OnChange( int wp )
894 DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
896 if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
898 Change( 200 - (int)dwPos );
902 void Interface::Change( int i_volume )
904 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
906 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
911 void Interface::OnStopStream( void )
913 playlist_t * p_playlist = (playlist_t *)
914 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
915 if( p_playlist == NULL ) return;
917 playlist_Stop( p_playlist );
918 TogglePlayButton( PAUSE_S );
919 vlc_object_release( p_playlist );
922 void Interface::OnPrevStream( void )
924 playlist_t * p_playlist = (playlist_t *)
925 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
926 if( p_playlist == NULL ) return;
928 playlist_Prev( p_playlist );
929 vlc_object_release( p_playlist );
932 void Interface::OnNextStream( void )
934 playlist_t * p_playlist = (playlist_t *)
935 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
936 if( p_playlist == NULL ) return;
938 playlist_Next( p_playlist );
939 vlc_object_release( p_playlist );
942 void Interface::OnSlowStream( void )
944 input_thread_t *p_input = (input_thread_t *)
945 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
947 if( p_input == NULL ) return;
949 vlc_value_t val; val.b_bool = VLC_TRUE;
950 var_Set( p_input, "rate-slower", val );
951 vlc_object_release( p_input );
954 void Interface::OnFastStream( void )
956 input_thread_t *p_input = (input_thread_t *)
957 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
959 if( p_input == NULL ) return;
961 vlc_value_t val; val.b_bool = VLC_TRUE;
962 var_Set( p_input, "rate-faster", val );
963 vlc_object_release( p_input );