1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 VideoLAN
7 * Authors: Gildas Bazin <gbazin@videolan.org>
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 "Auto-generated" menus */
359 p_settings_menu = SettingsMenu( p_intf, this );
360 p_audio_menu = AudioMenu( p_intf, this );
361 p_video_menu = VideoMenu( p_intf, this );
362 p_navig_menu = NavigMenu( p_intf, this );
364 /* Create the "Help" menu */
365 wxMenu *help_menu = new wxMenu;
366 help_menu->Append( About_Event, wxU(_("About VLC media player")),
367 wxU(_(HELP_ABOUT)) );
369 /* Append the freshly created menus to the menu bar... */
370 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
371 menubar->Append( file_menu, wxU(_("&File")) );
372 menubar->Append( view_menu, wxU(_("&View")) );
373 menubar->Append( p_settings_menu, wxU(_("&Settings")) );
374 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
375 menubar->Append( p_video_menu, wxU(_("&Video")) );
376 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
377 menubar->Append( help_menu, wxU(_("&Help")) );
379 /* Attach the menu bar to the frame */
380 SetMenuBar( menubar );
382 /* Intercept all menu events in our custom event handler */
383 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
385 #if !defined(__WXX11__)
386 /* Associate drop targets with the menubar */
387 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
391 class VLCVolCtrl : public wxControl
394 VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
395 virtual ~VLCVolCtrl() {};
397 virtual void OnPaint( wxPaintEvent &event );
400 DECLARE_EVENT_TABLE()
403 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
404 EVT_PAINT(VLCVolCtrl::OnPaint)
407 VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
408 wxGauge **pp_volctrl )
409 :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, 16 ), wxBORDER_NONE )
411 *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint(18,0),
415 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
417 wxPaintDC dc( this );
418 wxBitmap mPlayBitmap( speaker_xpm );
419 dc.DrawBitmap( mPlayBitmap, 1, 0, TRUE );
422 void Interface::CreateOurToolBar()
424 #define HELP_STOP N_("Stop")
426 #define HELP_PLAY N_("Play")
427 #define HELP_PAUSE N_("Pause")
428 #define HELP_PLO N_("Playlist")
429 #define HELP_PLP N_("Previous playlist item")
430 #define HELP_PLN N_("Next playlist item")
431 #define HELP_SLOW N_("Play slower")
432 #define HELP_FAST N_("Play faster")
434 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
435 * version because we don't include wx.rc */
438 CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
440 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
442 toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
445 toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
446 wxU(_(HELP_PAUSE)) );
448 toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
450 toolbar->AddSeparator();
451 toolbar->AddTool( PrevStream_Event, wxT(""),
452 wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
453 toolbar->AddTool( SlowStream_Event, wxT(""),
454 wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
455 toolbar->AddTool( FastStream_Event, wxT(""),
456 wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
457 toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
459 toolbar->AddSeparator();
460 toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( eject_xpm ),
463 wxControl *p_dummy_ctrl =
464 new wxControl( toolbar, -1, wxDefaultPosition,
465 wxSize(64, 16 ), wxBORDER_NONE );
467 toolbar->AddControl( p_dummy_ctrl );
469 VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
470 toolbar->AddControl( sound_control );
474 // '7' is the number of buttons on the toolbar, '3' is arbitrary :)
475 frame_sizer->SetMinSize( TOOLBAR_BMP_WIDTH * 7 * 3, -1 );
477 #if !defined(__WXX11__)
478 /* Associate drop targets with the toolbar */
479 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
483 void Interface::CreateOurSlider()
485 /* Create a new frame and sizer containing the slider */
486 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
487 slider_frame->SetAutoLayout( TRUE );
488 wxBoxSizer *frame_sizer = new wxBoxSizer( wxHORIZONTAL );
489 //frame_sizer->SetMinSize( -1, 50 );
492 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
493 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
495 /* Add everything to the frame */
496 frame_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
497 slider_frame->SetSizer( frame_sizer );
498 frame_sizer->Layout();
499 frame_sizer->SetSizeHints(slider_frame);
501 /* Hide the slider by default */
502 slider_frame->Hide();
506 void Interface::CreateOurExtendedPanel()
510 extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
511 extra_frame->SetAutoLayout( TRUE );
512 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
514 /* Create static box to surround the adjust controls */
515 wxStaticBox *adjust_box =
516 new wxStaticBox( extra_frame, -1, wxU(_("Adjust Image")) );
518 /* Create the size for the frame */
519 wxStaticBoxSizer *adjust_sizer =
520 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
521 adjust_sizer->SetMinSize( -1, 50 );
523 /* Create every controls */
525 /* Create the adjust button */
526 wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
530 wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
531 wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
533 hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
534 360, wxDefaultPosition, wxDefaultSize );
536 hue_sizer->Add(hue_text,1, 0 ,0);
537 hue_sizer->Add(hue_slider,1, 0 ,0);
540 wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
541 wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
542 wxU(_("Contrast")) );
543 contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
544 200, wxDefaultPosition, wxDefaultSize);
545 contrast_sizer->Add(contrast_text,1, 0 ,0);
546 contrast_sizer->Add(contrast_slider,1, 0 ,0);
547 contrast_sizer->Layout();
549 wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
550 wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
551 wxU(_("Brightness")) );
552 brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
553 200, wxDefaultPosition, wxDefaultSize) ;
554 brightness_sizer->Add(brightness_text,1,0,0);
555 brightness_sizer->Add(brightness_slider,1,0,0);
556 brightness_sizer->Layout();
558 wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
559 wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
560 wxU(_("Saturation")) );
561 saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
562 300, wxDefaultPosition, wxDefaultSize );
563 saturation_sizer->Add(saturation_text,1,0,0);
564 saturation_sizer->Add(saturation_slider,1,0,0);
565 saturation_sizer->Layout();
567 wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
568 wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
570 gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
571 100, wxDefaultPosition, wxDefaultSize );
572 gamma_sizer->Add(gamma_text,1,0,0);
573 gamma_sizer->Add(gamma_slider,1,0,0);
574 gamma_sizer->Layout();
576 adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
577 adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
578 adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
579 adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
580 adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
581 adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
583 extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
585 /* Create sizer to surround the other controls */
586 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
589 wxStaticBox *video_box =
590 new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
591 /* Create the sizer for the frame */
592 wxStaticBoxSizer *video_sizer =
593 new wxStaticBoxSizer( video_box, wxVERTICAL );
594 video_sizer->SetMinSize( -1, 50 );
596 static const wxString ratio_array[] =
602 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
603 wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
604 wxU(_("Aspect Ratio")) );
606 ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
607 wxDefaultPosition, wxSize(120,-1),
608 WXSIZEOF(ratio_array), ratio_array,
611 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
612 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
613 ratio_sizer->Layout();
615 video_sizer->Add( ratio_sizer , 0 , wxALL , 0 );
616 video_sizer->Layout();
619 wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
621 wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
622 wxU(_("Visualisations")) );
624 visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
625 visual_sizer->Layout();
627 wxStaticBox *audio_box =
628 new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
629 /* Create the sizer for the frame */
630 wxStaticBoxSizer *audio_sizer =
631 new wxStaticBoxSizer( audio_box, wxVERTICAL );
632 audio_sizer->SetMinSize( -1, 50 );
634 audio_sizer->Add( visual_sizer, 0, wxALL, 0);
635 audio_sizer->Layout();
637 other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
639 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
640 other_sizer->Layout();
642 extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
644 extra_frame->SetSizer( extra_sizer );
646 /* Layout the whole panel */
647 extra_sizer->Layout();
649 extra_sizer->SetSizeHints(extra_frame);
651 /* Write down initial values */
653 psz_filters = config_GetPsz( p_intf, "audio-filter" );
654 if( psz_filters && strstr( psz_filters, "visual" ) )
656 visual_checkbox->SetValue(1);
658 if( psz_filters ) free( psz_filters );
660 psz_filters = config_GetPsz( p_intf, "filter" );
661 if( psz_filters && strstr( psz_filters, "adjust" ) )
663 adjust_check->SetValue( 1 );
664 saturation_slider->Enable();
665 contrast_slider->Enable();
666 brightness_slider->Enable();
667 hue_slider->Enable();
668 gamma_slider->Enable();
672 adjust_check->SetValue( 0 );
673 saturation_slider->Disable();
674 contrast_slider->Disable();
675 brightness_slider->Disable();
676 hue_slider->Disable();
677 gamma_slider->Disable();
679 if( psz_filters ) free( psz_filters );
681 int i_value = config_GetInt( p_intf, "hue" );
682 if( i_value > 0 && i_value < 360 )
683 hue_slider->SetValue( i_value );
686 f_value = config_GetFloat( p_intf, "saturation" );
687 if( f_value > 0 && f_value < 5 )
688 saturation_slider->SetValue( (int)(100 * f_value) );
689 f_value = config_GetFloat( p_intf, "contrast" );
690 if( f_value > 0 && f_value < 4 )
691 contrast_slider->SetValue( (int)(100 * f_value) );
692 f_value = config_GetFloat( p_intf, "brightness" );
693 if( f_value > 0 && f_value < 2 )
694 brightness_slider->SetValue( (int)(100 * f_value) );
695 f_value = config_GetFloat( p_intf, "gamma" );
696 if( f_value > 0 && f_value < 10 )
697 gamma_slider->SetValue( (int)(10 * f_value) );
702 void Interface::UpdateAcceleratorTable()
704 /* Set some hotkeys */
705 wxAcceleratorEntry entries[7];
709 var_Get( p_intf->p_vlc, "key-quit", &val );
710 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
711 ConvertHotkey( val.i_int ), Exit_Event );
712 var_Get( p_intf->p_vlc, "key-stop", &val );
713 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
714 ConvertHotkey( val.i_int ), StopStream_Event );
715 var_Get( p_intf->p_vlc, "key-play-pause", &val );
716 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
717 ConvertHotkey( val.i_int ), PlayStream_Event );
718 var_Get( p_intf->p_vlc, "key-next", &val );
719 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
720 ConvertHotkey( val.i_int ), NextStream_Event );
721 var_Get( p_intf->p_vlc, "key-prev", &val );
722 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
723 ConvertHotkey( val.i_int ), PrevStream_Event );
724 var_Get( p_intf->p_vlc, "key-faster", &val );
725 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
726 ConvertHotkey( val.i_int ), FastStream_Event );
727 var_Get( p_intf->p_vlc, "key-slower", &val );
728 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
729 ConvertHotkey( val.i_int ), SlowStream_Event );
731 wxAcceleratorTable accel( 7, entries );
734 msg_Err( p_intf, "invalid accelerator table" );
736 SetAcceleratorTable( accel );
737 msg_Dbg( p_intf, "accelerator table loaded" );
741 /*****************************************************************************
743 *****************************************************************************/
745 void Interface::OnMenuOpen(wxMenuEvent& event)
747 #if !defined( __WXMSW__ )
748 if( event.GetEventObject() == p_settings_menu )
751 p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );
753 /* Add static items */
754 p_settings_menu->AppendCheckItem( Extended_Event,
755 wxU(_("&Extended GUI") ), wxU(_(HELP_EXTENDED)) );
756 p_settings_menu->AppendCheckItem( Bookmarks_Event,
757 wxU(_("&Bookmarks...") ), wxU(_(HELP_BOOKMARKS)) );
758 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
759 wxU(_(HELP_PREFS)) );
762 #if !defined( __WXMSW__ )
763 else if( event.GetEventObject() == p_audio_menu )
766 p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );
769 #if !defined( __WXMSW__ )
770 else if( event.GetEventObject() == p_video_menu )
773 p_video_menu = VideoMenu( p_intf, this, p_video_menu );
776 #if !defined( __WXMSW__ )
777 else if( event.GetEventObject() == p_navig_menu )
780 p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );
784 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
785 void Interface::OnContextMenu2(wxContextMenuEvent& event)
787 /* Only show the context menu for the main interface */
788 if( GetId() != event.GetId() )
794 if( p_intf->p_sys->pf_show_dialog )
795 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
798 void Interface::OnContextMenu(wxMouseEvent& event)
800 if( p_intf->p_sys->pf_show_dialog )
801 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
804 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
806 /* TRUE is to force the frame to close. */
810 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
813 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
814 wxU(_(" (wxWindows interface)\n\n")) +
815 wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
816 wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
817 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
818 "http://www.videolan.org/\n\n")) );
820 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
821 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
824 void Interface::OnShowDialog( wxCommandEvent& event )
826 if( p_intf->p_sys->pf_show_dialog )
830 switch( event.GetId() )
832 case OpenFileSimple_Event:
833 i_id = INTF_DIALOG_FILE_SIMPLE;
836 i_id = INTF_DIALOG_FILE;
838 i_id = INTF_DIALOG_FILE;
841 i_id = INTF_DIALOG_DISC;
844 i_id = INTF_DIALOG_NET;
847 i_id = INTF_DIALOG_SAT;
850 i_id = INTF_DIALOG_PLAYLIST;
853 i_id = INTF_DIALOG_MESSAGES;
856 i_id = INTF_DIALOG_FILEINFO;
859 i_id = INTF_DIALOG_PREFS;
861 case StreamWizard_Event:
862 i_id = INTF_DIALOG_STREAMWIZARD;
864 case Bookmarks_Event:
865 i_id = INTF_DIALOG_BOOKMARKS;
868 i_id = INTF_DIALOG_FILE;
872 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
876 void Interface::OnExtended(wxCommandEvent& event)
878 if( b_extra == VLC_FALSE)
881 frame_sizer->Show( extra_frame );
887 frame_sizer->Hide( extra_frame );
890 frame_sizer->Layout();
891 frame_sizer->Fit(this);
894 void Interface::OnEnableAdjust(wxCommandEvent& event)
896 char *psz_filters=config_GetPsz( p_intf, "filter");
897 char *psz_new = NULL;
898 if( event.IsChecked() )
900 if(psz_filters == NULL)
902 psz_new = strdup( "adjust" );
906 psz_new= (char *) malloc(strlen(psz_filters) + 8 );
907 sprintf( psz_new, "%s:adjust", psz_filters);
909 config_PutPsz( p_intf, "filter", psz_new );
911 vout_thread_t *p_vout =
912 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
916 val.psz_string = strdup( psz_new );
917 var_Set( p_vout, "filter", val);
918 vlc_object_release( p_vout );
920 if( val.psz_string ) free( val.psz_string );
921 brightness_slider->Enable();
922 saturation_slider->Enable();
923 contrast_slider->Enable();
924 hue_slider->Enable();
925 gamma_slider->Enable();
929 if( psz_filters != NULL )
934 for( i = 0; i< strlen(psz_filters ); i++)
936 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
939 if( psz_filters[i-1] == ':' ) i--;
940 psz_current = strchr( &psz_filters[i+1] , ':' );
942 psz_filters[i] = '\0';
945 memmove( &psz_filters[i] , psz_current,
946 &psz_filters[strlen(psz_filters)]-psz_current
951 config_PutPsz( p_intf, "filter", psz_filters);
953 val.psz_string = strdup( psz_filters );
954 vout_thread_t *p_vout =
955 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
959 var_Set( p_vout, "filter", val);
960 vlc_object_release( p_vout );
962 if( val.psz_string ) free( val.psz_string );
964 brightness_slider->Disable();
965 saturation_slider->Disable();
966 contrast_slider->Disable();
967 hue_slider->Disable();
968 gamma_slider->Disable();
970 if(psz_filters) free(psz_filters);
971 if(psz_new) free(psz_new);
974 void Interface::OnHueUpdate( wxScrollEvent& event)
976 config_PutInt( p_intf , "hue" , event.GetPosition() );
979 void Interface::OnSaturationUpdate( wxScrollEvent& event)
981 config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
984 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
986 config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
989 void Interface::OnContrastUpdate(wxScrollEvent& event)
991 config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
994 void Interface::OnGammaUpdate(wxScrollEvent& event)
996 config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
999 void Interface::OnRatio( wxCommandEvent& event )
1001 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1004 void Interface::OnEnableVisual(wxCommandEvent& event)
1006 if( event.IsChecked() )
1008 config_PutPsz( p_intf, "audio-filter", "visual" );
1012 config_PutPsz( p_intf, "audio-filter", "" );
1016 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1018 wxCommandEvent dummy;
1019 playlist_t *p_playlist =
1020 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1022 if( p_playlist == NULL ) return;
1024 if( p_playlist->i_size && p_playlist->i_enabled )
1028 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1031 if( p_input == NULL )
1033 /* No stream was playing, start one */
1034 playlist_Play( p_playlist );
1035 TogglePlayButton( PLAYING_S );
1036 vlc_object_release( p_playlist );
1040 var_Get( p_input, "state", &state );
1042 if( state.i_int != PAUSE_S )
1044 /* A stream is being played, pause it */
1045 state.i_int = PAUSE_S;
1049 /* Stream is paused, resume it */
1050 state.i_int = PLAYING_S;
1052 var_Set( p_input, "state", state );
1054 TogglePlayButton( state.i_int );
1055 vlc_object_release( p_input );
1056 vlc_object_release( p_playlist );
1060 /* If the playlist is empty, open a file requester instead */
1061 vlc_object_release( p_playlist );
1062 OnShowDialog( dummy );
1066 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1068 playlist_t * p_playlist =
1069 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1071 if( p_playlist == NULL )
1076 playlist_Stop( p_playlist );
1077 TogglePlayButton( PAUSE_S );
1078 vlc_object_release( p_playlist );
1081 void Interface::OnSliderUpdate( wxScrollEvent& event )
1083 vlc_mutex_lock( &p_intf->change_lock );
1086 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1087 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1090 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1091 && p_intf->p_sys->p_input )
1094 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1096 var_Set( p_intf->p_sys->p_input, "position", pos );
1100 p_intf->p_sys->b_slider_free = VLC_TRUE;
1104 p_intf->p_sys->b_slider_free = VLC_FALSE;
1106 if( p_intf->p_sys->p_input )
1108 /* Update stream date */
1109 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1110 char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
1114 var_Get( p_intf->p_sys->p_input, "length", &val );
1115 i_seconds = val.i_time / 1000000;
1116 secstotimestr ( psz_total, i_seconds );
1118 statusbar->SetStatusText(
1119 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1120 psz_time, p_area->i_size * event.GetPosition()
1121 / SLIDER_MAX_POS )) + wxString(wxT(" / ")) +
1122 wxU(psz_total), 0 );
1129 vlc_mutex_unlock( &p_intf->change_lock );
1132 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1134 playlist_t * p_playlist =
1135 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1137 if( p_playlist == NULL )
1142 vlc_mutex_lock( &p_playlist->object_lock );
1143 if( p_playlist->p_input != NULL )
1145 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1146 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1148 vlc_value_t val; val.b_bool = VLC_TRUE;
1149 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1150 var_Set( p_playlist->p_input, "prev-title", val );
1152 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1154 vlc_mutex_unlock( &p_playlist->object_lock );
1156 playlist_Prev( p_playlist );
1157 vlc_object_release( p_playlist );
1160 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1162 playlist_t * p_playlist =
1163 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1165 if( p_playlist == NULL )
1170 vlc_mutex_lock( &p_playlist->object_lock );
1171 if( p_playlist->p_input != NULL )
1173 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1174 if( p_playlist->p_input->stream.i_area_nb > 1 &&
1175 p_playlist->p_input->stream.p_selected_area->i_id <
1176 p_playlist->p_input->stream.i_area_nb - 1 )
1178 vlc_value_t val; val.b_bool = VLC_TRUE;
1179 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1180 var_Set( p_playlist->p_input, "next-title", val );
1182 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1184 vlc_mutex_unlock( &p_playlist->object_lock );
1186 playlist_Next( p_playlist );
1187 vlc_object_release( p_playlist );
1190 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1192 input_thread_t *p_input =
1193 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1197 vlc_value_t val; val.b_bool = VLC_TRUE;
1199 var_Set( p_input, "rate-slower", val );
1200 vlc_object_release( p_input );
1204 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1206 input_thread_t *p_input =
1207 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1211 vlc_value_t val; val.b_bool = VLC_TRUE;
1213 var_Set( p_input, "rate-faster", val );
1214 vlc_object_release( p_input );
1218 void Interface::TogglePlayButton( int i_playing_status )
1220 if( i_playing_status == i_old_playing_status )
1223 GetToolBar()->DeleteTool( PlayStream_Event );
1225 if( i_playing_status == PLAYING_S )
1227 GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Pause")),
1228 wxBitmap( pause_xpm ), wxNullBitmap,
1229 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1233 GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Play")),
1234 wxBitmap( play_xpm ), wxNullBitmap,
1235 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1238 GetToolBar()->Realize();
1240 i_old_playing_status = i_playing_status;
1243 #if !defined(__WXX11__)
1244 /*****************************************************************************
1245 * Definition of DragAndDrop class.
1246 *****************************************************************************/
1247 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1250 b_enqueue = _b_enqueue;
1253 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1254 const wxArrayString& filenames )
1256 /* Add dropped files to the playlist */
1258 playlist_t *p_playlist =
1259 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1261 if( p_playlist == NULL )
1266 for( size_t i = 0; i < filenames.GetCount(); i++ )
1267 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
1268 (const char *)filenames[i].mb_str(),
1269 PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1272 vlc_object_release( p_playlist );
1278 /*****************************************************************************
1279 * Definition of wxVolCtrl class.
1280 *****************************************************************************/
1281 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1282 wxPoint point, wxSize size )
1283 : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
1287 audio_volume_t i_volume;
1288 aout_VolumeGet( p_intf, &i_volume );
1289 i_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
1290 SetValue( i_volume );
1291 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1295 void wxVolCtrl::OnChange( wxMouseEvent& event )
1297 if( !event.LeftDown() && !event.LeftIsDown() ) return;
1299 int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
1303 void wxVolCtrl::Change( int i_volume )
1305 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1306 SetValue( i_volume );
1307 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),