]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/mdi.cpp
Added wxMenu::Delete() and fixed some menu deleted memory
[wxWidgets.git] / src / gtk1 / mdi.cpp
index 0b98599d59e20200bcb05c71852cb303986a2af3..343743670603a0bf5c667a5391ecdb691a15642e 100644 (file)
@@ -43,6 +43,27 @@ extern bool g_isIdle;
 
 extern wxList wxPendingDelete;
 
+//-----------------------------------------------------------------------------
+// "switch_page"
+//-----------------------------------------------------------------------------
+
+static void gtk_mdi_page_change_callback(GtkNotebook *WXUNUSED(widget),
+                                              GtkNotebookPage *WXUNUSED(page),
+                                              gint WXUNUSED(page),
+                                              wxMDIParentFrame *parent )
+{
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
+    wxMDIChildFrame *child = parent->GetActiveChild();
+    
+    if (!child) return;
+
+    wxActivateEvent event( wxEVT_ACTIVATE, TRUE, child->GetId() );
+    event.SetEventObject( child);
+    child->GetEventHandler()->ProcessEvent( event );
+}
+
 //-----------------------------------------------------------------------------
 // wxMDIParentFrame
 //-----------------------------------------------------------------------------
@@ -291,14 +312,14 @@ void wxMDIChildFrame::GetClientSize( int *width, int *height ) const
     wxWindow::GetClientSize( width, height );
 }
 
-void wxMDIChildFrame::AddChild( wxWindow *child )
+void wxMDIChildFrame::AddChild( wxWindowBase *child )
 {
-    wxWindow::AddChild( child );
+    wxWindow::AddChild(child);
 }
 
 void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
 {
-    wxASSERT_MSG( m_menuBar == NULL, _T("Only one menubar allowed") );
+    wxASSERT_MSG( m_menuBar == NULL, wxT("Only one menubar allowed") );
 
     m_menuBar = menu_bar;
 
@@ -410,14 +431,17 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
     m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
 
     if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
-        !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, _T("wxMDIClientWindow") ))
+        !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") ))
     {
-        wxFAIL_MSG( _T("wxMDIClientWindow creation failed") );
+        wxFAIL_MSG( wxT("wxMDIClientWindow creation failed") );
        return FALSE;
     }
 
     m_widget = gtk_notebook_new();
 
+    gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
+      GTK_SIGNAL_FUNC(gtk_mdi_page_change_callback), (gpointer)parent );
+
     gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
 
     m_parent->DoAddChild( this );