Changeset 81ddbebda3ff13dcf7539bde3280487f103c8d08

Show
Ignore:
Timestamp:
11/27/02 22:51:30 (6 years ago)
Author:
Boris Dorès <babal@videolan.org>
git-committer:
Boris Dorès <babal@videolan.org> 1038433890 +0000
git-parent:

[4c9f239846da7829947ec63cd6c87749dac6410b]

git-author:
Boris Dorès <babal@videolan.org> 1038433890 +0000
Message:

- 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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AUTHORS

    r85071f3 r81ddbeb  
    122122C: babal 
    123123D: Win32 network input 
     124D: Win32 interface 
    124125S: France 
    125126 
  • modules/gui/win32/preferences.cpp

    r82b8c86 r81ddbeb  
    55 * 
    66 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr> 
     7 *          Boris Dores <babal@via.ecp.fr> 
    78 * 
    89 * This program is free software; you can redistribute it and/or modify 
     
    4041extern intf_thread_t *p_intfGlobal; 
    4142 
     43/**************************************************************************** 
     44 * A THintWindow with a limited width 
     45 ****************************************************************************/ 
     46void __fastcall TNarrowHintWindow::ActivateHint(const Windows::TRect &Rect, 
     47    const System::AnsiString AHint) 
     48{ 
     49    TRect NarrowRect = CalcHintRect ( 300 , AHint , NULL ); 
     50    NarrowRect.Left = Rect.Left; 
     51    NarrowRect.Top = Rect.Top; 
     52    NarrowRect.Right += Rect.Left; 
     53    NarrowRect.Bottom += Rect.Top; 
     54    THintWindow::ActivateHint ( NarrowRect , AHint ); 
     55} 
     56 
     57 
     58/**************************************************************************** 
     59 * Just a wrapper to embed an AnsiString into a TObject 
     60 ****************************************************************************/ 
     61__fastcall TObjectString::TObjectString(char * String) 
     62{ 
     63    FString = AnsiString(String); 
     64} 
     65//--------------------------------------------------------------------------- 
     66AnsiString __fastcall TObjectString::String() 
     67{ 
     68    return FString; 
     69} 
     70 
     71 
     72/**************************************************************************** 
     73 * A TCheckListBox that automatically disposes any TObject 
     74 * associated with the string items 
     75 ****************************************************************************/ 
     76__fastcall TCleanCheckListBox::~TCleanCheckListBox() 
     77{ 
     78    for ( int i = 0 ; i < Items->Count ; i++ ) 
     79    { 
     80        if ( Items->Objects[i] != NULL ) delete Items->Objects[i]; 
     81    } 
     82} 
     83 
    4284 
    4385/**************************************************************************** 
    4486 * Functions to help components creation 
    4587 ****************************************************************************/ 
    46 __fastcall TGroupBoxPref::TGroupBoxPref( TComponent* Owner, 
    47             module_config_t *p_config_arg ) : TGroupBox( Owner ) 
     88__fastcall TPanelPref::TPanelPref( TComponent* Owner, 
     89            module_config_t *p_config_arg ) : TPanel( Owner ) 
    4890{ 
    4991    p_config = p_config_arg; 
    50     Caption = p_config->psz_text; 
    51 
    52 //--------------------------------------------------------------------------- 
    53 TCheckListBox * __fastcall TGroupBoxPref::CreateCheckListBox( 
     92    BevelInner = bvNone; 
     93    BevelOuter = bvNone; 
     94    BorderStyle = bsNone; 
     95
     96//--------------------------------------------------------------------------- 
     97TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox( 
    5498    TWinControl *Parent, int Left, int Width, int Top, int Height ) 
    5599{ 
    56     TCheckListBox *CheckListBox = new TCheckListBox( Parent ); 
    57     CheckListBox->Parent = Parent; 
    58     CheckListBox->Left = Left; 
    59     CheckListBox->Width = Width; 
    60     CheckListBox->Top = Top; 
    61     CheckListBox->Height = Height; 
    62     return CheckListBox; 
    63 } 
    64 //--------------------------------------------------------------------------- 
    65 TButton * __fastcall TGroupBoxPref::CreateButton( TWinControl *Parent, 
     100    TCleanCheckListBox *CleanCheckListBox = new TCleanCheckListBox( Parent ); 
     101    CleanCheckListBox->Parent = Parent; 
     102    CleanCheckListBox->Left = Left; 
     103    CleanCheckListBox->Width = Width; 
     104    CleanCheckListBox->Top = Top; 
     105    CleanCheckListBox->Height = Height; 
     106    return CleanCheckListBox; 
     107} 
     108//--------------------------------------------------------------------------- 
     109TButton * __fastcall TPanelPref::CreateButton( TWinControl *Parent, 
    66110            int Left, int Width, int Top, int Height, AnsiString Caption ) 
    67111{ 
     
    76120} 
    77121//--------------------------------------------------------------------------- 
    78 TCheckBox * __fastcall TGroupBoxPref::CreateCheckBox( TWinControl *Parent, 
     122TCheckBox * __fastcall TPanelPref::CreateCheckBox( TWinControl *Parent, 
    79123            int Left, int Width, int Top, int Height, AnsiString Caption ) 
    80124{ 
     
    89133} 
    90134//--------------------------------------------------------------------------- 
    91 TLabel * __fastcall TGroupBoxPref::CreateLabel( TWinControl *Parent, 
     135TLabel * __fastcall TPanelPref::CreateLabel( TWinControl *Parent, 
    92136            int Left, int Width, int Top, int Height, AnsiString Caption, 
    93137            bool WordWrap ) 
     
    104148} 
    105149//--------------------------------------------------------------------------- 
    106 TEdit * __fastcall TGroupBoxPref::CreateEdit( TWinControl *Parent, 
     150TEdit * __fastcall TPanelPref::CreateEdit( TWinControl *Parent, 
    107151            int Left, int Width, int Top, int Height, AnsiString Text ) 
    108152{ 
     
    117161} 
    118162//--------------------------------------------------------------------------- 
    119 TCSpinEdit * __fastcall TGroupBoxPref::CreateSpinEdit( TWinControl *Parent, 
     163TCSpinEdit * __fastcall TPanelPref::CreateSpinEdit( TWinControl *Parent, 
    120164            int Left, int Width, int Top, int Height, 
    121165            long Min, long Max, long Value ) 
     
    133177} 
    134178//--------------------------------------------------------------------------- 
    135 void __fastcall TGroupBoxPref::UpdateChanges() 
    136 
    137 
    138  
    139  
    140 /**************************************************************************** 
    141  * GroupBox for module management 
    142  ****************************************************************************/ 
    143 __fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner, 
    144             module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) 
    145 
    146     /* init checklistbox */ 
    147     CheckListBox = CreateCheckListBox( this, 16, 164, 24, 160 ); 
    148     CheckListBox->OnClick = CheckListBoxClick; 
    149     CheckListBox->OnClickCheck = CheckListBoxClickCheck; 
    150  
    151     /* init description label */ 
    152     LabelDesc = CreateLabel( this, 230, 225, 50, 52, 
    153                              p_config->psz_longtext, true ); 
    154  
    155     /* init hint label */ 
    156     LabelHint = CreateLabel( this, 230, 225, 135, 13, "", false ); 
    157  
     179void __fastcall TPanelPref::UpdateChanges() 
     180
     181
     182 
     183#define LIBWIN32_PREFSIZE_VPAD                4 
     184#define LIBWIN32_PREFSIZE_HPAD                4 
     185#define LIBWIN32_PREFSIZE_LEFT                16 
     186#define LIBWIN32_PREFSIZE_EDIT_LEFT           (LIBWIN32_PREFSIZE_LEFT+32) 
     187#define LIBWIN32_PREFSIZE_WIDTH               375 
     188#define LIBWIN32_PREFSIZE_EDIT_WIDTH          (LIBWIN32_PREFSIZE_WIDTH-32) 
     189#define LIBWIN32_PREFSIZE_BUTTON_WIDTH        150 
     190#define LIBWIN32_PREFSIZE_SPINEDIT_WIDTH      100 
     191#define LIBWIN32_PREFSIZE_RIGHT               (LIBWIN32_PREFSIZE_LEFT+LIBWIN32_PREFSIZE_WIDTH) 
     192#define LIBWIN32_PREFSIZE_BUTTON_HEIGHT       25 
     193#define LIBWIN32_PREFSIZE_LABEL_HEIGHT        26 
     194#define LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT 120 
     195#define LIBWIN32_PREFSIZE_EDIT_HEIGHT         21 
     196#define LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT     17 
     197#define LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT     21 
     198 
     199/**************************************************************************** 
     200 * Panel for module management 
     201 ****************************************************************************/ 
     202__fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner, 
     203            module_config_t *p_config ) : TPanelPref( Owner, p_config ) 
     204
    158205    /* init configure button */ 
    159     ButtonConfig = CreateButton( this, 16, 70, 192, 25, "Configure" ); 
     206    ButtonConfig = CreateButton( this, 
     207            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH, 
     208            LIBWIN32_PREFSIZE_BUTTON_WIDTH, 
     209            LIBWIN32_PREFSIZE_VPAD, 
     210            LIBWIN32_PREFSIZE_BUTTON_HEIGHT, 
     211            "Configure..." ); 
    160212    ButtonConfig->Enabled = false; 
    161213    ButtonConfig->OnClick = ButtonConfigClick; 
    162214 
    163     Height = 233; 
     215    /* init label */ 
     216    AnsiString Text = AnsiString(p_config->psz_text) + ":"; 
     217    Label = CreateLabel( this, 
     218            LIBWIN32_PREFSIZE_LEFT, 
     219            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH 
     220             - LIBWIN32_PREFSIZE_HPAD, 
     221            LIBWIN32_PREFSIZE_VPAD, 
     222            LIBWIN32_PREFSIZE_LABEL_HEIGHT, 
     223            Text.c_str(), true ); 
     224 
     225    /* vertical alignement */ 
     226    if ( ButtonConfig->Height > Label->Height ) 
     227        Label->Top += ( ButtonConfig->Height - Label->Height ) / 2; 
     228    else 
     229        ButtonConfig->Top += ( Label->Height - ButtonConfig->Height ) / 2; 
     230 
     231    /* init checklistbox */ 
     232    CleanCheckListBox = CreateCleanCheckListBox( this, 
     233            LIBWIN32_PREFSIZE_EDIT_LEFT, 
     234            LIBWIN32_PREFSIZE_EDIT_WIDTH, 
     235            max ( Label->Top + Label->Height , ButtonConfig->Top 
     236             + ButtonConfig->Height ) + LIBWIN32_PREFSIZE_VPAD, 
     237            LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT ); 
     238    CleanCheckListBox->OnClick = CheckListBoxClick; 
     239    CleanCheckListBox->OnClickCheck = CheckListBoxClickCheck; 
     240    CleanCheckListBox->Hint = p_config->psz_longtext; 
     241    CleanCheckListBox->ShowHint = true; 
     242 
     243    /* panel height */ 
     244    Height = CleanCheckListBox->Top + CleanCheckListBox->Height 
     245            + LIBWIN32_PREFSIZE_VPAD; 
    164246}; 
    165247//--------------------------------------------------------------------------- 
    166 void __fastcall TGroupBoxPlugin::CheckListBoxClick( TObject *Sender ) 
     248void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender ) 
    167249{ 
    168250    module_t **pp_parser; 
     
    171253    /* check that the click is valid (we are on an item, and the click 
    172254     * started on an item */ 
    173     if( CheckListBox->ItemIndex == -1 ) 
     255    if( CleanCheckListBox->ItemIndex == -1 ) 
    174256        return; 
    175257 
    176     AnsiString Name = CheckListBox->Items->Strings[CheckListBox->ItemIndex]; 
     258    AnsiString Name = ((TObjectString*)CleanCheckListBox->Items-> 
     259        Objects[CleanCheckListBox->ItemIndex])->String().c_str(); 
    177260    if( Name == "" ) 
    178261        return; 
     
    188271        { 
    189272            ModuleSelected = (*pp_parser); 
    190             LabelHint->Caption = (*pp_parser)->psz_longname ? 
    191                                  (*pp_parser)->psz_longname : ""; 
    192273            ButtonConfig->Enabled = 
    193274                (*pp_parser)->i_config_items ? true : false; 
     
    198279} 
    199280//--------------------------------------------------------------------------- 
    200 void __fastcall TGroupBoxPlugin::CheckListBoxClickCheck( TObject *Sender ) 
     281void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender ) 
    201282{ 
    202283    /* one item maximum must be checked */ 
    203     if( CheckListBox->Checked[CheckListBox->ItemIndex] ) 
    204     { 
    205         for( int item = 0; item < CheckListBox->Items->Count; item++ ) 
     284    if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] ) 
     285    { 
     286        for( int item = 0; item < CleanCheckListBox->Items->Count; item++ ) 
    206287        { 
    207             if( item != CheckListBox->ItemIndex ) 
     288            if( item != CleanCheckListBox->ItemIndex ) 
    208289            { 
    209                 CheckListBox->Checked[item] = false; 
     290                CleanCheckListBox->Checked[item] = false; 
    210291            } 
    211292        } 
     
    213294} 
    214295//--------------------------------------------------------------------------- 
    215 void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender ) 
     296void __fastcall TPanelPlugin::ButtonConfigClick( TObject *Sender ) 
    216297{ 
    217298    p_intfGlobal->p_sys->p_window-> 
     
    219300} 
    220301//--------------------------------------------------------------------------- 
    221 void __fastcall TGroupBoxPlugin::UpdateChanges() 
     302void __fastcall TPanelPlugin::UpdateChanges() 
    222303{ 
    223304    AnsiString Name = ""; 
    224305 
    225306    /* find the selected plugin (if any) */ 
    226     for( int item = 0; item < CheckListBox->Items->Count; item++ ) 
    227     { 
    228         if( CheckListBox->Checked[item] ) 
     307    for( int item = 0; item < CleanCheckListBox->Items->Count; item++ ) 
     308    { 
     309        if( CleanCheckListBox->Checked[item] ) 
    229310        { 
    230             Name = CheckListBox->Items->Strings[item]; 
     311            Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item]) 
     312                   ->String().c_str(); 
    231313            break; 
    232314        } 
     
    241323 
    242324/**************************************************************************** 
    243  * GroupBox for string management 
    244  ****************************************************************************/ 
    245 __fastcall TGroupBoxString::TGroupBoxString( TComponent* Owner, 
    246             module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) 
     325 * Panel for string management 
     326 ****************************************************************************/ 
     327__fastcall TPanelString::TPanelString( TComponent* Owner, 
     328            module_config_t *p_config ) : TPanelPref( Owner, p_config ) 
    247329{ 
    248330    /* init description label */ 
    249     LabelDesc = CreateLabel( this, 230, 225, 24, 26, 
    250                              p_config->psz_longtext, true ); 
     331    AnsiString Text = AnsiString ( p_config->psz_text ) + ":"; 
     332    Label = CreateLabel( this, 
     333            LIBWIN32_PREFSIZE_LEFT, 
     334            LIBWIN32_PREFSIZE_WIDTH, 
     335            LIBWIN32_PREFSIZE_VPAD, 
     336            LIBWIN32_PREFSIZE_LABEL_HEIGHT, 
     337            Text.c_str(), true ); 
    251338 
    252339    /* init edit */ 
    253     Edit = CreateEdit( this, 16, 164, 24, 21, "" ); 
     340    Edit = CreateEdit( this, 
     341            LIBWIN32_PREFSIZE_EDIT_LEFT, 
     342            LIBWIN32_PREFSIZE_EDIT_WIDTH, 
     343            LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD, 
     344            LIBWIN32_PREFSIZE_EDIT_HEIGHT, "" ); 
    254345    vlc_mutex_lock( p_config->p_lock ); 
    255346    Edit->Text = p_config->psz_value ? p_config->psz_value : ""; 
    256347    vlc_mutex_unlock( p_config->p_lock ); 
    257  
    258     /* vertical alignment */ 
    259     Height = LabelDesc->Height + 24; 
    260     LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4; 
    261     Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4; 
     348    Edit->Hint = p_config->psz_longtext; 
     349    Edit->ShowHint = true; 
     350 
     351    /* panel height */ 
     352    Height = LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD 
     353            + Edit->Height + LIBWIN32_PREFSIZE_VPAD; 
    262354}; 
    263355//--------------------------------------------------------------------------- 
    264 void __fastcall TGroupBoxString::UpdateChanges() 
     356void __fastcall TPanelString::UpdateChanges() 
    265357{ 
    266358    /* XXX: Necessary, since c_str() returns only a temporary pointer... */ 
     
    272364 
    273365/**************************************************************************** 
    274  * GroupBox for integer management 
    275  ****************************************************************************/ 
    276 __fastcall TGroupBoxInteger::TGroupBoxInteger( TComponent* Owner, 
    277             module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) 
     366 * Panel for integer management 
     367 ****************************************************************************/ 
     368__fastcall TPanelInteger::TPanelInteger( TComponent* Owner, 
     369            module_config_t *p_config ) : TPanelPref( Owner, p_config ) 
    278370{ 
    279371    /* init description label */ 
    280     LabelDesc = CreateLabel( this, 230, 225, 19, 26, 
    281                              p_config->psz_longtext, true ); 
     372    AnsiString Text = AnsiString ( p_config->psz_text ) + ":"; 
     373    Label = CreateLabel( this, 
     374            LIBWIN32_PREFSIZE_LEFT, 
     375            LIBWIN32_PREFSIZE_WIDTH - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH 
     376             - LIBWIN32_PREFSIZE_HPAD, 
     377            LIBWIN32_PREFSIZE_VPAD, 
     378            LIBWIN32_PREFSIZE_LABEL_HEIGHT, Text.c_str(), true ); 
    282379 
    283380    /* init spinedit */ 
    284     SpinEdit = CreateSpinEdit( this, 16, 164, 24, 21, 
    285                                -1, 100000, p_config->i_value ); 
    286  
    287     /* vertical alignment */ 
    288     Height = LabelDesc->Height + 24; 
    289     LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4; 
    290     SpinEdit->Top = Top + ( Height - SpinEdit->Height ) / 2 + 4; 
     381    SpinEdit = CreateSpinEdit( this, 
     382            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH, 
     383            LIBWIN32_PREFSIZE_SPINEDIT_WIDTH, 
     384            LIBWIN32_PREFSIZE_VPAD, 
     385            LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT, 
     386            -1, 100000, p_config->i_value ); 
     387    SpinEdit->Hint = p_config->psz_longtext; 
     388    SpinEdit->ShowHint = true; 
     389 
     390    /* vertical alignement and panel height */ 
     391    if ( SpinEdit->Height > Label->Height ) 
     392    { 
     393        Label->Top += ( SpinEdit->Height - Label->Height ) / 2; 
     394        Height = SpinEdit->Top + SpinEdit->Height + LIBWIN32_PREFSIZE_VPAD; 
     395    } 
     396    else 
     397    { 
     398        SpinEdit->Top += ( Label->Height - SpinEdit->Height ) / 2; 
     399        Height = Label->Top + Label->Height + LIBWIN32_PREFSIZE_VPAD; 
     400    } 
    291401}; 
    292402//--------------------------------------------------------------------------- 
    293 void __fastcall TGroupBoxInteger::UpdateChanges() 
     403void __fastcall TPanelInteger::UpdateChanges() 
    294404{ 
    295405    /* Warning: we're casting from long to int */ 
     
    299409 
    300410/**************************************************************************** 
    301  * GroupBox for boolean management 
    302  ****************************************************************************/ 
    303 __fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner, 
    304             module_config_t *p_config ) : TGroupBoxPref( Owner, p_config ) 
    305 
    306     /* init description label */ 
    307     LabelDesc = CreateLabel( this, 230, 225, 19, 26, 
    308                              p_config->psz_longtext, true ); 
    309  
     411 * Panel for boolean management 
     412 ****************************************************************************/ 
     413__fastcall TPanelBool::TPanelBool( TComponent* Owner, 
     414            module_config_t *p_config ) : TPanelPref( Owner, p_config ) 
     415
    310416    /* init checkbox */ 
    311     CheckBox = CreateCheckBox( this, 16, 184, 28, 17, p_config->psz_text ); 
     417    CheckBox = CreateCheckBox( this, 
     418            LIBWIN32_PREFSIZE_LEFT, 
     419            LIBWIN32_PREFSIZE_WIDTH, 
     420            LIBWIN32_PREFSIZE_VPAD, 
     421            LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT, p_config->psz_text ); 
    312422    CheckBox->Checked = p_config->i_value; 
    313  
    314     /* vertical alignment */ 
    315     Height = LabelDesc->Height + 24; 
    316     LabelDesc->Top = Top + ( Height - LabelDesc->Height ) / 2 + 4; 
    317     CheckBox->Top = Top + ( Height - CheckBox->Height ) / 2 + 4
     423    CheckBox->Hint = p_config->psz_longtext; 
     424    CheckBox->ShowHint = true; 
     425 
     426    /* panel height */ 
     427    Height = LIBWIN32_PREFSIZE_VPAD + CheckBox->Height + LIBWIN32_PREFSIZE_VPAD
    318428}; 
    319429//--------------------------------------------------------------------------- 
    320 void __fastcall TGroupBoxBool::UpdateChanges() 
     430void __fastcall TPanelBool::UpdateChanges() 
    321431{ 
    322432    p_config->i_value = CheckBox->Checked ? 1 : 0; 
     
    331441{ 
    332442    Icon = p_intfGlobal->p_sys->p_window->Icon; 
     443    Application->HintHidePause = 0x1000000; 
     444    HintWindowClass = __classid ( TNarrowHintWindow ); 
     445    /* prevent the form from being resized horizontally */ 
     446    Constraints->MinWidth = Width; 
     447    Constraints->MaxWidth = Width; 
    333448} 
    334449//--------------------------------------------------------------------------- 
     
    364479    TScrollBox         *ScrollBox; 
    365480    TPanel             *Panel; 
    366     TGroupBoxPlugin    *GroupBoxPlugin; 
    367     TGroupBoxString    *GroupBoxString; 
    368     TGroupBoxInteger   *GroupBoxInteger; 
    369     TGroupBoxBool      *GroupBoxBool; 
     481    TPanelPlugin       *PanelPlugin; 
     482    TPanelString       *PanelString; 
     483    TPanelInteger      *PanelInteger; 
     484    TPanelBool         *PanelBool; 
    370485 
    371486    /* Look for the selected module */ 
     
    414529            ScrollBox->VertScrollBar->Tracking = true; 
    415530 
     531            /* add a panel as top margin */ 
     532            ADD_PANEL; 
     533 
    416534            break; 
    417535 
    418536        case CONFIG_ITEM_MODULE: 
    419537 
    420             /* add new groupbox for the config option */ 
    421             GroupBoxPlugin = new TGroupBoxPlugin( this, p_item ); 
    422             GroupBoxPlugin->Parent = ScrollBox; 
    423  
    424             /* add panel as separator */ 
    425             ADD_PANEL; 
     538            /* add new panel for the config option */ 
     539            PanelPlugin = new TPanelPlugin( this, p_item ); 
     540            PanelPlugin->Parent = ScrollBox; 
    426541 
    427542            /* Look for valid modules */ 
     
    432547                if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) ) 
    433548                { 
    434                     int item = GroupBoxPlugin->CheckListBox->Items->Add( 
    435                         (*pp_parser)->psz_object_name ); 
     549                    AnsiString ModuleDesc; 
     550                    if ( (*pp_parser)->psz_longname != NULL ) { 
     551                        ModuleDesc = AnsiString((*pp_parser)->psz_longname) + 
     552                            " (" + AnsiString((*pp_parser)->psz_object_name) + 
     553                            ")"; 
     554                    } 
     555                    else 
     556                        ModuleDesc = AnsiString((*pp_parser)->psz_object_name); 
     557 
     558                    int item = PanelPlugin->CleanCheckListBox->Items->AddObject( 
     559                        ModuleDesc.c_str(), 
     560                        new TObjectString((*pp_parser)->psz_object_name) ); 
    436561 
    437562                    /* check the box if it's the default module */ 
     
    440565                    if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) ) 
    441566                    { 
    442                         GroupBoxPlugin->CheckListBox->Checked[item] = true; 
     567                        PanelPlugin->CleanCheckListBox->Checked[item] = true; 
    443568                    } 
    444569                } 
     
    451576        case CONFIG_ITEM_STRING: 
    452577 
    453             /* add new groupbox for the config option */ 
    454             GroupBoxString = new TGroupBoxString( this, p_item ); 
    455             GroupBoxString->Parent = ScrollBox; 
    456  
    457             /* add panel as separator */ 
    458             ADD_PANEL; 
     578            /* add new panel for the config option */ 
     579            PanelString = new TPanelString( this, p_item ); 
     580            PanelString->Parent = ScrollBox; 
    459581 
    460582            break; 
     
    462584        case CONFIG_ITEM_INTEGER: 
    463585 
    464             /* add new groupbox for the config option */ 
    465             GroupBoxInteger = new TGroupBoxInteger( this, p_item ); 
    466             GroupBoxInteger->Parent = ScrollBox; 
    467  
    468             /* add panel as separator */ 
    469             ADD_PANEL; 
     586            /* add new panel for the config option */ 
     587            PanelInteger = new TPanelInteger( this, p_item ); 
     588            PanelInteger->Parent = ScrollBox; 
    470589 
    471590            break; 
     
    473592        case CONFIG_ITEM_BOOL: 
    474593 
    475             /* add new groupbox for the config option */ 
    476             GroupBoxBool = new TGroupBoxBool( this, p_item ); 
    477             GroupBoxBool->Parent = ScrollBox; 
    478  
    479             /* add panel as separator */ 
    480             ADD_PANEL; 
     594            /* add new panel for the config option */ 
     595            PanelBool = new TPanelBool( this, p_item ); 
     596            PanelBool->Parent = ScrollBox; 
    481597 
    482598            break; 
     
    487603    while( p_item->i_type != CONFIG_HINT_END ); 
    488604 
    489     /* Reorder groupboxes inside the tabsheets */ 
     605    /* Reorder panels inside the tabsheets */ 
    490606    for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ ) 
    491607    { 
    492608        /* get scrollbox from the tabsheet */ 
    493609        ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0]; 
     610 
     611        /* add a panel as bottom margin */ 
     612        ADD_PANEL; 
    494613 
    495614        for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- ) 
     
    517636{ 
    518637    TScrollBox *ScrollBox; 
    519     TGroupBoxPref *GroupBox
     638    TPanelPref *Panel
    520639    int i, j; 
    521640 
     
    528647        { 
    529648            /* skip the panels */ 
    530             if( ScrollBox->Controls[j]->InheritsFrom( __classid( TGroupBoxPref ) ) ) 
     649            if( ScrollBox->Controls[j]->InheritsFrom( __classid( TPanelPref ) ) ) 
    531650            { 
    532                 GroupBox = (TGroupBoxPref *)ScrollBox->Controls[j]; 
    533                 GroupBox->UpdateChanges(); 
    534                 SaveValue( GroupBox->p_config ); 
     651                Panel = (TPanelPref *)ScrollBox->Controls[j]; 
     652                Panel->UpdateChanges(); 
     653                SaveValue( Panel->p_config ); 
    535654            } 
    536655        } 
  • modules/gui/win32/preferences.dfm

    r82b8c86 r81ddbeb  
    11object PreferencesDlg: TPreferencesDlg 
    2   Left = 309 
    3   Top = 124 
    4   Width = 522 
    5   Height = 582 
     2  Left = 310 
     3  Top = 125 
     4  Width = 458 
     5  Height = 594 
     6  Anchors = [akTop, akRight] 
    67  Caption = 'Preferences' 
    78  Color = clBtnFace 
     
    250251    Left = 8 
    251252    Top = 8 
    252     Width = 497 
    253     Height = 497 
     253    Width = 433 
     254    Height = 511 
     255    Anchors = [akLeft, akTop, akRight, akBottom] 
     256    TabOrder = 0 
     257  end 
     258  object ButtonApply: TButton 
     259    Left = 266 
     260    Top = 530 
     261    Width = 82 
     262    Height = 25 
     263    Anchors = [akRight, akBottom] 
     264    Caption = 'Apply' 
     265    TabOrder = 3 
     266    OnClick = ButtonApplyClick 
     267  end 
     268  object ButtonSave: TButton 
     269    Left = 359 
     270    Top = 530 
     271    Width = 82 
     272    Height = 25 
     273    Anchors = [akRight, akBottom] 
     274    Caption = 'Save' 
     275    TabOrder = 4 
     276    OnClick = ButtonSaveClick 
     277  end 
     278  object ButtonOK: TButton 
     279    Left = 81 
     280    Top = 530 
     281    Width = 82 
     282    Height = 25 
     283    Anchors = [akRight, akBottom] 
     284    Caption = 'OK' 
     285    Default = True 
    254286    TabOrder = 1 
    255   end 
    256   object ButtonApply: TButton 
    257     Left = 146 
    258     Top = 520 
    259     Width = 105 
    260     Height = 25 
    261     Caption = 'Apply' 
    262     TabOrder = 0 
    263     OnClick = ButtonApplyClick 
    264   end 
    265   object ButtonSave: TButton 
    266     Left = 265 
    267     Top = 520 
    268     Width = 105 
    269     Height = 25 
    270     Caption = 'Save' 
     287    OnClick = ButtonOkClick 
     288  end 
     289  object ButtonCancel: TButton 
     290    Left = 174 
     291    Top = 530 
     292    Width = 82 
     293    Height = 25 
     294    Anchors = [akRight, akBottom] 
     295    Caption = 'Cancel' 
    271296    TabOrder = 2 
    272     OnClick = ButtonSaveClick 
    273   end 
    274   object ButtonOK: TButton 
    275     Left = 26 
    276     Top = 520 
    277     Width = 105 
    278     Height = 25 
    279     Caption = 'OK' 
    280     TabOrder = 3 
    281     OnClick = ButtonOkClick 
    282   end 
    283   object ButtonCancel: TButton 
    284     Left = 386 
    285     Top = 520 
    286     Width = 105 
    287     Height = 25 
    288     Caption = 'Cancel' 
    289     TabOrder = 4 
    290297    OnClick = ButtonCancelClick 
    291298  end 
  • modules/gui/win32/preferences.h

    r82b8c86 r81ddbeb  
    55 * 
    66 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr> 
     7 *          Boris Dores <babal@via.ecp.fr> 
    78 * 
    89 * This program is free software; you can redistribute it and/or modify 
     
    3435#include "CSPIN.h" 
    3536//--------------------------------------------------------------------------- 
    36 class TGroupBoxPref : public TGroupBox 
     37/* A TCheckListBox that automatically disposes any TObject 
     38   associated with the string items */ 
     39class TCleanCheckListBox : public TCheckListBox 
    3740{ 
    3841public: 
    39     __fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg ); 
     42    __fastcall TCleanCheckListBox(Classes::TComponent* AOwner) 
     43        : TCheckListBox( AOwner ) { }; 
     44    virtual __fastcall ~TCleanCheckListBox(); 
     45}; 
     46//--------------------------------------------------------------------------- 
     47/* A THintWindow with a limited width */ 
     48class TNarrowHintWindow : public THintWindow 
     49
     50public: 
     51   virtual void __fastcall ActivateHint(const Windows::TRect &Rect, 
     52       const System::AnsiString AHint); 
     53}; 
     54//--------------------------------------------------------------------------- 
     55/* Just a wrapper to embed an AnsiString into a TObject */ 
     56class TObjectString : public TObject 
     57
     58private: 
     59    AnsiString FString; 
     60public: 
     61    __fastcall TObjectString(char * String); 
     62    AnsiString __fastcall String(); 
     63}; 
     64//--------------------------------------------------------------------------- 
     65class TPanelPref : public TPanel 
     66
     67public: 
     68    __fastcall TPanelPref( TComponent* Owner, module_config_t *p_config_arg ); 
    4069    module_config_t *p_config; 
    4170    virtual void __fastcall UpdateChanges(); 
    42     TCheckListBox * __fastcall CreateCheckListBox( TWinControl *Parent, 
     71    TCleanCheckListBox * __fastcall CreateCleanCheckListBox( TWinControl *Parent, 
    4372            int Left, int Width, int Top, int Height ); 
    4473    TButton * __fastcall CreateButton( TWinControl *Parent, 
     
    5685}; 
    5786//--------------------------------------------------------------------------- 
    58 class TGroupBoxPlugin : public TGroupBoxPref 
     87class TPanelPlugin : public TPanelPref 
    5988{ 
    6089public: 
    61     __fastcall TGroupBoxPlugin( TComponent* Owner, module_config_t *p_config ); 
    62     TCheckListBox *CheckListBox; 
     90    __fastcall TPanelPlugin( TComponent* Owner, module_config_t *p_config ); 
     91    TCleanCheckListBox *CleanCheckListBox; 
    6392    TButton *ButtonConfig; 
    64     TLabel *LabelDesc; 
    65     TLabel *LabelHint; 
     93    TLabel *Label; 
    6694    module_t *ModuleSelected; 
    6795    void __fastcall UpdateChanges(); 
     
    7199}; 
    72100//--------------------------------------------------------------------------- 
    73 class TGroupBoxString : public TGroupBoxPref 
     101class TPanelString : public TPanelPref 
    74102{ 
    75103public: 
    76     __fastcall TGroupBoxString( TComponent* Owner, module_config_t *p_config ); 
    77     TLabel *LabelDesc
     104    __fastcall TPanelString( TComponent* Owner, module_config_t *p_config ); 
     105    TLabel *Label
    78106    TEdit *Edit; 
    79107    void __fastcall UpdateChanges(); 
    80108}; 
    81109//--------------------------------------------------------------------------- 
    82 class TGroupBoxInteger : public TGroupBoxPref 
     110class TPanelInteger : public TPanelPref 
    83111{ 
    84112public: 
    85     __fastcall TGroupBoxInteger( TComponent* Owner, module_config_t *p_config ); 
    86     TLabel *LabelDesc
     113    __fastcall TPanelInteger( TComponent* Owner, module_config_t *p_config ); 
     114    TLabel *Label
    87115    TCSpinEdit *SpinEdit; 
    88116    void __fastcall UpdateChanges(); 
    89117}; 
    90118//--------------------------------------------------------------------------- 
    91 class TGroupBoxBool : public TGroupBoxPref 
     119class TPanelBool : public TPanelPref 
    92120{ 
    93121public: 
    94     __fastcall TGroupBoxBool( TComponent* Owner, module_config_t *p_config ); 
    95     TLabel *LabelDesc; 
     122    __fastcall TPanelBool( TComponent* Owner, module_config_t *p_config ); 
    96123    TCheckBox *CheckBox; 
    97124    void __fastcall UpdateChanges();