made Freeze/Thaw recursively (un)freeze child windows too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52283 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-03-03 11:30:07 +00:00
parent 9e85b0594d
commit 1c8e5c51f8
6 changed files with 62 additions and 62 deletions

View File

@@ -928,6 +928,52 @@ bool wxWindowBase::IsTopLevel() const
return false;
}
// ----------------------------------------------------------------------------
// Freeze/Thaw
// ----------------------------------------------------------------------------
void wxWindowBase::Freeze()
{
if ( !m_freezeCount++ )
{
// physically freeze this window:
DoFreeze();
// and recursively freeze all children:
for ( wxWindowList::iterator i = GetChildren().begin();
i != GetChildren().end(); ++i )
{
wxWindow *child = *i;
if ( child->IsTopLevel() )
continue;
child->Freeze();
}
}
}
void wxWindowBase::Thaw()
{
wxASSERT_MSG( m_freezeCount, "Thaw() without matching Freeze()" );
if ( !--m_freezeCount )
{
// recursively thaw all children:
for ( wxWindowList::iterator i = GetChildren().begin();
i != GetChildren().end(); ++i )
{
wxWindow *child = *i;
if ( child->IsTopLevel() )
continue;
child->Thaw();
}
// physically thaw this window:
DoThaw();
}
}
// ----------------------------------------------------------------------------
// reparenting the window
// ----------------------------------------------------------------------------
@@ -943,12 +989,22 @@ void wxWindowBase::AddChild(wxWindowBase *child)
GetChildren().Append((wxWindow*)child);
child->SetParent(this);
// adding a child while frozen will assert when thawn, so freeze it as if
// it had been already present when we were frozen
if ( IsFrozen() && !child->IsTopLevel() )
child->Freeze();
}
void wxWindowBase::RemoveChild(wxWindowBase *child)
{
wxCHECK_RET( child, wxT("can't remove a NULL child") );
// removing a child while frozen may result in permanently frozen window
// if used e.g. from Reparent(), so thaw it
if ( IsFrozen() && !child->IsTopLevel() )
child->Thaw();
GetChildren().DeleteObject((wxWindow *)child);
child->SetParent(NULL);
}