]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dialog.cpp
OS/2 Updates
[wxWidgets.git] / src / gtk / dialog.cpp
index 1b68a287c7f4da9f07bbc917fc3bff8cc85541c2..33bceb74e85cac34df282bb720ecd8d45d57198f 100644 (file)
@@ -59,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;
 }
@@ -79,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();
     }
 }
 
@@ -130,11 +131,6 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
     if (g_isIdle)
         wxapp_install_idle_handler();
 
-    /* I haven't been able to set the position of
-       the dialog before it is shown, so I set the
-       position in "realize" */
-    gtk_widget_set_uposition( widget, win->m_x, win->m_y );
-
     /* all this is for Motif Window Manager "hints" and is supposed to be
        recognized by other WM as well. not tested. */
     long decor = (long) GDK_DECOR_BORDER;
@@ -179,19 +175,6 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
     else
         gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
 
-    /* set size hints */
-    gint flag = 0; // GDK_HINT_POS;
-    if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE;
-    if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE;
-    if (flag)
-    {
-        gdk_window_set_hints( win->m_widget->window,
-                              win->m_x, win->m_y,
-                              win->GetMinWidth(), win->GetMinHeight(),
-                              win->GetMaxWidth(), win->GetMaxHeight(),
-                              flag );
-    }
-
     /* reset the icon */
     if (win->m_icon != wxNullIcon)
     {
@@ -266,8 +249,6 @@ bool wxDialog::Create( wxWindow *parent,
                        const wxPoint &pos, const wxSize &size,
                        long style, const wxString &name )
 {
-    g_openDialogs++;
-
     wxTopLevelWindows.Append( this );
 
     m_needParent = FALSE;
@@ -309,6 +290,10 @@ bool wxDialog::Create( wxWindow *parent,
 
     PostCreation();
 
+    if ((m_x != -1) || (m_y != -1))
+        gtk_widget_set_uposition( m_widget, m_x, m_y );
+    gtk_widget_set_usize( m_widget, m_width, m_height );
+        
     /*  we cannot set MWM hints  before the widget has
         been realized, so we do this directly after realization */
     gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
@@ -344,8 +329,6 @@ wxDialog::~wxDialog()
     {
         wxTheApp->ExitMainLoop();
     }
-    
-    g_openDialogs--;
 }
 
 void wxDialog::SetTitle( const wxString& title )
@@ -470,6 +453,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") );
@@ -528,6 +516,8 @@ void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_width != old_width) || (m_height != old_height))
     {
+        gtk_widget_set_usize( m_widget, m_width, m_height );
+
         /* actual resizing is deferred to GtkOnSize in idle time and
            when showing the dialog */
         m_sizeSet = FALSE;
@@ -553,8 +543,19 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh
     if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
     if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
-    /* we actually set the size of a frame here and no-where else */
-    gtk_widget_set_usize( m_widget, m_width, m_height );
+    /* set size hints */
+    gint flag = 0; // GDK_HINT_POS;
+    if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
+    if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
+    GdkGeometry geom;
+    geom.min_width = m_minWidth;
+    geom.min_height = m_minHeight;
+    geom.max_width = m_maxWidth;
+    geom.max_height = m_maxHeight;
+    gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), 
+                                   (GtkWidget*) NULL,
+                                   &geom,
+                                   (GdkWindowHints) flag );
 
     m_sizeSet = TRUE;
 
@@ -625,10 +626,14 @@ int wxDialog::ShowModal()
 
     m_modalShowing = TRUE;
 
+    g_openDialogs++;
+
     gtk_grab_add( m_widget );
     gtk_main();
     gtk_grab_remove( m_widget );
 
+    g_openDialogs--;
+
     return GetReturnCode();
 }