Fix using wxStaticBoxSizer in samples

If a control is contained in a wxStaticBoxSizer or its child sizer,
wxStaticBoxSizer::GetStaticBox() should be used as the control's parent.

However, widgets and dialogs samples did not do that, which resulted in
flooding the message log in widgets sample with warnings about this; in
dialogs sample the warnings were shown in the debug output.

Fix this by always using the static box as the control's parent when the
control is contained (directly or indirectly) in a wxStaticBoxSizer.

Closes #23967.
This commit is contained in:
PB 2023-10-14 13:12:27 +02:00 committed by Vadim Zeitlin
parent cc41fa5458
commit a69fabecb1
32 changed files with 657 additions and 567 deletions

View file

@ -154,14 +154,13 @@ void HyperlinkWidgetsPage::CreateContent()
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
wxStaticBox *box = new wxStaticBox(this, wxID_ANY, "Hyperlink details");
wxStaticBoxSizer *sizerLeft = new wxStaticBoxSizer(wxVERTICAL, this, "Hyperlink details");
wxStaticBox* const sizerLeftBox = sizerLeft->GetStaticBox();
wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetLabel , "Set &Label", wxID_ANY, &m_label ),
sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetLabel , "Set &Label", wxID_ANY, &m_label, sizerLeftBox ),
0, wxALL | wxALIGN_RIGHT , 5 );
sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetURL , "Set &URL", wxID_ANY, &m_url ),
sizerLeft->Add( CreateSizerWithTextAndButton( HyperlinkPage_SetURL , "Set &URL", wxID_ANY, &m_url, sizerLeftBox ),
0, wxALL | wxALIGN_RIGHT , 5 );
static const wxString alignments[] =
@ -173,14 +172,14 @@ void HyperlinkWidgetsPage::CreateContent()
wxCOMPILE_TIME_ASSERT( WXSIZEOF(alignments) == Align_Max,
AlignMismatch );
m_radioAlignMode = new wxRadioBox(this, wxID_ANY, "alignment",
m_radioAlignMode = new wxRadioBox(sizerLeftBox, wxID_ANY, "alignment",
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(alignments), alignments);
m_radioAlignMode->SetSelection(1); // start with "centre" selected since
// wxHL_DEFAULT_STYLE contains wxHL_ALIGN_CENTRE
sizerLeft->Add(m_radioAlignMode, 0, wxALL|wxGROW, 5);
m_checkGeneric = new wxCheckBox(this, wxID_ANY, "Use generic version",
m_checkGeneric = new wxCheckBox(sizerLeftBox, wxID_ANY, "Use generic version",
wxDefaultPosition, wxDefaultSize);
sizerLeft->Add(m_checkGeneric, 0, wxALL|wxGROW, 5);