1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: interface.cpp,v 1.55 2003/08/14 19:25:56 sigmunau 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)
116 EVT_MOTION(wxVolCtrl::OnChange)
119 /*****************************************************************************
121 *****************************************************************************/
123 /* IDs for the controls and the menu commands */
127 Exit_Event = wxID_HIGHEST,
128 OpenFileSimple_Event,
149 /* it is important for the id corresponding to the "About" command to have
150 * this standard value as otherwise it won't be handled properly under Mac
151 * (where it is special and put into the "Apple" menu) */
152 About_Event = wxID_ABOUT
155 BEGIN_EVENT_TABLE(Interface, wxFrame)
157 EVT_MENU(Exit_Event, Interface::OnExit)
158 EVT_MENU(About_Event, Interface::OnAbout)
160 EVT_MENU(Playlist_Event, Interface::OnShowDialog)
161 EVT_MENU(Logs_Event, Interface::OnShowDialog)
162 EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
163 EVT_MENU(Prefs_Event, Interface::OnShowDialog)
165 EVT_MENU_OPEN(Interface::OnMenuOpen)
167 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
168 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
170 EVT_RIGHT_UP(Interface::OnContextMenu)
173 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
174 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
175 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
176 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
177 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
178 EVT_MENU(StopStream_Event, Interface::OnStopStream)
179 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
180 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
181 EVT_MENU(NextStream_Event, Interface::OnNextStream)
182 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
183 EVT_MENU(FastStream_Event, Interface::OnFastStream)
186 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
190 /*****************************************************************************
192 *****************************************************************************/
193 Interface::Interface( intf_thread_t *_p_intf ):
194 wxFrame( NULL, -1, wxT("VLC media player"),
195 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
197 /* Initializations */
199 i_old_playing_status = PAUSE_S;
201 /* Give our interface a nice little icon */
202 SetIcon( wxIcon( vlc_xpm ) );
204 /* Create a sizer for the main frame */
205 frame_sizer = new wxBoxSizer( wxHORIZONTAL );
206 SetSizer( frame_sizer );
208 /* Create a dummy widget that can get the keyboard focus */
209 wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
212 frame_sizer->Add( p_dummy );
214 /* Creation of the menu bar */
217 /* Creation of the tool bar */
220 /* Creation of the slider sub-window */
222 frame_sizer->Add( slider_frame, 1, wxGROW, 0 );
223 frame_sizer->Hide( slider_frame );
225 /* Creation of the status bar
226 * Helptext for menu items and toolbar tools will automatically get
228 int i_status_width[3] = {-6, -2, -9};
229 statusbar = CreateStatusBar( 3 ); /* 2 fields */
230 statusbar->SetStatusWidths( 3, i_status_width );
231 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
233 /* Make sure we've got the right background colour */
234 SetBackgroundColour( slider_frame->GetBackgroundColour() );
236 /* Layout everything */
237 SetAutoLayout( TRUE );
238 frame_sizer->Layout();
239 frame_sizer->Fit(this);
241 #if !defined(__WXX11__)
242 /* Associate drop targets with the main interface */
243 SetDropTarget( new DragAndDrop( p_intf ) );
246 UpdateAcceleratorTable();
249 Interface::~Interface()
251 if( p_intf->p_sys->p_wxwindow )
253 delete p_intf->p_sys->p_wxwindow;
258 /*****************************************************************************
260 *****************************************************************************/
261 void Interface::CreateOurMenuBar()
263 #define HELP_FILE N_("Open a file")
264 #define HELP_DISC N_("Open a DVD or (S)VCD")
265 #define HELP_NET N_("Open a network stream")
266 #define HELP_SAT N_("Open a satellite stream")
267 #define HELP_EJECT N_("Eject the DVD/CD")
268 #define HELP_EXIT N_("Exit this program")
270 #define HELP_PLAYLIST N_("Open the playlist")
271 #define HELP_LOGS N_("Show the program logs")
272 #define HELP_FILEINFO N_("Show information about the file being played")
274 #define HELP_PREFS N_("Go to the preferences menu")
276 #define HELP_ABOUT N_("About this program")
278 /* Create the "File" menu */
279 wxMenu *file_menu = new wxMenu;
280 file_menu->Append( OpenFileSimple_Event, wxU(_("Simple &Open ...")),
282 file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
284 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
286 file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
289 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
293 file_menu->AppendSeparator();
294 file_menu->Append( EjectDisc_Event, wxU(_("&Eject Disc")),
295 wxU(_(HELP_EJECT)) );
297 file_menu->AppendSeparator();
298 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
300 /* Create the "View" menu */
301 wxMenu *view_menu = new wxMenu;
302 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
303 wxU(_(HELP_PLAYLIST)) );
304 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
305 view_menu->Append( FileInfo_Event, wxU(_("&File info...")),
306 wxU(_(HELP_FILEINFO)) );
308 /* Create the "Settings" menu */
309 wxMenu *settings_menu = new wxMenu;
310 settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
311 wxU(_(HELP_PREFS)) );
313 /* Create the "Audio" menu */
314 p_audio_menu = new wxMenu;
317 /* Create the "Video" menu */
318 p_video_menu = new wxMenu;
321 /* Create the "Navigation" menu */
322 p_navig_menu = new wxMenu;
325 /* Create the "Help" menu */
326 wxMenu *help_menu = new wxMenu;
327 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
329 /* Append the freshly created menus to the menu bar... */
330 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
331 menubar->Append( file_menu, wxU(_("&File")) );
332 menubar->Append( view_menu, wxU(_("&View")) );
333 menubar->Append( settings_menu, wxU(_("&Settings")) );
334 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
335 menubar->Append( p_video_menu, wxU(_("&Video")) );
336 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
337 menubar->Append( help_menu, wxU(_("&Help")) );
339 /* Attach the menu bar to the frame */
340 SetMenuBar( menubar );
342 /* Intercept all menu events in our custom event handler */
343 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
345 #if !defined(__WXX11__)
346 /* Associate drop targets with the menubar */
347 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
351 void Interface::CreateOurToolBar()
353 #define HELP_STOP N_("Stop current playlist item")
354 #define HELP_PLAY N_("Play current playlist item")
355 #define HELP_PAUSE N_("Pause current playlist item")
356 #define HELP_PLO N_("Open playlist")
357 #define HELP_PLP N_("Previous playlist item")
358 #define HELP_PLN N_("Next playlist item")
359 #define HELP_SLOW N_("Play slower")
360 #define HELP_FAST N_("Play faster")
362 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
363 * version because we don't include wx.rc */
365 wxToolBar *toolbar = CreateToolBar(
366 wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
368 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
370 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
372 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
374 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
377 toolbar->AddTool( OpenSat_Event, wxU(_("Sat")), wxBitmap( sat_xpm ),
380 toolbar->AddSeparator();
381 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
383 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
385 toolbar->AddSeparator();
386 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
387 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
388 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
389 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
390 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
392 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
394 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
399 /* Place the toolbar in a sizer, so we can calculate the width of the
400 * toolbar and set this as the minimum for the main frame size. */
401 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
402 toolbar_sizer->Add( toolbar, 0, 0, 0 );
403 toolbar_sizer->Layout();
406 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
408 frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
409 toolbar->GetToolsCount(), -1 );
412 #if !defined(__WXX11__)
413 /* Associate drop targets with the toolbar */
414 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
418 void Interface::CreateOurSlider()
420 /* Create a new frame and sizer containing the slider */
421 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
422 slider_frame->SetAutoLayout( TRUE );
423 wxBoxSizer *frame_sizer =
424 new wxBoxSizer( wxHORIZONTAL );
426 /* Create static box to surround the slider */
427 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
429 /* Create sizer for slider frame */
430 wxStaticBoxSizer *slider_sizer =
431 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
432 slider_sizer->SetMinSize( -1, 50 );
435 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
436 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
437 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
440 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
442 /* Add everything to the frame */
443 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
444 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
445 slider_frame->SetSizer( frame_sizer );
446 frame_sizer->Layout();
447 frame_sizer->SetSizeHints(slider_frame);
449 /* Hide the slider by default */
450 slider_frame->Hide();
453 void Interface::UpdateAcceleratorTable()
455 /* Set some hotkeys */
456 wxAcceleratorEntry entries[6];
457 int i_key = config_GetInt( p_intf, "quit-key" );
459 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
461 i_key = config_GetInt( p_intf, "stop-key" );
462 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
464 i_key = config_GetInt( p_intf, "play-pause-key" );
465 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
467 i_key = config_GetInt( p_intf, "next-key" );
468 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
470 i_key = config_GetInt( p_intf, "prev-key" );
471 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
473 i_key = config_GetInt( p_intf, "faster-key" );
474 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
476 i_key = config_GetInt( p_intf, "slower-key" );
477 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
480 wxAcceleratorTable accel( 6, entries );
483 msg_Err( p_intf, "invalid accelerator table" );
485 SetAcceleratorTable( accel );
486 msg_Dbg( p_intf, "accelerator table loaded" );
490 /*****************************************************************************
492 *****************************************************************************/
493 /* Work-around helper for buggy wxGTK */
494 void RecursiveDestroy( wxMenu *menu )
496 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
499 wxMenuItem *item = node->GetData();
500 node = node->GetNext();
502 /* Delete the submenus */
503 wxMenu *submenu = item->GetSubMenu();
506 RecursiveDestroy( submenu );
508 menu->Delete( item );
512 void Interface::OnMenuOpen(wxMenuEvent& event)
514 #if !defined( __WXMSW__ )
515 if( event.GetEventObject() == p_audio_menu )
519 p_audio_menu = AudioMenu( p_intf, this );
521 /* Work-around for buggy wxGTK */
522 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
523 RecursiveDestroy( menu );
524 /* End work-around */
527 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
528 if( menu ) delete menu;
532 else b_audio_menu = 1;
534 else if( event.GetEventObject() == p_video_menu )
538 p_video_menu = VideoMenu( p_intf, this );
540 /* Work-around for buggy wxGTK */
541 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
542 RecursiveDestroy( menu );
543 /* End work-around */
546 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
547 if( menu ) delete menu;
551 else b_video_menu = 1;
553 else if( event.GetEventObject() == p_navig_menu )
557 p_navig_menu = NavigMenu( p_intf, this );
559 /* Work-around for buggy wxGTK */
560 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
561 RecursiveDestroy( menu );
562 /* End work-around */
565 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
566 if( menu ) delete menu;
570 else b_navig_menu = 1;
574 p_audio_menu = AudioMenu( p_intf, this );
575 wxMenu *menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
576 if( menu ) delete menu;
578 p_video_menu = VideoMenu( p_intf, this );
579 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
580 if( menu ) delete menu;
582 p_navig_menu = NavigMenu( p_intf, this );
583 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
584 if( menu ) delete menu;
589 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
590 void Interface::OnContextMenu2(wxContextMenuEvent& event)
592 /* Only show the context menu for the main interface */
593 if( GetId() != event.GetId() )
599 if( p_intf->p_sys->pf_show_dialog )
600 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 0, 0 );
603 void Interface::OnContextMenu(wxMouseEvent& event)
605 if( p_intf->p_sys->pf_show_dialog )
606 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 0, 0 );
609 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
611 /* TRUE is to force the frame to close. */
615 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
618 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
619 wxU(_(" (wxWindows interface)\n\n")) +
620 wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
621 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
622 "http://www.videolan.org/\n\n")) +
623 wxU(_("This is the VideoLAN Client, a DVD, MPEG and DivX player."
624 "\nIt can play MPEG and MPEG2 files from a file or from a "
625 "network source.")) );
627 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
628 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
631 void Interface::OnShowDialog( wxCommandEvent& event )
633 if( p_intf->p_sys->pf_show_dialog )
637 switch( event.GetId() )
639 case OpenFileSimple_Event:
640 i_id = INTF_DIALOG_FILE_SIMPLE;
643 i_id = INTF_DIALOG_FILE;
646 i_id = INTF_DIALOG_DISC;
649 i_id = INTF_DIALOG_NET;
652 i_id = INTF_DIALOG_SAT;
655 i_id = INTF_DIALOG_PLAYLIST;
658 i_id = INTF_DIALOG_MESSAGES;
661 i_id = INTF_DIALOG_FILEINFO;
664 i_id = INTF_DIALOG_PREFS;
667 i_id = INTF_DIALOG_FILE;
672 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
676 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
678 wxCommandEvent dummy;
679 playlist_t *p_playlist =
680 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
682 if( p_playlist == NULL ) return;
684 if( p_playlist->i_size )
686 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
689 if( p_input == NULL )
691 /* No stream was playing, start one */
692 playlist_Play( p_playlist );
693 TogglePlayButton( PLAYING_S );
694 vlc_object_release( p_playlist );
698 if( p_input->stream.control.i_status != PAUSE_S )
700 /* A stream is being played, pause it */
701 input_SetStatus( p_input, INPUT_STATUS_PAUSE );
702 TogglePlayButton( PAUSE_S );
703 vlc_object_release( p_playlist );
704 vlc_object_release( p_input );
708 /* Stream is paused, resume it */
709 input_SetStatus( p_input, INPUT_STATUS_PLAY );
710 TogglePlayButton( PLAYING_S );
711 vlc_object_release( p_input );
712 vlc_object_release( p_playlist );
716 /* If the playlist is empty, open a file requester instead */
717 vlc_object_release( p_playlist );
718 OnShowDialog( dummy );
722 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
724 playlist_t * p_playlist =
725 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
727 if( p_playlist == NULL )
732 playlist_Stop( p_playlist );
733 TogglePlayButton( PAUSE_S );
734 vlc_object_release( p_playlist );
737 void Interface::OnSliderUpdate( wxScrollEvent& event )
739 vlc_mutex_lock( &p_intf->change_lock );
742 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
743 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
746 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
747 && p_intf->p_sys->p_input )
749 p_intf->p_sys->i_slider_pos = event.GetPosition();
750 input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos *
751 100 / SLIDER_MAX_POS,
752 INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
756 p_intf->p_sys->b_slider_free = VLC_TRUE;
760 p_intf->p_sys->b_slider_free = VLC_FALSE;
762 if( p_intf->p_sys->p_input )
764 /* Update stream date */
765 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
766 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
768 slider_box->SetLabel(
769 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
771 p_area->i_size * event.GetPosition()
772 / SLIDER_MAX_POS )) );
778 vlc_mutex_unlock( &p_intf->change_lock );
781 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
783 playlist_t * p_playlist =
784 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
786 if( p_playlist == NULL )
791 vlc_mutex_lock( &p_playlist->object_lock );
792 if( p_playlist->p_input != NULL )
794 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
795 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
797 vlc_value_t val; val.b_bool = VLC_TRUE;
798 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
799 var_Set( p_playlist->p_input, "prev-title", val );
800 vlc_mutex_unlock( &p_playlist->object_lock );
801 vlc_object_release( p_playlist );
804 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
806 vlc_mutex_unlock( &p_playlist->object_lock );
808 playlist_Prev( p_playlist );
809 vlc_object_release( p_playlist );
812 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
814 playlist_t * p_playlist =
815 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
817 if( p_playlist == NULL )
822 vlc_mutex_lock( &p_playlist->object_lock );
823 if( p_playlist->p_input != NULL )
825 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
826 if( p_playlist->p_input->stream.i_area_nb > 1 &&
827 p_playlist->p_input->stream.p_selected_area->i_id <
828 p_playlist->p_input->stream.i_area_nb - 1 )
830 vlc_value_t val; val.b_bool = VLC_TRUE;
831 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
832 var_Set( p_playlist->p_input, "next-title", val );
833 vlc_mutex_unlock( &p_playlist->object_lock );
834 vlc_object_release( p_playlist );
837 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
839 vlc_mutex_unlock( &p_playlist->object_lock );
841 playlist_Next( p_playlist );
842 vlc_object_release( p_playlist );
845 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
847 input_thread_t *p_input =
848 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
852 input_SetStatus( p_input, INPUT_STATUS_SLOWER );
853 vlc_object_release( p_input );
857 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
859 input_thread_t *p_input =
860 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
864 input_SetStatus( p_input, INPUT_STATUS_FASTER );
865 vlc_object_release( p_input );
869 void Interface::TogglePlayButton( int i_playing_status )
871 if( i_playing_status == i_old_playing_status )
874 GetToolBar()->DeleteTool( PlayStream_Event );
876 if( i_playing_status == PLAYING_S )
878 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")),
879 wxBitmap( pause_xpm ), wxNullBitmap,
880 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
884 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")),
885 wxBitmap( play_xpm ), wxNullBitmap,
886 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
889 GetToolBar()->Realize();
891 i_old_playing_status = i_playing_status;
894 #if !defined(__WXX11__)
895 /*****************************************************************************
896 * Definition of DragAndDrop class.
897 *****************************************************************************/
898 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
903 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
904 const wxArrayString& filenames )
906 /* Add dropped files to the playlist */
908 playlist_t *p_playlist =
909 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
911 if( p_playlist == NULL )
916 for( size_t i = 0; i < filenames.GetCount(); i++ )
917 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(), 0, 0,
918 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
920 vlc_object_release( p_playlist );
926 /*****************************************************************************
927 * Definition of wxVolCtrl class.
928 *****************************************************************************/
929 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
930 : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
931 wxGA_VERTICAL | wxGA_SMOOTH )
936 void wxVolCtrl::OnChange( wxMouseEvent& event )
938 if( !event.LeftDown() && !event.LeftIsDown() ) return;
940 int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
941 GetClientSize().GetHeight();
945 void wxVolCtrl::Change( int i_volume )
947 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
948 SetValue( i_volume );
949 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),