]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/dialog.cpp
Fixed blatant non-initialisation bug
[wxWidgets.git] / src / gtk1 / dialog.cpp
index 8739c60b354c52becae8a11fc73ef2d44a42f8fc..70c83e3c7732a7b6486978f49a4163f6f7b39f5b 100644 (file)
 #include "wx/dialog.h"
 #include "wx/frame.h"
 #include "wx/app.h"
-
-#include "gdk/gdk.h"
-#include "gtk/gtk.h"
-#include "wx/gtk/win_gtk.h"
 #include "wx/cursor.h"
 
-/*
-#include "gdk/gdkprivate.h"
-#include "gdk/gdkx.h"
-*/
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "wx/gtk/win_gtk.h"
 
 //-----------------------------------------------------------------------------
 // idle system
@@ -39,6 +36,20 @@ extern int g_openDialogs;
 
 extern wxList wxPendingDelete;
 
+//-----------------------------------------------------------------------------
+// "focus" from m_window
+//-----------------------------------------------------------------------------
+
+static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
+{
+    if (g_isIdle)
+        wxapp_install_idle_handler();
+
+    // This disables GTK's tab traversal
+    gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
+    return TRUE;
+}
+
 //-----------------------------------------------------------------------------
 // "delete_event"
 //-----------------------------------------------------------------------------
@@ -48,7 +59,8 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED
     if (g_isIdle)
         wxapp_install_idle_handler();
 
-    win->Close();
+    if (win->IsEnabled())
+        win->Close();
 
     return TRUE;
 }
@@ -68,7 +80,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation
     {
         win->m_width = alloc->width;
         win->m_height = alloc->height;
-        win->UpdateSize();
+        win->GtkUpdateSize();
     }
 }
 
@@ -268,6 +280,9 @@ bool wxDialog::Create( wxWindow *parent,
         return FALSE;
     }
 
+    // All dialogs should really have this style
+    m_windowStyle |= wxTAB_TRAVERSAL;
+
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog;
 
     m_widget = gtk_window_new( GTK_WINDOW_DIALOG );
@@ -307,6 +322,10 @@ bool wxDialog::Create( wxWindow *parent,
     gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
         GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this );
 
+    /* disable native tab traversal */
+    gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
+        GTK_SIGNAL_FUNC(gtk_dialog_focus_callback), (gpointer)this );
+
     return TRUE;
 }
 
@@ -321,7 +340,8 @@ wxDialog::~wxDialog()
         wxTheApp->SetTopWindow( (wxWindow*) NULL );
     }
 
-    if (wxTopLevelWindows.Number() == 0)
+    if ((wxTopLevelWindows.Number() == 0) &&
+        (wxTheApp->GetExitOnFrameDelete()))
     {
         wxTheApp->ExitMainLoop();
     }
@@ -451,6 +471,11 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
     }
 }
 
+void wxDialog::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
+{
+    wxFAIL_MSG( wxT("DoMoveWindow called for wxDialog") );
+}
+    
 void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );