+ wxASSERT_MSG( m_menuBar == NULL, wxT("Only one menubar allowed") );
+
+ m_menuBar = menu_bar;
+
+ if (m_menuBar)
+ {
+ wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
+
+ m_menuBar->SetParent( mdi_frame );
+
+ /* insert the invisible menu bar into the _parent_ mdi frame */
+ m_menuBar->Show(false);
+ gtk_box_pack_start(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, false, false, 0);
+ gtk_box_reorder_child(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, 0);
+
+ gulong handler_id = g_signal_handler_find(
+ m_menuBar->m_widget,
+ GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
+ g_signal_lookup("size_request", GTK_TYPE_WIDGET),
+ 0, NULL, NULL, m_menuBar);
+ if (handler_id != 0)
+ g_signal_handler_disconnect(m_menuBar->m_widget, handler_id);
+ gtk_widget_set_size_request(m_menuBar->m_widget, -1, -1);
+ }
+}
+
+wxMenuBar *wxMDIChildFrame::GetMenuBar() const
+{
+ return m_menuBar;
+}
+
+void wxMDIChildFrame::Activate()
+{
+ wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
+ GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
+ gint pageno = gtk_notebook_page_num( notebook, m_widget );
+ gtk_notebook_set_current_page( notebook, pageno );
+}
+
+void wxMDIChildFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
+{
+}
+
+void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event )
+{
+#if wxUSE_STATUSBAR
+ wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
+ if ( !ShowMenuHelp(event.GetMenuId()) )
+ {
+ // we don't have any help text for this item, but may be the MDI frame
+ // does?
+ mdi_frame->OnMenuHighlight(event);
+ }
+#endif // wxUSE_STATUSBAR
+}
+
+void wxMDIChildFrame::SetTitle( const wxString &title )
+{
+ if ( title == m_title )
+ return;
+
+ m_title = title;
+
+ wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
+ GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
+ gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) );
+}
+
+//-----------------------------------------------------------------------------
+// InsertChild callback for wxMDIClientWindow
+//-----------------------------------------------------------------------------
+
+static void wxInsertChildInMDI(wxWindow* parent, wxWindow* child)
+{
+ wxMDIChildFrame* child_frame = wx_static_cast(wxMDIChildFrame*, child);
+ wxString s = child_frame->GetTitle();
+ if (s.IsNull()) s = _("MDI child");
+
+ GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
+ gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
+
+ GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
+
+ gtk_notebook_append_page( notebook, child->m_widget, label_widget );
+
+ child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
+
+ wxMDIParentFrame *parent_frame = wx_static_cast(wxMDIParentFrame*, parent->GetParent());
+ parent_frame->m_justInserted = true;
+}