]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/mdi.cpp
reSWIGged
[wxWidgets.git] / src / gtk1 / mdi.cpp
index 99586ff639988bb1b887e86ca5bdd22ecbf0cb7b..ddd65e82be463d1c06e9abf68333df82cab8e9aa 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Robert Roebling
 // Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -15,6 +15,7 @@
 #include "wx/wxprec.h"
 
 #include "wx/mdi.h"
+#include "wx/notebook.h"
 
 #if wxUSE_MDI
 
@@ -51,6 +52,7 @@ extern wxList wxPendingDelete;
 // "switch_page"
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void
 gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
                               GtkNotebookPage *page,
@@ -82,8 +84,11 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
     while (node)
     {
         wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );
-
-        wxASSERT_MSG( child_frame, _T("child is not a 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)
         {
@@ -100,6 +105,7 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
     event2.SetEventObject( child);
     child->GetEventHandler()->ProcessEvent( event2 );
 }
+}
 
 //-----------------------------------------------------------------------------
 // wxMDIParentFrame
@@ -164,6 +170,21 @@ void wxMDIParentFrame::OnInternalIdle()
         GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
         gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 );
 
+        /* need to set the menubar of the child */
+        wxMDIChildFrame *active_child_frame = GetActiveChild();
+        if (active_child_frame != NULL)
+        {
+            wxMenuBar *menu_bar = active_child_frame->m_menuBar;
+            if (menu_bar)
+            {
+                menu_bar->m_width = m_width;
+                menu_bar->m_height = wxMENU_HEIGHT;
+                gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
+                                    menu_bar->m_widget,
+                                    0, 0, m_width, wxMENU_HEIGHT );
+                menu_bar->SetInvokingWindow(active_child_frame);
+            }
+        }
         m_justInserted = false;
         return;
     }
@@ -319,7 +340,7 @@ wxMDIChildFrame::~wxMDIChildFrame()
 {
     if (m_menuBar)
         delete m_menuBar;
-}
+} 
 
 bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
       wxWindowID id, const wxString& title,
@@ -416,6 +437,7 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
 // "size_allocate"
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
 {
     if (g_isIdle) wxapp_install_idle_handler();
@@ -431,6 +453,7 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
 
     win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
 }
+}
 
 //-----------------------------------------------------------------------------
 // InsertChild callback for wxMDIClientWindow
@@ -474,6 +497,7 @@ wxMDIClientWindow::wxMDIClientWindow( wxMDIParentFrame *parent, long style )
 
 wxMDIClientWindow::~wxMDIClientWindow()
 {
+
 }
 
 bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )