]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/interface.cpp
d7ef388cceafb06475b86c955427a47265b556f9
[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.74 2003/12/03 04:19:59 rocky 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 <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33 #include <vlc/aout.h>
34 #include <vlc/vout.h>
35 #include <vlc/intf.h>
36 #include "stream_control.h"
37
38 #include "wxwindows.h"
39
40 /* include the toolbar graphics */
41 #include "bitmaps/file.xpm"
42
43 #include "bitmaps/disc.xpm"
44 #include "bitmaps/net.xpm"
45 #if 0
46  #include "bitmaps/sat.xpm"
47 #endif
48 #include "bitmaps/play.xpm"
49 #include "bitmaps/pause.xpm"
50 #include "bitmaps/stop.xpm"
51 #include "bitmaps/previous.xpm"
52 #include "bitmaps/next.xpm"
53 #include "bitmaps/playlist.xpm"
54 #include "bitmaps/fast.xpm"
55 #include "bitmaps/slow.xpm"
56
57 #include <wx/listctrl.h>
58
59 #define TOOLBAR_BMP_WIDTH 36
60 #define TOOLBAR_BMP_HEIGHT 36
61
62 /* include the icon graphic */
63 #include "../../../share/vlc32x32.xpm"
64
65 /*****************************************************************************
66  * Local class declarations.
67  *****************************************************************************/
68 class wxMenuExt: public wxMenu
69 {
70 public:
71     /* Constructor */
72     wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
73                    const wxString& helpString, wxItemKind kind,
74                    char *_psz_var, int _i_object_id, vlc_value_t _val,
75                    int _i_val_type );
76
77     virtual ~wxMenuExt() {};
78
79     char *psz_var;
80     int  i_val_type;
81     int  i_object_id;
82     vlc_value_t val;
83
84 private:
85
86 };
87
88 class wxVolCtrl: public wxGauge
89 {
90 public:
91     /* Constructor */
92     wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
93     virtual ~wxVolCtrl() {};
94
95     void Change( int i_volume );
96
97     void OnChange( wxMouseEvent& event );
98
99 private:
100     intf_thread_t *p_intf;
101
102     DECLARE_EVENT_TABLE();
103 };
104
105 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
106     /* Mouse events */
107     EVT_LEFT_DOWN(wxVolCtrl::OnChange)
108     EVT_MOTION(wxVolCtrl::OnChange)
109 END_EVENT_TABLE()
110
111 /*****************************************************************************
112  * Event Table.
113  *****************************************************************************/
114
115 /* IDs for the controls and the menu commands */
116 enum
117 {
118     /* menu items */
119     MenuDummy_Event = wxID_HIGHEST + 1000,
120     Exit_Event = wxID_HIGHEST,
121     OpenFileSimple_Event,
122     OpenAdv_Event,
123     OpenFile_Event,
124     OpenDisc_Event,
125     OpenNet_Event,
126     OpenSat_Event,
127     OpenOther_Event,
128     EjectDisc_Event,
129
130     Stream_Event,
131
132     Playlist_Event,
133     Logs_Event,
134     FileInfo_Event,
135
136     Prefs_Event,
137     Extra_Event,
138     Skins_Event,
139
140     SliderScroll_Event,
141     StopStream_Event,
142     PlayStream_Event,
143     PrevStream_Event,
144     NextStream_Event,
145     SlowStream_Event,
146     FastStream_Event,
147
148     Adjust_Event,
149     Hue_Event,
150     Contrast_Event,
151     Brightness_Event,
152     Saturation_Event,
153
154     Ratio_Event,
155     Visual_Event,
156
157     /* it is important for the id corresponding to the "About" command to have
158      * this standard value as otherwise it won't be handled properly under Mac
159      * (where it is special and put into the "Apple" menu) */
160     About_Event = wxID_ABOUT
161 };
162
163 BEGIN_EVENT_TABLE(Interface, wxFrame)
164     /* Menu events */
165     EVT_MENU(Exit_Event, Interface::OnExit)
166     EVT_MENU(About_Event, Interface::OnAbout)
167
168     EVT_MENU(Playlist_Event, Interface::OnShowDialog)
169     EVT_MENU(Logs_Event, Interface::OnShowDialog)
170     EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
171     EVT_MENU(Prefs_Event, Interface::OnShowDialog)
172
173     EVT_MENU_OPEN(Interface::OnMenuOpen)
174
175     EVT_MENU( Extra_Event, Interface::OnExtra)
176     EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
177
178     EVT_COMBOBOX( Ratio_Event, Interface::OnRatio)
179     EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
180
181 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
182     EVT_CONTEXT_MENU(Interface::OnContextMenu2)
183 #endif
184     EVT_RIGHT_UP(Interface::OnContextMenu)
185
186     /* Toolbar events */
187     EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
188     EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
189     EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
190     EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
191     EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
192     EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
193     EVT_MENU(Stream_Event, Interface::OnStream)
194     EVT_MENU(StopStream_Event, Interface::OnStopStream)
195     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
196     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
197     EVT_MENU(NextStream_Event, Interface::OnNextStream)
198     EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
199     EVT_MENU(FastStream_Event, Interface::OnFastStream)
200
201     /* Slider events */
202     EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
203
204     EVT_COMMAND_SCROLL(Hue_Event, Interface::OnHueUpdate)
205     EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
206     EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
207     EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
208
209 END_EVENT_TABLE()
210
211 /*****************************************************************************
212  * Constructor.
213  *****************************************************************************/
214 Interface::Interface( intf_thread_t *_p_intf ):
215     wxFrame( NULL, -1, wxT("VLC media player"),
216              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
217 {
218     /* Initializations */
219     p_intf = _p_intf;
220     i_old_playing_status = PAUSE_S;
221     b_extra = VLC_FALSE;
222
223     /* Give our interface a nice little icon */
224     SetIcon( wxIcon( vlc_xpm ) );
225
226     /* Create a sizer for the main frame */
227     frame_sizer = new wxBoxSizer( wxVERTICAL );
228     SetSizer( frame_sizer );
229
230     /* Create a dummy widget that can get the keyboard focus */
231     wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
232                                       wxSize(0,0) );
233     p_dummy->SetFocus();
234     frame_sizer->Add( p_dummy );
235
236     /* Creation of the menu bar */
237     CreateOurMenuBar();
238
239     /* Creation of the tool bar */
240     CreateOurToolBar();
241
242     /* Creation of the slider sub-window */
243     CreateOurSlider();
244     frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
245     frame_sizer->Hide( slider_frame );
246
247     /* Create the extra panel */
248     CreateOurExtraPanel();
249     frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
250     frame_sizer->Hide( extra_frame );
251
252     /* Creation of the status bar
253      * Helptext for menu items and toolbar tools will automatically get
254      * displayed here. */
255     int i_status_width[3] = {-6, -2, -9};
256     statusbar = CreateStatusBar( 3 );                            /* 2 fields */
257     statusbar->SetStatusWidths( 3, i_status_width );
258     statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
259
260     /* Make sure we've got the right background colour */
261     SetBackgroundColour( slider_frame->GetBackgroundColour() );
262
263     /* Layout everything */
264     SetAutoLayout( TRUE );
265     frame_sizer->Layout();
266     frame_sizer->Fit(this);
267
268 #if !defined(__WXX11__)
269     /* Associate drop targets with the main interface */
270     SetDropTarget( new DragAndDrop( p_intf ) );
271 #endif
272
273     UpdateAcceleratorTable();
274
275     /* Start timer */
276     timer = new Timer( p_intf, this );
277 }
278
279 Interface::~Interface()
280 {
281     if( p_intf->p_sys->p_wxwindow )
282     {
283         delete p_intf->p_sys->p_wxwindow;
284     }
285
286     /* Clean up */
287     delete timer;
288 }
289
290 /*****************************************************************************
291  * Private methods.
292  *****************************************************************************/
293 void Interface::CreateOurMenuBar()
294 {
295 #define HELP_SIMPLE N_("Quick file open")
296 #define HELP_ADV N_("Advanced open")
297 #define HELP_FILE  N_("Open a file")
298 #define HELP_DISC  N_("Open a DVD or (S)VCD")
299 #define HELP_NET   N_("Open a network stream")
300 #define HELP_SAT   N_("Open a satellite stream")
301 #define HELP_EJECT N_("Eject the DVD/CD")
302 #define HELP_EXIT  N_("Exit this program")
303
304 #define HELP_STREAMWIZARD N_("Open the streaming wizard")
305 #define HELP_OTHER N_("Open other types of inputs")
306
307 #define HELP_PLAYLIST   N_("Open the playlist")
308 #define HELP_LOGS       N_("Show the program logs")
309 #define HELP_FILEINFO       N_("Show information about the file being played")
310
311 #define HELP_PREFS N_("Go to the preferences menu")
312 #define EXTRA_PREFS N_("Shows the extended GUI")
313
314 #define HELP_ABOUT N_("About this program")
315
316     /* Create the "File" menu */
317     wxMenu *file_menu = new wxMenu;
318     file_menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open ...")),
319                        wxU(_(HELP_SIMPLE)) );
320
321     file_menu->AppendSeparator();
322     file_menu->Append( OpenFile_Event, wxU(_("Open &File...")),
323                       wxU(_(HELP_FILE)));
324     file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
325                       wxU(_(HELP_DISC)));
326     file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")),
327                       wxU(_(HELP_NET)));
328
329 #if 0
330     file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")),
331                        wxU(_(HELP_NET)) );
332 #endif
333     file_menu->AppendSeparator();
334     file_menu->Append( Stream_Event, wxU(_("Streaming Wizard...")),
335                        wxU(_(HELP_STREAMWIZARD)) );
336     file_menu->AppendSeparator();
337     file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
338
339     /* Create the "View" menu */
340     wxMenu *view_menu = new wxMenu;
341     view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
342                        wxU(_(HELP_PLAYLIST)) );
343     view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
344     view_menu->Append( FileInfo_Event, wxU(_("&Stream and Media info...")),
345                        wxU(_(HELP_FILEINFO)) );
346
347     /* Create the "Settings" menu */
348     p_settings_menu = new wxMenu;
349     b_settings_menu = 1;
350
351     /* Create the "Audio" menu */
352     p_audio_menu = new wxMenu;
353     b_audio_menu = 1;
354
355     /* Create the "Video" menu */
356     p_video_menu = new wxMenu;
357     b_video_menu = 1;
358
359     /* Create the "Navigation" menu */
360     p_navig_menu = new wxMenu;
361     b_navig_menu = 1;
362
363     /* Create the "Help" menu */
364     wxMenu *help_menu = new wxMenu;
365     help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
366
367     /* Append the freshly created menus to the menu bar... */
368     wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
369     menubar->Append( file_menu, wxU(_("&File")) );
370     menubar->Append( view_menu, wxU(_("&View")) );
371     menubar->Append( p_settings_menu, wxU(_("&Settings")) );
372     menubar->Append( p_audio_menu, wxU(_("&Audio")) );
373     menubar->Append( p_video_menu, wxU(_("&Video")) );
374     menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
375     menubar->Append( help_menu, wxU(_("&Help")) );
376
377     /* Attach the menu bar to the frame */
378     SetMenuBar( menubar );
379
380     /* Intercept all menu events in our custom event handler */
381     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
382
383 #if !defined(__WXX11__)
384     /* Associate drop targets with the menubar */
385     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
386 #endif
387 }
388
389 void Interface::CreateOurToolBar()
390 {
391 #define HELP_STOP N_("Stop current playlist item")
392
393 #define HELP_PLAY N_("Play current playlist item")
394 #define HELP_PAUSE N_("Pause current playlist item")
395 #define HELP_PLO N_("Open playlist")
396 #define HELP_PLP N_("Previous playlist item")
397 #define HELP_PLN N_("Next playlist item")
398 #define HELP_SLOW N_("Play slower")
399 #define HELP_FAST N_("Play faster")
400
401     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
402                          * version because we don't include wx.rc */
403
404     wxToolBar *toolbar = CreateToolBar(
405                                        wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
406
407     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
408
409     toolbar->AddTool( OpenFileSimple_Event, wxU(_("Quick")),
410                       wxBitmap( file_xpm ), wxU(_(HELP_SIMPLE)) );
411
412     toolbar->AddSeparator();
413
414     toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
415                       wxU(_(HELP_FILE)) );
416     toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
417                       wxU(_(HELP_DISC)) );
418     toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
419                       wxU(_(HELP_NET)) );
420 #if 0
421     toolbar->AddTool( OpenSat_Event, wxU(_("Sat")), wxBitmap( sat_xpm ),
422                       wxU(_(HELP_SAT)) );
423 #endif
424     toolbar->AddSeparator();
425
426     toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
427                       wxU(_(HELP_STOP)) );
428     toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
429                       wxU(_(HELP_PLAY)) );
430     toolbar->AddSeparator();
431     toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
432                       wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
433     toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
434                       wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
435     toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
436                       wxU(_(HELP_PLN)) );
437     toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
438                       wxU(_(HELP_SLOW)) );
439     toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
440                       wxU(_(HELP_FAST)) );
441
442     toolbar->Realize();
443
444     /* Place the toolbar in a sizer, so we can calculate the width of the
445      * toolbar and set this as the minimum for the main frame size. */
446     wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
447     toolbar_sizer->Add( toolbar, 0, 0, 0 );
448
449     toolbar_sizer->Layout();
450
451 #ifndef WIN32
452     frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
453 #else
454     frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
455                              toolbar->GetToolsCount(), -1 );
456 #endif
457
458 #if !defined(__WXX11__)
459     /* Associate drop targets with the toolbar */
460     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
461 #endif
462 }
463
464 void Interface::CreateOurSlider()
465 {
466     /* Create a new frame and sizer containing the slider */
467     slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
468     slider_frame->SetAutoLayout( TRUE );
469     wxBoxSizer *frame_sizer =
470         new wxBoxSizer( wxHORIZONTAL );
471
472     /* Create static box to surround the slider */
473     slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
474
475     /* Create sizer for slider frame */
476     wxStaticBoxSizer *slider_sizer =
477         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
478     slider_sizer->SetMinSize( -1, 50 );
479
480     /* Create slider */
481     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
482                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
483     slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
484
485
486     volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
487
488     /* Add everything to the frame */
489     frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
490     frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
491     slider_frame->SetSizer( frame_sizer );
492     frame_sizer->Layout();
493     frame_sizer->SetSizeHints(slider_frame);
494
495     /* Hide the slider by default */
496     slider_frame->Hide();
497 }
498
499
500 void Interface::CreateOurExtraPanel()
501 {
502     char *psz_filters;
503
504     extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
505     extra_frame->SetAutoLayout( TRUE );
506     wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
507
508     /* Create static box to surround the adjust controls */
509     wxStaticBox *adjust_box =
510            new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) );
511
512     /* Create the size for the frame */
513     wxStaticBoxSizer *adjust_sizer =
514         new wxStaticBoxSizer( adjust_box, wxVERTICAL );
515     adjust_sizer->SetMinSize( -1, 50 );
516
517     /* Create every controls */
518
519     /* Create the adjust button */
520     wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
521                                                  wxU(_("Enable")));
522
523
524     wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
525     wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
526                                        wxU(_("Hue")) );
527     hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
528                                 360, wxDefaultPosition, wxDefaultSize );
529
530     hue_sizer->Add(hue_text,1, 0 ,0);
531     hue_sizer->Add(hue_slider,1, 0 ,0);
532     hue_sizer->Layout();
533
534     wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
535     wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
536                                        wxU(_("Contrast")) );
537     contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
538                                 200, wxDefaultPosition, wxDefaultSize);
539     contrast_sizer->Add(contrast_text,1, 0 ,0);
540     contrast_sizer->Add(contrast_slider,1, 0 ,0);
541     contrast_sizer->Layout();
542
543     wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
544     wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
545                                        wxU(_("Brightness")) );
546     brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
547                            200, wxDefaultPosition, wxDefaultSize) ;
548     brightness_sizer->Add(brightness_text,1,0,0);
549     brightness_sizer->Add(brightness_slider,1,0,0);
550     brightness_sizer->Layout();
551
552     wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
553     wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
554                                           wxU(_("Saturation")) );
555     saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
556                            300, wxDefaultPosition, wxDefaultSize );
557     saturation_sizer->Add(saturation_text,1,0,0);
558     saturation_sizer->Add(saturation_slider,1,0,0);
559     saturation_sizer->Layout();
560
561     adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
562     adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
563     adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
564     adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
565     adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
566
567     extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
568
569
570     /* Create sizer to surround the other controls */
571     wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
572
573
574     wxStaticBox *video_box =
575             new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
576     /* Create the sizer for the frame */
577     wxStaticBoxSizer *video_sizer =
578        new wxStaticBoxSizer( video_box, wxVERTICAL );
579     video_sizer->SetMinSize( -1, 50 );
580
581     static const wxString ratio_array[] =
582     {
583         wxT("4:3"),
584         wxT("16:9"),
585     };
586
587     wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
588     wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
589                                           wxU(_("Ratio")) );
590
591     ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
592                                   wxDefaultPosition, wxSize(120,-1),
593                                   WXSIZEOF(ratio_array), ratio_array,
594                                   0 );
595
596     ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
597     ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
598     ratio_sizer->Layout();
599
600     video_sizer->Add( ratio_sizer  , 0 , wxALL , 0 );
601     video_sizer->Layout();
602
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( video_sizer, 0, wxALL | wxEXPAND , 0);
622     other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
623     other_sizer->Layout();
624
625     extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
626
627     extra_frame->SetSizer( extra_sizer );
628
629     /* Layout the whole panel */
630     extra_sizer->Layout();
631
632     extra_sizer->SetSizeHints(extra_frame);
633
634     /* Write down initial values */
635     psz_filters = config_GetPsz( p_intf, "audio-filter" );
636     if( psz_filters && strstr( psz_filters, "visual" ) )
637     {
638         visual_checkbox->SetValue(1);
639     }
640     if( psz_filters ) free( psz_filters );
641
642     psz_filters = config_GetPsz( p_intf, "filter" );
643     if( psz_filters && strstr( psz_filters, "adjust" ) )
644     {
645         adjust_check->SetValue( 1 );
646         saturation_slider->Enable();
647         contrast_slider->Enable();
648         brightness_slider->Enable();
649         hue_slider->Enable();
650     }
651     else
652     {
653         adjust_check->SetValue( 0 );
654         saturation_slider->Disable();
655         contrast_slider->Disable();
656         brightness_slider->Disable();
657         hue_slider->Disable();
658     }
659     if( psz_filters ) free( psz_filters );
660
661     int i_value = config_GetInt( p_intf, "hue" );
662     if( i_value > 0 && i_value < 360 )
663         hue_slider->SetValue( i_value );
664
665     float f_value;
666     f_value = config_GetFloat( p_intf, "saturation" );
667     if( f_value > 0 && f_value < 5 )
668         saturation_slider->SetValue( (int)(100 * f_value) );
669     f_value = config_GetFloat( p_intf, "contrast" );
670     if( f_value > 0 && f_value < 4 )
671         contrast_slider->SetValue( (int)(100 * f_value) );
672     f_value = config_GetFloat( p_intf, "brightness" );
673     if( f_value > 0 && f_value < 2 )
674         brightness_slider->SetValue( (int)(100 * f_value) );
675
676     extra_frame->Hide();
677 }
678
679 void Interface::UpdateAcceleratorTable()
680 {
681     /* Set some hotkeys */
682     wxAcceleratorEntry entries[7];
683     vlc_value_t val;
684     int i = 0;
685
686     var_Get( p_intf->p_vlc, "key-quit", &val );
687     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
688                       ConvertHotkey( val.i_int ), Exit_Event );
689     var_Get( p_intf->p_vlc, "key-stop", &val );
690     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
691                       ConvertHotkey( val.i_int ), StopStream_Event );
692     var_Get( p_intf->p_vlc, "key-play-pause", &val );
693     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
694                       ConvertHotkey( val.i_int ), PlayStream_Event );
695     var_Get( p_intf->p_vlc, "key-next", &val );
696     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
697                       ConvertHotkey( val.i_int ), NextStream_Event );
698     var_Get( p_intf->p_vlc, "key-prev", &val );
699     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
700                       ConvertHotkey( val.i_int ), PrevStream_Event );
701     var_Get( p_intf->p_vlc, "key-faster", &val );
702     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
703                       ConvertHotkey( val.i_int ), FastStream_Event );
704     var_Get( p_intf->p_vlc, "key-slower", &val );
705     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
706                       ConvertHotkey( val.i_int ), SlowStream_Event );
707
708     wxAcceleratorTable accel( 7, entries );
709
710     if( !accel.Ok() )
711         msg_Err( p_intf, "invalid accelerator table" );
712
713     SetAcceleratorTable( accel );
714     msg_Dbg( p_intf, "accelerator table loaded" );
715
716 }
717
718 /*****************************************************************************
719  * Event Handlers.
720  *****************************************************************************/
721 /* Work-around helper for buggy wxGTK */
722 void RecursiveDestroy( wxMenu *menu )
723 {
724     wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
725     for( ; node; )
726     {
727         wxMenuItem *item = node->GetData();
728         node = node->GetNext();
729
730         /* Delete the submenus */
731         wxMenu *submenu = item->GetSubMenu();
732         if( submenu )
733         {
734             RecursiveDestroy( submenu );
735         }
736         menu->Delete( item );
737     }
738 }
739
740 void Interface::OnMenuOpen(wxMenuEvent& event)
741 {
742 #if !defined( __WXMSW__ )
743     if( event.GetEventObject() == p_settings_menu )
744     {
745         if( b_settings_menu )
746         {
747             p_settings_menu = SettingsMenu( p_intf, this );
748
749             /* Add static items */
750             p_settings_menu->AppendCheckItem( Extra_Event,
751                              wxU(_("&Extended GUI") ), wxU(_(EXTRA_PREFS)) );
752             p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
753                                      wxU(_(HELP_PREFS)) );
754
755             /* Work-around for buggy wxGTK */
756             wxMenu *menu = GetMenuBar()->GetMenu( 2 );
757             RecursiveDestroy( menu );
758             /* End work-around */
759
760             menu = GetMenuBar()->Replace( 2, p_settings_menu,
761                                           wxU(_("&Settings")));
762             if( menu ) delete menu;
763
764             b_settings_menu = 0;
765         }
766         else b_settings_menu = 1;
767     }
768     else if( event.GetEventObject() == p_audio_menu )
769     {
770         if( b_audio_menu )
771         {
772             p_audio_menu = AudioMenu( p_intf, this );
773
774             /* Work-around for buggy wxGTK */
775             wxMenu *menu = GetMenuBar()->GetMenu( 3 );
776             RecursiveDestroy( menu );
777             /* End work-around */
778
779             menu =
780                 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
781             if( menu ) delete menu;
782
783             b_audio_menu = 0;
784         }
785         else b_audio_menu = 1;
786     }
787     else if( event.GetEventObject() == p_video_menu )
788     {
789         if( b_video_menu )
790         {
791             p_video_menu = VideoMenu( p_intf, this );
792
793             /* Work-around for buggy wxGTK */
794             wxMenu *menu = GetMenuBar()->GetMenu( 4 );
795             RecursiveDestroy( menu );
796             /* End work-around */
797
798             menu =
799                 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
800             if( menu ) delete menu;
801
802             b_video_menu = 0;
803         }
804         else b_video_menu = 1;
805     }
806     else if( event.GetEventObject() == p_navig_menu )
807     {
808         if( b_navig_menu )
809         {
810             p_navig_menu = NavigMenu( p_intf, this );
811
812             /* Work-around for buggy wxGTK */
813             wxMenu *menu = GetMenuBar()->GetMenu( 5 );
814             RecursiveDestroy( menu );
815             /* End work-around */
816
817             menu =
818                 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
819             if( menu ) delete menu;
820
821             b_navig_menu = 0;
822         }
823         else b_navig_menu = 1;
824     }
825
826 #else
827     p_settings_menu = SettingsMenu( p_intf, this );
828     /* Add static items */
829     p_settings_menu->AppendCheckItem( Extra_Event, wxU(_("&Extended GUI") ),
830                                       wxU(_(EXTRA_PREFS)) );
831     p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
832                              wxU(_(HELP_PREFS)) );
833     wxMenu *menu =
834         GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
835     if( menu ) delete menu;
836
837     p_audio_menu = AudioMenu( p_intf, this );
838     menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
839     if( menu ) delete menu;
840
841     p_video_menu = VideoMenu( p_intf, this );
842     menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
843     if( menu ) delete menu;
844
845     p_navig_menu = NavigMenu( p_intf, this );
846     menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
847     if( menu ) delete menu;
848 #endif
849
850 }
851
852 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
853 void Interface::OnContextMenu2(wxContextMenuEvent& event)
854 {
855     /* Only show the context menu for the main interface */
856     if( GetId() != event.GetId() )
857     {
858         event.Skip();
859         return;
860     }
861
862     if( p_intf->p_sys->pf_show_dialog )
863         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
864 }
865 #endif
866 void Interface::OnContextMenu(wxMouseEvent& event)
867 {
868     if( p_intf->p_sys->pf_show_dialog )
869         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
870 }
871
872 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
873 {
874     /* TRUE is to force the frame to close. */
875     Close(TRUE);
876 }
877
878 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
879 {
880     wxString msg;
881     msg.Printf( wxString(wxT("VLC media player " VERSION)) +
882         wxU(_(" (wxWindows interface)\n\n")) +
883         wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
884         wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
885         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
886               "http://www.videolan.org/\n\n")) );
887
888     wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
889                   wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
890 }
891
892 void Interface::OnShowDialog( wxCommandEvent& event )
893 {
894     if( p_intf->p_sys->pf_show_dialog )
895     {
896         int i_id;
897
898         switch( event.GetId() )
899         {
900         case OpenFileSimple_Event:
901             i_id = INTF_DIALOG_FILE_SIMPLE;
902             break;
903         case OpenAdv_Event:
904             i_id = INTF_DIALOG_FILE;
905         case OpenFile_Event:
906             i_id = INTF_DIALOG_FILE;
907             break;
908         case OpenDisc_Event:
909             i_id = INTF_DIALOG_DISC;
910             break;
911         case OpenNet_Event:
912             i_id = INTF_DIALOG_NET;
913             break;
914         case OpenSat_Event:
915             i_id = INTF_DIALOG_SAT;
916             break;
917         case Playlist_Event:
918             i_id = INTF_DIALOG_PLAYLIST;
919             break;
920         case Logs_Event:
921             i_id = INTF_DIALOG_MESSAGES;
922             break;
923         case FileInfo_Event:
924             i_id = INTF_DIALOG_FILEINFO;
925             break;
926         case Prefs_Event:
927             i_id = INTF_DIALOG_PREFS;
928             break;
929         default:
930             i_id = INTF_DIALOG_FILE;
931             break;
932
933         }
934
935         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
936     }
937 }
938
939
940 void Interface::OnStream( wxCommandEvent& event )
941 {
942     StreamDialog *p_stream_dialog = new StreamDialog(p_intf,this);
943     p_stream_dialog->Show();
944 }
945
946
947 void Interface::OnExtra(wxCommandEvent& event)
948 {
949     if( b_extra == VLC_FALSE)
950     {
951         extra_frame->Show();
952         frame_sizer->Show( extra_frame );
953         b_extra = VLC_TRUE;
954     }
955     else
956     {
957         extra_frame->Hide();
958         frame_sizer->Hide( extra_frame );
959         b_extra = VLC_FALSE;
960     }
961     frame_sizer->Layout();
962     frame_sizer->Fit(this);
963 }
964
965 void Interface::OnEnableAdjust(wxCommandEvent& event)
966 {
967     char *psz_filters=config_GetPsz( p_intf, "filter");
968     char *psz_new = NULL;
969     if( event.IsChecked() )
970     {
971         if(psz_filters == NULL)
972         {
973             psz_new = strdup( "adjust" );
974         }
975         else
976         {
977             psz_new= (char *) malloc(strlen(psz_filters) + 8 );
978             sprintf( psz_new, "%s:adjust", psz_filters);
979         }
980         config_PutPsz( p_intf, "filter", psz_new );
981         vlc_value_t val;
982         vout_thread_t *p_vout =
983            (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
984                                        FIND_ANYWHERE );
985         if( p_vout != NULL )
986         {
987             val.psz_string = strdup( psz_new );
988             var_Set( p_vout, "filter", val);
989             vlc_object_release( p_vout );
990         }
991         if( val.psz_string ) free( val.psz_string );
992         brightness_slider->Enable();
993         saturation_slider->Enable();
994         contrast_slider->Enable();
995         hue_slider->Enable();
996     }
997     else
998     {
999         if( psz_filters != NULL )
1000         {
1001
1002             char *psz_current;
1003             unsigned int i=0;
1004             for( i = 0; i< strlen(psz_filters ); i++)
1005             {
1006                 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1007                 {
1008                     if(i > 0)
1009                         if( psz_filters[i-1] == ':' ) i--;
1010                     psz_current = strchr( &psz_filters[i+1] , ':' );
1011                     if( !psz_current )
1012                         psz_filters[i] = '\0';
1013                     else
1014                     {
1015                        memmove( &psz_filters[i] , psz_current,
1016                                 &psz_filters[strlen(psz_filters)]-psz_current
1017                                 +1);
1018                     }
1019                 }
1020             }
1021             config_PutPsz( p_intf, "filter", psz_filters);
1022             vlc_value_t val;
1023             val.psz_string = strdup( psz_filters );
1024             vout_thread_t *p_vout =
1025                (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1026                                        FIND_ANYWHERE );
1027             if( p_vout != NULL )
1028             {
1029                 var_Set( p_vout, "filter", val);
1030                 vlc_object_release( p_vout );
1031             }
1032             if( val.psz_string ) free( val.psz_string );
1033         }
1034         brightness_slider->Disable();
1035         saturation_slider->Disable();
1036         contrast_slider->Disable();
1037         hue_slider->Disable();
1038     }
1039     if(psz_filters) free(psz_filters);
1040     if(psz_new) free(psz_new);
1041 }
1042
1043 void Interface::OnHueUpdate( wxScrollEvent& event)
1044 {
1045    config_PutInt( p_intf , "hue" , event.GetPosition() );
1046 }
1047
1048 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1049 {
1050    config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1051 }
1052
1053 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1054 {
1055    config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1056 }
1057
1058 void Interface::OnContrastUpdate(wxScrollEvent& event)
1059 {
1060    config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1061
1062 }
1063
1064 void Interface::OnRatio( wxCommandEvent& event )
1065 {
1066    config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1067 }
1068
1069 void Interface::OnEnableVisual(wxCommandEvent& event)
1070 {
1071     if( event.IsChecked() )
1072     {
1073         config_PutPsz( p_intf, "audio-filter", "visual" );
1074     }
1075     else
1076     {
1077         config_PutPsz( p_intf, "audio-filter", "" );
1078     }
1079 }
1080
1081 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1082 {
1083     wxCommandEvent dummy;
1084     playlist_t *p_playlist =
1085         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1086                                        FIND_ANYWHERE );
1087     if( p_playlist == NULL ) return;
1088
1089     if( p_playlist->i_size && p_playlist->i_enabled )
1090     {
1091         vlc_value_t state;
1092
1093         input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1094                                                        VLC_OBJECT_INPUT,
1095                                                        FIND_ANYWHERE );
1096         if( p_input == NULL )
1097         {
1098             /* No stream was playing, start one */
1099             playlist_Play( p_playlist );
1100             TogglePlayButton( PLAYING_S );
1101             vlc_object_release( p_playlist );
1102             return;
1103         }
1104
1105         var_Get( p_input, "state", &state );
1106
1107         if( state.i_int != PAUSE_S )
1108         {
1109             /* A stream is being played, pause it */
1110             state.i_int = PAUSE_S;
1111         }
1112         else
1113         {
1114             /* Stream is paused, resume it */
1115             state.i_int = PLAYING_S;
1116         }
1117         var_Set( p_input, "state", state );
1118
1119         TogglePlayButton( state.i_int );
1120         vlc_object_release( p_input );
1121         vlc_object_release( p_playlist );
1122     }
1123     else
1124     {
1125         /* If the playlist is empty, open a file requester instead */
1126         vlc_object_release( p_playlist );
1127         OnShowDialog( dummy );
1128     }
1129 }
1130
1131 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1132 {
1133     playlist_t * p_playlist =
1134         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1135                                        FIND_ANYWHERE );
1136     if( p_playlist == NULL )
1137     {
1138         return;
1139     }
1140
1141     playlist_Stop( p_playlist );
1142     TogglePlayButton( PAUSE_S );
1143     vlc_object_release( p_playlist );
1144 }
1145
1146 void Interface::OnSliderUpdate( wxScrollEvent& event )
1147 {
1148     vlc_mutex_lock( &p_intf->change_lock );
1149
1150 #ifdef WIN32
1151     if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1152         || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1153     {
1154 #endif
1155         if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1156             && p_intf->p_sys->p_input )
1157         {
1158             vlc_value_t pos;
1159             pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1160
1161             var_Set( p_intf->p_sys->p_input, "position", pos );
1162         }
1163
1164 #ifdef WIN32
1165         p_intf->p_sys->b_slider_free = VLC_TRUE;
1166     }
1167     else
1168     {
1169         p_intf->p_sys->b_slider_free = VLC_FALSE;
1170
1171         if( p_intf->p_sys->p_input )
1172         {
1173             /* Update stream date */
1174 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1175             char psz_time[ OFFSETTOTIME_MAX_SIZE ];
1176
1177             slider_box->SetLabel(
1178                 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1179                                         psz_time,
1180                                         p_area->i_size * event.GetPosition()
1181                                         / SLIDER_MAX_POS )) );
1182 #undef p_area
1183         }
1184     }
1185 #endif
1186
1187     vlc_mutex_unlock( &p_intf->change_lock );
1188 }
1189
1190 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1191 {
1192     playlist_t * p_playlist =
1193         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1194                                        FIND_ANYWHERE );
1195     if( p_playlist == NULL )
1196     {
1197         return;
1198     }
1199
1200     vlc_mutex_lock( &p_playlist->object_lock );
1201     if( p_playlist->p_input != NULL )
1202     {
1203         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1204         if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1205         {
1206             vlc_value_t val; val.b_bool = VLC_TRUE;
1207             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1208             var_Set( p_playlist->p_input, "prev-title", val );
1209         } else 
1210             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1211     }
1212     vlc_mutex_unlock( &p_playlist->object_lock );
1213
1214     playlist_Prev( p_playlist );
1215     vlc_object_release( p_playlist );
1216 }
1217
1218 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1219 {
1220     playlist_t * p_playlist =
1221         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1222                                        FIND_ANYWHERE );
1223     if( p_playlist == NULL )
1224     {
1225         return;
1226     }
1227
1228     vlc_mutex_lock( &p_playlist->object_lock );
1229     if( p_playlist->p_input != NULL )
1230     {
1231         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1232         if( p_playlist->p_input->stream.i_area_nb > 1 &&
1233             p_playlist->p_input->stream.p_selected_area->i_id <
1234               p_playlist->p_input->stream.i_area_nb - 1 )
1235         {
1236             vlc_value_t val; val.b_bool = VLC_TRUE;
1237             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1238             var_Set( p_playlist->p_input, "next-title", val );
1239         } else 
1240             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1241     }
1242     vlc_mutex_unlock( &p_playlist->object_lock );
1243
1244     playlist_Next( p_playlist );
1245     vlc_object_release( p_playlist );
1246 }
1247
1248 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1249 {
1250     input_thread_t *p_input =
1251         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1252                                            FIND_ANYWHERE );
1253     if( p_input )
1254     {
1255         vlc_value_t val; val.b_bool = VLC_TRUE;
1256
1257         var_Set( p_input, "rate-slower", val );
1258         vlc_object_release( p_input );
1259     }
1260 }
1261
1262 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1263 {
1264     input_thread_t *p_input =
1265         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1266                                            FIND_ANYWHERE );
1267     if( p_input )
1268     {
1269         vlc_value_t val; val.b_bool = VLC_TRUE;
1270
1271         var_Set( p_input, "rate-faster", val );
1272         vlc_object_release( p_input );
1273     }
1274 }
1275
1276 void Interface::TogglePlayButton( int i_playing_status )
1277 {
1278     if( i_playing_status == i_old_playing_status )
1279         return;
1280
1281     GetToolBar()->DeleteTool( PlayStream_Event );
1282
1283     if( i_playing_status == PLAYING_S )
1284     {
1285         GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")),
1286                                   wxBitmap( pause_xpm ), wxNullBitmap,
1287                                   wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1288     }
1289     else
1290     {
1291         GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")),
1292                                   wxBitmap( play_xpm ), wxNullBitmap,
1293                                   wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1294     }
1295
1296     GetToolBar()->Realize();
1297
1298     i_old_playing_status = i_playing_status;
1299 }
1300
1301 #if !defined(__WXX11__)
1302 /*****************************************************************************
1303  * Definition of DragAndDrop class.
1304  *****************************************************************************/
1305 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1306 {
1307     p_intf = _p_intf;
1308     b_enqueue = _b_enqueue;
1309 }
1310
1311 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1312                                const wxArrayString& filenames )
1313 {
1314     /* Add dropped files to the playlist */
1315
1316     playlist_t *p_playlist =
1317         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1318                                        FIND_ANYWHERE );
1319     if( p_playlist == NULL )
1320     {
1321         return FALSE;
1322     }
1323
1324     for( size_t i = 0; i < filenames.GetCount(); i++ )
1325         playlist_Add( p_playlist, (const char *)filenames[i].mb_str(), 0, 0,
1326                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1327                       PLAYLIST_END );
1328
1329     vlc_object_release( p_playlist );
1330
1331     return TRUE;
1332 }
1333 #endif
1334
1335 /*****************************************************************************
1336  * Definition of wxVolCtrl class.
1337  *****************************************************************************/
1338 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
1339   : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
1340              wxGA_VERTICAL | wxGA_SMOOTH )
1341 {
1342     p_intf = _p_intf;
1343 }
1344
1345 void wxVolCtrl::OnChange( wxMouseEvent& event )
1346 {
1347     if( !event.LeftDown() && !event.LeftIsDown() ) return;
1348
1349     int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /
1350                     GetClientSize().GetHeight();
1351     Change( i_volume );
1352 }
1353
1354 void wxVolCtrl::Change( int i_volume )
1355 {
1356     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1357     SetValue( i_volume );
1358     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1359                 i_volume ) );
1360 }