]> git.sesse.net Git - vlc/commitdiff
- allow the user to choose (and sort) several plugins for the same
authorBoris Dorès <babal@videolan.org>
Thu, 23 Jan 2003 04:50:38 +0000 (04:50 +0000)
committerBoris Dorès <babal@videolan.org>
Thu, 23 Jan 2003 04:50:38 +0000 (04:50 +0000)
  category.

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

index b269d2c2b7e2a39779613ec781cff3ed5161401c..3c1713ae738519d5b7988fe79f4216a80e757251 100644 (file)
@@ -197,9 +197,11 @@ TCSpinEdit * __fastcall TPanelPref::CreateSpinEdit( TWinControl *Parent,
  * Panel for module management\r
  ****************************************************************************/\r
 __fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,\r
-        module_config_t *p_config, intf_thread_t *_p_intf )\r
-        : TPanelPref( Owner, p_config, _p_intf )\r
+        module_config_t *p_config, intf_thread_t *_p_intf,\r
+        bool b_multi_plugins ) : TPanelPref( Owner, p_config, _p_intf )\r
 {\r
+    this->b_multi_plugins = b_multi_plugins;\r
+\r
     /* init configure button */\r
     ButtonConfig = CreateButton( this,\r
             LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH,\r
@@ -238,6 +240,35 @@ __fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,
     CleanCheckListBox->Hint = p_config->psz_longtext;\r
     CleanCheckListBox->ShowHint = true;\r
 \r
+    /* init up and down buttons */\r
+    if ( b_multi_plugins )\r
+    {\r
+        ButtonUp = CreateButton ( this, LIBWIN32_PREFSIZE_LEFT,\r
+                CleanCheckListBox->Left - LIBWIN32_PREFSIZE_HPAD\r
+                    - LIBWIN32_PREFSIZE_LEFT,\r
+                CleanCheckListBox->Top + ( CleanCheckListBox->Height\r
+                    - 2*LIBWIN32_PREFSIZE_BUTTON_HEIGHT ) / 3,\r
+                LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
+                "+" );\r
+        ButtonUp->Enabled = false;\r
+        ButtonUp->OnClick = ButtonUpClick;\r
+        ButtonUp->Hint = "Raise the plugin priority";\r
+        ButtonUp->ShowHint = true;\r
+\r
+        ButtonDown = CreateButton ( this, LIBWIN32_PREFSIZE_LEFT,\r
+                CleanCheckListBox->Left - LIBWIN32_PREFSIZE_HPAD\r
+                    - LIBWIN32_PREFSIZE_LEFT,\r
+                CleanCheckListBox->Top + ( CleanCheckListBox->Height\r
+                    - 2*LIBWIN32_PREFSIZE_BUTTON_HEIGHT ) * 2 / 3\r
+                    + LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
+                LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
+                "-" );\r
+        ButtonDown->Enabled = false;\r
+        ButtonDown->OnClick = ButtonDownClick;\r
+        ButtonDown->Hint = "Decrease the plugin priority";\r
+        ButtonDown->ShowHint = true;\r
+    }\r
+\r
     /* panel height */\r
     Height = CleanCheckListBox->Top + CleanCheckListBox->Height\r
             + LIBWIN32_PREFSIZE_VPAD;\r
@@ -252,13 +283,30 @@ void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
     /* 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
+    {\r
+        ButtonUp->Enabled = false;\r
+        ButtonDown->Enabled = false;\r
         return;\r
+    }\r
 \r
     AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->\r
         Objects[CleanCheckListBox->ItemIndex])->String().c_str();\r
     if( Name == "" )\r
         return;\r
 \r
+    /* enable up and down buttons */\r
+    if ( b_multi_plugins )\r
+    {\r
+        if ( CleanCheckListBox->ItemIndex != -1 )\r
+        {\r
+            if ( CleanCheckListBox->ItemIndex == 0 )\r
+                ButtonUp->Enabled = false; else ButtonUp->Enabled = true;\r
+            if ( CleanCheckListBox->ItemIndex\r
+                == CleanCheckListBox->Items->Count - 1 )\r
+                ButtonDown->Enabled = false; else ButtonDown->Enabled = true;\r
+        }\r
+    }\r
+\r
     /* look for module 'Name' */\r
     list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );\r
 \r
@@ -279,14 +327,17 @@ void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
 //---------------------------------------------------------------------------\r
 void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender )\r
 {\r
-    /* one item maximum must be checked */\r
-    if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )\r
+    if ( ! b_multi_plugins )\r
     {\r
-        for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
+        /* one item maximum must be checked */\r
+        if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )\r
         {\r
-            if( item != CleanCheckListBox->ItemIndex )\r
+            for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
             {\r
-                CleanCheckListBox->Checked[item] = false;\r
+                if( item != CleanCheckListBox->ItemIndex )\r
+                {\r
+                    CleanCheckListBox->Checked[item] = false;\r
+                }\r
             }\r
         }\r
     }\r
@@ -298,6 +349,65 @@ void __fastcall TPanelPlugin::ButtonConfigClick( TObject *Sender )
                         CreatePreferences( ModuleSelected->psz_object_name );\r
 }\r
 //---------------------------------------------------------------------------\r
+void __fastcall TPanelPlugin::ButtonUpClick( TObject *Sender )\r
+{\r
+    if( CleanCheckListBox->ItemIndex != -1 && CleanCheckListBox->ItemIndex > 0 )\r
+    {\r
+        int Pos = CleanCheckListBox->ItemIndex;\r
+        CleanCheckListBox->Items->Move ( Pos , Pos - 1 );\r
+        CleanCheckListBox->ItemIndex = Pos - 1;\r
+        CheckListBoxClick ( Sender );\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
+void __fastcall TPanelPlugin::ButtonDownClick( TObject *Sender )\r
+{\r
+    if( CleanCheckListBox->ItemIndex != -1\r
+        && CleanCheckListBox->ItemIndex < CleanCheckListBox->Items->Count - 1 )\r
+    {\r
+        int Pos = CleanCheckListBox->ItemIndex;\r
+        CleanCheckListBox->Items->Move ( Pos , Pos + 1 );\r
+        CleanCheckListBox->ItemIndex = Pos + 1;\r
+        CheckListBoxClick ( Sender );\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
+void __fastcall TPanelPlugin::SetValue ( AnsiString Values )\r
+{\r
+    int TopChecked = 0;\r
+    while ( Values.Length() != 0 )\r
+    {\r
+        AnsiString Value;\r
+\r
+        int NextValue = Values.Pos ( "," );\r
+        if ( NextValue == 0 )\r
+        {\r
+            Value = Values.Trim();\r
+            Values = "";\r
+        }\r
+        else\r
+        {\r
+            Value = Values.SubString(1,NextValue-1).Trim();\r
+            Values = Values.SubString ( NextValue + 1\r
+                    , Values.Length() - NextValue );\r
+        }\r
+\r
+        if ( Value.Length() > 0 )\r
+        {\r
+            for ( int i = TopChecked; i < CleanCheckListBox->Items->Count; i++ )\r
+            {\r
+                if ( ((TObjectString*)CleanCheckListBox->Items->Objects[i])\r
+                        ->String() == Value )\r
+                {\r
+                    CleanCheckListBox->Checked[i] = true;\r
+                    CleanCheckListBox->Items->Move ( i , TopChecked );\r
+                    TopChecked++;\r
+                }\r
+            }\r
+        }\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
 void __fastcall TPanelPlugin::UpdateChanges()\r
 {\r
     AnsiString Name = "";\r
@@ -307,9 +417,17 @@ void __fastcall TPanelPlugin::UpdateChanges()
     {\r
         if( CleanCheckListBox->Checked[item] )\r
         {\r
-            Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
-                   ->String();\r
-            break;\r
+            if ( Name.Length() == 0 )\r
+            {\r
+                Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
+                       ->String();\r
+            }\r
+            else\r
+            {\r
+                Name = Name + ","\r
+                     + ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
+                       ->String();\r
+            }\r
         }\r
     }\r
 \r
@@ -590,7 +708,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
         case CONFIG_ITEM_MODULE:\r
 \r
             /* add new panel for the config option */\r
-            PanelPlugin = new TPanelPlugin( this, p_item, p_intf );\r
+            PanelPlugin = new TPanelPlugin( this, p_item, p_intf, true );\r
             PanelPlugin->Parent = ScrollBox;\r
 \r
             /* Look for valid modules */\r
@@ -609,20 +727,15 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
                     else\r
                         ModuleDesc = AnsiString( p_parser->psz_object_name );\r
 \r
-                    int item = PanelPlugin->CleanCheckListBox->Items->AddObject(\r
+                    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
+            /* check relevant boxes */\r
+            PanelPlugin->SetValue ( AnsiString ( p_item->psz_value ) );\r
+\r
             break;\r
 \r
         case CONFIG_ITEM_FILE:\r
index 88764e0089b4cab7ab7954ef9e638a9ac39fbdef..00a838c7bfbd2efd538472ad3e84f5ea03a0c400 100644 (file)
@@ -91,15 +91,21 @@ class TPanelPlugin : public TPanelPref
 {\r
 public:\r
     __fastcall TPanelPlugin( TComponent* Owner, module_config_t *p_config,\r
-            intf_thread_t *_p_intf );\r
+            intf_thread_t *_p_intf, bool b_multi_plugins );\r
+    bool b_multi_plugins;\r
     TCleanCheckListBox *CleanCheckListBox;\r
     TButton *ButtonConfig;\r
+    TButton *ButtonUp;\r
+    TButton *ButtonDown;\r
     TLabel *Label;\r
     module_t *ModuleSelected;\r
+    virtual void __fastcall TPanelPlugin::SetValue ( AnsiString Values );\r
     virtual void __fastcall UpdateChanges();\r
     void __fastcall CheckListBoxClick( TObject *Sender );\r
     void __fastcall CheckListBoxClickCheck( TObject *Sender );\r
     void __fastcall ButtonConfigClick( TObject *Sender );\r
+    void __fastcall ButtonUpClick( TObject *Sender );\r
+    void __fastcall ButtonDownClick( TObject *Sender );\r
 };\r
 //---------------------------------------------------------------------------\r
 class TPanelString : public TPanelPref\r