1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/clrpicker.cpp
3 // Purpose: implementation of wxColourButton
4 // Author: Francesco Montorsi
7 // Copyright: (c) Francesco Montorsi
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 // ----------------------------------------------------------------------------
14 // ----------------------------------------------------------------------------
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #if wxUSE_COLOURPICKERCTRL
21 #include "wx/clrpicker.h"
25 // ============================================================================
27 // ============================================================================
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
34 static void gtk_clrbutton_setcolor_callback(GtkColorButton
*widget
,
37 // update the m_colour member of the wxColourButton
41 gtk_color_button_get_rgba(widget
, &gdkColor
);
44 gtk_color_button_get_color(widget
, &gdkColor
);
46 p
->GTKSetColour(gdkColor
);
48 // fire the colour-changed event
49 wxColourPickerEvent
event(p
, p
->GetId(), p
->GetColour());
50 p
->HandleWindowEvent(event
);
54 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 IMPLEMENT_DYNAMIC_CLASS(wxColourButton
, wxButton
)
60 bool wxColourButton::Create( wxWindow
*parent
, wxWindowID id
,
62 const wxPoint
&pos
, const wxSize
&size
,
63 long style
, const wxValidator
& validator
,
64 const wxString
&name
)
66 if (!PreCreation( parent
, pos
, size
) ||
67 !wxControl::CreateBase(parent
, id
, pos
, size
, style
, validator
, name
))
69 wxFAIL_MSG( wxT("wxColourButton creation failed") );
75 m_widget
= gtk_color_button_new_with_rgba(m_colour
);
77 m_widget
= gtk_color_button_new_with_color( m_colour
.GetColor() );
79 g_object_ref(m_widget
);
81 // GtkColourButton signals
82 g_signal_connect(m_widget
, "color-set",
83 G_CALLBACK(gtk_clrbutton_setcolor_callback
), this);
86 m_parent
->DoAddChild( this );
94 wxColourButton::~wxColourButton()
98 void wxColourButton::UpdateColour()
101 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(m_widget
), m_colour
);
103 gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget
), m_colour
.GetColor());
107 #endif // wxUSE_COLOURPICKERCTRL