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 )\r
- delete Items->Objects[i];\r
- }\r
-}\r
-\r
-\r
/****************************************************************************\r
* Functions to help components creation\r
****************************************************************************/\r
BorderStyle = bsNone;\r
}\r
//---------------------------------------------------------------------------\r
-TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox(\r
+TExtCheckListBox * __fastcall TPanelPref::CreateExtCheckListBox(\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
+ TExtCheckListBox *ExtCheckListBox = new TExtCheckListBox( Parent );\r
+ ExtCheckListBox->Parent = Parent;\r
+ ExtCheckListBox->Left = Left;\r
+ ExtCheckListBox->Width = Width;\r
+ ExtCheckListBox->Top = Top;\r
+ ExtCheckListBox->Height = Height;\r
+ return ExtCheckListBox;\r
}\r
//---------------------------------------------------------------------------\r
TButton * __fastcall TPanelPref::CreateButton( TWinControl *Parent,\r
****************************************************************************/\r
__fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,\r
module_config_t *p_config, intf_thread_t *_p_intf,\r
- bool b_multi_plugins ) : TPanelPref( Owner, p_config, _p_intf )\r
+ TStringList * ModuleNames, bool b_multi_plugins )\r
+ : TPanelPref( Owner, p_config, _p_intf )\r
{\r
this->b_multi_plugins = b_multi_plugins;\r
+ this->ModuleNames = ModuleNames;\r
\r
/* init configure button */\r
ButtonConfig = CreateButton( this,\r
ButtonConfig->Top += ( Label->Height - ButtonConfig->Height ) / 2;\r
\r
/* init checklistbox */\r
- CleanCheckListBox = CreateCleanCheckListBox( this,\r
+ ExtCheckListBox = CreateExtCheckListBox( 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
+ ExtCheckListBox->OnClick = CheckListBoxClick;\r
+ ExtCheckListBox->OnClickCheck = CheckListBoxClickCheck;\r
+ ExtCheckListBox->Hint = p_config->psz_longtext;\r
+ ExtCheckListBox->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
+ ExtCheckListBox->Left - LIBWIN32_PREFSIZE_HPAD\r
- LIBWIN32_PREFSIZE_LEFT,\r
- CleanCheckListBox->Top + ( CleanCheckListBox->Height\r
+ ExtCheckListBox->Top + ( ExtCheckListBox->Height\r
- 2*LIBWIN32_PREFSIZE_BUTTON_HEIGHT ) / 3,\r
LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
"+" );\r
ButtonUp->ShowHint = true;\r
\r
ButtonDown = CreateButton ( this, LIBWIN32_PREFSIZE_LEFT,\r
- CleanCheckListBox->Left - LIBWIN32_PREFSIZE_HPAD\r
+ ExtCheckListBox->Left - LIBWIN32_PREFSIZE_HPAD\r
- LIBWIN32_PREFSIZE_LEFT,\r
- CleanCheckListBox->Top + ( CleanCheckListBox->Height\r
+ ExtCheckListBox->Top + ( ExtCheckListBox->Height\r
- 2*LIBWIN32_PREFSIZE_BUTTON_HEIGHT ) * 2 / 3\r
+ LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
LIBWIN32_PREFSIZE_BUTTON_HEIGHT,\r
}\r
\r
/* panel height */\r
- Height = CleanCheckListBox->Top + CleanCheckListBox->Height\r
+ Height = ExtCheckListBox->Top + ExtCheckListBox->Height\r
+ LIBWIN32_PREFSIZE_VPAD;\r
};\r
//---------------------------------------------------------------------------\r
\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
+ if( ExtCheckListBox->ItemIndex == -1 )\r
{\r
if ( ButtonUp != NULL ) ButtonUp->Enabled = false;\r
if ( ButtonDown != NULL ) ButtonDown->Enabled = false;\r
return;\r
}\r
\r
- AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->\r
- Objects[CleanCheckListBox->ItemIndex])->String().c_str();\r
+ AnsiString Name = ModuleNames->Strings\r
+ [ExtCheckListBox->GetItemData(ExtCheckListBox->ItemIndex)];\r
if( Name == "" )\r
return;\r
\r
/* enable up and down buttons */\r
if ( b_multi_plugins && ButtonUp != NULL && ButtonDown != NULL )\r
{\r
- if ( CleanCheckListBox->ItemIndex == 0 )\r
+ if ( ExtCheckListBox->ItemIndex == 0 )\r
ButtonUp->Enabled = false; else ButtonUp->Enabled = true;\r
- if ( CleanCheckListBox->ItemIndex\r
- == CleanCheckListBox->Items->Count - 1 )\r
+ if ( ExtCheckListBox->ItemIndex\r
+ == ExtCheckListBox->Items->Count - 1 )\r
ButtonDown->Enabled = false; else ButtonDown->Enabled = true;\r
}\r
\r
if ( ! b_multi_plugins )\r
{\r
/* one item maximum must be checked */\r
- if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )\r
+ if( ExtCheckListBox->Checked[ExtCheckListBox->ItemIndex] )\r
{\r
- for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
+ for( int item = 0; item < ExtCheckListBox->Items->Count; item++ )\r
{\r
- if( item != CleanCheckListBox->ItemIndex )\r
+ if( item != ExtCheckListBox->ItemIndex )\r
{\r
- CleanCheckListBox->Checked[item] = false;\r
+ ExtCheckListBox->Checked[item] = false;\r
}\r
}\r
}\r
//---------------------------------------------------------------------------\r
void __fastcall TPanelPlugin::ButtonUpClick( TObject *Sender )\r
{\r
- if( CleanCheckListBox->ItemIndex != -1 && CleanCheckListBox->ItemIndex > 0 )\r
+ if( ExtCheckListBox->ItemIndex != -1 && ExtCheckListBox->ItemIndex > 0 )\r
{\r
- int Pos = CleanCheckListBox->ItemIndex;\r
- CleanCheckListBox->Items->Move ( Pos , Pos - 1 );\r
- CleanCheckListBox->ItemIndex = Pos - 1;\r
+ int Pos = ExtCheckListBox->ItemIndex;\r
+ ExtCheckListBox->Items->Move ( Pos , Pos - 1 );\r
+ ExtCheckListBox->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
+ if( ExtCheckListBox->ItemIndex != -1\r
+ && ExtCheckListBox->ItemIndex < ExtCheckListBox->Items->Count - 1 )\r
{\r
- int Pos = CleanCheckListBox->ItemIndex;\r
- CleanCheckListBox->Items->Move ( Pos , Pos + 1 );\r
- CleanCheckListBox->ItemIndex = Pos + 1;\r
+ int Pos = ExtCheckListBox->ItemIndex;\r
+ ExtCheckListBox->Items->Move ( Pos , Pos + 1 );\r
+ ExtCheckListBox->ItemIndex = Pos + 1;\r
CheckListBoxClick ( Sender );\r
}\r
}\r
\r
if ( Value.Length() > 0 )\r
{\r
- for ( int i = TopChecked; i < CleanCheckListBox->Items->Count; i++ )\r
+ for ( int i = TopChecked; i < ExtCheckListBox->Items->Count; i++ )\r
{\r
- if ( ((TObjectString*)CleanCheckListBox->Items->Objects[i])\r
- ->String() == Value )\r
+ if ( ModuleNames->Strings[ExtCheckListBox->GetItemData(i)]\r
+ == Value )\r
{\r
- CleanCheckListBox->Checked[i] = true;\r
- CleanCheckListBox->Items->Move ( i , TopChecked );\r
+ ExtCheckListBox->Checked[i] = true;\r
+ ExtCheckListBox->Items->Move ( i , TopChecked );\r
TopChecked++;\r
}\r
}\r
AnsiString Name = "";\r
\r
/* find the selected plugin (if any) */\r
- for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )\r
+ for( int item = 0; item < ExtCheckListBox->Items->Count; item++ )\r
{\r
- if( CleanCheckListBox->Checked[item] )\r
+ if( ExtCheckListBox->Checked[item] )\r
{\r
if ( Name.Length() == 0 )\r
{\r
- Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
- ->String();\r
+ Name = ModuleNames->Strings\r
+ [ExtCheckListBox->GetItemData(item)];\r
}\r
else\r
{\r
- Name = Name + ","\r
- + ((TObjectString*)CleanCheckListBox->Items->Objects[item])\r
- ->String();\r
+ Name = Name + "," + ModuleNames->Strings\r
+ [ExtCheckListBox->GetItemData(item)];\r
}\r
}\r
}\r
Icon = p_intf->p_sys->p_window->Icon;\r
Application->HintHidePause = 0x1000000;\r
HintWindowClass = __classid ( TNarrowHintWindow );\r
+ ModuleNames = new TStringList();\r
/* prevent the form from being resized horizontally */\r
Constraints->MinWidth = Width;\r
Constraints->MaxWidth = Width;\r
}\r
//---------------------------------------------------------------------------\r
+__fastcall TPreferencesDlg::~TPreferencesDlg()\r
+{\r
+ delete ModuleNames;\r
+}\r
+//---------------------------------------------------------------------------\r
void __fastcall TPreferencesDlg::FormClose( TObject *Sender,\r
TCloseAction &Action )\r
{\r
case CONFIG_ITEM_MODULE:\r
\r
/* add new panel for the config option */\r
- PanelPlugin = new TPanelPlugin( this, p_item, p_intf, true );\r
+ PanelPlugin =\r
+ new TPanelPlugin( this, p_item, p_intf, ModuleNames, true );\r
PanelPlugin->Parent = ScrollBox;\r
\r
/* Look for valid modules */\r
else\r
ModuleDesc = AnsiString( p_parser->psz_object_name );\r
\r
- PanelPlugin->CleanCheckListBox->Items->AddObject(\r
- ModuleDesc.c_str(),\r
- new TObjectString( p_parser->psz_object_name ) );\r
+ // add a reference to the module name string\r
+ // in the list item object\r
+ PanelPlugin->ExtCheckListBox->SetItemData (\r
+ PanelPlugin->ExtCheckListBox->Items->Add(ModuleDesc)\r
+ , ModuleNames->Add( p_parser->psz_object_name ) );\r
}\r
}\r
\r
#include <ExtCtrls.hpp>\r
#include "CSPIN.h"\r
//---------------------------------------------------------------------------\r
-/* A TCheckListBox that automatically disposes any TObject\r
- associated with the string items */\r
-class TCleanCheckListBox : public TCheckListBox\r
+/* A TCheckListBox that can associate an integer to each string item */\r
+class TExtCheckListBox : public TCheckListBox\r
{\r
public:\r
- __fastcall TCleanCheckListBox( Classes::TComponent* AOwner )\r
+ DYNAMIC void __fastcall SetItemData(int Index, int AData) {\r
+ TCheckListBox::SetItemData ( Index , AData );\r
+ }\r
+ DYNAMIC int __fastcall GetItemData(int Index) {\r
+ return TCheckListBox::GetItemData ( Index );\r
+ }\r
+ __fastcall TExtCheckListBox( Classes::TComponent* AOwner )\r
: TCheckListBox( AOwner ) {};\r
- virtual __fastcall ~TCleanCheckListBox();\r
};\r
//---------------------------------------------------------------------------\r
/* A THintWindow with a limited width */\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
protected:\r
module_config_t * p_config;\r
intf_thread_t * p_intf;\r
- TCleanCheckListBox * __fastcall CreateCleanCheckListBox(TWinControl *Parent,\r
+ TExtCheckListBox * __fastcall CreateExtCheckListBox(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
//---------------------------------------------------------------------------\r
class TPanelPlugin : public TPanelPref\r
{\r
+ module_t *ModuleSelected;\r
public:\r
__fastcall TPanelPlugin( TComponent* Owner, module_config_t *p_config,\r
- intf_thread_t *_p_intf, bool b_multi_plugins );\r
+ intf_thread_t *_p_intf, TStringList * ModuleNames,\r
+ bool b_multi_plugins );\r
bool b_multi_plugins;\r
- TCleanCheckListBox *CleanCheckListBox;\r
+ TExtCheckListBox *ExtCheckListBox;\r
TButton *ButtonConfig;\r
TButton *ButtonUp;\r
TButton *ButtonDown;\r
TLabel *Label;\r
- module_t *ModuleSelected;\r
+ TStringList * ModuleNames;\r
virtual void __fastcall TPanelPlugin::SetValue ( AnsiString Values );\r
virtual void __fastcall UpdateChanges();\r
void __fastcall CheckListBoxClick( TObject *Sender );\r
void __fastcall FormClose( TObject *Sender, TCloseAction &Action );\r
private: // User declarations\r
intf_thread_t *p_intf;\r
+ TStringList * ModuleNames;\r
public: // User declarations\r
__fastcall TPreferencesDlg( TComponent* Owner, intf_thread_t *_p_intf );\r
+ virtual __fastcall ~TPreferencesDlg();\r
void __fastcall CreateConfigDialog( char *psz_module_name );\r
};\r
//---------------------------------------------------------------------------\r