00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vlc/vlc.h>
00028 #include <vlc/aout.h>
00029 #include <vlc/vout.h>
00030 #include <vlc/input.h>
00031 #include <vlc/intf.h>
00032 #include "charset.h"
00033
00034 #include "wxwidgets.h"
00035
00036
00037 #include "bitmaps/play.xpm"
00038 #include "bitmaps/pause.xpm"
00039 #include "bitmaps/stop.xpm"
00040 #include "bitmaps/prev.xpm"
00041 #include "bitmaps/next.xpm"
00042 #include "bitmaps/eject.xpm"
00043 #include "bitmaps/slow.xpm"
00044 #include "bitmaps/fast.xpm"
00045 #include "bitmaps/playlist.xpm"
00046 #include "bitmaps/speaker.xpm"
00047 #include "bitmaps/speaker_mute.xpm"
00048
00049 #define TOOLBAR_BMP_WIDTH 16
00050 #define TOOLBAR_BMP_HEIGHT 16
00051
00052
00053 #include "../../../share/vlc32x32.xpm"
00054
00055 #ifdef wxHAS_TASK_BAR_ICON
00056 #include "../../../share/vlc16x16.xpm"
00057 #endif
00058
00059
00060
00061
00062 class wxMenuExt: public wxMenu
00063 {
00064 public:
00065
00066 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
00067 const wxString& helpString, wxItemKind kind,
00068 char *_psz_var, int _i_object_id, vlc_value_t _val,
00069 int _i_val_type );
00070
00071 virtual ~wxMenuExt() {};
00072
00073 char *psz_var;
00074 int i_val_type;
00075 int i_object_id;
00076 vlc_value_t val;
00077
00078 private:
00079
00080 };
00081
00082 class wxVolCtrl;
00083 class VLCVolCtrl : public wxControl
00084 {
00085 public:
00086 VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent );
00087 virtual ~VLCVolCtrl() {};
00088
00089 virtual void OnPaint( wxPaintEvent &event );
00090 void OnChange( wxMouseEvent& event );
00091 void UpdateVolume();
00092
00093 private:
00094 DECLARE_EVENT_TABLE()
00095
00096 wxVolCtrl *gauge;
00097 int i_y_offset;
00098 vlc_bool_t b_mute;
00099 intf_thread_t *p_intf;
00100 };
00101
00102 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
00103 EVT_PAINT(VLCVolCtrl::OnPaint)
00104
00105
00106 EVT_LEFT_UP(VLCVolCtrl::OnChange)
00107 END_EVENT_TABLE()
00108
00109
00110
00111
00112
00113 DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );
00114
00115
00116 enum
00117 {
00118
00119 MenuDummy_Event = wxID_HIGHEST + 1000,
00120 Exit_Event = wxID_HIGHEST,
00121 OpenFileSimple_Event,
00122 OpenAdv_Event,
00123 OpenFile_Event,
00124 OpenDir_Event,
00125 OpenDisc_Event,
00126 OpenNet_Event,
00127 OpenCapture_Event,
00128 OpenSat_Event,
00129 OpenOther_Event,
00130 EjectDisc_Event,
00131
00132 Wizard_Event,
00133
00134 Playlist_Event,
00135 Logs_Event,
00136 FileInfo_Event,
00137
00138 Prefs_Event,
00139 Extended_Event,
00140
00141 Bookmarks_Event,
00142 Skins_Event,
00143
00144 SliderScroll_Event,
00145 StopStream_Event,
00146 PlayStream_Event,
00147 PrevStream_Event,
00148 NextStream_Event,
00149 SlowStream_Event,
00150 FastStream_Event,
00151
00152 DiscMenu_Event,
00153 DiscPrev_Event,
00154 DiscNext_Event,
00155
00156
00157
00158
00159 About_Event = wxID_ABOUT,
00160
00161 Iconize_Event
00162 };
00163
00164 BEGIN_EVENT_TABLE(Interface, wxFrame)
00165
00166 EVT_MENU(Exit_Event, Interface::OnExit)
00167 EVT_MENU(About_Event, Interface::OnAbout)
00168
00169 EVT_MENU(Playlist_Event, Interface::OnShowDialog)
00170 EVT_MENU(Logs_Event, Interface::OnShowDialog)
00171 EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
00172 EVT_MENU(Prefs_Event, Interface::OnShowDialog)
00173
00174 EVT_MENU_OPEN(Interface::OnMenuOpen)
00175
00176 EVT_MENU( Extended_Event, Interface::OnExtended )
00177
00178
00179 EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
00180
00181 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
00182 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
00183 #endif
00184 EVT_RIGHT_UP(Interface::OnContextMenu)
00185
00186
00187 EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
00188 EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
00189 EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
00190 EVT_MENU(OpenDir_Event, Interface::OnShowDialog)
00191 EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
00192 EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
00193 EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)
00194 EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
00195 EVT_MENU(Wizard_Event, Interface::OnShowDialog)
00196 EVT_MENU(StopStream_Event, Interface::OnStopStream)
00197 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
00198 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
00199 EVT_MENU(NextStream_Event, Interface::OnNextStream)
00200 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
00201 EVT_MENU(FastStream_Event, Interface::OnFastStream)
00202
00203
00204 EVT_BUTTON(DiscMenu_Event, Interface::OnDiscMenu)
00205 EVT_BUTTON(DiscPrev_Event, Interface::OnDiscPrev)
00206 EVT_BUTTON(DiscNext_Event, Interface::OnDiscNext)
00207
00208
00209 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
00210
00211
00212 EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
00213 EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
00214
00215 EVT_TIMER(ID_CONTROLS_TIMER, Interface::OnControlsTimer)
00216 EVT_TIMER(ID_SLIDER_TIMER, Interface::OnSliderTimer)
00217 END_EVENT_TABLE()
00218
00219
00220
00221
00222 Interface::Interface( intf_thread_t *_p_intf, long style ):
00223 wxFrame( NULL, -1, wxT("VLC media player"),
00224 wxDefaultPosition, wxSize(700,100), style )
00225 {
00226
00227 p_intf = _p_intf;
00228 i_old_playing_status = PAUSE_S;
00229 b_extra = VLC_FALSE;
00230
00231
00232
00233 extra_window = NULL;
00234
00235
00236 SetIcon( wxIcon( vlc_xpm ) );
00237
00238
00239 frame_sizer = new wxBoxSizer( wxVERTICAL );
00240 SetSizer( frame_sizer );
00241
00242
00243 wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
00244 wxSize(0,0) );
00245 #if defined(__WXGTK20__) && wxCHECK_VERSION(2,5,6)
00246
00247
00248 p_dummy->m_imData = 0;
00249 m_imData = 0;
00250 #endif
00251 p_dummy->SetFocus();
00252 frame_sizer->Add( p_dummy, 0, 0 );
00253
00254 #ifdef wxHAS_TASK_BAR_ICON
00255
00256 p_systray = NULL;
00257 if ( config_GetInt( p_intf, "wx-systray" ) )
00258 {
00259 p_systray = new Systray(this, p_intf);
00260 p_systray->SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") );
00261 if ( (! p_systray->IsOk()) || (! p_systray->IsIconInstalled()) )
00262 {
00263 msg_Warn(p_intf, "Cannot set systray icon, weird things may happen");
00264 }
00265 }
00266 #endif
00267
00268
00269 CreateOurMenuBar();
00270
00271
00272 CreateOurToolBar();
00273
00274
00275 extra_frame = new ExtraPanel( p_intf, this );
00276 frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
00277 frame_sizer->Hide( extra_frame );
00278
00279
00280
00281
00282 int i_status_width[3] = {-6, -2, -9};
00283 statusbar = CreateStatusBar( 3 );
00284 statusbar->SetStatusWidths( 3, i_status_width );
00285 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
00286
00287
00288 video_window = 0;
00289 if( config_GetInt( p_intf, "wx-embed" ) )
00290 {
00291 video_window = CreateVideoWindow( p_intf, this );
00292 frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
00293 }
00294
00295
00296 CreateOurSlider();
00297 frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
00298 frame_sizer->Hide( slider_frame );
00299
00300
00301 SetBackgroundColour( slider_frame->GetBackgroundColour() );
00302
00303
00304 frame_sizer->Layout();
00305 frame_sizer->Fit(this);
00306
00307 #if wxUSE_DRAG_AND_DROP
00308
00309 SetDropTarget( new DragAndDrop( p_intf ) );
00310 #endif
00311
00312 SetupHotkeys();
00313
00314 m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
00315 m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
00316
00317
00318 timer = new Timer( p_intf, this );
00319
00320
00321 WindowSettings *ws = p_intf->p_sys->p_window_settings;
00322 wxPoint p;
00323 wxSize s;
00324 bool b_shown;
00325
00326 ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),
00327 wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );
00328
00329 if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) )
00330 Move( p );
00331
00332
00333 s = GetSize();
00334 if( config_GetInt( p_intf, "wx-embed" ) )
00335 {
00336 wxSize s2;
00337 s2 = video_window->GetSize();
00338 s.SetHeight( s.GetHeight() - s2.GetHeight() );
00339 }
00340 #if (wxCHECK_VERSION(2,5,4))
00341 SetMinSize( s );
00342 #else
00343 frame_sizer->SetMinSize( s );
00344 #endif
00345
00346
00347 if( ( b_extra = config_GetInt( p_intf, "wx-extended" ) ) )
00348 frame_sizer->Show( extra_frame );
00349 }
00350
00351 Interface::~Interface()
00352 {
00353 WindowSettings *ws = p_intf->p_sys->p_window_settings;
00354
00355 if( !IsIconized() )
00356 {
00357 ws->SetSettings( WindowSettings::ID_MAIN, true,
00358 GetPosition(), GetSize() );
00359 }
00360
00361 PopEventHandler(true);
00362
00363 if( video_window ) delete video_window;
00364
00365 #ifdef wxHAS_TASK_BAR_ICON
00366 if( p_systray ) delete p_systray;
00367 #endif
00368
00369 if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;
00370
00371
00372 delete timer;
00373 }
00374
00375 void Interface::Init()
00376 {
00377
00378 SetupHotkeys();
00379 }
00380
00381 void Interface::Update()
00382 {
00383
00384 ((VLCVolCtrl *)volctrl)->UpdateVolume();
00385 }
00386
00387 void Interface::OnControlEvent( wxCommandEvent& event )
00388 {
00389 switch( event.GetId() )
00390 {
00391 case 0:
00392 {
00393 if( p_intf->p_sys->b_video_autosize )
00394 {
00395 frame_sizer->Layout();
00396 frame_sizer->Fit(this);
00397 }
00398 }
00399 break;
00400
00401 case 1:
00402 long i_style = GetWindowStyle();
00403 if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;
00404 else i_style &= ~wxSTAY_ON_TOP;
00405 SetWindowStyle( i_style );
00406 break;
00407 }
00408 }
00409
00410
00411
00412
00413 void Interface::CreateOurMenuBar()
00414 {
00415 int minimal = config_GetInt( p_intf, "wx-minimal" );
00416
00417
00418 wxMenu *file_menu = new wxMenu;
00419
00420 if (!minimal)
00421 {
00422 file_menu->Append( OpenFileSimple_Event,
00423 wxU(_("Quick &Open File...\tCtrl-O")) );
00424
00425 file_menu->AppendSeparator();
00426 file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );
00427 file_menu->Append( OpenDir_Event, wxU(_("Open Dir&ectory...\tCtrl-E")) );
00428 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );
00429 file_menu->Append( OpenNet_Event,
00430 wxU(_("Open &Network Stream...\tCtrl-N")) );
00431 file_menu->Append( OpenCapture_Event,
00432 wxU(_("Open C&apture Device...\tCtrl-A")) );
00433
00434 file_menu->AppendSeparator();
00435 file_menu->Append( Wizard_Event, wxU(_("&Wizard...\tCtrl-W")) );
00436 file_menu->AppendSeparator();
00437 }
00438 file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );
00439
00440
00441 wxMenu *view_menu = new wxMenu;
00442 if (!minimal)
00443 {
00444 view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );
00445 }
00446 view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
00447 view_menu->Append( FileInfo_Event,
00448 wxU(_("Stream and Media &info...\tCtrl-I")) );
00449
00450
00451 p_settings_menu = SettingsMenu( p_intf, this );
00452 p_audio_menu = AudioMenu( p_intf, this );
00453 p_video_menu = VideoMenu( p_intf, this );
00454 p_navig_menu = NavigMenu( p_intf, this );
00455
00456
00457 wxMenu *help_menu = new wxMenu;
00458 help_menu->Append( About_Event, wxU(_("About VLC media player")) );
00459
00460
00461 wxMenuBar *menubar = new wxMenuBar();
00462 menubar->Append( file_menu, wxU(_("&File")) );
00463 menubar->Append( view_menu, wxU(_("&View")) );
00464 menubar->Append( p_settings_menu, wxU(_("&Settings")) );
00465 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
00466 menubar->Append( p_video_menu, wxU(_("&Video")) );
00467 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
00468 menubar->Append( help_menu, wxU(_("&Help")) );
00469
00470
00471 SetMenuBar( menubar );
00472
00473
00474 int i_size = 0;
00475 for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
00476 {
00477 int i_width, i_height;
00478 menubar->GetTextExtent( menubar->GetLabelTop(i), &i_width, &i_height );
00479 i_size += i_width +
00480 #if defined(__WXGTK__)
00481 22 ;
00482 #else
00483 #if (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 5) && (wxRELEASE_NUMBER < 3)
00484 4 ;
00485 #else
00486 18 ;
00487 #endif
00488 #endif
00489 }
00490
00491
00492 #if defined(WIN32)
00493
00494 i_size = 0;
00495 SIZE sizing;
00496 HDC hdc = GetDC( NULL );
00497 for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
00498 {
00499
00500
00501 GetTextExtentPoint32( hdc, menubar->GetLabelTop(i).c_str(),
00502 menubar->GetLabelTop(i).Length(), &sizing );
00503
00504 i_size += sizing.cx;
00505
00506 i_size += 2;
00507
00508 i_size += GetSystemMetrics( SM_CXDLGFRAME ) * 2;
00509 }
00510 ReleaseDC( NULL, hdc );
00511
00512 i_size += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
00513
00514 i_size += 4;
00515 #endif
00516
00517
00518 frame_sizer->SetMinSize( i_size, -1 );
00519
00520
00521 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
00522
00523 #if wxUSE_DRAG_AND_DROP
00524
00525 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
00526 #endif
00527 }
00528
00529 void Interface::CreateOurToolBar()
00530 {
00531 #define HELP_OPEN N_("Open")
00532 #define HELP_STOP N_("Stop")
00533 #define HELP_PLAY N_("Play")
00534 #define HELP_PAUSE N_("Pause")
00535 #define HELP_PLO N_("Playlist")
00536 #define HELP_PLP N_("Previous playlist item")
00537 #define HELP_PLN N_("Next playlist item")
00538 #define HELP_SLOW N_("Play slower")
00539 #define HELP_FAST N_("Play faster")
00540
00541 int minimal = config_GetInt( p_intf, "wx-minimal" );
00542
00543 wxLogNull LogDummy;
00544
00545
00546 wxToolBar *toolbar =
00547 CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT );
00548
00549 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
00550
00551 if (!minimal)
00552 {
00553 toolbar->AddTool( OpenFile_Event, wxT(""),
00554 wxBitmap( eject_xpm ), wxU(_(HELP_OPEN)) );
00555 toolbar->AddSeparator();
00556 }
00557
00558 wxToolBarToolBase *p_tool = toolbar->AddTool( PlayStream_Event, wxT(""),
00559 wxBitmap( play_xpm ), wxU(_(HELP_PLAY)), wxITEM_CHECK );
00560 p_tool->SetClientData( p_tool );
00561
00562 if (!minimal)
00563 {
00564 toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
00565 wxU(_(HELP_STOP)) );
00566 toolbar->AddSeparator();
00567
00568 toolbar->AddTool( PrevStream_Event, wxT(""),
00569 wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
00570 toolbar->AddTool( SlowStream_Event, wxT(""),
00571 wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
00572 toolbar->AddTool( FastStream_Event, wxT(""),
00573 wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
00574 toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
00575 wxU(_(HELP_PLN)) );
00576 toolbar->AddSeparator();
00577 toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( playlist_xpm ),
00578 wxU(_(HELP_PLO)) );
00579 }
00580
00581 #if !( (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 6) && (wxRELEASE_NUMBER < 2) )
00582 wxControl *p_dummy_ctrl =
00583 new wxControl( toolbar, -1, wxDefaultPosition,
00584 wxSize(35, 16 ), wxBORDER_NONE );
00585
00586 toolbar->AddControl( p_dummy_ctrl );
00587 #endif
00588
00589 volctrl = new VLCVolCtrl( p_intf, toolbar );
00590 toolbar->AddControl( volctrl );
00591
00592 toolbar->Realize();
00593
00594 #if wxUSE_DRAG_AND_DROP
00595
00596 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
00597 #endif
00598 }
00599
00600 void Interface::CreateOurSlider()
00601 {
00602
00603 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
00604 slider_frame->SetAutoLayout( TRUE );
00605 slider_sizer = new wxBoxSizer( wxHORIZONTAL );
00606
00607
00608
00609 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
00610 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
00611
00612
00613 disc_frame = new wxPanel( slider_frame, -1, wxDefaultPosition,
00614 wxDefaultSize );
00615 disc_frame->SetAutoLayout( TRUE );
00616 disc_sizer = new wxBoxSizer( wxHORIZONTAL );
00617
00618 disc_menu_button = new wxBitmapButton( disc_frame, DiscMenu_Event,
00619 wxBitmap( playlist_xpm ) );
00620 disc_prev_button = new wxBitmapButton( disc_frame, DiscPrev_Event,
00621 wxBitmap( prev_xpm ) );
00622 disc_next_button = new wxBitmapButton( disc_frame, DiscNext_Event,
00623 wxBitmap( next_xpm ) );
00624
00625 disc_sizer->Add( disc_menu_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
00626 disc_sizer->Add( disc_prev_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
00627 disc_sizer->Add( disc_next_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
00628
00629 disc_frame->SetSizer( disc_sizer );
00630 disc_sizer->Layout();
00631
00632
00633 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
00634 slider_sizer->Add( disc_frame, 0, wxALL, 2 );
00635 slider_frame->SetSizer( slider_sizer );
00636
00637 disc_frame->Hide();
00638 slider_sizer->Hide( disc_frame );
00639
00640 slider_sizer->Layout();
00641 slider_sizer->Fit( slider_frame );
00642
00643
00644 slider_frame->Hide();
00645 }
00646
00647 static int ConvertHotkeyModifiers( int i_hotkey )
00648 {
00649 int i_accel_flags = 0;
00650 if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
00651 if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
00652 if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
00653 if( !i_accel_flags ) i_accel_flags = wxACCEL_NORMAL;
00654 return i_accel_flags;
00655 }
00656
00657 static int ConvertHotkey( int i_hotkey )
00658 {
00659 int i_key = i_hotkey & ~KEY_MODIFIER;
00660 if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
00661 else if( i_key & KEY_SPECIAL )
00662 {
00663 switch ( i_key )
00664 {
00665 case KEY_LEFT: return WXK_LEFT;
00666 case KEY_RIGHT: return WXK_RIGHT;
00667 case KEY_UP: return WXK_UP;
00668 case KEY_DOWN: return WXK_DOWN;
00669 case KEY_SPACE: return WXK_SPACE;
00670 case KEY_ENTER: return WXK_RETURN;
00671 case KEY_F1: return WXK_F1;
00672 case KEY_F2: return WXK_F2;
00673 case KEY_F3: return WXK_F3;
00674 case KEY_F4: return WXK_F4;
00675 case KEY_F5: return WXK_F5;
00676 case KEY_F6: return WXK_F6;
00677 case KEY_F7: return WXK_F7;
00678 case KEY_F8: return WXK_F8;
00679 case KEY_F9: return WXK_F9;
00680 case KEY_F10: return WXK_F10;
00681 case KEY_F11: return WXK_F11;
00682 case KEY_F12: return WXK_F12;
00683 case KEY_HOME: return WXK_HOME;
00684 case KEY_END: return WXK_END;
00685 case KEY_INSERT: return WXK_INSERT;
00686 case KEY_DELETE: return WXK_DELETE;
00687 case KEY_MENU: return WXK_MENU;
00688 case KEY_ESC: return WXK_ESCAPE;
00689 case KEY_PAGEUP: return WXK_PRIOR;
00690 case KEY_PAGEDOWN: return WXK_NEXT;
00691 case KEY_TAB: return WXK_TAB;
00692 case KEY_BACKSPACE: return WXK_BACK;
00693 }
00694 }
00695 return WXK_F24;
00696 }
00697
00698 void Interface::SetupHotkeys()
00699 {
00700 struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
00701 int i_hotkeys;
00702
00703
00704 for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );
00705
00706 p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;
00707 p_intf->p_sys->i_hotkeys = i_hotkeys;
00708
00709 wxAcceleratorEntry *p_entries = new wxAcceleratorEntry[i_hotkeys];
00710
00711
00712 for( int i = 0; i < i_hotkeys; i++ )
00713 {
00714 int i_mod = ConvertHotkeyModifiers( p_hotkeys[i].i_key );
00715 int i_key = ConvertHotkey( p_hotkeys[i].i_key );
00716
00717 #ifdef WIN32
00718 if( !(p_hotkeys[i].i_key & KEY_SPECIAL) && i_mod )
00719 i_key = toupper(i_key);
00720 #endif
00721
00722 p_entries[i].Set( i_mod, i_key,
00723 p_intf->p_sys->i_first_hotkey_event + i );
00724 }
00725
00726 wxAcceleratorTable accel( i_hotkeys, p_entries );
00727
00728 if( !accel.Ok() )
00729 {
00730 msg_Err( p_intf, "invalid accelerator table" );
00731 }
00732 else
00733 {
00734 SetAcceleratorTable( accel );
00735 }
00736
00737 delete [] p_entries;
00738 }
00739
00740 void Interface::HideSlider( bool layout )
00741 {
00742 ShowSlider( false, layout );
00743 }
00744
00745 void Interface::ShowSlider( bool show, bool layout )
00746 {
00747 if( show )
00748 {
00749
00750 m_slider_timer.Stop();
00751 m_controls_timer.Stop();
00752
00753
00754 if( slider_frame->IsShown() ) return;
00755 }
00756 else
00757 {
00758
00759 if( !slider_frame->IsShown() ) return;
00760 }
00761
00762 if( layout && p_intf->p_sys->b_video_autosize )
00763 UpdateVideoWindow( p_intf, video_window );
00764
00765 slider_frame->Show( show );
00766 frame_sizer->Show( slider_frame, show );
00767
00768 if( layout )
00769 {
00770 frame_sizer->Layout();
00771 if( p_intf->p_sys->b_video_autosize ) frame_sizer->Fit( this );
00772 }
00773 }
00774
00775 void Interface::HideDiscFrame( bool layout )
00776 {
00777 ShowDiscFrame( false, layout );
00778 }
00779
00780 void Interface::ShowDiscFrame( bool show, bool layout )
00781 {
00782 if( show )
00783 {
00784
00785 m_controls_timer.Stop();
00786
00787
00788 if( disc_frame->IsShown() ) return;
00789 }
00790 else
00791 {
00792
00793 if( !disc_frame->IsShown() ) return;
00794 }
00795
00796 if( layout && p_intf->p_sys->b_video_autosize )
00797 UpdateVideoWindow( p_intf, video_window );
00798
00799 disc_frame->Show( show );
00800 slider_sizer->Show( disc_frame, show );
00801
00802 if( layout )
00803 {
00804 slider_sizer->Layout();
00805 if( p_intf->p_sys->b_video_autosize )
00806 slider_sizer->Fit( slider_frame );
00807 }
00808 }
00809
00810
00811
00812
00813 void Interface::OnControlsTimer( wxTimerEvent& WXUNUSED(event) )
00814 {
00815 if( p_intf->p_sys->b_video_autosize )
00816 UpdateVideoWindow( p_intf, video_window );
00817
00818
00819
00820 HideDiscFrame( false );
00821 HideSlider( false );
00822
00823 slider_sizer->Layout();
00824 if( p_intf->p_sys->b_video_autosize )
00825 {
00826 slider_sizer->Fit( slider_frame );
00827 frame_sizer->Fit( this );
00828 }
00829 }
00830
00831 void Interface::OnSliderTimer( wxTimerEvent& WXUNUSED(event) )
00832 {
00833 HideSlider();
00834 }
00835
00836 void Interface::OnMenuOpen( wxMenuEvent& event )
00837 {
00838 #if defined( __WXMSW__ )
00839 # define GetEventObject GetMenu
00840 #endif
00841
00842 if( event.GetEventObject() == p_settings_menu )
00843 {
00844 p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );
00845
00846
00847 p_settings_menu->AppendCheckItem( Extended_Event,
00848 wxU(_("Extended &GUI\tCtrl-G") ) );
00849 if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE );
00850 #if 0
00851 p_settings_menu->AppendCheckItem( Undock_Event,
00852 wxU(_("&Undock Ext. GUI") ) );
00853 if( b_undock ) p_settings_menu->Check( Undock_Event, TRUE );
00854 #endif
00855 p_settings_menu->Append( Bookmarks_Event,
00856 wxU(_("&Bookmarks...\tCtrl-B") ) );
00857 p_settings_menu->Append( Prefs_Event,
00858 wxU(_("Preference&s...\tCtrl-S")) );
00859 }
00860
00861 else if( event.GetEventObject() == p_audio_menu )
00862 {
00863 p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );
00864 }
00865
00866 else if( event.GetEventObject() == p_video_menu )
00867 {
00868 p_video_menu = VideoMenu( p_intf, this, p_video_menu );
00869 }
00870
00871 else if( event.GetEventObject() == p_navig_menu )
00872 {
00873 p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );
00874 }
00875
00876 #if defined( __WXMSW__ )
00877 # undef GetEventObject
00878 #endif
00879 }
00880
00881 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
00882 void Interface::OnContextMenu2(wxContextMenuEvent& event)
00883 {
00884
00885 if( GetId() != event.GetId() )
00886 {
00887 event.Skip();
00888 return;
00889 }
00890
00891 if( p_intf->p_sys->pf_show_dialog )
00892 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
00893 }
00894 #endif
00895 void Interface::OnContextMenu(wxMouseEvent& event)
00896 {
00897 if( p_intf->p_sys->pf_show_dialog )
00898 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
00899 }
00900
00901 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
00902 {
00903
00904 Close(TRUE);
00905 }
00906
00907 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
00908 {
00909 wxString msg;
00910 msg.Printf( wxString(wxT("VLC media player " PACKAGE_VERSION)) +
00911 wxU(_(" (wxWidgets interface)\n\n")) +
00912 wxU(_("(c) 1996-2005 - the VideoLAN Team\n\n")) +
00913 wxU(_("Compiled by "))+ wxU(VLC_CompileBy())+ wxU("@") +
00914 wxU(VLC_CompileHost())+ wxT(".")+ wxU(VLC_CompileDomain())+ wxT(".\n") +
00915 wxU(_("Compiler: "))+ wxU(VLC_Compiler())+wxT( ".\n") +
00916 wxU(_("Based on SVN revision: "))+wxU(VLC_Changeset())+wxT(".\n\n") +
00917 #ifdef __WXMSW__
00918 wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,VLC_TRUE) ) + wxT("\n\n") +
00919 #else
00920 wxU( INTF_ABOUT_MSG ) + wxT("\n\n") +
00921 #endif
00922 wxU(_("The VideoLAN team <[email protected]>\n"
00923 "http://www.videolan.org/\n\n")) );
00924
00925 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
00926 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
00927 }
00928
00929 void Interface::OnShowDialog( wxCommandEvent& event )
00930 {
00931 if( p_intf->p_sys->pf_show_dialog )
00932 {
00933 int i_id;
00934
00935 switch( event.GetId() )
00936 {
00937 case OpenFileSimple_Event:
00938 i_id = INTF_DIALOG_FILE_SIMPLE;
00939 break;
00940 case OpenAdv_Event:
00941 i_id = INTF_DIALOG_FILE;
00942 case OpenFile_Event:
00943 i_id = INTF_DIALOG_FILE;
00944 break;
00945 case OpenDir_Event:
00946 i_id = INTF_DIALOG_DIRECTORY;
00947 break;
00948 case OpenDisc_Event:
00949 i_id = INTF_DIALOG_DISC;
00950 break;
00951 case OpenNet_Event:
00952 i_id = INTF_DIALOG_NET;
00953 break;
00954 case OpenCapture_Event:
00955 i_id = INTF_DIALOG_CAPTURE;
00956 break;
00957 case OpenSat_Event:
00958 i_id = INTF_DIALOG_SAT;
00959 break;
00960 case Playlist_Event:
00961 i_id = INTF_DIALOG_PLAYLIST;
00962 break;
00963 case Logs_Event:
00964 i_id = INTF_DIALOG_MESSAGES;
00965 break;
00966 case FileInfo_Event:
00967 i_id = INTF_DIALOG_FILEINFO;
00968 break;
00969 case Prefs_Event:
00970 i_id = INTF_DIALOG_PREFS;
00971 break;
00972 case Wizard_Event:
00973 i_id = INTF_DIALOG_WIZARD;
00974 break;
00975 case Bookmarks_Event:
00976 i_id = INTF_DIALOG_BOOKMARKS;
00977 break;
00978 default:
00979 i_id = INTF_DIALOG_FILE;
00980 break;
00981 }
00982
00983 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
00984 }
00985 }
00986
00987 void Interface::OnExtended(wxCommandEvent& event)
00988 {
00989 b_extra = (b_extra == VLC_TRUE ? VLC_FALSE : VLC_TRUE );
00990
00991 if( b_extra == VLC_FALSE )
00992 {
00993 extra_frame->Hide();
00994 frame_sizer->Hide( extra_frame );
00995 }
00996 else
00997 {
00998 extra_frame->Show();
00999 frame_sizer->Show( extra_frame );
01000 }
01001 frame_sizer->Layout();
01002 frame_sizer->Fit(this);
01003 }
01004
01005 #if 0
01006 if( b_undock == VLC_TRUE )
01007 {
01008 fprintf(stderr,"Deleting window\n");
01009 if( extra_window )
01010 {
01011 delete extra_window;
01012 extra_window = NULL;
01013 }
01014 }
01015 else
01016 {
01017 extra_frame->Hide();
01018 frame_sizer->Hide( extra_frame );
01019 frame_sizer->Layout();
01020 frame_sizer->Fit(this);
01021 }
01022 }
01023 else
01024 {
01025 if( b_undock == VLC_TRUE )
01026 {
01027 fprintf(stderr,"Creating window\n");
01028 extra_frame->Hide();
01029 frame_sizer->Hide( extra_frame );
01030 #if (wxCHECK_VERSION(2,5,0))
01031 frame_sizer->Detach( extra_frame );
01032 #else
01033 frame_sizer->Remove( extra_frame );
01034 #endif
01035 frame_sizer->Layout();
01036 frame_sizer->Fit(this);
01037 extra_window = new ExtraWindow( p_intf, this, extra_frame );
01038 }
01039 else
01040 {
01041 fprintf(stderr,"Deleting window\n");
01042 if( extra_window )
01043 {
01044 delete extra_window;
01045 }
01046 extra_frame->Show();
01047 frame_sizer->Show( extra_frame );
01048 frame_sizer->Layout();
01049 frame_sizer->Fit(this);
01050 }
01051 }
01052 }
01053
01054 void Interface::OnUndock(wxCommandEvent& event)
01055 {
01056 b_undock = (b_undock == VLC_TRUE ? VLC_FALSE : VLC_TRUE );
01057
01058 if( b_extra == VLC_TRUE )
01059 {
01060 if( b_undock == VLC_FALSE )
01061 {
01062 fprintf(stderr,"Deleting window\n");
01063 if( extra_window )
01064 {
01065 delete extra_window;
01066 extra_window = NULL;
01067 }
01068 extra_frame->Show();
01069 frame_sizer->Show( extra_frame );
01070 frame_sizer->Layout();
01071 frame_sizer->Fit(this);
01072 }
01073 else
01074 {
01075 fprintf(stderr,"Creating window\n");
01076 extra_frame->Hide();
01077 frame_sizer->Hide( extra_frame );
01078 #if (wxCHECK_VERSION(2,5,0))
01079 frame_sizer->Detach( extra_frame );
01080 #else
01081 frame_sizer->Remove( extra_frame );
01082 #endif
01083 frame_sizer->Layout();
01084 frame_sizer->Fit(this);
01085 extra_window = new ExtraWindow( p_intf, this, extra_frame );
01086 }
01087 }
01088 }
01089 #endif
01090
01091
01092 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
01093 {
01094 PlayStream();
01095 }
01096
01097 void Interface::PlayStream()
01098 {
01099 wxCommandEvent dummy;
01100 playlist_t *p_playlist =
01101 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01102 FIND_ANYWHERE );
01103 if( p_playlist == NULL ) return;
01104
01105 if( p_playlist->i_size && p_playlist->i_enabled )
01106 {
01107 vlc_value_t state;
01108
01109 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
01110 VLC_OBJECT_INPUT,
01111 FIND_ANYWHERE );
01112 if( p_input == NULL )
01113 {
01114
01115 playlist_Play( p_playlist );
01116 TogglePlayButton( PLAYING_S );
01117 vlc_object_release( p_playlist );
01118 return;
01119 }
01120
01121 var_Get( p_input, "state", &state );
01122
01123 if( state.i_int != PAUSE_S )
01124 {
01125
01126 state.i_int = PAUSE_S;
01127 }
01128 else
01129 {
01130
01131 state.i_int = PLAYING_S;
01132 }
01133 var_Set( p_input, "state", state );
01134
01135 TogglePlayButton( state.i_int );
01136 vlc_object_release( p_input );
01137 vlc_object_release( p_playlist );
01138 }
01139 else
01140 {
01141
01142 vlc_object_release( p_playlist );
01143 OnShowDialog( dummy );
01144 }
01145 }
01146
01147 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
01148 {
01149 StopStream();
01150 }
01151 void Interface::StopStream()
01152 {
01153 playlist_t * p_playlist =
01154 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01155 FIND_ANYWHERE );
01156 if( p_playlist == NULL )
01157 {
01158 return;
01159 }
01160
01161 playlist_Stop( p_playlist );
01162 TogglePlayButton( PAUSE_S );
01163 vlc_object_release( p_playlist );
01164 }
01165
01166 void Interface::OnSliderUpdate( wxScrollEvent& event )
01167 {
01168 vlc_mutex_lock( &p_intf->change_lock );
01169
01170 #ifdef WIN32
01171 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
01172 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
01173 {
01174 #endif
01175 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
01176 && p_intf->p_sys->p_input )
01177 {
01178 vlc_value_t pos;
01179 pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
01180
01181 var_Set( p_intf->p_sys->p_input, "position", pos );
01182 }
01183
01184 #ifdef WIN32
01185 p_intf->p_sys->b_slider_free = VLC_TRUE;
01186 }
01187 else
01188 {
01189 p_intf->p_sys->b_slider_free = VLC_FALSE;
01190
01191 if( p_intf->p_sys->p_input )
01192 {
01193
01194 char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
01195 mtime_t i_seconds;
01196
01197 i_seconds = var_GetTime( p_intf->p_sys->p_input, "length" ) /
01198 I64C(1000000 );
01199 secstotimestr( psz_total, i_seconds );
01200
01201 i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) /
01202 I64C(1000000 );
01203 secstotimestr( psz_time, i_seconds );
01204
01205 statusbar->SetStatusText( wxU(psz_time) + wxString(wxT(" / ") ) +
01206 wxU(psz_total), 0 );
01207 }
01208 }
01209 #endif
01210
01211 #undef WIN32
01212 vlc_mutex_unlock( &p_intf->change_lock );
01213 }
01214
01215 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
01216 {
01217 PrevStream();
01218 }
01219
01220 void Interface::PrevStream()
01221 {
01222 playlist_t * p_playlist =
01223 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01224 FIND_ANYWHERE );
01225 if( p_playlist == NULL )
01226 {
01227 return;
01228 }
01229
01230
01231 #if 0
01232 if( p_playlist->p_input != NULL )
01233 {
01234 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
01235 if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
01236 {
01237 vlc_value_t val; val.b_bool = VLC_TRUE;
01238 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
01239 var_Set( p_playlist->p_input, "prev-title", val );
01240 } else
01241 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
01242 }
01243 vlc_mutex_unlock( &p_playlist->object_lock );
01244 #endif
01245
01246 playlist_Prev( p_playlist );
01247 vlc_object_release( p_playlist );
01248 }
01249
01250 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
01251 {
01252 NextStream();
01253 }
01254
01255 void Interface::NextStream()
01256 {
01257 playlist_t * p_playlist =
01258 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01259 FIND_ANYWHERE );
01260 if( p_playlist == NULL )
01261 {
01262 return;
01263 }
01264
01265
01266 #if 0
01267 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
01268 vlc_mutex_lock( &p_playlist->object_lock );
01269 if( p_playlist->p_input != NULL )
01270 {
01271 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
01272 if( p_playlist->p_input->stream.i_area_nb > 1 &&
01273 p_playlist->p_input->stream.p_selected_area->i_id <
01274 p_playlist->p_input->stream.i_area_nb - 1 )
01275 {
01276 vlc_value_t val; val.b_bool = VLC_TRUE;
01277 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
01278 var_Set( p_playlist->p_input, "next-title", val );
01279 } else
01280 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
01281 }
01282 vlc_mutex_unlock( &p_playlist->object_lock );
01283 #endif
01284 playlist_Next( p_playlist );
01285 vlc_object_release( p_playlist );
01286 }
01287
01288 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
01289 {
01290 input_thread_t *p_input =
01291 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
01292 FIND_ANYWHERE );
01293 if( p_input )
01294 {
01295 vlc_value_t val; val.b_bool = VLC_TRUE;
01296
01297 var_Set( p_input, "rate-slower", val );
01298 vlc_object_release( p_input );
01299 }
01300 }
01301
01302 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
01303 {
01304 input_thread_t *p_input =
01305 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
01306 FIND_ANYWHERE );
01307 if( p_input )
01308 {
01309 vlc_value_t val; val.b_bool = VLC_TRUE;
01310
01311 var_Set( p_input, "rate-faster", val );
01312 vlc_object_release( p_input );
01313 }
01314 }
01315
01316 void Interface::TogglePlayButton( int i_playing_status )
01317 {
01318 if( i_playing_status == i_old_playing_status )
01319 return;
01320
01321 wxToolBarToolBase *p_tool = (wxToolBarToolBase *)
01322 GetToolBar()->GetToolClientData( PlayStream_Event );
01323 if( !p_tool ) return;
01324
01325 if( i_playing_status == PLAYING_S )
01326 {
01327 p_tool->SetNormalBitmap( wxBitmap( pause_xpm ) );
01328 p_tool->SetLabel( wxU(_("Pause")) );
01329 p_tool->SetShortHelp( wxU(_(HELP_PAUSE)) );
01330 }
01331 else
01332 {
01333 p_tool->SetNormalBitmap( wxBitmap( play_xpm ) );
01334 p_tool->SetLabel( wxU(_("Play")) );
01335 p_tool->SetShortHelp( wxU(_(HELP_PLAY)) );
01336 }
01337
01338 GetToolBar()->Realize();
01339 GetToolBar()->ToggleTool( PlayStream_Event, true );
01340 GetToolBar()->ToggleTool( PlayStream_Event, false );
01341
01342 i_old_playing_status = i_playing_status;
01343 }
01344
01345 void Interface::OnDiscMenu( wxCommandEvent& WXUNUSED(event) )
01346 {
01347 input_thread_t *p_input =
01348 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
01349 FIND_ANYWHERE );
01350 if( p_input )
01351 {
01352 vlc_value_t val; val.i_int = 2;
01353
01354 var_Set( p_input, "title 0", val);
01355 vlc_object_release( p_input );
01356 }
01357 }
01358
01359 void Interface::OnDiscPrev( wxCommandEvent& WXUNUSED(event) )
01360 {
01361 input_thread_t *p_input =
01362 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
01363 FIND_ANYWHERE );
01364 if( p_input )
01365 {
01366 int i_type = var_Type( p_input, "prev-chapter" );
01367 vlc_value_t val; val.b_bool = VLC_TRUE;
01368
01369 var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
01370 "prev-chapter" : "prev-title", val );
01371
01372 vlc_object_release( p_input );
01373 }
01374 }
01375
01376 void Interface::OnDiscNext( wxCommandEvent& WXUNUSED(event) )
01377 {
01378 input_thread_t *p_input =
01379 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
01380 FIND_ANYWHERE );
01381 if( p_input )
01382 {
01383 int i_type = var_Type( p_input, "next-chapter" );
01384 vlc_value_t val; val.b_bool = VLC_TRUE;
01385
01386 var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
01387 "next-chapter" : "next-title", val );
01388
01389 vlc_object_release( p_input );
01390 }
01391 }
01392
01393 #if wxUSE_DRAG_AND_DROP
01394
01395
01396
01397 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
01398 {
01399 p_intf = _p_intf;
01400 b_enqueue = _b_enqueue;
01401 }
01402
01403 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
01404 const wxArrayString& filenames )
01405 {
01406
01407
01408 playlist_t *p_playlist =
01409 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01410 FIND_ANYWHERE );
01411 if( p_playlist == NULL )
01412 {
01413 return FALSE;
01414 }
01415
01416 for( size_t i = 0; i < filenames.GetCount(); i++ )
01417 {
01418 char *psz_utf8 = wxFromLocale( filenames[i] );
01419 playlist_Add( p_playlist, psz_utf8, psz_utf8,
01420 PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
01421 PLAYLIST_END );
01422 wxLocaleFree( psz_utf8 );
01423 }
01424
01425 vlc_object_release( p_playlist );
01426
01427 return TRUE;
01428 }
01429 #endif
01430
01431
01432
01433
01434 class wxVolCtrl: public wxGauge
01435 {
01436 public:
01437
01438 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
01439 wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) );
01440 virtual ~wxVolCtrl() {};
01441
01442 void UpdateVolume();
01443 int GetVolume();
01444
01445 void OnChange( wxMouseEvent& event );
01446
01447 private:
01448 intf_thread_t *p_intf;
01449
01450 DECLARE_EVENT_TABLE();
01451 };
01452
01453 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
01454
01455 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
01456 EVT_MOTION(wxVolCtrl::OnChange)
01457 END_EVENT_TABLE()
01458
01459 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
01460 wxPoint point, wxSize size )
01461 : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH )
01462 {
01463 p_intf = _p_intf;
01464 UpdateVolume();
01465 }
01466
01467 void wxVolCtrl::OnChange( wxMouseEvent& event )
01468 {
01469 if( !event.LeftDown() && !event.LeftIsDown() ) return;
01470
01471 int i_volume = event.GetX() * 200 / GetClientSize().GetWidth();
01472 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
01473 UpdateVolume();
01474 }
01475
01476 void wxVolCtrl::UpdateVolume()
01477 {
01478 audio_volume_t i_volume;
01479 aout_VolumeGet( p_intf, &i_volume );
01480
01481 int i_gauge_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX;
01482 if( i_gauge_volume == GetValue() ) return;
01483
01484 SetValue( i_gauge_volume );
01485 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
01486 i_gauge_volume / 2 ) );
01487 }
01488
01489 #if defined(__WXGTK__)
01490 #define VLCVOL_HEIGHT p_parent->GetSize().GetHeight()
01491 #else
01492 #define VLCVOL_HEIGHT TOOLBAR_BMP_HEIGHT
01493 #endif
01494 VLCVolCtrl::VLCVolCtrl( intf_thread_t *_p_intf, wxWindow *p_parent )
01495 :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, VLCVOL_HEIGHT ),
01496 wxBORDER_NONE ),
01497 i_y_offset((VLCVOL_HEIGHT - TOOLBAR_BMP_HEIGHT) / 2),
01498 b_mute(0), p_intf(_p_intf)
01499 {
01500 gauge = new wxVolCtrl( p_intf, this, -1, wxPoint( 18, i_y_offset ),
01501 wxSize( 44, TOOLBAR_BMP_HEIGHT ) );
01502 }
01503
01504 void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
01505 {
01506 wxPaintDC dc( this );
01507 wxBitmap mPlayBitmap( b_mute ? speaker_mute_xpm : speaker_xpm );
01508 dc.DrawBitmap( mPlayBitmap, 0, i_y_offset, TRUE );
01509 }
01510
01511 void VLCVolCtrl::OnChange( wxMouseEvent& event )
01512 {
01513 if( event.GetX() < TOOLBAR_BMP_WIDTH )
01514 {
01515 int i_volume;
01516 aout_VolumeMute( p_intf, (audio_volume_t *)&i_volume );
01517
01518 b_mute = !b_mute;
01519 Refresh();
01520 }
01521 }
01522
01523 void VLCVolCtrl::UpdateVolume()
01524 {
01525 gauge->UpdateVolume();
01526
01527 int i_volume = gauge->GetValue();
01528 if( !!i_volume == !b_mute ) return;
01529 b_mute = !b_mute;
01530 Refresh();
01531 }
01532
01533
01534
01535
01536
01537 #ifdef wxHAS_TASK_BAR_ICON
01538
01539 BEGIN_EVENT_TABLE(Systray, wxTaskBarIcon)
01540
01541 #ifdef WIN32
01542 EVT_TASKBAR_LEFT_DCLICK(Systray::OnLeftClick)
01543 #else
01544 EVT_TASKBAR_LEFT_DOWN(Systray::OnLeftClick)
01545 #endif
01546
01547 EVT_MENU(Iconize_Event, Systray::OnMenuIconize)
01548 EVT_MENU(Exit_Event, Systray::OnExit)
01549 EVT_MENU(PlayStream_Event, Systray::OnPlayStream)
01550 EVT_MENU(NextStream_Event, Systray::OnNextStream)
01551 EVT_MENU(PrevStream_Event, Systray::OnPrevStream)
01552 EVT_MENU(StopStream_Event, Systray::OnStopStream)
01553 END_EVENT_TABLE()
01554
01555 Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf )
01556 {
01557 p_main_interface = _p_main_interface;
01558 p_intf = _p_intf;
01559 }
01560
01561
01562 void Systray::OnMenuIconize( wxCommandEvent& event )
01563 {
01564 p_main_interface->Show( ! p_main_interface->IsShown() );
01565 if ( p_main_interface->IsShown() ) p_main_interface->Raise();
01566 }
01567
01568 void Systray::OnLeftClick( wxTaskBarIconEvent& event )
01569 {
01570 wxCommandEvent cevent;
01571 OnMenuIconize(cevent);
01572 }
01573
01574 void Systray::OnExit( wxCommandEvent& event )
01575 {
01576 p_main_interface->Close(TRUE);
01577 }
01578
01579 void Systray::OnPrevStream( wxCommandEvent& event )
01580 {
01581 p_main_interface->PrevStream();
01582 }
01583
01584 void Systray::OnNextStream( wxCommandEvent& event )
01585 {
01586 p_main_interface->NextStream();
01587 }
01588
01589 void Systray::OnPlayStream( wxCommandEvent& event )
01590 {
01591 p_main_interface->PlayStream();
01592 }
01593
01594 void Systray::OnStopStream( wxCommandEvent& event )
01595 {
01596 p_main_interface->StopStream();
01597 }
01598
01599
01600 wxMenu* Systray::CreatePopupMenu()
01601 {
01602 int minimal = config_GetInt( p_intf, "wx-minimal" );
01603
01604 wxMenu* systray_menu = new wxMenu;
01605 systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) );
01606 systray_menu->AppendSeparator();
01607 systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) );
01608
01609 if (!minimal)
01610 {
01611 systray_menu->Append( PrevStream_Event, wxU(_("Previous")) );
01612 systray_menu->Append( NextStream_Event, wxU(_("Next")) );
01613 systray_menu->Append( StopStream_Event, wxU(_("Stop")) );
01614 }
01615 systray_menu->AppendSeparator();
01616 systray_menu->Append( Iconize_Event, wxU(_("Show/Hide interface")) );
01617 return systray_menu;
01618 }
01619
01620 void Systray::UpdateTooltip( const wxChar* tooltip )
01621 {
01622 SetIcon( wxIcon( vlc16x16_xpm ), tooltip );
01623 }
01624 #endif