wxGridBagSizer issue

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

wxGridBagSizer issue

Post by ONEEYEMAN »

Hi, ALL,

Here is my code:

Code: Select all

ForeignKeyDialog::ForeignKeyDialog()
{
    m_label1 = new wxStaticText( this, wxID_ANY, _( "Foreign Key Name:" ) );
    m_foreignKeyName = new wxTextCtrl( this, wxID_ANY, wxEmptyString );
    m_label3 = new wxStaticText( this, wxID_ANY, _( "Primary Key Table:" ) );
    m_primaryKeyTable = new wxComboBox( this, wxID_ANY, wxT( "" ), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxCB_READONLY );
    m_label2 = new wxStaticText( this, wxID_ANY, _( "Foreign Key Columns:" ) );
    m_foreignKeyColumns = new wxTextCtrl( this, wxID_ANY, wxEmptyString );
    m_label4 = new wxStaticText( this, wxID_ANY, _( "Primary Key Columns:" ) );
    m_primaryKeyColumns = new wxTextCtrl( this, wxID_ANY, wxEmptyString );
    m_OK = new wxButton( this, wxID_OK, _( "OK" ) );
    m_cancel = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
    m_help = new wxButton( this, wxID_HELP, _( "&Help" ) );
    m_logOnly = new wxButton( this, wxID_ANY, _( "Log Only" ) );
    m_label6 = new wxStaticText( this, wxID_ANY, _( "Select Columns:" ) );
    list_ctrl_1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
    const wxString m_onDelete_choices[] = {
        _( "Disallow if Dependent Row Exist (RESTRICT)" ),
        _( "Delete any Dependent Row (CASCADE)" ),
        _( "Set Dependent Columns to NULL (SET NULL)" ),
    };
    m_onDelete = new wxRadioBox( this, wxID_ANY, _( "On Delete of Primary Table Row" ), wxDefaultPosition, wxDefaultSize, 3, m_onDelete_choices, 1, wxRA_SPECIFY_COLS );
    do_layout();
}

ForeignKeyDialog::do_layout()
{
    wxBoxSizer* sizer_1 = new wxBoxSizer( wxHORIZONTAL );
    wxBoxSizer* sizer_2 = new wxBoxSizer( wxVERTICAL );
    wxGridBagSizer* grid_sizer_1 = new wxGridBagSizer( 5, 5 );
    wxBoxSizer *buttonSizer = new wxBoxSizer( wxVERTICAL );
    buttonSizer->Add( 5, 5, 0, wxEXPAND, 0 );
    buttonSizer->Add( m_OK, 0, wxEXPAND, 0 );
    buttonSizer->Add( 5, 5, 0, wxEXPAND, 0 );
    buttonSizer->Add( m_cancel, 0, wxEXPAND, 0 );
    buttonSizer->Add( 5, 5, 0, wxEXPAND, 0 );
    buttonSizer->Add( m_help, 0, wxEXPAND, 0 );
    buttonSizer->Add( 5, 5, 0, wxEXPAND, 0 );
    buttonSizer->Add( m_logOnly, 0, wxEXPAND, 0 );
    buttonSizer->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer_1->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer_2->Add( 5, 5, 0, wxEXPAND, 0 );
    grid_sizer_1->Add( m_label1, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_label2, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( buttonSizer, wxGBPosition( 0, 3 ), wxGBSpan( 4, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_foreignKeyName, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_primaryKeyTable, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_label3, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_label4, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_foreignKeyColumns, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_primaryKeyColumns, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_label6, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( m_onDelete, wxGBPosition( 5, 1 ), wxGBSpan( 2, 2 ), wxEXPAND );
    grid_sizer_1->Add( list_ctrl_1, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxEXPAND );
    grid_sizer_1->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer_2->Add( grid_sizer_1, 0, wxEXPAND, 0 );
    sizer_2->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer_1->Add( sizer_2, 0, wxEXPAND, 0 );
    sizer_1->Add( 5, 5, 0, wxEXPAND, 0 );
    SetSizer( sizer_1 );
    sizer_1->Fit( this );
    Layout();
}
And the result is attached.

I have 2 questions about that:

1. Is there a reason why wxRadioBox doesn't expand to fill the whole space on the right side?
2. Why the column 0 and column 1 are not the same size? I'm looking at the edit control and combo box in the first row.

This is wx 3.1 on Windows 8 with MSVC 2010 Pro.

Thank you for any hints.


Thank you.
Attachments
fk_dialog.png
fk_dialog.png (11.89 KiB) Viewed 359 times
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGridBagSizer issue

Post by doublemax »

Try adding:

Code: Select all

grid_sizer_1->AddGrowableCol(0);
grid_sizer_1->AddGrowableCol(1);
Use the source, Luke!
Post Reply