]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/colordlg.cpp
don't use deprecated wxMenuItem methods
[wxWidgets.git] / src / gtk / colordlg.cpp
index 9e676a6fa8d5ae18c28dc63b73efa5cf91568704..20bacbb9e29e9658261ac3b1bf63122f060a5856 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // 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"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -44,25 +40,29 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
 
     wxString title(_("Choose colour"));
     m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
 
     wxString title(_("Choose colour"));
     m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
-    
-    if (parent)
+
+    m_parent = GetParentForModalDialog(parent);
+    if ( m_parent )
+    {
+        GtkWindow* gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(m_parent->m_widget) );
         gtk_window_set_transient_for(GTK_WINDOW(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;
 }
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
     gtk_color_selection_set_has_palette(sel, true);
 
     return true;
 }
-    
+
 int wxColourDialog::ShowModal()
 {
     ColourDataToDialog();
 int wxColourDialog::ShowModal()
 {
     ColourDataToDialog();
-    
+
     gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
     gtk_widget_hide(m_widget);
     gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
     gtk_widget_hide(m_widget);
-    
+
     switch (result)
     {
         default:
     switch (result)
     {
         default:
@@ -73,18 +73,18 @@ int wxColourDialog::ShowModal()
         case GTK_RESPONSE_DELETE_EVENT:
         case GTK_RESPONSE_CLOSE:
             return wxID_CANCEL;
         case GTK_RESPONSE_DELETE_EVENT:
         case GTK_RESPONSE_CLOSE:
             return wxID_CANCEL;
-     
+
         case GTK_RESPONSE_OK:
             DialogToColourData();
             return wxID_OK;
         case GTK_RESPONSE_OK:
             DialogToColourData();
             return wxID_OK;
-    };
+    }
 }
 
 void wxColourDialog::ColourDataToDialog()
 {
 }
 
 void wxColourDialog::ColourDataToDialog()
 {
-    GtkColorSelection *sel = 
+    GtkColorSelection *sel =
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
-                
+
     if (m_data.GetColour().Ok())
     {
         gtk_color_selection_set_current_color(sel,
     if (m_data.GetColour().Ok())
     {
         gtk_color_selection_set_current_color(sel,
@@ -105,23 +105,21 @@ void wxColourDialog::ColourDataToDialog()
         }
     }
 
         }
     }
 
-    gchar *pal = gtk_color_selection_palette_to_string(colors, n_colors);
+    wxGtkString pal(gtk_color_selection_palette_to_string(colors, n_colors));
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
-    g_object_set(settings, "gtk-color-palette", pal, NULL);
-
-    g_free(pal);
+    g_object_set(settings, "gtk-color-palette", pal.c_str(), NULL);
 }
 
 void wxColourDialog::DialogToColourData()
 {
 }
 
 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);
         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));
-    
+    m_data.SetColour(wxColour(clr));
+
     // Extract custom palette:
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
     // Extract custom palette:
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
@@ -134,13 +132,11 @@ void wxColourDialog::DialogToColourData()
     {
         for (int i = 0; i < wxMin(n_colors, 16); i++)
         {
     {
         for (int i = 0; i < wxMin(n_colors, 16); i++)
         {
-            m_data.SetCustomColour(i, wxColour(colors[i].red >> 8,
-                                               colors[i].green >> 8,
-                                               colors[i].blue >> 8));
+            m_data.SetCustomColour(i, wxColour(colors[i]));
         }
         g_free(colors);
     }
         }
         g_free(colors);
     }
-    
+
     g_free(pal);
 }
 
     g_free(pal);
 }