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 #if wxUSE_COLOURPICKERCTRL
22 #include "wx/clrpicker.h"
26 // ============================================================================
28 // ============================================================================
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
35 static void gtk_clrbutton_setcolor_callback(GtkColorButton
*widget
,
38 // update the m_colour member of the wxColourButton
41 gtk_color_button_get_color(widget
, &gdkColor
);
42 p
->SetGdkColor(gdkColor
);
44 // fire the colour-changed event
45 wxColourPickerEvent
event(p
, p
->GetId(), p
->GetColour());
46 p
->HandleWindowEvent(event
);
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 IMPLEMENT_DYNAMIC_CLASS(wxColourButton
, wxButton
)
56 bool wxColourButton::Create( wxWindow
*parent
, wxWindowID id
,
58 const wxPoint
&pos
, const wxSize
&size
,
59 long style
, const wxValidator
& validator
,
60 const wxString
&name
)
62 if (!PreCreation( parent
, pos
, size
) ||
63 !wxControl::CreateBase(parent
, id
, pos
, size
, style
, validator
, name
))
65 wxFAIL_MSG( wxT("wxColourButton creation failed") );
70 m_widget
= gtk_color_button_new_with_color( m_colour
.GetColor() );
71 g_object_ref(m_widget
);
72 gtk_widget_show(m_widget
);
74 // GtkColourButton signals
75 g_signal_connect(m_widget
, "color-set",
76 G_CALLBACK(gtk_clrbutton_setcolor_callback
), this);
79 m_parent
->DoAddChild( this );
87 wxColourButton::~wxColourButton()
91 void wxColourButton::UpdateColour()
93 gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget
), m_colour
.GetColor());
96 #endif // wxUSE_COLOURPICKERCTRL