]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/subtitles.cpp
* modules/gui/wxwindows/wxwindows.cpp: don't "play on start" when in dialogs provider...
[vlc] / modules / gui / wxwindows / subtitles.cpp
index e8584526d72d7823fe40b70cefa8e0789a1c2e31..e9c0a1c3e3687879ea8ad9c63b5badda9985137a 100644 (file)
@@ -2,7 +2,7 @@
  * subtitles.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: subtitles.cpp,v 1.1 2003/05/13 22:59:16 gbazin Exp $
+ * $Id: subtitles.cpp,v 1.11 2004/02/14 12:36:16 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 #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/textctrl.h>
-#include <wx/combobox.h>
-#include <wx/spinctrl.h>
-#include <wx/statline.h>
-
 #include <vlc/intf.h>
 
-#if defined MODULE_NAME_IS_skins
-#   include "../skins/src/skin_common.h"
-#endif
-
 #include "wxwindows.h"
+#include <wx/combobox.h>
+#include <wx/statline.h>
 
 #ifndef wxRB_SINGLE
 #   define wxRB_SINGLE 0
@@ -80,7 +62,7 @@ END_EVENT_TABLE()
  * Constructor.
  *****************************************************************************/
 SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
-    wxDialog( _p_parent, -1, wxU(_("Open Subtitles File")),
+    wxDialog( _p_parent, -1, wxU(_("Subtitle options")),
               wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
@@ -91,6 +73,8 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     /* Create a panel to put everything in */
     wxPanel *panel = new wxPanel( this, -1 );
     panel->SetAutoLayout( TRUE );
+    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
+    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
 
     /* Create the subtitles file textctrl */
     wxBoxSizer *file_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
@@ -99,8 +83,8 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box,
                                                         wxHORIZONTAL );
     char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
-    file_combo = new wxComboBox( panel, -1,
-                                 psz_subsfile ? wxU(psz_subsfile) : wxT(""),
+    if( !psz_subsfile ) psz_subsfile = strdup("");
+    file_combo = new wxComboBox( panel, -1, wxL2U(psz_subsfile),
                                  wxPoint(20,25), wxSize(300, -1), 0, NULL );
     if( psz_subsfile ) free( psz_subsfile );
     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
@@ -108,6 +92,44 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     file_sizer->Add( file_combo, 1, wxALL, 5 );
     file_sizer->Add( browse_button, 0, wxALL, 5 );
     file_sizer_sizer->Add( file_sizer, 1, wxEXPAND | wxALL, 5 );
+    panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
+
+    /* Subtitles encoding */
+    encoding_combo = NULL;
+    module_config_t *p_item =
+        config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
+    if( p_item )
+    {
+        wxBoxSizer *enc_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
+        wxStaticBox *enc_box = new wxStaticBox( panel, -1,
+                                                wxU(_("Subtitles encoding")) );
+        wxStaticBoxSizer *enc_sizer = new wxStaticBoxSizer( enc_box,
+                                                            wxHORIZONTAL );
+        wxStaticText *label =
+            new wxStaticText(panel, -1, wxU(p_item->psz_text));
+        encoding_combo = new wxComboBox( panel, -1, wxU(p_item->psz_value),
+                                         wxDefaultPosition, wxDefaultSize,
+                                         0, NULL, wxCB_READONLY );
+
+        /* build a list of available options */
+        for( int i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
+             i_index++ )
+        {
+            encoding_combo->Append( wxU(p_item->ppsz_list[i_index]) );
+            if( p_item->psz_value && !strcmp( p_item->psz_value,
+                                              p_item->ppsz_list[i_index] ) )
+                encoding_combo->SetSelection( i_index );
+        }
+
+        if( p_item->psz_value )
+        encoding_combo->SetValue( wxU(p_item->psz_value) );
+        encoding_combo->SetToolTip( wxU(p_item->psz_longtext) );
+
+        enc_sizer->Add( label, 0, wxALL, 5 );
+        enc_sizer->Add( encoding_combo, 0, wxALL, 5 );
+        enc_sizer_sizer->Add( enc_sizer, 1, wxEXPAND | wxALL, 5 );
+        panel_sizer->Add( enc_sizer, 0, wxEXPAND | wxALL, 5 );
+    }
 
     /* Misc Subtitles options */
     wxBoxSizer *misc_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
@@ -118,8 +140,9 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     wxStaticText *label =
         new wxStaticText(panel, -1, wxU(_("Delay subtitles (in 1/10s)")));
     int i_delay = config_GetInt( p_intf, "sub-delay" );
-    delay_spinctrl = new wxSpinCtrl( panel, -1,
-                                     wxString::Format(wxT("%d"), i_delay),
+    /* Outside the new wxSpinCtrl to avoid an internal error in gcc2.95 ! */
+    wxString format_delay(wxString::Format(wxT("%d"), i_delay));
+    delay_spinctrl = new wxSpinCtrl( panel, -1, format_delay,
                                      wxDefaultPosition, wxDefaultSize,
                                      wxSP_ARROW_KEYS,
                                      -650000, 650000, i_delay );
@@ -130,8 +153,9 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     label = new wxStaticText(panel, -1, wxU(_("Frames per second")));
 
     float f_fps = config_GetFloat( p_intf, "sub-fps" );
-    fps_spinctrl = new wxSpinCtrl( panel, -1,
-                                   wxString::Format(wxT("%d"),(int)f_fps),
+    /* Outside the new wxSpinCtrl to avoid an internal error in gcc2.95 ! */
+    wxString format_fps(wxString::Format(wxT("%d"),(int)f_fps));
+    fps_spinctrl = new wxSpinCtrl( panel, -1, format_fps,
                                    wxDefaultPosition, wxDefaultSize,
                                    wxSP_ARROW_KEYS,
                                    0, 16000, (int)f_fps );
@@ -141,6 +165,7 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     misc_sizer->Add( fps_spinctrl, 0, wxALL, 5 );
 
     misc_sizer_sizer->Add( misc_sizer, 1, wxEXPAND | wxALL, 5 );
+    panel_sizer->Add( misc_sizer, 0, wxEXPAND | wxALL, 5 );
 
     /* Separation */
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
@@ -156,10 +181,7 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     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( file_sizer, 0, wxEXPAND | wxALL, 5 );
-    panel_sizer->Add( misc_sizer, 0, wxEXPAND | wxALL, 5 );
+
     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
                       wxALL, 5 );
@@ -194,7 +216,7 @@ void SubsFileDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 void SubsFileDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     wxFileDialog dialog( this, wxU(_("Open file")),
-                         wxT(""), wxT(""), wxT("*.*"), wxOPEN );
+                         wxT(""), wxT(""), wxT("*"), wxOPEN );
 
     if( dialog.ShowModal() == wxID_OK )
     {