Added wxWindow::IsDescendant() helper.
This function checks if another window is a direct or indirect child of this one, which can be needed in a number of situations. See #3063. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1242,9 +1242,28 @@ void wxWindowBase::Thaw()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// reparenting the window
|
||||
// Dealing with parents and children.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxWindowBase::IsDescendant(wxWindowBase* win) const
|
||||
{
|
||||
// Iterate until we find this window in the parent chain or exhaust it.
|
||||
while ( win )
|
||||
{
|
||||
wxWindow* const parent = win->GetParent();
|
||||
if ( parent == this )
|
||||
return true;
|
||||
|
||||
// Stop iterating on reaching the top level window boundary.
|
||||
if ( parent->IsTopLevel() )
|
||||
break;
|
||||
|
||||
win = parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxWindowBase::AddChild(wxWindowBase *child)
|
||||
{
|
||||
wxCHECK_RET( child, wxT("can't add a NULL child") );
|
||||
|
Reference in New Issue
Block a user