1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/clrpicker.cpp
3 // Purpose: implementation of wxColourButton
4 // Author: Francesco Montorsi
8 // Copyright: (c) Francesco Montorsi
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
20 #include "wx/gtk/private.h"
21 #include "wx/clrpicker.h"
28 // ============================================================================
30 // ============================================================================
32 #if wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__)
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
39 static void gtk_clrbutton_setcolor_callback(GtkColorButton
*widget
,
42 // update the m_colour member of the wxColourButton
44 gtk_color_button_get_color(widget
, p
->GetGdkColor());
46 // fire the colour-changed event
47 wxColourPickerEvent
event(p
, p
->GetId(), p
->GetColour());
48 p
->GetEventHandler()->ProcessEvent(event
);
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
56 IMPLEMENT_DYNAMIC_CLASS(wxColourButton
, wxGenericColourButton
)
58 bool wxColourButton::Create( wxWindow
*parent
, wxWindowID id
,
60 const wxPoint
&pos
, const wxSize
&size
,
61 long style
, const wxValidator
& validator
,
62 const wxString
&name
)
64 if (!gtk_check_version(2,4,0))
68 if (!PreCreation( parent
, pos
, size
) ||
69 !wxControl::CreateBase(parent
, id
, pos
, size
, style
, validator
, name
))
71 wxFAIL_MSG( wxT("wxColourButton creation failed") );
76 m_widget
= gtk_color_button_new_with_color( m_colour
.GetColor() );
77 gtk_widget_show( GTK_WIDGET(m_widget
) );
79 // GtkColourButton signals
80 g_signal_connect(m_widget
, "color-set",
81 G_CALLBACK(gtk_clrbutton_setcolor_callback
), this);
84 m_parent
->DoAddChild( this );
90 return wxGenericColourButton::Create(parent
, id
, col
, pos
, size
,
91 style
, validator
, name
);
95 wxColourButton::~wxColourButton()
99 void wxColourButton::UpdateColour()
101 if (!gtk_check_version(2,4,0))
102 gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget
), m_colour
.GetColor());
104 wxGenericColourButton::UpdateColour();
107 #endif // wxUSE_COLOURPICKERCTRL && defined(__WXGTK24__)