]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dialog.cpp
Uses wxUSE_WCHAR_T for compilers that don't support wchar_t.
[wxWidgets.git] / src / gtk / dialog.cpp
index 7edb2940c8712fd6b239715896d9ca75d1944ba4..ee8da61ef8e0dafc8793f443e006caf01e699423 100644 (file)
@@ -82,6 +82,56 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints and icons before the widget has been realized, 
+   so we do this directly after realization */
+
+static gint 
+gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
+{
+    /* 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_ALL;
+    long func = (long) GDK_FUNC_ALL;
+    
+    if ((win->m_windowStyle & wxCAPTION) == 0)
+       decor |= GDK_DECOR_TITLE;
+/*  if ((win->m_windowStyle & wxMINIMIZE) == 0)
+       func |= GDK_FUNC_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+       func |= GDK_FUNC_MAXIMIZE;            */
+    if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+       decor |= GDK_DECOR_MENU;
+    if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MAXIMIZE;
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+       func |= GDK_FUNC_RESIZE;
+       
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+      
+    /* GTK's shrinking/growing policy */
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+    else
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+    
+    /* reset the icon */
+    if (win->m_icon != wxNullIcon)
+    {
+        wxIcon icon( win->m_icon );
+        win->m_icon = wxNullIcon;
+       win->SetIcon( icon );
+    }
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // wxDialog
 //-----------------------------------------------------------------------------
@@ -143,37 +193,12 @@ bool wxDialog::Create( wxWindow *parent,
 
     PostCreation();
 
-    gtk_widget_realize( m_widget );
-
-    /* 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_ALL;
-    long func = (long) GDK_FUNC_ALL;
+    /*  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",
+                       GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
     
-    if ((m_windowStyle & wxCAPTION) == 0)
-       decor |= GDK_DECOR_TITLE;
-/*  if ((m_windowStyle & wxMINIMIZE) == 0)
-       func |= GDK_FUNC_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE) == 0)
-       func |= GDK_FUNC_MAXIMIZE; */
-    if ((m_windowStyle & wxSYSTEM_MENU) == 0)
-       decor |= GDK_DECOR_MENU;
-    if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MAXIMIZE;
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-       func |= GDK_FUNC_RESIZE;
-       
-    gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-    
-    /* GTK's shrinking/growing policy */
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
-    else
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
+    /* the user resized the frame by dragging etc. */
     gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
         GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );