]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/interface.cpp
all: gamma correction patch by Arwed von Merkatz <v.merkatz@gmx.net>
[vlc] / modules / gui / wxwindows / interface.cpp
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 $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28 #include <vlc/aout.h>
29 #include <vlc/vout.h>
30 #include <vlc/intf.h>
31 #include "stream_control.h"
32
33 #include "wxwindows.h"
34
35 /* include the toolbar graphics */
36 #include "bitmaps/file.xpm"
37
38 #include "bitmaps/disc.xpm"
39 #include "bitmaps/net.xpm"
40 #if 0
41  #include "bitmaps/sat.xpm"
42 #endif
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"
51
52 #include <wx/listctrl.h>
53
54 #define TOOLBAR_BMP_WIDTH 36
55 #define TOOLBAR_BMP_HEIGHT 36
56
57 /* include the icon graphic */
58 #include "../../../share/vlc32x32.xpm"
59
60 /*****************************************************************************
61  * Local class declarations.
62  *****************************************************************************/
63 class wxMenuExt: public wxMenu
64 {
65 public:
66     /* Constructor */
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,
70                    int _i_val_type );
71
72     virtual ~wxMenuExt() {};
73
74     char *psz_var;
75     int  i_val_type;
76     int  i_object_id;
77     vlc_value_t val;
78
79 private:
80
81 };
82
83 class wxVolCtrl: public wxGauge
84 {
85 public:
86     /* Constructor */
87     wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
88     virtual ~wxVolCtrl() {};
89
90     void Change( int i_volume );
91
92     void OnChange( wxMouseEvent& event );
93
94 private:
95     intf_thread_t *p_intf;
96
97     DECLARE_EVENT_TABLE();
98 };
99
100 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
101     /* Mouse events */
102     EVT_LEFT_DOWN(wxVolCtrl::OnChange)
103     EVT_MOTION(wxVolCtrl::OnChange)
104 END_EVENT_TABLE()
105
106 /*****************************************************************************
107  * Event Table.
108  *****************************************************************************/
109
110 /* IDs for the controls and the menu commands */
111 enum
112 {
113     /* menu items */
114     MenuDummy_Event = wxID_HIGHEST + 1000,
115     Exit_Event = wxID_HIGHEST,
116     OpenFileSimple_Event,
117     OpenAdv_Event,
118     OpenFile_Event,
119     OpenDisc_Event,
120     OpenNet_Event,
121     OpenSat_Event,
122     OpenOther_Event,
123     EjectDisc_Event,
124
125     Stream_Event,
126
127     Playlist_Event,
128     Logs_Event,
129     FileInfo_Event,
130
131     Prefs_Event,
132     Extra_Event,
133     Skins_Event,
134
135     SliderScroll_Event,
136     StopStream_Event,
137     PlayStream_Event,
138     PrevStream_Event,
139     NextStream_Event,
140     SlowStream_Event,
141     FastStream_Event,
142
143     Adjust_Event,
144     Hue_Event,
145     Contrast_Event,
146     Brightness_Event,
147     Saturation_Event,
148     Gamma_Event,
149
150     Ratio_Event,
151     Visual_Event,
152
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
157 };
158
159 BEGIN_EVENT_TABLE(Interface, wxFrame)
160     /* Menu events */
161     EVT_MENU(Exit_Event, Interface::OnExit)
162     EVT_MENU(About_Event, Interface::OnAbout)
163
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)
168
169     EVT_MENU_OPEN(Interface::OnMenuOpen)
170
171     EVT_MENU( Extra_Event, Interface::OnExtra)
172     EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
173
174     EVT_TEXT( Ratio_Event, Interface::OnRatio)
175     EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
176
177 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
178     EVT_CONTEXT_MENU(Interface::OnContextMenu2)
179 #endif
180     EVT_RIGHT_UP(Interface::OnContextMenu)
181
182     /* Toolbar events */
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)
196
197     /* Slider events */
198     EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
199
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)
205
206 END_EVENT_TABLE()
207
208 /*****************************************************************************
209  * Constructor.
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 )
214 {
215     /* Initializations */
216     p_intf = _p_intf;
217     i_old_playing_status = PAUSE_S;
218     b_extra = VLC_FALSE;
219
220     /* Give our interface a nice little icon */
221     SetIcon( wxIcon( vlc_xpm ) );
222
223     /* Create a sizer for the main frame */
224     frame_sizer = new wxBoxSizer( wxVERTICAL );
225     SetSizer( frame_sizer );
226
227     /* Create a dummy widget that can get the keyboard focus */
228     wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
229                                       wxSize(0,0) );
230     p_dummy->SetFocus();
231     frame_sizer->Add( p_dummy, 0, wxEXPAND );
232
233     /* Creation of the menu bar */
234     CreateOurMenuBar();
235
236     /* Creation of the tool bar */
237     CreateOurToolBar();
238
239     /* Creation of the slider sub-window */
240     CreateOurSlider();
241     frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
242     frame_sizer->Hide( slider_frame );
243
244     /* Create the extra panel */
245     CreateOurExtraPanel();
246     frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
247     frame_sizer->Hide( extra_frame );
248
249     /* Creation of the status bar
250      * Helptext for menu items and toolbar tools will automatically get
251      * displayed here. */
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 );
256
257     /* Make sure we've got the right background colour */
258     SetBackgroundColour( slider_frame->GetBackgroundColour() );
259
260     /* Layout everything */
261     frame_sizer->Layout();
262     frame_sizer->Fit(this);
263
264 #if !defined(__WXX11__)
265     /* Associate drop targets with the main interface */
266     SetDropTarget( new DragAndDrop( p_intf ) );
267 #endif
268
269     UpdateAcceleratorTable();
270
271     /* Start timer */
272     timer = new Timer( p_intf, this );
273 }
274
275 Interface::~Interface()
276 {
277     if( p_intf->p_sys->p_wxwindow )
278     {
279         delete p_intf->p_sys->p_wxwindow;
280     }
281
282     /* Clean up */
283     delete timer;
284 }
285
286 /*****************************************************************************
287  * Private methods.
288  *****************************************************************************/
289 void Interface::CreateOurMenuBar()
290 {
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")
299
300 #define HELP_STREAMWIZARD N_("Open the streaming wizard")
301 #define HELP_OTHER N_("Open other types of inputs")
302
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")
306
307 #define HELP_PREFS N_("Go to the preferences menu")
308 #define EXTRA_PREFS N_("Shows the extended GUI")
309
310 #define HELP_ABOUT N_("About this program")
311
312     /* Create the "File" menu */
313     wxMenu *file_menu = new wxMenu;
314     file_menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open ...")),
315                        wxU(_(HELP_SIMPLE)) );
316
317     file_menu->AppendSeparator();
318     file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
319                       wxU(_(HELP_FILE)));
320     file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
321                       wxU(_(HELP_DISC)));
322     file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
323                       wxU(_(HELP_NET)));
324
325 #if 0
326     file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
327                        wxU(_(HELP_NET)) );
328 #endif
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)) );
334
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)) );
342
343     /* Create the "Settings" menu */
344     p_settings_menu = new wxMenu;
345     b_settings_menu = 1;
346
347     /* Create the "Audio" menu */
348     p_audio_menu = new wxMenu;
349     b_audio_menu = 1;
350
351     /* Create the "Video" menu */
352     p_video_menu = new wxMenu;
353     b_video_menu = 1;
354
355     /* Create the "Navigation" menu */
356     p_navig_menu = new wxMenu;
357     b_navig_menu = 1;
358
359     /* Create the "Help" menu */
360     wxMenu *help_menu = new wxMenu;
361     help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
362
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")) );
372
373     /* Attach the menu bar to the frame */
374     SetMenuBar( menubar );
375
376     /* Intercept all menu events in our custom event handler */
377     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
378
379 #if !defined(__WXX11__)
380     /* Associate drop targets with the menubar */
381     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
382 #endif
383 }
384
385 void Interface::CreateOurToolBar()
386 {
387 #define HELP_STOP N_("Stop current playlist item")
388
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")
396
397     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
398                          * version because we don't include wx.rc */
399
400     wxToolBar *toolbar =
401         CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
402
403     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
404
405     toolbar->AddTool( OpenFileSimple_Event, wxU(_("Quick")),
406                       wxBitmap( file_xpm ), wxU(_(HELP_SIMPLE)) );
407
408     toolbar->AddSeparator();
409     toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
410                       wxU(_(HELP_FILE)) );
411     toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
412                       wxU(_(HELP_DISC)) );
413     toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
414                       wxU(_(HELP_NET)) );
415     toolbar->AddSeparator();
416
417     toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
418                       wxU(_(HELP_STOP)) );
419     toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
420                       wxU(_(HELP_PLAY)) );
421
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 ),
428                       wxU(_(HELP_PLN)) );
429     toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
430                       wxU(_(HELP_SLOW)) );
431     toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
432                       wxU(_(HELP_FAST)) );
433
434     toolbar->Realize();
435
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();
441
442 #ifndef WIN32
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 );
446 #endif
447
448 #if !defined(__WXX11__)
449     /* Associate drop targets with the toolbar */
450     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
451 #endif
452 }
453
454 void Interface::CreateOurSlider()
455 {
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 );
461
462     /* Create static box to surround the slider */
463     slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
464
465     /* Create sizer for slider frame */
466     wxStaticBoxSizer *slider_sizer =
467         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
468     slider_sizer->SetMinSize( -1, 50 );
469
470     /* Create slider */
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 );
474
475
476     volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
477
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);
484
485     /* Hide the slider by default */
486     slider_frame->Hide();
487 }
488
489
490 void Interface::CreateOurExtraPanel()
491 {
492     char *psz_filters;
493
494     extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
495     extra_frame->SetAutoLayout( TRUE );
496     wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
497
498     /* Create static box to surround the adjust controls */
499     wxStaticBox *adjust_box =
500            new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) );
501
502     /* Create the size for the frame */
503     wxStaticBoxSizer *adjust_sizer =
504         new wxStaticBoxSizer( adjust_box, wxVERTICAL );
505     adjust_sizer->SetMinSize( -1, 50 );
506
507     /* Create every controls */
508
509     /* Create the adjust button */
510     wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
511                                                  wxU(_("Enable")));
512
513
514     wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
515     wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
516                                        wxU(_("Hue")) );
517     hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
518                                 360, wxDefaultPosition, wxDefaultSize );
519
520     hue_sizer->Add(hue_text,1, 0 ,0);
521     hue_sizer->Add(hue_slider,1, 0 ,0);
522     hue_sizer->Layout();
523
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();
532
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();
541
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();
550
551     wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
552     wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
553                                           wxU(_("Gamma")) );
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();
559
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);
566
567     extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
568
569     /* Create sizer to surround the other controls */
570     wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
571
572
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 );
579
580     static const wxString ratio_array[] =
581     {
582         wxT("4:3"),
583         wxT("16:9"),
584     };
585
586     wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
587     wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
588                                           wxU(_("Ratio")) );
589
590     ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
591                                   wxDefaultPosition, wxSize(120,-1),
592                                   WXSIZEOF(ratio_array), ratio_array,
593                                   0 );
594
595     ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
596     ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
597     ratio_sizer->Layout();
598
599     video_sizer->Add( ratio_sizer  , 0 , wxALL , 0 );
600     video_sizer->Layout();
601
602 #if 0
603     wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
604
605     wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
606                                             wxU(_("Visualisation")) );
607
608     visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
609     visual_sizer->Layout();
610
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 );
617
618     audio_sizer->Add( visual_sizer, 0, wxALL, 0);
619     audio_sizer->Layout();
620
621     other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
622 #endif
623     other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
624     other_sizer->Layout();
625
626     extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
627
628     extra_frame->SetSizer( extra_sizer );
629
630     /* Layout the whole panel */
631     extra_sizer->Layout();
632
633     extra_sizer->SetSizeHints(extra_frame);
634
635     /* Write down initial values */
636 #if 0
637     psz_filters = config_GetPsz( p_intf, "audio-filter" );
638     if( psz_filters && strstr( psz_filters, "visual" ) )
639     {
640         visual_checkbox->SetValue(1);
641     }
642     if( psz_filters ) free( psz_filters );
643 #endif
644     psz_filters = config_GetPsz( p_intf, "filter" );
645     if( psz_filters && strstr( psz_filters, "adjust" ) )
646     {
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();
653     }
654     else
655     {
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();
662     }
663     if( psz_filters ) free( psz_filters );
664
665     int i_value = config_GetInt( p_intf, "hue" );
666     if( i_value > 0 && i_value < 360 )
667         hue_slider->SetValue( i_value );
668
669     float f_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) );
682
683     extra_frame->Hide();
684 }
685
686 void Interface::UpdateAcceleratorTable()
687 {
688     /* Set some hotkeys */
689     wxAcceleratorEntry entries[7];
690     vlc_value_t val;
691     int i = 0;
692
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 );
714
715     wxAcceleratorTable accel( 7, entries );
716
717     if( !accel.Ok() )
718         msg_Err( p_intf, "invalid accelerator table" );
719
720     SetAcceleratorTable( accel );
721     msg_Dbg( p_intf, "accelerator table loaded" );
722
723 }
724
725 /*****************************************************************************
726  * Event Handlers.
727  *****************************************************************************/
728 /* Work-around helper for buggy wxGTK */
729 void RecursiveDestroy( wxMenu *menu )
730 {
731     wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
732     for( ; node; )
733     {
734         wxMenuItem *item = node->GetData();
735         node = node->GetNext();
736
737         /* Delete the submenus */
738         wxMenu *submenu = item->GetSubMenu();
739         if( submenu )
740         {
741             RecursiveDestroy( submenu );
742         }
743         menu->Delete( item );
744     }
745 }
746
747 void Interface::OnMenuOpen(wxMenuEvent& event)
748 {
749 #if !defined( __WXMSW__ )
750     if( event.GetEventObject() == p_settings_menu )
751     {
752         if( b_settings_menu )
753         {
754             p_settings_menu = SettingsMenu( p_intf, this );
755
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)) );
761
762             /* Work-around for buggy wxGTK */
763             wxMenu *menu = GetMenuBar()->GetMenu( 2 );
764             RecursiveDestroy( menu );
765             /* End work-around */
766
767             menu = GetMenuBar()->Replace( 2, p_settings_menu,
768                                           wxU(_("&Settings")));
769             if( menu ) delete menu;
770
771             b_settings_menu = 0;
772         }
773         else b_settings_menu = 1;
774     }
775     else if( event.GetEventObject() == p_audio_menu )
776     {
777         if( b_audio_menu )
778         {
779             p_audio_menu = AudioMenu( p_intf, this );
780
781             /* Work-around for buggy wxGTK */
782             wxMenu *menu = GetMenuBar()->GetMenu( 3 );
783             RecursiveDestroy( menu );
784             /* End work-around */
785
786             menu =
787                 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
788             if( menu ) delete menu;
789
790             b_audio_menu = 0;
791         }
792         else b_audio_menu = 1;
793     }
794     else if( event.GetEventObject() == p_video_menu )
795     {
796         if( b_video_menu )
797         {
798             p_video_menu = VideoMenu( p_intf, this );
799
800             /* Work-around for buggy wxGTK */
801             wxMenu *menu = GetMenuBar()->GetMenu( 4 );
802             RecursiveDestroy( menu );
803             /* End work-around */
804
805             menu =
806                 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
807             if( menu ) delete menu;
808
809             b_video_menu = 0;
810         }
811         else b_video_menu = 1;
812     }
813     else if( event.GetEventObject() == p_navig_menu )
814     {
815         if( b_navig_menu )
816         {
817             p_navig_menu = NavigMenu( p_intf, this );
818
819             /* Work-around for buggy wxGTK */
820             wxMenu *menu = GetMenuBar()->GetMenu( 5 );
821             RecursiveDestroy( menu );
822             /* End work-around */
823
824             menu =
825                 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
826             if( menu ) delete menu;
827
828             b_navig_menu = 0;
829         }
830         else b_navig_menu = 1;
831     }
832
833 #else
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)) );
840     wxMenu *menu =
841         GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
842     if( menu ) delete menu;
843
844     p_audio_menu = AudioMenu( p_intf, this );
845     menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
846     if( menu ) delete menu;
847
848     p_video_menu = VideoMenu( p_intf, this );
849     menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
850     if( menu ) delete menu;
851
852     p_navig_menu = NavigMenu( p_intf, this );
853     menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
854     if( menu ) delete menu;
855 #endif
856
857 }
858
859 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
860 void Interface::OnContextMenu2(wxContextMenuEvent& event)
861 {
862     /* Only show the context menu for the main interface */
863     if( GetId() != event.GetId() )
864     {
865         event.Skip();
866         return;
867     }
868
869     if( p_intf->p_sys->pf_show_dialog )
870         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
871 }
872 #endif
873 void Interface::OnContextMenu(wxMouseEvent& event)
874 {
875     if( p_intf->p_sys->pf_show_dialog )
876         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
877 }
878
879 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
880 {
881     /* TRUE is to force the frame to close. */
882     Close(TRUE);
883 }
884
885 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
886 {
887     wxString msg;
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")) );
894
895     wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
896                   wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
897 }
898
899 void Interface::OnShowDialog( wxCommandEvent& event )
900 {
901     if( p_intf->p_sys->pf_show_dialog )
902     {
903         int i_id;
904
905         switch( event.GetId() )
906         {
907         case OpenFileSimple_Event:
908             i_id = INTF_DIALOG_FILE_SIMPLE;
909             break;
910         case OpenAdv_Event:
911             i_id = INTF_DIALOG_FILE;
912         case OpenFile_Event:
913             i_id = INTF_DIALOG_FILE;
914             break;
915         case OpenDisc_Event:
916             i_id = INTF_DIALOG_DISC;
917             break;
918         case OpenNet_Event:
919             i_id = INTF_DIALOG_NET;
920             break;
921         case OpenSat_Event:
922             i_id = INTF_DIALOG_SAT;
923             break;
924         case Playlist_Event:
925             i_id = INTF_DIALOG_PLAYLIST;
926             break;
927         case Logs_Event:
928             i_id = INTF_DIALOG_MESSAGES;
929             break;
930         case FileInfo_Event:
931             i_id = INTF_DIALOG_FILEINFO;
932             break;
933         case Prefs_Event:
934             i_id = INTF_DIALOG_PREFS;
935             break;
936         default:
937             i_id = INTF_DIALOG_FILE;
938             break;
939
940         }
941
942         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
943     }
944 }
945
946
947 void Interface::OnStream( wxCommandEvent& event )
948 {
949     StreamDialog *p_stream_dialog = new StreamDialog(p_intf,this);
950     p_stream_dialog->Show();
951 }
952
953
954 void Interface::OnExtra(wxCommandEvent& event)
955 {
956     if( b_extra == VLC_FALSE)
957     {
958         extra_frame->Show();
959         frame_sizer->Show( extra_frame );
960         b_extra = VLC_TRUE;
961     }
962     else
963     {
964         extra_frame->Hide();
965         frame_sizer->Hide( extra_frame );
966         b_extra = VLC_FALSE;
967     }
968     frame_sizer->Layout();
969     frame_sizer->Fit(this);
970 }
971
972 void Interface::OnEnableAdjust(wxCommandEvent& event)
973 {
974     char *psz_filters=config_GetPsz( p_intf, "filter");
975     char *psz_new = NULL;
976     if( event.IsChecked() )
977     {
978         if(psz_filters == NULL)
979         {
980             psz_new = strdup( "adjust" );
981         }
982         else
983         {
984             psz_new= (char *) malloc(strlen(psz_filters) + 8 );
985             sprintf( psz_new, "%s:adjust", psz_filters);
986         }
987         config_PutPsz( p_intf, "filter", psz_new );
988         vlc_value_t val;
989         vout_thread_t *p_vout =
990            (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
991                                        FIND_ANYWHERE );
992         if( p_vout != NULL )
993         {
994             val.psz_string = strdup( psz_new );
995             var_Set( p_vout, "filter", val);
996             vlc_object_release( p_vout );
997         }
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();
1004     }
1005     else
1006     {
1007         if( psz_filters != NULL )
1008         {
1009
1010             char *psz_current;
1011             unsigned int i=0;
1012             for( i = 0; i< strlen(psz_filters ); i++)
1013             {
1014                 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1015                 {
1016                     if(i > 0)
1017                         if( psz_filters[i-1] == ':' ) i--;
1018                     psz_current = strchr( &psz_filters[i+1] , ':' );
1019                     if( !psz_current )
1020                         psz_filters[i] = '\0';
1021                     else
1022                     {
1023                        memmove( &psz_filters[i] , psz_current,
1024                                 &psz_filters[strlen(psz_filters)]-psz_current
1025                                 +1);
1026                     }
1027                 }
1028             }
1029             config_PutPsz( p_intf, "filter", psz_filters);
1030             vlc_value_t val;
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,
1034                                        FIND_ANYWHERE );
1035             if( p_vout != NULL )
1036             {
1037                 var_Set( p_vout, "filter", val);
1038                 vlc_object_release( p_vout );
1039             }
1040             if( val.psz_string ) free( val.psz_string );
1041         }
1042         brightness_slider->Disable();
1043         saturation_slider->Disable();
1044         contrast_slider->Disable();
1045         hue_slider->Disable();
1046         gamma_slider->Disable();
1047     }
1048     if(psz_filters) free(psz_filters);
1049     if(psz_new) free(psz_new);
1050 }
1051
1052 void Interface::OnHueUpdate( wxScrollEvent& event)
1053 {
1054    config_PutInt( p_intf , "hue" , event.GetPosition() );
1055 }
1056
1057 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1058 {
1059    config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1060 }
1061
1062 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1063 {
1064    config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1065 }
1066
1067 void Interface::OnContrastUpdate(wxScrollEvent& event)
1068 {
1069    config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1070
1071 }
1072
1073 void Interface::OnGammaUpdate(wxScrollEvent& event)
1074 {
1075     config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
1076 }
1077
1078 void Interface::OnRatio( wxCommandEvent& event )
1079 {
1080    config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1081 }
1082
1083 void Interface::OnEnableVisual(wxCommandEvent& event)
1084 {
1085     if( event.IsChecked() )
1086     {
1087         config_PutPsz( p_intf, "audio-filter", "visual" );
1088     }
1089     else
1090     {
1091         config_PutPsz( p_intf, "audio-filter", "" );
1092     }
1093 }
1094
1095 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1096 {
1097     wxCommandEvent dummy;
1098     playlist_t *p_playlist =
1099         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1100                                        FIND_ANYWHERE );
1101     if( p_playlist == NULL ) return;
1102
1103     if( p_playlist->i_size && p_playlist->i_enabled )
1104     {
1105         vlc_value_t state;
1106
1107         input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1108                                                        VLC_OBJECT_INPUT,
1109                                                        FIND_ANYWHERE );
1110         if( p_input == NULL )
1111         {
1112             /* No stream was playing, start one */
1113             playlist_Play( p_playlist );
1114             TogglePlayButton( PLAYING_S );
1115             vlc_object_release( p_playlist );
1116             return;
1117         }
1118
1119         var_Get( p_input, "state", &state );
1120
1121         if( state.i_int != PAUSE_S )
1122         {
1123             /* A stream is being played, pause it */
1124             state.i_int = PAUSE_S;
1125         }
1126         else
1127         {
1128             /* Stream is paused, resume it */
1129             state.i_int = PLAYING_S;
1130         }
1131         var_Set( p_input, "state", state );
1132
1133         TogglePlayButton( state.i_int );
1134         vlc_object_release( p_input );
1135         vlc_object_release( p_playlist );
1136     }
1137     else
1138     {
1139         /* If the playlist is empty, open a file requester instead */
1140         vlc_object_release( p_playlist );
1141         OnShowDialog( dummy );
1142     }
1143 }
1144
1145 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1146 {
1147     playlist_t * p_playlist =
1148         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1149                                        FIND_ANYWHERE );
1150     if( p_playlist == NULL )
1151     {
1152         return;
1153     }
1154
1155     playlist_Stop( p_playlist );
1156     TogglePlayButton( PAUSE_S );
1157     vlc_object_release( p_playlist );
1158 }
1159
1160 void Interface::OnSliderUpdate( wxScrollEvent& event )
1161 {
1162     vlc_mutex_lock( &p_intf->change_lock );
1163
1164 #ifdef WIN32
1165     if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1166         || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1167     {
1168 #endif
1169         if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1170             && p_intf->p_sys->p_input )
1171         {
1172             vlc_value_t pos;
1173             pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1174
1175             var_Set( p_intf->p_sys->p_input, "position", pos );
1176         }
1177
1178 #ifdef WIN32
1179         p_intf->p_sys->b_slider_free = VLC_TRUE;
1180     }
1181     else
1182     {
1183         p_intf->p_sys->b_slider_free = VLC_FALSE;
1184
1185         if( p_intf->p_sys->p_input )
1186         {
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 ];
1190
1191             slider_box->SetLabel(
1192                 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1193                                         psz_time,
1194                                         p_area->i_size * event.GetPosition()
1195                                         / SLIDER_MAX_POS )) );
1196 #undef p_area
1197         }
1198     }
1199 #endif
1200
1201 #undef WIN32
1202     vlc_mutex_unlock( &p_intf->change_lock );
1203 }
1204
1205 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1206 {
1207     playlist_t * p_playlist =
1208         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1209                                        FIND_ANYWHERE );
1210     if( p_playlist == NULL )
1211     {
1212         return;
1213     }
1214
1215     vlc_mutex_lock( &p_playlist->object_lock );
1216     if( p_playlist->p_input != NULL )
1217     {
1218         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1219         if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1220         {
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 );
1224         } else
1225             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1226     }
1227     vlc_mutex_unlock( &p_playlist->object_lock );
1228
1229     playlist_Prev( p_playlist );
1230     vlc_object_release( p_playlist );
1231 }
1232
1233 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1234 {
1235     playlist_t * p_playlist =
1236         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1237                                        FIND_ANYWHERE );
1238     if( p_playlist == NULL )
1239     {
1240         return;
1241     }
1242
1243     vlc_mutex_lock( &p_playlist->object_lock );
1244     if( p_playlist->p_input != NULL )
1245     {
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 )
1250         {
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 );
1254         } else
1255             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1256     }
1257     vlc_mutex_unlock( &p_playlist->object_lock );
1258
1259     playlist_Next( p_playlist );
1260     vlc_object_release( p_playlist );
1261 }
1262
1263 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1264 {
1265     input_thread_t *p_input =
1266         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1267                                            FIND_ANYWHERE );
1268     if( p_input )
1269     {
1270         vlc_value_t val; val.b_bool = VLC_TRUE;
1271
1272         var_Set( p_input, "rate-slower", val );
1273         vlc_object_release( p_input );
1274     }
1275 }
1276
1277 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1278 {
1279     input_thread_t *p_input =
1280         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1281                                            FIND_ANYWHERE );
1282     if( p_input )
1283     {
1284         vlc_value_t val; val.b_bool = VLC_TRUE;
1285
1286         var_Set( p_input, "rate-faster", val );
1287         vlc_object_release( p_input );
1288     }
1289 }
1290
1291 void Interface::TogglePlayButton( int i_playing_status )
1292 {
1293     if( i_playing_status == i_old_playing_status )
1294         return;
1295
1296     GetToolBar()->DeleteTool( PlayStream_Event );
1297
1298     if( i_playing_status == PLAYING_S )
1299     {
1300         GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")),
1301                                   wxBitmap( pause_xpm ), wxNullBitmap,
1302                                   wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1303     }
1304     else
1305     {
1306         GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")),
1307                                   wxBitmap( play_xpm ), wxNullBitmap,
1308                                   wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1309     }
1310
1311     GetToolBar()->Realize();
1312
1313     i_old_playing_status = i_playing_status;
1314 }
1315
1316 #if !defined(__WXX11__)
1317 /*****************************************************************************
1318  * Definition of DragAndDrop class.
1319  *****************************************************************************/
1320 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1321 {
1322     p_intf = _p_intf;
1323     b_enqueue = _b_enqueue;
1324 }
1325
1326 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1327                                const wxArrayString& filenames )
1328 {
1329     /* Add dropped files to the playlist */
1330
1331     playlist_t *p_playlist =
1332         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1333                                        FIND_ANYWHERE );
1334     if( p_playlist == NULL )
1335     {
1336         return FALSE;
1337     }
1338
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),
1343                       PLAYLIST_END );
1344
1345     vlc_object_release( p_playlist );
1346
1347     return TRUE;
1348 }
1349 #endif
1350
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 )
1357 {
1358     p_intf = _p_intf;
1359 }
1360
1361 void wxVolCtrl::OnChange( wxMouseEvent& event )
1362 {
1363     if( !event.LeftDown() && !event.LeftIsDown() ) return;
1364
1365     int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
1366                     GetClientSize().GetHeight();
1367     Change( i_volume );
1368 }
1369
1370 void wxVolCtrl::Change( int i_volume )
1371 {
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"),
1375                 i_volume ) );
1376 }