]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/interface.cpp
9528b2c94c6d44372b315a333f088463aadcde8e
[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@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28 #include <vlc/aout.h>
29 #include <vlc/vout.h>
30 #include <vlc/intf.h>
31 #include "stream_control.h"
32
33 #include "wxwindows.h"
34
35 /* include the toolbar graphics */
36 #include "bitmaps/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 "Settings" menu */
359     p_settings_menu = new wxMenu;
360     b_settings_menu = 1;
361
362     /* Create the "Audio" menu */
363     p_audio_menu = new wxMenu;
364     b_audio_menu = 1;
365
366     /* Create the "Video" menu */
367     p_video_menu = new wxMenu;
368     b_video_menu = 1;
369
370     /* Create the "Navigation" menu */
371     p_navig_menu = new wxMenu;
372     b_navig_menu = 1;
373
374     /* Create the "Help" menu */
375     wxMenu *help_menu = new wxMenu;
376     help_menu->Append( About_Event, wxU(_("About VLC media player")),
377                        wxU(_(HELP_ABOUT)) );
378
379     /* Append the freshly created menus to the menu bar... */
380     wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
381     menubar->Append( file_menu, wxU(_("&File")) );
382     menubar->Append( view_menu, wxU(_("&View")) );
383     menubar->Append( p_settings_menu, wxU(_("&Settings")) );
384     menubar->Append( p_audio_menu, wxU(_("&Audio")) );
385     menubar->Append( p_video_menu, wxU(_("&Video")) );
386     menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
387     menubar->Append( help_menu, wxU(_("&Help")) );
388
389     /* Attach the menu bar to the frame */
390     SetMenuBar( menubar );
391
392     /* Intercept all menu events in our custom event handler */
393     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
394
395 #if !defined(__WXX11__)
396     /* Associate drop targets with the menubar */
397     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
398 #endif
399 }
400
401 class VLCVolCtrl : public wxControl
402 {
403 public:
404     VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
405     virtual ~VLCVolCtrl() {};
406
407     virtual void OnPaint( wxPaintEvent &event );
408
409   private:
410     DECLARE_EVENT_TABLE()
411 };
412
413 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
414    EVT_PAINT(VLCVolCtrl::OnPaint)
415 END_EVENT_TABLE()
416
417 VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
418                         wxGauge **pp_volctrl )
419   :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, 16 ), wxBORDER_NONE )
420 {
421     *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint(18,0),
422                                   wxSize(44,16) );
423 }
424
425 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
426 {
427     wxPaintDC dc( this );
428     wxBitmap mPlayBitmap( speaker_xpm );
429     dc.DrawBitmap( mPlayBitmap, 1, 0, TRUE );
430 }
431
432 void Interface::CreateOurToolBar()
433 {
434 #define HELP_STOP N_("Stop")
435
436 #define HELP_PLAY N_("Play")
437 #define HELP_PAUSE N_("Pause")
438 #define HELP_PLO N_("Playlist")
439 #define HELP_PLP N_("Previous playlist item")
440 #define HELP_PLN N_("Next playlist item")
441 #define HELP_SLOW N_("Play slower")
442 #define HELP_FAST N_("Play faster")
443
444     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
445                          * version because we don't include wx.rc */
446
447     wxToolBar *toolbar =
448         CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
449
450     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
451
452     toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
453                       wxU(_(HELP_PLAY)) );
454 #if 0
455     toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
456                       wxU(_(HELP_PAUSE)) );
457 #endif
458     toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
459                       wxU(_(HELP_STOP)) );
460     toolbar->AddSeparator();
461     toolbar->AddTool( PrevStream_Event, wxT(""),
462                       wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
463     toolbar->AddTool( SlowStream_Event, wxT(""),
464                       wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
465     toolbar->AddTool( FastStream_Event, wxT(""),
466                       wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
467     toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
468                       wxU(_(HELP_PLN)) );
469     toolbar->AddSeparator();
470     toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( eject_xpm ),
471                       wxU(_(HELP_PLO)) );
472
473     wxControl *p_dummy_ctrl =
474         new wxControl( toolbar, -1, wxDefaultPosition,
475                        wxSize(64, 16 ), wxBORDER_NONE );
476
477     toolbar->AddControl( p_dummy_ctrl );
478
479     VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
480     toolbar->AddControl( sound_control );
481
482     toolbar->Realize();
483
484     // '7' is the number of buttons on the toolbar, '3' is arbitrary :)
485     frame_sizer->SetMinSize( TOOLBAR_BMP_WIDTH * 7 * 3, -1 );
486
487 #if !defined(__WXX11__)
488     /* Associate drop targets with the toolbar */
489     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
490 #endif
491 }
492
493 void Interface::CreateOurSlider()
494 {
495     /* Create a new frame and sizer containing the slider */
496     slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
497     slider_frame->SetAutoLayout( TRUE );
498     wxBoxSizer *frame_sizer =
499         new wxBoxSizer( wxHORIZONTAL );
500
501     /* Create static box to surround the slider */
502     slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
503
504     /* Create sizer for slider frame */
505     wxStaticBoxSizer *slider_sizer =
506         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
507     slider_sizer->SetMinSize( -1, 50 );
508
509     /* Create slider */
510     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
511                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
512     slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
513
514     /* Add everything to the frame */
515     frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
516     slider_frame->SetSizer( frame_sizer );
517     frame_sizer->Layout();
518     frame_sizer->SetSizeHints(slider_frame);
519
520     /* Hide the slider by default */
521     slider_frame->Hide();
522 }
523
524
525 void Interface::CreateOurExtendedPanel()
526 {
527     char *psz_filters;
528
529     extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
530     extra_frame->SetAutoLayout( TRUE );
531     wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
532
533     /* Create static box to surround the adjust controls */
534     wxStaticBox *adjust_box =
535            new wxStaticBox( extra_frame, -1, wxU(_("Adjust Image")) );
536
537     /* Create the size for the frame */
538     wxStaticBoxSizer *adjust_sizer =
539         new wxStaticBoxSizer( adjust_box, wxVERTICAL );
540     adjust_sizer->SetMinSize( -1, 50 );
541
542     /* Create every controls */
543
544     /* Create the adjust button */
545     wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
546                                                  wxU(_("Enable")));
547
548
549     wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
550     wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
551                                        wxU(_("Hue")) );
552     hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
553                                 360, wxDefaultPosition, wxDefaultSize );
554
555     hue_sizer->Add(hue_text,1, 0 ,0);
556     hue_sizer->Add(hue_slider,1, 0 ,0);
557     hue_sizer->Layout();
558
559     wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
560     wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
561                                        wxU(_("Contrast")) );
562     contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
563                                 200, wxDefaultPosition, wxDefaultSize);
564     contrast_sizer->Add(contrast_text,1, 0 ,0);
565     contrast_sizer->Add(contrast_slider,1, 0 ,0);
566     contrast_sizer->Layout();
567
568     wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
569     wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
570                                        wxU(_("Brightness")) );
571     brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
572                            200, wxDefaultPosition, wxDefaultSize) ;
573     brightness_sizer->Add(brightness_text,1,0,0);
574     brightness_sizer->Add(brightness_slider,1,0,0);
575     brightness_sizer->Layout();
576
577     wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
578     wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
579                                           wxU(_("Saturation")) );
580     saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
581                            300, wxDefaultPosition, wxDefaultSize );
582     saturation_sizer->Add(saturation_text,1,0,0);
583     saturation_sizer->Add(saturation_slider,1,0,0);
584     saturation_sizer->Layout();
585
586     wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
587     wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
588                                           wxU(_("Gamma")) );
589     gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
590                            100, wxDefaultPosition, wxDefaultSize );
591     gamma_sizer->Add(gamma_text,1,0,0);
592     gamma_sizer->Add(gamma_slider,1,0,0);
593     gamma_sizer->Layout();
594
595     adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
596     adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
597     adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
598     adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
599     adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
600     adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
601
602     extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
603
604     /* Create sizer to surround the other controls */
605     wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
606
607
608     wxStaticBox *video_box =
609             new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
610     /* Create the sizer for the frame */
611     wxStaticBoxSizer *video_sizer =
612        new wxStaticBoxSizer( video_box, wxVERTICAL );
613     video_sizer->SetMinSize( -1, 50 );
614
615     static const wxString ratio_array[] =
616     {
617         wxT("4:3"),
618         wxT("16:9"),
619     };
620
621     wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
622     wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
623                                           wxU(_("Aspect Ratio")) );
624
625     ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
626                                   wxDefaultPosition, wxSize(120,-1),
627                                   WXSIZEOF(ratio_array), ratio_array,
628                                   0 );
629
630     ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
631     ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
632     ratio_sizer->Layout();
633
634     video_sizer->Add( ratio_sizer  , 0 , wxALL , 0 );
635     video_sizer->Layout();
636
637 #if 0
638     wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
639
640     wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
641                                             wxU(_("Visualisations")) );
642
643     visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
644     visual_sizer->Layout();
645
646     wxStaticBox *audio_box =
647               new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
648     /* Create the sizer for the frame */
649     wxStaticBoxSizer *audio_sizer =
650         new wxStaticBoxSizer( audio_box, wxVERTICAL );
651     audio_sizer->SetMinSize( -1, 50 );
652
653     audio_sizer->Add( visual_sizer, 0, wxALL, 0);
654     audio_sizer->Layout();
655
656     other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
657 #endif
658     other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
659     other_sizer->Layout();
660
661     extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
662
663     extra_frame->SetSizer( extra_sizer );
664
665     /* Layout the whole panel */
666     extra_sizer->Layout();
667
668     extra_sizer->SetSizeHints(extra_frame);
669
670     /* Write down initial values */
671 #if 0
672     psz_filters = config_GetPsz( p_intf, "audio-filter" );
673     if( psz_filters && strstr( psz_filters, "visual" ) )
674     {
675         visual_checkbox->SetValue(1);
676     }
677     if( psz_filters ) free( psz_filters );
678 #endif
679     psz_filters = config_GetPsz( p_intf, "filter" );
680     if( psz_filters && strstr( psz_filters, "adjust" ) )
681     {
682         adjust_check->SetValue( 1 );
683         saturation_slider->Enable();
684         contrast_slider->Enable();
685         brightness_slider->Enable();
686         hue_slider->Enable();
687         gamma_slider->Enable();
688     }
689     else
690     {
691         adjust_check->SetValue( 0 );
692         saturation_slider->Disable();
693         contrast_slider->Disable();
694         brightness_slider->Disable();
695         hue_slider->Disable();
696         gamma_slider->Disable();
697     }
698     if( psz_filters ) free( psz_filters );
699
700     int i_value = config_GetInt( p_intf, "hue" );
701     if( i_value > 0 && i_value < 360 )
702         hue_slider->SetValue( i_value );
703
704     float f_value;
705     f_value = config_GetFloat( p_intf, "saturation" );
706     if( f_value > 0 && f_value < 5 )
707         saturation_slider->SetValue( (int)(100 * f_value) );
708     f_value = config_GetFloat( p_intf, "contrast" );
709     if( f_value > 0 && f_value < 4 )
710         contrast_slider->SetValue( (int)(100 * f_value) );
711     f_value = config_GetFloat( p_intf, "brightness" );
712     if( f_value > 0 && f_value < 2 )
713         brightness_slider->SetValue( (int)(100 * f_value) );
714     f_value = config_GetFloat( p_intf, "gamma" );
715     if( f_value > 0 && f_value < 10 )
716         gamma_slider->SetValue( (int)(10 * f_value) );
717
718     extra_frame->Hide();
719 }
720
721 void Interface::UpdateAcceleratorTable()
722 {
723     /* Set some hotkeys */
724     wxAcceleratorEntry entries[7];
725     vlc_value_t val;
726     int i = 0;
727
728     var_Get( p_intf->p_vlc, "key-quit", &val );
729     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
730                       ConvertHotkey( val.i_int ), Exit_Event );
731     var_Get( p_intf->p_vlc, "key-stop", &val );
732     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
733                       ConvertHotkey( val.i_int ), StopStream_Event );
734     var_Get( p_intf->p_vlc, "key-play-pause", &val );
735     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
736                       ConvertHotkey( val.i_int ), PlayStream_Event );
737     var_Get( p_intf->p_vlc, "key-next", &val );
738     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
739                       ConvertHotkey( val.i_int ), NextStream_Event );
740     var_Get( p_intf->p_vlc, "key-prev", &val );
741     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
742                       ConvertHotkey( val.i_int ), PrevStream_Event );
743     var_Get( p_intf->p_vlc, "key-faster", &val );
744     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
745                       ConvertHotkey( val.i_int ), FastStream_Event );
746     var_Get( p_intf->p_vlc, "key-slower", &val );
747     entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
748                       ConvertHotkey( val.i_int ), SlowStream_Event );
749
750     wxAcceleratorTable accel( 7, entries );
751
752     if( !accel.Ok() )
753         msg_Err( p_intf, "invalid accelerator table" );
754
755     SetAcceleratorTable( accel );
756     msg_Dbg( p_intf, "accelerator table loaded" );
757
758 }
759
760 /*****************************************************************************
761  * Event Handlers.
762  *****************************************************************************/
763 /* Work-around helper for buggy wxGTK */
764 void RecursiveDestroy( wxMenu *menu )
765 {
766     wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
767     for( ; node; )
768     {
769         wxMenuItem *item = node->GetData();
770         node = node->GetNext();
771
772         /* Delete the submenus */
773         wxMenu *submenu = item->GetSubMenu();
774         if( submenu )
775         {
776             RecursiveDestroy( submenu );
777         }
778         menu->Delete( item );
779     }
780 }
781
782 void Interface::OnMenuOpen(wxMenuEvent& event)
783 {
784 #if !defined( __WXMSW__ )
785     if( event.GetEventObject() == p_settings_menu )
786     {
787         if( b_settings_menu )
788         {
789             p_settings_menu = SettingsMenu( p_intf, this );
790
791             /* Add static items */
792             p_settings_menu->AppendCheckItem( Extended_Event,
793                              wxU(_("&Extended GUI") ), wxU(_(HELP_EXTENDED)) );
794             p_settings_menu->AppendCheckItem( Bookmarks_Event,
795                              wxU(_("&Bookmarks") ), wxU(_(HELP_BOOKMARKS)) );
796             p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
797                                      wxU(_(HELP_PREFS)) );
798
799             /* Work-around for buggy wxGTK */
800             wxMenu *menu = GetMenuBar()->GetMenu( 2 );
801             RecursiveDestroy( menu );
802             /* End work-around */
803
804             menu = GetMenuBar()->Replace( 2, p_settings_menu,
805                                           wxU(_("&Settings")));
806             if( menu ) delete menu;
807
808             b_settings_menu = 0;
809         }
810         else b_settings_menu = 1;
811     }
812     else if( event.GetEventObject() == p_audio_menu )
813     {
814         if( b_audio_menu )
815         {
816             p_audio_menu = AudioMenu( p_intf, this );
817
818             /* Work-around for buggy wxGTK */
819             wxMenu *menu = GetMenuBar()->GetMenu( 3 );
820             RecursiveDestroy( menu );
821             /* End work-around */
822
823             menu =
824                 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
825             if( menu ) delete menu;
826
827             b_audio_menu = 0;
828         }
829         else b_audio_menu = 1;
830     }
831     else if( event.GetEventObject() == p_video_menu )
832     {
833         if( b_video_menu )
834         {
835             p_video_menu = VideoMenu( p_intf, this );
836
837             /* Work-around for buggy wxGTK */
838             wxMenu *menu = GetMenuBar()->GetMenu( 4 );
839             RecursiveDestroy( menu );
840             /* End work-around */
841
842             menu =
843                 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
844             if( menu ) delete menu;
845
846             b_video_menu = 0;
847         }
848         else b_video_menu = 1;
849     }
850     else if( event.GetEventObject() == p_navig_menu )
851     {
852         if( b_navig_menu )
853         {
854             p_navig_menu = NavigMenu( p_intf, this );
855
856             /* Work-around for buggy wxGTK */
857             wxMenu *menu = GetMenuBar()->GetMenu( 5 );
858             RecursiveDestroy( menu );
859             /* End work-around */
860
861             menu =
862                 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
863             if( menu ) delete menu;
864
865             b_navig_menu = 0;
866         }
867         else b_navig_menu = 1;
868     }
869
870 #else
871     p_settings_menu = SettingsMenu( p_intf, this );
872     /* Add static items */
873     p_settings_menu->AppendCheckItem( Extended_Event, wxU(_("&Extended GUI") ),
874                                       wxU(_(HELP_EXTENDED)) );
875     p_settings_menu->AppendCheckItem( Bookmarks_Event, wxU(_("&Bookmarks") ),
876                                       wxU(_(HELP_BOOKMARKS)) );
877     p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
878                              wxU(_(HELP_PREFS)) );
879     wxMenu *menu =
880         GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
881     if( menu ) delete menu;
882
883     p_audio_menu = AudioMenu( p_intf, this );
884     menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
885     if( menu ) delete menu;
886
887     p_video_menu = VideoMenu( p_intf, this );
888     menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
889     if( menu ) delete menu;
890
891     p_navig_menu = NavigMenu( p_intf, this );
892     menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
893     if( menu ) delete menu;
894 #endif
895
896 }
897
898 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
899 void Interface::OnContextMenu2(wxContextMenuEvent& event)
900 {
901     /* Only show the context menu for the main interface */
902     if( GetId() != event.GetId() )
903     {
904         event.Skip();
905         return;
906     }
907
908     if( p_intf->p_sys->pf_show_dialog )
909         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
910 }
911 #endif
912 void Interface::OnContextMenu(wxMouseEvent& event)
913 {
914     if( p_intf->p_sys->pf_show_dialog )
915         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
916 }
917
918 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
919 {
920     /* TRUE is to force the frame to close. */
921     Close(TRUE);
922 }
923
924 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
925 {
926     wxString msg;
927     msg.Printf( wxString(wxT("VLC media player " VERSION)) +
928         wxU(_(" (wxWindows interface)\n\n")) +
929         wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
930         wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
931         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
932               "http://www.videolan.org/\n\n")) );
933
934     wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
935                   wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
936 }
937
938 void Interface::OnShowDialog( wxCommandEvent& event )
939 {
940     if( p_intf->p_sys->pf_show_dialog )
941     {
942         int i_id;
943
944         switch( event.GetId() )
945         {
946         case OpenFileSimple_Event:
947             i_id = INTF_DIALOG_FILE_SIMPLE;
948             break;
949         case OpenAdv_Event:
950             i_id = INTF_DIALOG_FILE;
951         case OpenFile_Event:
952             i_id = INTF_DIALOG_FILE;
953             break;
954         case OpenDisc_Event:
955             i_id = INTF_DIALOG_DISC;
956             break;
957         case OpenNet_Event:
958             i_id = INTF_DIALOG_NET;
959             break;
960         case OpenSat_Event:
961             i_id = INTF_DIALOG_SAT;
962             break;
963         case Playlist_Event:
964             i_id = INTF_DIALOG_PLAYLIST;
965             break;
966         case Logs_Event:
967             i_id = INTF_DIALOG_MESSAGES;
968             break;
969         case FileInfo_Event:
970             i_id = INTF_DIALOG_FILEINFO;
971             break;
972         case Prefs_Event:
973             i_id = INTF_DIALOG_PREFS;
974             break;
975         case StreamWizard_Event:
976             i_id = INTF_DIALOG_STREAMWIZARD;
977             break;
978         case Bookmarks_Event:
979             i_id = INTF_DIALOG_BOOKMARKS;
980             break;
981         default:
982             i_id = INTF_DIALOG_FILE;
983             break;
984         }
985
986         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
987     }
988 }
989
990 void Interface::OnExtended(wxCommandEvent& event)
991 {
992     if( b_extra == VLC_FALSE)
993     {
994         extra_frame->Show();
995         frame_sizer->Show( extra_frame );
996         b_extra = VLC_TRUE;
997     }
998     else
999     {
1000         extra_frame->Hide();
1001         frame_sizer->Hide( extra_frame );
1002         b_extra = VLC_FALSE;
1003     }
1004     frame_sizer->Layout();
1005     frame_sizer->Fit(this);
1006 }
1007
1008 void Interface::OnEnableAdjust(wxCommandEvent& event)
1009 {
1010     char *psz_filters=config_GetPsz( p_intf, "filter");
1011     char *psz_new = NULL;
1012     if( event.IsChecked() )
1013     {
1014         if(psz_filters == NULL)
1015         {
1016             psz_new = strdup( "adjust" );
1017         }
1018         else
1019         {
1020             psz_new= (char *) malloc(strlen(psz_filters) + 8 );
1021             sprintf( psz_new, "%s:adjust", psz_filters);
1022         }
1023         config_PutPsz( p_intf, "filter", psz_new );
1024         vlc_value_t val;
1025         vout_thread_t *p_vout =
1026            (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1027                                        FIND_ANYWHERE );
1028         if( p_vout != NULL )
1029         {
1030             val.psz_string = strdup( psz_new );
1031             var_Set( p_vout, "filter", val);
1032             vlc_object_release( p_vout );
1033         }
1034         if( val.psz_string ) free( val.psz_string );
1035         brightness_slider->Enable();
1036         saturation_slider->Enable();
1037         contrast_slider->Enable();
1038         hue_slider->Enable();
1039         gamma_slider->Enable();
1040     }
1041     else
1042     {
1043         if( psz_filters != NULL )
1044         {
1045
1046             char *psz_current;
1047             unsigned int i=0;
1048             for( i = 0; i< strlen(psz_filters ); i++)
1049             {
1050                 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
1051                 {
1052                     if(i > 0)
1053                         if( psz_filters[i-1] == ':' ) i--;
1054                     psz_current = strchr( &psz_filters[i+1] , ':' );
1055                     if( !psz_current )
1056                         psz_filters[i] = '\0';
1057                     else
1058                     {
1059                        memmove( &psz_filters[i] , psz_current,
1060                                 &psz_filters[strlen(psz_filters)]-psz_current
1061                                 +1);
1062                     }
1063                 }
1064             }
1065             config_PutPsz( p_intf, "filter", psz_filters);
1066             vlc_value_t val;
1067             val.psz_string = strdup( psz_filters );
1068             vout_thread_t *p_vout =
1069                (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1070                                        FIND_ANYWHERE );
1071             if( p_vout != NULL )
1072             {
1073                 var_Set( p_vout, "filter", val);
1074                 vlc_object_release( p_vout );
1075             }
1076             if( val.psz_string ) free( val.psz_string );
1077         }
1078         brightness_slider->Disable();
1079         saturation_slider->Disable();
1080         contrast_slider->Disable();
1081         hue_slider->Disable();
1082         gamma_slider->Disable();
1083     }
1084     if(psz_filters) free(psz_filters);
1085     if(psz_new) free(psz_new);
1086 }
1087
1088 void Interface::OnHueUpdate( wxScrollEvent& event)
1089 {
1090     config_PutInt( p_intf , "hue" , event.GetPosition() );
1091 }
1092
1093 void Interface::OnSaturationUpdate( wxScrollEvent& event)
1094 {
1095     config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1096 }
1097
1098 void Interface::OnBrightnessUpdate( wxScrollEvent& event)
1099 {
1100     config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
1101 }
1102
1103 void Interface::OnContrastUpdate(wxScrollEvent& event)
1104 {
1105     config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1106 }
1107
1108 void Interface::OnGammaUpdate(wxScrollEvent& event)
1109 {
1110     config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
1111 }
1112
1113 void Interface::OnRatio( wxCommandEvent& event )
1114 {
1115    config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
1116 }
1117
1118 void Interface::OnEnableVisual(wxCommandEvent& event)
1119 {
1120     if( event.IsChecked() )
1121     {
1122         config_PutPsz( p_intf, "audio-filter", "visual" );
1123     }
1124     else
1125     {
1126         config_PutPsz( p_intf, "audio-filter", "" );
1127     }
1128 }
1129
1130 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
1131 {
1132     wxCommandEvent dummy;
1133     playlist_t *p_playlist =
1134         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1135                                        FIND_ANYWHERE );
1136     if( p_playlist == NULL ) return;
1137
1138     if( p_playlist->i_size && p_playlist->i_enabled )
1139     {
1140         vlc_value_t state;
1141
1142         input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
1143                                                        VLC_OBJECT_INPUT,
1144                                                        FIND_ANYWHERE );
1145         if( p_input == NULL )
1146         {
1147             /* No stream was playing, start one */
1148             playlist_Play( p_playlist );
1149             TogglePlayButton( PLAYING_S );
1150             vlc_object_release( p_playlist );
1151             return;
1152         }
1153
1154         var_Get( p_input, "state", &state );
1155
1156         if( state.i_int != PAUSE_S )
1157         {
1158             /* A stream is being played, pause it */
1159             state.i_int = PAUSE_S;
1160         }
1161         else
1162         {
1163             /* Stream is paused, resume it */
1164             state.i_int = PLAYING_S;
1165         }
1166         var_Set( p_input, "state", state );
1167
1168         TogglePlayButton( state.i_int );
1169         vlc_object_release( p_input );
1170         vlc_object_release( p_playlist );
1171     }
1172     else
1173     {
1174         /* If the playlist is empty, open a file requester instead */
1175         vlc_object_release( p_playlist );
1176         OnShowDialog( dummy );
1177     }
1178 }
1179
1180 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
1181 {
1182     playlist_t * p_playlist =
1183         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1184                                        FIND_ANYWHERE );
1185     if( p_playlist == NULL )
1186     {
1187         return;
1188     }
1189
1190     playlist_Stop( p_playlist );
1191     TogglePlayButton( PAUSE_S );
1192     vlc_object_release( p_playlist );
1193 }
1194
1195 void Interface::OnSliderUpdate( wxScrollEvent& event )
1196 {
1197     vlc_mutex_lock( &p_intf->change_lock );
1198
1199 #ifdef WIN32
1200     if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
1201         || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
1202     {
1203 #endif
1204         if( p_intf->p_sys->i_slider_pos != event.GetPosition()
1205             && p_intf->p_sys->p_input )
1206         {
1207             vlc_value_t pos;
1208             pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
1209
1210             var_Set( p_intf->p_sys->p_input, "position", pos );
1211         }
1212
1213 #ifdef WIN32
1214         p_intf->p_sys->b_slider_free = VLC_TRUE;
1215     }
1216     else
1217     {
1218         p_intf->p_sys->b_slider_free = VLC_FALSE;
1219
1220         if( p_intf->p_sys->p_input )
1221         {
1222             /* Update stream date */
1223 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
1224             char psz_time[ MSTRTIME_MAX_SIZE ];
1225
1226             slider_box->SetLabel(
1227                 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1228                                         psz_time,
1229                                         p_area->i_size * event.GetPosition()
1230                                         / SLIDER_MAX_POS )) );
1231 #undef p_area
1232         }
1233     }
1234 #endif
1235
1236 #undef WIN32
1237     vlc_mutex_unlock( &p_intf->change_lock );
1238 }
1239
1240 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1241 {
1242     playlist_t * p_playlist =
1243         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1244                                        FIND_ANYWHERE );
1245     if( p_playlist == NULL )
1246     {
1247         return;
1248     }
1249
1250     vlc_mutex_lock( &p_playlist->object_lock );
1251     if( p_playlist->p_input != NULL )
1252     {
1253         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1254         if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1255         {
1256             vlc_value_t val; val.b_bool = VLC_TRUE;
1257             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1258             var_Set( p_playlist->p_input, "prev-title", val );
1259         } else
1260             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1261     }
1262     vlc_mutex_unlock( &p_playlist->object_lock );
1263
1264     playlist_Prev( p_playlist );
1265     vlc_object_release( p_playlist );
1266 }
1267
1268 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1269 {
1270     playlist_t * p_playlist =
1271         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1272                                        FIND_ANYWHERE );
1273     if( p_playlist == NULL )
1274     {
1275         return;
1276     }
1277
1278     vlc_mutex_lock( &p_playlist->object_lock );
1279     if( p_playlist->p_input != NULL )
1280     {
1281         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1282         if( p_playlist->p_input->stream.i_area_nb > 1 &&
1283             p_playlist->p_input->stream.p_selected_area->i_id <
1284               p_playlist->p_input->stream.i_area_nb - 1 )
1285         {
1286             vlc_value_t val; val.b_bool = VLC_TRUE;
1287             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1288             var_Set( p_playlist->p_input, "next-title", val );
1289         } else
1290             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1291     }
1292     vlc_mutex_unlock( &p_playlist->object_lock );
1293
1294     playlist_Next( p_playlist );
1295     vlc_object_release( p_playlist );
1296 }
1297
1298 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1299 {
1300     input_thread_t *p_input =
1301         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1302                                            FIND_ANYWHERE );
1303     if( p_input )
1304     {
1305         vlc_value_t val; val.b_bool = VLC_TRUE;
1306
1307         var_Set( p_input, "rate-slower", val );
1308         vlc_object_release( p_input );
1309     }
1310 }
1311
1312 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1313 {
1314     input_thread_t *p_input =
1315         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1316                                            FIND_ANYWHERE );
1317     if( p_input )
1318     {
1319         vlc_value_t val; val.b_bool = VLC_TRUE;
1320
1321         var_Set( p_input, "rate-faster", val );
1322         vlc_object_release( p_input );
1323     }
1324 }
1325
1326 void Interface::TogglePlayButton( int i_playing_status )
1327 {
1328     if( i_playing_status == i_old_playing_status )
1329         return;
1330
1331     GetToolBar()->DeleteTool( PlayStream_Event );
1332
1333     if( i_playing_status == PLAYING_S )
1334     {
1335         GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Pause")),
1336                                   wxBitmap( pause_xpm ), wxNullBitmap,
1337                                   wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1338     }
1339     else
1340     {
1341         GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Play")),
1342                                   wxBitmap( play_xpm ), wxNullBitmap,
1343                                   wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1344     }
1345
1346     GetToolBar()->Realize();
1347
1348     i_old_playing_status = i_playing_status;
1349 }
1350
1351 #if !defined(__WXX11__)
1352 /*****************************************************************************
1353  * Definition of DragAndDrop class.
1354  *****************************************************************************/
1355 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1356 {
1357     p_intf = _p_intf;
1358     b_enqueue = _b_enqueue;
1359 }
1360
1361 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1362                                const wxArrayString& filenames )
1363 {
1364     /* Add dropped files to the playlist */
1365
1366     playlist_t *p_playlist =
1367         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1368                                        FIND_ANYWHERE );
1369     if( p_playlist == NULL )
1370     {
1371         return FALSE;
1372     }
1373
1374     for( size_t i = 0; i < filenames.GetCount(); i++ )
1375         playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
1376                       (const char *)filenames[i].mb_str(),
1377                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1378                       PLAYLIST_END );
1379
1380     vlc_object_release( p_playlist );
1381
1382     return TRUE;
1383 }
1384 #endif
1385
1386 /*****************************************************************************
1387  * Definition of wxVolCtrl class.
1388  *****************************************************************************/
1389 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1390                       wxPoint point, wxSize size )
1391   : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
1392 {
1393     p_intf = _p_intf;
1394
1395     audio_volume_t i_volume;
1396     aout_VolumeGet( p_intf, &i_volume );
1397     i_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
1398     SetValue( i_volume );
1399     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1400                 i_volume ) );
1401 }
1402
1403 void wxVolCtrl::OnChange( wxMouseEvent& event )
1404 {
1405     if( !event.LeftDown() && !event.LeftIsDown() ) return;
1406
1407     int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
1408     Change( i_volume );
1409 }
1410
1411 void wxVolCtrl::Change( int i_volume )
1412 {
1413     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1414     SetValue( i_volume );
1415     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1416                 i_volume ) );
1417 }