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