Use a panel in internat sample to make it look better under MSW

Creating the controls directly on wxFrame is not recommended and looks
ugly under MSW due to the wrong background being used, so add an
intermediate panel.
This commit is contained in:
Vadim Zeitlin
2021-08-07 17:35:34 +01:00
parent 4db5de9cdb
commit e0cd2c637d

View File

@@ -378,16 +378,18 @@ MyFrame::MyFrame(wxLocale& locale)
// this demonstrates RTL support in wxStatusBar: // this demonstrates RTL support in wxStatusBar:
CreateStatusBar(1); CreateStatusBar(1);
wxPanel* const panel = new wxPanel(this);
// create some controls affected by the locale // create some controls affected by the locale
wxSizer* const topSizer = new wxBoxSizer(wxVERTICAL); wxSizer* const topSizer = new wxBoxSizer(wxVERTICAL);
// this demonstrates RTL layout mirroring for Arabic locales and using // this demonstrates RTL layout mirroring for Arabic locales and using
// locale-specific decimal separator in wxSpinCtrlDouble. // locale-specific decimal separator in wxSpinCtrlDouble.
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, _("Numeric input:")), sizer->Add(new wxStaticText(panel, wxID_ANY, _("Numeric input:")),
wxSizerFlags().Center().Border()); wxSizerFlags().Center().Border());
wxSpinCtrlDouble* const spin = new wxSpinCtrlDouble(this, wxID_ANY); wxSpinCtrlDouble* const spin = new wxSpinCtrlDouble(panel, wxID_ANY);
spin->SetDigits(2); spin->SetDigits(2);
spin->SetValue(12.34); spin->SetValue(12.34);
sizer->Add(spin, wxSizerFlags().Center().Border()); sizer->Add(spin, wxSizerFlags().Center().Border());
@@ -395,7 +397,7 @@ MyFrame::MyFrame(wxLocale& locale)
topSizer->Add(sizer, wxSizerFlags().Center()); topSizer->Add(sizer, wxSizerFlags().Center());
// show that week days and months names are translated too // show that week days and months names are translated too
topSizer->Add(new wxCalendarCtrl(this, wxID_ANY), topSizer->Add(new wxCalendarCtrl(panel, wxID_ANY),
wxSizerFlags().Center().Border()); wxSizerFlags().Center().Border());
// show the difference between wxString::Format() and wxNumberFormatter: // show the difference between wxString::Format() and wxNumberFormatter:
@@ -403,7 +405,7 @@ MyFrame::MyFrame(wxLocale& locale)
// locale // locale
topSizer->Add(new wxStaticText topSizer->Add(new wxStaticText
( (
this, panel,
wxID_ANY, wxID_ANY,
wxString::Format wxString::Format
( (
@@ -414,7 +416,8 @@ MyFrame::MyFrame(wxLocale& locale)
), ),
wxSizerFlags().Center().Border()); wxSizerFlags().Center().Border());
SetSizerAndFit(topSizer); panel->SetSizer(topSizer);
topSizer->SetSizeHints(this);
} }
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )