X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..40730ad17db78193611389a3d12db772b28eac31:/samples/layout/layout.cpp diff --git a/samples/layout/layout.cpp b/samples/layout/layout.cpp index 41249df292..5cca8d8d71 100644 --- a/samples/layout/layout.cpp +++ b/samples/layout/layout.cpp @@ -7,7 +7,7 @@ // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart // 2005 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- @@ -31,6 +31,7 @@ #include "wx/notebook.h" #include "wx/spinctrl.h" #include "wx/wrapsizer.h" +#include "wx/generic/stattextg.h" #include "layout.h" @@ -77,9 +78,7 @@ END_EVENT_TABLE() // Define my frame constructor MyFrame::MyFrame() - : wxFrame(NULL, wxID_ANY, wxT("wxWidgets Layout Demo"), - wxPoint(30,30), wxDefaultSize, - wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) + : wxFrame(NULL, wxID_ANY, wxT("wxWidgets Layout Demo")) { SetIcon(wxICON(sample)); @@ -314,16 +313,16 @@ void MyFlexSizerFrame::InitFlexSizer(wxFlexGridSizer *sizer, wxWindow* parent) { for ( int j = 0; j < 3; j++ ) { - sizer->Add(new wxStaticText - ( - parent, - wxID_ANY, - wxString::Format(wxT("(%d, %d)"), i + 1, j + 1), - wxDefaultPosition, - wxDefaultSize, - wxALIGN_CENTER - ), - 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 3); + 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); } } } @@ -337,24 +336,24 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxString &title, int x, int y ) // 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); + 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); + 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); + 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); + sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5)); InitFlexSizer(sizerFlex, p); sizerFlex->AddGrowableCol(0, 1); sizerFlex->AddGrowableCol(1, 2); @@ -364,14 +363,14 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxString &title, int x, int y ) // 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); + 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); + sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5)); InitFlexSizer(sizerFlex, p); sizerFlex->AddGrowableCol(1); sizerFlex->AddGrowableRow(1); @@ -379,7 +378,7 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxString &title, int x, int y ) 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); + sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5)); InitFlexSizer(sizerFlex, p); sizerFlex->AddGrowableCol(1); sizerFlex->AddGrowableRow(1); @@ -388,7 +387,7 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxString &title, int x, int y ) 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); + sizerFlex = new wxFlexGridSizer(3, 3, wxSize(5, 5)); InitFlexSizer(sizerFlex, p); sizerFlex->AddGrowableCol(1); sizerFlex->AddGrowableRow(1);