+void wxMDIParentFrame::AddChild(wxWindowBase *child)
+{
+ if ( !m_currentChild )
+ {
+ m_currentChild = wxDynamicCast(child, wxMDIChildFrame);
+
+ if ( m_currentChild && IsShown() && !ShouldBeVisible() )
+ {
+ // we shouldn't remain visible any more
+ wxFrame::Show(false);
+ m_shouldBeShown = true;
+ }
+ }
+
+ wxFrame::AddChild(child);
+}
+
+void wxMDIParentFrame::RemoveChild(wxWindowBase *child)
+{
+ if ( child == m_currentChild )
+ {
+ // the current child isn't active any more, try to find another one
+ m_currentChild = NULL;
+
+ for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ wxMDIChildFrame *
+ childCur = wxDynamicCast(node->GetData(), wxMDIChildFrame);
+ if ( childCur != child )
+ {
+ m_currentChild = childCur;
+ break;
+ }
+ }
+ }
+
+ wxFrame::RemoveChild(child);
+
+ // if there are no more children left we need to show the frame if we
+ // hadn't shown it before because there were active children and it was
+ // useless (note that we have to do it after fully removing the child, i.e.
+ // after calling the base class RemoveChild() as otherwise we risk to touch
+ // pointer to the child being deleted)
+ if ( !m_currentChild && m_shouldBeShown && !IsShown() )
+ {
+ // we have to show it, but at least move it out of sight and make it of
+ // smallest possible size (unfortunately (0, 0) doesn't work so that it
+ // doesn't appear in expose
+ SetSize(-10000, -10000, 1, 1);
+ Show();
+ }
+}
+