delete the associated wxStaticBox in wxStaticBoxSizer dtor (patch 1473769)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,6 +24,7 @@ INCOMPATIBLE CHANGES SINCE 2.6.x
|
|||||||
use GetMouseCursor().
|
use GetMouseCursor().
|
||||||
- wxFontEnumerator::GetFacenames() and GetEncodings() now return arrays and
|
- wxFontEnumerator::GetFacenames() and GetEncodings() now return arrays and
|
||||||
not pointers to arrays
|
not pointers to arrays
|
||||||
|
- wxStaticBoxSizer now deletes the associated wxStaticBox when it is deleted
|
||||||
|
|
||||||
|
|
||||||
Deprecated methods since 2.6.x and their replacements
|
Deprecated methods since 2.6.x and their replacements
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
\section{\class{wxStaticBoxSizer}}\label{wxstaticboxsizer}
|
\section{\class{wxStaticBoxSizer}}\label{wxstaticboxsizer}
|
||||||
|
|
||||||
wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static
|
wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static
|
||||||
box around the sizer. This static box has to be created independently or the
|
box around the sizer. This static box may be either created independently or
|
||||||
sizer may create it itself as a convenience.
|
the sizer may create it itself as a convenience. In any case, the sizer owns
|
||||||
|
the \helpref{wxStaticBox}{wxstaticbox} control and will delete it if it is
|
||||||
|
deleted.
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
@@ -685,6 +685,7 @@ class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
|
|||||||
public:
|
public:
|
||||||
wxStaticBoxSizer(wxStaticBox *box, int orient);
|
wxStaticBoxSizer(wxStaticBox *box, int orient);
|
||||||
wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
|
wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
|
||||||
|
virtual ~wxStaticBoxSizer() { delete m_staticBox; }
|
||||||
|
|
||||||
void RecalcSizes();
|
void RecalcSizes();
|
||||||
wxSize CalcMin();
|
wxSize CalcMin();
|
||||||
@@ -694,6 +695,7 @@ public:
|
|||||||
|
|
||||||
// override to hide/show the static box as well
|
// override to hide/show the static box as well
|
||||||
virtual void ShowItems (bool show);
|
virtual void ShowItems (bool show);
|
||||||
|
virtual bool Detach( wxWindow *window );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxStaticBox *m_staticBox;
|
wxStaticBox *m_staticBox;
|
||||||
|
@@ -1697,16 +1697,22 @@ wxSize wxBoxSizer::CalcMin()
|
|||||||
#if wxUSE_STATBOX
|
#if wxUSE_STATBOX
|
||||||
|
|
||||||
wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox *box, int orient )
|
wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox *box, int orient )
|
||||||
: wxBoxSizer( orient )
|
: wxBoxSizer( orient ),
|
||||||
, m_staticBox( box )
|
m_staticBox( box )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( box, wxT("wxStaticBoxSizer needs a static box") );
|
wxASSERT_MSG( box, wxT("wxStaticBoxSizer needs a static box") );
|
||||||
|
|
||||||
|
// do this so that our Detach() is called if the static box is destroyed
|
||||||
|
// before we are
|
||||||
|
m_staticBox->SetContainingSizer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStaticBoxSizer::wxStaticBoxSizer(int orient, wxWindow *win, const wxString& s)
|
wxStaticBoxSizer::wxStaticBoxSizer(int orient, wxWindow *win, const wxString& s)
|
||||||
: wxBoxSizer(orient),
|
: wxBoxSizer(orient),
|
||||||
m_staticBox(new wxStaticBox(win, wxID_ANY, s))
|
m_staticBox(new wxStaticBox(win, wxID_ANY, s))
|
||||||
{
|
{
|
||||||
|
// same as above
|
||||||
|
m_staticBox->SetContainingSizer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetStaticBoxBorders( wxStaticBox *box,
|
static void GetStaticBoxBorders( wxStaticBox *box,
|
||||||
@@ -1756,6 +1762,20 @@ void wxStaticBoxSizer::ShowItems( bool show )
|
|||||||
wxBoxSizer::ShowItems( show );
|
wxBoxSizer::ShowItems( show );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxStaticBoxSizer::Detach( wxWindow *window )
|
||||||
|
{
|
||||||
|
// avoid deleting m_staticBox in our dtor if it's being detached from the
|
||||||
|
// sizer (which can happen because it's being already destroyed for
|
||||||
|
// example)
|
||||||
|
if ( window == m_staticBox )
|
||||||
|
{
|
||||||
|
m_staticBox = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxSizer::Detach( window );
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_STATBOX
|
#endif // wxUSE_STATBOX
|
||||||
|
|
||||||
#if wxUSE_BUTTON
|
#if wxUSE_BUTTON
|
||||||
|
Reference in New Issue
Block a user