]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/interface.cpp
* modules/gui/wxwindows/open.cpp: fixed the update of the advanced MRLs. Added a...
[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     OpenCapture_Event,
117     OpenSat_Event,
118     OpenOther_Event,
119     EjectDisc_Event,
120
121     StreamWizard_Event,
122     Wizard_Event,
123
124     Playlist_Event,
125     Logs_Event,
126     FileInfo_Event,
127
128     Prefs_Event,
129     Extended_Event,
130     Bookmarks_Event,
131     Skins_Event,
132
133     SliderScroll_Event,
134     StopStream_Event,
135     PlayStream_Event,
136     PrevStream_Event,
137     NextStream_Event,
138     SlowStream_Event,
139     FastStream_Event,
140
141     Adjust_Event,
142     RestoreDefaults_Event,
143     Hue_Event,
144     Contrast_Event,
145     Brightness_Event,
146     Saturation_Event,
147     Gamma_Event,
148
149     Ratio_Event,
150     Visual_Event,
151
152     /* it is important for the id corresponding to the "About" command to have
153      * this standard value as otherwise it won't be handled properly under Mac
154      * (where it is special and put into the "Apple" menu) */
155     About_Event = wxID_ABOUT
156 };
157
158 BEGIN_EVENT_TABLE(Interface, wxFrame)
159     /* Menu events */
160     EVT_MENU(Exit_Event, Interface::OnExit)
161     EVT_MENU(About_Event, Interface::OnAbout)
162
163     EVT_MENU(Playlist_Event, Interface::OnShowDialog)
164     EVT_MENU(Logs_Event, Interface::OnShowDialog)
165     EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
166     EVT_MENU(Prefs_Event, Interface::OnShowDialog)
167
168     EVT_MENU_OPEN(Interface::OnMenuOpen)
169
170     EVT_MENU( Extended_Event, Interface::OnExtended)
171     EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
172
173     EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
174     EVT_BUTTON( RestoreDefaults_Event, Interface::OnRestoreDefaults)
175     EVT_TEXT( Ratio_Event, Interface::OnRatio)
176     EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
177
178 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
179     EVT_CONTEXT_MENU(Interface::OnContextMenu2)
180 #endif
181     EVT_RIGHT_UP(Interface::OnContextMenu)
182
183     /* Toolbar events */
184     EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
185     EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
186     EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
187     EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
188     EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
189     EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)
190     EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
191     EVT_MENU(StreamWizard_Event, Interface::OnShowDialog)
192     EVT_MENU(Wizard_Event, Interface::OnShowDialog)
193     EVT_MENU(StopStream_Event, Interface::OnStopStream)
194     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
195     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
196     EVT_MENU(NextStream_Event, Interface::OnNextStream)
197     EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
198     EVT_MENU(FastStream_Event, Interface::OnFastStream)
199
200     /* Slider events */
201     EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
202     
203     EVT_COMMAND_SCROLL(Hue_Event, Interface::OnAdjustUpdate)
204     EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnAdjustUpdate)
205     EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnAdjustUpdate)
206     EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnAdjustUpdate)
207     EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnAdjustUpdate)
208
209     /* Custom events */
210     EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
211     EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
212
213 END_EVENT_TABLE()
214
215 /*****************************************************************************
216  * Constructor.
217  *****************************************************************************/
218 Interface::Interface( intf_thread_t *_p_intf ):
219     wxFrame( NULL, -1, wxT("VLC media player"),
220              wxDefaultPosition, wxSize(700,100), wxDEFAULT_FRAME_STYLE )
221 {
222     /* Initializations */
223     p_intf = _p_intf;
224     i_old_playing_status = PAUSE_S;
225     b_extra = VLC_FALSE;
226
227     /* Give our interface a nice little icon */
228     SetIcon( wxIcon( vlc_xpm ) );
229
230     /* Create a sizer for the main frame */
231     frame_sizer = new wxBoxSizer( wxVERTICAL );
232     SetSizer( frame_sizer );
233
234     /* Create a dummy widget that can get the keyboard focus */
235     wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
236                                       wxSize(0,0) );
237     p_dummy->SetFocus();
238     frame_sizer->Add( p_dummy, 0, wxEXPAND );
239
240     /* Creation of the menu bar */
241     CreateOurMenuBar();
242
243     /* Creation of the tool bar */
244     CreateOurToolBar();
245
246     /* Create the extra panel */
247     CreateOurExtendedPanel();
248     frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
249     frame_sizer->Hide( extra_frame );
250
251     /* Creation of the status bar
252      * Helptext for menu items and toolbar tools will automatically get
253      * displayed here. */
254     int i_status_width[3] = {-6, -2, -9};
255     statusbar = CreateStatusBar( 3 );                            /* 2 fields */
256     statusbar->SetStatusWidths( 3, i_status_width );
257     statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
258
259     /* Video window */
260     if( config_GetInt( p_intf, "wxwin-embed" ) )
261     {
262         VideoWindow( p_intf, this );
263         frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
264     }
265
266     /* Creation of the slider sub-window */
267     CreateOurSlider();
268     frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
269     frame_sizer->Hide( slider_frame );
270
271     /* Make sure we've got the right background colour */
272     SetBackgroundColour( slider_frame->GetBackgroundColour() );
273
274     /* Layout everything */
275     frame_sizer->Layout();
276     frame_sizer->Fit(this);
277
278 #if wxUSE_DRAG_AND_DROP
279     /* Associate drop targets with the main interface */
280     SetDropTarget( new DragAndDrop( p_intf ) );
281 #endif
282
283     SetupHotkeys();
284
285     /* Start timer */
286     timer = new Timer( p_intf, this );
287 }
288
289 Interface::~Interface()
290 {
291     if( p_intf->p_sys->p_wxwindow )
292     {
293         delete p_intf->p_sys->p_wxwindow;
294     }
295
296     /* Clean up */
297     delete timer;
298 }
299
300 void Interface::OnControlEvent( wxCommandEvent& event )
301 {
302     switch( event.GetId() )
303     {
304     case 0:
305         frame_sizer->Layout();
306         frame_sizer->Fit(this);
307         break;
308
309     case 1:
310         long i_style = GetWindowStyle();
311         if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;
312         else i_style &= ~wxSTAY_ON_TOP;
313         SetWindowStyle( i_style );
314         break;
315     }
316 }
317
318 /*****************************************************************************
319  * Private methods.
320  *****************************************************************************/
321 void Interface::CreateOurMenuBar()
322 {
323     /* Create the "File" menu */
324     wxMenu *file_menu = new wxMenu;
325     file_menu->Append( OpenFileSimple_Event,
326                        wxU(_("Quick &Open File...\tCtrl-O")) );
327
328     file_menu->AppendSeparator();
329     file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );
330     file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );
331     file_menu->Append( OpenNet_Event,
332                        wxU(_("Open &Network Stream...\tCtrl-N")) );
333     file_menu->Append( OpenCapture_Event,
334                        wxU(_("Open &Capture Device...\tCtrl-C")) );
335
336     file_menu->AppendSeparator();
337     file_menu->Append( StreamWizard_Event,
338                        wxU(_("Streaming &Wizard...\tCtrl-W")) );
339 #if 0
340     file_menu->Append( Wizard_Event, wxU(_("New Wizard...")) );
341 #endif
342     file_menu->AppendSeparator();
343     file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );
344
345     /* Create the "View" menu */
346     wxMenu *view_menu = new wxMenu;
347     view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );
348     view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
349     view_menu->Append( FileInfo_Event,
350                        wxU(_("Stream and Media &info...\tCtrl-I")) );
351
352     /* Create the "Auto-generated" menus */
353     p_settings_menu = SettingsMenu( p_intf, this );
354     p_audio_menu = AudioMenu( p_intf, this );
355     p_video_menu = VideoMenu( p_intf, this );
356     p_navig_menu = NavigMenu( p_intf, this );
357
358     /* Create the "Help" menu */
359     wxMenu *help_menu = new wxMenu;
360     help_menu->Append( About_Event, wxU(_("About VLC media player")) );
361
362     /* Append the freshly created menus to the menu bar... */
363     wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
364     menubar->Append( file_menu, wxU(_("&File")) );
365     menubar->Append( view_menu, wxU(_("&View")) );
366     menubar->Append( p_settings_menu, wxU(_("&Settings")) );
367     menubar->Append( p_audio_menu, wxU(_("&Audio")) );
368     menubar->Append( p_video_menu, wxU(_("&Video")) );
369     menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
370     menubar->Append( help_menu, wxU(_("&Help")) );
371
372     /* Attach the menu bar to the frame */
373     SetMenuBar( menubar );
374
375     /* Find out size of menu bar */
376     int i_size = 0;
377     for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
378     {
379         int i_width, i_height;
380         menubar->GetTextExtent( menubar->GetLabelTop(i), &i_width, &i_height );
381         i_size += i_width +
382 #if defined(__WXGTK__)
383             20 /* approximate margin */;
384 #else
385             4 /* approximate margin */;
386 #endif
387     }
388     frame_sizer->SetMinSize( i_size, -1 );
389
390     /* Intercept all menu events in our custom event handler */
391     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
392
393 #if wxUSE_DRAG_AND_DROP
394     /* Associate drop targets with the menubar */
395     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
396 #endif
397 }
398
399 class VLCVolCtrl : public wxControl
400 {
401 public:
402     VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
403     virtual ~VLCVolCtrl() {};
404
405     virtual void OnPaint( wxPaintEvent &event );
406
407   private:
408     DECLARE_EVENT_TABLE()
409 };
410
411 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
412    EVT_PAINT(VLCVolCtrl::OnPaint)
413 END_EVENT_TABLE()
414
415 VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
416                         wxGauge **pp_volctrl )
417   :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, 16 ), wxBORDER_NONE )
418 {
419     *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint(18,0),
420                                   wxSize(44,16) );
421 }
422
423 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
424 {
425     wxPaintDC dc( this );
426     wxBitmap mPlayBitmap( speaker_xpm );
427     dc.DrawBitmap( mPlayBitmap, 1, 0, TRUE );
428 }
429
430 void Interface::CreateOurToolBar()
431 {
432 #define HELP_STOP N_("Stop")
433 #define HELP_PLAY N_("Play")
434 #define HELP_PAUSE N_("Pause")
435 #define HELP_PLO N_("Playlist")
436 #define HELP_PLP N_("Previous playlist item")
437 #define HELP_PLN N_("Next playlist item")
438 #define HELP_SLOW N_("Play slower")
439 #define HELP_FAST N_("Play faster")
440
441     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
442                          * version because we don't include wx.rc */
443
444     wxToolBar *toolbar =
445         CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
446
447     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
448
449     toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
450                       wxU(_(HELP_PLAY)) );
451 #if 0
452     toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
453                       wxU(_(HELP_PAUSE)) );
454 #endif
455     toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
456                       wxU(_(HELP_STOP)) );
457     toolbar->AddSeparator();
458     toolbar->AddTool( PrevStream_Event, wxT(""),
459                       wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
460     toolbar->AddTool( SlowStream_Event, wxT(""),
461                       wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
462     toolbar->AddTool( FastStream_Event, wxT(""),
463                       wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
464     toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
465                       wxU(_(HELP_PLN)) );
466     toolbar->AddSeparator();
467     toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( eject_xpm ),
468                       wxU(_(HELP_PLO)) );
469
470     wxControl *p_dummy_ctrl =
471         new wxControl( toolbar, -1, wxDefaultPosition,
472                        wxSize(64, 16 ), wxBORDER_NONE );
473
474     toolbar->AddControl( p_dummy_ctrl );
475
476     VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
477     toolbar->AddControl( sound_control );
478
479     toolbar->Realize();
480
481 #if wxUSE_DRAG_AND_DROP
482     /* Associate drop targets with the toolbar */
483     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
484 #endif
485 }
486
487 void Interface::CreateOurSlider()
488 {
489     /* Create a new frame and sizer containing the slider */
490     slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
491     slider_frame->SetAutoLayout( TRUE );
492     wxBoxSizer *frame_sizer = new wxBoxSizer( wxHORIZONTAL );
493     //frame_sizer->SetMinSize( -1, 50 );
494
495     /* Create slider */
496     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
497                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
498
499     /* Add everything to the frame */
500     frame_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
501     slider_frame->SetSizer( frame_sizer );
502     frame_sizer->Layout();
503     frame_sizer->SetSizeHints(slider_frame);
504
505     /* Hide the slider by default */
506     slider_frame->Hide();
507 }
508
509
510 void Interface::CreateOurExtendedPanel()
511 {
512     char *psz_filters;
513
514     extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
515     extra_frame->SetAutoLayout( TRUE );
516     wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
517
518     /* Create static box to surround the adjust controls */
519     wxStaticBox *adjust_box =
520            new wxStaticBox( extra_frame, -1, wxU(_("Adjust Image")) );
521
522     /* Create the size for the frame */
523     wxStaticBoxSizer *adjust_sizer =
524         new wxStaticBoxSizer( adjust_box, wxVERTICAL );
525     adjust_sizer->SetMinSize( -1, 50 );
526     
527     /* Create flex grid */
528     wxFlexGridSizer *adjust_gridsizer =
529         new wxFlexGridSizer( 6, 2, 0, 0);
530     adjust_gridsizer->AddGrowableCol(1);
531
532     /* Create every controls */
533
534     /* Create the adjust button */
535     wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
536                                                  wxU(_("Enable")));
537
538     /* Create the restore to defaults button */
539     restoredefaults_button = 
540         new wxButton( extra_frame, RestoreDefaults_Event,
541         wxU(_("Restore Defaults")), wxDefaultPosition);
542
543     wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
544                                        wxU(_("Hue")) );
545     hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
546                                 360, wxDefaultPosition, wxDefaultSize );
547
548
549     wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
550                                        wxU(_("Contrast")) );
551     contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
552                                 200, wxDefaultPosition, wxDefaultSize);
553
554     wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
555                                        wxU(_("Brightness")) );
556     brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
557                            200, wxDefaultPosition, wxDefaultSize) ;
558
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
564     wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
565                                           wxU(_("Gamma")) );
566     gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
567                            100, wxDefaultPosition, wxDefaultSize );
568
569     adjust_gridsizer->Add(adjust_check, 1, wxEXPAND, 0);
570     adjust_gridsizer->Add(restoredefaults_button, 1, wxEXPAND, 0);
571     adjust_gridsizer->Add(hue_text, 1, wxEXPAND, 0);
572     adjust_gridsizer->Add(hue_slider, 1, wxEXPAND, 0);
573     adjust_gridsizer->Add(contrast_text, 1, wxEXPAND, 0);
574     adjust_gridsizer->Add(contrast_slider, 1, wxEXPAND, 0);
575     adjust_gridsizer->Add(brightness_text, 1, wxEXPAND, 0);
576     adjust_gridsizer->Add(brightness_slider, 1, wxEXPAND, 0);
577     adjust_gridsizer->Add(saturation_text, 1, wxEXPAND, 0);
578     adjust_gridsizer->Add(saturation_slider, 1, wxEXPAND, 0);
579     adjust_gridsizer->Add(gamma_text, 1, wxEXPAND, 0);
580     adjust_gridsizer->Add(gamma_slider, 1, wxEXPAND, 0);
581     
582     adjust_sizer->Add(adjust_gridsizer,1,wxEXPAND, 0);
583     
584     extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
585
586     /* Create sizer to surround the other controls */
587     wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
588
589
590     wxStaticBox *video_box =
591             new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
592     /* Create the sizer for the frame */
593     wxStaticBoxSizer *video_sizer =
594        new wxStaticBoxSizer( video_box, wxVERTICAL );
595     video_sizer->SetMinSize( -1, 50 );
596
597     static const wxString ratio_array[] =
598     {
599         wxT("4:3"),
600         wxT("16:9"),
601     };
602
603     wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
604     wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
605                                           wxU(_("Aspect Ratio")) );
606
607     ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
608                                   wxDefaultPosition, wxSize(120,-1),
609                                   WXSIZEOF(ratio_array), ratio_array,
610                                   0 );
611
612     ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
613     ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
614     ratio_sizer->Layout();
615
616     video_sizer->Add( ratio_sizer  , 0 , wxALL , 0 );
617     video_sizer->Layout();
618
619 #if 0
620     wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );
621
622     wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
623                                             wxU(_("Visualizations")) );
624
625     visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
626     visual_sizer->Layout();
627
628     wxStaticBox *audio_box =
629               new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
630     /* Create the sizer for the frame */
631     wxStaticBoxSizer *audio_sizer =
632         new wxStaticBoxSizer( audio_box, wxVERTICAL );
633     audio_sizer->SetMinSize( -1, 50 );
634
635     audio_sizer->Add( visual_sizer, 0, wxALL, 0);
636     audio_sizer->Layout();
637
638     other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
639 #endif
640     other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
641     other_sizer->Layout();
642
643     extra_sizer->Add(other_sizer,0,wxBOTTOM,5);
644
645     extra_frame->SetSizer( extra_sizer );
646
647     /* Layout the whole panel */
648     extra_sizer->Layout();
649
650     extra_sizer->SetSizeHints(extra_frame);
651
652     /* Write down initial values */
653 #if 0
654     psz_filters = config_GetPsz( p_intf, "audio-filter" );
655     if( psz_filters && strstr( psz_filters, "visual" ) )
656     {
657         visual_checkbox->SetValue(1);
658     }
659     if( psz_filters ) free( psz_filters );
660 #endif
661     psz_filters = config_GetPsz( p_intf, "filter" );
662     if( psz_filters && strstr( psz_filters, "adjust" ) )
663     {
664         adjust_check->SetValue( 1 );
665         restoredefaults_button->Enable();
666         saturation_slider->Enable();
667         contrast_slider->Enable();
668         brightness_slider->Enable();
669         hue_slider->Enable();
670         gamma_slider->Enable();
671     }
672     else
673     {
674         adjust_check->SetValue( 0 );
675         restoredefaults_button->Disable();
676         saturation_slider->Disable();
677         contrast_slider->Disable();
678         brightness_slider->Disable();
679         hue_slider->Disable();
680         gamma_slider->Disable();
681     }
682     if( psz_filters ) free( psz_filters );
683
684     int i_value = config_GetInt( p_intf, "hue" );
685     if( i_value > 0 && i_value < 360 )
686         hue_slider->SetValue( i_value );
687
688     float f_value;
689     f_value = config_GetFloat( p_intf, "saturation" );
690     if( f_value > 0 && f_value < 5 )
691         saturation_slider->SetValue( (int)(100 * f_value) );
692     f_value = config_GetFloat( p_intf, "contrast" );
693     if( f_value > 0 && f_value < 4 )
694         contrast_slider->SetValue( (int)(100 * f_value) );
695     f_value = config_GetFloat( p_intf, "brightness" );
696     if( f_value > 0 && f_value < 2 )
697         brightness_slider->SetValue( (int)(100 * f_value) );
698     f_value = config_GetFloat( p_intf, "gamma" );
699     if( f_value > 0 && f_value < 10 )
700         gamma_slider->SetValue( (int)(10 * f_value) );
701
702     extra_frame->Hide();
703 }
704
705 static int ConvertHotkeyModifiers( int i_hotkey )
706 {
707     int i_accel_flags = 0;
708     if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
709     if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
710     if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
711     if( !i_accel_flags ) i_accel_flags = wxACCEL_NORMAL;
712     return i_accel_flags;
713 }
714
715 static int ConvertHotkey( int i_hotkey )
716 {
717     int i_key = i_hotkey & ~KEY_MODIFIER;
718     if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
719     else if( i_key & KEY_SPECIAL )
720     {
721         switch ( i_key )
722         {
723         case KEY_LEFT: return WXK_LEFT;
724         case KEY_RIGHT: return WXK_RIGHT;
725         case KEY_UP: return WXK_UP;
726         case KEY_DOWN: return WXK_DOWN;
727         case KEY_SPACE: return WXK_SPACE;
728         case KEY_ENTER: return WXK_RETURN;
729         case KEY_F1: return WXK_F1;
730         case KEY_F2: return WXK_F2;
731         case KEY_F3: return WXK_F3;
732         case KEY_F4: return WXK_F4;
733         case KEY_F5: return WXK_F5;
734         case KEY_F6: return WXK_F6;
735         case KEY_F7: return WXK_F7;
736         case KEY_F8: return WXK_F8;
737         case KEY_F9: return WXK_F9;
738         case KEY_F10: return WXK_F10;
739         case KEY_F11: return WXK_F11;
740         case KEY_F12: return WXK_F12;
741         case KEY_HOME: return WXK_HOME;
742         case KEY_END: return WXK_HOME;
743         case KEY_MENU: return WXK_MENU;
744         case KEY_ESC: return WXK_ESCAPE;
745         case KEY_PAGEUP: return WXK_PRIOR;
746         case KEY_PAGEDOWN: return WXK_NEXT;
747         case KEY_TAB: return WXK_TAB;
748         case KEY_BACKSPACE: return WXK_BACK;
749         }
750     }
751     return WXK_F24;
752 }
753
754 void Interface::SetupHotkeys()
755 {
756     struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
757     int i_hotkeys;
758
759     /* Count number of hoteys */
760     for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );
761
762     p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;
763     p_intf->p_sys->i_hotkeys = i_hotkeys;
764
765     wxAcceleratorEntry p_entries[i_hotkeys];
766
767     /* Setup the hotkeys as accelerators */
768     for( int i = 0; i < i_hotkeys; i++ )
769     {
770         p_entries[i].Set( ConvertHotkeyModifiers( p_hotkeys[i].i_key ),
771                           ConvertHotkey( p_hotkeys[i].i_key ),
772                           p_intf->p_sys->i_first_hotkey_event + i );
773     }
774
775     wxAcceleratorTable accel( i_hotkeys, p_entries );
776
777     if( !accel.Ok() )
778     {
779         msg_Err( p_intf, "invalid accelerator table" );
780     }
781     else
782     {
783         SetAcceleratorTable( accel );
784         msg_Dbg( p_intf, "accelerator table loaded" );
785     }
786 }
787
788 /*****************************************************************************
789  * Event Handlers.
790  *****************************************************************************/
791
792 void Interface::OnMenuOpen(wxMenuEvent& event)
793 {
794 #if defined( __WXMSW__ )
795 #   define GetEventObject GetMenu
796 #endif
797
798     if( event.GetEventObject() == p_settings_menu )
799     {
800         p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );
801
802         /* Add static items */
803         p_settings_menu->AppendCheckItem( Extended_Event,
804             wxU(_("&Extended GUI") ) );
805         p_settings_menu->AppendCheckItem( Bookmarks_Event,
806             wxU(_("&Bookmarks...") ) );
807         p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")) );
808     }
809
810     else if( event.GetEventObject() == p_audio_menu )
811     {
812         p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );
813     }
814
815     else if( event.GetEventObject() == p_video_menu )
816     {
817         p_video_menu = VideoMenu( p_intf, this, p_video_menu );
818     }
819
820     else if( event.GetEventObject() == p_navig_menu )
821     {
822         p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );
823     }
824
825 #if defined( __WXMSW__ )
826 #   undef GetEventObject
827 #endif
828 }
829
830 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
831 void Interface::OnContextMenu2(wxContextMenuEvent& event)
832 {
833     /* Only show the context menu for the main interface */
834     if( GetId() != event.GetId() )
835     {
836         event.Skip();
837         return;
838     }
839
840     if( p_intf->p_sys->pf_show_dialog )
841         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
842 }
843 #endif
844 void Interface::OnContextMenu(wxMouseEvent& event)
845 {
846     if( p_intf->p_sys->pf_show_dialog )
847         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
848 }
849
850 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
851 {
852     /* TRUE is to force the frame to close. */
853     Close(TRUE);
854 }
855
856 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
857 {
858     wxString msg;
859     msg.Printf( wxString(wxT("VLC media player " VERSION)) +
860         wxU(_(" (wxWindows interface)\n\n")) +
861         wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
862         wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
863         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
864               "http://www.videolan.org/\n\n")) );
865
866     wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
867                   wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
868 }
869
870 void Interface::OnShowDialog( wxCommandEvent& event )
871 {
872     if( p_intf->p_sys->pf_show_dialog )
873     {
874         int i_id;
875
876         switch( event.GetId() )
877         {
878         case OpenFileSimple_Event:
879             i_id = INTF_DIALOG_FILE_SIMPLE;
880             break;
881         case OpenAdv_Event:
882             i_id = INTF_DIALOG_FILE;
883         case OpenFile_Event:
884             i_id = INTF_DIALOG_FILE;
885             break;
886         case OpenDisc_Event:
887             i_id = INTF_DIALOG_DISC;
888             break;
889         case OpenNet_Event:
890             i_id = INTF_DIALOG_NET;
891             break;
892         case OpenCapture_Event:
893             i_id = INTF_DIALOG_CAPTURE;
894             break;
895         case OpenSat_Event:
896             i_id = INTF_DIALOG_SAT;
897             break;
898         case Playlist_Event:
899             i_id = INTF_DIALOG_PLAYLIST;
900             break;
901         case Logs_Event:
902             i_id = INTF_DIALOG_MESSAGES;
903             break;
904         case FileInfo_Event:
905             i_id = INTF_DIALOG_FILEINFO;
906             break;
907         case Prefs_Event:
908             i_id = INTF_DIALOG_PREFS;
909             break;
910         case StreamWizard_Event:
911             i_id = INTF_DIALOG_STREAMWIZARD;
912             break;
913         case Wizard_Event:
914             i_id = INTF_DIALOG_WIZARD;
915             break;
916         case Bookmarks_Event:
917             i_id = INTF_DIALOG_BOOKMARKS;
918             break;
919         default:
920             i_id = INTF_DIALOG_FILE;
921             break;
922         }
923
924         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
925     }
926 }
927
928 void Interface::OnExtended(wxCommandEvent& event)
929 {
930     if( b_extra == VLC_FALSE)
931     {
932         extra_frame->Show();
933         frame_sizer->Show( extra_frame );
934         b_extra = VLC_TRUE;
935     }
936     else
937     {
938         extra_frame->Hide();
939         frame_sizer->Hide( extra_frame );
940         b_extra = VLC_FALSE;
941     }
942     frame_sizer->Layout();
943     frame_sizer->Fit(this);
944 }
945
946 void Interface::OnEnableAdjust(wxCommandEvent& event)
947 {
948     char *psz_filters=config_GetPsz( p_intf, "filter");
949     char *psz_new = NULL;
950     if( event.IsChecked() )
951     {
952         if(psz_filters == NULL)
953         {
954             psz_new = strdup( "adjust" );
955         }
956         else
957         {
958             psz_new= (char *) malloc(strlen(psz_filters) + 8 );
959             sprintf( psz_new, "%s:adjust", psz_filters);
960         }
961         config_PutPsz( p_intf, "filter", psz_new );
962         vlc_value_t val;
963         vout_thread_t *p_vout =
964            (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
965                                        FIND_ANYWHERE );
966         if( p_vout != NULL )
967         {
968             val.psz_string = strdup( psz_new );
969             var_Set( p_vout, "filter", val);
970             vlc_object_release( p_vout );
971         }
972         if( val.psz_string ) free( val.psz_string );
973         restoredefaults_button->Enable();
974         brightness_slider->Enable();
975         saturation_slider->Enable();
976         contrast_slider->Enable();
977         hue_slider->Enable();
978         gamma_slider->Enable();
979     }
980     else
981     {
982         if( psz_filters != NULL )
983         {
984
985             char *psz_current;
986             unsigned int i=0;
987             for( i = 0; i< strlen(psz_filters ); i++)
988             {
989                 if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
990                 {
991                     if(i > 0)
992                         if( psz_filters[i-1] == ':' ) i--;
993                     psz_current = strchr( &psz_filters[i+1] , ':' );
994                     if( !psz_current )
995                         psz_filters[i] = '\0';
996                     else
997                     {
998                        memmove( &psz_filters[i] , psz_current,
999                                 &psz_filters[strlen(psz_filters)]-psz_current
1000                                 +1);
1001                     }
1002                 }
1003             }
1004             config_PutPsz( p_intf, "filter", psz_filters);
1005             vlc_value_t val;
1006             val.psz_string = strdup( psz_filters );
1007             vout_thread_t *p_vout =
1008                (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1009                                        FIND_ANYWHERE );
1010             if( p_vout != NULL )
1011             {
1012                 var_Set( p_vout, "filter", val);
1013                 vlc_object_release( p_vout );
1014             }
1015             if( val.psz_string ) free( val.psz_string );
1016         }
1017         restoredefaults_button->Disable();
1018         brightness_slider->Disable();
1019         saturation_slider->Disable();
1020         contrast_slider->Disable();
1021         hue_slider->Disable();
1022         gamma_slider->Disable();
1023     }
1024     if(psz_filters) free(psz_filters);
1025     if(psz_new) free(psz_new);
1026 }
1027
1028 void Interface::OnRestoreDefaults( wxCommandEvent &event)
1029 {
1030     hue_slider->SetValue(0);
1031     saturation_slider->SetValue(100);
1032     brightness_slider->SetValue(100);
1033     contrast_slider->SetValue(100),
1034     gamma_slider->SetValue(10);
1035
1036     wxScrollEvent *hscroll_event = new wxScrollEvent(0, Hue_Event, 0);
1037     OnAdjustUpdate(*hscroll_event);
1038     
1039     wxScrollEvent *sscroll_event = new wxScrollEvent(0, Saturation_Event, 100);
1040     OnAdjustUpdate(*sscroll_event);
1041     
1042     wxScrollEvent *bscroll_event = new wxScrollEvent(0, Brightness_Event, 100);
1043     OnAdjustUpdate(*bscroll_event);
1044     
1045     wxScrollEvent *cscroll_event = new wxScrollEvent(0, Contrast_Event, 100);
1046     OnAdjustUpdate(*cscroll_event);
1047     
1048     wxScrollEvent *gscroll_event = new wxScrollEvent(0, Gamma_Event, 10);
1049     OnAdjustUpdate(*gscroll_event);
1050
1051 }
1052
1053 void Interface::OnAdjustUpdate( wxScrollEvent &event)
1054 {
1055     vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE);
1056     if(p_vout == NULL)
1057         switch(event.GetId())
1058         {
1059             case Hue_Event: 
1060                 config_PutInt( p_intf , "hue" , event.GetPosition() );
1061                 break;
1062             
1063             case Saturation_Event: 
1064                 config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
1065                 break;
1066             
1067             case Brightness_Event: 
1068                 config_PutFloat( p_intf , "brightness" , (float)event.GetPosition()/100 );
1069                 break;
1070             
1071             case Contrast_Event: 
1072                 config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
1073                 break;
1074             
1075             case Gamma_Event: 
1076                 config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
1077                 break;
1078         }
1079     else
1080     {
1081         vlc_value_t val;
1082         switch(event.GetId())
1083         {
1084             case Hue_Event: 
1085                 val.i_int = event.GetPosition();
1086                 var_Set(p_vout, "hue", val);
1087                 break;
1088             
1089             case Saturation_Event:
1090                 val.f_float = (float)event.GetPosition()/100;
1091                 var_Set(p_vout, "saturation", val);
1092                 break;
1093             
1094             case Brightness_Event: 
1095                 val.f_float = (float)event.GetPosition()/100;
1096                 var_Set(p_vout, "brightness", val);
1097                 break;
1098             
1099             case Contrast_Event: 
1100                 val.f_float = (float)event.GetPosition()/100;
1101                 var_Set(p_vout, "contrast", val);
1102                 break;
1103             
1104             case Gamma_Event: 
1105                 val.f_float = (float)event.GetPosition()/10;
1106                 var_Set(p_vout, "gamma", val);
1107                 break;
1108         }
1109         vlc_object_release(p_vout);
1110     }
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 ], psz_total[ MSTRTIME_MAX_SIZE ];
1225             mtime_t i_seconds;
1226             vlc_value_t val;
1227
1228             var_Get( p_intf->p_sys->p_input, "length",  &val );
1229             i_seconds = val.i_time / 1000000;
1230             secstotimestr ( psz_total, i_seconds );
1231
1232             statusbar->SetStatusText(
1233                 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
1234                     psz_time, p_area->i_size * event.GetPosition()
1235                         / SLIDER_MAX_POS )) + wxString(wxT(" / ")) +
1236                         wxU(psz_total), 0 );
1237 #undef p_area
1238         }
1239     }
1240 #endif
1241
1242 #undef WIN32
1243     vlc_mutex_unlock( &p_intf->change_lock );
1244 }
1245
1246 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1247 {
1248     playlist_t * p_playlist =
1249         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1250                                        FIND_ANYWHERE );
1251     if( p_playlist == NULL )
1252     {
1253         return;
1254     }
1255
1256     vlc_mutex_lock( &p_playlist->object_lock );
1257     if( p_playlist->p_input != NULL )
1258     {
1259         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1260         if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
1261         {
1262             vlc_value_t val; val.b_bool = VLC_TRUE;
1263             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1264             var_Set( p_playlist->p_input, "prev-title", val );
1265         } else
1266             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1267     }
1268     vlc_mutex_unlock( &p_playlist->object_lock );
1269
1270     playlist_Prev( p_playlist );
1271     vlc_object_release( p_playlist );
1272 }
1273
1274 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1275 {
1276     playlist_t * p_playlist =
1277         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1278                                        FIND_ANYWHERE );
1279     if( p_playlist == NULL )
1280     {
1281         return;
1282     }
1283
1284     vlc_mutex_lock( &p_playlist->object_lock );
1285     if( p_playlist->p_input != NULL )
1286     {
1287         vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
1288         if( p_playlist->p_input->stream.i_area_nb > 1 &&
1289             p_playlist->p_input->stream.p_selected_area->i_id <
1290               p_playlist->p_input->stream.i_area_nb - 1 )
1291         {
1292             vlc_value_t val; val.b_bool = VLC_TRUE;
1293             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1294             var_Set( p_playlist->p_input, "next-title", val );
1295         } else
1296             vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
1297     }
1298     vlc_mutex_unlock( &p_playlist->object_lock );
1299
1300     playlist_Next( p_playlist );
1301     vlc_object_release( p_playlist );
1302 }
1303
1304 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1305 {
1306     input_thread_t *p_input =
1307         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1308                                            FIND_ANYWHERE );
1309     if( p_input )
1310     {
1311         vlc_value_t val; val.b_bool = VLC_TRUE;
1312
1313         var_Set( p_input, "rate-slower", val );
1314         vlc_object_release( p_input );
1315     }
1316 }
1317
1318 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1319 {
1320     input_thread_t *p_input =
1321         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1322                                            FIND_ANYWHERE );
1323     if( p_input )
1324     {
1325         vlc_value_t val; val.b_bool = VLC_TRUE;
1326
1327         var_Set( p_input, "rate-faster", val );
1328         vlc_object_release( p_input );
1329     }
1330 }
1331
1332 void Interface::TogglePlayButton( int i_playing_status )
1333 {
1334     if( i_playing_status == i_old_playing_status )
1335         return;
1336
1337     GetToolBar()->DeleteTool( PlayStream_Event );
1338
1339     if( i_playing_status == PLAYING_S )
1340     {
1341         GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Pause")),
1342                                   wxBitmap( pause_xpm ), wxNullBitmap,
1343                                   wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
1344     }
1345     else
1346     {
1347         GetToolBar()->InsertTool( 0, PlayStream_Event, wxU(_("Play")),
1348                                   wxBitmap( play_xpm ), wxNullBitmap,
1349                                   wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
1350     }
1351
1352     GetToolBar()->Realize();
1353
1354     i_old_playing_status = i_playing_status;
1355 }
1356
1357 #if wxUSE_DRAG_AND_DROP
1358 /*****************************************************************************
1359  * Definition of DragAndDrop class.
1360  *****************************************************************************/
1361 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1362 {
1363     p_intf = _p_intf;
1364     b_enqueue = _b_enqueue;
1365 }
1366
1367 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1368                                const wxArrayString& filenames )
1369 {
1370     /* Add dropped files to the playlist */
1371
1372     playlist_t *p_playlist =
1373         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1374                                        FIND_ANYWHERE );
1375     if( p_playlist == NULL )
1376     {
1377         return FALSE;
1378     }
1379
1380     for( size_t i = 0; i < filenames.GetCount(); i++ )
1381         playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
1382                       (const char *)filenames[i].mb_str(),
1383                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1384                       PLAYLIST_END );
1385
1386     vlc_object_release( p_playlist );
1387
1388     return TRUE;
1389 }
1390 #endif
1391
1392 /*****************************************************************************
1393  * Definition of wxVolCtrl class.
1394  *****************************************************************************/
1395 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1396                       wxPoint point, wxSize size )
1397   : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
1398 {
1399     p_intf = _p_intf;
1400
1401     audio_volume_t i_volume;
1402     aout_VolumeGet( p_intf, &i_volume );
1403     i_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
1404     SetValue( i_volume );
1405     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1406                 i_volume ) );
1407 }
1408
1409 void wxVolCtrl::OnChange( wxMouseEvent& event )
1410 {
1411     if( !event.LeftDown() && !event.LeftIsDown() ) return;
1412
1413     int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
1414     Change( i_volume );
1415 }
1416
1417 void wxVolCtrl::Change( int i_volume )
1418 {
1419     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1420     SetValue( i_volume );
1421     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1422                 i_volume ) );
1423 }