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