1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: interface.cpp,v 1.59 2003/08/30 13:59:15 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 #include "stream_control.h"
37 #include "wxwindows.h"
39 /* include the toolbar graphics */
40 #include "bitmaps/file.xpm"
41 #include "bitmaps/disc.xpm"
42 #include "bitmaps/net.xpm"
44 #include "bitmaps/sat.xpm"
46 #include "bitmaps/play.xpm"
47 #include "bitmaps/pause.xpm"
48 #include "bitmaps/stop.xpm"
49 #include "bitmaps/previous.xpm"
50 #include "bitmaps/next.xpm"
51 #include "bitmaps/playlist.xpm"
52 #include "bitmaps/fast.xpm"
53 #include "bitmaps/slow.xpm"
55 #define TOOLBAR_BMP_WIDTH 36
56 #define TOOLBAR_BMP_HEIGHT 36
58 /* include the icon graphic */
59 #include "../../../share/vlc32x32.xpm"
61 /*****************************************************************************
62 * Local class declarations.
63 *****************************************************************************/
64 class wxMenuExt: public wxMenu
68 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
69 const wxString& helpString, wxItemKind kind,
70 char *_psz_var, int _i_object_id, vlc_value_t _val,
73 virtual ~wxMenuExt() {};
84 class wxVolCtrl: public wxGauge
88 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
89 virtual ~wxVolCtrl() {};
91 void Change( int i_volume );
93 void OnChange( wxMouseEvent& event );
96 intf_thread_t *p_intf;
98 DECLARE_EVENT_TABLE();
101 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
103 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
104 EVT_MOTION(wxVolCtrl::OnChange)
107 /*****************************************************************************
109 *****************************************************************************/
111 /* IDs for the controls and the menu commands */
115 Exit_Event = wxID_HIGHEST,
116 OpenFileSimple_Event,
137 /* it is important for the id corresponding to the "About" command to have
138 * this standard value as otherwise it won't be handled properly under Mac
139 * (where it is special and put into the "Apple" menu) */
140 About_Event = wxID_ABOUT
143 BEGIN_EVENT_TABLE(Interface, wxFrame)
145 EVT_MENU(Exit_Event, Interface::OnExit)
146 EVT_MENU(About_Event, Interface::OnAbout)
148 EVT_MENU(Playlist_Event, Interface::OnShowDialog)
149 EVT_MENU(Logs_Event, Interface::OnShowDialog)
150 EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
151 EVT_MENU(Prefs_Event, Interface::OnShowDialog)
153 EVT_MENU_OPEN(Interface::OnMenuOpen)
155 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
156 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
158 EVT_RIGHT_UP(Interface::OnContextMenu)
161 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
162 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
163 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
164 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
165 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
166 EVT_MENU(StopStream_Event, Interface::OnStopStream)
167 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
168 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
169 EVT_MENU(NextStream_Event, Interface::OnNextStream)
170 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
171 EVT_MENU(FastStream_Event, Interface::OnFastStream)
174 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
178 /*****************************************************************************
180 *****************************************************************************/
181 Interface::Interface( intf_thread_t *_p_intf ):
182 wxFrame( NULL, -1, wxT("VLC media player"),
183 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
185 /* Initializations */
187 i_old_playing_status = PAUSE_S;
189 /* Give our interface a nice little icon */
190 SetIcon( wxIcon( vlc_xpm ) );
192 /* Create a sizer for the main frame */
193 frame_sizer = new wxBoxSizer( wxHORIZONTAL );
194 SetSizer( frame_sizer );
196 /* Create a dummy widget that can get the keyboard focus */
197 wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
200 frame_sizer->Add( p_dummy );
202 /* Creation of the menu bar */
205 /* Creation of the tool bar */
208 /* Creation of the slider sub-window */
210 frame_sizer->Add( slider_frame, 1, wxGROW, 0 );
211 frame_sizer->Hide( slider_frame );
213 /* Creation of the status bar
214 * Helptext for menu items and toolbar tools will automatically get
216 int i_status_width[3] = {-6, -2, -9};
217 statusbar = CreateStatusBar( 3 ); /* 2 fields */
218 statusbar->SetStatusWidths( 3, i_status_width );
219 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
221 /* Make sure we've got the right background colour */
222 SetBackgroundColour( slider_frame->GetBackgroundColour() );
224 /* Layout everything */
225 SetAutoLayout( TRUE );
226 frame_sizer->Layout();
227 frame_sizer->Fit(this);
229 #if !defined(__WXX11__)
230 /* Associate drop targets with the main interface */
231 SetDropTarget( new DragAndDrop( p_intf ) );
234 UpdateAcceleratorTable();
237 Interface::~Interface()
239 if( p_intf->p_sys->p_wxwindow )
241 delete p_intf->p_sys->p_wxwindow;
246 /*****************************************************************************
248 *****************************************************************************/
249 void Interface::CreateOurMenuBar()
251 #define HELP_FILE N_("Open a file")
252 #define HELP_DISC N_("Open a DVD or (S)VCD")
253 #define HELP_NET N_("Open a network stream")
254 #define HELP_SAT N_("Open a satellite stream")
255 #define HELP_EJECT N_("Eject the DVD/CD")
256 #define HELP_EXIT N_("Exit this program")
258 #define HELP_PLAYLIST N_("Open the playlist")
259 #define HELP_LOGS N_("Show the program logs")
260 #define HELP_FILEINFO N_("Show information about the file being played")
262 #define HELP_PREFS N_("Go to the preferences menu")
264 #define HELP_ABOUT N_("About this program")
266 /* Create the "File" menu */
267 wxMenu *file_menu = new wxMenu;
268 file_menu->Append( OpenFileSimple_Event, wxU(_("Simple &Open ...")),
270 file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
272 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
274 file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
277 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
281 file_menu->AppendSeparator();
282 file_menu->Append( EjectDisc_Event, wxU(_("&Eject Disc")),
283 wxU(_(HELP_EJECT)) );
285 file_menu->AppendSeparator();
286 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
288 /* Create the "View" menu */
289 wxMenu *view_menu = new wxMenu;
290 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
291 wxU(_(HELP_PLAYLIST)) );
292 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
293 view_menu->Append( FileInfo_Event, wxU(_("&File info...")),
294 wxU(_(HELP_FILEINFO)) );
296 /* Create the "Settings" menu */
297 wxMenu *settings_menu = new wxMenu;
298 settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
299 wxU(_(HELP_PREFS)) );
301 /* Create the "Audio" menu */
302 p_audio_menu = new wxMenu;
305 /* Create the "Video" menu */
306 p_video_menu = new wxMenu;
309 /* Create the "Navigation" menu */
310 p_navig_menu = new wxMenu;
313 /* Create the "Help" menu */
314 wxMenu *help_menu = new wxMenu;
315 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
317 /* Append the freshly created menus to the menu bar... */
318 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
319 menubar->Append( file_menu, wxU(_("&File")) );
320 menubar->Append( view_menu, wxU(_("&View")) );
321 menubar->Append( settings_menu, wxU(_("&Settings")) );
322 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
323 menubar->Append( p_video_menu, wxU(_("&Video")) );
324 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
325 menubar->Append( help_menu, wxU(_("&Help")) );
327 /* Attach the menu bar to the frame */
328 SetMenuBar( menubar );
330 /* Intercept all menu events in our custom event handler */
331 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
333 #if !defined(__WXX11__)
334 /* Associate drop targets with the menubar */
335 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
339 void Interface::CreateOurToolBar()
341 #define HELP_STOP N_("Stop current playlist item")
342 #define HELP_PLAY N_("Play current playlist item")
343 #define HELP_PAUSE N_("Pause current playlist item")
344 #define HELP_PLO N_("Open playlist")
345 #define HELP_PLP N_("Previous playlist item")
346 #define HELP_PLN N_("Next playlist item")
347 #define HELP_SLOW N_("Play slower")
348 #define HELP_FAST N_("Play faster")
350 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
351 * version because we don't include wx.rc */
353 wxToolBar *toolbar = CreateToolBar(
354 wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
356 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
358 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
360 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
362 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
365 toolbar->AddTool( OpenSat_Event, wxU(_("Sat")), wxBitmap( sat_xpm ),
368 toolbar->AddSeparator();
369 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
371 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
373 toolbar->AddSeparator();
374 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
375 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
376 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
377 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
378 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
380 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
382 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
387 /* Place the toolbar in a sizer, so we can calculate the width of the
388 * toolbar and set this as the minimum for the main frame size. */
389 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
390 toolbar_sizer->Add( toolbar, 0, 0, 0 );
391 toolbar_sizer->Layout();
394 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
396 frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
397 toolbar->GetToolsCount(), -1 );
400 #if !defined(__WXX11__)
401 /* Associate drop targets with the toolbar */
402 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
406 void Interface::CreateOurSlider()
408 /* Create a new frame and sizer containing the slider */
409 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
410 slider_frame->SetAutoLayout( TRUE );
411 wxBoxSizer *frame_sizer =
412 new wxBoxSizer( wxHORIZONTAL );
414 /* Create static box to surround the slider */
415 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
417 /* Create sizer for slider frame */
418 wxStaticBoxSizer *slider_sizer =
419 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
420 slider_sizer->SetMinSize( -1, 50 );
423 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
424 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
425 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
428 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
430 /* Add everything to the frame */
431 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
432 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
433 slider_frame->SetSizer( frame_sizer );
434 frame_sizer->Layout();
435 frame_sizer->SetSizeHints(slider_frame);
437 /* Hide the slider by default */
438 slider_frame->Hide();
441 void Interface::UpdateAcceleratorTable()
443 /* Set some hotkeys */
444 wxAcceleratorEntry entries[7];
445 int i_key = config_GetInt( p_intf, "quit-key" );
447 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
449 i_key = config_GetInt( p_intf, "stop-key" );
450 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
452 i_key = config_GetInt( p_intf, "play-pause-key" );
453 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
455 i_key = config_GetInt( p_intf, "next-key" );
456 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
458 i_key = config_GetInt( p_intf, "prev-key" );
459 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
461 i_key = config_GetInt( p_intf, "faster-key" );
462 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
464 i_key = config_GetInt( p_intf, "slower-key" );
465 entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
468 wxAcceleratorTable accel( 7, entries );
471 msg_Err( p_intf, "invalid accelerator table" );
473 SetAcceleratorTable( accel );
474 msg_Dbg( p_intf, "accelerator table loaded" );
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 /* Only show the context menu for the main interface */
581 if( GetId() != event.GetId() )
587 if( p_intf->p_sys->pf_show_dialog )
588 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
591 void Interface::OnContextMenu(wxMouseEvent& event)
593 if( p_intf->p_sys->pf_show_dialog )
594 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
597 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
599 /* TRUE is to force the frame to close. */
603 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
606 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
607 wxU(_(" (wxWindows interface)\n\n")) +
608 wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
609 wxU( INTF_ABOUT_MSG ) + wxT("\n\n") +
610 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
611 "http://www.videolan.org/\n\n")) );
613 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
614 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
617 void Interface::OnShowDialog( wxCommandEvent& event )
619 if( p_intf->p_sys->pf_show_dialog )
623 switch( event.GetId() )
625 case OpenFileSimple_Event:
626 i_id = INTF_DIALOG_FILE_SIMPLE;
629 i_id = INTF_DIALOG_FILE;
632 i_id = INTF_DIALOG_DISC;
635 i_id = INTF_DIALOG_NET;
638 i_id = INTF_DIALOG_SAT;
641 i_id = INTF_DIALOG_PLAYLIST;
644 i_id = INTF_DIALOG_MESSAGES;
647 i_id = INTF_DIALOG_FILEINFO;
650 i_id = INTF_DIALOG_PREFS;
653 i_id = INTF_DIALOG_FILE;
658 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
662 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
664 wxCommandEvent dummy;
665 playlist_t *p_playlist =
666 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
668 if( p_playlist == NULL ) return;
670 if( p_playlist->i_size )
672 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
675 if( p_input == NULL )
677 /* No stream was playing, start one */
678 playlist_Play( p_playlist );
679 TogglePlayButton( PLAYING_S );
680 vlc_object_release( p_playlist );
684 if( p_input->stream.control.i_status != PAUSE_S )
686 /* A stream is being played, pause it */
687 input_SetStatus( p_input, INPUT_STATUS_PAUSE );
688 TogglePlayButton( PAUSE_S );
689 vlc_object_release( p_playlist );
690 vlc_object_release( p_input );
694 /* Stream is paused, resume it */
695 input_SetStatus( p_input, INPUT_STATUS_PLAY );
696 TogglePlayButton( PLAYING_S );
697 vlc_object_release( p_input );
698 vlc_object_release( p_playlist );
702 /* If the playlist is empty, open a file requester instead */
703 vlc_object_release( p_playlist );
704 OnShowDialog( dummy );
708 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
710 playlist_t * p_playlist =
711 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
713 if( p_playlist == NULL )
718 playlist_Stop( p_playlist );
719 TogglePlayButton( PAUSE_S );
720 vlc_object_release( p_playlist );
723 void Interface::OnSliderUpdate( wxScrollEvent& event )
725 vlc_mutex_lock( &p_intf->change_lock );
728 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
729 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
732 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
733 && p_intf->p_sys->p_input )
735 p_intf->p_sys->i_slider_pos = event.GetPosition();
736 input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos *
737 100 / SLIDER_MAX_POS,
738 INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
742 p_intf->p_sys->b_slider_free = VLC_TRUE;
746 p_intf->p_sys->b_slider_free = VLC_FALSE;
748 if( p_intf->p_sys->p_input )
750 /* Update stream date */
751 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
752 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
754 slider_box->SetLabel(
755 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
757 p_area->i_size * event.GetPosition()
758 / SLIDER_MAX_POS )) );
764 vlc_mutex_unlock( &p_intf->change_lock );
767 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
769 playlist_t * p_playlist =
770 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
772 if( p_playlist == NULL )
777 vlc_mutex_lock( &p_playlist->object_lock );
778 if( p_playlist->p_input != NULL )
780 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
781 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
783 vlc_value_t val; val.b_bool = VLC_TRUE;
784 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
785 var_Set( p_playlist->p_input, "prev-title", val );
786 vlc_mutex_unlock( &p_playlist->object_lock );
787 vlc_object_release( p_playlist );
790 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
792 vlc_mutex_unlock( &p_playlist->object_lock );
794 playlist_Prev( p_playlist );
795 vlc_object_release( p_playlist );
798 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
800 playlist_t * p_playlist =
801 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
803 if( p_playlist == NULL )
808 vlc_mutex_lock( &p_playlist->object_lock );
809 if( p_playlist->p_input != NULL )
811 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
812 if( p_playlist->p_input->stream.i_area_nb > 1 &&
813 p_playlist->p_input->stream.p_selected_area->i_id <
814 p_playlist->p_input->stream.i_area_nb - 1 )
816 vlc_value_t val; val.b_bool = VLC_TRUE;
817 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
818 var_Set( p_playlist->p_input, "next-title", val );
819 vlc_mutex_unlock( &p_playlist->object_lock );
820 vlc_object_release( p_playlist );
823 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
825 vlc_mutex_unlock( &p_playlist->object_lock );
827 playlist_Next( p_playlist );
828 vlc_object_release( p_playlist );
831 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
833 input_thread_t *p_input =
834 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
838 input_SetStatus( p_input, INPUT_STATUS_SLOWER );
839 vlc_object_release( p_input );
843 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
845 input_thread_t *p_input =
846 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
850 input_SetStatus( p_input, INPUT_STATUS_FASTER );
851 vlc_object_release( p_input );
855 void Interface::TogglePlayButton( int i_playing_status )
857 if( i_playing_status == i_old_playing_status )
860 GetToolBar()->DeleteTool( PlayStream_Event );
862 if( i_playing_status == PLAYING_S )
864 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")),
865 wxBitmap( pause_xpm ), wxNullBitmap,
866 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
870 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")),
871 wxBitmap( play_xpm ), wxNullBitmap,
872 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
875 GetToolBar()->Realize();
877 i_old_playing_status = i_playing_status;
880 #if !defined(__WXX11__)
881 /*****************************************************************************
882 * Definition of DragAndDrop class.
883 *****************************************************************************/
884 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
889 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
890 const wxArrayString& filenames )
892 /* Add dropped files to the playlist */
894 playlist_t *p_playlist =
895 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
897 if( p_playlist == NULL )
902 for( size_t i = 0; i < filenames.GetCount(); i++ )
903 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(), 0, 0,
904 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
906 vlc_object_release( p_playlist );
912 /*****************************************************************************
913 * Definition of wxVolCtrl class.
914 *****************************************************************************/
915 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
916 : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
917 wxGA_VERTICAL | wxGA_SMOOTH )
922 void wxVolCtrl::OnChange( wxMouseEvent& event )
924 if( !event.LeftDown() && !event.LeftIsDown() ) return;
926 int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
927 GetClientSize().GetHeight();
931 void wxVolCtrl::Change( int i_volume )
933 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
934 SetValue( i_volume );
935 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),