Use more wxSizerFlags in widgets sample

This commit is contained in:
Maarten Bent
2019-01-27 15:23:02 +01:00
parent a6fbfacc62
commit ee752e2439
3 changed files with 35 additions and 29 deletions

View File

@@ -284,7 +284,7 @@ void ButtonWidgetsPage::CreateContent()
m_radioImagePos = new wxRadioBox(this, wxID_ANY, "Image &position", m_radioImagePos = new wxRadioBox(this, wxID_ANY, "Image &position",
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
WXSIZEOF(dirs), dirs); WXSIZEOF(dirs), dirs);
sizerLeft->Add(m_radioImagePos, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioImagePos, wxSizerFlags().Expand().Border());
sizerLeft->AddSpacer(15); sizerLeft->AddSpacer(15);
// should be in sync with enums Button[HV]Align! // should be in sync with enums Button[HV]Align!
@@ -309,13 +309,13 @@ void ButtonWidgetsPage::CreateContent()
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
WXSIZEOF(valign), valign); WXSIZEOF(valign), valign);
sizerLeft->Add(m_radioHAlign, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioHAlign, wxSizerFlags().Expand().Border());
sizerLeft->Add(m_radioVAlign, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioVAlign, wxSizerFlags().Expand().Border());
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer sizerLeft->AddSpacer(5);
wxButton *btn = new wxButton(this, ButtonPage_Reset, "&Reset"); wxButton *btn = new wxButton(this, ButtonPage_Reset, "&Reset");
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); sizerLeft->Add(btn, wxSizerFlags().CentreHorizontal().Border(wxALL, 15));
// middle pane // middle pane
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Operations"); wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Operations");
@@ -326,7 +326,7 @@ void ButtonWidgetsPage::CreateContent()
wxID_ANY, wxID_ANY,
&m_textLabel); &m_textLabel);
m_textLabel->SetValue("&Press me!"); m_textLabel->SetValue("&Press me!");
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
#if wxUSE_COMMANDLINKBUTTON #if wxUSE_COMMANDLINKBUTTON
m_sizerNote = CreateSizerWithTextAndButton(ButtonPage_ChangeNote, m_sizerNote = CreateSizerWithTextAndButton(ButtonPage_ChangeNote,
@@ -335,7 +335,7 @@ void ButtonWidgetsPage::CreateContent()
&m_textNote); &m_textNote);
m_textNote->SetValue("Writes down button clicks in the log."); m_textNote->SetValue("Writes down button clicks in the log.");
sizerMiddle->Add(m_sizerNote, 0, wxALL | wxGROW, 5); sizerMiddle->Add(m_sizerNote, wxSizerFlags().Expand().Border());
#endif #endif
// right pane // right pane
@@ -343,9 +343,12 @@ void ButtonWidgetsPage::CreateContent()
m_sizerButton->SetMinSize(150, 0); m_sizerButton->SetMinSize(150, 0);
// the 3 panes panes compose the window // the 3 panes panes compose the window
sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10); sizerTop->Add(sizerLeft,
sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10); wxSizerFlags(0).Expand().Border((wxALL & ~wxLEFT), 10));
sizerTop->Add(m_sizerButton, 1, wxGROW | (wxALL & ~wxRIGHT), 10); sizerTop->Add(sizerMiddle,
wxSizerFlags(1).Expand().Border(wxALL, 10));
sizerTop->Add(m_sizerButton,
wxSizerFlags(1).Expand().Border((wxALL & ~wxRIGHT), 10));
// do create the main control // do create the main control
Reset(); Reset();

View File

@@ -262,7 +262,7 @@ void ToggleWidgetsPage::CreateContent()
m_radioImagePos = new wxRadioBox(this, wxID_ANY, "Image &position", m_radioImagePos = new wxRadioBox(this, wxID_ANY, "Image &position",
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
WXSIZEOF(dirs), dirs); WXSIZEOF(dirs), dirs);
sizerLeft->Add(m_radioImagePos, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioImagePos, wxSizerFlags().Expand().Border());
sizerLeft->AddSpacer(15); sizerLeft->AddSpacer(15);
// should be in sync with enums Toggle[HV]Align! // should be in sync with enums Toggle[HV]Align!
@@ -287,14 +287,14 @@ void ToggleWidgetsPage::CreateContent()
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
WXSIZEOF(valign), valign); WXSIZEOF(valign), valign);
sizerLeft->Add(m_radioHAlign, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioHAlign, wxSizerFlags().Expand().Border());
sizerLeft->Add(m_radioVAlign, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioVAlign, wxSizerFlags().Expand().Border());
#endif // wxHAS_BITMAPTOGGLEBUTTON #endif // wxHAS_BITMAPTOGGLEBUTTON
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer sizerLeft->AddSpacer(5);
wxButton *btn = new wxButton(this, TogglePage_Reset, "&Reset"); wxButton *btn = new wxButton(this, TogglePage_Reset, "&Reset");
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); sizerLeft->Add(btn, wxSizerFlags().CentreHorizontal().Border(wxALL, 15));
// middle pane // middle pane
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Operations"); wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Operations");
@@ -306,16 +306,19 @@ void ToggleWidgetsPage::CreateContent()
&m_textLabel); &m_textLabel);
m_textLabel->SetValue("&Toggle me!"); m_textLabel->SetValue("&Toggle me!");
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
// right pane // right pane
m_sizerToggle = new wxBoxSizer(wxHORIZONTAL); m_sizerToggle = new wxBoxSizer(wxHORIZONTAL);
m_sizerToggle->SetMinSize(150, 0); m_sizerToggle->SetMinSize(150, 0);
// the 3 panes panes compose the window // the 3 panes panes compose the window
sizerTop->Add(sizerLeft, 0, (wxALL & ~wxLEFT), 10); sizerTop->Add(sizerLeft,
sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10); wxSizerFlags(0).Expand().Border((wxALL & ~wxLEFT), 10));
sizerTop->Add(m_sizerToggle, 1, wxGROW | (wxALL & ~wxRIGHT), 10); sizerTop->Add(sizerMiddle,
wxSizerFlags(1).Expand().Border(wxALL, 10));
sizerTop->Add(m_sizerToggle,
wxSizerFlags(1).Expand().Border((wxALL & ~wxRIGHT), 10));
// do create the main control // do create the main control
Reset(); Reset();

View File

@@ -492,7 +492,7 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
wxVERTICAL); wxVERTICAL);
m_lboxLog = new wxListBox(m_panel, wxID_ANY); m_lboxLog = new wxListBox(m_panel, wxID_ANY);
sizerDown->Add(m_lboxLog, 1, wxGROW | wxALL, 5); sizerDown->Add(m_lboxLog, wxSizerFlags(1).Expand().Border());
sizerDown->SetMinSize(100, 150); sizerDown->SetMinSize(100, 150);
#else #else
wxSizer *sizerDown = new wxBoxSizer(wxVERTICAL); wxSizer *sizerDown = new wxBoxSizer(wxVERTICAL);
@@ -503,16 +503,16 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
#if USE_LOG #if USE_LOG
btn = new wxButton(m_panel, Widgets_ClearLog, "Clear &log"); btn = new wxButton(m_panel, Widgets_ClearLog, "Clear &log");
sizerBtns->Add(btn); sizerBtns->Add(btn);
sizerBtns->Add(10, 0); // spacer sizerBtns->AddSpacer(10);
#endif // USE_LOG #endif // USE_LOG
btn = new wxButton(m_panel, Widgets_Quit, "E&xit"); btn = new wxButton(m_panel, Widgets_Quit, "E&xit");
sizerBtns->Add(btn); sizerBtns->Add(btn);
sizerDown->Add(sizerBtns, 0, wxALL | wxALIGN_RIGHT, 5); sizerDown->Add(sizerBtns, wxSizerFlags().Border().Right());
// put everything together // put everything together
sizerTop->Add(m_book, 1, wxGROW | (wxALL & ~(wxTOP | wxBOTTOM)), 10); sizerTop->Add(m_book, wxSizerFlags(1).Expand().DoubleBorder(wxALL & ~(wxTOP | wxBOTTOM)));
sizerTop->Add(0, 5, 0, wxGROW); // spacer in between sizerTop->AddSpacer(5);
sizerTop->Add(sizerDown, 0, wxGROW | (wxALL & ~wxTOP), 10); sizerTop->Add(sizerDown, wxSizerFlags(0).Expand().DoubleBorder(wxALL & ~wxTOP));
m_panel->SetSizer(sizerTop); m_panel->SetSizer(sizerTop);
@@ -1347,8 +1347,8 @@ wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString, wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
sizerRow->Add(control, 0, wxRIGHT | wxALIGN_CENTRE_VERTICAL, 5); sizerRow->Add(control, wxSizerFlags(0).Border(wxRIGHT).CentreVertical());
sizerRow->Add(text, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5); sizerRow->Add(text, wxSizerFlags(1).Border(wxLEFT).CentreVertical());
if ( ppText ) if ( ppText )
*ppText = text; *ppText = text;
@@ -1379,8 +1379,8 @@ wxCheckBox *WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer *sizer,
wxWindowID id) wxWindowID id)
{ {
wxCheckBox *checkbox = new wxCheckBox(this, id, label); wxCheckBox *checkbox = new wxCheckBox(this, id, label);
sizer->Add(checkbox, 0, wxLEFT | wxRIGHT, 5); sizer->Add(checkbox, wxSizerFlags().HorzBorder());
sizer->Add(0, 2, 0, wxGROW); // spacer sizer->AddSpacer(2);
return checkbox; return checkbox;
} }