1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: interface.cpp,v 1.45 2003/07/12 13:33:10 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #ifdef WIN32 /* mingw32 hack */
40 /* Let vlc take care of the i18n stuff */
41 #define WXINTL_NO_GETTEXT_MACRO
43 #include <wx/wxprec.h>
47 #include "stream_control.h"
49 #include "wxwindows.h"
51 /* include the toolbar graphics */
52 #include "bitmaps/file.xpm"
53 #include "bitmaps/disc.xpm"
54 #include "bitmaps/net.xpm"
56 #include "bitmaps/sat.xpm"
58 #include "bitmaps/play.xpm"
59 #include "bitmaps/pause.xpm"
60 #include "bitmaps/stop.xpm"
61 #include "bitmaps/previous.xpm"
62 #include "bitmaps/next.xpm"
63 #include "bitmaps/playlist.xpm"
64 #include "bitmaps/fast.xpm"
65 #include "bitmaps/slow.xpm"
67 #define TOOLBAR_BMP_WIDTH 36
68 #define TOOLBAR_BMP_HEIGHT 36
70 /* include the icon graphic */
71 #include "../../../share/vlc32x32.xpm"
73 /*****************************************************************************
74 * Local class declarations.
75 *****************************************************************************/
76 class wxMenuExt: public wxMenu
80 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
81 const wxString& helpString, wxItemKind kind,
82 char *_psz_var, int _i_object_id, vlc_value_t _val,
85 virtual ~wxMenuExt() {};
96 class wxVolCtrl: public wxGauge
100 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
101 virtual ~wxVolCtrl() {};
103 void Change( int i_volume );
105 void OnChange( wxMouseEvent& event );
108 intf_thread_t *p_intf;
110 DECLARE_EVENT_TABLE();
113 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
115 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
118 /*****************************************************************************
120 *****************************************************************************/
122 /* IDs for the controls and the menu commands */
126 Exit_Event = wxID_HIGHEST,
127 OpenFileSimple_Event,
148 /* it is important for the id corresponding to the "About" command to have
149 * this standard value as otherwise it won't be handled properly under Mac
150 * (where it is special and put into the "Apple" menu) */
151 About_Event = wxID_ABOUT
154 BEGIN_EVENT_TABLE(Interface, wxFrame)
156 EVT_MENU(Exit_Event, Interface::OnExit)
157 EVT_MENU(About_Event, Interface::OnAbout)
158 EVT_MENU(Playlist_Event, Interface::OnPlaylist)
159 EVT_MENU(Logs_Event, Interface::OnLogs)
160 EVT_MENU(FileInfo_Event, Interface::OnFileInfo)
161 EVT_MENU(Prefs_Event, Interface::OnPreferences)
163 EVT_MENU_OPEN(Interface::OnMenuOpen)
165 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
166 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
168 EVT_RIGHT_UP(Interface::OnContextMenu)
171 EVT_MENU(OpenFileSimple_Event, Interface::OnOpenFileSimple)
172 EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
173 EVT_MENU(OpenDisc_Event, Interface::OnOpenDisc)
174 EVT_MENU(OpenNet_Event, Interface::OnOpenNet)
175 EVT_MENU(OpenSat_Event, Interface::OnOpenSat)
176 EVT_MENU(StopStream_Event, Interface::OnStopStream)
177 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
178 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
179 EVT_MENU(NextStream_Event, Interface::OnNextStream)
180 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
181 EVT_MENU(FastStream_Event, Interface::OnFastStream)
184 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
187 /*****************************************************************************
189 *****************************************************************************/
190 Interface::Interface( intf_thread_t *_p_intf ):
191 wxFrame( NULL, -1, wxT("VLC media player"),
192 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
194 /* Initializations */
196 p_prefs_dialog = NULL;
197 i_old_playing_status = PAUSE_S;
198 p_open_dialog = NULL;
199 p_file_dialog = NULL;
201 /* Give our interface a nice little icon */
202 p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
203 SetIcon( *p_intf->p_sys->p_icon );
205 /* Create a sizer for the main frame */
206 frame_sizer = new wxBoxSizer( wxHORIZONTAL );
207 SetSizer( frame_sizer );
209 /* Creation of the menu bar */
212 /* Creation of the tool bar */
215 /* Creation of the slider sub-window */
217 frame_sizer->Add( slider_frame, 1, wxGROW, 0 );
218 frame_sizer->Hide( slider_frame );
220 /* Creation of the status bar
221 * Helptext for menu items and toolbar tools will automatically get
223 int i_status_width[3] = {-6, -2, -9};
224 statusbar = CreateStatusBar( 3 ); /* 2 fields */
225 statusbar->SetStatusWidths( 3, i_status_width );
226 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
229 /* Make sure we've got the right background colour */
230 SetBackgroundColour( slider_frame->GetBackgroundColour() );
232 /* Layout everything */
233 SetAutoLayout( TRUE );
234 frame_sizer->Layout();
235 frame_sizer->Fit(this);
237 #if !defined(__WXX11__)
238 /* Associate drop targets with the main interface */
239 SetDropTarget( new DragAndDrop( p_intf ) );
243 Interface::~Interface()
246 if( p_open_dialog ) delete p_open_dialog;
247 if( p_prefs_dialog ) p_prefs_dialog->Destroy();
248 if( p_file_dialog ) delete p_file_dialog;
249 if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
252 /*****************************************************************************
254 *****************************************************************************/
255 void Interface::CreateOurMenuBar()
257 #define HELP_FILE N_("Open a file")
258 #define HELP_DISC N_("Open a DVD or (S)VCD")
259 #define HELP_NET N_("Open a network stream")
260 #define HELP_SAT N_("Open a satellite stream")
261 #define HELP_EJECT N_("Eject the DVD/CD")
262 #define HELP_EXIT N_("Exit this program")
264 #define HELP_PLAYLIST N_("Open the playlist")
265 #define HELP_LOGS N_("Show the program logs")
266 #define HELP_FILEINFO N_("Show information about the file being played")
268 #define HELP_PREFS N_("Go to the preferences menu")
270 #define HELP_ABOUT N_("About this program")
272 /* Create the "File" menu */
273 wxMenu *file_menu = new wxMenu;
274 file_menu->Append( OpenFileSimple_Event, wxU(_("Simple &Open ...")),
276 file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
278 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
280 file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
283 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
287 file_menu->AppendSeparator();
288 file_menu->Append( EjectDisc_Event, wxU(_("&Eject Disc")),
289 wxU(_(HELP_EJECT)) );
291 file_menu->AppendSeparator();
292 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
294 /* Create the "View" menu */
295 wxMenu *view_menu = new wxMenu;
296 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
297 wxU(_(HELP_PLAYLIST)) );
298 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
299 view_menu->Append( FileInfo_Event, wxU(_("&File info...")),
300 wxU(_(HELP_FILEINFO)) );
302 /* Create the "Settings" menu */
303 wxMenu *settings_menu = new wxMenu;
304 settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
305 wxU(_(HELP_PREFS)) );
307 /* Create the "Audio" menu */
308 p_audio_menu = new wxMenu;
311 /* Create the "Video" menu */
312 p_video_menu = new wxMenu;
315 /* Create the "Navigation" menu */
316 p_navig_menu = new wxMenu;
319 /* Create the "Help" menu */
320 wxMenu *help_menu = new wxMenu;
321 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
323 /* Append the freshly created menus to the menu bar... */
324 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
325 menubar->Append( file_menu, wxU(_("&File")) );
326 menubar->Append( view_menu, wxU(_("&View")) );
327 menubar->Append( settings_menu, wxU(_("&Settings")) );
328 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
329 menubar->Append( p_video_menu, wxU(_("&Video")) );
330 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
331 menubar->Append( help_menu, wxU(_("&Help")) );
333 /* Attach the menu bar to the frame */
334 SetMenuBar( menubar );
336 /* Intercept all menu events in our custom event handler */
337 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
339 #if !defined(__WXX11__)
340 /* Associate drop targets with the menubar */
341 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
345 void Interface::CreateOurToolBar()
347 #define HELP_STOP N_("Stop current playlist item")
348 #define HELP_PLAY N_("Play current playlist item")
349 #define HELP_PAUSE N_("Pause current playlist item")
350 #define HELP_PLO N_("Open playlist")
351 #define HELP_PLP N_("Previous playlist item")
352 #define HELP_PLN N_("Next playlist item")
353 #define HELP_SLOW N_("Play slower")
354 #define HELP_FAST N_("Play faster")
356 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
357 * version because we don't include wx.rc */
359 wxToolBar *toolbar = CreateToolBar(
360 wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
362 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
364 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
366 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
368 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
371 toolbar->AddTool( OpenSat_Event, wxU(_("Sat")), wxBitmap( sat_xpm ),
374 toolbar->AddSeparator();
375 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
377 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
379 toolbar->AddSeparator();
380 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
381 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
382 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
383 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
384 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
386 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
388 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
393 /* Place the toolbar in a sizer, so we can calculate the width of the
394 * toolbar and set this as the minimum for the main frame size. */
395 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
396 toolbar_sizer->Add( toolbar, 0, 0, 0 );
397 toolbar_sizer->Layout();
400 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
402 frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
403 toolbar->GetToolsCount(), -1 );
406 #if !defined(__WXX11__)
407 /* Associate drop targets with the toolbar */
408 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
412 void Interface::CreateOurSlider()
414 /* Create a new frame and sizer containing the slider */
415 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
416 slider_frame->SetAutoLayout( TRUE );
417 wxBoxSizer *frame_sizer =
418 new wxBoxSizer( wxHORIZONTAL );
420 /* Create static box to surround the slider */
421 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
423 /* Create sizer for slider frame */
424 wxStaticBoxSizer *slider_sizer =
425 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
426 slider_sizer->SetMinSize( -1, 50 );
429 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
430 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
431 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
434 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
436 /* Add everything to the frame */
437 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
438 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
439 slider_frame->SetSizer( frame_sizer );
440 frame_sizer->Layout();
441 frame_sizer->SetSizeHints(slider_frame);
443 /* Hide the slider by default */
444 slider_frame->Hide();
447 void Interface::Open( int i_access_method )
449 /* Show/hide the open dialog */
450 if( p_open_dialog == NULL )
451 p_open_dialog = new OpenDialog( p_intf, this, i_access_method );
454 p_open_dialog->ShowModal( i_access_method ) == wxID_OK )
456 /* Update the playlist */
457 playlist_t *p_playlist =
458 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
460 if( p_playlist == NULL )
465 for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
467 playlist_Add( p_playlist,
468 (const char *)p_open_dialog->mrl[i].mb_str(),
469 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
472 TogglePlayButton( PLAYING_S );
474 vlc_object_release( p_playlist );
478 /*****************************************************************************
480 *****************************************************************************/
481 /* Work-around helper for buggy wxGTK */
482 void RecursiveDestroy( wxMenu *menu )
484 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
487 wxMenuItem *item = node->GetData();
488 node = node->GetNext();
490 /* Delete the submenus */
491 wxMenu *submenu = item->GetSubMenu();
494 RecursiveDestroy( submenu );
496 menu->Delete( item );
500 void Interface::OnMenuOpen(wxMenuEvent& event)
502 #if !defined( __WXMSW__ )
503 if( event.GetEventObject() == p_audio_menu )
507 p_audio_menu = AudioMenu( p_intf, this );
509 /* Work-around for buggy wxGTK */
510 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
511 RecursiveDestroy( menu );
512 /* End work-around */
515 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
516 if( menu ) delete menu;
520 else b_audio_menu = 1;
522 else if( event.GetEventObject() == p_video_menu )
526 p_video_menu = VideoMenu( p_intf, this );
528 /* Work-around for buggy wxGTK */
529 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
530 RecursiveDestroy( menu );
531 /* End work-around */
534 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
535 if( menu ) delete menu;
539 else b_video_menu = 1;
541 else if( event.GetEventObject() == p_navig_menu )
545 p_navig_menu = NavigMenu( p_intf, this );
547 /* Work-around for buggy wxGTK */
548 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
549 RecursiveDestroy( menu );
550 /* End work-around */
553 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
554 if( menu ) delete menu;
558 else b_navig_menu = 1;
562 p_audio_menu = AudioMenu( p_intf, this );
563 wxMenu *menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
564 if( menu ) delete menu;
566 p_video_menu = VideoMenu( p_intf, this );
567 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
568 if( menu ) delete menu;
570 p_navig_menu = NavigMenu( p_intf, this );
571 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
572 if( menu ) delete menu;
577 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
578 void Interface::OnContextMenu2(wxContextMenuEvent& event)
580 ::PopupMenu( p_intf, this, ScreenToClient(event.GetPosition()) );
583 void Interface::OnContextMenu(wxMouseEvent& event)
585 ::PopupMenu( p_intf, this, event.GetPosition() );
588 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
590 /* TRUE is to force the frame to close. */
594 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
597 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
598 wxU(_(" (wxWindows interface)\n\n")) +
599 wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
600 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
601 "http://www.videolan.org/\n\n")) +
602 wxU(_("This is the VideoLAN Client, a DVD, MPEG and DivX player."
603 "\nIt can play MPEG and MPEG2 files from a file or from a "
604 "network source.")) );
606 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
607 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
610 void Interface::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
612 /* Show/hide the playlist window */
613 Playlist *p_playlist_window = p_intf->p_sys->p_playlist_window;
614 if( p_playlist_window )
616 p_playlist_window->ShowPlaylist( ! p_playlist_window->IsShown() );
620 void Interface::OnLogs( wxCommandEvent& WXUNUSED(event) )
622 /* Show/hide the log window */
623 wxFrame *p_messages_window = p_intf->p_sys->p_messages_window;
624 if( p_messages_window )
626 p_messages_window->Show( ! p_messages_window->IsShown() );
630 void Interface::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
632 /* Show/hide the file info window */
633 wxFrame *p_fileinfo_window = p_intf->p_sys->p_fileinfo_window;
634 if( p_fileinfo_window )
636 p_fileinfo_window->Show( ! p_fileinfo_window->IsShown() );
640 void Interface::OnPreferences( wxCommandEvent& WXUNUSED(event) )
642 /* Show/hide the open dialog */
643 if( p_prefs_dialog == NULL )
645 p_prefs_dialog = new PrefsDialog( p_intf, this );
650 p_prefs_dialog->Show( true );
654 void Interface::OnOpenFileSimple( wxCommandEvent& WXUNUSED(event) )
656 playlist_t *p_playlist =
657 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
659 if( p_playlist == NULL )
664 if( p_file_dialog == NULL )
665 p_file_dialog = new wxFileDialog( this, wxU(_("Open file")),
666 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
668 if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK )
672 p_file_dialog->GetPaths( paths );
674 for( size_t i = 0; i < paths.GetCount(); i++ )
675 playlist_Add( p_playlist, (const char *)paths[i].mb_str(),
676 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO),
680 vlc_object_release( p_playlist );
683 void Interface::OnOpenFile( wxCommandEvent& WXUNUSED(event) )
688 void Interface::OnOpenDisc( wxCommandEvent& WXUNUSED(event) )
693 void Interface::OnOpenNet( wxCommandEvent& WXUNUSED(event) )
698 void Interface::OnOpenSat( wxCommandEvent& WXUNUSED(event) )
703 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
705 wxCommandEvent dummy;
706 playlist_t *p_playlist =
707 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
709 if( p_playlist == NULL )
711 /* If the playlist is empty, open a file requester instead */
716 vlc_mutex_lock( &p_playlist->object_lock );
717 if( p_playlist->i_size )
719 vlc_mutex_unlock( &p_playlist->object_lock );
721 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
724 if( p_input == NULL )
726 /* No stream was playing, start one */
727 playlist_Play( p_playlist );
728 TogglePlayButton( PLAYING_S );
729 vlc_object_release( p_playlist );
733 if( p_input->stream.control.i_status != PAUSE_S )
735 /* A stream is being played, pause it */
736 input_SetStatus( p_input, INPUT_STATUS_PAUSE );
737 TogglePlayButton( PAUSE_S );
738 vlc_object_release( p_playlist );
739 vlc_object_release( p_input );
743 /* Stream is paused, resume it */
744 input_SetStatus( p_input, INPUT_STATUS_PLAY );
745 TogglePlayButton( PLAYING_S );
746 vlc_object_release( p_input );
747 vlc_object_release( p_playlist );
751 vlc_mutex_unlock( &p_playlist->object_lock );
752 vlc_object_release( p_playlist );
757 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
759 playlist_t * p_playlist =
760 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
762 if( p_playlist == NULL )
767 playlist_Stop( p_playlist );
768 TogglePlayButton( PAUSE_S );
769 vlc_object_release( p_playlist );
772 void Interface::OnSliderUpdate( wxScrollEvent& event )
774 vlc_mutex_lock( &p_intf->change_lock );
777 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
778 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
781 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
782 && p_intf->p_sys->p_input )
784 p_intf->p_sys->i_slider_pos = event.GetPosition();
785 input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos *
786 100 / SLIDER_MAX_POS,
787 INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
791 p_intf->p_sys->b_slider_free = VLC_TRUE;
795 p_intf->p_sys->b_slider_free = VLC_FALSE;
797 if( p_intf->p_sys->p_input )
799 /* Update stream date */
800 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
801 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
803 slider_box->SetLabel(
804 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
806 p_area->i_size * event.GetPosition()
807 / SLIDER_MAX_POS )) );
813 vlc_mutex_unlock( &p_intf->change_lock );
816 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
818 playlist_t * p_playlist =
819 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
821 if( p_playlist == NULL )
826 playlist_Prev( p_playlist );
827 vlc_object_release( p_playlist );
830 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
832 playlist_t * p_playlist =
833 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
835 if( p_playlist == NULL )
840 playlist_Next( p_playlist );
841 vlc_object_release( p_playlist );
844 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
846 input_thread_t *p_input =
847 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
851 input_SetStatus( p_input, INPUT_STATUS_SLOWER );
852 vlc_object_release( p_input );
856 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
858 input_thread_t *p_input =
859 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
863 input_SetStatus( p_input, INPUT_STATUS_FASTER );
864 vlc_object_release( p_input );
868 void Interface::TogglePlayButton( int i_playing_status )
870 if( i_playing_status == i_old_playing_status )
873 GetToolBar()->DeleteTool( PlayStream_Event );
875 if( i_playing_status == PLAYING_S )
877 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")),
878 wxBitmap( pause_xpm ), wxNullBitmap,
879 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
883 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")),
884 wxBitmap( play_xpm ), wxNullBitmap,
885 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
888 GetToolBar()->Realize();
890 i_old_playing_status = i_playing_status;
893 #if !defined(__WXX11__)
894 /*****************************************************************************
895 * Definition of DragAndDrop class.
896 *****************************************************************************/
897 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
902 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
903 const wxArrayString& filenames )
905 /* Add dropped files to the playlist */
907 playlist_t *p_playlist =
908 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
910 if( p_playlist == NULL )
915 for( size_t i = 0; i < filenames.GetCount(); i++ )
916 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
917 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
919 vlc_object_release( p_playlist );
925 /*****************************************************************************
926 * Definition of wxVolCtrl class.
927 *****************************************************************************/
928 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
929 : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
930 wxGA_VERTICAL | wxGA_SMOOTH )
935 void wxVolCtrl::OnChange( wxMouseEvent& event )
937 int i_volume = (GetRect().height - event.GetY()) * 200 / GetRect().height;
941 void wxVolCtrl::Change( int i_volume )
943 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
944 SetValue( i_volume );
945 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),