Simplify and fix layout of the display sample
Get rid of an unnecessary wxPanel and just create wxBookCtrl containing pages showing information about the displays directly as a child of wxFrame.
This commit is contained in:
@@ -232,9 +232,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
|
|||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
|
||||||
// create child controls
|
// create child controls
|
||||||
wxPanel *panel = new wxPanel(this, wxID_ANY);
|
m_book = new wxBookCtrl(this, wxID_ANY);
|
||||||
|
|
||||||
m_book = new wxBookCtrl(panel, wxID_ANY);
|
|
||||||
const size_t countDpy = wxDisplay::GetCount();
|
const size_t countDpy = wxDisplay::GetCount();
|
||||||
for ( size_t nDpy = 0; nDpy < countDpy; nDpy++ )
|
for ( size_t nDpy = 0; nDpy < countDpy; nDpy++ )
|
||||||
{
|
{
|
||||||
@@ -291,6 +289,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
|
|||||||
sizer->Add(new wxStaticText(page, wxID_ANY,
|
sizer->Add(new wxStaticText(page, wxID_ANY,
|
||||||
display.IsPrimary() ? "yes" : "no"));
|
display.IsPrimary() ? "yes" : "no"));
|
||||||
|
|
||||||
|
// add it to another sizer to have borders around it and button below
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
|
||||||
sizerTop->Add(sizer, 1, wxALL | wxEXPAND, 10);
|
sizerTop->Add(sizer, 1, wxALL | wxEXPAND, 10);
|
||||||
|
|
||||||
@@ -313,22 +312,19 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
|
|||||||
sizer->Add(new wxStaticText(page, Display_CurrentMode,
|
sizer->Add(new wxStaticText(page, Display_CurrentMode,
|
||||||
VideoModeToText(display.GetCurrentMode())));
|
VideoModeToText(display.GetCurrentMode())));
|
||||||
|
|
||||||
// add it to another sizer to have borders around it and button below
|
|
||||||
sizerTop->Add(new wxButton(page, Display_ResetMode, "&Reset mode"),
|
sizerTop->Add(new wxButton(page, Display_ResetMode, "&Reset mode"),
|
||||||
0, wxALL | wxCENTRE, 5);
|
0, wxALL | wxCENTRE, 5);
|
||||||
#endif // wxUSE_DISPLAY
|
#endif // wxUSE_DISPLAY
|
||||||
|
|
||||||
page->SetSizer(sizerTop);
|
page->SetSizer(sizerTop);
|
||||||
|
page->Layout();
|
||||||
|
|
||||||
m_book->AddPage(page,
|
m_book->AddPage(page,
|
||||||
wxString::Format("Display %lu",
|
wxString::Format("Display %lu",
|
||||||
(unsigned long)nDpy));
|
(unsigned long)nDpy));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
SetClientSize(m_book->GetBestSize());
|
||||||
sizer->Add(m_book, 1, wxEXPAND);
|
|
||||||
panel->SetSizer(sizer);
|
|
||||||
sizer->SetSizeHints(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_DISPLAY
|
#if wxUSE_DISPLAY
|
||||||
|
Reference in New Issue
Block a user