]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/mdi.cpp
added default ctor for wxDirDialog
[wxWidgets.git] / src / gtk1 / mdi.cpp
index e9acbdf01acd6b949f25d3f9c4ac331d70204fc4..3fa7de98fd7f1b19ef7b60264db6a99fd57c8821 100644 (file)
 #endif
 
 #include "wx/mdi.h"
+
+#if wxUSE_MDI_ARCHITECTURE
+
 #include "wx/dialog.h"
 #include "wx/menu.h"
-#include <wx/intl.h>
+#include "wx/intl.h"
 
-#include "glib.h"
-#include "gdk/gdk.h"
-#include "gtk/gtk.h"
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
 #include "wx/gtk/win_gtk.h"
 
 //-----------------------------------------------------------------------------
@@ -40,6 +43,57 @@ extern bool g_isIdle;
 
 extern wxList wxPendingDelete;
 
+//-----------------------------------------------------------------------------
+// "switch_page"
+//-----------------------------------------------------------------------------
+
+static void 
+gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
+                              GtkNotebookPage *page,
+                             gint WXUNUSED(page_num),
+                             wxMDIParentFrame *parent )
+{
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
+    // send deactivate event to old child
+
+    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
+    
+    wxMDIClientWindow *client_window = parent->GetClientWindow();
+    if (!client_window)
+        return;
+
+    child = (wxMDIChildFrame*) NULL;
+
+    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 );
+}
+
 //-----------------------------------------------------------------------------
 // wxMDIParentFrame
 //-----------------------------------------------------------------------------
@@ -96,7 +150,7 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
     menu_bar->m_y = 0;
     menu_bar->m_width = m_width;
     menu_bar->m_height = wxMENU_HEIGHT;
-    gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), 
+    gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), 
                           menu_bar->m_widget, 
                           0, 0, m_width, wxMENU_HEIGHT );
 }
@@ -135,7 +189,7 @@ void wxMDIParentFrame::OnInternalIdle()
                {
                    menu_bar->m_width = m_width;
                    menu_bar->m_height = wxMENU_HEIGHT;
-                    gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), 
+                    gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), 
                                          menu_bar->m_widget, 
                                          0, 0, m_width, wxMENU_HEIGHT );
                    menu_bar->SetInvokingWindow( child_frame );
@@ -169,7 +223,7 @@ void wxMDIParentFrame::OnInternalIdle()
            
            m_frameMenuBar->m_width = m_width;
            m_frameMenuBar->m_height = wxMENU_HEIGHT;
-            gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), 
+            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), 
                                  m_frameMenuBar->m_widget, 
                                  0, 0, m_width, wxMENU_HEIGHT );
        }
@@ -288,14 +342,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;
 
@@ -306,7 +360,7 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
         m_menuBar->SetParent( mdi_frame );
 
         /* insert the invisible menu bar into the _parent_ mdi frame */
-        gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget), 
+        gtk_pizza_put( GTK_PIZZA(mdi_frame->m_mainWidget), 
                          m_menuBar->m_widget, 
                          0, 0,  mdi_frame->m_width, wxMENU_HEIGHT );
     }
@@ -406,10 +460,18 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
 
     m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
 
-    PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
+    if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
+        !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") ))
+    {
+        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 );
@@ -421,3 +483,4 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
     return TRUE;
 }
 
+#endif