Commit 81ddbebd authored by Boris Dorès's avatar Boris Dorès

- Enterely new layout for the preference window of the native win32

  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.
parent 4c9f2398
...@@ -122,6 +122,7 @@ N: Boris Dor ...@@ -122,6 +122,7 @@ N: Boris Dor
E: babal@via.ecp.fr E: babal@via.ecp.fr
C: babal C: babal
D: Win32 network input D: Win32 network input
D: Win32 interface
S: France S: France
N: Jean-Marc Dressler N: Jean-Marc Dressler
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* *
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr> * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
* Boris Dores <babal@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -39,30 +40,73 @@ ...@@ -39,30 +40,73 @@
extern intf_thread_t *p_intfGlobal; extern intf_thread_t *p_intfGlobal;
/****************************************************************************
* A THintWindow with a limited width
****************************************************************************/
void __fastcall TNarrowHintWindow::ActivateHint(const Windows::TRect &Rect,
const System::AnsiString AHint)
{
TRect NarrowRect = CalcHintRect ( 300 , AHint , NULL );
NarrowRect.Left = Rect.Left;
NarrowRect.Top = Rect.Top;
NarrowRect.Right += Rect.Left;
NarrowRect.Bottom += Rect.Top;
THintWindow::ActivateHint ( NarrowRect , AHint );
}
/****************************************************************************
* Just a wrapper to embed an AnsiString into a TObject
****************************************************************************/
__fastcall TObjectString::TObjectString(char * String)
{
FString = AnsiString(String);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TObjectString::String()
{
return FString;
}
/****************************************************************************
* A TCheckListBox that automatically disposes any TObject
* associated with the string items
****************************************************************************/
__fastcall TCleanCheckListBox::~TCleanCheckListBox()
{
for ( int i = 0 ; i < Items->Count ; i++ )
{
if ( Items->Objects[i] != NULL ) delete Items->Objects[i];
}
}
/**************************************************************************** /****************************************************************************
* Functions to help components creation * Functions to help components creation
****************************************************************************/ ****************************************************************************/
__fastcall TGroupBoxPref::TGroupBoxPref( TComponent* Owner, __fastcall TPanelPref::TPanelPref( TComponent* Owner,
module_config_t *p_config_arg ) : TGroupBox( Owner ) module_config_t *p_config_arg ) : TPanel( Owner )
{ {
p_config = p_config_arg; p_config = p_config_arg;
Caption = p_config->psz_text; BevelInner = bvNone;
BevelOuter = bvNone;
BorderStyle = bsNone;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TCheckListBox * __fastcall TGroupBoxPref::CreateCheckListBox( TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox(
TWinControl *Parent, int Left, int Width, int Top, int Height ) TWinControl *Parent, int Left, int Width, int Top, int Height )
{ {
TCheckListBox *CheckListBox = new TCheckListBox( Parent ); TCleanCheckListBox *CleanCheckListBox = new TCleanCheckListBox( Parent );
CheckListBox->Parent = Parent; CleanCheckListBox->Parent = Parent;
CheckListBox->Left = Left; CleanCheckListBox->Left = Left;
CheckListBox->Width = Width; CleanCheckListBox->Width = Width;
CheckListBox->Top = Top; CleanCheckListBox->Top = Top;
CheckListBox->Height = Height; CleanCheckListBox->Height = Height;
return CheckListBox; return CleanCheckListBox;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent, TButton * __fastcall TPanelPref::CreateButton( TWinControl *Parent,
int Left, int Width, int Top, int Height, AnsiString Caption ) int Left, int Width, int Top, int Height, AnsiString Caption )
{ {
TButton *Button = new TButton( Parent ); TButton *Button = new TButton( Parent );
...@@ -75,7 +119,7 @@ TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent, ...@@ -75,7 +119,7 @@ TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent,
return Button; return Button;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent, TCheckBox * __fastcall TPanelPref::CreateCheckBox( TWinControl *Parent,
int Left, int Width, int Top, int Height, AnsiString Caption ) int Left, int Width, int Top, int Height, AnsiString Caption )
{ {
TCheckBox *CheckBox = new TCheckBox( Parent ); TCheckBox *CheckBox = new TCheckBox( Parent );
...@@ -88,7 +132,7 @@ TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent, ...@@ -88,7 +132,7 @@ TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent,
return CheckBox; return CheckBox;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent, TLabel * __fastcall TPanelPref::CreateLabel( TWinControl *Parent,
int Left, int Width, int Top, int Height, AnsiString Caption, int Left, int Width, int Top, int Height, AnsiString Caption,
bool WordWrap ) bool WordWrap )
{ {
...@@ -103,7 +147,7 @@ TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent, ...@@ -103,7 +147,7 @@ TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent,
return Label; return Label;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent, TEdit * __fastcall TPanelPref::CreateEdit( TWinControl *Parent,
int Left, int Width, int Top, int Height, AnsiString Text ) int Left, int Width, int Top, int Height, AnsiString Text )
{ {
TEdit *Edit = new TEdit( Parent ); TEdit *Edit = new TEdit( Parent );
...@@ -116,7 +160,7 @@ TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent, ...@@ -116,7 +160,7 @@ TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent,
return Edit; return Edit;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent, TCSpinEdit * __fastcall TPanelPref::CreateSpinEdit( TWinControl *Parent,
int Left, int Width, int Top, int Height, int Left, int Width, int Top, int Height,
long Min, long Max, long Value ) long Min, long Max, long Value )
{ {
...@@ -132,48 +176,87 @@ TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent, ...@@ -132,48 +176,87 @@ TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent,
return SpinEdit; return SpinEdit;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPref::UpdateChanges() void __fastcall TPanelPref::UpdateChanges()
{ {
} }
#define LIBWIN32_PREFSIZE_VPAD 4
#define LIBWIN32_PREFSIZE_HPAD 4
#define LIBWIN32_PREFSIZE_LEFT 16
#define LIBWIN32_PREFSIZE_EDIT_LEFT (LIBWIN32_PREFSIZE_LEFT+32)
#define LIBWIN32_PREFSIZE_WIDTH 375
#define LIBWIN32_PREFSIZE_EDIT_WIDTH (LIBWIN32_PREFSIZE_WIDTH-32)
#define LIBWIN32_PREFSIZE_BUTTON_WIDTH 150
#define LIBWIN32_PREFSIZE_SPINEDIT_WIDTH 100
#define LIBWIN32_PREFSIZE_RIGHT (LIBWIN32_PREFSIZE_LEFT+LIBWIN32_PREFSIZE_WIDTH)
#define LIBWIN32_PREFSIZE_BUTTON_HEIGHT 25
#define LIBWIN32_PREFSIZE_LABEL_HEIGHT 26
#define LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT 120
#define LIBWIN32_PREFSIZE_EDIT_HEIGHT 21
#define LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT 17
#define LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT 21
/**************************************************************************** /****************************************************************************
* GroupBox for module management * Panel for module management
****************************************************************************/ ****************************************************************************/
__fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner, __fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,
module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) module_config_t *p_config ) : TPanelPref( Owner, p_config )
{ {
/* init checklistbox */
CheckListBox = CreateCheckListBox( this, 16, 164, 24, 160 );
CheckListBox->OnClick = CheckListBoxClick;
CheckListBox->OnClickCheck = CheckListBoxClickCheck;
/* init description label */
LabelDesc = CreateLabel( this, 230, 225, 50, 52,
p_config->psz_longtext, true );
/* init hint label */
LabelHint = CreateLabel( this, 230, 225, 135, 13, "", false );
/* init configure button */ /* init configure button */
ButtonConfig = CreateButton( this, 16, 70, 192, 25, "Configure" ); ButtonConfig = CreateButton( this,
LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH,
LIBWIN32_PREFSIZE_BUTTON_WIDTH,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_BUTTON_HEIGHT,
"Configure..." );
ButtonConfig->Enabled = false; ButtonConfig->Enabled = false;
ButtonConfig->OnClick = ButtonConfigClick; ButtonConfig->OnClick = ButtonConfigClick;
Height = 233; /* init label */
AnsiString Text = AnsiString(p_config->psz_text) + ":";
Label = CreateLabel( this,
LIBWIN32_PREFSIZE_LEFT,
LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH
- LIBWIN32_PREFSIZE_HPAD,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_LABEL_HEIGHT,
Text.c_str(), true );
/* vertical alignement */
if ( ButtonConfig->Height > Label->Height )
Label->Top += ( ButtonConfig->Height - Label->Height ) / 2;
else
ButtonConfig->Top += ( Label->Height - ButtonConfig->Height ) / 2;
/* init checklistbox */
CleanCheckListBox = CreateCleanCheckListBox( this,
LIBWIN32_PREFSIZE_EDIT_LEFT,
LIBWIN32_PREFSIZE_EDIT_WIDTH,
max ( Label->Top + Label->Height , ButtonConfig->Top
+ ButtonConfig->Height ) + LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT );
CleanCheckListBox->OnClick = CheckListBoxClick;
CleanCheckListBox->OnClickCheck = CheckListBoxClickCheck;
CleanCheckListBox->Hint = p_config->psz_longtext;
CleanCheckListBox->ShowHint = true;
/* panel height */
Height = CleanCheckListBox->Top + CleanCheckListBox->Height
+ LIBWIN32_PREFSIZE_VPAD;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender ) void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
{ {
module_t **pp_parser; module_t **pp_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
/* check that the click is valid (we are on an item, and the click /* check that the click is valid (we are on an item, and the click
* started on an item */ * started on an item */
if( CheckListBox->ItemIndex == -1 ) if( CleanCheckListBox->ItemIndex == -1 )
return; return;
AnsiString Name = CheckListBox->Items->Strings[CheckListBox->ItemIndex]; AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->
Objects[CleanCheckListBox->ItemIndex])->String().c_str();
if( Name == "" ) if( Name == "" )
return; return;
...@@ -187,8 +270,6 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender ) ...@@ -187,8 +270,6 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender )
if( strcmp( (*pp_parser)->psz_object_name, Name.c_str() ) == 0 ) if( strcmp( (*pp_parser)->psz_object_name, Name.c_str() ) == 0 )
{ {
ModuleSelected = (*pp_parser); ModuleSelected = (*pp_parser);
LabelHint->Caption = (*pp_parser)->psz_longname ?
(*pp_parser)->psz_longname : "";
ButtonConfig->Enabled = ButtonConfig->Enabled =
(*pp_parser)->i_config_items ? true : false; (*pp_parser)->i_config_items ? true : false;
...@@ -197,37 +278,38 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender ) ...@@ -197,37 +278,38 @@ void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender )
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::CheckListBoxClickCheck( TObject *Sender ) void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender )
{ {
/* one item maximum must be checked */ /* one item maximum must be checked */
if( CheckListBox->Checked[CheckListBox->ItemIndex] ) if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )
{ {
for( int item = 0; item < CheckListBox->Items->Count; item++ ) for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )
{ {
if( item != CheckListBox->ItemIndex ) if( item != CleanCheckListBox->ItemIndex )
{ {
CheckListBox->Checked[item] = false; CleanCheckListBox->Checked[item] = false;
} }
} }
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender ) void __fastcall TPanelPlugin::ButtonConfigClick( TObject *Sender )
{ {
p_intfGlobal->p_sys->p_window-> p_intfGlobal->p_sys->p_window->
CreatePreferences( ModuleSelected->psz_object_name ); CreatePreferences( ModuleSelected->psz_object_name );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::UpdateChanges() void __fastcall TPanelPlugin::UpdateChanges()
{ {
AnsiString Name = ""; AnsiString Name = "";
/* find the selected plugin (if any) */ /* find the selected plugin (if any) */
for( int item = 0; item < CheckListBox->Items->Count; item++ ) for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )
{ {
if( CheckListBox->Checked[item] ) if( CleanCheckListBox->Checked[item] )
{ {
Name = CheckListBox->Items->Strings[item]; Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])
->String().c_str();
break; break;
} }
} }
...@@ -240,28 +322,38 @@ void __fastcall TGroupBoxPlugin::UpdateChanges() ...@@ -240,28 +322,38 @@ void __fastcall TGroupBoxPlugin::UpdateChanges()
/**************************************************************************** /****************************************************************************
* GroupBox for string management * Panel for string management
****************************************************************************/ ****************************************************************************/
__fastcall TGroupBoxString::TGroupBoxString( TComponent* Owner, __fastcall TPanelString::TPanelString( TComponent* Owner,
module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) module_config_t *p_config ) : TPanelPref( Owner, p_config )
{ {
/* init description label */ /* init description label */
LabelDesc = CreateLabel( this, 230, 225, 24, 26, AnsiString Text = AnsiString ( p_config->psz_text ) + ":";
p_config->psz_longtext, true ); Label = CreateLabel( this,
LIBWIN32_PREFSIZE_LEFT,
LIBWIN32_PREFSIZE_WIDTH,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_LABEL_HEIGHT,
Text.c_str(), true );
/* init edit */ /* init edit */
Edit = CreateEdit( this, 16, 164, 24, 21, "" ); Edit = CreateEdit( this,
LIBWIN32_PREFSIZE_EDIT_LEFT,
LIBWIN32_PREFSIZE_EDIT_WIDTH,
LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_EDIT_HEIGHT, "" );
vlc_mutex_lock( p_config->p_lock ); vlc_mutex_lock( p_config->p_lock );
Edit->Text = p_config->psz_value ? p_config->psz_value : ""; Edit->Text = p_config->psz_value ? p_config->psz_value : "";
vlc_mutex_unlock( p_config->p_lock ); vlc_mutex_unlock( p_config->p_lock );
Edit->Hint = p_config->psz_longtext;
Edit->ShowHint = true;
/* vertical alignment */ /* panel height */
Height = LabelDesc->Height + 24; Height = LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD
LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4; + Edit->Height + LIBWIN32_PREFSIZE_VPAD;
Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxString::UpdateChanges() void __fastcall TPanelString::UpdateChanges()
{ {
/* 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 );
...@@ -271,26 +363,44 @@ void __fastcall TGroupBoxString::UpdateChanges() ...@@ -271,26 +363,44 @@ void __fastcall TGroupBoxString::UpdateChanges()
/**************************************************************************** /****************************************************************************
* GroupBox for integer management * Panel for integer management
****************************************************************************/ ****************************************************************************/
__fastcall TGroupBoxInteger::TGroupBoxInteger( TComponent* Owner, __fastcall TPanelInteger::TPanelInteger( TComponent* Owner,
module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) module_config_t *p_config ) : TPanelPref( Owner, p_config )
{ {
/* init description label */ /* init description label */
LabelDesc = CreateLabel( this, 230, 225, 19, 26, AnsiString Text = AnsiString ( p_config->psz_text ) + ":";
p_config->psz_longtext, true ); Label = CreateLabel( this,
LIBWIN32_PREFSIZE_LEFT,
LIBWIN32_PREFSIZE_WIDTH - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH
- LIBWIN32_PREFSIZE_HPAD,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_LABEL_HEIGHT, Text.c_str(), true );
/* init spinedit */ /* init spinedit */
SpinEdit = CreateSpinEdit( this, 16, 164, 24, 21, SpinEdit = CreateSpinEdit( this,
LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,
LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT,
-1, 100000, p_config->i_value ); -1, 100000, p_config->i_value );
SpinEdit->Hint = p_config->psz_longtext;
SpinEdit->ShowHint = true;
/* vertical alignment */ /* vertical alignement and panel height */
Height = LabelDesc->Height + 24; if ( SpinEdit->Height > Label->Height )
LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4; {
SpinEdit->Top = Top + ( Height - SpinEdit->Height ) / 2 + 4; Label->Top += ( SpinEdit->Height - Label->Height ) / 2;
Height = SpinEdit->Top + SpinEdit->Height + LIBWIN32_PREFSIZE_VPAD;
}
else
{
SpinEdit->Top += ( Label->Height - SpinEdit->Height ) / 2;
Height = Label->Top + Label->Height + LIBWIN32_PREFSIZE_VPAD;
}
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxInteger::UpdateChanges() void __fastcall TPanelInteger::UpdateChanges()
{ {
/* Warning: we're casting from long to int */ /* Warning: we're casting from long to int */
p_config->i_value = (int)SpinEdit->Value; p_config->i_value = (int)SpinEdit->Value;
...@@ -298,26 +408,26 @@ void __fastcall TGroupBoxInteger::UpdateChanges() ...@@ -298,26 +408,26 @@ void __fastcall TGroupBoxInteger::UpdateChanges()
/**************************************************************************** /****************************************************************************
* GroupBox for boolean management * Panel for boolean management
****************************************************************************/ ****************************************************************************/
__fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner, __fastcall TPanelBool::TPanelBool( TComponent* Owner,
module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) module_config_t *p_config ) : TPanelPref( Owner, p_config )
{ {
/* init description label */
LabelDesc = CreateLabel( this, 230, 225, 19, 26,
p_config->psz_longtext, true );
/* init checkbox */ /* init checkbox */
CheckBox = CreateCheckBox( this, 16, 184, 28, 17, p_config->psz_text ); CheckBox = CreateCheckBox( this,
LIBWIN32_PREFSIZE_LEFT,
LIBWIN32_PREFSIZE_WIDTH,
LIBWIN32_PREFSIZE_VPAD,
LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT, p_config->psz_text );
CheckBox->Checked = p_config->i_value; CheckBox->Checked = p_config->i_value;
CheckBox->Hint = p_config->psz_longtext;
CheckBox->ShowHint = true;
/* vertical alignment */ /* panel height */
Height = LabelDesc->Height + 24; Height = LIBWIN32_PREFSIZE_VPAD + CheckBox->Height + LIBWIN32_PREFSIZE_VPAD;
LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4;
CheckBox->Top = Top + ( Height - CheckBox->Height ) / 2 + 4;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TGroupBoxBool::UpdateChanges() void __fastcall TPanelBool::UpdateChanges()
{ {
p_config->i_value = CheckBox->Checked ? 1 : 0; p_config->i_value = CheckBox->Checked ? 1 : 0;
} }
...@@ -330,6 +440,11 @@ __fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner ) ...@@ -330,6 +440,11 @@ __fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner )
: TForm( Owner ) : TForm( Owner )
{ {
Icon = p_intfGlobal->p_sys->p_window->Icon; Icon = p_intfGlobal->p_sys->p_window->Icon;
Application->HintHidePause = 0x1000000;
HintWindowClass = __classid ( TNarrowHintWindow );
/* prevent the form from being resized horizontally */
Constraints->MinWidth = Width;
Constraints->MaxWidth = Width;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::FormClose( TObject *Sender, void __fastcall TPreferencesDlg::FormClose( TObject *Sender,
...@@ -363,10 +478,10 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -363,10 +478,10 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
TTabSheet *TabSheet; TTabSheet *TabSheet;
TScrollBox *ScrollBox; TScrollBox *ScrollBox;
TPanel *Panel; TPanel *Panel;
TGroupBoxPlugin *GroupBoxPlugin; TPanelPlugin *PanelPlugin;
TGroupBoxString *GroupBoxString; TPanelString *PanelString;
TGroupBoxInteger *GroupBoxInteger; TPanelInteger *PanelInteger;
TGroupBoxBool *GroupBoxBool; TPanelBool *PanelBool;
/* 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 );
...@@ -413,16 +528,16 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -413,16 +528,16 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
ScrollBox->HorzScrollBar->Tracking = true; ScrollBox->HorzScrollBar->Tracking = true;
ScrollBox->VertScrollBar->Tracking = true; ScrollBox->VertScrollBar->Tracking = true;
/* add a panel as top margin */
ADD_PANEL;
break; break;
case CONFIG_ITEM_MODULE: case CONFIG_ITEM_MODULE:
/* add new groupbox for the config option */ /* add new panel for the config option */
GroupBoxPlugin = new TGroupBoxPlugin( this, p_item ); PanelPlugin = new TPanelPlugin( this, p_item );
GroupBoxPlugin->Parent = ScrollBox; PanelPlugin->Parent = ScrollBox;
/* add panel as separator */
ADD_PANEL;
/* Look for valid modules */ /* Look for valid modules */
pp_parser = (module_t **)p_list->pp_objects; pp_parser = (module_t **)p_list->pp_objects;
...@@ -431,15 +546,25 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -431,15 +546,25 @@ 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 ) )
{ {
int item = GroupBoxPlugin->CheckListBox->Items->Add( AnsiString ModuleDesc;
(*pp_parser)->psz_object_name ); if ( (*pp_parser)->psz_longname != NULL ) {
ModuleDesc = AnsiString((*pp_parser)->psz_longname) +
" (" + AnsiString((*pp_parser)->psz_object_name) +
")";
}
else
ModuleDesc = AnsiString((*pp_parser)->psz_object_name);
int item = PanelPlugin->CleanCheckListBox->Items->AddObject(
ModuleDesc.c_str(),
new TObjectString((*pp_parser)->psz_object_name) );
/* check the box if it's the default module */ /* check the box if it's the default module */
AnsiString Name = p_item->psz_value ? AnsiString Name = p_item->psz_value ?
p_item->psz_value : ""; p_item->psz_value : "";
if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) ) if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) )
{ {
GroupBoxPlugin->CheckListBox->Checked[item] = true; PanelPlugin->CleanCheckListBox->Checked[item] = true;
} }
} }
} }
...@@ -450,34 +575,25 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -450,34 +575,25 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
/* add new groupbox for the config option */ /* add new panel for the config option */
GroupBoxString = new TGroupBoxString( this, p_item ); PanelString = new TPanelString( this, p_item );
GroupBoxString->Parent = ScrollBox; PanelString->Parent = ScrollBox;
/* add panel as separator */
ADD_PANEL;
break; break;
case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_INTEGER:
/* add new groupbox for the config option */ /* add new panel for the config option */
GroupBoxInteger = new TGroupBoxInteger( this, p_item ); PanelInteger = new TPanelInteger( this, p_item );
GroupBoxInteger->Parent = ScrollBox; PanelInteger->Parent = ScrollBox;
/* add panel as separator */
ADD_PANEL;
break; break;
case CONFIG_ITEM_BOOL: case CONFIG_ITEM_BOOL:
/* add new groupbox for the config option */ /* add new panel for the config option */
GroupBoxBool = new TGroupBoxBool( this, p_item ); PanelBool = new TPanelBool( this, p_item );
GroupBoxBool->Parent = ScrollBox; PanelBool->Parent = ScrollBox;
/* add panel as separator */
ADD_PANEL;
break; break;
} }
...@@ -486,12 +602,15 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -486,12 +602,15 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
} }
while( p_item->i_type != CONFIG_HINT_END ); while( p_item->i_type != CONFIG_HINT_END );
/* Reorder groupboxes inside the tabsheets */ /* Reorder panels inside the tabsheets */
for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ ) for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ )
{ {
/* get scrollbox from the tabsheet */ /* get scrollbox from the tabsheet */
ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0]; ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0];
/* add a panel as bottom margin */
ADD_PANEL;
for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- ) for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- )
{ {
ScrollBox->Controls[i_ctrl]->Align = alTop; ScrollBox->Controls[i_ctrl]->Align = alTop;
...@@ -516,7 +635,7 @@ void __fastcall TPreferencesDlg::ButtonOkClick( TObject *Sender ) ...@@ -516,7 +635,7 @@ void __fastcall TPreferencesDlg::ButtonOkClick( TObject *Sender )
void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender ) void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
{ {
TScrollBox *ScrollBox; TScrollBox *ScrollBox;
TGroupBoxPref *GroupBox; TPanelPref *Panel;
int i, j; int i, j;
for( i = 0; i < PageControlPref->PageCount; i++ ) for( i = 0; i < PageControlPref->PageCount; i++ )
...@@ -527,11 +646,11 @@ void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender ) ...@@ -527,11 +646,11 @@ void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
for( j = 0; j < ScrollBox->ControlCount ; j++ ) for( j = 0; j < ScrollBox->ControlCount ; j++ )
{ {
/* skip the panels */ /* skip the panels */
if( ScrollBox->Controls[j]->InheritsFrom( __classid( TGroupBoxPref ) ) ) if( ScrollBox->Controls[j]->InheritsFrom( __classid( TPanelPref ) ) )
{ {
GroupBox = (TGroupBoxPref *)ScrollBox->Controls[j]; Panel = (TPanelPref *)ScrollBox->Controls[j];
GroupBox->UpdateChanges(); Panel->UpdateChanges();
SaveValue( GroupBox->p_config ); SaveValue( Panel->p_config );
} }
} }
} }
......
object PreferencesDlg: TPreferencesDlg object PreferencesDlg: TPreferencesDlg
Left = 309 Left = 310
Top = 124 Top = 125
Width = 522 Width = 458
Height = 582 Height = 594
Anchors = [akTop, akRight]
Caption = 'Preferences' Caption = 'Preferences'
Color = clBtnFace Color = clBtnFace
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
...@@ -249,44 +250,50 @@ object PreferencesDlg: TPreferencesDlg ...@@ -249,44 +250,50 @@ object PreferencesDlg: TPreferencesDlg
object PageControlPref: TPageControl object PageControlPref: TPageControl
Left = 8 Left = 8
Top = 8 Top = 8
Width = 497 Width = 433
Height = 497 Height = 511
TabOrder = 1 Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 0
end end
object ButtonApply: TButton object ButtonApply: TButton
Left = 146 Left = 266
Top = 520 Top = 530
Width = 105 Width = 82
Height = 25 Height = 25
Anchors = [akRight, akBottom]
Caption = 'Apply' Caption = 'Apply'
TabOrder = 0 TabOrder = 3
OnClick = ButtonApplyClick OnClick = ButtonApplyClick
end end
object ButtonSave: TButton object ButtonSave: TButton
Left = 265 Left = 359
Top = 520 Top = 530
Width = 105 Width = 82
Height = 25 Height = 25
Anchors = [akRight, akBottom]
Caption = 'Save' Caption = 'Save'
TabOrder = 2 TabOrder = 4
OnClick = ButtonSaveClick OnClick = ButtonSaveClick
end end
object ButtonOK: TButton object ButtonOK: TButton
Left = 26 Left = 81
Top = 520 Top = 530
Width = 105 Width = 82
Height = 25 Height = 25
Anchors = [akRight, akBottom]
Caption = 'OK' Caption = 'OK'
TabOrder = 3 Default = True
TabOrder = 1
OnClick = ButtonOkClick OnClick = ButtonOkClick
end end
object ButtonCancel: TButton object ButtonCancel: TButton
Left = 386 Left = 174
Top = 520 Top = 530
Width = 105 Width = 82
Height = 25 Height = 25
Anchors = [akRight, akBottom]
Caption = 'Cancel' Caption = 'Cancel'
TabOrder = 4 TabOrder = 2
OnClick = ButtonCancelClick OnClick = ButtonCancelClick
end end
end end
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* *
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr> * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
* Boris Dores <babal@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -33,13 +34,41 @@ ...@@ -33,13 +34,41 @@
#include <ExtCtrls.hpp> #include <ExtCtrls.hpp>
#include "CSPIN.h" #include "CSPIN.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TGroupBoxPref : public TGroupBox /* A TCheckListBox that automatically disposes any TObject
associated with the string items */
class TCleanCheckListBox : public TCheckListBox
{ {
public: public:
__fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg ); __fastcall TCleanCheckListBox(Classes::TComponent* AOwner)
: TCheckListBox( AOwner ) { };
virtual __fastcall ~TCleanCheckListBox();
};
//---------------------------------------------------------------------------
/* A THintWindow with a limited width */
class TNarrowHintWindow : public THintWindow
{
public:
virtual void __fastcall ActivateHint(const Windows::TRect &Rect,
const System::AnsiString AHint);
};
//---------------------------------------------------------------------------
/* Just a wrapper to embed an AnsiString into a TObject */
class TObjectString : public TObject
{
private:
AnsiString FString;
public:
__fastcall TObjectString(char * String);
AnsiString __fastcall String();
};
//---------------------------------------------------------------------------
class TPanelPref : public TPanel
{
public:
__fastcall TPanelPref( 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();
TCheckListBox * __fastcall CreateCheckListBox( TWinControl *Parent, TCleanCheckListBox * __fastcall CreateCleanCheckListBox( TWinControl *Parent,
int Left, int Width, int Top, int Height ); 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 );
...@@ -55,14 +84,13 @@ public: ...@@ -55,14 +84,13 @@ public:
long Min, long Max, long Value ); long Min, long Max, long Value );
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TGroupBoxPlugin : public TGroupBoxPref class TPanelPlugin : public TPanelPref
{ {
public: public:
__fastcall TGroupBoxPlugin( TComponent* Owner, module_config_t *p_config ); __fastcall TPanelPlugin( TComponent* Owner, module_config_t *p_config );
TCheckListBox *CheckListBox; TCleanCheckListBox *CleanCheckListBox;
TButton *ButtonConfig; TButton *ButtonConfig;
TLabel *LabelDesc; TLabel *Label;
TLabel *LabelHint;
module_t *ModuleSelected; module_t *ModuleSelected;
void __fastcall UpdateChanges(); void __fastcall UpdateChanges();
void __fastcall CheckListBoxClick( TObject *Sender ); void __fastcall CheckListBoxClick( TObject *Sender );
...@@ -70,29 +98,28 @@ public: ...@@ -70,29 +98,28 @@ public:
void __fastcall ButtonConfigClick( TObject *Sender ); void __fastcall ButtonConfigClick( TObject *Sender );
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TGroupBoxString : public TGroupBoxPref class TPanelString : public TPanelPref
{ {
public: public:
__fastcall TGroupBoxString( TComponent* Owner, module_config_t *p_config ); __fastcall TPanelString( TComponent* Owner, module_config_t *p_config );
TLabel *LabelDesc; TLabel *Label;
TEdit *Edit; TEdit *Edit;
void __fastcall UpdateChanges(); void __fastcall UpdateChanges();
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TGroupBoxInteger : public TGroupBoxPref class TPanelInteger : public TPanelPref
{ {
public: public:
__fastcall TGroupBoxInteger( TComponent* Owner, module_config_t *p_config ); __fastcall TPanelInteger( TComponent* Owner, module_config_t *p_config );
TLabel *LabelDesc; TLabel *Label;
TCSpinEdit *SpinEdit; TCSpinEdit *SpinEdit;
void __fastcall UpdateChanges(); void __fastcall UpdateChanges();
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TGroupBoxBool : public TGroupBoxPref class TPanelBool : public TPanelPref
{ {
public: public:
__fastcall TGroupBoxBool( TComponent* Owner, module_config_t *p_config ); __fastcall TPanelBool( TComponent* Owner, module_config_t *p_config );
TLabel *LabelDesc;
TCheckBox *CheckBox; TCheckBox *CheckBox;
void __fastcall UpdateChanges(); void __fastcall UpdateChanges();
}; };
......
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