1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001, 2003 VideoLAN
5 * $Id: interface.cpp,v 1.78 2003/12/14 15:42:19 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 *****************************************************************************/
31 #include "stream_control.h"
33 #include "wxwindows.h"
35 /* include the toolbar graphics */
36 #include "bitmaps/file.xpm"
38 #include "bitmaps/disc.xpm"
39 #include "bitmaps/net.xpm"
41 #include "bitmaps/sat.xpm"
43 #include "bitmaps/play.xpm"
44 #include "bitmaps/pause.xpm"
45 #include "bitmaps/stop.xpm"
46 #include "bitmaps/previous.xpm"
47 #include "bitmaps/next.xpm"
48 #include "bitmaps/playlist.xpm"
49 #include "bitmaps/fast.xpm"
50 #include "bitmaps/slow.xpm"
52 #include <wx/listctrl.h>
54 #define TOOLBAR_BMP_WIDTH 36
55 #define TOOLBAR_BMP_HEIGHT 36
57 /* include the icon graphic */
58 #include "../../../share/vlc32x32.xpm"
60 /*****************************************************************************
61 * Local class declarations.
62 *****************************************************************************/
63 class wxMenuExt: public wxMenu
67 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
68 const wxString& helpString, wxItemKind kind,
69 char *_psz_var, int _i_object_id, vlc_value_t _val,
72 virtual ~wxMenuExt() {};
83 class wxVolCtrl: public wxGauge
87 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
88 virtual ~wxVolCtrl() {};
90 void Change( int i_volume );
92 void OnChange( wxMouseEvent& event );
95 intf_thread_t *p_intf;
97 DECLARE_EVENT_TABLE();
100 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
102 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
103 EVT_MOTION(wxVolCtrl::OnChange)
106 /*****************************************************************************
108 *****************************************************************************/
110 /* IDs for the controls and the menu commands */
114 MenuDummy_Event = wxID_HIGHEST + 1000,
115 Exit_Event = wxID_HIGHEST,
116 OpenFileSimple_Event,
152 /* it is important for the id corresponding to the "About" command to have
153 * this standard value as otherwise it won't be handled properly under Mac
154 * (where it is special and put into the "Apple" menu) */
155 About_Event = wxID_ABOUT
158 BEGIN_EVENT_TABLE(Interface, wxFrame)
160 EVT_MENU(Exit_Event, Interface::OnExit)
161 EVT_MENU(About_Event, Interface::OnAbout)
163 EVT_MENU(Playlist_Event, Interface::OnShowDialog)
164 EVT_MENU(Logs_Event, Interface::OnShowDialog)
165 EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
166 EVT_MENU(Prefs_Event, Interface::OnShowDialog)
168 EVT_MENU_OPEN(Interface::OnMenuOpen)
170 EVT_MENU( Extra_Event, Interface::OnExtra)
171 EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
173 EVT_COMBOBOX( Ratio_Event, Interface::OnRatio)
174 EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
176 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
177 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
179 EVT_RIGHT_UP(Interface::OnContextMenu)
182 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
183 EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
184 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
185 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
186 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
187 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
188 EVT_MENU(Stream_Event, Interface::OnStream)
189 EVT_MENU(StopStream_Event, Interface::OnStopStream)
190 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
191 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
192 EVT_MENU(NextStream_Event, Interface::OnNextStream)
193 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
194 EVT_MENU(FastStream_Event, Interface::OnFastStream)
197 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
199 EVT_COMMAND_SCROLL(Hue_Event, Interface::OnHueUpdate)
200 EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
201 EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
202 EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
206 /*****************************************************************************
208 *****************************************************************************/
209 Interface::Interface( intf_thread_t *_p_intf ):
210 wxFrame( NULL, -1, wxT("VLC media player"),
211 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
213 /* Initializations */
215 i_old_playing_status = PAUSE_S;
218 /* Give our interface a nice little icon */
219 SetIcon( wxIcon( vlc_xpm ) );
221 /* Create a sizer for the main frame */
222 frame_sizer = new wxBoxSizer( wxVERTICAL );
223 SetSizer( frame_sizer );
225 /* Create a dummy widget that can get the keyboard focus */
226 wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
229 frame_sizer->Add( p_dummy, 0, wxEXPAND );
231 /* Creation of the menu bar */
234 /* Creation of the tool bar */
237 /* Creation of the slider sub-window */
239 frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
240 frame_sizer->Hide( slider_frame );
242 /* Create the extra panel */
243 CreateOurExtraPanel();
244 frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
245 frame_sizer->Hide( extra_frame );
247 /* Creation of the status bar
248 * Helptext for menu items and toolbar tools will automatically get
250 int i_status_width[3] = {-6, -2, -9};
251 statusbar = CreateStatusBar( 3 ); /* 2 fields */
252 statusbar->SetStatusWidths( 3, i_status_width );
253 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
255 /* Make sure we've got the right background colour */
256 SetBackgroundColour( slider_frame->GetBackgroundColour() );
258 /* Layout everything */
259 frame_sizer->Layout();
260 frame_sizer->Fit(this);
262 #if !defined(__WXX11__)
263 /* Associate drop targets with the main interface */
264 SetDropTarget( new DragAndDrop( p_intf ) );
267 UpdateAcceleratorTable();
270 timer = new Timer( p_intf, this );
273 Interface::~Interface()
275 if( p_intf->p_sys->p_wxwindow )
277 delete p_intf->p_sys->p_wxwindow;
284 /*****************************************************************************
286 *****************************************************************************/
287 void Interface::CreateOurMenuBar()
289 #define HELP_SIMPLE N_("Quick file open")
290 #define HELP_ADV N_("Advanced open")
291 #define HELP_FILE N_("Open a file")
292 #define HELP_DISC N_("Open Disc Media")
293 #define HELP_NET N_("Open a network stream")
294 #define HELP_SAT N_("Open a satellite stream")
295 #define HELP_EJECT N_("Eject the DVD/CD")
296 #define HELP_EXIT N_("Exit this program")
298 #define HELP_STREAMWIZARD N_("Open the streaming wizard")
299 #define HELP_OTHER N_("Open other types of inputs")
301 #define HELP_PLAYLIST N_("Open the playlist")
302 #define HELP_LOGS N_("Show the program logs")
303 #define HELP_FILEINFO N_("Show information about the file being played")
305 #define HELP_PREFS N_("Go to the preferences menu")
306 #define EXTRA_PREFS N_("Shows the extended GUI")
308 #define HELP_ABOUT N_("About this program")
310 /* Create the "File" menu */
311 wxMenu *file_menu = new wxMenu;
312 file_menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open ...")),
313 wxU(_(HELP_SIMPLE)) );
315 file_menu->AppendSeparator();
316 file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
318 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
320 file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
324 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
327 file_menu->AppendSeparator();
328 file_menu->Append( Stream_Event, wxU(_("Streaming Wizard...")),
329 wxU(_(HELP_STREAMWIZARD)) );
330 file_menu->AppendSeparator();
331 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
333 /* Create the "View" menu */
334 wxMenu *view_menu = new wxMenu;
335 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
336 wxU(_(HELP_PLAYLIST)) );
337 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
338 view_menu->Append( FileInfo_Event, wxU(_("&Stream and Media info...")),
339 wxU(_(HELP_FILEINFO)) );
341 /* Create the "Settings" menu */
342 p_settings_menu = new wxMenu;
345 /* Create the "Audio" menu */
346 p_audio_menu = new wxMenu;
349 /* Create the "Video" menu */
350 p_video_menu = new wxMenu;
353 /* Create the "Navigation" menu */
354 p_navig_menu = new wxMenu;
357 /* Create the "Help" menu */
358 wxMenu *help_menu = new wxMenu;
359 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
361 /* Append the freshly created menus to the menu bar... */
362 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
363 menubar->Append( file_menu, wxU(_("&File")) );
364 menubar->Append( view_menu, wxU(_("&View")) );
365 menubar->Append( p_settings_menu, wxU(_("&Settings")) );
366 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
367 menubar->Append( p_video_menu, wxU(_("&Video")) );
368 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
369 menubar->Append( help_menu, wxU(_("&Help")) );
371 /* Attach the menu bar to the frame */
372 SetMenuBar( menubar );
374 /* Intercept all menu events in our custom event handler */
375 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
377 #if !defined(__WXX11__)
378 /* Associate drop targets with the menubar */
379 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
383 void Interface::CreateOurToolBar()
385 #define HELP_STOP N_("Stop current playlist item")
387 #define HELP_PLAY N_("Play current playlist item")
388 #define HELP_PAUSE N_("Pause current playlist item")
389 #define HELP_PLO N_("Open playlist")
390 #define HELP_PLP N_("Previous playlist item")
391 #define HELP_PLN N_("Next playlist item")
392 #define HELP_SLOW N_("Play slower")
393 #define HELP_FAST N_("Play faster")
395 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
396 * version because we don't include wx.rc */
399 CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
401 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
403 toolbar->AddTool( OpenFileSimple_Event, wxU(_("Quick")),
404 wxBitmap( file_xpm ), wxU(_(HELP_SIMPLE)) );
406 toolbar->AddSeparator();
407 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
409 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
411 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
413 toolbar->AddSeparator();
415 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
417 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
420 toolbar->AddSeparator();
421 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
422 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
423 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
424 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
425 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
427 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
429 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
434 /* Place the toolbar in a sizer, so we can calculate the width of the
435 * toolbar and set this as the minimum for the main frame size. */
436 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
437 toolbar_sizer->Add( toolbar, 1, 0, 0 );
438 toolbar_sizer->Layout();
441 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
443 frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() * 11 +
444 toolbar->GetToolSeparation() * 3 +
445 (toolbar->GetMargins().GetWidth() + 2) *
446 toolbar->GetToolsCount(), -1 );
449 #if !defined(__WXX11__)
450 /* Associate drop targets with the toolbar */
451 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
455 void Interface::CreateOurSlider()
457 /* Create a new frame and sizer containing the slider */
458 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
459 slider_frame->SetAutoLayout( TRUE );
460 wxBoxSizer *frame_sizer =
461 new wxBoxSizer( wxHORIZONTAL );
463 /* Create static box to surround the slider */
464 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
466 /* Create sizer for slider frame */
467 wxStaticBoxSizer *slider_sizer =
468 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
469 slider_sizer->SetMinSize( -1, 50 );
472 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
473 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
474 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
477 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
479 /* Add everything to the frame */
480 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
481 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
482 slider_frame->SetSizer( frame_sizer );
483 frame_sizer->Layout();
484 frame_sizer->SetSizeHints(slider_frame);
486 /* Hide the slider by default */
487 slider_frame->Hide();
491 void Interface::CreateOurExtraPanel()
495 extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
496 extra_frame->SetAutoLayout( TRUE );
497 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
499 /* Create static box to surround the adjust controls */
500 wxStaticBox *adjust_box =
501 new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) );
503 /* Create the size for the frame */
504 wxStaticBoxSizer *adjust_sizer =
505 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
506 adjust_sizer->SetMinSize( -1, 50 );
508 /* Create every controls */
510 /* Create the adjust button */
511 wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
515 wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
516 wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
518 hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
519 360, wxDefaultPosition, wxDefaultSize );
521 hue_sizer->Add(hue_text,1, 0 ,0);
522 hue_sizer->Add(hue_slider,1, 0 ,0);
525 wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
526 wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
527 wxU(_("Contrast")) );
528 contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
529 200, wxDefaultPosition, wxDefaultSize);
530 contrast_sizer->Add(contrast_text,1, 0 ,0);
531 contrast_sizer->Add(contrast_slider,1, 0 ,0);
532 contrast_sizer->Layout();
534 wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
535 wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
536 wxU(_("Brightness")) );
537 brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
538 200, wxDefaultPosition, wxDefaultSize) ;
539 brightness_sizer->Add(brightness_text,1,0,0);
540 brightness_sizer->Add(brightness_slider,1,0,0);
541 brightness_sizer->Layout();
543 wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
544 wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
545 wxU(_("Saturation")) );
546 saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
547 300, wxDefaultPosition, wxDefaultSize );
548 saturation_sizer->Add(saturation_text,1,0,0);
549 saturation_sizer->Add(saturation_slider,1,0,0);
550 saturation_sizer->Layout();
552 adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
553 adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
554 adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
555 adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
556 adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
558 extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
561 /* Create sizer to surround the other controls */
562 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
565 wxStaticBox *video_box =
566 new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
567 /* Create the sizer for the frame */
568 wxStaticBoxSizer *video_sizer =
569 new wxStaticBoxSizer( video_box, wxVERTICAL );
570 video_sizer->SetMinSize( -1, 50 );
572 static const wxString ratio_array[] =
578 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
579 wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
582 ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
583 wxDefaultPosition, wxSize(120,-1),
584 WXSIZEOF(ratio_array), ratio_array,
587 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
588 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
589 ratio_sizer->Layout();
591 video_sizer->Add( ratio_sizer , 0 , wxALL , 0 );
592 video_sizer->Layout();
594 wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
596 wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
597 wxU(_("Visualisation")) );
599 visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
600 visual_sizer->Layout();
602 wxStaticBox *audio_box =
603 new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
604 /* Create the sizer for the frame */
605 wxStaticBoxSizer *audio_sizer =
606 new wxStaticBoxSizer( audio_box, wxVERTICAL );
607 audio_sizer->SetMinSize( -1, 50 );
609 audio_sizer->Add( visual_sizer, 0, wxALL, 0);
610 audio_sizer->Layout();
612 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
613 other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
614 other_sizer->Layout();
616 extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
618 extra_frame->SetSizer( extra_sizer );
620 /* Layout the whole panel */
621 extra_sizer->Layout();
623 extra_sizer->SetSizeHints(extra_frame);
625 /* Write down initial values */
626 psz_filters = config_GetPsz( p_intf, "audio-filter" );
627 if( psz_filters && strstr( psz_filters, "visual" ) )
629 visual_checkbox->SetValue(1);
631 if( psz_filters ) free( psz_filters );
633 psz_filters = config_GetPsz( p_intf, "filter" );
634 if( psz_filters && strstr( psz_filters, "adjust" ) )
636 adjust_check->SetValue( 1 );
637 saturation_slider->Enable();
638 contrast_slider->Enable();
639 brightness_slider->Enable();
640 hue_slider->Enable();
644 adjust_check->SetValue( 0 );
645 saturation_slider->Disable();
646 contrast_slider->Disable();
647 brightness_slider->Disable();
648 hue_slider->Disable();
650 if( psz_filters ) free( psz_filters );
652 int i_value = config_GetInt( p_intf, "hue" );
653 if( i_value > 0 && i_value < 360 )
654 hue_slider->SetValue( i_value );
657 f_value = config_GetFloat( p_intf, "saturation" );
658 if( f_value > 0 && f_value < 5 )
659 saturation_slider->SetValue( (int)(100 * f_value) );
660 f_value = config_GetFloat( p_intf, "contrast" );
661 if( f_value > 0 && f_value < 4 )
662 contrast_slider->SetValue( (int)(100 * f_value) );
663 f_value = config_GetFloat( p_intf, "brightness" );
664 if( f_value > 0 && f_value < 2 )
665 brightness_slider->SetValue( (int)(100 * f_value) );
670 void Interface::UpdateAcceleratorTable()
672 /* Set some hotkeys */
673 wxAcceleratorEntry entries[7];
677 var_Get( p_intf->p_vlc, "key-quit", &val );
678 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
679 ConvertHotkey( val.i_int ), Exit_Event );
680 var_Get( p_intf->p_vlc, "key-stop", &val );
681 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
682 ConvertHotkey( val.i_int ), StopStream_Event );
683 var_Get( p_intf->p_vlc, "key-play-pause", &val );
684 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
685 ConvertHotkey( val.i_int ), PlayStream_Event );
686 var_Get( p_intf->p_vlc, "key-next", &val );
687 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
688 ConvertHotkey( val.i_int ), NextStream_Event );
689 var_Get( p_intf->p_vlc, "key-prev", &val );
690 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
691 ConvertHotkey( val.i_int ), PrevStream_Event );
692 var_Get( p_intf->p_vlc, "key-faster", &val );
693 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
694 ConvertHotkey( val.i_int ), FastStream_Event );
695 var_Get( p_intf->p_vlc, "key-slower", &val );
696 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
697 ConvertHotkey( val.i_int ), SlowStream_Event );
699 wxAcceleratorTable accel( 7, entries );
702 msg_Err( p_intf, "invalid accelerator table" );
704 SetAcceleratorTable( accel );
705 msg_Dbg( p_intf, "accelerator table loaded" );
709 /*****************************************************************************
711 *****************************************************************************/
712 /* Work-around helper for buggy wxGTK */
713 void RecursiveDestroy( wxMenu *menu )
715 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
718 wxMenuItem *item = node->GetData();
719 node = node->GetNext();
721 /* Delete the submenus */
722 wxMenu *submenu = item->GetSubMenu();
725 RecursiveDestroy( submenu );
727 menu->Delete( item );
731 void Interface::OnMenuOpen(wxMenuEvent& event)
733 #if !defined( __WXMSW__ )
734 if( event.GetEventObject() == p_settings_menu )
736 if( b_settings_menu )
738 p_settings_menu = SettingsMenu( p_intf, this );
740 /* Add static items */
741 p_settings_menu->AppendCheckItem( Extra_Event,
742 wxU(_("&Extended GUI") ), wxU(_(EXTRA_PREFS)) );
743 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
744 wxU(_(HELP_PREFS)) );
746 /* Work-around for buggy wxGTK */
747 wxMenu *menu = GetMenuBar()->GetMenu( 2 );
748 RecursiveDestroy( menu );
749 /* End work-around */
751 menu = GetMenuBar()->Replace( 2, p_settings_menu,
752 wxU(_("&Settings")));
753 if( menu ) delete menu;
757 else b_settings_menu = 1;
759 else if( event.GetEventObject() == p_audio_menu )
763 p_audio_menu = AudioMenu( p_intf, this );
765 /* Work-around for buggy wxGTK */
766 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
767 RecursiveDestroy( menu );
768 /* End work-around */
771 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
772 if( menu ) delete menu;
776 else b_audio_menu = 1;
778 else if( event.GetEventObject() == p_video_menu )
782 p_video_menu = VideoMenu( p_intf, this );
784 /* Work-around for buggy wxGTK */
785 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
786 RecursiveDestroy( menu );
787 /* End work-around */
790 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
791 if( menu ) delete menu;
795 else b_video_menu = 1;
797 else if( event.GetEventObject() == p_navig_menu )
801 p_navig_menu = NavigMenu( p_intf, this );
803 /* Work-around for buggy wxGTK */
804 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
805 RecursiveDestroy( menu );
806 /* End work-around */
809 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
810 if( menu ) delete menu;
814 else b_navig_menu = 1;
818 p_settings_menu = SettingsMenu( p_intf, this );
819 /* Add static items */
820 p_settings_menu->AppendCheckItem( Extra_Event, wxU(_("&Extended GUI") ),
821 wxU(_(EXTRA_PREFS)) );
822 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
823 wxU(_(HELP_PREFS)) );
825 GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
826 if( menu ) delete menu;
828 p_audio_menu = AudioMenu( p_intf, this );
829 menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
830 if( menu ) delete menu;
832 p_video_menu = VideoMenu( p_intf, this );
833 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
834 if( menu ) delete menu;
836 p_navig_menu = NavigMenu( p_intf, this );
837 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
838 if( menu ) delete menu;
843 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
844 void Interface::OnContextMenu2(wxContextMenuEvent& event)
846 /* Only show the context menu for the main interface */
847 if( GetId() != event.GetId() )
853 if( p_intf->p_sys->pf_show_dialog )
854 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
857 void Interface::OnContextMenu(wxMouseEvent& event)
859 if( p_intf->p_sys->pf_show_dialog )
860 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
863 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
865 /* TRUE is to force the frame to close. */
869 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
872 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
873 wxU(_(" (wxWindows interface)\n\n")) +
874 wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
875 wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
876 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
877 "http://www.videolan.org/\n\n")) );
879 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
880 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
883 void Interface::OnShowDialog( wxCommandEvent& event )
885 if( p_intf->p_sys->pf_show_dialog )
889 switch( event.GetId() )
891 case OpenFileSimple_Event:
892 i_id = INTF_DIALOG_FILE_SIMPLE;
895 i_id = INTF_DIALOG_FILE;
897 i_id = INTF_DIALOG_FILE;
900 i_id = INTF_DIALOG_DISC;
903 i_id = INTF_DIALOG_NET;
906 i_id = INTF_DIALOG_SAT;
909 i_id = INTF_DIALOG_PLAYLIST;
912 i_id = INTF_DIALOG_MESSAGES;
915 i_id = INTF_DIALOG_FILEINFO;
918 i_id = INTF_DIALOG_PREFS;
921 i_id = INTF_DIALOG_FILE;
926 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
931 void Interface::OnStream( wxCommandEvent& event )
933 StreamDialog *p_stream_dialog = new StreamDialog(p_intf,this);
934 p_stream_dialog->Show();
938 void Interface::OnExtra(wxCommandEvent& event)
940 if( b_extra == VLC_FALSE)
943 frame_sizer->Show( extra_frame );
949 frame_sizer->Hide( extra_frame );
952 frame_sizer->Layout();
953 frame_sizer->Fit(this);
956 void Interface::OnEnableAdjust(wxCommandEvent& event)
958 char *psz_filters=config_GetPsz( p_intf, "filter");
959 char *psz_new = NULL;
960 if( event.IsChecked() )
962 if(psz_filters == NULL)
964 psz_new = strdup( "adjust" );
968 psz_new= (char *) malloc(strlen(psz_filters) + 8 );
969 sprintf( psz_new, "%s:adjust", psz_filters);
971 config_PutPsz( p_intf, "filter", psz_new );
973 vout_thread_t *p_vout =
974 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
978 val.psz_string = strdup( psz_new );
979 var_Set( p_vout, "filter", val);
980 vlc_object_release( p_vout );
982 if( val.psz_string ) free( val.psz_string );
983 brightness_slider->Enable();
984 saturation_slider->Enable();
985 contrast_slider->Enable();
986 hue_slider->Enable();
990 if( psz_filters != NULL )
995 for( i = 0; i< strlen(psz_filters ); i++)
997 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1000 if( psz_filters[i-1] == ':' ) i--;
1001 psz_current = strchr( &psz_filters[i+1] , ':' );
1003 psz_filters[i] = '\0';
1006 memmove( &psz_filters[i] , psz_current,
1007 &psz_filters[strlen(psz_filters)]-psz_current
1012 config_PutPsz( p_intf, "filter", psz_filters);
1014 val.psz_string = strdup( psz_filters );
1015 vout_thread_t *p_vout =
1016 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1018 if( p_vout != NULL )
1020 var_Set( p_vout, "filter", val);
1021 vlc_object_release( p_vout );
1023 if( val.psz_string ) free( val.psz_string );
1025 brightness_slider->Disable();
1026 saturation_slider->Disable();
1027 contrast_slider->Disable();
1028 hue_slider->Disable();
1030 if(psz_filters) free(psz_filters);
1031 if(psz_new) free(psz_new);
1034 void Interface::OnHueUpdate( wxScrollEvent& event)
1036 config_PutInt( p_intf , "hue" , event.GetPosition() );
1039 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1041 config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1044 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1046 config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1049 void Interface::OnContrastUpdate(wxScrollEvent& event)
1051 config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1055 void Interface::OnRatio( wxCommandEvent& event )
1057 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1060 void Interface::OnEnableVisual(wxCommandEvent& event)
1062 if( event.IsChecked() )
1064 config_PutPsz( p_intf, "audio-filter", "visual" );
1068 config_PutPsz( p_intf, "audio-filter", "" );
1072 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1074 wxCommandEvent dummy;
1075 playlist_t *p_playlist =
1076 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1078 if( p_playlist == NULL ) return;
1080 if( p_playlist->i_size && p_playlist->i_enabled )
1084 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1087 if( p_input == NULL )
1089 /* No stream was playing, start one */
1090 playlist_Play( p_playlist );
1091 TogglePlayButton( PLAYING_S );
1092 vlc_object_release( p_playlist );
1096 var_Get( p_input, "state", &state );
1098 if( state.i_int != PAUSE_S )
1100 /* A stream is being played, pause it */
1101 state.i_int = PAUSE_S;
1105 /* Stream is paused, resume it */
1106 state.i_int = PLAYING_S;
1108 var_Set( p_input, "state", state );
1110 TogglePlayButton( state.i_int );
1111 vlc_object_release( p_input );
1112 vlc_object_release( p_playlist );
1116 /* If the playlist is empty, open a file requester instead */
1117 vlc_object_release( p_playlist );
1118 OnShowDialog( dummy );
1122 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1124 playlist_t * p_playlist =
1125 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1127 if( p_playlist == NULL )
1132 playlist_Stop( p_playlist );
1133 TogglePlayButton( PAUSE_S );
1134 vlc_object_release( p_playlist );
1137 void Interface::OnSliderUpdate( wxScrollEvent& event )
1139 vlc_mutex_lock( &p_intf->change_lock );
1142 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1143 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1146 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1147 && p_intf->p_sys->p_input )
1150 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1152 var_Set( p_intf->p_sys->p_input, "position", pos );
1156 p_intf->p_sys->b_slider_free = VLC_TRUE;
1160 p_intf->p_sys->b_slider_free = VLC_FALSE;
1162 if( p_intf->p_sys->p_input )
1164 /* Update stream date */
1165 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1166 char psz_time[ MSTRTIME_MAX_SIZE ];
1168 slider_box->SetLabel(
1169 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1171 p_area->i_size * event.GetPosition()
1172 / SLIDER_MAX_POS )) );
1178 vlc_mutex_unlock( &p_intf->change_lock );
1181 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1183 playlist_t * p_playlist =
1184 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1186 if( p_playlist == NULL )
1191 vlc_mutex_lock( &p_playlist->object_lock );
1192 if( p_playlist->p_input != NULL )
1194 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1195 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1197 vlc_value_t val; val.b_bool = VLC_TRUE;
1198 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1199 var_Set( p_playlist->p_input, "prev-title", val );
1201 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1203 vlc_mutex_unlock( &p_playlist->object_lock );
1205 playlist_Prev( p_playlist );
1206 vlc_object_release( p_playlist );
1209 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1211 playlist_t * p_playlist =
1212 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1214 if( p_playlist == NULL )
1219 vlc_mutex_lock( &p_playlist->object_lock );
1220 if( p_playlist->p_input != NULL )
1222 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1223 if( p_playlist->p_input->stream.i_area_nb > 1 &&
1224 p_playlist->p_input->stream.p_selected_area->i_id <
1225 p_playlist->p_input->stream.i_area_nb - 1 )
1227 vlc_value_t val; val.b_bool = VLC_TRUE;
1228 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1229 var_Set( p_playlist->p_input, "next-title", val );
1231 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1233 vlc_mutex_unlock( &p_playlist->object_lock );
1235 playlist_Next( p_playlist );
1236 vlc_object_release( p_playlist );
1239 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1241 input_thread_t *p_input =
1242 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1246 vlc_value_t val; val.b_bool = VLC_TRUE;
1248 var_Set( p_input, "rate-slower", val );
1249 vlc_object_release( p_input );
1253 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1255 input_thread_t *p_input =
1256 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1260 vlc_value_t val; val.b_bool = VLC_TRUE;
1262 var_Set( p_input, "rate-faster", val );
1263 vlc_object_release( p_input );
1267 void Interface::TogglePlayButton( int i_playing_status )
1269 if( i_playing_status == i_old_playing_status )
1272 GetToolBar()->DeleteTool( PlayStream_Event );
1274 if( i_playing_status == PLAYING_S )
1276 GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")),
1277 wxBitmap( pause_xpm ), wxNullBitmap,
1278 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1282 GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")),
1283 wxBitmap( play_xpm ), wxNullBitmap,
1284 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1287 GetToolBar()->Realize();
1289 i_old_playing_status = i_playing_status;
1292 #if !defined(__WXX11__)
1293 /*****************************************************************************
1294 * Definition of DragAndDrop class.
1295 *****************************************************************************/
1296 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1299 b_enqueue = _b_enqueue;
1302 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1303 const wxArrayString& filenames )
1305 /* Add dropped files to the playlist */
1307 playlist_t *p_playlist =
1308 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1310 if( p_playlist == NULL )
1315 for( size_t i = 0; i < filenames.GetCount(); i++ )
1316 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(), 0, 0,
1317 PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1320 vlc_object_release( p_playlist );
1326 /*****************************************************************************
1327 * Definition of wxVolCtrl class.
1328 *****************************************************************************/
1329 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
1330 : wxGauge( parent, id, 200, wxDefaultPosition, wxSize( 20, -1 ),
1331 wxGA_VERTICAL | wxGA_SMOOTH )
1336 void wxVolCtrl::OnChange( wxMouseEvent& event )
1338 if( !event.LeftDown() && !event.LeftIsDown() ) return;
1340 int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
1341 GetClientSize().GetHeight();
1345 void wxVolCtrl::Change( int i_volume )
1347 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1348 SetValue( i_volume );
1349 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),