]> git.sesse.net Git - vlc/blobdiff - modules/gui/win32/preferences.cpp
* ALL: added a new vlc_list_t common type. vlc_list_find() and vlc_list_release(...
[vlc] / modules / gui / win32 / preferences.cpp
index 85a7f79a6a7d0291b4e84b1e2b9ed1ff08924b33..51cfd2dd26018c12bf877c6be95d44d11f99f15b 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2002 VideoLAN\r
  *\r
  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>\r
+ *          Boris Dores <babal@via.ecp.fr>\r
  *\r
  * This program is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
 #pragma link "CSPIN"\r
 #pragma resource "*.dfm"\r
 \r
-extern intf_thread_t *p_intfGlobal;\r
+/****************************************************************************\r
+ * A THintWindow with a limited width\r
+ ****************************************************************************/\r
+void __fastcall TNarrowHintWindow::ActivateHint(const Windows::TRect &Rect,\r
+    const System::AnsiString AHint)\r
+{\r
+    TRect NarrowRect = CalcHintRect ( 300 , AHint , NULL );\r
+    NarrowRect.Left = Rect.Left;\r
+    NarrowRect.Top = Rect.Top;\r
+    NarrowRect.Right += Rect.Left;\r
+    NarrowRect.Bottom += Rect.Top;\r
+    THintWindow::ActivateHint ( NarrowRect , AHint );\r
+}\r
+\r
+\r
+/****************************************************************************\r
+ * Just a wrapper to embed an AnsiString into a TObject\r
+ ****************************************************************************/\r
+__fastcall TObjectString::TObjectString(char * String)\r
+{\r
+    FString = AnsiString(String);\r
+}\r
+//---------------------------------------------------------------------------\r
+AnsiString __fastcall TObjectString::String()\r
+{\r
+    return FString;\r
+}\r
+\r
+\r
+/****************************************************************************\r
+ * A TCheckListBox that automatically disposes any TObject\r
+ * associated with the string items\r
+ ****************************************************************************/\r
+__fastcall TCleanCheckListBox::~TCleanCheckListBox()\r
+{\r
+    for ( int i = 0 ; i < Items->Count ; i++ )\r
+    {\r
+        if ( Items->Objects[i] != NULL ) delete Items->Objects[i];\r
+    }\r
+}\r
 \r
 \r
 /****************************************************************************\r
  * Functions to help components creation\r
  ****************************************************************************/\r
-__fastcall TGroupBoxPref::TGroupBoxPref( TComponent* Owner,\r
-            module_config_t *p_config_arg ) : TGroupBox( Owner )\r
+__fastcall TPanelPref::TPanelPref( TComponent* Owner,\r
+            module_config_t *p_config_arg ) : TPanel( Owner )\r
 {\r
     p_config = p_config_arg;\r
-    Caption = p_config->psz_text;\r
+    BevelInner = bvNone;\r
+    BevelOuter = bvNone;\r
+    BorderStyle = bsNone;\r
 }\r
 //---------------------------------------------------------------------------\r
-TListView * __fastcall TGroupBoxPref::CreateListView( TWinControl *Parent,\r
-            int Left, int Width, int Top, int Height, TViewStyle ViewStyle )\r
-{\r
-    TListView *ListView = new TListView( Parent );\r
-    ListView->Parent = Parent;\r
-    ListView->ViewStyle = ViewStyle;\r
-    ListView->Left = Left;\r
-    ListView->Width = Width;\r
-    ListView->Top = Top;\r
-    ListView->Height = Height;\r
-    return ListView;\r
+TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox(\r
+    TWinControl *Parent, int Left, int Width, int Top, int Height )\r
+{\r
+    TCleanCheckListBox *CleanCheckListBox = new TCleanCheckListBox( Parent );\r
+    CleanCheckListBox->Parent = Parent;\r
+    CleanCheckListBox->Left = Left;\r
+    CleanCheckListBox->Width = Width;\r
+    CleanCheckListBox->Top = Top;\r
+    CleanCheckListBox->Height = Height;\r
+    return CleanCheckListBox;\r
 }\r
 //---------------------------------------------------------------------------\r
-TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent,\r
+TButton * __fastcall TPanelPref::CreateButton( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height, AnsiString Caption )\r
 {\r
     TButton *Button = new TButton( Parent );\r
@@ -76,7 +117,7 @@ TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent,
     return Button;\r
 }\r
 //---------------------------------------------------------------------------\r
-TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent,\r
+TCheckBox * __fastcall TPanelPref::CreateCheckBox( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height, AnsiString Caption )\r
 {\r
     TCheckBox *CheckBox = new TCheckBox( Parent );\r
@@ -89,7 +130,7 @@ TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent,
     return CheckBox;\r
 }\r
 //---------------------------------------------------------------------------\r
-TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent,\r
+TLabel * __fastcall TPanelPref::CreateLabel( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height, AnsiString Caption,\r
             bool WordWrap )\r
 {\r
@@ -104,7 +145,7 @@ TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent,
     return Label;\r
 }\r
 //---------------------------------------------------------------------------\r
-TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent,\r
+TEdit * __fastcall TPanelPref::CreateEdit( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height, AnsiString Text )\r
 {\r
     TEdit *Edit = new TEdit( Parent );\r
@@ -117,7 +158,7 @@ TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent,
     return Edit;\r
 }\r
 //---------------------------------------------------------------------------\r
-TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent,\r
+TCSpinEdit * __fastcall TPanelPref::CreateSpinEdit( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height,\r
             long Min, long Max, long Value )\r
 {\r
@@ -133,127 +174,188 @@ TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent,
     return SpinEdit;\r
 }\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPref::UpdateChanges()\r
+void __fastcall TPanelPref::UpdateChanges()\r
 {\r
 }\r
 \r
+#define LIBWIN32_PREFSIZE_VPAD                4\r
+#define LIBWIN32_PREFSIZE_HPAD                4\r
+#define LIBWIN32_PREFSIZE_LEFT                16\r
+#define LIBWIN32_PREFSIZE_EDIT_LEFT           (LIBWIN32_PREFSIZE_LEFT+32)\r
+#define LIBWIN32_PREFSIZE_WIDTH               375\r
+#define LIBWIN32_PREFSIZE_EDIT_WIDTH          (LIBWIN32_PREFSIZE_WIDTH-32)\r
+#define LIBWIN32_PREFSIZE_BUTTON_WIDTH        150\r
+#define LIBWIN32_PREFSIZE_SPINEDIT_WIDTH      100\r
+#define LIBWIN32_PREFSIZE_RIGHT               (LIBWIN32_PREFSIZE_LEFT+LIBWIN32_PREFSIZE_WIDTH)\r
+#define LIBWIN32_PREFSIZE_BUTTON_HEIGHT       25\r
+#define LIBWIN32_PREFSIZE_LABEL_HEIGHT        26\r
+#define LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT 120\r
+#define LIBWIN32_PREFSIZE_EDIT_HEIGHT         21\r
+#define LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT     17\r
+#define LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT     21\r
 \r
 /****************************************************************************\r
- * GroupBox for module management\r
+ * Panel for module management\r
  ****************************************************************************/\r
-__fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner,\r
-            module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )\r
+__fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,\r
+    module_config_t *p_config, intf_thread_t *_p_intf )\r
+    : TPanelPref( Owner, p_config )\r
 {\r
-    /* init listview */\r
-    ListView = CreateListView( this, 16, 164, 24, 160, vsReport );\r
-    ListView->ReadOnly = true;\r
-    ListView->Columns->Add();\r
-    ListView->Columns->Items[0]->Width = 160;\r
-    ListView->Columns->Items[0]->Caption = "Name";//p_config->psz_text;\r
-    ListView->OnSelectItem = ListViewSelectItem;\r
-\r
-    /* init description label */\r
-    LabelDesc = CreateLabel( this, 230, 225, 50, 52,\r
-                             p_config->psz_longtext, true );\r
-\r
-    /* init hint label */\r
-    LabelHint = CreateLabel( this, 230, 225, 135, 13, "", false );\r
+    p_intf = _p_intf;\r
 \r
     /* init configure button */\r
-    ButtonConfig = CreateButton( this, 16, 70, 192, 25, "Configure" );\r
+    ButtonConfig = CreateButton( this,\r
+            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH,\r
+            LIBWIN32_PREFSIZE_BUTTON_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
+            "Configure..." );\r
     ButtonConfig->Enabled = false;\r
     ButtonConfig->OnClick = ButtonConfigClick;\r
 \r
-    /* init select button */\r
-    ButtonSelect = CreateButton( this, 110, 70, 192, 25, "Select" );\r
-    ButtonSelect->OnClick = ButtonSelectClick;\r
-\r
-    /* init 'Selected' label */\r
-    LabelSelected = CreateLabel( this, 230, 45, 198, 13, "Selected", false );\r
-\r
-    /* init 'Selected' edit */\r
-    Edit = CreateEdit( this, 280, 164, 194, 21, "" );\r
-    vlc_mutex_lock( p_config->p_lock );\r
-    Edit->Text = p_config->psz_value ? p_config->psz_value : "";\r
-    vlc_mutex_unlock( p_config->p_lock );\r
-\r
-    Height = 233;\r
+    /* init label */\r
+    AnsiString Text = AnsiString(p_config->psz_text) + ":";\r
+    Label = CreateLabel( this,\r
+            LIBWIN32_PREFSIZE_LEFT,\r
+            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH\r
+             - LIBWIN32_PREFSIZE_HPAD,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_LABEL_HEIGHT,\r
+            Text.c_str(), true );\r
+\r
+    /* vertical alignement */\r
+    if ( ButtonConfig->Height > Label->Height )\r
+        Label->Top += ( ButtonConfig->Height - Label->Height ) / 2;\r
+    else\r
+        ButtonConfig->Top += ( Label->Height - ButtonConfig->Height ) / 2;\r
+\r
+    /* init checklistbox */\r
+    CleanCheckListBox = CreateCleanCheckListBox( this,\r
+            LIBWIN32_PREFSIZE_EDIT_LEFT,\r
+            LIBWIN32_PREFSIZE_EDIT_WIDTH,\r
+            max ( Label->Top + Label->Height , ButtonConfig->Top\r
+             + ButtonConfig->Height ) + LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT );\r
+    CleanCheckListBox->OnClick = CheckListBoxClick;\r
+    CleanCheckListBox->OnClickCheck = CheckListBoxClickCheck;\r
+    CleanCheckListBox->Hint = p_config->psz_longtext;\r
+    CleanCheckListBox->ShowHint = true;\r
+\r
+    /* panel height */\r
+    Height = CleanCheckListBox->Top + CleanCheckListBox->Height\r
+            + LIBWIN32_PREFSIZE_VPAD;\r
 };\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::ListViewSelectItem( TObject *Sender,\r
-        TListItem *Item, bool Selected )\r
+void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )\r
 {\r
-    module_t **pp_parser;\r
-    vlc_list_t *p_list;\r
-    AnsiString Name;\r
+    module_t *p_parser;\r
+    vlc_list_t list;\r
+    int i_index;\r
 \r
-    Name = Item->Caption;\r
+    /* check that the click is valid (we are on an item, and the click\r
+     * started on an item */\r
+    if( CleanCheckListBox->ItemIndex == -1 )\r
+        return;\r
+\r
+    AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->\r
+        Objects[CleanCheckListBox->ItemIndex])->String().c_str();\r
     if( Name == "" )\r
-    {\r
         return;\r
-    }\r
 \r
     /* look for module 'Name' */\r
-    for( pp_parser = (module_t **)p_list->pp_objects ;\r
-         *pp_parser ;\r
-         pp_parser++ )\r
+    list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );\r
+\r
+    for( i_index = 0; i_index < list.i_count; i_index++ )\r
     {\r
-        if( strcmp( (*pp_parser)->psz_object_name, Name.c_str() ) == 0 )\r
+        p_parser = (module_t *)list.p_values[i_index].p_object ;\r
+\r
+        if( strcmp( p_parser->psz_object_name, Name.c_str() ) == 0 )\r
         {\r
-            ModuleSelected = (*pp_parser);\r
-            LabelHint->Caption = (*pp_parser)->psz_longname ?\r
-                                 (*pp_parser)->psz_longname : "";\r
-            ButtonConfig->Enabled = (*pp_parser)->i_config_items ? true : false;\r
+            ModuleSelected = p_parser;\r
+            ButtonConfig->Enabled =\r
+                p_parser->i_config_items ? true : false;\r
 \r
             break;\r
         }\r
     }\r
 }\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::ButtonSelectClick( TObject *Sender )\r
+void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender )\r
 {\r
-    if( !ModuleSelected ) return;\r
-    Edit->Text = ModuleSelected->psz_object_name;\r
+    /* one item maximum must be checked */\r
+    if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )\r
+    {\r
+        for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
+        {\r
+            if( item != CleanCheckListBox->ItemIndex )\r
+            {\r
+                CleanCheckListBox->Checked[item] = false;\r
+            }\r
+        }\r
+    }\r
 }\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender )\r
+void __fastcall TPanelPlugin::ButtonConfigClick( TObject *Sender )\r
 {\r
-    p_intfGlobal->p_sys->p_window->\r
+    p_intf->p_sys->p_window->\r
                         CreatePreferences( ModuleSelected->psz_object_name );\r
 }\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::UpdateChanges()\r
+void __fastcall TPanelPlugin::UpdateChanges()\r
 {\r
+    AnsiString Name = "";\r
+\r
+    /* find the selected plugin (if any) */\r
+    for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
+    {\r
+        if( CleanCheckListBox->Checked[item] )\r
+        {\r
+            Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
+                   ->String().c_str();\r
+            break;\r
+        }\r
+    }\r
+\r
     /* XXX: Necessary, since c_str() returns only a temporary pointer... */\r
     free( p_config->psz_value );\r
-    p_config->psz_value = (char *)malloc( Edit->Text.Length() + 1 );\r
-    strcpy( p_config->psz_value, Edit->Text.c_str() );\r
+    p_config->psz_value = (char *)malloc( Name.Length() + 1 );\r
+    strcpy( p_config->psz_value, Name.c_str() );\r
 }\r
 \r
 \r
 /****************************************************************************\r
- * GroupBox for string management\r
+ * Panel for string management\r
  ****************************************************************************/\r
-__fastcall TGroupBoxString::TGroupBoxString( TComponent* Owner,\r
-            module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )\r
+__fastcall TPanelString::TPanelString( TComponent* Owner,\r
+            module_config_t *p_config ) : TPanelPref( Owner, p_config )\r
 {\r
     /* init description label */\r
-    LabelDesc = CreateLabel( this, 230, 225, 24, 26,\r
-                             p_config->psz_longtext, true );\r
+    AnsiString Text = AnsiString ( p_config->psz_text ) + ":";\r
+    Label = CreateLabel( this,\r
+            LIBWIN32_PREFSIZE_LEFT,\r
+            LIBWIN32_PREFSIZE_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_LABEL_HEIGHT,\r
+            Text.c_str(), true );\r
 \r
     /* init edit */\r
-    Edit = CreateEdit( this, 16, 164, 24, 21, "" );\r
+    Edit = CreateEdit( this,\r
+            LIBWIN32_PREFSIZE_EDIT_LEFT,\r
+            LIBWIN32_PREFSIZE_EDIT_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_EDIT_HEIGHT, "" );\r
     vlc_mutex_lock( p_config->p_lock );\r
     Edit->Text = p_config->psz_value ? p_config->psz_value : "";\r
     vlc_mutex_unlock( p_config->p_lock );\r
+    Edit->Hint = p_config->psz_longtext;\r
+    Edit->ShowHint = true;\r
 \r
-    /* vertical alignment */\r
-    Height = LabelDesc->Height + 24;\r
-    LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4;\r
-    Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;\r
+    /* panel height */\r
+    Height = LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD\r
+            + Edit->Height + LIBWIN32_PREFSIZE_VPAD;\r
 };\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxString::UpdateChanges()\r
+void __fastcall TPanelString::UpdateChanges()\r
 {\r
     /* XXX: Necessary, since c_str() returns only a temporary pointer... */\r
     free( p_config->psz_value );\r
@@ -263,26 +365,44 @@ void __fastcall TGroupBoxString::UpdateChanges()
 \r
 \r
 /****************************************************************************\r
- * GroupBox for integer management\r
+ * Panel for integer management\r
  ****************************************************************************/\r
-__fastcall TGroupBoxInteger::TGroupBoxInteger( TComponent* Owner,\r
-            module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )\r
+__fastcall TPanelInteger::TPanelInteger( TComponent* Owner,\r
+            module_config_t *p_config ) : TPanelPref( Owner, p_config )\r
 {\r
     /* init description label */\r
-    LabelDesc = CreateLabel( this, 230, 225, 19, 26,\r
-                             p_config->psz_longtext, true );\r
+    AnsiString Text = AnsiString ( p_config->psz_text ) + ":";\r
+    Label = CreateLabel( this,\r
+            LIBWIN32_PREFSIZE_LEFT,\r
+            LIBWIN32_PREFSIZE_WIDTH - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH\r
+             - LIBWIN32_PREFSIZE_HPAD,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_LABEL_HEIGHT, Text.c_str(), true );\r
 \r
     /* init spinedit */\r
-    SpinEdit = CreateSpinEdit( this, 16, 164, 24, 21,\r
-                               -1, 100000, p_config->i_value );\r
-\r
-    /* vertical alignment */\r
-    Height = LabelDesc->Height + 24;\r
-    LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4;\r
-    SpinEdit->Top = Top + ( Height - SpinEdit->Height ) / 2 + 4;\r
+    SpinEdit = CreateSpinEdit( this,\r
+            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,\r
+            LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT,\r
+            -1, 100000, p_config->i_value );\r
+    SpinEdit->Hint = p_config->psz_longtext;\r
+    SpinEdit->ShowHint = true;\r
+\r
+    /* vertical alignement and panel height */\r
+    if ( SpinEdit->Height > Label->Height )\r
+    {\r
+        Label->Top += ( SpinEdit->Height - Label->Height ) / 2;\r
+        Height = SpinEdit->Top + SpinEdit->Height + LIBWIN32_PREFSIZE_VPAD;\r
+    }\r
+    else\r
+    {\r
+        SpinEdit->Top += ( Label->Height - SpinEdit->Height ) / 2;\r
+        Height = Label->Top + Label->Height + LIBWIN32_PREFSIZE_VPAD;\r
+    }\r
 };\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxInteger::UpdateChanges()\r
+void __fastcall TPanelInteger::UpdateChanges()\r
 {\r
     /* Warning: we're casting from long to int */\r
     p_config->i_value = (int)SpinEdit->Value;\r
@@ -290,26 +410,78 @@ void __fastcall TGroupBoxInteger::UpdateChanges()
 \r
 \r
 /****************************************************************************\r
- * GroupBox for boolean management\r
+ * Panel for float management\r
  ****************************************************************************/\r
-__fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner,\r
-            module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )\r
+__fastcall TPanelFloat::TPanelFloat( TComponent* Owner,\r
+            module_config_t *p_config ) : TPanelPref( Owner, p_config )\r
 {\r
+#define MAX_FLOAT_CHARS 20\r
     /* init description label */\r
-    LabelDesc = CreateLabel( this, 230, 225, 19, 26,\r
-                             p_config->psz_longtext, true );\r
+    AnsiString Text = AnsiString( p_config->psz_text ) + ":";\r
+    Label = CreateLabel( this,\r
+            LIBWIN32_PREFSIZE_LEFT,\r
+            LIBWIN32_PREFSIZE_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_LABEL_HEIGHT,\r
+            Text.c_str(), true );\r
+\r
+    /* init edit */\r
+    char *psz_value = (char *)malloc( MAX_FLOAT_CHARS );\r
+    snprintf( psz_value, MAX_FLOAT_CHARS, "%f", p_config->f_value );\r
+    /* we use the spinedit size, to be similar with the integers */\r
+    Edit = CreateEdit( this,\r
+            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,\r
+            LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT,\r
+            psz_value );\r
+    free( psz_value );\r
+    Edit->Hint = p_config->psz_longtext;\r
+    Edit->ShowHint = true;\r
+\r
+    /* vertical alignement and panel height */\r
+    if ( Edit->Height > Label->Height )\r
+    {\r
+        Label->Top += ( Edit->Height - Label->Height ) / 2;\r
+        Height = Edit->Top + Edit->Height + LIBWIN32_PREFSIZE_VPAD;\r
+    }\r
+    else\r
+    {\r
+        Edit->Top += ( Label->Height - Edit->Height ) / 2;\r
+        Height = Label->Top + Label->Height + LIBWIN32_PREFSIZE_VPAD;\r
+    }\r
 \r
+#undef MAX_FLOAT_CHARS\r
+};\r
+//---------------------------------------------------------------------------\r
+void __fastcall TPanelFloat::UpdateChanges()\r
+{\r
+    /* Warning: we're casting from double to float */\r
+    p_config->f_value = atof( Edit->Text.c_str() );\r
+}\r
+\r
+\r
+/****************************************************************************\r
+ * Panel for boolean management\r
+ ****************************************************************************/\r
+__fastcall TPanelBool::TPanelBool( TComponent* Owner,\r
+            module_config_t *p_config ) : TPanelPref( Owner, p_config )\r
+{\r
     /* init checkbox */\r
-    CheckBox = CreateCheckBox( this, 16, 184, 28, 17, p_config->psz_text );\r
+    CheckBox = CreateCheckBox( this,\r
+            LIBWIN32_PREFSIZE_LEFT,\r
+            LIBWIN32_PREFSIZE_WIDTH,\r
+            LIBWIN32_PREFSIZE_VPAD,\r
+            LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT, p_config->psz_text );\r
     CheckBox->Checked = p_config->i_value;\r
+    CheckBox->Hint = p_config->psz_longtext;\r
+    CheckBox->ShowHint = true;\r
 \r
-    /* vertical alignment */\r
-    Height = LabelDesc->Height + 24;\r
-    LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4;\r
-    CheckBox->Top = Top + ( Height - CheckBox->Height ) / 2 + 4;\r
+    /* panel height */\r
+    Height = LIBWIN32_PREFSIZE_VPAD + CheckBox->Height + LIBWIN32_PREFSIZE_VPAD;\r
 };\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxBool::UpdateChanges()\r
+void __fastcall TPanelBool::UpdateChanges()\r
 {\r
     p_config->i_value = CheckBox->Checked ? 1 : 0;\r
 }\r
@@ -318,11 +490,16 @@ void __fastcall TGroupBoxBool::UpdateChanges()
 /****************************************************************************\r
  * Callbacks for the dialog\r
  ****************************************************************************/\r
-//---------------------------------------------------------------------------\r
-__fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner )\r
-        : TForm( Owner )\r
+__fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner,\r
+    intf_thread_t *_p_intf ) : TForm( Owner )\r
 {\r
-    Icon = p_intfGlobal->p_sys->p_window->Icon;\r
+    p_intf = _p_intf;\r
+    Icon = p_intf->p_sys->p_window->Icon;\r
+    Application->HintHidePause = 0x1000000;\r
+    HintWindowClass = __classid ( TNarrowHintWindow );\r
+    /* prevent the form from being resized horizontally */\r
+    Constraints->MinWidth = Width;\r
+    Constraints->MaxWidth = Width;\r
 }\r
 //---------------------------------------------------------------------------\r
 void __fastcall TPreferencesDlg::FormClose( TObject *Sender,\r
@@ -330,22 +507,6 @@ void __fastcall TPreferencesDlg::FormClose( TObject *Sender,
 {\r
     Action = caHide;\r
 }\r
-//---------------------------------------------------------------------------\r
-void __fastcall TPreferencesDlg::FormShow( TObject *Sender )\r
-{\r
-/*\r
-    p_intfGlobal->p_sys->p_window->MenuPreferences->Checked = true;\r
-    p_intfGlobal->p_sys->p_window->PopupPreferences->Checked = true;\r
-*/\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TPreferencesDlg::FormHide( TObject *Sender )\r
-{\r
-/*\r
-    p_intfGlobal->p_sys->p_window->MenuPreferences->Checked = false;\r
-    p_intfGlobal->p_sys->p_window->PopupPreferences->Checked = false;\r
-*/\r
-}\r
 \r
 \r
 /****************************************************************************\r
@@ -363,37 +524,38 @@ void __fastcall TPreferencesDlg::FormHide( TObject *Sender )
 \r
 void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )\r
 {\r
-    module_t          **pp_parser;\r
-    vlc_list_t         *p_list;\r
+    module_t           *p_parser;\r
+    vlc_list_t          list;\r
+    int                 i_index;\r
 \r
     module_config_t    *p_item;\r
     int                 i_pages, i_ctrl;\r
-    \r
+\r
     TTabSheet          *TabSheet;\r
     TScrollBox         *ScrollBox;\r
     TPanel             *Panel;\r
-    TGroupBoxPlugin    *GroupBoxPlugin;\r
-    TGroupBoxString    *GroupBoxString;\r
-    TGroupBoxInteger   *GroupBoxInteger;\r
-    TGroupBoxBool      *GroupBoxBool;\r
-    TListItem          *ListItem;\r
+    TPanelPlugin       *PanelPlugin;\r
+    TPanelString       *PanelString;\r
+    TPanelInteger      *PanelInteger;\r
+    TPanelFloat        *PanelFloat;\r
+    TPanelBool         *PanelBool;\r
 \r
     /* Look for the selected module */\r
-    p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );\r
+    list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );\r
 \r
-    for( pp_parser = (module_t **)p_list->pp_objects ;\r
-         *pp_parser ;\r
-         pp_parser++ )\r
+    for( i_index = 0; i_index < list.i_count; i_index++ )\r
     {\r
+        p_parser = (module_t *)list.p_values[i_index].p_object ;\r
+\r
         if( psz_module_name\r
-             && !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )\r
+             && !strcmp( psz_module_name, p_parser->psz_object_name ) )\r
         {\r
             break;\r
         }\r
     }\r
-    if( !(*pp_parser) )\r
+    if( !p_parser || i_index == list.i_count )\r
     {\r
-        vlc_list_release( p_list );\r
+        vlc_list_release( &list );\r
         return;\r
     }\r
 \r
@@ -402,7 +564,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
      */\r
 \r
     /* Enumerate config options and add corresponding config boxes */\r
-    p_item = (*pp_parser)->p_config;\r
+    p_item = p_parser->p_config;\r
     if( p_item ) do\r
     {\r
         switch( p_item->i_type )\r
@@ -423,26 +585,44 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
             ScrollBox->HorzScrollBar->Tracking = true;\r
             ScrollBox->VertScrollBar->Tracking = true;\r
 \r
+            /* add a panel as top margin */\r
+            ADD_PANEL;\r
+\r
             break;\r
 \r
         case CONFIG_ITEM_MODULE:\r
 \r
-            /* add new groupbox for the config option */\r
-            GroupBoxPlugin = new TGroupBoxPlugin( this, p_item );\r
-            GroupBoxPlugin->Parent = ScrollBox;\r
-\r
-            /* add panel as separator */\r
-            ADD_PANEL;\r
+            /* add new panel for the config option */\r
+            PanelPlugin = new TPanelPlugin( this, p_item, p_intf );\r
+            PanelPlugin->Parent = ScrollBox;\r
 \r
             /* Look for valid modules */\r
-            pp_parser = (module_t **)p_list->pp_objects;\r
-\r
-            for( ; *pp_parser ; pp_parser++ )\r
+            for( i_index = 0; i_index < list.i_count; i_index++ )\r
             {\r
-                if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) )\r
+                p_parser = (module_t *)list.p_values[i_index].p_object ;\r
+\r
+                if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )\r
                 {\r
-                    ListItem = GroupBoxPlugin->ListView->Items->Add();\r
-                    ListItem->Caption = (*pp_parser)->psz_object_name;\r
+                    AnsiString ModuleDesc;\r
+                    if ( p_parser->psz_longname != NULL ) {\r
+                        ModuleDesc = AnsiString(p_parser->psz_longname) +\r
+                            " (" + AnsiString(p_parser->psz_object_name) +\r
+                            ")";\r
+                    }\r
+                    else\r
+                        ModuleDesc = AnsiString(p_parser->psz_object_name);\r
+\r
+                    int item = PanelPlugin->CleanCheckListBox->Items->AddObject(\r
+                        ModuleDesc.c_str(),\r
+                        new TObjectString(p_parser->psz_object_name) );\r
+\r
+                    /* check the box if it's the default module */\r
+                    AnsiString Name = p_item->psz_value ?\r
+                        p_item->psz_value : "";\r
+                    if( !strcmp( p_parser->psz_object_name, Name.c_str()) )\r
+                    {\r
+                        PanelPlugin->CleanCheckListBox->Checked[item] = true;\r
+                    }\r
                 }\r
             }\r
 \r
@@ -452,55 +632,60 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
 \r
         case CONFIG_ITEM_STRING:\r
 \r
-            /* add new groupbox for the config option */\r
-            GroupBoxString = new TGroupBoxString( this, p_item );\r
-            GroupBoxString->Parent = ScrollBox;\r
-\r
-            /* add panel as separator */\r
-            ADD_PANEL;\r
+            /* add new panel for the config option */\r
+            PanelString = new TPanelString( this, p_item );\r
+            PanelString->Parent = ScrollBox;\r
 \r
             break;\r
 \r
         case CONFIG_ITEM_INTEGER:\r
 \r
-            /* add new groupbox for the config option */\r
-            GroupBoxInteger = new TGroupBoxInteger( this, p_item );\r
-            GroupBoxInteger->Parent = ScrollBox;\r
+            /* add new panel for the config option */\r
+            PanelInteger = new TPanelInteger( this, p_item );\r
+            PanelInteger->Parent = ScrollBox;\r
 \r
-            /* add panel as separator */\r
-            ADD_PANEL;\r
+            break;\r
+\r
+        case CONFIG_ITEM_FLOAT:\r
+\r
+            /* add new panel for the config option */\r
+            PanelFloat = new TPanelFloat( this, p_item );\r
+            PanelFloat->Parent = ScrollBox;\r
 \r
             break;\r
 \r
         case CONFIG_ITEM_BOOL:\r
 \r
-            /* add new groupbox for the config option */\r
-            GroupBoxBool = new TGroupBoxBool( this, p_item );\r
-            GroupBoxBool->Parent = ScrollBox;\r
-\r
-            /* add panel as separator */\r
-            ADD_PANEL;\r
+            /* add new panel for the config option */\r
+            PanelBool = new TPanelBool( this, p_item );\r
+            PanelBool->Parent = ScrollBox;\r
 \r
+            break;\r
+        default:\r
+            msg_Warn( p_intf, "unknown config type" );\r
             break;\r
         }\r
-        \r
+\r
         p_item++;\r
     }\r
     while( p_item->i_type != CONFIG_HINT_END );\r
 \r
-    /* Reorder groupboxes inside the tabsheets */\r
+    /* Reorder panels inside the tabsheets */\r
     for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ )\r
     {\r
         /* get scrollbox from the tabsheet */\r
         ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0];\r
 \r
+        /* add a panel as bottom margin */\r
+        ADD_PANEL;\r
+\r
         for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- )\r
         {\r
             ScrollBox->Controls[i_ctrl]->Align = alTop;\r
         }\r
     }\r
 \r
-    vlc_list_release( p_list );\r
+    vlc_list_release( &list );\r
 \r
     /* set active tabsheet\r
      * FIXME: i don't know why, but both lines are necessary */\r
@@ -518,7 +703,7 @@ void __fastcall TPreferencesDlg::ButtonOkClick( TObject *Sender )
 void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )\r
 {\r
     TScrollBox *ScrollBox;\r
-    TGroupBoxPref *GroupBox;\r
+    TPanelPref *Panel;\r
     int i, j;\r
 \r
     for( i = 0; i < PageControlPref->PageCount; i++ )\r
@@ -529,11 +714,11 @@ void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
         for( j = 0; j < ScrollBox->ControlCount ; j++ )\r
         {\r
             /* skip the panels */\r
-            if( ScrollBox->Controls[j]->InheritsFrom( __classid( TGroupBoxPref ) ) )\r
+            if( ScrollBox->Controls[j]->InheritsFrom( __classid( TPanelPref ) ) )\r
             {\r
-                GroupBox = (TGroupBoxPref *)ScrollBox->Controls[j];\r
-                GroupBox->UpdateChanges();\r
-                SaveValue( GroupBox->p_config );\r
+                Panel = (TPanelPref *)ScrollBox->Controls[j];\r
+                Panel->UpdateChanges();\r
+                SaveValue( Panel->p_config );\r
             }\r
         }\r
     }\r
@@ -542,7 +727,7 @@ void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
 void __fastcall TPreferencesDlg::ButtonSaveClick( TObject *Sender )\r
 {\r
     ButtonApplyClick( Sender );\r
-    config_SaveConfigFile( p_intfGlobal, NULL );\r
+    config_SaveConfigFile( p_intf, NULL );\r
 }\r
 //---------------------------------------------------------------------------\r
 void __fastcall TPreferencesDlg::ButtonCancelClick( TObject *Sender )\r
@@ -557,13 +742,18 @@ void __fastcall TPreferencesDlg::SaveValue( module_config_t *p_config )
         case CONFIG_ITEM_STRING:\r
         case CONFIG_ITEM_FILE:\r
         case CONFIG_ITEM_MODULE:\r
-            config_PutPsz( p_intfGlobal, p_config->psz_name,\r
+            config_PutPsz( p_intf, p_config->psz_name,\r
                            *p_config->psz_value ? p_config->psz_value : NULL );\r
             break;\r
         case CONFIG_ITEM_INTEGER:\r
         case CONFIG_ITEM_BOOL:\r
-            config_PutInt( p_intfGlobal, p_config->psz_name,\r
-                           p_config->i_value );\r
+            config_PutInt( p_intf, p_config->psz_name, p_config->i_value );\r
+            break;\r
+        case CONFIG_ITEM_FLOAT:\r
+            config_PutFloat( p_intf, p_config->psz_name, p_config->f_value );\r
+            break;\r
+        default:\r
+            msg_Warn( p_intf, "unknown config type" );\r
             break;\r
     }\r
 }\r