X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c757b5fee093bbc3686f1e474316396b742fb888..92d00a3615b1e598cac48b2f608be1bf32b27057:/src/gtk/clrpicker.cpp diff --git a/src/gtk/clrpicker.cpp b/src/gtk/clrpicker.cpp index 5ba0324488..f317108ac1 100644 --- a/src/gtk/clrpicker.cpp +++ b/src/gtk/clrpicker.cpp @@ -17,7 +17,7 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#if wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__) +#if wxUSE_COLOURPICKERCTRL #include "wx/clrpicker.h" @@ -37,11 +37,18 @@ static void gtk_clrbutton_setcolor_callback(GtkColorButton *widget, { // update the m_colour member of the wxColourButton wxASSERT(p); - gtk_color_button_get_color(widget, p->GetGdkColor()); +#ifdef __WXGTK3__ + GdkRGBA gdkColor; + gtk_color_button_get_rgba(widget, &gdkColor); +#else + GdkColor gdkColor; + gtk_color_button_get_color(widget, &gdkColor); +#endif + p->GTKSetColour(gdkColor); // fire the colour-changed event wxColourPickerEvent event(p, p->GetId(), p->GetColour()); - p->GetEventHandler()->ProcessEvent(event); + p->HandleWindowEvent(event); } } @@ -49,7 +56,7 @@ static void gtk_clrbutton_setcolor_callback(GtkColorButton *widget, // wxColourButton //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxColourButton, wxGenericColourButton) +IMPLEMENT_DYNAMIC_CLASS(wxColourButton, wxButton) bool wxColourButton::Create( wxWindow *parent, wxWindowID id, const wxColour &col, @@ -57,34 +64,31 @@ bool wxColourButton::Create( wxWindow *parent, wxWindowID id, long style, const wxValidator& validator, const wxString &name ) { - if (!gtk_check_version(2,4,0)) + if (!PreCreation( parent, pos, size ) || + !wxControl::CreateBase(parent, id, pos, size, style, validator, name)) { - m_needParent = true; + wxFAIL_MSG( wxT("wxColourButton creation failed") ); + return false; + } - if (!PreCreation( parent, pos, size ) || - !wxControl::CreateBase(parent, id, pos, size, style, validator, name)) - { - wxFAIL_MSG( wxT("wxColourButton creation failed") ); - return false; - } + m_colour = col; +#ifdef __WXGTK3__ + m_widget = gtk_color_button_new_with_rgba(m_colour); +#else + m_widget = gtk_color_button_new_with_color( m_colour.GetColor() ); +#endif + g_object_ref(m_widget); - m_colour = col; - m_widget = gtk_color_button_new_with_color( m_colour.GetColor() ); - gtk_widget_show( GTK_WIDGET(m_widget) ); + // GtkColourButton signals + g_signal_connect(m_widget, "color-set", + G_CALLBACK(gtk_clrbutton_setcolor_callback), this); - // GtkColourButton signals - g_signal_connect(m_widget, "color-set", - G_CALLBACK(gtk_clrbutton_setcolor_callback), this); + m_parent->DoAddChild( this ); - m_parent->DoAddChild( this ); + PostCreation(size); + SetInitialSize(size); - PostCreation(size); - SetBestSize(size); - } - else - return wxGenericColourButton::Create(parent, id, col, pos, size, - style, validator, name); return true; } @@ -94,10 +98,11 @@ wxColourButton::~wxColourButton() void wxColourButton::UpdateColour() { - if (!gtk_check_version(2,4,0)) - gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor()); - else - wxGenericColourButton::UpdateColour(); +#ifdef __WXGTK3__ + gtk_color_button_set_rgba(GTK_COLOR_BUTTON(m_widget), m_colour); +#else + gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor()); +#endif } -#endif // wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__) +#endif // wxUSE_COLOURPICKERCTRL