-wxMDIParentFrame::wxMDIParentFrame( wxWindow *parent,
- wxWindowID id, const wxString& title,
- const wxPoint& pos, const wxSize& size,
- long style, const wxString& name )
-{
- m_justInserted = FALSE;
- m_clientWindow = (wxMDIClientWindow *) NULL;
- Create( parent, id, title, pos, size, style, name );
+ // send deactivate event to old child
+
+ wxMDIChildFrame *child = parent->GetActiveChild();
+ if (child)
+ {
+ wxActivateEvent event1( wxEVT_ACTIVATE, false, child->GetId() );
+ event1.SetEventObject( child);
+ child->HandleWindowEvent( event1 );
+ }
+
+ // send activate event to new child
+
+ wxMDIClientWindowBase * const client_window = parent->GetClientWindow();
+ if ( !client_window )
+ return;
+
+ child = NULL;
+
+ wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst();
+ while (node)
+ {
+ wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );
+ // CE: we come here in the destructor with a null child_frame - I think because
+ // gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", (see below)
+ // isn't deleted early enough
+ if (!child_frame)
+ return ;
+
+ if (child_frame->m_page == page)
+ {
+ child = child_frame;
+ break;
+ }
+ node = node->GetNext();
+ }
+
+ if (!child)
+ return;
+
+ wxActivateEvent event2( wxEVT_ACTIVATE, true, child->GetId() );
+ event2.SetEventObject( child);
+ child->HandleWindowEvent( event2 );
+}