]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/interface.cpp
* modules/gui/wxwidgets: wxSplitterWindow is buggy under wxGTK so we implement our...
[vlc] / modules / gui / wxwidgets / interface.cpp
1 /*****************************************************************************
2  * interface.cpp : wxWidgets plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2005 the VideoLAN team
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 "interface.hpp"
28 #include "playlist_manager.hpp"
29 #include "extrapanel.hpp"
30 #include "timer.hpp"
31 #include "video.hpp"
32 #include <vlc_keys.h>
33
34 #include "charset.h"
35
36 #include <vlc/aout.h>
37 #include "charset.h"
38
39 #include <wx/splitter.h>
40
41 /* include the toolbar graphics */
42 #include "bitmaps/play.xpm"
43 #include "bitmaps/pause.xpm"
44 #include "bitmaps/stop.xpm"
45 #include "bitmaps/prev.xpm"
46 #include "bitmaps/next.xpm"
47 #include "bitmaps/eject.xpm"
48 #include "bitmaps/slow.xpm"
49 #include "bitmaps/fast.xpm"
50 #include "bitmaps/playlist.xpm"
51 #include "bitmaps/playlist_small.xpm"
52 #include "bitmaps/speaker.xpm"
53 #include "bitmaps/speaker_mute.xpm"
54
55 #define TOOLBAR_BMP_WIDTH 16
56 #define TOOLBAR_BMP_HEIGHT 16
57
58 /* include the icon graphic */
59 #include "../../../share/vlc32x32.xpm"
60 /* include a small icon graphic for the systray icon */
61 #ifdef wxHAS_TASK_BAR_ICON
62 #include "../../../share/vlc16x16.xpm"
63 #endif
64
65 /*****************************************************************************
66  * Local class declarations.
67  *****************************************************************************/
68 class wxMenuExt: public wxMenu
69 {
70 public:
71     /* Constructor */
72     wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
73                    const wxString& helpString, wxItemKind kind,
74                    char *_psz_var, int _i_object_id, vlc_value_t _val,
75                    int _i_val_type );
76
77     virtual ~wxMenuExt() {};
78
79     char *psz_var;
80     int  i_val_type;
81     int  i_object_id;
82     vlc_value_t val;
83
84 private:
85
86 };
87
88 class wxVolCtrl;
89 class VLCVolCtrl : public wxControl
90 {
91 public:
92     VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent );
93     virtual ~VLCVolCtrl() {};
94
95     virtual void OnPaint( wxPaintEvent &event );
96     void OnChange( wxMouseEvent& event );
97     void UpdateVolume();
98
99   private:
100     DECLARE_EVENT_TABLE()
101
102     wxVolCtrl *gauge;
103     int i_y_offset;
104     vlc_bool_t b_mute;
105     intf_thread_t *p_intf;
106 };
107
108 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
109     EVT_PAINT(VLCVolCtrl::OnPaint)
110
111     /* Mouse events */
112     EVT_LEFT_UP(VLCVolCtrl::OnChange)
113 END_EVENT_TABLE()
114
115 class Splitter : public wxSplitterWindow
116 {
117 public:
118     Splitter( wxWindow *p_parent, intf_thread_t *_p_intf )
119       : wxSplitterWindow( p_parent, -1, wxDefaultPosition, wxSize(0,0),
120                           wxCLIP_CHILDREN|wxSP_3DSASH ),
121         p_intf(_p_intf), i_sash_position(150) {}
122     virtual ~Splitter() {};
123
124     virtual bool Split( wxWindow* window1, wxWindow* window2 )
125     {
126         return wxSplitterWindow::SplitHorizontally( window1, window2,
127                                                     -i_sash_position );
128     }
129
130 private:
131     DECLARE_EVENT_TABLE()
132
133     void OnSize( wxSizeEvent &event )
134     {
135         SetSashPosition( event.GetSize().GetHeight() - i_sash_position );
136         event.Skip();
137     }
138
139     void OnSashPosChanged( wxSplitterEvent &event )
140     {
141         if( !GetSize().GetHeight() ){ event.Skip(); return; }
142         i_sash_position = GetSize().GetHeight() - event.GetSashPosition();
143         event.Skip();
144     }
145
146     intf_thread_t *p_intf;
147     int i_sash_position;
148 };
149
150 BEGIN_EVENT_TABLE(Splitter, wxSplitterWindow)
151     EVT_SIZE( Splitter::OnSize )
152     EVT_SPLITTER_SASH_POS_CHANGED(-1, Splitter::OnSashPosChanged)
153 END_EVENT_TABLE()
154
155 /*****************************************************************************
156  * Event Table.
157  *****************************************************************************/
158
159 DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );
160
161 /* IDs for the controls and the menu commands */
162 enum
163 {
164     /* menu items */
165     MenuDummy_Event = wxID_HIGHEST + 1000,
166     Exit_Event = wxID_HIGHEST,
167     OpenFileSimple_Event,
168     OpenAdv_Event,
169     OpenFile_Event,
170     OpenDir_Event,
171     OpenDisc_Event,
172     OpenNet_Event,
173     OpenCapture_Event,
174     OpenSat_Event,
175     OpenOther_Event,
176     EjectDisc_Event,
177
178     Wizard_Event,
179
180     Playlist_Event,
181     PlaylistSmall_Event,
182     Logs_Event,
183     FileInfo_Event,
184
185     Prefs_Event,
186     Extended_Event,
187     Bookmarks_Event,
188     Skins_Event,
189
190     StopStream_Event,
191     PlayStream_Event,
192     PrevStream_Event,
193     NextStream_Event,
194     SlowStream_Event,
195     FastStream_Event,
196
197     /* it is important for the id corresponding to the "About" command to have
198      * this standard value as otherwise it won't be handled properly under Mac
199      * (where it is special and put into the "Apple" menu) */
200     About_Event = wxID_ABOUT,
201     UpdateVLC_Event,
202     VLM_Event,
203
204     Iconize_Event
205 };
206
207 BEGIN_EVENT_TABLE(Interface, wxFrame)
208     /* Menu events */
209     EVT_MENU(Exit_Event, Interface::OnExit)
210     EVT_MENU(About_Event, Interface::OnAbout)
211     EVT_MENU(UpdateVLC_Event, Interface::OnShowDialog)
212     EVT_MENU(VLM_Event, Interface::OnShowDialog)
213
214     EVT_MENU(Playlist_Event, Interface::OnShowDialog)
215     EVT_MENU(PlaylistSmall_Event, Interface::OnSmallPlaylist)
216     EVT_MENU(Logs_Event, Interface::OnShowDialog)
217     EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
218     EVT_MENU(Prefs_Event, Interface::OnShowDialog)
219
220     EVT_MENU_OPEN(Interface::OnMenuOpen)
221
222     EVT_MENU( Extended_Event, Interface::OnExtended )
223
224     EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
225
226 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
227     EVT_CONTEXT_MENU(Interface::OnContextMenu2)
228 #endif
229     EVT_RIGHT_UP(Interface::OnContextMenu)
230
231     /* Toolbar events */
232     EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
233     EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
234     EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
235     EVT_MENU(OpenDir_Event, Interface::OnShowDialog)
236     EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
237     EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
238     EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)
239     EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
240     EVT_MENU(Wizard_Event, Interface::OnShowDialog)
241     EVT_MENU(StopStream_Event, Interface::OnStopStream)
242     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
243     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
244     EVT_MENU(NextStream_Event, Interface::OnNextStream)
245     EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
246     EVT_MENU(FastStream_Event, Interface::OnFastStream)
247
248     /* Custom events */
249     EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
250     EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
251 END_EVENT_TABLE()
252
253 /*****************************************************************************
254  * Constructor.
255  *****************************************************************************/
256 Interface::Interface( intf_thread_t *_p_intf, long style ):
257     wxFrame( NULL, -1, wxT("VLC media player"),
258              wxDefaultPosition, wxSize(700,100), style )
259 {
260     /* Initializations */
261     p_intf = _p_intf;
262     b_extra = VLC_FALSE;
263     extra_frame = 0;
264     b_playlist_manager = VLC_FALSE;
265     playlist_manager = 0;
266
267     /* Give our interface a nice little icon */
268     SetIcon( wxIcon( vlc_xpm ) );
269
270     /* Create a splitter window that will fill in the interface window.
271      * We need a splitter bar in order to make the embedded playlist
272      * resizable. */
273     splitter = new Splitter( this, p_intf );
274     main_sizer = new wxBoxSizer( wxVERTICAL );
275     main_sizer->Add( splitter, 1, wxEXPAND );
276     SetSizer( main_sizer );
277
278     /* Create a main panel that will fill in the interface window */
279     main_panel = new wxPanel( splitter, -1, wxPoint(0,0), wxSize(0,0),
280                               wxCLIP_CHILDREN );
281     main_panel->SetFocus();
282
283 #if defined(__WXGTK20__) && wxCHECK_VERSION(2,5,6)
284     /* As ugly as your butt! Please remove when wxWidgets 2.6 fixed their
285      * Accelerators bug. */
286     main_panel->m_imData = 0;
287     m_imData = 0;
288 #endif
289
290     /* Create a sizer for the main frame */
291     panel_sizer = new wxBoxSizer( wxVERTICAL );
292     main_panel->SetSizer( panel_sizer );
293
294     /* Put this in the splitter */
295     splitter->Initialize( main_panel );
296
297 #ifdef wxHAS_TASK_BAR_ICON
298     /* Systray integration */
299     p_systray = NULL;
300     if( config_GetInt( p_intf, "wx-systray" ) )
301     {
302         p_systray = new Systray( this, p_intf );
303     }
304 #endif
305
306     /* Creation of the menu bar */
307     CreateOurMenuBar();
308
309     /* Creation of the tool bar */
310     CreateOurToolBar();
311
312     /* Creation of the status bar
313      * Helptext for menu items and toolbar tools will automatically get
314      * displayed here. */
315     int i_status_width[3] = {100, 40, -1};
316     statusbar = CreateStatusBar( 3 );                            /* 2 fields */
317     statusbar->SetStatusWidths( 3, i_status_width );
318     statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
319
320     /* Get minimum window size to prevent user from glitching it */
321     splitter->SetSizeHints( -1, 0 );
322     panel_sizer->Layout(); panel_sizer->Fit( main_panel );
323     main_sizer->Layout(); main_sizer->Fit( this );
324     main_min_size = GetSize();
325     splitter->SetSizeHints( -1, -1 );
326
327     /* Video window */
328     video_window = 0;
329     if( config_GetInt( p_intf, "wx-embed" ) )
330     {
331         video_window = CreateVideoWindow( p_intf, main_panel );
332         panel_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
333     }
334
335     /* Creation of the input manager panel */
336     input_manager = new InputManager( p_intf, this, main_panel );
337     panel_sizer->Add( input_manager, 0, wxEXPAND , 0 );
338
339     /* Layout everything */
340     splitter->SetSizeHints( -1, 0 );
341     panel_sizer->Layout(); panel_sizer->Fit( main_panel );
342     main_sizer->Layout(); main_sizer->Fit( this );
343     splitter->SetSizeHints( -1, -1 );
344
345 #if wxUSE_DRAG_AND_DROP
346     /* Associate drop targets with the main interface */
347     SetDropTarget( new DragAndDrop( p_intf ) );
348 #endif
349
350     SetupHotkeys();
351
352     /* Start timer */
353     timer = new Timer( p_intf, this );
354
355     /* Restore previous position / settings */
356     WindowSettings *ws = p_intf->p_sys->p_window_settings;
357     wxPoint p;
358     wxSize s;
359     bool b_shown;
360
361     ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),
362                    wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );
363
364     if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) Move( p );
365
366     /* Show extended GUI if requested */
367     wxCommandEvent dummy;
368     if( config_GetInt( p_intf, "wx-extended" ) ) OnExtended( dummy );
369
370     SetIntfMinSize();
371 }
372
373 Interface::~Interface()
374 {
375     WindowSettings *ws = p_intf->p_sys->p_window_settings;
376
377     if( !IsIconized() )
378     {
379         ws->SetSettings( WindowSettings::ID_MAIN, true,
380                          GetPosition(), GetSize() );
381     }
382
383     PopEventHandler(true);
384
385     if( video_window ) delete video_window;
386
387 #ifdef wxHAS_TASK_BAR_ICON
388     if( p_systray ) delete p_systray;
389 #endif
390
391     if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;
392
393     /* Clean up */
394     delete timer;
395 }
396
397 void Interface::Init()
398 {
399     /* Misc init */
400     SetupHotkeys();
401 }
402
403 void Interface::Update()
404 {
405     /* Misc updates */
406     ((VLCVolCtrl *)volctrl)->UpdateVolume();
407
408     if( playlist_manager ) playlist_manager->Update();
409 }
410
411 void Interface::OnControlEvent( wxCommandEvent& event )
412 {
413     switch( event.GetId() )
414     {
415     case 0:
416         main_sizer->Layout();
417         main_sizer->Fit( this );
418         break;
419
420     case 1:
421         long i_style = GetWindowStyle();
422         if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;
423         else i_style &= ~wxSTAY_ON_TOP;
424         SetWindowStyle( i_style );
425         break;
426     }
427 }
428
429 /*****************************************************************************
430  * Private methods.
431  *****************************************************************************/
432 void Interface::CreateOurMenuBar()
433 {
434     int minimal = config_GetInt( p_intf, "wx-minimal" );
435
436     /* Create the "File" menu */
437     wxMenu *file_menu = new wxMenu;
438
439     if (!minimal)
440     {
441     file_menu->Append( OpenFileSimple_Event,
442                        wxU(_("Quick &Open File...\tCtrl-O")) );
443
444     file_menu->AppendSeparator();
445     file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );
446     file_menu->Append( OpenDir_Event, wxU(_("Open Dir&ectory...\tCtrl-E")) );
447     file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );
448     file_menu->Append( OpenNet_Event,
449                        wxU(_("Open &Network Stream...\tCtrl-N")) );
450     file_menu->Append( OpenCapture_Event,
451                        wxU(_("Open C&apture Device...\tCtrl-A")) );
452
453     file_menu->AppendSeparator();
454     file_menu->Append( Wizard_Event, wxU(_("&Wizard...\tCtrl-W")) );
455     file_menu->AppendSeparator();
456     }
457     file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );
458
459     /* Create the "View" menu */
460     wxMenu *view_menu = new wxMenu;
461     if (!minimal)
462     {
463     view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );
464     }
465     view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
466     view_menu->Append( FileInfo_Event,
467                        wxU(_("Stream and Media &info...\tCtrl-I")) );
468     view_menu->Append( VLM_Event,
469                        wxU(_("VLM Control...\tCtrl-V")) );
470
471     /* Create the "Auto-generated" menus */
472     p_settings_menu = SettingsMenu( p_intf, this );
473     p_audio_menu = AudioMenu( p_intf, this );
474     p_video_menu = VideoMenu( p_intf, this );
475     p_navig_menu = NavigMenu( p_intf, this );
476
477     /* Create the "Help" menu */
478     wxMenu *help_menu = new wxMenu;
479     help_menu->Append( About_Event, wxU(_("About VLC media player")) );
480     help_menu->AppendSeparator();
481     help_menu->Append( UpdateVLC_Event, wxU(_("Check for updates ...")) );
482
483     /* Append the freshly created menus to the menu bar... */
484     wxMenuBar *menubar = new wxMenuBar();
485     menubar->Append( file_menu, wxU(_("&File")) );
486     menubar->Append( view_menu, wxU(_("&View")) );
487     menubar->Append( p_settings_menu, wxU(_("&Settings")) );
488     menubar->Append( p_audio_menu, wxU(_("&Audio")) );
489     menubar->Append( p_video_menu, wxU(_("&Video")) );
490     menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
491     menubar->Append( help_menu, wxU(_("&Help")) );
492
493     /* Attach the menu bar to the frame */
494     SetMenuBar( menubar );
495
496     /* Find out size of menu bar */
497     int i_size = 0;
498     for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
499     {
500         int i_width, i_height;
501         menubar->GetTextExtent( menubar->GetLabelTop(i), &i_width, &i_height );
502         i_size += i_width +
503 #if defined(__WXGTK__)
504             22 /* approximate margin */;
505 #else
506 #if (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 5) && (wxRELEASE_NUMBER < 3)
507             4 /* approximate margin */;
508 #else
509             18 /* approximate margin */;
510 #endif
511 #endif
512     }
513
514 /* Patch by zcot for menu wrapping */
515 #if defined(WIN32)
516     /* Find out size of msw menu bar */
517     i_size = 0;
518     SIZE sizing;
519     HDC hdc = GetDC( NULL );
520     for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
521     {
522         GetTextExtentPoint32( hdc, menubar->GetLabelTop(i).c_str(),
523                                 menubar->GetLabelTop(i).Length(), &sizing );
524
525         // [ SM_CXDLGFRAME + pixels + textextent + pixels + SM_CXDLGFRAME ]
526         i_size += sizing.cx + 2 + GetSystemMetrics( SM_CXDLGFRAME ) * 2;
527     }
528     ReleaseDC( NULL, hdc );
529     i_size += GetSystemMetrics( SM_CXSIZEFRAME ) * 2 + 4;
530 #endif
531 /* End patch by zcot */
532
533     panel_sizer->SetMinSize( i_size, -1 );
534
535     /* Intercept all menu events in our custom event handler */
536     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
537
538 #if wxUSE_DRAG_AND_DROP
539     /* Associate drop targets with the menubar */
540     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
541 #endif
542 }
543
544 void Interface::CreateOurToolBar()
545 {
546 #define HELP_OPEN N_("Open")
547 #define HELP_STOP N_("Stop")
548 #define HELP_PLAY N_("Play")
549 #define HELP_PAUSE N_("Pause")
550 #define HELP_PLO N_("Playlist")
551 #define HELP_SPLO N_("Small playlist")
552 #define HELP_PLP N_("Previous playlist item")
553 #define HELP_PLN N_("Next playlist item")
554 #define HELP_SLOW N_("Play slower")
555 #define HELP_FAST N_("Play faster")
556
557     int minimal = config_GetInt( p_intf, "wx-minimal" );
558
559     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
560                          * version because we don't include wx.rc */
561
562     wxToolBar *toolbar =
563         CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT );
564
565     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
566
567     if (!minimal)
568     {
569     toolbar->AddTool( OpenFile_Event, wxT(""),
570                       wxBitmap( eject_xpm ), wxU(_(HELP_OPEN)) );
571     toolbar->AddSeparator();
572     }
573
574     wxToolBarToolBase *p_tool = toolbar->AddTool( PlayStream_Event, wxT(""),
575                       wxBitmap( play_xpm ), wxU(_(HELP_PLAY)), wxITEM_CHECK );
576     p_tool->SetClientData( p_tool );
577
578     if (!minimal)
579     {
580     toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
581                       wxU(_(HELP_STOP)) );
582     toolbar->AddSeparator();
583
584     toolbar->AddTool( PrevStream_Event, wxT(""),
585                       wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
586     toolbar->AddTool( SlowStream_Event, wxT(""),
587                       wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
588     toolbar->AddTool( FastStream_Event, wxT(""),
589                       wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
590     toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
591                       wxU(_(HELP_PLN)) );
592     toolbar->AddSeparator();
593     toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( playlist_xpm ),
594                       wxU(_(HELP_PLO)) );
595     toolbar->AddTool( PlaylistSmall_Event, wxT(""),
596                       wxBitmap( playlist_small_xpm ), wxU(_(HELP_SPLO)) );
597     }
598
599     wxControl *p_dummy_ctrl =
600         new wxControl( toolbar, -1, wxDefaultPosition,
601                        wxSize(16, 16 ), wxBORDER_NONE );
602
603     toolbar->AddControl( p_dummy_ctrl );
604
605     volctrl = new VLCVolCtrl( p_intf, toolbar );
606     toolbar->AddControl( volctrl );
607
608     toolbar->Realize();
609
610 #if wxUSE_DRAG_AND_DROP
611     /* Associate drop targets with the toolbar */
612     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
613 #endif
614 }
615
616 static int ConvertHotkeyModifiers( int i_hotkey )
617 {
618     int i_accel_flags = 0;
619     if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
620     if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
621     if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
622     if( !i_accel_flags ) i_accel_flags = wxACCEL_NORMAL;
623     return i_accel_flags;
624 }
625
626 static int ConvertHotkey( int i_hotkey )
627 {
628     int i_key = i_hotkey & ~KEY_MODIFIER;
629     if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
630     else if( i_key & KEY_SPECIAL )
631     {
632         switch ( i_key )
633         {
634         case KEY_LEFT: return WXK_LEFT;
635         case KEY_RIGHT: return WXK_RIGHT;
636         case KEY_UP: return WXK_UP;
637         case KEY_DOWN: return WXK_DOWN;
638         case KEY_SPACE: return WXK_SPACE;
639         case KEY_ENTER: return WXK_RETURN;
640         case KEY_F1: return WXK_F1;
641         case KEY_F2: return WXK_F2;
642         case KEY_F3: return WXK_F3;
643         case KEY_F4: return WXK_F4;
644         case KEY_F5: return WXK_F5;
645         case KEY_F6: return WXK_F6;
646         case KEY_F7: return WXK_F7;
647         case KEY_F8: return WXK_F8;
648         case KEY_F9: return WXK_F9;
649         case KEY_F10: return WXK_F10;
650         case KEY_F11: return WXK_F11;
651         case KEY_F12: return WXK_F12;
652         case KEY_HOME: return WXK_HOME;
653         case KEY_END: return WXK_END;
654         case KEY_INSERT: return WXK_INSERT;
655         case KEY_DELETE: return WXK_DELETE;
656         case KEY_MENU: return WXK_MENU;
657         case KEY_ESC: return WXK_ESCAPE;
658         case KEY_PAGEUP: return WXK_PRIOR;
659         case KEY_PAGEDOWN: return WXK_NEXT;
660         case KEY_TAB: return WXK_TAB;
661         case KEY_BACKSPACE: return WXK_BACK;
662         }
663     }
664     return WXK_F24;
665 }
666
667 void Interface::SetupHotkeys()
668 {
669     struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
670     int i_hotkeys;
671
672     /* Count number of hoteys */
673     for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );
674
675     p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;
676     p_intf->p_sys->i_hotkeys = i_hotkeys;
677
678     wxAcceleratorEntry *p_entries = new wxAcceleratorEntry[i_hotkeys];
679
680     /* Setup the hotkeys as accelerators */
681     for( int i = 0; i < i_hotkeys; i++ )
682     {
683         int i_mod = ConvertHotkeyModifiers( p_hotkeys[i].i_key );
684         int i_key = ConvertHotkey( p_hotkeys[i].i_key );
685
686 #ifdef WIN32
687         if( !(p_hotkeys[i].i_key & KEY_SPECIAL) && i_mod )
688             i_key = toupper(i_key);
689 #endif
690
691         p_entries[i].Set( i_mod, i_key,
692                           p_intf->p_sys->i_first_hotkey_event + i );
693     }
694
695     wxAcceleratorTable accel( i_hotkeys, p_entries );
696
697     if( !accel.Ok() )
698     {
699         msg_Err( p_intf, "invalid accelerator table" );
700     }
701     else
702     {
703         SetAcceleratorTable( accel );
704     }
705
706     delete [] p_entries;
707 }
708
709 void Interface::SetIntfMinSize()
710 {
711     wxSize ms = main_min_size;
712
713     if( extra_frame && extra_frame->IsShown() )
714     {
715         ms.SetHeight( ms.GetHeight() + ext_min_size.GetHeight() );
716         if( ext_min_size.GetWidth() > ms.GetWidth() )
717             ms.SetWidth( ext_min_size.GetWidth() );
718     }
719
720     if( playlist_manager && playlist_manager->IsShown() )
721     {
722         ms.SetHeight( ms.GetHeight() + playlist_min_size.GetHeight() );
723         if( playlist_min_size.GetWidth() > ms.GetWidth() )
724             ms.SetWidth( playlist_min_size.GetWidth() );
725     }
726
727     SetSizeHints( ms.GetWidth(), ms.GetHeight() );
728 }
729
730 /*****************************************************************************
731  * Event Handlers.
732  *****************************************************************************/
733 void Interface::OnMenuOpen( wxMenuEvent& event )
734 {
735 #if defined( __WXMSW__ )
736 #   define GetEventObject GetMenu
737 #endif
738
739     if( event.GetEventObject() == p_settings_menu )
740     {
741         p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );
742
743         /* Add static items */
744         p_settings_menu->AppendCheckItem( Extended_Event,
745             wxU(_("Extended &GUI\tCtrl-G") ) );
746         if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE );
747         p_settings_menu->Append( Bookmarks_Event,
748                                  wxU(_("&Bookmarks...\tCtrl-B") ) );
749         p_settings_menu->Append( Prefs_Event,
750                                  wxU(_("Preference&s...\tCtrl-S")) );
751     }
752
753     else if( event.GetEventObject() == p_audio_menu )
754     {
755         p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );
756     }
757
758     else if( event.GetEventObject() == p_video_menu )
759     {
760         p_video_menu = VideoMenu( p_intf, this, p_video_menu );
761     }
762
763     else if( event.GetEventObject() == p_navig_menu )
764     {
765         p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );
766     }
767
768 #if defined( __WXMSW__ )
769 #   undef GetEventObject
770 #endif
771 }
772
773 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
774 void Interface::OnContextMenu2(wxContextMenuEvent& event)
775 {
776     /* Only show the context menu for the main interface */
777     if( GetId() != event.GetId() )
778     {
779         event.Skip();
780         return;
781     }
782
783     if( p_intf->p_sys->pf_show_dialog )
784         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
785 }
786 #endif
787 void Interface::OnContextMenu(wxMouseEvent& event)
788 {
789     if( p_intf->p_sys->pf_show_dialog )
790         p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
791 }
792
793 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
794 {
795     /* TRUE is to force the frame to close. */
796     Close(TRUE);
797 }
798
799 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
800 {
801     wxString msg;
802     msg.Printf( wxString(wxT("VLC media player " PACKAGE_VERSION)) +
803         wxU(_(" (wxWidgets interface)\n\n")) +
804         wxU(_("(c) 1996-2005 - the VideoLAN Team\n\n")) +
805        wxU(_("Compiled by "))+ wxU(VLC_CompileBy())+ wxU("@") +
806        wxU(VLC_CompileHost())+ wxT(".")+ wxU(VLC_CompileDomain())+ wxT(".\n") +
807        wxU(_("Compiler: "))+ wxU(VLC_Compiler())+wxT( ".\n") +
808        wxU(_("Based on SVN revision: "))+wxU(VLC_Changeset())+wxT(".\n\n") +
809 #ifdef __WXMSW__
810         wxU( vlc_wraptext(LICENSE_MSG,WRAPCOUNT,VLC_TRUE) ) + wxT("\n\n") +
811 #else
812         wxU( LICENSE_MSG ) + wxT("\n\n") +
813 #endif
814         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
815               "http://www.videolan.org/\n\n")) );
816
817     wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
818                   wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
819 }
820
821 void Interface::OnShowDialog( wxCommandEvent& event )
822 {
823     if( p_intf->p_sys->pf_show_dialog )
824     {
825         int i_id;
826
827         switch( event.GetId() )
828         {
829         case OpenFileSimple_Event:
830             i_id = INTF_DIALOG_FILE_SIMPLE;
831             break;
832         case OpenAdv_Event:
833             i_id = INTF_DIALOG_FILE;
834             break;
835         case OpenFile_Event:
836             i_id = INTF_DIALOG_FILE;
837             break;
838         case OpenDir_Event:
839             i_id = INTF_DIALOG_DIRECTORY;
840             break;
841         case OpenDisc_Event:
842             i_id = INTF_DIALOG_DISC;
843             break;
844         case OpenNet_Event:
845             i_id = INTF_DIALOG_NET;
846             break;
847         case OpenCapture_Event:
848             i_id = INTF_DIALOG_CAPTURE;
849             break;
850         case OpenSat_Event:
851             i_id = INTF_DIALOG_SAT;
852             break;
853         case Playlist_Event:
854             i_id = INTF_DIALOG_PLAYLIST;
855             break;
856         case Logs_Event:
857             i_id = INTF_DIALOG_MESSAGES;
858             break;
859         case FileInfo_Event:
860             i_id = INTF_DIALOG_FILEINFO;
861             break;
862         case Prefs_Event:
863             i_id = INTF_DIALOG_PREFS;
864             break;
865         case Wizard_Event:
866             i_id = INTF_DIALOG_WIZARD;
867             break;
868         case Bookmarks_Event:
869             i_id = INTF_DIALOG_BOOKMARKS;
870             break;
871         case UpdateVLC_Event:
872             i_id = INTF_DIALOG_UPDATEVLC;
873             break;
874         case VLM_Event:
875             i_id = INTF_DIALOG_VLM;
876             break;
877         default:
878             i_id = INTF_DIALOG_FILE;
879             break;
880         }
881
882         p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
883     }
884 }
885
886 void Interface::OnExtended( wxCommandEvent& WXUNUSED(event) )
887 {
888     UpdateVideoWindow( p_intf, video_window );
889
890     if( !extra_frame )
891     {
892         /* Create the extra panel */
893         extra_frame = new ExtraPanel( p_intf, main_panel );
894         panel_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
895         ext_min_size = extra_frame->GetBestSize();
896     }
897
898     b_extra = !b_extra;
899     panel_sizer->Show( extra_frame, b_extra );
900
901     SetIntfMinSize();
902     main_sizer->Layout();
903     main_sizer->Fit( this );
904 }
905
906 void Interface::OnSmallPlaylist( wxCommandEvent& WXUNUSED(event) )
907 {
908     UpdateVideoWindow( p_intf, video_window );
909
910     if( !playlist_manager )
911     {
912         /* Create the extra panel */
913         playlist_manager = new PlaylistManager( p_intf, splitter );
914         playlist_min_size = playlist_manager->GetBestSize();
915     }
916
917     b_playlist_manager = !b_playlist_manager;
918
919     if( b_playlist_manager ) splitter->Split( main_panel, playlist_manager );
920     else splitter->Unsplit( playlist_manager );
921
922     SetIntfMinSize();
923     main_sizer->Layout();
924     main_sizer->Fit( this );
925 }
926
927 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
928 {
929     PlayStream();
930 }
931
932 void Interface::PlayStream()
933 {
934     wxCommandEvent dummy;
935     playlist_t *p_playlist =
936         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
937                                        FIND_ANYWHERE );
938     if( p_playlist == NULL ) return;
939
940     if( p_playlist->i_size && p_playlist->i_enabled )
941     {
942         vlc_value_t state;
943
944         input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
945                                                        VLC_OBJECT_INPUT,
946                                                        FIND_ANYWHERE );
947         if( p_input == NULL )
948         {
949             /* No stream was playing, start one */
950             playlist_Play( p_playlist );
951             vlc_object_release( p_playlist );
952             input_manager->Update();
953             return;
954         }
955
956         var_Get( p_input, "state", &state );
957         if( state.i_int != PAUSE_S )
958         {
959             /* A stream is being played, pause it */
960             state.i_int = PAUSE_S;
961         }
962         else
963         {
964             /* Stream is paused, resume it */
965             state.i_int = PLAYING_S;
966         }
967         var_Set( p_input, "state", state );
968
969         vlc_object_release( p_input );
970         vlc_object_release( p_playlist );
971         input_manager->Update();
972     }
973     else
974     {
975         /* If the playlist is empty, open a file requester instead */
976         vlc_object_release( p_playlist );
977         OnShowDialog( dummy );
978     }
979 }
980
981 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
982 {
983     StopStream();
984 }
985 void Interface::StopStream()
986 {
987     playlist_t * p_playlist =
988         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
989                                        FIND_ANYWHERE );
990     if( p_playlist == NULL )
991     {
992         return;
993     }
994
995     playlist_Stop( p_playlist );
996     vlc_object_release( p_playlist );
997     input_manager->Update();
998 }
999
1000 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
1001 {
1002     PrevStream();
1003 }
1004
1005 void Interface::PrevStream()
1006 {
1007     playlist_t * p_playlist =
1008         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1009                                        FIND_ANYWHERE );
1010     if( p_playlist == NULL )
1011     {
1012         return;
1013     }
1014
1015     playlist_Prev( p_playlist );
1016     vlc_object_release( p_playlist );
1017 }
1018
1019 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
1020 {
1021     NextStream();
1022 }
1023
1024 void Interface::NextStream()
1025 {
1026     playlist_t * p_playlist =
1027         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1028                                        FIND_ANYWHERE );
1029     if( p_playlist == NULL )
1030     {
1031         return;
1032     }
1033     playlist_Next( p_playlist );
1034     vlc_object_release( p_playlist );
1035 }
1036
1037 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
1038 {
1039     input_thread_t *p_input =
1040         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1041                                            FIND_ANYWHERE );
1042     if( p_input )
1043     {
1044         vlc_value_t val; val.b_bool = VLC_TRUE;
1045
1046         var_Set( p_input, "rate-slower", val );
1047         vlc_object_release( p_input );
1048     }
1049 }
1050
1051 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
1052 {
1053     input_thread_t *p_input =
1054         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
1055                                            FIND_ANYWHERE );
1056     if( p_input )
1057     {
1058         vlc_value_t val; val.b_bool = VLC_TRUE;
1059
1060         var_Set( p_input, "rate-faster", val );
1061         vlc_object_release( p_input );
1062     }
1063 }
1064
1065 void Interface::TogglePlayButton( int i_playing_status )
1066 {
1067     wxToolBarToolBase *p_tool = (wxToolBarToolBase *)
1068         GetToolBar()->GetToolClientData( PlayStream_Event );
1069     if( !p_tool ) return;
1070
1071     if( i_playing_status == PLAYING_S )
1072     {
1073         p_tool->SetNormalBitmap( wxBitmap( pause_xpm ) );
1074         p_tool->SetLabel( wxU(_("Pause")) );
1075         p_tool->SetShortHelp( wxU(_(HELP_PAUSE)) );
1076     }
1077     else
1078     {
1079         p_tool->SetNormalBitmap( wxBitmap( play_xpm ) );
1080         p_tool->SetLabel( wxU(_("Play")) );
1081         p_tool->SetShortHelp( wxU(_(HELP_PLAY)) );
1082     }
1083
1084     GetToolBar()->Realize();
1085
1086 #if defined( __WXMSW__ )
1087     /* Needed to work around a bug in wxToolBar::Realize() */
1088     GetToolBar()->SetSize( GetSize().GetWidth(),
1089                            GetToolBar()->GetSize().GetHeight() );
1090     GetToolBar()->Update();
1091 #endif
1092
1093     GetToolBar()->ToggleTool( PlayStream_Event, true );
1094     GetToolBar()->ToggleTool( PlayStream_Event, false );
1095 }
1096
1097 #if wxUSE_DRAG_AND_DROP
1098 /*****************************************************************************
1099  * Definition of DragAndDrop class.
1100  *****************************************************************************/
1101 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
1102 {
1103     p_intf = _p_intf;
1104     b_enqueue = _b_enqueue;
1105 }
1106
1107 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
1108                                const wxArrayString& filenames )
1109 {
1110     /* Add dropped files to the playlist */
1111
1112     playlist_t *p_playlist =
1113         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1114                                        FIND_ANYWHERE );
1115     if( p_playlist == NULL )
1116     {
1117         return FALSE;
1118     }
1119
1120     for( size_t i = 0; i < filenames.GetCount(); i++ )
1121     {
1122         char *psz_utf8 = wxFromLocale( filenames[i] );
1123
1124         playlist_Add( p_playlist, psz_utf8, psz_utf8,
1125                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
1126                       PLAYLIST_END );
1127         wxLocaleFree( psz_utf8 );
1128     }
1129
1130     vlc_object_release( p_playlist );
1131
1132     return TRUE;
1133 }
1134 #endif
1135
1136 /*****************************************************************************
1137  * Definition of VolCtrl class.
1138  *****************************************************************************/
1139 class wxVolCtrl: public wxGauge
1140 {
1141 public:
1142     /* Constructor */
1143     wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1144                wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) );
1145     virtual ~wxVolCtrl() {};
1146
1147     void UpdateVolume();
1148     int GetVolume();
1149
1150     void OnChange( wxMouseEvent& event );
1151
1152 private:
1153     intf_thread_t *p_intf;
1154
1155     DECLARE_EVENT_TABLE();
1156 };
1157
1158 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
1159     /* Mouse events */
1160     EVT_LEFT_DOWN(wxVolCtrl::OnChange)
1161     EVT_MOTION(wxVolCtrl::OnChange)
1162 END_EVENT_TABLE()
1163
1164 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
1165                       wxPoint point, wxSize size )
1166   : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
1167 {
1168     p_intf = _p_intf;
1169     UpdateVolume();
1170 }
1171
1172 void wxVolCtrl::OnChange( wxMouseEvent& event )
1173 {
1174     if( !event.LeftDown() && !event.LeftIsDown() ) return;
1175
1176     int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
1177     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
1178     UpdateVolume();
1179 }
1180
1181 void wxVolCtrl::UpdateVolume()
1182 {
1183     audio_volume_t i_volume;
1184     aout_VolumeGet( p_intf, &i_volume );
1185
1186     int i_gauge_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
1187     if( i_gauge_volume == GetValue() ) return;
1188
1189     SetValue( i_gauge_volume );
1190     SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
1191                 i_gauge_volume / 2 ) );
1192 }
1193
1194 #if defined(__WXGTK__)
1195 #define VLCVOL_HEIGHT p_parent->GetSize().GetHeight()
1196 #else
1197 #define VLCVOL_HEIGHT TOOLBAR_BMP_HEIGHT
1198 #endif
1199 VLCVolCtrl::VLCVolCtrl( intf_thread_t *_p_intf, wxWindow *p_parent )
1200   :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, VLCVOL_HEIGHT ),
1201               wxBORDER_NONE ),
1202    i_y_offset((VLCVOL_HEIGHT - TOOLBAR_BMP_HEIGHT) / 2),
1203    b_mute(0), p_intf(_p_intf)
1204 {
1205     gauge = new wxVolCtrl( p_intf, this, -1, wxPoint( 18, i_y_offset ),
1206                            wxSize( 44, TOOLBAR_BMP_HEIGHT ) );
1207 }
1208
1209 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
1210 {
1211     wxPaintDC dc( this );
1212     wxBitmap mPlayBitmap( b_mute ? speaker_mute_xpm : speaker_xpm );
1213     dc.DrawBitmap( mPlayBitmap, 0, i_y_offset, TRUE );
1214 }
1215
1216 void VLCVolCtrl::OnChange( wxMouseEvent& event )
1217 {
1218     if( event.GetX() < TOOLBAR_BMP_WIDTH )
1219     {
1220         int i_volume;
1221         aout_VolumeMute( p_intf, (audio_volume_t *)&i_volume );
1222
1223         b_mute = !b_mute;
1224         Refresh();
1225     }
1226 }
1227
1228 void VLCVolCtrl::UpdateVolume()
1229 {
1230     gauge->UpdateVolume();
1231
1232     int i_volume = gauge->GetValue();
1233     if( !!i_volume == !b_mute ) return;
1234     b_mute = !b_mute;
1235     Refresh();
1236 }
1237
1238 /*****************************************************************************
1239  * Systray class.
1240  *****************************************************************************/
1241
1242 #ifdef wxHAS_TASK_BAR_ICON
1243
1244 BEGIN_EVENT_TABLE(Systray, wxTaskBarIcon)
1245     /* Mouse events */
1246 #ifdef WIN32
1247     EVT_TASKBAR_LEFT_DCLICK(Systray::OnLeftClick)
1248 #else
1249     EVT_TASKBAR_LEFT_DOWN(Systray::OnLeftClick)
1250 #endif
1251     /* Menu events */
1252     EVT_MENU(Iconize_Event, Systray::OnMenuIconize)
1253     EVT_MENU(Exit_Event, Systray::OnExit)
1254     EVT_MENU(PlayStream_Event, Systray::OnPlayStream)
1255     EVT_MENU(NextStream_Event, Systray::OnNextStream)
1256     EVT_MENU(PrevStream_Event, Systray::OnPrevStream)
1257     EVT_MENU(StopStream_Event, Systray::OnStopStream)
1258 END_EVENT_TABLE()
1259
1260 Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf )
1261 {
1262     p_main_interface = _p_main_interface;
1263     p_intf = _p_intf;
1264
1265     SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") );
1266     if( !IsOk() || !IsIconInstalled() )
1267     {
1268         msg_Warn(p_intf, "cannot set systray icon, weird things may happen");
1269     }
1270 }
1271
1272 /* Event handlers */
1273 void Systray::OnMenuIconize( wxCommandEvent& event )
1274 {
1275     p_main_interface->Show( ! p_main_interface->IsShown() );
1276     if ( p_main_interface->IsShown() ) p_main_interface->Raise();
1277 }
1278
1279 void Systray::OnLeftClick( wxTaskBarIconEvent& event )
1280 {
1281     wxCommandEvent cevent;
1282     OnMenuIconize(cevent);
1283 }
1284
1285 void Systray::OnExit( wxCommandEvent& event )
1286 {
1287     p_main_interface->Close(TRUE);
1288 }
1289
1290 void Systray::OnPrevStream( wxCommandEvent& event )
1291 {
1292     p_main_interface->PrevStream();
1293 }
1294
1295 void Systray::OnNextStream( wxCommandEvent& event )
1296 {
1297     p_main_interface->NextStream();
1298 }
1299
1300 void Systray::OnPlayStream( wxCommandEvent& event )
1301 {
1302     p_main_interface->PlayStream();
1303 }
1304
1305 void Systray::OnStopStream( wxCommandEvent& event )
1306 {
1307     p_main_interface->StopStream();
1308 }
1309
1310 /* Systray popup menu */
1311 wxMenu* Systray::CreatePopupMenu()
1312 {
1313     int minimal = config_GetInt( p_intf, "wx-minimal" );
1314
1315     wxMenu* systray_menu = new wxMenu;
1316     systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) );
1317     systray_menu->AppendSeparator();
1318     systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) );
1319
1320     if (!minimal)
1321     {
1322     systray_menu->Append( PrevStream_Event, wxU(_("Previous")) );
1323     systray_menu->Append( NextStream_Event, wxU(_("Next")) );
1324     systray_menu->Append( StopStream_Event, wxU(_("Stop")) );
1325     }
1326     systray_menu->AppendSeparator();
1327     systray_menu->Append( Iconize_Event, wxU(_("Show/Hide interface")) );
1328     return systray_menu;
1329 }
1330
1331 void Systray::UpdateTooltip( const wxChar* tooltip )
1332 {
1333     SetIcon( wxIcon( vlc16x16_xpm ), tooltip );
1334 }
1335 #endif