]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/colordlg.cpp
Allow wx parents a chance to handle events fired by non-wx children. (i.e. wxActiveX...
[wxWidgets.git] / src / gtk / colordlg.cpp
index fa41faa4f84acfe9220ca6eb7b2c5f595356771a..8571dab73e1a1cb73031682d106ce01dfb90fa13 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "colordlg.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -44,24 +40,28 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
 
     wxString title(_("Choose colour"));
     m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
-    
+
     if (parent)
+    {
+        GtkWindow* gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
         gtk_window_set_transient_for(GTK_WINDOW(m_widget),
-                                     GTK_WINDOW(parent->m_widget));
-    
-    GtkColorSelection *sel = 
+                                     gtk_parent);
+    }
+
+    GtkColorSelection *sel =
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
     gtk_color_selection_set_has_palette(sel, true);
 
     return true;
 }
-    
+
 int wxColourDialog::ShowModal()
 {
     ColourDataToDialog();
-    
+
     gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
-   
+    gtk_widget_hide(m_widget);
+
     switch (result)
     {
         default:
@@ -72,18 +72,18 @@ int wxColourDialog::ShowModal()
         case GTK_RESPONSE_DELETE_EVENT:
         case GTK_RESPONSE_CLOSE:
             return wxID_CANCEL;
-     
+
         case GTK_RESPONSE_OK:
             DialogToColourData();
             return wxID_OK;
-    };
+    }
 }
 
 void wxColourDialog::ColourDataToDialog()
 {
-    GtkColorSelection *sel = 
+    GtkColorSelection *sel =
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
-                
+
     if (m_data.GetColour().Ok())
     {
         gtk_color_selection_set_current_color(sel,
@@ -114,13 +114,13 @@ void wxColourDialog::ColourDataToDialog()
 
 void wxColourDialog::DialogToColourData()
 {
-    GtkColorSelection *sel = 
+    GtkColorSelection *sel =
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
 
     GdkColor clr;
     gtk_color_selection_get_current_color(sel, &clr);
     m_data.SetColour(wxColour(clr.red >> 8, clr.green >> 8, clr.blue >> 8));
-    
+
     // Extract custom palette:
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
@@ -139,7 +139,7 @@ void wxColourDialog::DialogToColourData()
         }
         g_free(colors);
     }
-    
+
     g_free(pal);
 }