1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 VideoLAN
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/play.xpm"
37 #include "bitmaps/pause.xpm"
38 #include "bitmaps/stop.xpm"
39 #include "bitmaps/prev.xpm"
40 #include "bitmaps/next.xpm"
41 #include "bitmaps/eject.xpm"
42 #include "bitmaps/slow.xpm"
43 #include "bitmaps/fast.xpm"
44 #include "bitmaps/speaker.xpm"
46 #define TOOLBAR_BMP_WIDTH 16
47 #define TOOLBAR_BMP_HEIGHT 16
49 /* include the icon graphic */
50 #include "../../../share/vlc32x32.xpm"
52 /*****************************************************************************
53 * Local class declarations.
54 *****************************************************************************/
55 class wxMenuExt: public wxMenu
59 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
60 const wxString& helpString, wxItemKind kind,
61 char *_psz_var, int _i_object_id, vlc_value_t _val,
64 virtual ~wxMenuExt() {};
75 class wxVolCtrl: public wxGauge
79 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
80 wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) );
81 virtual ~wxVolCtrl() {};
83 void Change( int i_volume );
85 void OnChange( wxMouseEvent& event );
88 intf_thread_t *p_intf;
90 DECLARE_EVENT_TABLE();
93 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
95 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
96 EVT_MOTION(wxVolCtrl::OnChange)
99 /*****************************************************************************
101 *****************************************************************************/
103 DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );
105 /* IDs for the controls and the menu commands */
109 MenuDummy_Event = wxID_HIGHEST + 1000,
110 Exit_Event = wxID_HIGHEST,
111 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 EVT_MENU( Extended_Event, Interface::OnExtended)
168 EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
170 EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
171 EVT_TEXT( Ratio_Event, Interface::OnRatio)
172 EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
174 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
175 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
177 EVT_RIGHT_UP(Interface::OnContextMenu)
180 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
181 EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
182 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
183 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
184 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
185 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
186 EVT_MENU(StreamWizard_Event, Interface::OnShowDialog)
187 EVT_MENU(StopStream_Event, Interface::OnStopStream)
188 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
189 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
190 EVT_MENU(NextStream_Event, Interface::OnNextStream)
191 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
192 EVT_MENU(FastStream_Event, Interface::OnFastStream)
195 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
197 EVT_COMMAND_SCROLL(Hue_Event, Interface::OnHueUpdate)
198 EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
199 EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
200 EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
201 EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
204 EVT_COMMAND(0, wxEVT_INTF, Interface::UpdateSizeEvent)
208 /*****************************************************************************
210 *****************************************************************************/
211 Interface::Interface( intf_thread_t *_p_intf ):
212 wxFrame( NULL, -1, wxT("VLC media player"),
213 wxDefaultPosition, wxSize(700,100), wxDEFAULT_FRAME_STYLE )
215 /* Initializations */
217 i_old_playing_status = PAUSE_S;
220 /* Give our interface a nice little icon */
221 SetIcon( wxIcon( vlc_xpm ) );
223 /* Create a sizer for the main frame */
224 frame_sizer = new wxBoxSizer( wxVERTICAL );
225 SetSizer( frame_sizer );
227 /* Create a dummy widget that can get the keyboard focus */
228 wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
231 frame_sizer->Add( p_dummy, 0, wxEXPAND );
233 /* Creation of the menu bar */
236 /* Creation of the tool bar */
239 /* Create the extra panel */
240 CreateOurExtendedPanel();
241 frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
242 frame_sizer->Hide( extra_frame );
244 /* Creation of the status bar
245 * Helptext for menu items and toolbar tools will automatically get
247 int i_status_width[3] = {-6, -2, -9};
248 statusbar = CreateStatusBar( 3 ); /* 2 fields */
249 statusbar->SetStatusWidths( 3, i_status_width );
250 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
253 if( config_GetInt( p_intf, "wxwin-embed" ) )
255 VideoWindow( p_intf, this );
256 frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
259 /* Creation of the slider sub-window */
261 frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
262 frame_sizer->Hide( slider_frame );
264 /* Make sure we've got the right background colour */
265 SetBackgroundColour( slider_frame->GetBackgroundColour() );
267 /* Layout everything */
268 frame_sizer->Layout();
269 frame_sizer->Fit(this);
271 #if !defined(__WXX11__)
272 /* Associate drop targets with the main interface */
273 SetDropTarget( new DragAndDrop( p_intf ) );
276 UpdateAcceleratorTable();
279 timer = new Timer( p_intf, this );
282 Interface::~Interface()
284 if( p_intf->p_sys->p_wxwindow )
286 delete p_intf->p_sys->p_wxwindow;
293 void Interface::UpdateSizeEvent( wxCommandEvent& event )
295 frame_sizer->Layout();
296 frame_sizer->Fit(this);
299 /*****************************************************************************
301 *****************************************************************************/
302 void Interface::CreateOurMenuBar()
304 #define HELP_SIMPLE N_("Quick file open")
305 #define HELP_ADV N_("Advanced open")
306 #define HELP_FILE N_("Open a file")
307 #define HELP_DISC N_("Open Disc Media")
308 #define HELP_NET N_("Open a network stream")
309 #define HELP_SAT N_("Open a satellite stream")
310 #define HELP_EJECT N_("Eject the DVD/CD")
311 #define HELP_EXIT N_("Exit this program")
313 #define HELP_STREAMWIZARD N_("Open the streaming wizard")
315 #define HELP_PLAYLIST N_("Open the playlist")
316 #define HELP_LOGS N_("Show the program logs")
317 #define HELP_FILEINFO N_("Show information about the file being played")
319 #define HELP_PREFS N_("Go to the preferences menu")
320 #define HELP_EXTENDED N_("Shows the extended GUI")
321 #define HELP_BOOKMARKS N_("Shows the bookmarks window")
323 #define HELP_ABOUT N_("About this program")
325 /* Create the "File" menu */
326 wxMenu *file_menu = new wxMenu;
327 file_menu->Append( OpenFileSimple_Event,
328 wxU(_("Quick &Open File...\tCtrl-O")),
329 wxU(_(HELP_SIMPLE)) );
331 file_menu->AppendSeparator();
332 file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")),
334 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")),
336 file_menu->Append( OpenNet_Event,
337 wxU(_("Open &Network Stream...\tCtrl-N")),
340 file_menu->AppendSeparator();
341 file_menu->Append( StreamWizard_Event,
342 wxU(_("Streaming &Wizard...\tCtrl-W")),
343 wxU(_(HELP_STREAMWIZARD)) );
344 file_menu->AppendSeparator();
345 file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")),
348 /* Create the "View" menu */
349 wxMenu *view_menu = new wxMenu;
350 view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")),
351 wxU(_(HELP_PLAYLIST)) );
352 view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")),
354 view_menu->Append( FileInfo_Event,
355 wxU(_("Stream and Media &info...\tCtrl-I")),
356 wxU(_(HELP_FILEINFO)) );
358 /* Create the "Settings" menu */
359 p_settings_menu = new wxMenu;
362 /* Create the "Audio" menu */
363 p_audio_menu = new wxMenu;
366 /* Create the "Video" menu */
367 p_video_menu = new wxMenu;
370 /* Create the "Navigation" menu */
371 p_navig_menu = new wxMenu;
374 /* Create the "Help" menu */
375 wxMenu *help_menu = new wxMenu;
376 help_menu->Append( About_Event, wxU(_("About VLC media player")),
377 wxU(_(HELP_ABOUT)) );
379 /* Append the freshly created menus to the menu bar... */
380 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
381 menubar->Append( file_menu, wxU(_("&File")) );
382 menubar->Append( view_menu, wxU(_("&View")) );
383 menubar->Append( p_settings_menu, wxU(_("&Settings")) );
384 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
385 menubar->Append( p_video_menu, wxU(_("&Video")) );
386 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
387 menubar->Append( help_menu, wxU(_("&Help")) );
389 /* Attach the menu bar to the frame */
390 SetMenuBar( menubar );
392 /* Intercept all menu events in our custom event handler */
393 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
395 #if !defined(__WXX11__)
396 /* Associate drop targets with the menubar */
397 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
401 class VLCVolCtrl : public wxControl
404 VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
405 virtual ~VLCVolCtrl() {};
407 virtual void OnPaint( wxPaintEvent &event );
410 DECLARE_EVENT_TABLE()
413 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
414 EVT_PAINT(VLCVolCtrl::OnPaint)
417 VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
418 wxGauge **pp_volctrl )
419 :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, 16 ), wxBORDER_NONE )
421 *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint(18,0),
425 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
427 wxPaintDC dc( this );
428 wxBitmap mPlayBitmap( speaker_xpm );
429 dc.DrawBitmap( mPlayBitmap, 1, 0, TRUE );
432 void Interface::CreateOurToolBar()
434 #define HELP_STOP N_("Stop")
436 #define HELP_PLAY N_("Play")
437 #define HELP_PAUSE N_("Pause")
438 #define HELP_PLO N_("Playlist")
439 #define HELP_PLP N_("Previous playlist item")
440 #define HELP_PLN N_("Next playlist item")
441 #define HELP_SLOW N_("Play slower")
442 #define HELP_FAST N_("Play faster")
444 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
445 * version because we don't include wx.rc */
448 CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
450 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
452 toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
455 toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
456 wxU(_(HELP_PAUSE)) );
458 toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
460 toolbar->AddSeparator();
461 toolbar->AddTool( PrevStream_Event, wxT(""),
462 wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
463 toolbar->AddTool( SlowStream_Event, wxT(""),
464 wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
465 toolbar->AddTool( FastStream_Event, wxT(""),
466 wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
467 toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
469 toolbar->AddSeparator();
470 toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( eject_xpm ),
473 wxControl *p_dummy_ctrl =
474 new wxControl( toolbar, -1, wxDefaultPosition,
475 wxSize(64, 16 ), wxBORDER_NONE );
477 toolbar->AddControl( p_dummy_ctrl );
479 VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
480 toolbar->AddControl( sound_control );
484 // '7' is the number of buttons on the toolbar, '3' is arbitrary :)
485 frame_sizer->SetMinSize( TOOLBAR_BMP_WIDTH * 7 * 3, -1 );
487 #if !defined(__WXX11__)
488 /* Associate drop targets with the toolbar */
489 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
493 void Interface::CreateOurSlider()
495 /* Create a new frame and sizer containing the slider */
496 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
497 slider_frame->SetAutoLayout( TRUE );
498 wxBoxSizer *frame_sizer =
499 new wxBoxSizer( wxHORIZONTAL );
501 /* Create static box to surround the slider */
502 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
504 /* Create sizer for slider frame */
505 wxStaticBoxSizer *slider_sizer =
506 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
507 slider_sizer->SetMinSize( -1, 50 );
510 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
511 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
512 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
514 /* Add everything to the frame */
515 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
516 slider_frame->SetSizer( frame_sizer );
517 frame_sizer->Layout();
518 frame_sizer->SetSizeHints(slider_frame);
520 /* Hide the slider by default */
521 slider_frame->Hide();
525 void Interface::CreateOurExtendedPanel()
529 extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
530 extra_frame->SetAutoLayout( TRUE );
531 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
533 /* Create static box to surround the adjust controls */
534 wxStaticBox *adjust_box =
535 new wxStaticBox( extra_frame, -1, wxU(_("Adjust Image")) );
537 /* Create the size for the frame */
538 wxStaticBoxSizer *adjust_sizer =
539 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
540 adjust_sizer->SetMinSize( -1, 50 );
542 /* Create every controls */
544 /* Create the adjust button */
545 wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
549 wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
550 wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
552 hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
553 360, wxDefaultPosition, wxDefaultSize );
555 hue_sizer->Add(hue_text,1, 0 ,0);
556 hue_sizer->Add(hue_slider,1, 0 ,0);
559 wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
560 wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
561 wxU(_("Contrast")) );
562 contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
563 200, wxDefaultPosition, wxDefaultSize);
564 contrast_sizer->Add(contrast_text,1, 0 ,0);
565 contrast_sizer->Add(contrast_slider,1, 0 ,0);
566 contrast_sizer->Layout();
568 wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
569 wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
570 wxU(_("Brightness")) );
571 brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
572 200, wxDefaultPosition, wxDefaultSize) ;
573 brightness_sizer->Add(brightness_text,1,0,0);
574 brightness_sizer->Add(brightness_slider,1,0,0);
575 brightness_sizer->Layout();
577 wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
578 wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
579 wxU(_("Saturation")) );
580 saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
581 300, wxDefaultPosition, wxDefaultSize );
582 saturation_sizer->Add(saturation_text,1,0,0);
583 saturation_sizer->Add(saturation_slider,1,0,0);
584 saturation_sizer->Layout();
586 wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
587 wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
589 gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
590 100, wxDefaultPosition, wxDefaultSize );
591 gamma_sizer->Add(gamma_text,1,0,0);
592 gamma_sizer->Add(gamma_slider,1,0,0);
593 gamma_sizer->Layout();
595 adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
596 adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
597 adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
598 adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
599 adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
600 adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
602 extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
604 /* Create sizer to surround the other controls */
605 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
608 wxStaticBox *video_box =
609 new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
610 /* Create the sizer for the frame */
611 wxStaticBoxSizer *video_sizer =
612 new wxStaticBoxSizer( video_box, wxVERTICAL );
613 video_sizer->SetMinSize( -1, 50 );
615 static const wxString ratio_array[] =
621 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
622 wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
623 wxU(_("Aspect Ratio")) );
625 ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
626 wxDefaultPosition, wxSize(120,-1),
627 WXSIZEOF(ratio_array), ratio_array,
630 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
631 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
632 ratio_sizer->Layout();
634 video_sizer->Add( ratio_sizer , 0 , wxALL , 0 );
635 video_sizer->Layout();
638 wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
640 wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
641 wxU(_("Visualisations")) );
643 visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
644 visual_sizer->Layout();
646 wxStaticBox *audio_box =
647 new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
648 /* Create the sizer for the frame */
649 wxStaticBoxSizer *audio_sizer =
650 new wxStaticBoxSizer( audio_box, wxVERTICAL );
651 audio_sizer->SetMinSize( -1, 50 );
653 audio_sizer->Add( visual_sizer, 0, wxALL, 0);
654 audio_sizer->Layout();
656 other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
658 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
659 other_sizer->Layout();
661 extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
663 extra_frame->SetSizer( extra_sizer );
665 /* Layout the whole panel */
666 extra_sizer->Layout();
668 extra_sizer->SetSizeHints(extra_frame);
670 /* Write down initial values */
672 psz_filters = config_GetPsz( p_intf, "audio-filter" );
673 if( psz_filters && strstr( psz_filters, "visual" ) )
675 visual_checkbox->SetValue(1);
677 if( psz_filters ) free( psz_filters );
679 psz_filters = config_GetPsz( p_intf, "filter" );
680 if( psz_filters && strstr( psz_filters, "adjust" ) )
682 adjust_check->SetValue( 1 );
683 saturation_slider->Enable();
684 contrast_slider->Enable();
685 brightness_slider->Enable();
686 hue_slider->Enable();
687 gamma_slider->Enable();
691 adjust_check->SetValue( 0 );
692 saturation_slider->Disable();
693 contrast_slider->Disable();
694 brightness_slider->Disable();
695 hue_slider->Disable();
696 gamma_slider->Disable();
698 if( psz_filters ) free( psz_filters );
700 int i_value = config_GetInt( p_intf, "hue" );
701 if( i_value > 0 && i_value < 360 )
702 hue_slider->SetValue( i_value );
705 f_value = config_GetFloat( p_intf, "saturation" );
706 if( f_value > 0 && f_value < 5 )
707 saturation_slider->SetValue( (int)(100 * f_value) );
708 f_value = config_GetFloat( p_intf, "contrast" );
709 if( f_value > 0 && f_value < 4 )
710 contrast_slider->SetValue( (int)(100 * f_value) );
711 f_value = config_GetFloat( p_intf, "brightness" );
712 if( f_value > 0 && f_value < 2 )
713 brightness_slider->SetValue( (int)(100 * f_value) );
714 f_value = config_GetFloat( p_intf, "gamma" );
715 if( f_value > 0 && f_value < 10 )
716 gamma_slider->SetValue( (int)(10 * f_value) );
721 void Interface::UpdateAcceleratorTable()
723 /* Set some hotkeys */
724 wxAcceleratorEntry entries[7];
728 var_Get( p_intf->p_vlc, "key-quit", &val );
729 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
730 ConvertHotkey( val.i_int ), Exit_Event );
731 var_Get( p_intf->p_vlc, "key-stop", &val );
732 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
733 ConvertHotkey( val.i_int ), StopStream_Event );
734 var_Get( p_intf->p_vlc, "key-play-pause", &val );
735 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
736 ConvertHotkey( val.i_int ), PlayStream_Event );
737 var_Get( p_intf->p_vlc, "key-next", &val );
738 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
739 ConvertHotkey( val.i_int ), NextStream_Event );
740 var_Get( p_intf->p_vlc, "key-prev", &val );
741 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
742 ConvertHotkey( val.i_int ), PrevStream_Event );
743 var_Get( p_intf->p_vlc, "key-faster", &val );
744 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
745 ConvertHotkey( val.i_int ), FastStream_Event );
746 var_Get( p_intf->p_vlc, "key-slower", &val );
747 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
748 ConvertHotkey( val.i_int ), SlowStream_Event );
750 wxAcceleratorTable accel( 7, entries );
753 msg_Err( p_intf, "invalid accelerator table" );
755 SetAcceleratorTable( accel );
756 msg_Dbg( p_intf, "accelerator table loaded" );
760 /*****************************************************************************
762 *****************************************************************************/
763 /* Work-around helper for buggy wxGTK */
764 void RecursiveDestroy( wxMenu *menu )
766 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
769 wxMenuItem *item = node->GetData();
770 node = node->GetNext();
772 /* Delete the submenus */
773 wxMenu *submenu = item->GetSubMenu();
776 RecursiveDestroy( submenu );
778 menu->Delete( item );
782 void Interface::OnMenuOpen(wxMenuEvent& event)
784 #if !defined( __WXMSW__ )
785 if( event.GetEventObject() == p_settings_menu )
787 if( b_settings_menu )
789 p_settings_menu = SettingsMenu( p_intf, this );
791 /* Add static items */
792 p_settings_menu->AppendCheckItem( Extended_Event,
793 wxU(_("&Extended GUI") ), wxU(_(HELP_EXTENDED)) );
794 p_settings_menu->AppendCheckItem( Bookmarks_Event,
795 wxU(_("&Bookmarks") ), wxU(_(HELP_BOOKMARKS)) );
796 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
797 wxU(_(HELP_PREFS)) );
799 /* Work-around for buggy wxGTK */
800 wxMenu *menu = GetMenuBar()->GetMenu( 2 );
801 RecursiveDestroy( menu );
802 /* End work-around */
804 menu = GetMenuBar()->Replace( 2, p_settings_menu,
805 wxU(_("&Settings")));
806 if( menu ) delete menu;
810 else b_settings_menu = 1;
812 else if( event.GetEventObject() == p_audio_menu )
816 p_audio_menu = AudioMenu( p_intf, this );
818 /* Work-around for buggy wxGTK */
819 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
820 RecursiveDestroy( menu );
821 /* End work-around */
824 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
825 if( menu ) delete menu;
829 else b_audio_menu = 1;
831 else if( event.GetEventObject() == p_video_menu )
835 p_video_menu = VideoMenu( p_intf, this );
837 /* Work-around for buggy wxGTK */
838 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
839 RecursiveDestroy( menu );
840 /* End work-around */
843 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
844 if( menu ) delete menu;
848 else b_video_menu = 1;
850 else if( event.GetEventObject() == p_navig_menu )
854 p_navig_menu = NavigMenu( p_intf, this );
856 /* Work-around for buggy wxGTK */
857 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
858 RecursiveDestroy( menu );
859 /* End work-around */
862 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
863 if( menu ) delete menu;
867 else b_navig_menu = 1;
871 p_settings_menu = SettingsMenu( p_intf, this );
872 /* Add static items */
873 p_settings_menu->AppendCheckItem( Extended_Event, wxU(_("&Extended GUI") ),
874 wxU(_(HELP_EXTENDED)) );
875 p_settings_menu->AppendCheckItem( Bookmarks_Event, wxU(_("&Bookmarks") ),
876 wxU(_(HELP_BOOKMARKS)) );
877 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
878 wxU(_(HELP_PREFS)) );
880 GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
881 if( menu ) delete menu;
883 p_audio_menu = AudioMenu( p_intf, this );
884 menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
885 if( menu ) delete menu;
887 p_video_menu = VideoMenu( p_intf, this );
888 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
889 if( menu ) delete menu;
891 p_navig_menu = NavigMenu( p_intf, this );
892 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
893 if( menu ) delete menu;
898 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
899 void Interface::OnContextMenu2(wxContextMenuEvent& event)
901 /* Only show the context menu for the main interface */
902 if( GetId() != event.GetId() )
908 if( p_intf->p_sys->pf_show_dialog )
909 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
912 void Interface::OnContextMenu(wxMouseEvent& event)
914 if( p_intf->p_sys->pf_show_dialog )
915 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
918 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
920 /* TRUE is to force the frame to close. */
924 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
927 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
928 wxU(_(" (wxWindows interface)\n\n")) +
929 wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
930 wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
931 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
932 "http://www.videolan.org/\n\n")) );
934 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
935 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
938 void Interface::OnShowDialog( wxCommandEvent& event )
940 if( p_intf->p_sys->pf_show_dialog )
944 switch( event.GetId() )
946 case OpenFileSimple_Event:
947 i_id = INTF_DIALOG_FILE_SIMPLE;
950 i_id = INTF_DIALOG_FILE;
952 i_id = INTF_DIALOG_FILE;
955 i_id = INTF_DIALOG_DISC;
958 i_id = INTF_DIALOG_NET;
961 i_id = INTF_DIALOG_SAT;
964 i_id = INTF_DIALOG_PLAYLIST;
967 i_id = INTF_DIALOG_MESSAGES;
970 i_id = INTF_DIALOG_FILEINFO;
973 i_id = INTF_DIALOG_PREFS;
975 case StreamWizard_Event:
976 i_id = INTF_DIALOG_STREAMWIZARD;
978 case Bookmarks_Event:
979 i_id = INTF_DIALOG_BOOKMARKS;
982 i_id = INTF_DIALOG_FILE;
986 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
990 void Interface::OnExtended(wxCommandEvent& event)
992 if( b_extra == VLC_FALSE)
995 frame_sizer->Show( extra_frame );
1000 extra_frame->Hide();
1001 frame_sizer->Hide( extra_frame );
1002 b_extra = VLC_FALSE;
1004 frame_sizer->Layout();
1005 frame_sizer->Fit(this);
1008 void Interface::OnEnableAdjust(wxCommandEvent& event)
1010 char *psz_filters=config_GetPsz( p_intf, "filter");
1011 char *psz_new = NULL;
1012 if( event.IsChecked() )
1014 if(psz_filters == NULL)
1016 psz_new = strdup( "adjust" );
1020 psz_new= (char *) malloc(strlen(psz_filters) + 8 );
1021 sprintf( psz_new, "%s:adjust", psz_filters);
1023 config_PutPsz( p_intf, "filter", psz_new );
1025 vout_thread_t *p_vout =
1026 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1028 if( p_vout != NULL )
1030 val.psz_string = strdup( psz_new );
1031 var_Set( p_vout, "filter", val);
1032 vlc_object_release( p_vout );
1034 if( val.psz_string ) free( val.psz_string );
1035 brightness_slider->Enable();
1036 saturation_slider->Enable();
1037 contrast_slider->Enable();
1038 hue_slider->Enable();
1039 gamma_slider->Enable();
1043 if( psz_filters != NULL )
1048 for( i = 0; i< strlen(psz_filters ); i++)
1050 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1053 if( psz_filters[i-1] == ':' ) i--;
1054 psz_current = strchr( &psz_filters[i+1] , ':' );
1056 psz_filters[i] = '\0';
1059 memmove( &psz_filters[i] , psz_current,
1060 &psz_filters[strlen(psz_filters)]-psz_current
1065 config_PutPsz( p_intf, "filter", psz_filters);
1067 val.psz_string = strdup( psz_filters );
1068 vout_thread_t *p_vout =
1069 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1071 if( p_vout != NULL )
1073 var_Set( p_vout, "filter", val);
1074 vlc_object_release( p_vout );
1076 if( val.psz_string ) free( val.psz_string );
1078 brightness_slider->Disable();
1079 saturation_slider->Disable();
1080 contrast_slider->Disable();
1081 hue_slider->Disable();
1082 gamma_slider->Disable();
1084 if(psz_filters) free(psz_filters);
1085 if(psz_new) free(psz_new);
1088 void Interface::OnHueUpdate( wxScrollEvent& event)
1090 config_PutInt( p_intf , "hue" , event.GetPosition() );
1093 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1095 config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1098 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1100 config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1103 void Interface::OnContrastUpdate(wxScrollEvent& event)
1105 config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1108 void Interface::OnGammaUpdate(wxScrollEvent& event)
1110 config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
1113 void Interface::OnRatio( wxCommandEvent& event )
1115 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1118 void Interface::OnEnableVisual(wxCommandEvent& event)
1120 if( event.IsChecked() )
1122 config_PutPsz( p_intf, "audio-filter", "visual" );
1126 config_PutPsz( p_intf, "audio-filter", "" );
1130 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1132 wxCommandEvent dummy;
1133 playlist_t *p_playlist =
1134 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1136 if( p_playlist == NULL ) return;
1138 if( p_playlist->i_size && p_playlist->i_enabled )
1142 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1145 if( p_input == NULL )
1147 /* No stream was playing, start one */
1148 playlist_Play( p_playlist );
1149 TogglePlayButton( PLAYING_S );
1150 vlc_object_release( p_playlist );
1154 var_Get( p_input, "state", &state );
1156 if( state.i_int != PAUSE_S )
1158 /* A stream is being played, pause it */
1159 state.i_int = PAUSE_S;
1163 /* Stream is paused, resume it */
1164 state.i_int = PLAYING_S;
1166 var_Set( p_input, "state", state );
1168 TogglePlayButton( state.i_int );
1169 vlc_object_release( p_input );
1170 vlc_object_release( p_playlist );
1174 /* If the playlist is empty, open a file requester instead */
1175 vlc_object_release( p_playlist );
1176 OnShowDialog( dummy );
1180 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1182 playlist_t * p_playlist =
1183 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1185 if( p_playlist == NULL )
1190 playlist_Stop( p_playlist );
1191 TogglePlayButton( PAUSE_S );
1192 vlc_object_release( p_playlist );
1195 void Interface::OnSliderUpdate( wxScrollEvent& event )
1197 vlc_mutex_lock( &p_intf->change_lock );
1200 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1201 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1204 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1205 && p_intf->p_sys->p_input )
1208 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1210 var_Set( p_intf->p_sys->p_input, "position", pos );
1214 p_intf->p_sys->b_slider_free = VLC_TRUE;
1218 p_intf->p_sys->b_slider_free = VLC_FALSE;
1220 if( p_intf->p_sys->p_input )
1222 /* Update stream date */
1223 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1224 char psz_time[ MSTRTIME_MAX_SIZE ];
1226 slider_box->SetLabel(
1227 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1229 p_area->i_size * event.GetPosition()
1230 / SLIDER_MAX_POS )) );
1237 vlc_mutex_unlock( &p_intf->change_lock );
1240 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1242 playlist_t * p_playlist =
1243 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1245 if( p_playlist == NULL )
1250 vlc_mutex_lock( &p_playlist->object_lock );
1251 if( p_playlist->p_input != NULL )
1253 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1254 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1256 vlc_value_t val; val.b_bool = VLC_TRUE;
1257 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1258 var_Set( p_playlist->p_input, "prev-title", val );
1260 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1262 vlc_mutex_unlock( &p_playlist->object_lock );
1264 playlist_Prev( p_playlist );
1265 vlc_object_release( p_playlist );
1268 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1270 playlist_t * p_playlist =
1271 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1273 if( p_playlist == NULL )
1278 vlc_mutex_lock( &p_playlist->object_lock );
1279 if( p_playlist->p_input != NULL )
1281 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1282 if( p_playlist->p_input->stream.i_area_nb > 1 &&
1283 p_playlist->p_input->stream.p_selected_area->i_id <
1284 p_playlist->p_input->stream.i_area_nb - 1 )
1286 vlc_value_t val; val.b_bool = VLC_TRUE;
1287 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1288 var_Set( p_playlist->p_input, "next-title", val );
1290 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1292 vlc_mutex_unlock( &p_playlist->object_lock );
1294 playlist_Next( p_playlist );
1295 vlc_object_release( p_playlist );
1298 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1300 input_thread_t *p_input =
1301 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1305 vlc_value_t val; val.b_bool = VLC_TRUE;
1307 var_Set( p_input, "rate-slower", val );
1308 vlc_object_release( p_input );
1312 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1314 input_thread_t *p_input =
1315 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1319 vlc_value_t val; val.b_bool = VLC_TRUE;
1321 var_Set( p_input, "rate-faster", val );
1322 vlc_object_release( p_input );
1326 void Interface::TogglePlayButton( int i_playing_status )
1328 if( i_playing_status == i_old_playing_status )
1331 GetToolBar()->DeleteTool( PlayStream_Event );
1333 if( i_playing_status == PLAYING_S )
1335 GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Pause")),
1336 wxBitmap( pause_xpm ), wxNullBitmap,
1337 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1341 GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Play")),
1342 wxBitmap( play_xpm ), wxNullBitmap,
1343 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1346 GetToolBar()->Realize();
1348 i_old_playing_status = i_playing_status;
1351 #if !defined(__WXX11__)
1352 /*****************************************************************************
1353 * Definition of DragAndDrop class.
1354 *****************************************************************************/
1355 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1358 b_enqueue = _b_enqueue;
1361 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1362 const wxArrayString& filenames )
1364 /* Add dropped files to the playlist */
1366 playlist_t *p_playlist =
1367 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1369 if( p_playlist == NULL )
1374 for( size_t i = 0; i < filenames.GetCount(); i++ )
1375 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
1376 (const char *)filenames[i].mb_str(),
1377 PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1380 vlc_object_release( p_playlist );
1386 /*****************************************************************************
1387 * Definition of wxVolCtrl class.
1388 *****************************************************************************/
1389 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1390 wxPoint point, wxSize size )
1391 : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
1395 audio_volume_t i_volume;
1396 aout_VolumeGet( p_intf, &i_volume );
1397 i_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
1398 SetValue( i_volume );
1399 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1403 void wxVolCtrl::OnChange( wxMouseEvent& event )
1405 if( !event.LeftDown() && !event.LeftIsDown() ) return;
1407 int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
1411 void wxVolCtrl::Change( int i_volume )
1413 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1414 SetValue( i_volume );
1415 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),