]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwindows/*: improved preferences widgets a bit.
authorGildas Bazin <gbazin@videolan.org>
Mon, 12 Apr 2004 00:06:59 +0000 (00:06 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 12 Apr 2004 00:06:59 +0000 (00:06 +0000)
modules/gui/wxwindows/open.cpp
modules/gui/wxwindows/preferences_widgets.cpp
modules/gui/wxwindows/preferences_widgets.h

index f9f34be738b85d31ad7950ba13afb70f866e699b..1edc231ba91682dd5e9dff9ad7179af27463dd0e 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2000-2004 VideoLAN
  * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  * 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
@@ -849,7 +849,13 @@ void OpenDialog::UpdateMRL( int i_access_method )
             for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
             {
                 ConfigControl *control = input_panel->config_array.Item(i);
-                mrltemp += wxT(" :") + control->GetName() + wxT("=");
+
+                mrltemp += wxT(" :");
+
+                if( control->GetType() == CONFIG_ITEM_BOOL &&
+                    !control->GetIntValue() ) mrltemp += wxT("no-");
+
+                mrltemp += control->GetName();
 
                 switch( control->GetType() )
                 {
@@ -857,16 +863,15 @@ void OpenDialog::UpdateMRL( int i_access_method )
                 case CONFIG_ITEM_FILE:
                 case CONFIG_ITEM_DIRECTORY:
                 case CONFIG_ITEM_MODULE:
-                    mrltemp += wxT("\"") + control->GetPszValue() + wxT("\"");
+                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
                     break;
                 case CONFIG_ITEM_INTEGER:
-                case CONFIG_ITEM_BOOL:
                     mrltemp +=
-                        wxString::Format( wxT("%i"), control->GetIntValue() );
+                        wxString::Format( wxT("=%i"), control->GetIntValue() );
                     break;
                 case CONFIG_ITEM_FLOAT:
                     mrltemp +=
-                        wxString::Format( wxT("%f"), control->GetFloatValue());
+                        wxString::Format(wxT("=%f"), control->GetFloatValue());
                     break;
                 }
             }
index 71da8bff80fa26396eae4fa947bd058f441a0b41..958bd1151f0bf3e3652e4050156ebc006f04cd7a 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2000-2004 VideoLAN
  * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.org>
  *          Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -335,6 +335,9 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
                                                   wxWindow *parent )
   : ConfigControl( p_this, p_item, parent )
 {
+    psz_default_value = p_item->psz_value;
+    if( psz_default_value ) psz_default_value = strdup( psz_default_value );
+
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
     combo = new wxComboBox( this, -1, wxT(""),
@@ -359,12 +362,16 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
 
 StringListConfigControl::~StringListConfigControl()
 {
+    if( psz_default_value ) free( psz_default_value );
 }
 
 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
 {
+    vlc_bool_t b_found = VLC_FALSE;
+    int i_index;
+
     /* build a list of available options */
-    for( int i_index = 0; i_index < p_item->i_list; i_index++ )
+    for( i_index = 0; i_index < p_item->i_list; i_index++ )
     {
         combo->Append( ( p_item->ppsz_list_text &&
                          p_item->ppsz_list_text[i_index] ) ?
@@ -380,8 +387,18 @@ void StringListConfigControl::UpdateCombo( module_config_t *p_item )
                                p_item->ppsz_list_text[i_index] ) ?
                              wxU(p_item->ppsz_list_text[i_index]) :
                              wxL2U(p_item->ppsz_list[i_index]) );
+            b_found = VLC_TRUE;
         }
     }
+
+    if( p_item->psz_value && !b_found )
+    {
+        /* Add custom entry to list */
+        combo->Append( wxL2U(p_item->psz_value) );
+        combo->SetClientData( i_index, (void *)psz_default_value );
+        combo->SetSelection( i_index );
+        combo->SetValue( wxL2U(p_item->psz_value) );
+    }
 }
 
 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
@@ -494,6 +511,10 @@ wxString FileConfigControl::GetPszValue()
 /*****************************************************************************
  * IntegerConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(IntegerConfigControl, wxPanel)
+    EVT_COMMAND_SCROLL(-1, IntegerConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
                                             module_config_t *p_item,
                                             wxWindow *parent )
@@ -621,6 +642,10 @@ int IntegerListConfigControl::GetIntValue()
 /*****************************************************************************
  * RangedIntConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(RangedIntConfigControl, wxPanel)
+    EVT_COMMAND_SCROLL(-1, RangedIntConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
                                                 module_config_t *p_item,
                                                 wxWindow *parent )
@@ -650,6 +675,10 @@ int RangedIntConfigControl::GetIntValue()
 /*****************************************************************************
  * FloatConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(FloatConfigControl, wxPanel)
+    EVT_TEXT(-1, FloatConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
                                         module_config_t *p_item,
                                         wxWindow *parent )
@@ -684,6 +713,10 @@ float FloatConfigControl::GetFloatValue()
 /*****************************************************************************
  * BoolConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(BoolConfigControl, wxPanel)
+    EVT_CHECKBOX(-1, BoolConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
                                       module_config_t *p_item,
                                       wxWindow *parent )
@@ -704,12 +737,6 @@ BoolConfigControl::~BoolConfigControl()
 
 int BoolConfigControl::GetIntValue()
 {
-    if( checkbox->IsChecked() )
-    {
-        return 1;
-    }
-    else
-    {
-        return 0;
-    }
+    if( checkbox->IsChecked() ) return 1;
+    else return 0;
 }
index 249df16210bf7f0aa77566789ac078dc206e0b19..f51ab841bf94873709bc9f3a140a3a426b1796d6 100644 (file)
@@ -102,6 +102,7 @@ public:
     virtual wxString GetPszValue();
 private:
     wxComboBox *combo;
+    char *psz_default_value;
     void UpdateCombo( module_config_t *p_item );
 
     void OnAction( wxCommandEvent& );
@@ -117,10 +118,11 @@ public:
     void OnBrowse( wxCommandEvent& );
     virtual wxString GetPszValue();
 private:
-    DECLARE_EVENT_TABLE()
     wxTextCtrl *textctrl;
     wxButton *browse;
     bool directory;
+
+    DECLARE_EVENT_TABLE()
 };
 
 class IntegerConfigControl: public ConfigControl
@@ -131,6 +133,8 @@ public:
     virtual int GetIntValue();
 private:
     wxSpinCtrl *spin;
+
+    DECLARE_EVENT_TABLE()
 };
 
 class IntegerListConfigControl: public ConfigControl
@@ -156,6 +160,8 @@ public:
     virtual int GetIntValue();
 private:
     wxSlider *slider;
+
+    DECLARE_EVENT_TABLE()
 };
 
 class FloatConfigControl: public ConfigControl
@@ -166,6 +172,8 @@ public:
     virtual float GetFloatValue();
 private:
     wxTextCtrl *textctrl;
+
+    DECLARE_EVENT_TABLE()
 };
 
 class BoolConfigControl: public ConfigControl
@@ -176,4 +184,6 @@ public:
     virtual int GetIntValue();
 private:
     wxCheckBox *checkbox;
+
+    DECLARE_EVENT_TABLE()
 };