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