interface.cpp 44.7 KB
Newer Older
gbazin's avatar
   
gbazin committed
1
2
3
/*****************************************************************************
 * interface.cpp : wxWindows plugin for vlc
 *****************************************************************************
hartman's avatar
hartman committed
4
 * Copyright (C) 2000-2004, 2003 VideoLAN
gbazin's avatar
gbazin committed
5
 * $Id$
gbazin's avatar
   
gbazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
gbazin's avatar
   
gbazin committed
8
9
10
11
12
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
13
 *
gbazin's avatar
   
gbazin committed
14
15
16
17
18
19
20
21
22
23
24
25
26
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
27
#include <vlc/vlc.h>
gbazin's avatar
   
gbazin committed
28
#include <vlc/aout.h>
29
#include <vlc/vout.h>
gbazin's avatar
   
gbazin committed
30
#include <vlc/intf.h>
gbazin's avatar
   
gbazin committed
31
#include "stream_control.h"
gbazin's avatar
   
gbazin committed
32
33
34
35
36
37
38

#include "wxwindows.h"

/* include the toolbar graphics */
#include "bitmaps/play.xpm"
#include "bitmaps/pause.xpm"
#include "bitmaps/stop.xpm"
39
#include "bitmaps/prev.xpm"
gbazin's avatar
   
gbazin committed
40
#include "bitmaps/next.xpm"
41
#include "bitmaps/eject.xpm"
gbazin's avatar
   
gbazin committed
42
#include "bitmaps/slow.xpm"
43
#include "bitmaps/fast.xpm"
44
#include "bitmaps/speaker.xpm"
gbazin's avatar
   
gbazin committed
45

46
47
#define TOOLBAR_BMP_WIDTH 16
#define TOOLBAR_BMP_HEIGHT 16
gbazin's avatar
   
gbazin committed
48

gbazin's avatar
   
gbazin committed
49
/* include the icon graphic */
Sam Hocevar's avatar
Sam Hocevar committed
50
#include "../../../share/vlc32x32.xpm"
gbazin's avatar
   
gbazin committed
51
52
53
54

/*****************************************************************************
 * Local class declarations.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class wxMenuExt: public wxMenu
{
public:
    /* Constructor */
    wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
                   const wxString& helpString, wxItemKind kind,
                   char *_psz_var, int _i_object_id, vlc_value_t _val,
                   int _i_val_type );

    virtual ~wxMenuExt() {};

    char *psz_var;
    int  i_val_type;
    int  i_object_id;
    vlc_value_t val;

private:

};
gbazin's avatar
   
gbazin committed
74

gbazin's avatar
   
gbazin committed
75
76
77
78
class wxVolCtrl: public wxGauge
{
public:
    /* Constructor */
79
80
    wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
               wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) );
gbazin's avatar
   
gbazin committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    virtual ~wxVolCtrl() {};

    void Change( int i_volume );

    void OnChange( wxMouseEvent& event );

private:
    intf_thread_t *p_intf;

    DECLARE_EVENT_TABLE();
};

BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
    /* Mouse events */
    EVT_LEFT_DOWN(wxVolCtrl::OnChange)
96
    EVT_MOTION(wxVolCtrl::OnChange)
gbazin's avatar
   
gbazin committed
97
98
END_EVENT_TABLE()

gbazin's avatar
   
gbazin committed
99
100
101
102
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

gbazin's avatar
gbazin committed
103
104
DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );

gbazin's avatar
   
gbazin committed
105
106
107
108
/* IDs for the controls and the menu commands */
enum
{
    /* menu items */
zorglub's avatar
zorglub committed
109
    MenuDummy_Event = wxID_HIGHEST + 1000,
gbazin's avatar
   
gbazin committed
110
    Exit_Event = wxID_HIGHEST,
gbazin's avatar
   
gbazin committed
111
    OpenFileSimple_Event,
zorglub's avatar
zorglub committed
112
    OpenAdv_Event,
gbazin's avatar
   
gbazin committed
113
114
115
116
    OpenFile_Event,
    OpenDisc_Event,
    OpenNet_Event,
    OpenSat_Event,
zorglub's avatar
zorglub committed
117
    OpenOther_Event,
gbazin's avatar
   
gbazin committed
118
119
    EjectDisc_Event,

gbazin's avatar
   
gbazin committed
120
    StreamWizard_Event,
zorglub's avatar
zorglub committed
121

122
    Playlist_Event,
gbazin's avatar
   
gbazin committed
123
    Logs_Event,
124
    FileInfo_Event,
gbazin's avatar
   
gbazin committed
125
126

    Prefs_Event,
gbazin's avatar
gbazin committed
127
128
    Extended_Event,
    Bookmarks_Event,
gbazin's avatar
   
gbazin committed
129
    Skins_Event,
gbazin's avatar
   
gbazin committed
130
131
132
133
134

    SliderScroll_Event,
    StopStream_Event,
    PlayStream_Event,
    PrevStream_Event,
gbazin's avatar
   
gbazin committed
135
    NextStream_Event,
gbazin's avatar
   
gbazin committed
136
137
    SlowStream_Event,
    FastStream_Event,
gbazin's avatar
   
gbazin committed
138

zorglub's avatar
zorglub committed
139
140
141
142
143
    Adjust_Event,
    Hue_Event,
    Contrast_Event,
    Brightness_Event,
    Saturation_Event,
144
    Gamma_Event,
zorglub's avatar
zorglub committed
145
146

    Ratio_Event,
zorglub's avatar
zorglub committed
147
148
    Visual_Event,

gbazin's avatar
   
gbazin committed
149
150
151
    /* it is important for the id corresponding to the "About" command to have
     * this standard value as otherwise it won't be handled properly under Mac
     * (where it is special and put into the "Apple" menu) */
gbazin's avatar
   
gbazin committed
152
    About_Event = wxID_ABOUT
gbazin's avatar
   
gbazin committed
153
154
155
156
157
158
};

BEGIN_EVENT_TABLE(Interface, wxFrame)
    /* Menu events */
    EVT_MENU(Exit_Event, Interface::OnExit)
    EVT_MENU(About_Event, Interface::OnAbout)
gbazin's avatar
   
gbazin committed
159
160
161
162
163

    EVT_MENU(Playlist_Event, Interface::OnShowDialog)
    EVT_MENU(Logs_Event, Interface::OnShowDialog)
    EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
    EVT_MENU(Prefs_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
164

gbazin's avatar
   
gbazin committed
165
166
    EVT_MENU_OPEN(Interface::OnMenuOpen)

gbazin's avatar
gbazin committed
167
168
    EVT_MENU( Extended_Event, Interface::OnExtended)
    EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
zorglub's avatar
zorglub committed
169

gbazin's avatar
gbazin committed
170
    EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
gbazin's avatar
   
gbazin committed
171
    EVT_TEXT( Ratio_Event, Interface::OnRatio)
zorglub's avatar
zorglub committed
172
    EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
zorglub's avatar
zorglub committed
173

gbazin's avatar
   
gbazin committed
174
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
gbazin's avatar
   
gbazin committed
175
    EVT_CONTEXT_MENU(Interface::OnContextMenu2)
gbazin's avatar
   
gbazin committed
176
#endif
gbazin's avatar
   
gbazin committed
177
    EVT_RIGHT_UP(Interface::OnContextMenu)
gbazin's avatar
   
gbazin committed
178

gbazin's avatar
   
gbazin committed
179
    /* Toolbar events */
gbazin's avatar
   
gbazin committed
180
    EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
zorglub's avatar
zorglub committed
181
    EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
182
183
184
185
    EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
    EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
    EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
    EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
186
    EVT_MENU(StreamWizard_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
187
188
189
190
    EVT_MENU(StopStream_Event, Interface::OnStopStream)
    EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
    EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
    EVT_MENU(NextStream_Event, Interface::OnNextStream)
gbazin's avatar
   
gbazin committed
191
192
    EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
    EVT_MENU(FastStream_Event, Interface::OnFastStream)
gbazin's avatar
   
gbazin committed
193

gbazin's avatar
   
gbazin committed
194
195
    /* Slider events */
    EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
gbazin's avatar
   
gbazin committed
196

zorglub's avatar
zorglub committed
197
198
199
200
    EVT_COMMAND_SCROLL(Hue_Event, Interface::OnHueUpdate)
    EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
    EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
    EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
201
    EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
zorglub's avatar
zorglub committed
202

gbazin's avatar
gbazin committed
203
204
205
    /* Custom events */
    EVT_COMMAND(0, wxEVT_INTF, Interface::UpdateSizeEvent)

gbazin's avatar
   
gbazin committed
206
207
208
209
210
211
END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
Interface::Interface( intf_thread_t *_p_intf ):
gbazin's avatar
   
gbazin committed
212
    wxFrame( NULL, -1, wxT("VLC media player"),
213
             wxDefaultPosition, wxSize(700,100), wxDEFAULT_FRAME_STYLE )
gbazin's avatar
   
gbazin committed
214
215
216
{
    /* Initializations */
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
217
    i_old_playing_status = PAUSE_S;
zorglub's avatar
zorglub committed
218
    b_extra = VLC_FALSE;
gbazin's avatar
   
gbazin committed
219

gbazin's avatar
   
gbazin committed
220
    /* Give our interface a nice little icon */
gbazin's avatar
   
gbazin committed
221
    SetIcon( wxIcon( vlc_xpm ) );
gbazin's avatar
   
gbazin committed
222
223

    /* Create a sizer for the main frame */
zorglub's avatar
zorglub committed
224
    frame_sizer = new wxBoxSizer( wxVERTICAL );
gbazin's avatar
   
gbazin committed
225
226
    SetSizer( frame_sizer );

227
228
229
230
    /* Create a dummy widget that can get the keyboard focus */
    wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
                                      wxSize(0,0) );
    p_dummy->SetFocus();
231
    frame_sizer->Add( p_dummy, 0, wxEXPAND );
zorglub's avatar
zorglub committed
232

gbazin's avatar
   
gbazin committed
233
234
235
236
237
238
    /* Creation of the menu bar */
    CreateOurMenuBar();

    /* Creation of the tool bar */
    CreateOurToolBar();

zorglub's avatar
zorglub committed
239
    /* Create the extra panel */
gbazin's avatar
gbazin committed
240
    CreateOurExtendedPanel();
zorglub's avatar
zorglub committed
241
242
243
    frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
    frame_sizer->Hide( extra_frame );

244
    /* Creation of the status bar
gbazin's avatar
   
gbazin committed
245
246
     * Helptext for menu items and toolbar tools will automatically get
     * displayed here. */
gbazin's avatar
   
gbazin committed
247
248
249
250
251
    int i_status_width[3] = {-6, -2, -9};
    statusbar = CreateStatusBar( 3 );                            /* 2 fields */
    statusbar->SetStatusWidths( 3, i_status_width );
    statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );

gbazin's avatar
gbazin committed
252
253
254
255
256
257
258
    /* Video window */
    if( config_GetInt( p_intf, "wxwin-embed" ) )
    {
        VideoWindow( p_intf, this );
        frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
    }

259
260
261
262
263
264
265
266
    /* Creation of the slider sub-window */
    CreateOurSlider();
    frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
    frame_sizer->Hide( slider_frame );

    /* Make sure we've got the right background colour */
    SetBackgroundColour( slider_frame->GetBackgroundColour() );

gbazin's avatar
   
gbazin committed
267
268
    /* Layout everything */
    frame_sizer->Layout();
gbazin's avatar
   
gbazin committed
269
    frame_sizer->Fit(this);
gbazin's avatar
   
gbazin committed
270

gbazin's avatar
   
gbazin committed
271
#if !defined(__WXX11__)
gbazin's avatar
   
gbazin committed
272
273
    /* Associate drop targets with the main interface */
    SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
274
#endif
275
276

    UpdateAcceleratorTable();
gbazin's avatar
   
gbazin committed
277
278
279

    /* Start timer */
    timer = new Timer( p_intf, this );
gbazin's avatar
   
gbazin committed
280
281
282
283
}

Interface::~Interface()
{
gbazin's avatar
   
gbazin committed
284
285
286
287
    if( p_intf->p_sys->p_wxwindow )
    {
        delete p_intf->p_sys->p_wxwindow;
    }
gbazin's avatar
   
gbazin committed
288

gbazin's avatar
   
gbazin committed
289
    /* Clean up */
gbazin's avatar
   
gbazin committed
290
    delete timer;
gbazin's avatar
   
gbazin committed
291
}
gbazin's avatar
   
gbazin committed
292

gbazin's avatar
gbazin committed
293
294
295
296
297
298
void Interface::UpdateSizeEvent( wxCommandEvent& event )
{
    frame_sizer->Layout();
    frame_sizer->Fit(this);
}

gbazin's avatar
   
gbazin committed
299
300
301
302
303
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
void Interface::CreateOurMenuBar()
{
zorglub's avatar
zorglub committed
304
#define HELP_SIMPLE N_("Quick file open")
gbazin's avatar
gbazin committed
305
#define HELP_ADV   N_("Advanced open")
gbazin's avatar
   
gbazin committed
306
#define HELP_FILE  N_("Open a file")
307
#define HELP_DISC  N_("Open Disc Media")
gbazin's avatar
   
gbazin committed
308
309
310
311
#define HELP_NET   N_("Open a network stream")
#define HELP_SAT   N_("Open a satellite stream")
#define HELP_EJECT N_("Eject the DVD/CD")
#define HELP_EXIT  N_("Exit this program")
gbazin's avatar
   
gbazin committed
312

gbazin's avatar
   
gbazin committed
313
#define HELP_STREAMWIZARD N_("Open the streaming wizard")
zorglub's avatar
zorglub committed
314

gbazin's avatar
   
gbazin committed
315
316
#define HELP_PLAYLIST   N_("Open the playlist")
#define HELP_LOGS       N_("Show the program logs")
gbazin's avatar
gbazin committed
317
#define HELP_FILEINFO   N_("Show information about the file being played")
gbazin's avatar
   
gbazin committed
318

gbazin's avatar
gbazin committed
319
320
321
#define HELP_PREFS     N_("Go to the preferences menu")
#define HELP_EXTENDED  N_("Shows the extended GUI")
#define HELP_BOOKMARKS N_("Shows the bookmarks window")
gbazin's avatar
   
gbazin committed
322
323
324
325

#define HELP_ABOUT N_("About this program")

    /* Create the "File" menu */
gbazin's avatar
   
gbazin committed
326
    wxMenu *file_menu = new wxMenu;
327
328
    file_menu->Append( OpenFileSimple_Event,
                       wxU(_("Quick &Open File...\tCtrl-O")),
zorglub's avatar
zorglub committed
329
330
331
                       wxU(_(HELP_SIMPLE)) );

    file_menu->AppendSeparator();
332
333
334
335
336
337
338
    file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")),
                       wxU(_(HELP_FILE)));
    file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")),
                       wxU(_(HELP_DISC)));
    file_menu->Append( OpenNet_Event,
                       wxU(_("Open &Network Stream...\tCtrl-N")),
                       wxU(_(HELP_NET)));
zorglub's avatar
zorglub committed
339

gbazin's avatar
   
gbazin committed
340
    file_menu->AppendSeparator();
341
342
    file_menu->Append( StreamWizard_Event,
                       wxU(_("Streaming &Wizard...\tCtrl-W")),
gbazin's avatar
   
gbazin committed
343
                       wxU(_(HELP_STREAMWIZARD)) );
gbazin's avatar
   
gbazin committed
344
    file_menu->AppendSeparator();
345
346
    file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")),
                       wxU(_(HELP_EXIT)) );
gbazin's avatar
   
gbazin committed
347

gbazin's avatar
   
gbazin committed
348
    /* Create the "View" menu */
gbazin's avatar
   
gbazin committed
349
    wxMenu *view_menu = new wxMenu;
350
    view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")),
gbazin's avatar
   
gbazin committed
351
                       wxU(_(HELP_PLAYLIST)) );
352
353
    view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")),
                       wxU(_(HELP_LOGS)) );
354
355
    view_menu->Append( FileInfo_Event,
                       wxU(_("Stream and Media &info...\tCtrl-I")),
gbazin's avatar
   
gbazin committed
356
                       wxU(_(HELP_FILEINFO)) );
gbazin's avatar
   
gbazin committed
357

gbazin's avatar
   
gbazin committed
358
    /* Create the "Settings" menu */
gbazin's avatar
   
gbazin committed
359
360
    p_settings_menu = new wxMenu;
    b_settings_menu = 1;
zorglub's avatar
zorglub committed
361

gbazin's avatar
   
gbazin committed
362
363
364
365
366
367
368
369
    /* Create the "Audio" menu */
    p_audio_menu = new wxMenu;
    b_audio_menu = 1;

    /* Create the "Video" menu */
    p_video_menu = new wxMenu;
    b_video_menu = 1;

gbazin's avatar
   
gbazin committed
370
371
372
373
    /* Create the "Navigation" menu */
    p_navig_menu = new wxMenu;
    b_navig_menu = 1;

gbazin's avatar
   
gbazin committed
374
    /* Create the "Help" menu */
gbazin's avatar
   
gbazin committed
375
    wxMenu *help_menu = new wxMenu;
376
377
    help_menu->Append( About_Event, wxU(_("About VLC media player")),
                       wxU(_(HELP_ABOUT)) );
gbazin's avatar
   
gbazin committed
378
379
380

    /* Append the freshly created menus to the menu bar... */
    wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
gbazin's avatar
   
gbazin committed
381
382
    menubar->Append( file_menu, wxU(_("&File")) );
    menubar->Append( view_menu, wxU(_("&View")) );
gbazin's avatar
   
gbazin committed
383
    menubar->Append( p_settings_menu, wxU(_("&Settings")) );
gbazin's avatar
   
gbazin committed
384
385
    menubar->Append( p_audio_menu, wxU(_("&Audio")) );
    menubar->Append( p_video_menu, wxU(_("&Video")) );
gbazin's avatar
   
gbazin committed
386
    menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
gbazin's avatar
   
gbazin committed
387
    menubar->Append( help_menu, wxU(_("&Help")) );
gbazin's avatar
   
gbazin committed
388
389
390
391

    /* Attach the menu bar to the frame */
    SetMenuBar( menubar );

gbazin's avatar
   
gbazin committed
392
393
394
    /* Intercept all menu events in our custom event handler */
    PushEventHandler( new MenuEvtHandler( p_intf, this ) );

gbazin's avatar
   
gbazin committed
395
#if !defined(__WXX11__)
gbazin's avatar
   
gbazin committed
396
397
    /* Associate drop targets with the menubar */
    menubar->SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
398
#endif
gbazin's avatar
   
gbazin committed
399
400
}

401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
class VLCVolCtrl : public wxControl
{
public:
    VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
    virtual ~VLCVolCtrl() {};

    virtual void OnPaint( wxPaintEvent &event );

  private:
    DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
   EVT_PAINT(VLCVolCtrl::OnPaint)
END_EVENT_TABLE()

VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
                        wxGauge **pp_volctrl )
419
  :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, 16 ), wxBORDER_NONE )
420
421
422
423
424
425
426
427
428
429
430
431
{
    *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint(18,0),
                                  wxSize(44,16) );
}

void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
{
    wxPaintDC dc( this );
    wxBitmap mPlayBitmap( speaker_xpm );
    dc.DrawBitmap( mPlayBitmap, 1, 0, TRUE );
}

gbazin's avatar
   
gbazin committed
432
433
void Interface::CreateOurToolBar()
{
hartman's avatar
hartman committed
434
#define HELP_STOP N_("Stop")
zorglub's avatar
zorglub committed
435

hartman's avatar
hartman committed
436
437
438
#define HELP_PLAY N_("Play")
#define HELP_PAUSE N_("Pause")
#define HELP_PLO N_("Playlist")
gbazin's avatar
   
gbazin committed
439
440
#define HELP_PLP N_("Previous playlist item")
#define HELP_PLN N_("Next playlist item")
gbazin's avatar
   
gbazin committed
441
442
#define HELP_SLOW N_("Play slower")
#define HELP_FAST N_("Play faster")
gbazin's avatar
   
gbazin committed
443

gbazin's avatar
   
gbazin committed
444
445
    wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
                         * version because we don't include wx.rc */
gbazin's avatar
   
gbazin committed
446

447
448
    wxToolBar *toolbar =
        CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
gbazin's avatar
   
gbazin committed
449

gbazin's avatar
   
gbazin committed
450
451
    toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );

gbazin's avatar
   
gbazin committed
452
    toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
gbazin's avatar
   
gbazin committed
453
                      wxU(_(HELP_PLAY)) );
454
455
456
457
458
459
#if 0
    toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
                      wxU(_(HELP_PAUSE)) );
#endif
    toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
                      wxU(_(HELP_STOP)) );
gbazin's avatar
   
gbazin committed
460
    toolbar->AddSeparator();
gbazin's avatar
   
gbazin committed
461
    toolbar->AddTool( PrevStream_Event, wxT(""),
462
463
464
465
466
                      wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
    toolbar->AddTool( SlowStream_Event, wxT(""),
                      wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
    toolbar->AddTool( FastStream_Event, wxT(""),
                      wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
gbazin's avatar
   
gbazin committed
467
    toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
gbazin's avatar
   
gbazin committed
468
                      wxU(_(HELP_PLN)) );
469
470
471
    toolbar->AddSeparator();
    toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( eject_xpm ),
                      wxU(_(HELP_PLO)) );
gbazin's avatar
   
gbazin committed
472

473
    wxControl *p_dummy_ctrl =
474
475
476
        new wxControl( toolbar, -1, wxDefaultPosition,
                       wxSize(64, 16 ), wxBORDER_NONE );

477
    toolbar->AddControl( p_dummy_ctrl );
gbazin's avatar
   
gbazin committed
478

479
480
481
482
    VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
    toolbar->AddControl( sound_control );

    toolbar->Realize();
gbazin's avatar
   
gbazin committed
483

484
485
    // '7' is the number of buttons on the toolbar, '3' is arbitrary :)
    frame_sizer->SetMinSize( TOOLBAR_BMP_WIDTH * 7 * 3, -1 );
486

gbazin's avatar
   
gbazin committed
487
#if !defined(__WXX11__)
gbazin's avatar
   
gbazin committed
488
489
    /* Associate drop targets with the toolbar */
    toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
490
#endif
gbazin's avatar
   
gbazin committed
491
492
}

gbazin's avatar
   
gbazin committed
493
void Interface::CreateOurSlider()
gbazin's avatar
   
gbazin committed
494
{
gbazin's avatar
   
gbazin committed
495
    /* Create a new frame and sizer containing the slider */
gbazin's avatar
   
gbazin committed
496
    slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
gbazin's avatar
   
gbazin committed
497
    slider_frame->SetAutoLayout( TRUE );
gbazin's avatar
   
gbazin committed
498
499
    wxBoxSizer *frame_sizer =
        new wxBoxSizer( wxHORIZONTAL );
gbazin's avatar
   
gbazin committed
500
501

    /* Create static box to surround the slider */
gbazin's avatar
   
gbazin committed
502
    slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
gbazin's avatar
   
gbazin committed
503
504
505
506

    /* Create sizer for slider frame */
    wxStaticBoxSizer *slider_sizer =
        new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
gbazin's avatar
   
gbazin committed
507
    slider_sizer->SetMinSize( -1, 50 );
gbazin's avatar
   
gbazin committed
508
509
510
511

    /* Create slider */
    slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
                           SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
gbazin's avatar
   
gbazin committed
512
513
514
515
516
517
518
    slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );

    /* Add everything to the frame */
    frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
    slider_frame->SetSizer( frame_sizer );
    frame_sizer->Layout();
    frame_sizer->SetSizeHints(slider_frame);
gbazin's avatar
   
gbazin committed
519
520
521

    /* Hide the slider by default */
    slider_frame->Hide();
gbazin's avatar
   
gbazin committed
522
523
}

zorglub's avatar
zorglub committed
524

gbazin's avatar
gbazin committed
525
void Interface::CreateOurExtendedPanel()
zorglub's avatar
zorglub committed
526
527
528
529
530
531
532
533
{
    char *psz_filters;

    extra_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
    extra_frame->SetAutoLayout( TRUE );
    wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );

    /* Create static box to surround the adjust controls */
zorglub's avatar
zorglub committed
534
    wxStaticBox *adjust_box =
hartman's avatar
hartman committed
535
           new wxStaticBox( extra_frame, -1, wxU(_("Adjust Image")) );
zorglub's avatar
zorglub committed
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554

    /* Create the size for the frame */
    wxStaticBoxSizer *adjust_sizer =
        new wxStaticBoxSizer( adjust_box, wxVERTICAL );
    adjust_sizer->SetMinSize( -1, 50 );

    /* Create every controls */

    /* Create the adjust button */
    wxCheckBox * adjust_check = new wxCheckBox( extra_frame, Adjust_Event,
                                                 wxU(_("Enable")));


    wxBoxSizer *hue_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *hue_text = new wxStaticText( extra_frame, -1,
                                       wxU(_("Hue")) );
    hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
                                360, wxDefaultPosition, wxDefaultSize );

555
556
557
    hue_sizer->Add(hue_text,1, 0 ,0);
    hue_sizer->Add(hue_slider,1, 0 ,0);
    hue_sizer->Layout();
zorglub's avatar
zorglub committed
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585

    wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
                                       wxU(_("Contrast")) );
    contrast_slider = new wxSlider ( extra_frame, Contrast_Event, 0, 0,
                                200, wxDefaultPosition, wxDefaultSize);
    contrast_sizer->Add(contrast_text,1, 0 ,0);
    contrast_sizer->Add(contrast_slider,1, 0 ,0);
    contrast_sizer->Layout();

    wxBoxSizer *brightness_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *brightness_text = new wxStaticText( extra_frame, -1,
                                       wxU(_("Brightness")) );
    brightness_slider = new wxSlider ( extra_frame, Brightness_Event, 0, 0,
                           200, wxDefaultPosition, wxDefaultSize) ;
    brightness_sizer->Add(brightness_text,1,0,0);
    brightness_sizer->Add(brightness_slider,1,0,0);
    brightness_sizer->Layout();

    wxBoxSizer *saturation_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *saturation_text = new wxStaticText( extra_frame, -1,
                                          wxU(_("Saturation")) );
    saturation_slider = new wxSlider ( extra_frame, Saturation_Event, 0, 0,
                           300, wxDefaultPosition, wxDefaultSize );
    saturation_sizer->Add(saturation_text,1,0,0);
    saturation_sizer->Add(saturation_slider,1,0,0);
    saturation_sizer->Layout();

586
587
588
589
590
591
592
593
594
    wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
                                          wxU(_("Gamma")) );
    gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
                           100, wxDefaultPosition, wxDefaultSize );
    gamma_sizer->Add(gamma_text,1,0,0);
    gamma_sizer->Add(gamma_slider,1,0,0);
    gamma_sizer->Layout();

zorglub's avatar
zorglub committed
595
596
597
598
599
    adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
    adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
    adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
    adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
    adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
600
    adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
zorglub's avatar
zorglub committed
601
602
603

    extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);

zorglub's avatar
zorglub committed
604
605
606
    /* Create sizer to surround the other controls */
    wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );

zorglub's avatar
zorglub committed
607

zorglub's avatar
zorglub committed
608
609
    wxStaticBox *video_box =
            new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) );
zorglub's avatar
zorglub committed
610
    /* Create the sizer for the frame */
zorglub's avatar
zorglub committed
611
612
613
    wxStaticBoxSizer *video_sizer =
       new wxStaticBoxSizer( video_box, wxVERTICAL );
    video_sizer->SetMinSize( -1, 50 );
zorglub's avatar
zorglub committed
614
615
616
617
618
619
620
621
622

    static const wxString ratio_array[] =
    {
        wxT("4:3"),
        wxT("16:9"),
    };

    wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *ratio_text = new wxStaticText( extra_frame, -1,
hartman's avatar
hartman committed
623
                                          wxU(_("Aspect Ratio")) );
zorglub's avatar
zorglub committed
624
625
626
627
628
629
630
631
632
633

    ratio_combo = new wxComboBox( extra_frame, Ratio_Event, wxT(""),
                                  wxDefaultPosition, wxSize(120,-1),
                                  WXSIZEOF(ratio_array), ratio_array,
                                  0 );

    ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
    ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
    ratio_sizer->Layout();

zorglub's avatar
zorglub committed
634
635
636
    video_sizer->Add( ratio_sizer  , 0 , wxALL , 0 );
    video_sizer->Layout();

gbazin's avatar
   
gbazin committed
637
#if 0
zorglub's avatar
zorglub committed
638
639
640
    wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL );

    wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event,
hartman's avatar
hartman committed
641
                                            wxU(_("Visualisations")) );
zorglub's avatar
zorglub committed
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656

    visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0);
    visual_sizer->Layout();

    wxStaticBox *audio_box =
              new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) );
    /* Create the sizer for the frame */
    wxStaticBoxSizer *audio_sizer =
        new wxStaticBoxSizer( audio_box, wxVERTICAL );
    audio_sizer->SetMinSize( -1, 50 );

    audio_sizer->Add( visual_sizer, 0, wxALL, 0);
    audio_sizer->Layout();

    other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 );
gbazin's avatar
   
gbazin committed
657
658
#endif
    other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
zorglub's avatar
zorglub committed
659
    other_sizer->Layout();
zorglub's avatar
zorglub committed
660
661
662
663
664
665
666
667
668
669
670

    extra_sizer->Add(other_sizer,0,wxBOTTOM,5);

    extra_frame->SetSizer( extra_sizer );

    /* Layout the whole panel */
    extra_sizer->Layout();

    extra_sizer->SetSizeHints(extra_frame);

    /* Write down initial values */
671
#if 0
gbazin's avatar
   
gbazin committed
672
673
    psz_filters = config_GetPsz( p_intf, "audio-filter" );
    if( psz_filters && strstr( psz_filters, "visual" ) )
zorglub's avatar
zorglub committed
674
675
676
    {
        visual_checkbox->SetValue(1);
    }
gbazin's avatar
   
gbazin committed
677
    if( psz_filters ) free( psz_filters );
678
#endif
zorglub's avatar
zorglub committed
679
    psz_filters = config_GetPsz( p_intf, "filter" );
gbazin's avatar
   
gbazin committed
680
    if( psz_filters && strstr( psz_filters, "adjust" ) )
zorglub's avatar
zorglub committed
681
682
683
684
685
686
    {
        adjust_check->SetValue( 1 );
        saturation_slider->Enable();
        contrast_slider->Enable();
        brightness_slider->Enable();
        hue_slider->Enable();
687
        gamma_slider->Enable();
zorglub's avatar
zorglub committed
688
689
690
691
692
693
694
695
    }
    else
    {
        adjust_check->SetValue( 0 );
        saturation_slider->Disable();
        contrast_slider->Disable();
        brightness_slider->Disable();
        hue_slider->Disable();
696
        gamma_slider->Disable();
zorglub's avatar
zorglub committed
697
    }
gbazin's avatar
   
gbazin committed
698
    if( psz_filters ) free( psz_filters );
zorglub's avatar
zorglub committed
699

700
701
702
703
704
705
    int i_value = config_GetInt( p_intf, "hue" );
    if( i_value > 0 && i_value < 360 )
        hue_slider->SetValue( i_value );

    float f_value;
    f_value = config_GetFloat( p_intf, "saturation" );
706
    if( f_value > 0 && f_value < 5 )
707
708
        saturation_slider->SetValue( (int)(100 * f_value) );
    f_value = config_GetFloat( p_intf, "contrast" );
709
    if( f_value > 0 && f_value < 4 )
710
711
712
713
        contrast_slider->SetValue( (int)(100 * f_value) );
    f_value = config_GetFloat( p_intf, "brightness" );
    if( f_value > 0 && f_value < 2 )
        brightness_slider->SetValue( (int)(100 * f_value) );
714
    f_value = config_GetFloat( p_intf, "gamma" );
hartman's avatar
hartman committed
715
    if( f_value > 0 && f_value < 10 )
716
        gamma_slider->SetValue( (int)(10 * f_value) );
717

zorglub's avatar
zorglub committed
718
719
720
    extra_frame->Hide();
}

721
722
723
void Interface::UpdateAcceleratorTable()
{
    /* Set some hotkeys */
724
    wxAcceleratorEntry entries[7];
gbazin's avatar
   
gbazin committed
725
    vlc_value_t val;
726
    int i = 0;
gbazin's avatar
   
gbazin committed
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748

    var_Get( p_intf->p_vlc, "key-quit", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), Exit_Event );
    var_Get( p_intf->p_vlc, "key-stop", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), StopStream_Event );
    var_Get( p_intf->p_vlc, "key-play-pause", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), PlayStream_Event );
    var_Get( p_intf->p_vlc, "key-next", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), NextStream_Event );
    var_Get( p_intf->p_vlc, "key-prev", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), PrevStream_Event );
    var_Get( p_intf->p_vlc, "key-faster", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), FastStream_Event );
    var_Get( p_intf->p_vlc, "key-slower", &val );
    entries[i++].Set( ConvertHotkeyModifiers( val.i_int ),
                      ConvertHotkey( val.i_int ), SlowStream_Event );
749

750
    wxAcceleratorTable accel( 7, entries );
751
752
753

    if( !accel.Ok() )
        msg_Err( p_intf, "invalid accelerator table" );
zorglub's avatar
zorglub committed
754

755
756
    SetAcceleratorTable( accel );
    msg_Dbg( p_intf, "accelerator table loaded" );
zorglub's avatar
zorglub committed
757

758
759
}

gbazin's avatar
   
gbazin committed
760
/*****************************************************************************
gbazin's avatar
   
gbazin committed
761
 * Event Handlers.
gbazin's avatar
   
gbazin committed
762
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
763
764
765
766
767
768
769
/* Work-around helper for buggy wxGTK */
void RecursiveDestroy( wxMenu *menu )
{
    wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
    for( ; node; )
    {
        wxMenuItem *item = node->GetData();
gbazin's avatar
   
gbazin committed
770
771
772
773
774
775
776
777
778
        node = node->GetNext();

        /* Delete the submenus */
        wxMenu *submenu = item->GetSubMenu();
        if( submenu )
        {
            RecursiveDestroy( submenu );
        }
        menu->Delete( item );
gbazin's avatar
   
gbazin committed
779
780
781
    }
}

gbazin's avatar
   
gbazin committed
782
783
void Interface::OnMenuOpen(wxMenuEvent& event)
{
gbazin's avatar
   
gbazin committed
784
#if !defined( __WXMSW__ )
gbazin's avatar
   
gbazin committed
785
786
787
788
789
790
791
    if( event.GetEventObject() == p_settings_menu )
    {
        if( b_settings_menu )
        {
            p_settings_menu = SettingsMenu( p_intf, this );

            /* Add static items */
gbazin's avatar
gbazin committed
792
793
794
            p_settings_menu->AppendCheckItem( Extended_Event,
                             wxU(_("&Extended GUI") ), wxU(_(HELP_EXTENDED)) );
            p_settings_menu->AppendCheckItem( Bookmarks_Event,
795
                             wxU(_("&Bookmarks...") ), wxU(_(HELP_BOOKMARKS)) );
gbazin's avatar
   
gbazin committed
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
            p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
                                     wxU(_(HELP_PREFS)) );

            /* Work-around for buggy wxGTK */
            wxMenu *menu = GetMenuBar()->GetMenu( 2 );
            RecursiveDestroy( menu );
            /* End work-around */

            menu = GetMenuBar()->Replace( 2, p_settings_menu,
                                          wxU(_("&Settings")));
            if( menu ) delete menu;

            b_settings_menu = 0;
        }
        else b_settings_menu = 1;
    }
    else if( event.GetEventObject() == p_audio_menu )
gbazin's avatar
   
gbazin committed
813
814
815
816
    {
        if( b_audio_menu )
        {
            p_audio_menu = AudioMenu( p_intf, this );
gbazin's avatar
   
gbazin committed
817
818
819
820
821
822
823

            /* Work-around for buggy wxGTK */
            wxMenu *menu = GetMenuBar()->GetMenu( 3 );
            RecursiveDestroy( menu );
            /* End work-around */

            menu =
gbazin's avatar
   
gbazin committed
824
                GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
gbazin's avatar
   
gbazin committed
825
826
827
828
829
830
831
832
833
834
835
            if( menu ) delete menu;

            b_audio_menu = 0;
        }
        else b_audio_menu = 1;
    }
    else if( event.GetEventObject() == p_video_menu )
    {
        if( b_video_menu )
        {
            p_video_menu = VideoMenu( p_intf, this );
gbazin's avatar
   
gbazin committed
836
837
838
839
840
841
842

            /* Work-around for buggy wxGTK */
            wxMenu *menu = GetMenuBar()->GetMenu( 4 );
            RecursiveDestroy( menu );
            /* End work-around */

            menu =
gbazin's avatar
   
gbazin committed
843
                GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
gbazin's avatar
   
gbazin committed
844
845
846
847
848
849
            if( menu ) delete menu;

            b_video_menu = 0;
        }
        else b_video_menu = 1;
    }
gbazin's avatar
   
gbazin committed
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
    else if( event.GetEventObject() == p_navig_menu )
    {
        if( b_navig_menu )
        {
            p_navig_menu = NavigMenu( p_intf, this );

            /* Work-around for buggy wxGTK */
            wxMenu *menu = GetMenuBar()->GetMenu( 5 );
            RecursiveDestroy( menu );
            /* End work-around */

            menu =
                GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
            if( menu ) delete menu;

            b_navig_menu = 0;
        }
        else b_navig_menu = 1;
    }
gbazin's avatar
   
gbazin committed
869
870

#else
gbazin's avatar
   
gbazin committed
871
872
    p_settings_menu = SettingsMenu( p_intf, this );
    /* Add static items */
gbazin's avatar
gbazin committed
873
874
875
876
    p_settings_menu->AppendCheckItem( Extended_Event, wxU(_("&Extended GUI") ),
                                      wxU(_(HELP_EXTENDED)) );
    p_settings_menu->AppendCheckItem( Bookmarks_Event, wxU(_("&Bookmarks") ),
                                      wxU(_(HELP_BOOKMARKS)) );
gbazin's avatar
   
gbazin committed
877
878
879
880
881
882
    p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
                             wxU(_(HELP_PREFS)) );
    wxMenu *menu =
        GetMenuBar()->Replace( 2, p_settings_menu, wxU(_("&Settings")) );
    if( menu ) delete menu;

gbazin's avatar
   
gbazin committed
883
    p_audio_menu = AudioMenu( p_intf, this );
gbazin's avatar
   
gbazin committed
884
    menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
gbazin's avatar
   
gbazin committed
885
886
887
    if( menu ) delete menu;

    p_video_menu = VideoMenu( p_intf, this );
gbazin's avatar
   
gbazin committed
888
    menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
gbazin's avatar
   
gbazin committed
889
890
    if( menu ) delete menu;

gbazin's avatar
   
gbazin committed
891
892
893
    p_navig_menu = NavigMenu( p_intf, this );
    menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
    if( menu ) delete menu;
gbazin's avatar
   
gbazin committed
894
#endif
gbazin's avatar
   
gbazin committed
895

gbazin's avatar
   
gbazin committed
896
897
}

gbazin's avatar
   
gbazin committed
898
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
gbazin's avatar
   
gbazin committed
899
void Interface::OnContextMenu2(wxContextMenuEvent& event)
gbazin's avatar
   
gbazin committed
900
{
gbazin's avatar
   
gbazin committed
901
902
903
904
905
906
907
    /* Only show the context menu for the main interface */
    if( GetId() != event.GetId() )
    {
        event.Skip();
        return;
    }

gbazin's avatar
   
gbazin committed
908
    if( p_intf->p_sys->pf_show_dialog )
909
        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
gbazin's avatar
   
gbazin committed
910
}
gbazin's avatar
   
gbazin committed
911
#endif
gbazin's avatar
   
gbazin committed
912
913
void Interface::OnContextMenu(wxMouseEvent& event)
{
gbazin's avatar
   
gbazin committed
914
    if( p_intf->p_sys->pf_show_dialog )
915
        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
gbazin's avatar
   
gbazin committed
916
}
gbazin's avatar
   
gbazin committed
917

gbazin's avatar
   
gbazin committed
918
919
920
921
922
923
924
925
926
void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
{
    /* TRUE is to force the frame to close. */
    Close(TRUE);
}

void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
    wxString msg;
927
    msg.Printf( wxString(wxT("VLC media player " VERSION)) +
gbazin's avatar
   
gbazin committed
928
        wxU(_(" (wxWindows interface)\n\n")) +
hartman's avatar
hartman committed
929
        wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
zorglub's avatar
zorglub committed
930
        wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
gbazin's avatar
   
gbazin committed
931
        wxU(_("The VideoLAN team <videolan@videolan.org>\n"
gbazin's avatar
   
gbazin committed
932
              "http://www.videolan.org/\n\n")) );
gbazin's avatar
   
gbazin committed
933

gbazin's avatar
   
gbazin committed
934
935
    wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
                  wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
gbazin's avatar
   
gbazin committed
936
937
}

gbazin's avatar
   
gbazin committed
938
void Interface::OnShowDialog( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
939
{
gbazin's avatar
   
gbazin committed
940
    if( p_intf->p_sys->pf_show_dialog )
gbazin's avatar
   
gbazin committed
941
    {
gbazin's avatar
   
gbazin committed
942
        int i_id;
gbazin's avatar
   
gbazin committed
943

gbazin's avatar
   
gbazin committed
944
945
946
947
948
        switch( event.GetId() )
        {
        case OpenFileSimple_Event:
            i_id = INTF_DIALOG_FILE_SIMPLE;
            break;
zorglub's avatar
zorglub committed
949
950
        case OpenAdv_Event:
            i_id = INTF_DIALOG_FILE;
gbazin's avatar
   
gbazin committed
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
        case OpenFile_Event:
            i_id = INTF_DIALOG_FILE;
            break;
        case OpenDisc_Event:
            i_id = INTF_DIALOG_DISC;
            break;
        case OpenNet_Event:
            i_id = INTF_DIALOG_NET;
            break;
        case OpenSat_Event:
            i_id = INTF_DIALOG_SAT;
            break;
        case Playlist_Event:
            i_id = INTF_DIALOG_PLAYLIST;
            break;
        case Logs_Event:
            i_id = INTF_DIALOG_MESSAGES;
            break;
        case FileInfo_Event:
            i_id = INTF_DIALOG_FILEINFO;
            break;
        case Prefs_Event:
            i_id = INTF_DIALOG_PREFS;
            break;
gbazin's avatar
   
gbazin committed
975
976
977
        case StreamWizard_Event:
            i_id = INTF_DIALOG_STREAMWIZARD;
            break;
gbazin's avatar
gbazin committed
978
979
980
        case Bookmarks_Event:
            i_id = INTF_DIALOG_BOOKMARKS;
            break;
gbazin's avatar
   
gbazin committed
981
982
983
984
        default:
            i_id = INTF_DIALOG_FILE;
            break;
        }
gbazin's avatar
   
gbazin committed
985

gbazin's avatar
   
gbazin committed
986
        p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
gbazin's avatar
   
gbazin committed
987
    }
gbazin's avatar
   
gbazin committed
988
989
}

gbazin's avatar
gbazin committed
990
void Interface::OnExtended(wxCommandEvent& event)
zorglub's avatar
zorglub committed
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
{
    if( b_extra == VLC_FALSE)
    {
        extra_frame->Show();
        frame_sizer->Show( extra_frame );
        b_extra = VLC_TRUE;
    }
    else
    {
        extra_frame->Hide();
        frame_sizer->Hide( extra_frame );
        b_extra = VLC_FALSE;
    }
    frame_sizer->Layout();
    frame_sizer->Fit(this);
}

void Interface::OnEnableAdjust(wxCommandEvent& event)
{
    char *psz_filters=config_GetPsz( p_intf, "filter");
    char *psz_new = NULL;
    if( event.IsChecked() )
    {
        if(psz_filters == NULL)
        {
            psz_new = strdup( "adjust" );
        }
        else
        {
            psz_new= (char *) malloc(strlen(psz_filters) + 8 );
            sprintf( psz_new, "%s:adjust", psz_filters);
        }
        config_PutPsz( p_intf, "filter", psz_new );
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
        vlc_value_t val;
        vout_thread_t *p_vout =
           (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
                                       FIND_ANYWHERE );
        if( p_vout != NULL )
        {
            val.psz_string = strdup( psz_new );
            var_Set( p_vout, "filter", val);
            vlc_object_release( p_vout );
        }
        if( val.psz_string ) free( val.psz_string );
zorglub's avatar
zorglub committed
1035
1036
1037
1038
        brightness_slider->Enable();
        saturation_slider->Enable();
        contrast_slider->Enable();
        hue_slider->Enable();
1039
        gamma_slider->Enable();
zorglub's avatar
zorglub committed
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
    }
    else
    {
        if( psz_filters != NULL )
        {

            char *psz_current;
            unsigned int i=0;
            for( i = 0; i< strlen(psz_filters ); i++)
            {
                if ( !strncasecmp( &psz_filters[i],"adjust",6 ))
                {
                    if(i > 0)
                        if( psz_filters[i-1] == ':' ) i--;
                    psz_current = strchr( &psz_filters[i+1] , ':' );
                    if( !psz_current )
                        psz_filters[i] = '\0';
                    else
                    {
                       memmove( &psz_filters[i] , psz_current,
                                &psz_filters[strlen(psz_filters)]-psz_current
                                +1);
                    }
                }
            }
            config_PutPsz( p_intf, "filter", psz_filters);
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
            vlc_value_t val;
            val.psz_string = strdup( psz_filters );
            vout_thread_t *p_vout =
               (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
                                       FIND_ANYWHERE );
            if( p_vout != NULL )
            {
                var_Set( p_vout, "filter", val);
                vlc_object_release( p_vout );
            }
            if( val.psz_string ) free( val.psz_string );
zorglub's avatar
zorglub committed
1077
1078
1079
1080
1081
        }
        brightness_slider->Disable();
        saturation_slider->Disable();
        contrast_slider->Disable();
        hue_slider->Disable();
1082
        gamma_slider->Disable();
zorglub's avatar
zorglub committed
1083
1084
1085
1086
1087
1088
1089
    }
    if(psz_filters) free(psz_filters);
    if(psz_new) free(psz_new);
}

void Interface::OnHueUpdate( wxScrollEvent& event)
{
hartman's avatar
hartman committed
1090
    config_PutInt( p_intf , "hue" , event.GetPosition() );
zorglub's avatar
zorglub committed
1091
1092
1093
1094
}

void Interface::OnSaturationUpdate( wxScrollEvent& event)
{
hartman's avatar
hartman committed
1095
    config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );
zorglub's avatar
zorglub committed
1096
1097
1098
1099
}

void Interface::OnBrightnessUpdate( wxScrollEvent& event)
{
hartman's avatar
hartman committed
1100
    config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );
zorglub's avatar
zorglub committed
1101
1102
1103
1104
}

void Interface::OnContrastUpdate(wxScrollEvent& event)
{
hartman's avatar
hartman committed
1105
    config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );
zorglub's avatar
zorglub committed
1106
1107
}

1108
1109
1110
1111
1112
void Interface::OnGammaUpdate(wxScrollEvent& event)
{
    config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
}

zorglub's avatar
zorglub committed
1113
1114
void Interface::OnRatio( wxCommandEvent& event )
{
gbazin's avatar
   
gbazin committed
1115
   config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
zorglub's avatar
zorglub committed
1116
1117
}

zorglub's avatar
zorglub committed
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
void Interface::OnEnableVisual(wxCommandEvent& event)
{
    if( event.IsChecked() )
    {
        config_PutPsz( p_intf, "audio-filter", "visual" );
    }
    else
    {
        config_PutPsz( p_intf, "audio-filter", "" );
    }
}

gbazin's avatar
   
gbazin committed
1130
1131
1132
1133
1134
1135
void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
{
    wxCommandEvent dummy;
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
gbazin's avatar
   
gbazin committed
1136
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
1137

zorglub's avatar
zorglub committed
1138
    if( p_playlist->i_size && p_playlist->i_enabled )
gbazin's avatar
   
gbazin committed
1139
    {
1140
1141
        vlc_value_t state;

gbazin's avatar
   
gbazin committed
1142
1143
1144
1145
1146
1147
1148
        input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
                                                       VLC_OBJECT_INPUT,
                                                       FIND_ANYWHERE );
        if( p_input == NULL )
        {
            /* No stream was playing, start one */
            playlist_Play( p_playlist );
gbazin's avatar
   
gbazin committed
1149
            TogglePlayButton( PLAYING_S );
gbazin's avatar
   
gbazin committed
1150
1151
1152
1153
            vlc_object_release( p_playlist );
            return;
        }

1154
1155
1156
        var_Get( p_input, "state", &state );