Commit 82b8c862 authored by Olivier Teulière's avatar Olivier Teulière

* ./modules/gui/win32/preferences.cpp: used CheckListBoxes instead

   of ListViews, because they are more intuitive. This eliminates the
   "Select" button and the "Selected" label.

   The preferences window still needs some work though...
parent b144a5ef
...@@ -50,17 +50,16 @@ __fastcall TGroupBoxPref::TGroupBoxPref( TComponent* Owner, ...@@ -50,17 +50,16 @@ __fastcall TGroupBoxPref::TGroupBoxPref( TComponent* Owner,
Caption = p_config->psz_text; Caption = p_config->psz_text;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TListView * __fastcall TGroupBoxPref::CreateListView( TWinControl *Parent, TCheckListBox * __fastcall TGroupBoxPref::CreateCheckListBox(
int Left, int Width, int Top, int Height, TViewStyle ViewStyle ) TWinControl *Parent, int Left, int Width, int Top, int Height )
{ {
TListView *ListView = new TListView( Parent ); TCheckListBox *CheckListBox = new TCheckListBox( Parent );
ListView->Parent = Parent; CheckListBox->Parent = Parent;
ListView->ViewStyle = ViewStyle; CheckListBox->Left = Left;
ListView->Left = Left; CheckListBox->Width = Width;
ListView->Width = Width; CheckListBox->Top = Top;
ListView->Top = Top; CheckListBox->Height = Height;
ListView->Height = Height; return CheckListBox;
return ListView;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent, TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent,
...@@ -144,13 +143,10 @@ void __fastcall TGroupBoxPref::UpdateChanges() ...@@ -144,13 +143,10 @@ void __fastcall TGroupBoxPref::UpdateChanges()
__fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner, __fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner,
module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) module_config_t *p_config ) : TGroupBoxPref( Owner, p_config )
{ {
/* init listview */ /* init checklistbox */
ListView = CreateListView( this, 16, 164, 24, 160, vsReport ); CheckListBox = CreateCheckListBox( this, 16, 164, 24, 160 );
ListView->ReadOnly = true; CheckListBox->OnClick = CheckListBoxClick;
ListView->Columns->Add(); CheckListBox->OnClickCheck = CheckListBoxClickCheck;
ListView->Columns->Items[0]->Width = 160;
ListView->Columns->Items[0]->Caption = "Name";//p_config->psz_text;
ListView->OnSelectItem = ListViewSelectItem;
/* init description label */ /* init description label */
LabelDesc = CreateLabel( this, 230, 225, 50, 52, LabelDesc = CreateLabel( this, 230, 225, 50, 52,
...@@ -164,34 +160,22 @@ __fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner, ...@@ -164,34 +160,22 @@ __fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner,
ButtonConfig->Enabled = false; ButtonConfig->Enabled = false;
ButtonConfig->OnClick = ButtonConfigClick; ButtonConfig->OnClick = ButtonConfigClick;
/* init select button */
ButtonSelect = CreateButton( this, 110, 70, 192, 25, "Select" );
ButtonSelect->OnClick = ButtonSelectClick;
/* init 'Selected' label */
LabelSelected = CreateLabel( this, 230, 45, 198, 13, "Selected", false );
/* init 'Selected' edit */
Edit = CreateEdit( this, 280, 164, 194, 21, "" );
vlc_mutex_lock( p_config->p_lock );
Edit->Text = p_config->psz_value ? p_config->psz_value : "";
vlc_mutex_unlock( p_config->p_lock );
Height = 233; Height = 233;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::ListViewSelectItem( TObject *Sender, void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender )
TListItem *Item, bool Selected )
{ {
module_t **pp_parser; module_t **pp_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
AnsiString Name;
Name = Item->Caption; /* check that the click is valid (we are on an item, and the click
* started on an item */
if( CheckListBox->ItemIndex == -1 )
return;
AnsiString Name = CheckListBox->Items->Strings[CheckListBox->ItemIndex];
if( Name == "" ) if( Name == "" )
{
return; return;
}
/* look for module 'Name' */ /* look for module 'Name' */
p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE ); p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );
...@@ -205,17 +189,27 @@ void __fastcall TGroupBoxPlugin::ListViewSelectItem( TObject *Sender, ...@@ -205,17 +189,27 @@ void __fastcall TGroupBoxPlugin::ListViewSelectItem( TObject *Sender,
ModuleSelected = (*pp_parser); ModuleSelected = (*pp_parser);
LabelHint->Caption = (*pp_parser)->psz_longname ? LabelHint->Caption = (*pp_parser)->psz_longname ?
(*pp_parser)->psz_longname : ""; (*pp_parser)->psz_longname : "";
ButtonConfig->Enabled = (*pp_parser)->i_config_items ? true : false; ButtonConfig->Enabled =
(*pp_parser)->i_config_items ? true : false;
break; break;
} }
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::ButtonSelectClick( TObject *Sender ) void __fastcall TGroupBoxPlugin::CheckListBoxClickCheck( TObject *Sender )
{ {
if( !ModuleSelected ) return; /* one item maximum must be checked */
Edit->Text = ModuleSelected->psz_object_name; if( CheckListBox->Checked[CheckListBox->ItemIndex] )
{
for( int item = 0; item < CheckListBox->Items->Count; item++ )
{
if( item != CheckListBox->ItemIndex )
{
CheckListBox->Checked[item] = false;
}
}
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender ) void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender )
...@@ -226,10 +220,22 @@ void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender ) ...@@ -226,10 +220,22 @@ void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::UpdateChanges() void __fastcall TGroupBoxPlugin::UpdateChanges()
{ {
AnsiString Name = "";
/* find the selected plugin (if any) */
for( int item = 0; item < CheckListBox->Items->Count; item++ )
{
if( CheckListBox->Checked[item] )
{
Name = CheckListBox->Items->Strings[item];
break;
}
}
/* XXX: Necessary, since c_str() returns only a temporary pointer... */ /* XXX: Necessary, since c_str() returns only a temporary pointer... */
free( p_config->psz_value ); free( p_config->psz_value );
p_config->psz_value = (char *)malloc( Edit->Text.Length() + 1 ); p_config->psz_value = (char *)malloc( Name.Length() + 1 );
strcpy( p_config->psz_value, Edit->Text.c_str() ); strcpy( p_config->psz_value, Name.c_str() );
} }
...@@ -320,7 +326,6 @@ void __fastcall TGroupBoxBool::UpdateChanges() ...@@ -320,7 +326,6 @@ void __fastcall TGroupBoxBool::UpdateChanges()
/**************************************************************************** /****************************************************************************
* Callbacks for the dialog * Callbacks for the dialog
****************************************************************************/ ****************************************************************************/
//---------------------------------------------------------------------------
__fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner ) __fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner )
: TForm( Owner ) : TForm( Owner )
{ {
...@@ -332,20 +337,6 @@ void __fastcall TPreferencesDlg::FormClose( TObject *Sender, ...@@ -332,20 +337,6 @@ void __fastcall TPreferencesDlg::FormClose( TObject *Sender,
{ {
Action = caHide; Action = caHide;
} }
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::FormShow( TObject *Sender )
{
/*
p_intfGlobal->p_sys->p_window->PreferencesAction->Checked = true;
*/
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::FormHide( TObject *Sender )
{
/*
p_intfGlobal->p_sys->p_window->PreferencesAction->Checked = false;
*/
}
/**************************************************************************** /****************************************************************************
...@@ -368,7 +359,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -368,7 +359,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
module_config_t *p_item; module_config_t *p_item;
int i_pages, i_ctrl; int i_pages, i_ctrl;
TTabSheet *TabSheet; TTabSheet *TabSheet;
TScrollBox *ScrollBox; TScrollBox *ScrollBox;
TPanel *Panel; TPanel *Panel;
...@@ -376,7 +367,6 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -376,7 +367,6 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
TGroupBoxString *GroupBoxString; TGroupBoxString *GroupBoxString;
TGroupBoxInteger *GroupBoxInteger; TGroupBoxInteger *GroupBoxInteger;
TGroupBoxBool *GroupBoxBool; TGroupBoxBool *GroupBoxBool;
TListItem *ListItem;
/* Look for the selected module */ /* Look for the selected module */
p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE ); p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );
...@@ -441,8 +431,16 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -441,8 +431,16 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
{ {
if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) ) if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) )
{ {
ListItem = GroupBoxPlugin->ListView->Items->Add(); int item = GroupBoxPlugin->CheckListBox->Items->Add(
ListItem->Caption = (*pp_parser)->psz_object_name; (*pp_parser)->psz_object_name );
/* check the box if it's the default module */
AnsiString Name = p_item->psz_value ?
p_item->psz_value : "";
if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) )
{
GroupBoxPlugin->CheckListBox->Checked[item] = true;
}
} }
} }
...@@ -483,7 +481,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -483,7 +481,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
break; break;
} }
p_item++; p_item++;
} }
while( p_item->i_type != CONFIG_HINT_END ); while( p_item->i_type != CONFIG_HINT_END );
......
...@@ -244,8 +244,6 @@ object PreferencesDlg: TPreferencesDlg ...@@ -244,8 +244,6 @@ object PreferencesDlg: TPreferencesDlg
OldCreateOrder = False OldCreateOrder = False
Position = poDefaultPosOnly Position = poDefaultPosOnly
OnClose = FormClose OnClose = FormClose
OnHide = FormHide
OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object PageControlPref: TPageControl object PageControlPref: TPageControl
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <Forms.hpp> #include <Forms.hpp>
#include <Buttons.hpp> #include <Buttons.hpp>
#include <ComCtrls.hpp> #include <ComCtrls.hpp>
#include <CheckLst.hpp>
#include <ExtCtrls.hpp> #include <ExtCtrls.hpp>
#include "CSPIN.h" #include "CSPIN.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -38,8 +39,8 @@ public: ...@@ -38,8 +39,8 @@ public:
__fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg ); __fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg );
module_config_t *p_config; module_config_t *p_config;
virtual void __fastcall UpdateChanges(); virtual void __fastcall UpdateChanges();
TListView * __fastcall CreateListView( TWinControl *Parent, TCheckListBox * __fastcall CreateCheckListBox( TWinControl *Parent,
int Left, int Width, int Top, int Height, TViewStyle ViewStyle ); int Left, int Width, int Top, int Height );
TButton * __fastcall CreateButton( TWinControl *Parent, TButton * __fastcall CreateButton( TWinControl *Parent,
int Left, int Width, int Top, int Height, AnsiString Caption ); int Left, int Width, int Top, int Height, AnsiString Caption );
TCheckBox * __fastcall CreateCheckBox( TWinControl *Parent, TCheckBox * __fastcall CreateCheckBox( TWinControl *Parent,
...@@ -58,18 +59,14 @@ class TGroupBoxPlugin : public TGroupBoxPref ...@@ -58,18 +59,14 @@ class TGroupBoxPlugin : public TGroupBoxPref
{ {
public: public:
__fastcall TGroupBoxPlugin( TComponent* Owner, module_config_t *p_config ); __fastcall TGroupBoxPlugin( TComponent* Owner, module_config_t *p_config );
TListView *ListView; TCheckListBox *CheckListBox;
TButton *ButtonConfig; TButton *ButtonConfig;
TButton *ButtonSelect;
TLabel *LabelDesc; TLabel *LabelDesc;
TLabel *LabelHint; TLabel *LabelHint;
TLabel *LabelSelected;
TEdit *Edit;
module_t *ModuleSelected; module_t *ModuleSelected;
void __fastcall UpdateChanges(); void __fastcall UpdateChanges();
void __fastcall ListViewSelectItem( TObject *Sender, TListItem *Item, void __fastcall CheckListBoxClick( TObject *Sender );
bool Selected ); void __fastcall CheckListBoxClickCheck( TObject *Sender );
void __fastcall ButtonSelectClick( TObject *Sender );
void __fastcall ButtonConfigClick( TObject *Sender ); void __fastcall ButtonConfigClick( TObject *Sender );
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -108,8 +105,6 @@ __published: // IDE-managed Components ...@@ -108,8 +105,6 @@ __published: // IDE-managed Components
TButton *ButtonSave; TButton *ButtonSave;
TButton *ButtonOK; TButton *ButtonOK;
TButton *ButtonCancel; TButton *ButtonCancel;
void __fastcall FormShow( TObject *Sender );
void __fastcall FormHide( TObject *Sender );
void __fastcall ButtonOkClick( TObject *Sender ); void __fastcall ButtonOkClick( TObject *Sender );
void __fastcall ButtonApplyClick( TObject *Sender ); void __fastcall ButtonApplyClick( TObject *Sender );
void __fastcall ButtonSaveClick( TObject *Sender ); void __fastcall ButtonSaveClick( TObject *Sender );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment