]> git.sesse.net Git - vlc/commitdiff
- Enterely new layout for the preference window of the native win32
authorBoris Dorès <babal@videolan.org>
Wed, 27 Nov 2002 21:51:30 +0000 (21:51 +0000)
committerBoris Dorès <babal@videolan.org>
Wed, 27 Nov 2002 21:51:30 +0000 (21:51 +0000)
  interface, in order to improve its clarity (the dialog box is now even
  a bit smaller) and to get closer to Windows standards.
  (second part of the job, and hopefully the last for now, begun with
  Ipkiss a few days ago by using CheckListBoxes)

  Still need some work to get the interface compatible with Windows XP
  skins.

AUTHORS
modules/gui/win32/preferences.cpp
modules/gui/win32/preferences.dfm
modules/gui/win32/preferences.h

diff --git a/AUTHORS b/AUTHORS
index 48338788d47b6ac496e77a13205e1a07392ecb88..8c0dc8f0c4efa94cd790eb0ecb917a5fcfa0d166 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -122,6 +122,7 @@ N: Boris Dor
 E: babal@via.ecp.fr
 C: babal
 D: Win32 network input
+D: Win32 interface
 S: France
 
 N: Jean-Marc Dressler
index f0d987a4f1f0fef8f8a56320084fb752c9c3dbfd..aa2ba098826d94ffaf74ad5b97d4fa78b9ee3831 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
 \r
 extern intf_thread_t *p_intfGlobal;\r
 \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
-TCheckListBox * __fastcall TGroupBoxPref::CreateCheckListBox(\r
+TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox(\r
     TWinControl *Parent, int Left, int Width, int Top, int Height )\r
 {\r
-    TCheckListBox *CheckListBox = new TCheckListBox( Parent );\r
-    CheckListBox->Parent = Parent;\r
-    CheckListBox->Left = Left;\r
-    CheckListBox->Width = Width;\r
-    CheckListBox->Top = Top;\r
-    CheckListBox->Height = Height;\r
-    return CheckListBox;\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
@@ -75,7 +119,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
@@ -88,7 +132,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
@@ -103,7 +147,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
@@ -116,7 +160,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
@@ -132,48 +176,87 @@ 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 ) : TPanelPref( Owner, p_config )\r
 {\r
-    /* init checklistbox */\r
-    CheckListBox = CreateCheckListBox( this, 16, 164, 24, 160 );\r
-    CheckListBox->OnClick = CheckListBoxClick;\r
-    CheckListBox->OnClickCheck = CheckListBoxClickCheck;\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
-\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
-    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::CheckListBoxClick( TObject *Sender )\r
+void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )\r
 {\r
     module_t **pp_parser;\r
     vlc_list_t *p_list;\r
 \r
     /* check that the click is valid (we are on an item, and the click\r
      * started on an item */\r
-    if( CheckListBox->ItemIndex == -1 )\r
+    if( CleanCheckListBox->ItemIndex == -1 )\r
         return;\r
 \r
-    AnsiString Name = CheckListBox->Items->Strings[CheckListBox->ItemIndex];\r
+    AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->\r
+        Objects[CleanCheckListBox->ItemIndex])->String().c_str();\r
     if( Name == "" )\r
         return;\r
 \r
@@ -187,8 +270,6 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender )
         if( strcmp( (*pp_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 =\r
                 (*pp_parser)->i_config_items ? true : false;\r
 \r
@@ -197,37 +278,38 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender )
     }\r
 }\r
 //---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::CheckListBoxClickCheck( TObject *Sender )\r
+void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender )\r
 {\r
     /* one item maximum must be checked */\r
-    if( CheckListBox->Checked[CheckListBox->ItemIndex] )\r
+    if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )\r
     {\r
-        for( int item = 0; item < CheckListBox->Items->Count; item++ )\r
+        for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
         {\r
-            if( item != CheckListBox->ItemIndex )\r
+            if( item != CleanCheckListBox->ItemIndex )\r
             {\r
-                CheckListBox->Checked[item] = false;\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
                         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 < CheckListBox->Items->Count; item++ )\r
+    for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
     {\r
-        if( CheckListBox->Checked[item] )\r
+        if( CleanCheckListBox->Checked[item] )\r
         {\r
-            Name = CheckListBox->Items->Strings[item];\r
+            Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
+                   ->String().c_str();\r
             break;\r
         }\r
     }\r
@@ -240,28 +322,38 @@ void __fastcall TGroupBoxPlugin::UpdateChanges()
 \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
@@ -271,26 +363,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
@@ -298,26 +408,26 @@ void __fastcall TGroupBoxInteger::UpdateChanges()
 \r
 \r
 /****************************************************************************\r
- * GroupBox for boolean management\r
+ * Panel for boolean management\r
  ****************************************************************************/\r
-__fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner,\r
-            module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )\r
+__fastcall TPanelBool::TPanelBool( 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
-\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
@@ -330,6 +440,11 @@ __fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner )
         : TForm( Owner )\r
 {\r
     Icon = p_intfGlobal->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
@@ -363,10 +478,10 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
     TTabSheet          *TabSheet;\r
     TScrollBox         *ScrollBox;\r
     TPanel             *Panel;\r
-    TGroupBoxPlugin    *GroupBoxPlugin;\r
-    TGroupBoxString    *GroupBoxString;\r
-    TGroupBoxInteger   *GroupBoxInteger;\r
-    TGroupBoxBool      *GroupBoxBool;\r
+    TPanelPlugin       *PanelPlugin;\r
+    TPanelString       *PanelString;\r
+    TPanelInteger      *PanelInteger;\r
+    TPanelBool         *PanelBool;\r
 \r
     /* Look for the selected module */\r
     p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );\r
@@ -413,16 +528,16 @@ 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 );\r
+            PanelPlugin->Parent = ScrollBox;\r
 \r
             /* Look for valid modules */\r
             pp_parser = (module_t **)p_list->pp_objects;\r
@@ -431,15 +546,25 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
             {\r
                 if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) )\r
                 {\r
-                    int item = GroupBoxPlugin->CheckListBox->Items->Add(\r
-                        (*pp_parser)->psz_object_name );\r
+                    AnsiString ModuleDesc;\r
+                    if ( (*pp_parser)->psz_longname != NULL ) {\r
+                        ModuleDesc = AnsiString((*pp_parser)->psz_longname) +\r
+                            " (" + AnsiString((*pp_parser)->psz_object_name) +\r
+                            ")";\r
+                    }\r
+                    else\r
+                        ModuleDesc = AnsiString((*pp_parser)->psz_object_name);\r
+\r
+                    int item = PanelPlugin->CleanCheckListBox->Items->AddObject(\r
+                        ModuleDesc.c_str(),\r
+                        new TObjectString((*pp_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( (*pp_parser)->psz_object_name, Name.c_str()) )\r
                     {\r
-                        GroupBoxPlugin->CheckListBox->Checked[item] = true;\r
+                        PanelPlugin->CleanCheckListBox->Checked[item] = true;\r
                     }\r
                 }\r
             }\r
@@ -450,34 +575,25 @@ 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
-\r
-            /* add panel as separator */\r
-            ADD_PANEL;\r
+            /* add new panel for the config option */\r
+            PanelInteger = new TPanelInteger( this, p_item );\r
+            PanelInteger->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
         }\r
@@ -486,12 +602,15 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
     }\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
@@ -516,7 +635,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
@@ -527,11 +646,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
index 585a631c3a9d725995eb2ea46f14924378eb1f15..4404d9f80a6a8a2fc61f967a57b9d24080295775 100644 (file)
@@ -1,8 +1,9 @@
 object PreferencesDlg: TPreferencesDlg\r
-  Left = 309\r
-  Top = 124\r
-  Width = 522\r
-  Height = 582\r
+  Left = 310\r
+  Top = 125\r
+  Width = 458\r
+  Height = 594\r
+  Anchors = [akTop, akRight]\r
   Caption = 'Preferences'\r
   Color = clBtnFace\r
   Font.Charset = DEFAULT_CHARSET\r
@@ -249,44 +250,50 @@ object PreferencesDlg: TPreferencesDlg
   object PageControlPref: TPageControl\r
     Left = 8\r
     Top = 8\r
-    Width = 497\r
-    Height = 497\r
-    TabOrder = 1\r
+    Width = 433\r
+    Height = 511\r
+    Anchors = [akLeft, akTop, akRight, akBottom]\r
+    TabOrder = 0\r
   end\r
   object ButtonApply: TButton\r
-    Left = 146\r
-    Top = 520\r
-    Width = 105\r
+    Left = 266\r
+    Top = 530\r
+    Width = 82\r
     Height = 25\r
+    Anchors = [akRight, akBottom]\r
     Caption = 'Apply'\r
-    TabOrder = 0\r
+    TabOrder = 3\r
     OnClick = ButtonApplyClick\r
   end\r
   object ButtonSave: TButton\r
-    Left = 265\r
-    Top = 520\r
-    Width = 105\r
+    Left = 359\r
+    Top = 530\r
+    Width = 82\r
     Height = 25\r
+    Anchors = [akRight, akBottom]\r
     Caption = 'Save'\r
-    TabOrder = 2\r
+    TabOrder = 4\r
     OnClick = ButtonSaveClick\r
   end\r
   object ButtonOK: TButton\r
-    Left = 26\r
-    Top = 520\r
-    Width = 105\r
+    Left = 81\r
+    Top = 530\r
+    Width = 82\r
     Height = 25\r
+    Anchors = [akRight, akBottom]\r
     Caption = 'OK'\r
-    TabOrder = 3\r
+    Default = True\r
+    TabOrder = 1\r
     OnClick = ButtonOkClick\r
   end\r
   object ButtonCancel: TButton\r
-    Left = 386\r
-    Top = 520\r
-    Width = 105\r
+    Left = 174\r
+    Top = 530\r
+    Width = 82\r
     Height = 25\r
+    Anchors = [akRight, akBottom]\r
     Caption = 'Cancel'\r
-    TabOrder = 4\r
+    TabOrder = 2\r
     OnClick = ButtonCancelClick\r
   end\r
 end\r
index 9445d0f2a9d642dff61a54681ff0b02a299d32c1..971a422f9e0fe933b726a8f51e9634b0fbf0802c 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
 #include <ExtCtrls.hpp>\r
 #include "CSPIN.h"\r
 //---------------------------------------------------------------------------\r
-class TGroupBoxPref : public TGroupBox\r
+/* A TCheckListBox that automatically disposes any TObject\r
+   associated with the string items */\r
+class TCleanCheckListBox : public TCheckListBox\r
 {\r
 public:\r
-    __fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg );\r
+    __fastcall TCleanCheckListBox(Classes::TComponent* AOwner)\r
+        : TCheckListBox( AOwner ) { };\r
+    virtual __fastcall ~TCleanCheckListBox();\r
+};\r
+//---------------------------------------------------------------------------\r
+/* A THintWindow with a limited width */\r
+class TNarrowHintWindow : public THintWindow\r
+{\r
+public:\r
+   virtual void __fastcall ActivateHint(const Windows::TRect &Rect,\r
+       const System::AnsiString AHint);\r
+};\r
+//---------------------------------------------------------------------------\r
+/* Just a wrapper to embed an AnsiString into a TObject */\r
+class TObjectString : public TObject\r
+{\r
+private:\r
+    AnsiString FString;\r
+public:\r
+    __fastcall TObjectString(char * String);\r
+    AnsiString __fastcall String();\r
+};\r
+//---------------------------------------------------------------------------\r
+class TPanelPref : public TPanel\r
+{\r
+public:\r
+    __fastcall TPanelPref( TComponent* Owner, module_config_t *p_config_arg );\r
     module_config_t *p_config;\r
     virtual void __fastcall UpdateChanges();\r
-    TCheckListBox * __fastcall CreateCheckListBox( TWinControl *Parent,\r
+    TCleanCheckListBox * __fastcall CreateCleanCheckListBox( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height );\r
     TButton * __fastcall CreateButton( TWinControl *Parent,\r
             int Left, int Width, int Top, int Height, AnsiString Caption );\r
@@ -55,14 +84,13 @@ public:
             long Min, long Max, long Value );\r
 };\r
 //---------------------------------------------------------------------------\r
-class TGroupBoxPlugin : public TGroupBoxPref\r
+class TPanelPlugin : public TPanelPref\r
 {\r
 public:\r
-    __fastcall TGroupBoxPlugin( TComponent* Owner, module_config_t *p_config );\r
-    TCheckListBox *CheckListBox;\r
+    __fastcall TPanelPlugin( TComponent* Owner, module_config_t *p_config );\r
+    TCleanCheckListBox *CleanCheckListBox;\r
     TButton *ButtonConfig;\r
-    TLabel *LabelDesc;\r
-    TLabel *LabelHint;\r
+    TLabel *Label;\r
     module_t *ModuleSelected;\r
     void __fastcall UpdateChanges();\r
     void __fastcall CheckListBoxClick( TObject *Sender );\r
@@ -70,29 +98,28 @@ public:
     void __fastcall ButtonConfigClick( TObject *Sender );\r
 };\r
 //---------------------------------------------------------------------------\r
-class TGroupBoxString : public TGroupBoxPref\r
+class TPanelString : public TPanelPref\r
 {\r
 public:\r
-    __fastcall TGroupBoxString( TComponent* Owner, module_config_t *p_config );\r
-    TLabel *LabelDesc;\r
+    __fastcall TPanelString( TComponent* Owner, module_config_t *p_config );\r
+    TLabel *Label;\r
     TEdit *Edit;\r
     void __fastcall UpdateChanges();\r
 };\r
 //---------------------------------------------------------------------------\r
-class TGroupBoxInteger : public TGroupBoxPref\r
+class TPanelInteger : public TPanelPref\r
 {\r
 public:\r
-    __fastcall TGroupBoxInteger( TComponent* Owner, module_config_t *p_config );\r
-    TLabel *LabelDesc;\r
+    __fastcall TPanelInteger( TComponent* Owner, module_config_t *p_config );\r
+    TLabel *Label;\r
     TCSpinEdit *SpinEdit;\r
     void __fastcall UpdateChanges();\r
 };\r
 //---------------------------------------------------------------------------\r
-class TGroupBoxBool : public TGroupBoxPref\r
+class TPanelBool : public TPanelPref\r
 {\r
 public:\r
-    __fastcall TGroupBoxBool( TComponent* Owner, module_config_t *p_config );\r
-    TLabel *LabelDesc;\r
+    __fastcall TPanelBool( TComponent* Owner, module_config_t *p_config );\r
     TCheckBox *CheckBox;\r
     void __fastcall UpdateChanges();\r
 };\r