]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/interface.cpp
corrected a newbie notation
[vlc] / modules / gui / wxwindows / interface.cpp
index cad7e9365c5f853fe431eeb99053405c0364109c..3badf8d109c1a48384f193a5923904cdb462c641 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.35 2003/05/26 19:06:47 gbazin Exp $
+ * $Id: interface.cpp,v 1.43 2003/07/01 13:12:19 sam Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -30,6 +30,7 @@
 #include <stdio.h>
 
 #include <vlc/vlc.h>
+#include <vlc/aout.h>
 
 #ifdef WIN32                                                 /* mingw32 hack */
 #undef Yield
@@ -67,7 +68,7 @@
 #define TOOLBAR_BMP_HEIGHT 36
 
 /* include the icon graphic */
-#include "share/vlc32x32.xpm"
+#include "../../../share/vlc32x32.xpm"
 
 /*****************************************************************************
  * Local class declarations.
@@ -92,6 +93,28 @@ private:
 
 };
 
+class wxVolCtrl: public wxGauge
+{
+public:
+    /* Constructor */
+    wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
+    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)
+END_EVENT_TABLE()
+
 /*****************************************************************************
  * Event Table.
  *****************************************************************************/
@@ -139,10 +162,9 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU_OPEN(Interface::OnMenuOpen)
 
 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
-    EVT_CONTEXT_MENU(Interface::OnContextMenu)
-#else
-    EVT_RIGHT_UP(Interface::OnContextMenu)
+    EVT_CONTEXT_MENU(Interface::OnContextMenu2)
 #endif
+    EVT_RIGHT_UP(Interface::OnContextMenu)
 
     /* Toolbar events */
     EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
@@ -172,8 +194,6 @@ Interface::Interface( intf_thread_t *_p_intf ):
     p_prefs_dialog = NULL;
     i_old_playing_status = PAUSE_S;
     p_open_dialog = NULL;
-    p_popup_menu = NULL;
-    b_popup_change = VLC_FALSE;
 
     /* Give our interface a nice little icon */
     p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
@@ -222,6 +242,7 @@ Interface::~Interface()
     /* Clean up */
     if( p_open_dialog ) delete p_open_dialog;
     if( p_prefs_dialog ) p_prefs_dialog->Destroy();
+    if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
 }
 
 /*****************************************************************************
@@ -384,9 +405,11 @@ void Interface::CreateOurToolBar()
 
 void Interface::CreateOurSlider()
 {
-    /* Create a new frame containing the slider */
+    /* Create a new frame and sizer containing the slider */
     slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
     slider_frame->SetAutoLayout( TRUE );
+    wxBoxSizer *frame_sizer =
+        new wxBoxSizer( wxHORIZONTAL );
 
     /* Create static box to surround the slider */
     slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
@@ -394,15 +417,22 @@ void Interface::CreateOurSlider()
     /* Create sizer for slider frame */
     wxStaticBoxSizer *slider_sizer =
         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
-    slider_frame->SetSizer( slider_sizer );
     slider_sizer->SetMinSize( -1, 50 );
 
     /* Create slider */
     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
-    slider_sizer->Add( slider, 1, wxGROW | wxALL, 5 );
-    slider_sizer->Layout();
-    slider_sizer->SetSizeHints(slider_frame);
+    slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
+
+
+    volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
+
+    /* Add everything to the frame */
+    frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
+    frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
+    slider_frame->SetSizer( frame_sizer );
+    frame_sizer->Layout();
+    frame_sizer->SetSizeHints(slider_frame);
 
     /* Hide the slider by default */
     slider_frame->Hide();
@@ -539,16 +569,15 @@ void Interface::OnMenuOpen(wxMenuEvent& event)
 }
 
 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
-void Interface::OnContextMenu(wxContextMenuEvent& event)
+void Interface::OnContextMenu2(wxContextMenuEvent& event)
 {
     ::PopupMenu( p_intf, this, ScreenToClient(event.GetPosition()) );
 }
-#else
+#endif
 void Interface::OnContextMenu(wxMouseEvent& event)
 {
     ::PopupMenu( p_intf, this, event.GetPosition() );
 }
-#endif
 
 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
 {
@@ -559,7 +588,7 @@ void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
 {
     wxString msg;
-    msg.Printf( wxString(wxT("VLC media player")) +
+    msg.Printf( wxString(wxT("VLC media player " VERSION)) +
         wxU(_(" (wxWindows interface)\n\n")) +
         wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
@@ -811,12 +840,14 @@ void Interface::TogglePlayButton( int i_playing_status )
     if( i_playing_status == PLAYING_S )
     {
         GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")),
-                                  wxBitmap( pause_xpm ) );
+                                  wxBitmap( pause_xpm ), wxNullBitmap,
+                                  wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
     }
     else
     {
         GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")),
-                                  wxBitmap( play_xpm ) );
+                                  wxBitmap( play_xpm ), wxNullBitmap,
+                                  wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
     }
 
     GetToolBar()->Realize();
@@ -855,3 +886,27 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
     return TRUE;
 }
 #endif
+
+/*****************************************************************************
+ * Definition of wxVolCtrl class.
+ *****************************************************************************/
+wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
+  : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
+             wxGA_VERTICAL | wxGA_SMOOTH )
+{
+    p_intf = _p_intf;
+}
+
+void wxVolCtrl::OnChange( wxMouseEvent& event )
+{
+    int i_volume = (GetRect().height - event.GetY()) * 200 / GetRect().height;
+    Change( i_volume );
+}
+
+void wxVolCtrl::Change( int i_volume )
+{
+    aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
+    SetValue( i_volume );
+    SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
+                i_volume ) );
+}