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:
parent
cc41fa5458
commit
a69fabecb1
32 changed files with 657 additions and 567 deletions
|
|
@ -514,11 +514,11 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
|
|||
|
||||
// the lower one only has the log listbox and a button to clear it
|
||||
#if USE_LOG
|
||||
wxSizer *sizerDown = new wxStaticBoxSizer(
|
||||
wxStaticBoxSizer *sizerDown = new wxStaticBoxSizer(
|
||||
new wxStaticBox( m_panel, wxID_ANY, "&Log window" ),
|
||||
wxVERTICAL);
|
||||
|
||||
m_lboxLog = new wxListBox(m_panel, wxID_ANY);
|
||||
m_lboxLog = new wxListBox(sizerDown->GetStaticBox(), wxID_ANY);
|
||||
sizerDown->Add(m_lboxLog, wxSizerFlags(1).Expand().Border());
|
||||
sizerDown->SetMinSize(100, 150);
|
||||
#else
|
||||
|
|
@ -1391,7 +1391,7 @@ wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
|
|||
wxTextCtrl **ppText)
|
||||
{
|
||||
wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString,
|
||||
wxTextCtrl *text = new wxTextCtrl(control->GetParent(), id, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||
|
||||
sizerRow->Add(control, wxSizerFlags(0).Border(wxRIGHT).CentreVertical());
|
||||
|
|
@ -1406,9 +1406,10 @@ wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
|
|||
// create a sizer containing a label and a text ctrl
|
||||
wxSizer *WidgetsPage::CreateSizerWithTextAndLabel(const wxString& label,
|
||||
wxWindowID id,
|
||||
wxTextCtrl **ppText)
|
||||
wxTextCtrl **ppText,
|
||||
wxWindow* statBoxParent)
|
||||
{
|
||||
return CreateSizerWithText(new wxStaticText(this, wxID_ANY, label),
|
||||
return CreateSizerWithText(new wxStaticText(statBoxParent ? statBoxParent: this, wxID_ANY, label),
|
||||
id, ppText);
|
||||
}
|
||||
|
||||
|
|
@ -1416,16 +1417,18 @@ wxSizer *WidgetsPage::CreateSizerWithTextAndLabel(const wxString& label,
|
|||
wxSizer *WidgetsPage::CreateSizerWithTextAndButton(wxWindowID idBtn,
|
||||
const wxString& label,
|
||||
wxWindowID id,
|
||||
wxTextCtrl **ppText)
|
||||
wxTextCtrl **ppText,
|
||||
wxWindow* statBoxParent)
|
||||
{
|
||||
return CreateSizerWithText(new wxButton(this, idBtn, label), id, ppText);
|
||||
return CreateSizerWithText(new wxButton(statBoxParent ? statBoxParent: this, idBtn, label), id, ppText);
|
||||
}
|
||||
|
||||
wxCheckBox *WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer *sizer,
|
||||
const wxString& label,
|
||||
wxWindowID id)
|
||||
wxWindowID id,
|
||||
wxWindow* statBoxParent)
|
||||
{
|
||||
wxCheckBox *checkbox = new wxCheckBox(this, id, label);
|
||||
wxCheckBox *checkbox = new wxCheckBox(statBoxParent ? statBoxParent: this, id, label);
|
||||
sizer->Add(checkbox, wxSizerFlags().HorzBorder());
|
||||
sizer->AddSpacer(2);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue