]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/mdi.cpp
assert in OnSelected() fixed
[wxWidgets.git] / src / gtk / mdi.cpp
index f31951f90c049f913797308e8c9696fc10bdb096..ef10bb6cfcb7975afc7fae698bdd7b567c34f226 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "wx/dialog.h"
 #include "wx/menu.h"
 
 #include "wx/dialog.h"
 #include "wx/menu.h"
-#include <wx/intl.h>
+#include "wx/intl.h"
 
 #include "glib.h"
 #include "gdk/gdk.h"
 
 #include "glib.h"
 #include "gdk/gdk.h"
@@ -47,21 +47,51 @@ extern wxList wxPendingDelete;
 // "switch_page"
 //-----------------------------------------------------------------------------
 
 // "switch_page"
 //-----------------------------------------------------------------------------
 
-static void gtk_mdi_page_change_callback(GtkNotebook *WXUNUSED(widget),
-                                              GtkNotebookPage *WXUNUSED(page),
-                                              gint WXUNUSED(page),
-                                              wxMDIParentFrame *parent )
+static void 
+gtk_mdi_page_change_callback( GtkNotebook *widget,
+                              GtkNotebookPage *page,
+                             gint WXUNUSED(page_num),
+                             wxMDIParentFrame *parent )
 {
     if (g_isIdle) 
         wxapp_install_idle_handler();
 
 {
     if (g_isIdle) 
         wxapp_install_idle_handler();
 
+    // send deactivate event to old child
+
     wxMDIChildFrame *child = parent->GetActiveChild();
     wxMDIChildFrame *child = parent->GetActiveChild();
+    if (child)
+    {
+        wxActivateEvent event1( wxEVT_ACTIVATE, FALSE, child->GetId() );
+        event1.SetEventObject( child);
+        child->GetEventHandler()->ProcessEvent( event1 );
+    }
+    
+    // send activate event to new child
     
     
-    if (!child) return;
+    wxMDIClientWindow *client_window = parent->GetClientWindow();
+    if (!client_window)
+        return;
+
+    child = (wxMDIChildFrame*) NULL;
 
 
-    wxActivateEvent event( wxEVT_ACTIVATE, TRUE, child->GetId() );
-    event.SetEventObject( child);
-    child->GetEventHandler()->ProcessEvent( event );
+    wxNode *node = client_window->GetChildren().First();
+    while (node)
+    {
+        wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
+        if (child_frame->m_page == page)
+       {
+            child = child_frame;
+           break;
+       }
+        node = node->Next();
+    }
+    
+    if (!child)
+         return;
+    
+    wxActivateEvent event2( wxEVT_ACTIVATE, TRUE, child->GetId() );
+    event2.SetEventObject( child);
+    child->GetEventHandler()->ProcessEvent( event2 );
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------