As per the wx-dev discussion in early Jan, replaced
wxWindow::m_parentSizer with m_containingSizer which is used to track which sizer this window is a member of. Windows will now remove themselves from a sizer when destroyed. Also added accessors so window classes can find out if they are in a sizer and do things like reset their min size, etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -236,7 +236,7 @@ void wxSizerItem::DeleteWindows()
|
||||
{
|
||||
if (m_window)
|
||||
m_window->Destroy();
|
||||
|
||||
|
||||
if (m_sizer)
|
||||
m_sizer->DeleteWindows();
|
||||
}
|
||||
@@ -269,11 +269,13 @@ wxSizer::wxSizer()
|
||||
|
||||
wxSizer::~wxSizer()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void wxSizer::Add( wxWindow *window, int option, int flag, int border, wxObject* userData )
|
||||
{
|
||||
m_children.Append( new wxSizerItem( window, option, flag, border, userData ) );
|
||||
window->SetContainingSizer(this);
|
||||
}
|
||||
|
||||
void wxSizer::Add( wxSizer *sizer, int option, int flag, int border, wxObject* userData )
|
||||
@@ -289,6 +291,7 @@ void wxSizer::Add( int width, int height, int option, int flag, int border, wxOb
|
||||
void wxSizer::Prepend( wxWindow *window, int option, int flag, int border, wxObject* userData )
|
||||
{
|
||||
m_children.Insert( new wxSizerItem( window, option, flag, border, userData ) );
|
||||
window->SetContainingSizer(this);
|
||||
}
|
||||
|
||||
void wxSizer::Prepend( wxSizer *sizer, int option, int flag, int border, wxObject* userData )
|
||||
@@ -304,6 +307,7 @@ void wxSizer::Prepend( int width, int height, int option, int flag, int border,
|
||||
void wxSizer::Insert( int before, wxWindow *window, int option, int flag, int border, wxObject* userData )
|
||||
{
|
||||
m_children.Insert( before, new wxSizerItem( window, option, flag, border, userData ) );
|
||||
window->SetContainingSizer(this);
|
||||
}
|
||||
|
||||
void wxSizer::Insert( int before, wxSizer *sizer, int option, int flag, int border, wxObject* userData )
|
||||
@@ -326,6 +330,7 @@ bool wxSizer::Remove( wxWindow *window )
|
||||
wxSizerItem *item = (wxSizerItem*)node->Data();
|
||||
if (item->GetWindow() == window)
|
||||
{
|
||||
item->GetWindow()->SetContainingSizer(NULL);
|
||||
m_children.DeleteNode( node );
|
||||
return TRUE;
|
||||
}
|
||||
@@ -366,9 +371,21 @@ bool wxSizer::Remove( int pos )
|
||||
|
||||
void wxSizer::Clear( bool delete_windows )
|
||||
{
|
||||
// First clear the ContainingSizer pointers
|
||||
wxNode *node = m_children.First();
|
||||
while (node)
|
||||
{
|
||||
wxSizerItem *item = (wxSizerItem*)node->Data();
|
||||
if (item->IsWindow())
|
||||
item->GetWindow()->SetContainingSizer(NULL);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// Destroy the windows if needed
|
||||
if (delete_windows)
|
||||
DeleteWindows();
|
||||
|
||||
|
||||
// Now empty the list
|
||||
m_children.Clear();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user