* 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
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
/* 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
//---------------------------------------------------------------------------\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
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
{\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
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
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