+void MyFlexSizerFrame::InitFlexSizer(wxFlexGridSizer *sizer, wxWindow* parent)
+{
+ for ( int i = 0; i < 3; i++ )
+ {
+ for ( int j = 0; j < 3; j++ )
+ {
+ wxWindow * const cell = new wxGenericStaticText
+ (
+ parent,
+ wxID_ANY,
+ wxString::Format("(%d, %d)",
+ i + 1, j + 1)
+ );
+ if ( (i + j) % 2 )
+ cell->SetBackgroundColour( *wxLIGHT_GREY );
+ sizer->Add(cell, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 3);
+ }
+ }
+}
+
+MyFlexSizerFrame::MyFlexSizerFrame(wxFrame* parent)
+ : wxFrame(parent, wxID_ANY, "Flex Sizer Test Frame")
+{
+ wxFlexGridSizer *sizerFlex;
+ wxPanel* p = new wxPanel(this, wxID_ANY);
+
+ // consttuct the first column
+ wxSizer *sizerCol1 = new wxBoxSizer(wxVERTICAL);
+ sizerCol1->Add(new wxStaticText(p, wxID_ANY, wxT("Ungrowable:")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol1->Add(new wxStaticText(p, wxID_ANY, wxT("Growable middle column:")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(1);
+ sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol1->Add(new wxStaticText(p, wxID_ANY, wxT("Growable middle row:")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableRow(1);
+ sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol1->Add(new wxStaticText(p, wxID_ANY, wxT("All growable columns:")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(0, 1);
+ sizerFlex->AddGrowableCol(1, 2);
+ sizerFlex->AddGrowableCol(2, 3);
+ sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ // the second one
+ wxSizer *sizerCol2 = new wxBoxSizer(wxVERTICAL);
+ sizerCol2->Add(new wxStaticText(p, wxID_ANY, wxT("Growable middle row and column:")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(1);
+ sizerFlex->AddGrowableRow(1);
+ sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol2->Add(new wxStaticText(p, wxID_ANY, wxT("Same with horz flex direction")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(1);
+ sizerFlex->AddGrowableRow(1);
+ sizerFlex->SetFlexibleDirection(wxHORIZONTAL);
+ sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol2->Add(new wxStaticText(p, wxID_ANY, wxT("Same with grow mode == \"none\"")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(1);
+ sizerFlex->AddGrowableRow(1);
+ sizerFlex->SetFlexibleDirection(wxHORIZONTAL);
+ sizerFlex->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE);
+ sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ sizerCol2->Add(new wxStaticText(p, wxID_ANY, wxT("Same with grow mode == \"all\"")), 0, wxCENTER | wxTOP, 20);
+ sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5));
+ InitFlexSizer(sizerFlex, p);
+ sizerFlex->AddGrowableCol(1);
+ sizerFlex->AddGrowableRow(1);
+ sizerFlex->SetFlexibleDirection(wxHORIZONTAL);
+ sizerFlex->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
+ sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10);
+
+ // add both columns to grid sizer
+ wxGridSizer *sizerTop = new wxGridSizer(2, 0, 20);
+ sizerTop->Add(sizerCol1, 1, wxEXPAND);
+ sizerTop->Add(sizerCol2, 1, wxEXPAND);
+
+ p->SetSizer(sizerTop);
+ sizerTop->SetSizeHints(this);
+}