* modules/gui/wxwindows/open.cpp: New "open dialog" that mimics the one from the...
authorGildas Bazin <gbazin@videolan.org>
Thu, 23 Jan 2003 23:57:50 +0000 (23:57 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 23 Jan 2003 23:57:50 +0000 (23:57 +0000)
* modules/gui/wxwindows/popup.cpp: Started implementing the popup menu.
* modules/gui/wxwindows/interface.cpp: Got rid of the pause button. The play button now acts as a
play/pause button depending on the context.
* modules/gui/wxwindows/*: A few hacks needed to make the win32 version useable.

modules/gui/wxwindows/Modules.am
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/open.cpp [new file with mode: 0644]
modules/gui/wxwindows/popup.cpp
modules/gui/wxwindows/timer.cpp
modules/gui/wxwindows/wxwindows.cpp
modules/gui/wxwindows/wxwindows.h

index 92def6a..e4afcef 100644 (file)
@@ -2,6 +2,7 @@ SOURCES_wxwindows = \
        modules/gui/wxwindows/wxwindows.cpp \
        modules/gui/wxwindows/wxwindows.h \
        modules/gui/wxwindows/interface.cpp \
+       modules/gui/wxwindows/open.cpp \
        modules/gui/wxwindows/messages.cpp \
        modules/gui/wxwindows/playlist.cpp \
        modules/gui/wxwindows/popup.cpp \
index 7202cd8..373f686 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.12 2002/12/21 11:20:30 sigmunau Exp $
+ * $Id: interface.cpp,v 1.13 2003/01/23 23:57:50 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -43,6 +43,7 @@
 #include <wx/wx.h>
 
 #include <vlc/intf.h>
+#include "stream_control.h"
 
 #include "wxwindows.h"
 
@@ -77,7 +78,7 @@
 enum
 {
     /* menu items */
-    Exit_Event = 1,
+    Exit_Event = wxID_HIGHEST,
     OpenFile_Event,
     OpenDisc_Event,
     OpenNet_Event,
@@ -95,7 +96,6 @@ enum
     SliderScroll_Event,
     StopStream_Event,
     PlayStream_Event,
-    PauseStream_Event,
     PrevStream_Event,
     NextStream_Event,
 
@@ -112,12 +112,14 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(Playlist_Event, Interface::OnPlaylist)
     EVT_MENU(Logs_Event, Interface::OnLogs)
     EVT_MENU(FileInfo_Event, Interface::OnFileInfo)
-    EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
+
     /* Toolbar events */
     EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
+    EVT_MENU(OpenDisc_Event, Interface::OnOpenDisc)
+    EVT_MENU(OpenNet_Event, Interface::OnOpenNet)
+    EVT_MENU(OpenSat_Event, Interface::OnOpenSat)
     EVT_MENU(StopStream_Event, Interface::OnStopStream)
     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
-    EVT_MENU(PauseStream_Event, Interface::OnPauseStream)
     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
     EVT_MENU(NextStream_Event, Interface::OnNextStream)
     /* Slider events */
@@ -128,11 +130,12 @@ END_EVENT_TABLE()
  * Constructor.
  *****************************************************************************/
 Interface::Interface( intf_thread_t *_p_intf ):
-    wxFrame( NULL, -1, "title", wxDefaultPosition, wxDefaultSize,
-             wxDEFAULT_FRAME_STYLE )
+    wxFrame( NULL, -1, VOUT_TITLE,
+             wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
     p_intf = _p_intf;
+    i_playing_status = PAUSE_S;
 
     /* Give our interface a nice little icon */
     SetIcon( *new wxIcon( vlc_xpm ) );
@@ -157,8 +160,6 @@ Interface::Interface( intf_thread_t *_p_intf ):
     statusbar = CreateStatusBar( 2 );                            /* 2 fields */
     statusbar->SetStatusWidths( 2, i_status_width );
 
-    SetTitle( COPYRIGHT_MESSAGE );
-
     /* Make sure we've got the right background colour */
     SetBackgroundColour( slider_frame->GetBackgroundColour() );
 
@@ -254,36 +255,36 @@ void Interface::CreateOurToolBar()
 #define HELP_PLP N_("Previous playlist item")
 #define HELP_PLN N_("Next playlist item")
 
-    wxBitmap *p_bmp_file     = new wxBitmap( file_xpm );
-    wxBitmap *p_bmp_disc     = new wxBitmap( disc_xpm );
-    wxBitmap *p_bmp_net      = new wxBitmap( net_xpm );
-    wxBitmap *p_bmp_play     = new wxBitmap( play_xpm );
-    wxBitmap *p_bmp_stop     = new wxBitmap( stop_xpm );
-    wxBitmap *p_bmp_pause    = new wxBitmap( pause_xpm );
-    wxBitmap *p_bmp_prev     = new wxBitmap( previous_xpm );
-    wxBitmap *p_bmp_next     = new wxBitmap( next_xpm );
-    wxBitmap *p_bmp_playlist = new wxBitmap( playlist_xpm );
+    wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
+                         * version because we don't include wx.rc */
 
     wxToolBar *toolbar = CreateToolBar(
         wxTB_HORIZONTAL | wxTB_TEXT | wxTB_FLAT | wxTB_DOCKABLE );
 
     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
 
-    toolbar->AddTool( OpenFile_Event, _("File"), *p_bmp_file, HELP_FILE );
-    toolbar->AddTool( OpenFile_Event, _("Disc"), *p_bmp_disc, HELP_DISC );
-    toolbar->AddTool( OpenFile_Event, _("Net"), *p_bmp_net, HELP_NET );
+    toolbar->AddTool( OpenFile_Event, _("File"), wxBitmap( file_xpm ),
+                      HELP_FILE );
+    toolbar->AddTool( OpenDisc_Event, _("Disc"), wxBitmap( disc_xpm ),
+                      HELP_DISC );
+    toolbar->AddTool( OpenNet_Event, _("Net"), wxBitmap( net_xpm ),
+                      HELP_NET );
 #if 0
-    toolbar->AddTool( OpenFile_Event, _("Sat"), *p_bmp_net, HELP_SAT );
+    toolbar->AddTool( OpenSat_Event, _("Sat"), wxBitmap( sat_xpm ),
+                      HELP_SAT );
 #endif
     toolbar->AddSeparator();
-    toolbar->AddTool( StopStream_Event, _("Stop"), *p_bmp_stop, HELP_STOP );
-    toolbar->AddTool( PlayStream_Event, _("Play"), *p_bmp_play, HELP_PLAY );
-    toolbar->AddTool( PauseStream_Event, _("Pause"), *p_bmp_pause, HELP_PAUSE);
+    toolbar->AddTool( StopStream_Event, _("Stop"), wxBitmap( stop_xpm ),
+                      HELP_STOP );
+    toolbar->AddTool( PlayStream_Event, _("Play"), wxBitmap( play_xpm ),
+                      HELP_PLAY );
     toolbar->AddSeparator();
-    toolbar->AddTool( Playlist_Event, _("Playlist"), *p_bmp_playlist,
+    toolbar->AddTool( Playlist_Event, _("Playlist"), wxBitmap( playlist_xpm ),
                       HELP_PLO );
-    toolbar->AddTool( PrevStream_Event, _("Prev"), *p_bmp_prev, HELP_PLP );
-    toolbar->AddTool( NextStream_Event, _("Next"), *p_bmp_next, HELP_PLN );
+    toolbar->AddTool( PrevStream_Event, _("Prev"), wxBitmap( previous_xpm ),
+                      HELP_PLP );
+    toolbar->AddTool( NextStream_Event, _("Next"), wxBitmap( next_xpm ),
+                      HELP_PLN );
 
     toolbar->Realize();
 
@@ -292,7 +293,13 @@ void Interface::CreateOurToolBar()
     wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
     toolbar_sizer->Add( toolbar, 0, 0, 0 );
     toolbar_sizer->Layout();
+
+#ifndef WIN32
     frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
+#else
+    frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
+                             toolbar->GetToolsCount(), -1 );
+#endif
 
 #if !defined(__WXX11__)
     /* Associate drop targets with the toolbar */
@@ -324,6 +331,37 @@ void Interface::CreateOurSlider()
     slider_sizer->SetSizeHints(slider_frame);
 }
 
+void Interface::Open( int i_access_method )
+{
+    /* Show/hide the open dialog */
+    OpenDialog dialog( p_intf, this, i_access_method );
+
+    if( dialog.ShowModal() == wxID_OK )
+    {
+        /* Update the playlist */
+        playlist_t *p_playlist =
+            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                           FIND_ANYWHERE );
+        if( p_playlist == NULL )
+        {
+            return;
+        }
+
+        msg_Err( p_intf, "%s", (char *)dialog.mrl.c_str() );
+
+        playlist_Add( p_playlist, (char *)dialog.mrl.c_str(),
+                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+
+        i_playing_status = PLAYING_S;
+        TogglePlayButton();
+
+        /* Rebuild the playlist */
+        p_intf->p_sys->p_playlist_window->Rebuild();
+
+        vlc_object_release( p_playlist );
+    }
+}
+
 /*****************************************************************************
  * Event Handlers.
  *****************************************************************************/
@@ -336,9 +374,15 @@ void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
 {
     wxString msg;
-    msg.Printf( _("This is the about dialog of the VideoLAN Client.\n") );
-
-    wxMessageBox( msg, _("About VideoLAN Client"),
+    msg.Printf( VOUT_TITLE + wxString(_(" (wxWindows interface)\n\n")) +
+        wxString(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
+        wxString(_("The VideoLAN team <videolan@videolan.org>\n"
+                   "http://www.videolan.org/\n\n")) +
+        wxString(_("This is the VideoLAN Client, a DVD, MPEG and DivX player."
+          "\nIt can play MPEG and MPEG2 files from a file or from a "
+          "network source.")) );
+
+    wxMessageBox( msg, wxString(_("About ")) + VOUT_TITLE,
                   wxOK | wxICON_INFORMATION, this );
 }
 
@@ -374,27 +418,22 @@ void Interface::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
 
 void Interface::OnOpenFile( wxCommandEvent& WXUNUSED(event) )
 {
-    wxFileDialog dialog( this, _("Open file"), _(""), _(""), _("*.*") );
-
-    if( dialog.ShowModal() == wxID_OK )
-    {
-        /* Update the playlist */
-        playlist_t *p_playlist =
-            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                           FIND_ANYWHERE );
-        if( p_playlist == NULL )
-        {
-            return;
-        }
+    Open( FILE_ACCESS );
+}
 
-        playlist_Add( p_playlist, (char *)dialog.GetPath().c_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+void Interface::OnOpenDisc( wxCommandEvent& WXUNUSED(event) )
+{
+    Open( DISC_ACCESS );
+}
 
-        /* Rebuild the playlist */
-        p_intf->p_sys->p_playlist_window->Rebuild();
+void Interface::OnOpenNet( wxCommandEvent& WXUNUSED(event) )
+{
+    Open( NET_ACCESS );
+}
 
-        vlc_object_release( p_playlist );
-    }
+void Interface::OnOpenSat( wxCommandEvent& WXUNUSED(event) )
+{
+    Open( SAT_ACCESS );
 }
 
 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
@@ -414,7 +453,36 @@ void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
     if( p_playlist->i_size )
     {
         vlc_mutex_unlock( &p_playlist->object_lock );
+
+        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 );
+            i_playing_status = PLAYING_S;
+            TogglePlayButton();
+            vlc_object_release( p_playlist );
+            return;
+        }
+
+        if( p_input->stream.control.i_status != PAUSE_S )
+        {
+            /* A stream is being played, pause it */
+            input_SetStatus( p_input, INPUT_STATUS_PAUSE );
+            i_playing_status = PAUSE_S;
+            TogglePlayButton();
+            vlc_object_release( p_playlist );
+            vlc_object_release( p_input );
+            return;
+        }
+
+        /* Stream is paused, resume it */
         playlist_Play( p_playlist );
+        i_playing_status = PLAYING_S;
+        TogglePlayButton();
+        vlc_object_release( p_input );
         vlc_object_release( p_playlist );
     }
     else
@@ -436,19 +504,11 @@ void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
     }
 
     playlist_Stop( p_playlist );
+    i_playing_status = PAUSE_S;
+    TogglePlayButton();
     vlc_object_release( p_playlist );
 }
 
-void Interface::OnPauseStream( wxCommandEvent& WXUNUSED(event) )
-{
-    if( p_intf->p_sys->p_input == NULL )
-    {
-        return;
-    }
-
-    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
-}
-
 void Interface::OnSliderUpdate( wxScrollEvent& event )
 {
     p_intf->p_sys->i_slider_pos = event.GetPosition();
@@ -482,6 +542,24 @@ void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
     vlc_object_release( p_playlist );
 }
 
+void Interface::TogglePlayButton( )
+{
+    GetToolBar()->DeleteTool( PlayStream_Event );
+
+    if( i_playing_status == PLAYING_S )
+    {
+        GetToolBar()->InsertTool( 5, PlayStream_Event, _("Pause"),
+                                  wxBitmap( pause_xpm ) );
+    }
+    else
+    {
+        GetToolBar()->InsertTool( 5, PlayStream_Event, _("Play"),
+                                  wxBitmap( play_xpm ) );
+    }
+
+    GetToolBar()->Realize();
+}
+
 #if !defined(__WXX11__)
 /*****************************************************************************
  * Definition of DragAndDrop class.
diff --git a/modules/gui/wxwindows/open.cpp b/modules/gui/wxwindows/open.cpp
new file mode 100644 (file)
index 0000000..cf72e3b
--- /dev/null
@@ -0,0 +1,558 @@
+/*****************************************************************************
+ * open.cpp : wxWindows plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000-2001 VideoLAN
+ * $Id: open.cpp,v 1.1 2003/01/23 23:57:50 gbazin Exp $
+ *
+ * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ *
+ * 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.
+ *
+ * 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
+ *****************************************************************************/
+#include <stdlib.h>                                      /* malloc(), free() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <string.h>                                            /* strerror() */
+#include <stdio.h>
+
+#include <vlc/vlc.h>
+
+#ifdef WIN32                                                 /* mingw32 hack */
+#undef Yield
+#undef CreateDialog
+#endif
+
+/* Let vlc take care of the i18n stuff */
+#define WXINTL_NO_GETTEXT_MACRO
+
+#include <wx/wxprec.h>
+#include <wx/wx.h>
+#include <wx/notebook.h>
+#include <wx/textctrl.h>
+#include <wx/combobox.h>
+#include <wx/spinctrl.h>
+
+#include <vlc/intf.h>
+
+#include "wxwindows.h"
+
+/*****************************************************************************
+ * Event Table.
+ *****************************************************************************/
+
+/* IDs for the controls and the menu commands */
+enum
+{
+    Notebook_Event = wxID_HIGHEST,
+    MRL_Event,
+
+    FileBrowse_Event,
+    FileName_Event,
+
+    DiscType_Event,
+    DiscDevice_Event,
+    DiscTitle_Event,
+    DiscChapter_Event,
+
+    NetType_Event,
+    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
+    NetPort1_Event, NetPort2_Event, NetPort3_Event, NetPort4_Event,
+    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
+};
+
+BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
+    /* Button events */
+    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
+    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
+    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
+
+    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
+
+    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
+
+    /* Events generated by the file panel */
+    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
+
+    /* Events generated by the disc panel */
+    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
+    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
+    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
+    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
+    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
+    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
+
+    /* Events generated by the net panel */
+    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
+    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
+    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
+    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
+    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
+    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
+    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
+    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
+
+END_EVENT_TABLE()
+
+/*****************************************************************************
+ * Constructor.
+ *****************************************************************************/
+OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
+                        int i_access_method ):
+    wxDialog( _p_main_interface, -1, _("Open Target"), wxDefaultPosition,
+             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
+{
+    /* Initializations */
+    p_intf = _p_intf;
+    p_main_interface = _p_main_interface;
+
+    /* Create a panel to put everything in */
+    wxPanel *panel = new wxPanel( this, -1 );
+    panel->SetAutoLayout( TRUE );
+
+    /* Create MRL combobox */
+    wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
+    wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
+                               _("Media Resource Locator (MRL)") );
+    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
+                                                        wxHORIZONTAL );
+    wxStaticText *mrl_label = new wxStaticText( panel, -1,
+                                                _("Open Target:") );
+    mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
+                                wxPoint(20,25), wxSize(120, -1),
+                                0, NULL );
+    mrl_sizer->Add( mrl_label, 0, wxEXPAND | wxALL, 5 );
+    mrl_sizer->Add( mrl_combo, 1, wxEXPAND | wxALL, 5 );
+    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
+
+
+    /* Create Static Text */
+    wxStaticText *label = new wxStaticText( panel, -1,
+        _("Alternatively, you can build an MRL using one of the "
+          "following predefined targets:") );
+
+    /* Create notebook */
+    wxNotebook *notebook = new wxNotebook( panel, Notebook_Event,
+                                           wxDefaultPosition,
+                                           wxSize( 300, 250 ) );
+    notebook->AddPage( FilePanel( notebook ), _("File"),
+                       i_access_method == FILE_ACCESS );
+    notebook->AddPage( DiscPanel( notebook ), _("Disc"),
+                       i_access_method == DISC_ACCESS );
+    notebook->AddPage( NetPanel( notebook ), _("Network"),
+                       i_access_method == NET_ACCESS );
+    notebook->AddPage( SatPanel( notebook ), _("Satellite"),
+                       i_access_method == SAT_ACCESS );
+
+    /* Create the buttons */
+    wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
+    ok_button->SetDefault();
+    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, _("Cancel") );
+
+
+    /* Update MRL */
+    wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
+    OnPageChange( event );
+
+    /* Place everything in sizers */
+    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
+    button_sizer->Add( ok_button, 0, wxALL, 5 );
+    button_sizer->Add( cancel_button, 0, wxALL, 5 );
+    button_sizer->Layout();
+    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
+    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
+    panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
+    panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
+    panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
+    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT );
+    panel_sizer->Layout();
+    panel->SetSizerAndFit( panel_sizer );
+    main_sizer->Add( panel, 1, wxGROW, 0 );
+    main_sizer->Layout();
+    SetSizerAndFit( main_sizer );
+}
+
+OpenDialog::~OpenDialog()
+{
+}
+
+/*****************************************************************************
+ * Private methods.
+ *****************************************************************************/
+wxPanel *OpenDialog::FilePanel( wxWindow* parent )
+{
+    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+                                  wxSize(200, 200) );
+
+    wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+
+    file_combo = new wxComboBox( panel, FileName_Event, "",
+                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
+    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
+                                            _("Browse...") );
+    sizer->Add( file_combo, 1, wxALL, 5 );
+    sizer->Add( browse_button, 0, wxALL, 5 );
+
+    panel->SetSizerAndFit( sizer );
+
+    return panel;
+}
+
+wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
+{
+    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+                                  wxSize(200, 200) );
+
+    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
+    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
+
+    static const wxString disc_type_array[] =
+    {
+        _("DVD"),
+        _("DVD (menus support)"),
+        _("VCD")
+    };
+
+    disc_type = new wxRadioBox( panel, DiscType_Event, _("Disc type"),
+                                wxDefaultPosition, wxDefaultSize,
+                                WXSIZEOF(disc_type_array), disc_type_array,
+                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
+    sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
+
+    wxStaticText *label = new wxStaticText( panel, -1, _("Device Name") );
+    char *psz_device = config_GetPsz( p_intf, "dvd" );
+    disc_device = new wxTextCtrl( panel, DiscDevice_Event,
+                                  psz_device ? psz_device : "",
+                                  wxDefaultPosition, wxDefaultSize,
+                                  wxTE_PROCESS_ENTER);
+    if( psz_device ) free( psz_device );
+
+    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    int val = 1;
+    label = new wxStaticText( panel, -1, _("Title") );
+    disc_title = new wxSpinCtrl( panel, DiscTitle_Event,
+                                 wxString::Format(_("%d"), val),
+                                 wxDefaultPosition, wxDefaultSize,
+                                 wxSP_ARROW_KEYS,
+                                 1, 255, val);
+
+    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    label = new wxStaticText( panel, -1, _("Chapter") );
+    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event,
+                                   wxString::Format(_("%d"), val),
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxSP_ARROW_KEYS,
+                                   1, 255, val);
+    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
+
+    panel->SetSizerAndFit( sizer_row );
+
+    return panel;
+}
+
+wxPanel *OpenDialog::NetPanel( wxWindow* parent )
+{
+    int i;
+    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+                                  wxSize(200, 200) );
+
+    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
+    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
+
+    static const wxString net_type_array[] =
+    {
+        _("UDP/RTP"),
+        _("UDP/RTP Multicast"),
+        _("Channel server"),
+        _("HTTP/FTP/MMS")
+    };
+
+    for( i=0; i<4; i++ )
+    {
+        net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
+                                           net_type_array[i],
+                                           wxDefaultPosition, wxDefaultSize,
+                                           wxRB_SINGLE );
+
+        net_subpanels[i] = new wxPanel( panel, -1,
+                                        wxDefaultPosition, wxDefaultSize );
+    }
+
+    /* UDP/RTP row */
+    wxFlexGridSizer *subpanel_sizer;
+    wxStaticText *label;
+    int val = config_GetInt( p_intf, "server-port" );
+    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
+    label = new wxStaticText( net_subpanels[0], -1, _("Port") );
+    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
+                                   wxString::Format(_("%d"), val),
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxSP_ARROW_KEYS,
+                                   0, 16000, val);
+
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_ports[0], 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
+
+    /* UDP/RTP Multicast row */
+    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
+    label = new wxStaticText( net_subpanels[1], -1, _("Address") );
+    net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, "",
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_addrs[1], 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    label = new wxStaticText( net_subpanels[1], -1, _("Port") );
+    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
+                                   wxString::Format(_("%d"), val),
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxSP_ARROW_KEYS,
+                                   0, 16000, val);
+
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_ports[1], 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
+
+    /* Channel server row */
+    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
+    label = new wxStaticText( net_subpanels[2], -1, _("Address") );
+    net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, "",
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_addrs[2], 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    label = new wxStaticText( net_subpanels[2], -1, _("Port") );
+    net_ports[2] = new wxSpinCtrl( net_subpanels[2], NetPort3_Event,
+                                   wxString::Format(_("%d"), val),
+                                   wxDefaultPosition, wxDefaultSize,
+                                   wxSP_ARROW_KEYS,
+                                   0, 16000, val);
+
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_ports[2], 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
+
+    /* HTTP row */
+    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
+    label = new wxStaticText( net_subpanels[3], -1, _("URL") );
+    net_addrs[3] = new wxTextCtrl( net_subpanels[3], NetAddr4_Event, "http://",
+                                   wxDefaultPosition, wxSize( 200, -1 ),
+                                   wxTE_PROCESS_ENTER);
+    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( net_addrs[3], 1,
+                         wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    net_subpanels[3]->SetSizerAndFit( subpanel_sizer );
+
+    /* Stuff everything into the main panel */
+    for( i=0; i<4; i++ )
+    {
+        sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+        sizer->Add( net_subpanels[i], 1,
+                    wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    }
+
+    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
+
+    panel->SetSizerAndFit( sizer_row );
+
+    /* Update Net panel */
+    wxCommandEvent dummy_event;
+    dummy_event.SetId( NetRadio1_Event );
+    OnNetTypeChange( dummy_event );
+
+    return panel;
+}
+
+wxPanel *OpenDialog::SatPanel( wxWindow* parent )
+{
+    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+                                  wxSize(200, 200) );
+    return panel;
+}
+
+void OpenDialog::UpdateMRL( int i_access_method )
+{
+    switch( i_access_method )
+    {
+    case FILE_ACCESS:
+        mrl = "file://" + file_combo->GetValue();
+        break;
+    case DISC_ACCESS:
+        mrl = ( disc_type->GetSelection() == 0 ? "dvdold://" :
+                disc_type->GetSelection() == 1 ? "dvd://" : "vcd://" )
+                  + disc_device->GetLineText(0)
+                  + wxString::Format( "@%d:%d",
+                                      disc_title->GetValue(),
+                                      disc_chapter->GetValue() );
+        break;
+    case NET_ACCESS:
+        switch( i_net_type )
+        {
+        case 0:
+            if( net_ports[0]->GetValue() !=
+                config_GetInt( p_intf, "server-port" ) )
+            {
+                mrl = wxString::Format( "udp://@:%d",
+                                        net_ports[0]->GetValue() );
+            }
+            else
+            {
+                mrl = "udp://";
+            }
+            break;
+
+        case 1:
+            mrl = "udp://@" + net_addrs[1]->GetLineText(0);
+            if( net_ports[1]->GetValue() !=
+                config_GetInt( p_intf, "server-port" ) )
+            {
+                mrl = mrl + wxString::Format( ":%d",
+                                              net_ports[1]->GetValue() );
+            }
+            break;
+
+        case 2:
+            mrl = "udp://";
+            break;
+
+        case 3:
+            /* http access */     
+            mrl = net_addrs[3]->GetLineText(0);
+            break;
+        }
+        break;
+
+    case SAT_ACCESS:
+        mrl = "satellite://";
+        break;
+    default:
+        break;
+    }
+
+    mrl_combo->SetValue( mrl );
+}
+
+/*****************************************************************************
+ * Events methods.
+ *****************************************************************************/
+void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
+{
+    EndModal( wxID_OK );
+}
+
+void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
+{
+    EndModal( wxID_CANCEL );
+}
+
+void OpenDialog::OnPageChange( wxNotebookEvent& event )
+{
+    UpdateMRL( event.GetSelection() );
+}
+
+void OpenDialog::OnMRLChange( wxCommandEvent& event )
+{
+    mrl = event.GetString();
+}
+
+/*****************************************************************************
+ * File panel event methods.
+ *****************************************************************************/
+void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdateMRL( FILE_ACCESS );
+}
+
+void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
+{
+    wxFileDialog dialog( this, _("Open file"), _(""), _(""), _("*.*"),
+                         wxOPEN );
+
+    if( dialog.ShowModal() == wxID_OK )
+    {
+        file_combo->SetValue( dialog.GetPath() );      
+        UpdateMRL( FILE_ACCESS );
+    }
+}
+
+/*****************************************************************************
+ * Disc panel event methods.
+ *****************************************************************************/
+void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdateMRL( DISC_ACCESS );
+}
+
+void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
+{
+    char *psz_device;
+
+    switch( disc_type->GetSelection() )
+    {
+    case 3:
+        psz_device = config_GetPsz( p_intf, "vcd" );
+        disc_device->SetValue( psz_device ? psz_device : "" );
+        break;
+
+    case 2:
+    default:
+        psz_device = config_GetPsz( p_intf, "dvd" );
+        disc_device->SetValue( psz_device ? psz_device : "" );
+        break;
+    }
+
+    if( psz_device ) free( psz_device );
+}
+
+/*****************************************************************************
+ * Net panel event methods.
+ *****************************************************************************/
+void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdateMRL( NET_ACCESS );
+}
+
+void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
+{
+    int i;
+
+    i_net_type = event.GetId() - NetRadio1_Event;
+
+    for(i=0; i<4; i++)
+    {
+        net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
+    }
+
+    UpdateMRL( NET_ACCESS );
+}
index 32fcb07..40a93c5 100644 (file)
@@ -2,7 +2,7 @@
  * popup.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: popup.cpp,v 1.1 2002/12/13 01:50:32 gbazin Exp $
+ * $Id: popup.cpp,v 1.2 2003/01/23 23:57:50 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 enum
 {
     /* menu items */
-    Close_Event = 1,
-    MenuEntry_Event,
-    MenuDummy_Event
+    Close_Event = wxID_HIGHEST,
+    MenuDummy_Event,
 };
 
 BEGIN_EVENT_TABLE(PopupMenu, wxMenu)
     /* Menu events */
     EVT_MENU(Close_Event, PopupMenu::OnClose)
-    EVT_MENU(MenuEntry_Event, PopupMenu::OnEntrySelected)
+    EVT_MENU(MenuDummy_Event, PopupMenu::OnEntrySelected)
 
 END_EVENT_TABLE()
 
+BEGIN_EVENT_TABLE(PopupEvtHandler, wxEvtHandler)
+    EVT_MENU(-1, PopupEvtHandler::OnMenuEvent)
+END_EVENT_TABLE()
+
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
 PopupMenu::PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ):
-    wxMenu( "VideoLan" )
+    wxMenu( )
 {
+    vlc_object_t *p_object;
+
     /* Initializations */
     p_intf = _p_intf;
     p_main_interface = _p_main_interface;
+    i_item_id = 0;
+
+    /* Audio menu */
+    Append( MenuDummy_Event, _("Audio menu") );
+    AppendSeparator();
+    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+                                                FIND_ANYWHERE );
+    if( p_object == NULL ) return;
+
+    CreateMenuEntry( "audio-device", p_object );
+    CreateMenuEntry( "audio-channels", p_object );
+
+    vlc_object_release( p_object );
+
+    /* Video menu */
+    AppendSeparator();
+    Append( MenuDummy_Event, _("Video menu") );
+    AppendSeparator();
+    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                                FIND_ANYWHERE );
+    if( p_object == NULL ) return;
+
+    CreateMenuEntry( "fullscreen", p_object );
+
+    vlc_object_release( p_object );
 
-    Append(MenuEntry_Event, "Dummy1");
-    Append(MenuEntry_Event, "Dummy2");
-    Append(MenuDummy_Event, "&Dummy sub menu",
-           CreateDummyMenu(), "Dummy sub menu help");
-    Append(MenuEntry_Event, "Dummy3", "", TRUE);
+    /* Input menu */
+    AppendSeparator();
+    Append( MenuDummy_Event, _("Input menu") );
+    AppendSeparator();
+    p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                                FIND_ANYWHERE );
+    if( p_object == NULL ) return;
+
+    CreateMenuEntry( "title", p_object );
+    CreateMenuEntry( "chapter", p_object );
+
+    vlc_object_release( p_object );
+
+    /* Misc stuff */
     AppendSeparator();
     Append( Close_Event, _("&Close") );
 
+    /* Intercept all menu events in our custom event handler */
+    p_main_interface->p_popup_menu = this;
+    p_main_interface->PushEventHandler(
+        new PopupEvtHandler( p_intf, p_main_interface ) );
+
     wxPoint mousepos = wxGetMousePosition();
-    p_main_interface->PopupMenu( this, mousepos.x, mousepos.y );
+    p_main_interface->PopupMenu( this,
+                                 p_main_interface->ScreenToClient(mousepos).x,
+                                 p_main_interface->ScreenToClient(mousepos).y
+                                 );
 }
 
 PopupMenu::~PopupMenu()
@@ -105,12 +152,163 @@ void PopupMenu::OnEntrySelected( wxCommandEvent& WXUNUSED(event) )
 {
 }
 
-wxMenu *PopupMenu::CreateDummyMenu()
+void PopupMenu::CreateMenuEntry( char *psz_var, vlc_object_t *p_object )
+{
+    vlc_value_t val, val1;
+    int i_type;
+
+    /* Check the type of the object variable */
+    i_type = var_Type( p_object, psz_var );
+
+    if( i_type & VLC_VAR_HASCHOICE )
+    {
+        Append( MenuDummy_Event, psz_var,
+                CreateSubMenu( psz_var, p_object ),
+                "YEAAAARRRGGGHHH HEEELLPPPPPP" );
+        return;
+    }
+
+    if( var_Get( p_object, psz_var, &val ) < 0 )
+    {
+        return;
+    }
+
+    wxMenuItemExt *menuitem;
+
+    switch( i_type )
+    {
+    case VLC_VAR_VOID:
+        menuitem = new wxMenuItemExt( this, i_item_id++, psz_var,
+                                      "", wxITEM_NORMAL, strdup(psz_var),
+                                      p_object->i_object_id, val );
+        Append( menuitem );
+        break;
+
+    case VLC_VAR_BOOL:
+        val1.b_bool = !val.b_bool;
+        menuitem = new wxMenuItemExt( this, i_item_id++, psz_var,
+                                      "", wxITEM_CHECK, strdup(psz_var),
+                                      p_object->i_object_id, val1 );
+        Append( menuitem );
+        Check( i_item_id - 1, val.b_bool ? TRUE : FALSE );
+        break;
+
+    case VLC_VAR_STRING:
+        break;
+
+    default:
+        break;
+    }
+
+}
+
+wxMenu *PopupMenu::CreateSubMenu( char *psz_var, vlc_object_t *p_object )
 {
     wxMenu *menu = new wxMenu;
-    menu->Append(MenuEntry_Event, "Sub Dummy1");
-    menu->AppendSeparator();
-    menu->Append(MenuEntry_Event, "Sub Dummy2", "", TRUE);
+    vlc_value_t val;
+    char *psz_value;
+    int i_type, i;
+
+    /* Check the type of the object variable */
+    i_type = var_Type( p_object, psz_var );
+
+    switch( i_type )
+    {
+    case VLC_VAR_VOID:
+    case VLC_VAR_STRING:
+        break;
+
+    default:
+        break;
+    }
+
+    if( var_Get( p_object, psz_var, &val ) < 0 )
+    {
+        return NULL;
+    }
+    psz_value = val.psz_string;
+
+    if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val ) < 0 )
+    {
+        return NULL;
+    }
+
+    for( i = 0; i < val.p_list->i_count; i++ )
+    {
+        vlc_value_t another_val;
+        wxMenuItemExt *menuitem;
+
+        switch( i_type & VLC_VAR_TYPE )
+        {
+        case VLC_VAR_STRING:
+          another_val.psz_string =
+              strdup(val.p_list->p_values[i].psz_string);
+          menuitem =
+              new wxMenuItemExt( this, i_item_id++, another_val.psz_string,
+                                 "", wxITEM_RADIO, strdup(psz_var),
+                                 p_object->i_object_id,
+                                 another_val );
+
+          menu->Append( menuitem );
+
+          if( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) )
+              menu->Check( i_item_id - 1, TRUE );
+          break;
+
+        case VLC_VAR_INTEGER:
+          menuitem =
+              new wxMenuItemExt( this, i_item_id++,
+                                 wxString::Format(_("%d"),
+                                 val.p_list->p_values[i].i_int),
+                                 "", wxITEM_RADIO, strdup(psz_var),
+                                 p_object->i_object_id,
+                                 val.p_list->p_values[i] );
+
+          menu->Append( menuitem );
+          break;
+
+        default:
+          break;
+        }
+    }
+
+    var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val );
 
     return menu;
 }
+
+/*****************************************************************************
+ * A small helper class which intercepts all popup menu events
+ *****************************************************************************/
+PopupEvtHandler::PopupEvtHandler( intf_thread_t *_p_intf,
+                                  Interface *_p_main_interface )
+{
+    /* Initializations */
+    p_intf = _p_intf;
+    p_main_interface = _p_main_interface;
+}
+
+PopupEvtHandler::~PopupEvtHandler()
+{
+}
+
+void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event )
+{
+    wxMenuItemExt *p_menuitem = (wxMenuItemExt *)
+        p_main_interface->p_popup_menu->FindItem( event.GetId() );
+
+    if( p_menuitem )
+    {
+        vlc_object_t *p_object;
+
+        p_object = (vlc_object_t *)vlc_object_get( p_intf,
+                                                   p_menuitem->i_object_id );
+        if( p_object == NULL ) return;
+
+        var_Set( p_object, p_menuitem->psz_var, p_menuitem->val );
+
+        vlc_object_release( p_object );
+    }
+    else
+        event.Skip();
+}
index ae3f433..896865f 100644 (file)
@@ -2,7 +2,7 @@
  * timer.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: timer.cpp,v 1.7 2002/12/15 18:37:39 ipkiss Exp $
+ * $Id: timer.cpp,v 1.8 2003/01/23 23:57:50 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -104,7 +104,8 @@ void Timer::Notify()
     /* If the "display popup" flag has changed */
     if( p_intf->b_menu_change )
     {
-        new PopupMenu( p_intf, p_main_interface );
+        p_main_interface->p_popup_menu =
+            new PopupMenu( p_intf, p_main_interface );
         p_intf->b_menu_change = 0;
     }
 
index 950d8e9..25dd6ee 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: wxwindows.cpp,v 1.9 2002/12/15 18:37:39 ipkiss Exp $
+ * $Id: wxwindows.cpp,v 1.10 2003/01/23 23:57:50 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -144,6 +144,16 @@ static void Close( vlc_object_t *p_this )
 /*****************************************************************************
  * Run: wxWindows thread
  *****************************************************************************/
+#if defined( WIN32 )
+HINSTANCE hInstance = 0;
+extern "C" BOOL WINAPI
+DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
+{
+    hInstance = (HINSTANCE)hModule;
+    return TRUE;
+}
+#endif
+
 static void Run( intf_thread_t *p_intf )
 {
 #if !defined( WIN32 )
@@ -154,7 +164,7 @@ static void Run( intf_thread_t *p_intf )
     wxTheApp = new Instance( p_intf );
 
 #if defined( WIN32 )
-    wxEntry( GetModuleHandle(NULL), NULL, NULL, SW_SHOW, TRUE );
+    wxEntry( hInstance/*GetModuleHandle(NULL)*/, NULL, NULL, SW_SHOW, TRUE );
 #else
     wxEntry( 1, p_args );
 #endif
index b1d9540..eaee9c0 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.7 2002/12/21 11:20:30 sigmunau Exp $
+ * $Id: wxwindows.h,v 1.8 2003/01/23 23:57:50 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -23,6 +23,8 @@
 
 #include <wx/listctrl.h>
 #include <wx/textctrl.h>
+#include <wx/notebook.h>
+#include <wx/spinctrl.h>
 #include <wx/dnd.h>
 
 class Playlist;
@@ -116,10 +118,15 @@ public:
     wxWindow    *slider_frame;
     wxStaticBox *slider_box;
 
+    wxMenu      *p_popup_menu;
+
+    wxArrayString mrl_history;
+
 private:
     void CreateOurMenuBar();
     void CreateOurToolBar();
     void CreateOurSlider();
+    void Open( int i_access_method );
 
     /* Event handlers (these functions should _not_ be virtual) */
     void OnExit( wxCommandEvent& event );
@@ -128,18 +135,98 @@ private:
     void OnPlaylist( wxCommandEvent& event );
     void OnLogs( wxCommandEvent& event );
     void OnFileInfo( wxCommandEvent& event );
+
     void OnOpenFile( wxCommandEvent& event );
+    void OnOpenDisc( wxCommandEvent& event );
+    void OnOpenNet( wxCommandEvent& event );
+    void OnOpenSat( wxCommandEvent& event );
+
     void OnPlayStream( wxCommandEvent& event );
     void OnStopStream( wxCommandEvent& event );
-    void OnPauseStream( wxCommandEvent& event );
     void OnSliderUpdate( wxScrollEvent& event );
     void OnPrevStream( wxCommandEvent& event );
     void OnNextStream( wxCommandEvent& event );
 
+    void TogglePlayButton();
+
     DECLARE_EVENT_TABLE();
 
     Timer *timer;
     intf_thread_t *p_intf;
+    int i_playing_status;
+};
+
+/* Open Dialog */
+class OpenDialog: public wxDialog
+{
+public:
+    /* Constructor */
+    OpenDialog( intf_thread_t *p_intf, Interface *p_main_interface,
+                int i_access_method );
+    virtual ~OpenDialog();
+    void Rebuild();
+    void Manage();
+
+    wxString mrl;
+
+private:
+    wxPanel *FilePanel( wxWindow* parent );
+    wxPanel *DiscPanel( wxWindow* parent );
+    wxPanel *NetPanel( wxWindow* parent );
+    wxPanel *SatPanel( wxWindow* parent );
+
+    void OpenDialog::UpdateMRL( int i_access_method );
+
+    /* Event handlers (these functions should _not_ be virtual) */
+    void OnOk( wxCommandEvent& event );
+    void OnCancel( wxCommandEvent& event );
+
+    void OnPageChange( wxNotebookEvent& event );
+    void OnMRLChange( wxCommandEvent& event );
+
+    /* Event handlers for the disc page */
+    void OnFilePanelChange( wxCommandEvent& event );
+    void OnFileBrowse( wxCommandEvent& event );
+
+    /* Event handlers for the disc page */
+    void OnDiscPanelChange( wxCommandEvent& event );
+    void OnDiscTypeChange( wxCommandEvent& event );
+
+    /* Event handlers for the net page */
+    void OnNetPanelChange( wxCommandEvent& event );
+    void OnNetTypeChange( wxCommandEvent& event );
+
+    DECLARE_EVENT_TABLE();
+
+    intf_thread_t *p_intf;
+    Interface *p_main_interface;
+
+    wxComboBox *mrl_combo;
+
+    /* Controls for the file panel */
+    wxComboBox *file_combo;
+
+    /* Controls for the disc panel */
+    wxRadioBox *disc_type;
+    wxTextCtrl *disc_device;
+    wxSpinCtrl *disc_title;
+    wxSpinCtrl *disc_chapter;
+
+    /* Controls for the net panel */
+    wxRadioBox *net_type;
+    int i_net_type;
+    wxPanel *net_subpanels[4];
+    wxRadioButton *net_radios[4];
+    wxSpinCtrl *net_ports[4];
+    wxTextCtrl *net_addrs[4];
+};
+
+enum
+{
+    FILE_ACCESS = 0,
+    DISC_ACCESS,
+    NET_ACCESS,
+    SAT_ACCESS
 };
 
 /* Messages */
@@ -241,9 +328,56 @@ private:
     void OnEntrySelected( wxCommandEvent& event );
 
     wxMenu *PopupMenu::CreateDummyMenu();
+    void   PopupMenu::CreateMenuEntry( char *, vlc_object_t * );
+    wxMenu *PopupMenu::CreateSubMenu( char *, vlc_object_t * );
 
     DECLARE_EVENT_TABLE();
 
     intf_thread_t *p_intf;
     Interface *p_main_interface;
+
+    int  i_item_id;
+};
+
+class PopupEvtHandler : public wxEvtHandler
+{
+public:
+    PopupEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
+    virtual ~PopupEvtHandler();
+
+    void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event );
+
+private:
+
+    DECLARE_EVENT_TABLE()
+
+    intf_thread_t *p_intf;
+    Interface *p_main_interface;
+};
+
+class wxMenuItemExt: public wxMenuItem
+{
+public:
+    /* Constructor */
+    wxMenuItemExt( wxMenu* parentMenu, int id,
+                   const wxString& text,
+                   const wxString& helpString,
+                   wxItemKind kind,
+                   char *_psz_var, int _i_object_id, vlc_value_t _val ):
+        wxMenuItem( parentMenu, id, text, helpString, kind )
+    {
+        /* Initializations */
+        psz_var = _psz_var;
+        i_object_id = _i_object_id;
+        val = _val;
+    };
+
+    virtual ~wxMenuItemExt() { if( psz_var ) free( psz_var ); };
+
+    char *psz_var;
+    int  i_object_id;
+    vlc_value_t val;
+
+private:
+
 };