1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001, 2003 VideoLAN
5 * $Id: interface.cpp,v 1.84 2004/01/22 15:00:10 sigmunau Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
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,
153 /* it is important for the id corresponding to the "About" command to have
154 * this standard value as otherwise it won't be handled properly under Mac
155 * (where it is special and put into the "Apple" menu) */
156 About_Event = wxID_ABOUT
159 BEGIN_EVENT_TABLE(Interface, wxFrame)
161 EVT_MENU(Exit_Event, Interface::OnExit)
162 EVT_MENU(About_Event, Interface::OnAbout)
164 EVT_MENU(Playlist_Event, Interface::OnShowDialog)
165 EVT_MENU(Logs_Event, Interface::OnShowDialog)
166 EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
167 EVT_MENU(Prefs_Event, Interface::OnShowDialog)
169 EVT_MENU_OPEN(Interface::OnMenuOpen)
171 EVT_MENU( Extra_Event, Interface::OnExtra)
172 EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
174 EVT_TEXT( Ratio_Event, Interface::OnRatio)
175 EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
177 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
178 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
180 EVT_RIGHT_UP(Interface::OnContextMenu)
183 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
184 EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
185 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
186 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
187 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
188 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
189 EVT_MENU(Stream_Event, Interface::OnStream)
190 EVT_MENU(StopStream_Event, Interface::OnStopStream)
191 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
192 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
193 EVT_MENU(NextStream_Event, Interface::OnNextStream)
194 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
195 EVT_MENU(FastStream_Event, Interface::OnFastStream)
198 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
200 EVT_COMMAND_SCROLL(Hue_Event, Interface::OnHueUpdate)
201 EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
202 EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
203 EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
204 EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
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 /* Creation of the slider sub-window */
241 frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
242 frame_sizer->Hide( slider_frame );
244 /* Create the extra panel */
245 CreateOurExtraPanel();
246 frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
247 frame_sizer->Hide( extra_frame );
249 /* Creation of the status bar
250 * Helptext for menu items and toolbar tools will automatically get
252 int i_status_width[3] = {-6, -2, -9};
253 statusbar = CreateStatusBar( 3 ); /* 2 fields */
254 statusbar->SetStatusWidths( 3, i_status_width );
255 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
257 /* Make sure we've got the right background colour */
258 SetBackgroundColour( slider_frame->GetBackgroundColour() );
260 /* Layout everything */
261 frame_sizer->Layout();
262 frame_sizer->Fit(this);
264 #if !defined(__WXX11__)
265 /* Associate drop targets with the main interface */
266 SetDropTarget( new DragAndDrop( p_intf ) );
269 UpdateAcceleratorTable();
272 timer = new Timer( p_intf, this );
275 Interface::~Interface()
277 if( p_intf->p_sys->p_wxwindow )
279 delete p_intf->p_sys->p_wxwindow;
286 /*****************************************************************************
288 *****************************************************************************/
289 void Interface::CreateOurMenuBar()
291 #define HELP_SIMPLE N_("Quick file open")
292 #define HELP_ADV N_("Advanced open")
293 #define HELP_FILE N_("Open a file")
294 #define HELP_DISC N_("Open Disc Media")
295 #define HELP_NET N_("Open a network stream")
296 #define HELP_SAT N_("Open a satellite stream")
297 #define HELP_EJECT N_("Eject the DVD/CD")
298 #define HELP_EXIT N_("Exit this program")
300 #define HELP_STREAMWIZARD N_("Open the streaming wizard")
301 #define HELP_OTHER N_("Open other types of inputs")
303 #define HELP_PLAYLIST N_("Open the playlist")
304 #define HELP_LOGS N_("Show the program logs")
305 #define HELP_FILEINFO N_("Show information about the file being played")
307 #define HELP_PREFS N_("Go to the preferences menu")
308 #define EXTRA_PREFS N_("Shows the extended GUI")
310 #define HELP_ABOUT N_("About this program")
312 /* Create the "File" menu */
313 wxMenu *file_menu = new wxMenu;
314 file_menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open ...")),
315 wxU(_(HELP_SIMPLE)) );
317 file_menu->AppendSeparator();
318 file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
320 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
322 file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
326 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
329 file_menu->AppendSeparator();
330 file_menu->Append( Stream_Event, wxU(_("Streaming Wizard...")),
331 wxU(_(HELP_STREAMWIZARD)) );
332 file_menu->AppendSeparator();
333 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
335 /* Create the "View" menu */
336 wxMenu *view_menu = new wxMenu;
337 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
338 wxU(_(HELP_PLAYLIST)) );
339 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
340 view_menu->Append( FileInfo_Event, wxU(_("&Stream and Media info...")),
341 wxU(_(HELP_FILEINFO)) );
343 /* Create the "Settings" menu */
344 p_settings_menu = new wxMenu;
347 /* Create the "Audio" menu */
348 p_audio_menu = new wxMenu;
351 /* Create the "Video" menu */
352 p_video_menu = new wxMenu;
355 /* Create the "Navigation" menu */
356 p_navig_menu = new wxMenu;
359 /* Create the "Help" menu */
360 wxMenu *help_menu = new wxMenu;
361 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
363 /* Append the freshly created menus to the menu bar... */
364 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
365 menubar->Append( file_menu, wxU(_("&File")) );
366 menubar->Append( view_menu, wxU(_("&View")) );
367 menubar->Append( p_settings_menu, wxU(_("&Settings")) );
368 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
369 menubar->Append( p_video_menu, wxU(_("&Video")) );
370 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
371 menubar->Append( help_menu, wxU(_("&Help")) );
373 /* Attach the menu bar to the frame */
374 SetMenuBar( menubar );
376 /* Intercept all menu events in our custom event handler */
377 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
379 #if !defined(__WXX11__)
380 /* Associate drop targets with the menubar */
381 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
385 void Interface::CreateOurToolBar()
387 #define HELP_STOP N_("Stop current playlist item")
389 #define HELP_PLAY N_("Play current playlist item")
390 #define HELP_PAUSE N_("Pause current playlist item")
391 #define HELP_PLO N_("Open playlist")
392 #define HELP_PLP N_("Previous playlist item")
393 #define HELP_PLN N_("Next playlist item")
394 #define HELP_SLOW N_("Play slower")
395 #define HELP_FAST N_("Play faster")
397 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
398 * version because we don't include wx.rc */
401 CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
403 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
405 toolbar->AddTool( OpenFileSimple_Event, wxU(_("Quick")),
406 wxBitmap( file_xpm ), wxU(_(HELP_SIMPLE)) );
408 toolbar->AddSeparator();
409 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
411 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
413 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
415 toolbar->AddSeparator();
417 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
419 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
422 toolbar->AddSeparator();
423 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
424 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
425 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
426 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
427 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
429 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
431 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
436 /* Place the toolbar in a sizer, so we can calculate the width of the
437 * toolbar and set this as the minimum for the main frame size. */
438 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
439 toolbar_sizer->Add( toolbar, 1, 0, 0 );
440 toolbar_sizer->Layout();
443 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
444 #else /* That sucks but for some reason it works better */
445 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth()*2/3, -1 );
448 #if !defined(__WXX11__)
449 /* Associate drop targets with the toolbar */
450 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
454 void Interface::CreateOurSlider()
456 /* Create a new frame and sizer containing the slider */
457 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
458 slider_frame->SetAutoLayout( TRUE );
459 wxBoxSizer *frame_sizer =
460 new wxBoxSizer( wxHORIZONTAL );
462 /* Create static box to surround the slider */
463 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
465 /* Create sizer for slider frame */
466 wxStaticBoxSizer *slider_sizer =
467 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
468 slider_sizer->SetMinSize( -1, 50 );
471 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
472 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
473 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
476 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
478 /* Add everything to the frame */
479 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
480 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
481 slider_frame->SetSizer( frame_sizer );
482 frame_sizer->Layout();
483 frame_sizer->SetSizeHints(slider_frame);
485 /* Hide the slider by default */
486 slider_frame->Hide();
490 void Interface::CreateOurExtraPanel()
494 extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
495 extra_frame->SetAutoLayout( TRUE );
496 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
498 /* Create static box to surround the adjust controls */
499 wxStaticBox *adjust_box =
500 new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) );
502 /* Create the size for the frame */
503 wxStaticBoxSizer *adjust_sizer =
504 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
505 adjust_sizer->SetMinSize( -1, 50 );
507 /* Create every controls */
509 /* Create the adjust button */
510 wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
514 wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
515 wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
517 hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
518 360, wxDefaultPosition, wxDefaultSize );
520 hue_sizer->Add(hue_text,1, 0 ,0);
521 hue_sizer->Add(hue_slider,1, 0 ,0);
524 wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
525 wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
526 wxU(_("Contrast")) );
527 contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
528 200, wxDefaultPosition, wxDefaultSize);
529 contrast_sizer->Add(contrast_text,1, 0 ,0);
530 contrast_sizer->Add(contrast_slider,1, 0 ,0);
531 contrast_sizer->Layout();
533 wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
534 wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
535 wxU(_("Brightness")) );
536 brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
537 200, wxDefaultPosition, wxDefaultSize) ;
538 brightness_sizer->Add(brightness_text,1,0,0);
539 brightness_sizer->Add(brightness_slider,1,0,0);
540 brightness_sizer->Layout();
542 wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
543 wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
544 wxU(_("Saturation")) );
545 saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
546 300, wxDefaultPosition, wxDefaultSize );
547 saturation_sizer->Add(saturation_text,1,0,0);
548 saturation_sizer->Add(saturation_slider,1,0,0);
549 saturation_sizer->Layout();
551 wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
552 wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
554 gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
555 100, wxDefaultPosition, wxDefaultSize );
556 gamma_sizer->Add(gamma_text,1,0,0);
557 gamma_sizer->Add(gamma_slider,1,0,0);
558 gamma_sizer->Layout();
560 adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
561 adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
562 adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
563 adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
564 adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
565 adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
567 extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
569 /* Create sizer to surround the other controls */
570 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
573 wxStaticBox *video_box =
574 new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
575 /* Create the sizer for the frame */
576 wxStaticBoxSizer *video_sizer =
577 new wxStaticBoxSizer( video_box, wxVERTICAL );
578 video_sizer->SetMinSize( -1, 50 );
580 static const wxString ratio_array[] =
586 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
587 wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
590 ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
591 wxDefaultPosition, wxSize(120,-1),
592 WXSIZEOF(ratio_array), ratio_array,
595 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
596 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
597 ratio_sizer->Layout();
599 video_sizer->Add( ratio_sizer , 0 , wxALL , 0 );
600 video_sizer->Layout();
603 wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
605 wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
606 wxU(_("Visualisation")) );
608 visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
609 visual_sizer->Layout();
611 wxStaticBox *audio_box =
612 new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
613 /* Create the sizer for the frame */
614 wxStaticBoxSizer *audio_sizer =
615 new wxStaticBoxSizer( audio_box, wxVERTICAL );
616 audio_sizer->SetMinSize( -1, 50 );
618 audio_sizer->Add( visual_sizer, 0, wxALL, 0);
619 audio_sizer->Layout();
621 other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
623 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
624 other_sizer->Layout();
626 extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
628 extra_frame->SetSizer( extra_sizer );
630 /* Layout the whole panel */
631 extra_sizer->Layout();
633 extra_sizer->SetSizeHints(extra_frame);
635 /* Write down initial values */
637 psz_filters = config_GetPsz( p_intf, "audio-filter" );
638 if( psz_filters && strstr( psz_filters, "visual" ) )
640 visual_checkbox->SetValue(1);
642 if( psz_filters ) free( psz_filters );
644 psz_filters = config_GetPsz( p_intf, "filter" );
645 if( psz_filters && strstr( psz_filters, "adjust" ) )
647 adjust_check->SetValue( 1 );
648 saturation_slider->Enable();
649 contrast_slider->Enable();
650 brightness_slider->Enable();
651 hue_slider->Enable();
652 gamma_slider->Enable();
656 adjust_check->SetValue( 0 );
657 saturation_slider->Disable();
658 contrast_slider->Disable();
659 brightness_slider->Disable();
660 hue_slider->Disable();
661 gamma_slider->Disable();
663 if( psz_filters ) free( psz_filters );
665 int i_value = config_GetInt( p_intf, "hue" );
666 if( i_value > 0 && i_value < 360 )
667 hue_slider->SetValue( i_value );
670 f_value = config_GetFloat( p_intf, "saturation" );
671 if( f_value > 0 && f_value < 5 )
672 saturation_slider->SetValue( (int)(100 * f_value) );
673 f_value = config_GetFloat( p_intf, "contrast" );
674 if( f_value > 0 && f_value < 4 )
675 contrast_slider->SetValue( (int)(100 * f_value) );
676 f_value = config_GetFloat( p_intf, "brightness" );
677 if( f_value > 0 && f_value < 2 )
678 brightness_slider->SetValue( (int)(100 * f_value) );
679 f_value = config_GetFloat( p_intf, "gamma" );
680 if (f_value > 0 && f_value < 10 )
681 gamma_slider->SetValue( (int)(10 * f_value) );
686 void Interface::UpdateAcceleratorTable()
688 /* Set some hotkeys */
689 wxAcceleratorEntry entries[7];
693 var_Get( p_intf->p_vlc, "key-quit", &val );
694 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
695 ConvertHotkey( val.i_int ), Exit_Event );
696 var_Get( p_intf->p_vlc, "key-stop", &val );
697 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
698 ConvertHotkey( val.i_int ), StopStream_Event );
699 var_Get( p_intf->p_vlc, "key-play-pause", &val );
700 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
701 ConvertHotkey( val.i_int ), PlayStream_Event );
702 var_Get( p_intf->p_vlc, "key-next", &val );
703 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
704 ConvertHotkey( val.i_int ), NextStream_Event );
705 var_Get( p_intf->p_vlc, "key-prev", &val );
706 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
707 ConvertHotkey( val.i_int ), PrevStream_Event );
708 var_Get( p_intf->p_vlc, "key-faster", &val );
709 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
710 ConvertHotkey( val.i_int ), FastStream_Event );
711 var_Get( p_intf->p_vlc, "key-slower", &val );
712 entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
713 ConvertHotkey( val.i_int ), SlowStream_Event );
715 wxAcceleratorTable accel( 7, entries );
718 msg_Err( p_intf, "invalid accelerator table" );
720 SetAcceleratorTable( accel );
721 msg_Dbg( p_intf, "accelerator table loaded" );
725 /*****************************************************************************
727 *****************************************************************************/
728 /* Work-around helper for buggy wxGTK */
729 void RecursiveDestroy( wxMenu *menu )
731 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
734 wxMenuItem *item = node->GetData();
735 node = node->GetNext();
737 /* Delete the submenus */
738 wxMenu *submenu = item->GetSubMenu();
741 RecursiveDestroy( submenu );
743 menu->Delete( item );
747 void Interface::OnMenuOpen(wxMenuEvent& event)
749 #if !defined( __WXMSW__ )
750 if( event.GetEventObject() == p_settings_menu )
752 if( b_settings_menu )
754 p_settings_menu = SettingsMenu( p_intf, this );
756 /* Add static items */
757 p_settings_menu->AppendCheckItem( Extra_Event,
758 wxU(_("&Extended GUI") ), wxU(_(EXTRA_PREFS)) );
759 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
760 wxU(_(HELP_PREFS)) );
762 /* Work-around for buggy wxGTK */
763 wxMenu *menu = GetMenuBar()->GetMenu( 2 );
764 RecursiveDestroy( menu );
765 /* End work-around */
767 menu = GetMenuBar()->Replace( 2, p_settings_menu,
768 wxU(_("&Settings")));
769 if( menu ) delete menu;
773 else b_settings_menu = 1;
775 else if( event.GetEventObject() == p_audio_menu )
779 p_audio_menu = AudioMenu( p_intf, this );
781 /* Work-around for buggy wxGTK */
782 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
783 RecursiveDestroy( menu );
784 /* End work-around */
787 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
788 if( menu ) delete menu;
792 else b_audio_menu = 1;
794 else if( event.GetEventObject() == p_video_menu )
798 p_video_menu = VideoMenu( p_intf, this );
800 /* Work-around for buggy wxGTK */
801 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
802 RecursiveDestroy( menu );
803 /* End work-around */
806 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
807 if( menu ) delete menu;
811 else b_video_menu = 1;
813 else if( event.GetEventObject() == p_navig_menu )
817 p_navig_menu = NavigMenu( p_intf, this );
819 /* Work-around for buggy wxGTK */
820 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
821 RecursiveDestroy( menu );
822 /* End work-around */
825 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
826 if( menu ) delete menu;
830 else b_navig_menu = 1;
834 p_settings_menu = SettingsMenu( p_intf, this );
835 /* Add static items */
836 p_settings_menu->AppendCheckItem( Extra_Event, wxU(_("&Extended GUI") ),
837 wxU(_(EXTRA_PREFS)) );
838 p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
839 wxU(_(HELP_PREFS)) );
841 GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
842 if( menu ) delete menu;
844 p_audio_menu = AudioMenu( p_intf, this );
845 menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
846 if( menu ) delete menu;
848 p_video_menu = VideoMenu( p_intf, this );
849 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
850 if( menu ) delete menu;
852 p_navig_menu = NavigMenu( p_intf, this );
853 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
854 if( menu ) delete menu;
859 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
860 void Interface::OnContextMenu2(wxContextMenuEvent& event)
862 /* Only show the context menu for the main interface */
863 if( GetId() != event.GetId() )
869 if( p_intf->p_sys->pf_show_dialog )
870 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
873 void Interface::OnContextMenu(wxMouseEvent& event)
875 if( p_intf->p_sys->pf_show_dialog )
876 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
879 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
881 /* TRUE is to force the frame to close. */
885 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
888 msg.Printf( wxString(wxT("VLC media player " VERSION)) +
889 wxU(_(" (wxWindows interface)\n\n")) +
890 wxU(_("(c) 1996-2003 - the VideoLAN Team\n\n")) +
891 wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
892 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
893 "http://www.videolan.org/\n\n")) );
895 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
896 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
899 void Interface::OnShowDialog( wxCommandEvent& event )
901 if( p_intf->p_sys->pf_show_dialog )
905 switch( event.GetId() )
907 case OpenFileSimple_Event:
908 i_id = INTF_DIALOG_FILE_SIMPLE;
911 i_id = INTF_DIALOG_FILE;
913 i_id = INTF_DIALOG_FILE;
916 i_id = INTF_DIALOG_DISC;
919 i_id = INTF_DIALOG_NET;
922 i_id = INTF_DIALOG_SAT;
925 i_id = INTF_DIALOG_PLAYLIST;
928 i_id = INTF_DIALOG_MESSAGES;
931 i_id = INTF_DIALOG_FILEINFO;
934 i_id = INTF_DIALOG_PREFS;
937 i_id = INTF_DIALOG_FILE;
942 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
947 void Interface::OnStream( wxCommandEvent& event )
949 StreamDialog *p_stream_dialog = new StreamDialog(p_intf,this);
950 p_stream_dialog->Show();
954 void Interface::OnExtra(wxCommandEvent& event)
956 if( b_extra == VLC_FALSE)
959 frame_sizer->Show( extra_frame );
965 frame_sizer->Hide( extra_frame );
968 frame_sizer->Layout();
969 frame_sizer->Fit(this);
972 void Interface::OnEnableAdjust(wxCommandEvent& event)
974 char *psz_filters=config_GetPsz( p_intf, "filter");
975 char *psz_new = NULL;
976 if( event.IsChecked() )
978 if(psz_filters == NULL)
980 psz_new = strdup( "adjust" );
984 psz_new= (char *) malloc(strlen(psz_filters) + 8 );
985 sprintf( psz_new, "%s:adjust", psz_filters);
987 config_PutPsz( p_intf, "filter", psz_new );
989 vout_thread_t *p_vout =
990 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
994 val.psz_string = strdup( psz_new );
995 var_Set( p_vout, "filter", val);
996 vlc_object_release( p_vout );
998 if( val.psz_string ) free( val.psz_string );
999 brightness_slider->Enable();
1000 saturation_slider->Enable();
1001 contrast_slider->Enable();
1002 hue_slider->Enable();
1003 gamma_slider->Enable();
1007 if( psz_filters != NULL )
1012 for( i = 0; i< strlen(psz_filters ); i++)
1014 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1017 if( psz_filters[i-1] == ':' ) i--;
1018 psz_current = strchr( &psz_filters[i+1] , ':' );
1020 psz_filters[i] = '\0';
1023 memmove( &psz_filters[i] , psz_current,
1024 &psz_filters[strlen(psz_filters)]-psz_current
1029 config_PutPsz( p_intf, "filter", psz_filters);
1031 val.psz_string = strdup( psz_filters );
1032 vout_thread_t *p_vout =
1033 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1035 if( p_vout != NULL )
1037 var_Set( p_vout, "filter", val);
1038 vlc_object_release( p_vout );
1040 if( val.psz_string ) free( val.psz_string );
1042 brightness_slider->Disable();
1043 saturation_slider->Disable();
1044 contrast_slider->Disable();
1045 hue_slider->Disable();
1046 gamma_slider->Disable();
1048 if(psz_filters) free(psz_filters);
1049 if(psz_new) free(psz_new);
1052 void Interface::OnHueUpdate( wxScrollEvent& event)
1054 config_PutInt( p_intf , "hue" , event.GetPosition() );
1057 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1059 config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1062 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1064 config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1067 void Interface::OnContrastUpdate(wxScrollEvent& event)
1069 config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1073 void Interface::OnGammaUpdate(wxScrollEvent& event)
1075 config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
1078 void Interface::OnRatio( wxCommandEvent& event )
1080 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1083 void Interface::OnEnableVisual(wxCommandEvent& event)
1085 if( event.IsChecked() )
1087 config_PutPsz( p_intf, "audio-filter", "visual" );
1091 config_PutPsz( p_intf, "audio-filter", "" );
1095 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1097 wxCommandEvent dummy;
1098 playlist_t *p_playlist =
1099 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1101 if( p_playlist == NULL ) return;
1103 if( p_playlist->i_size && p_playlist->i_enabled )
1107 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1110 if( p_input == NULL )
1112 /* No stream was playing, start one */
1113 playlist_Play( p_playlist );
1114 TogglePlayButton( PLAYING_S );
1115 vlc_object_release( p_playlist );
1119 var_Get( p_input, "state", &state );
1121 if( state.i_int != PAUSE_S )
1123 /* A stream is being played, pause it */
1124 state.i_int = PAUSE_S;
1128 /* Stream is paused, resume it */
1129 state.i_int = PLAYING_S;
1131 var_Set( p_input, "state", state );
1133 TogglePlayButton( state.i_int );
1134 vlc_object_release( p_input );
1135 vlc_object_release( p_playlist );
1139 /* If the playlist is empty, open a file requester instead */
1140 vlc_object_release( p_playlist );
1141 OnShowDialog( dummy );
1145 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1147 playlist_t * p_playlist =
1148 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1150 if( p_playlist == NULL )
1155 playlist_Stop( p_playlist );
1156 TogglePlayButton( PAUSE_S );
1157 vlc_object_release( p_playlist );
1160 void Interface::OnSliderUpdate( wxScrollEvent& event )
1162 vlc_mutex_lock( &p_intf->change_lock );
1165 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1166 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1169 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1170 && p_intf->p_sys->p_input )
1173 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1175 var_Set( p_intf->p_sys->p_input, "position", pos );
1179 p_intf->p_sys->b_slider_free = VLC_TRUE;
1183 p_intf->p_sys->b_slider_free = VLC_FALSE;
1185 if( p_intf->p_sys->p_input )
1187 /* Update stream date */
1188 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1189 char psz_time[ MSTRTIME_MAX_SIZE ];
1191 slider_box->SetLabel(
1192 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1194 p_area->i_size * event.GetPosition()
1195 / SLIDER_MAX_POS )) );
1202 vlc_mutex_unlock( &p_intf->change_lock );
1205 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1207 playlist_t * p_playlist =
1208 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1210 if( p_playlist == NULL )
1215 vlc_mutex_lock( &p_playlist->object_lock );
1216 if( p_playlist->p_input != NULL )
1218 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1219 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1221 vlc_value_t val; val.b_bool = VLC_TRUE;
1222 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1223 var_Set( p_playlist->p_input, "prev-title", val );
1225 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1227 vlc_mutex_unlock( &p_playlist->object_lock );
1229 playlist_Prev( p_playlist );
1230 vlc_object_release( p_playlist );
1233 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1235 playlist_t * p_playlist =
1236 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1238 if( p_playlist == NULL )
1243 vlc_mutex_lock( &p_playlist->object_lock );
1244 if( p_playlist->p_input != NULL )
1246 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1247 if( p_playlist->p_input->stream.i_area_nb > 1 &&
1248 p_playlist->p_input->stream.p_selected_area->i_id <
1249 p_playlist->p_input->stream.i_area_nb - 1 )
1251 vlc_value_t val; val.b_bool = VLC_TRUE;
1252 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1253 var_Set( p_playlist->p_input, "next-title", val );
1255 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1257 vlc_mutex_unlock( &p_playlist->object_lock );
1259 playlist_Next( p_playlist );
1260 vlc_object_release( p_playlist );
1263 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1265 input_thread_t *p_input =
1266 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1270 vlc_value_t val; val.b_bool = VLC_TRUE;
1272 var_Set( p_input, "rate-slower", val );
1273 vlc_object_release( p_input );
1277 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1279 input_thread_t *p_input =
1280 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1284 vlc_value_t val; val.b_bool = VLC_TRUE;
1286 var_Set( p_input, "rate-faster", val );
1287 vlc_object_release( p_input );
1291 void Interface::TogglePlayButton( int i_playing_status )
1293 if( i_playing_status == i_old_playing_status )
1296 GetToolBar()->DeleteTool( PlayStream_Event );
1298 if( i_playing_status == PLAYING_S )
1300 GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")),
1301 wxBitmap( pause_xpm ), wxNullBitmap,
1302 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1306 GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")),
1307 wxBitmap( play_xpm ), wxNullBitmap,
1308 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1311 GetToolBar()->Realize();
1313 i_old_playing_status = i_playing_status;
1316 #if !defined(__WXX11__)
1317 /*****************************************************************************
1318 * Definition of DragAndDrop class.
1319 *****************************************************************************/
1320 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1323 b_enqueue = _b_enqueue;
1326 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1327 const wxArrayString& filenames )
1329 /* Add dropped files to the playlist */
1331 playlist_t *p_playlist =
1332 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1334 if( p_playlist == NULL )
1339 for( size_t i = 0; i < filenames.GetCount(); i++ )
1340 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
1341 (const char *)filenames[i].mb_str(),
1342 PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1345 vlc_object_release( p_playlist );
1351 /*****************************************************************************
1352 * Definition of wxVolCtrl class.
1353 *****************************************************************************/
1354 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
1355 : wxGauge( parent, id, 200, wxDefaultPosition, wxSize( 20, -1 ),
1356 wxGA_VERTICAL | wxGA_SMOOTH )
1361 void wxVolCtrl::OnChange( wxMouseEvent& event )
1363 if( !event.LeftDown() && !event.LeftIsDown() ) return;
1365 int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
1366 GetClientSize().GetHeight();
1370 void wxVolCtrl::Change( int i_volume )
1372 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1373 SetValue( i_volume );
1374 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),