]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/clrpicker.cpp
Make wxMSW stack walking methods work with Unicode identifiers.
[wxWidgets.git] / src / gtk / clrpicker.cpp
CommitLineData
ec376c8f
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/clrpicker.cpp
3// Purpose: implementation of wxColourButton
4// Author: Francesco Montorsi
5// Modified By:
6// Created: 15/04/2006
ec376c8f
VZ
7// Copyright: (c) Francesco Montorsi
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11
12// ----------------------------------------------------------------------------
13// headers
14// ----------------------------------------------------------------------------
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
ff654490 19#if wxUSE_COLOURPICKERCTRL
4ce7b1e4 20
ec376c8f
VZ
21#include "wx/clrpicker.h"
22
ec376c8f
VZ
23#include <gtk/gtk.h>
24
ec376c8f
VZ
25// ============================================================================
26// implementation
27// ============================================================================
28
ec376c8f
VZ
29//-----------------------------------------------------------------------------
30// "color-set"
31//-----------------------------------------------------------------------------
32
33extern "C" {
34static void gtk_clrbutton_setcolor_callback(GtkColorButton *widget,
35 wxColourButton *p)
36{
37 // update the m_colour member of the wxColourButton
38 wxASSERT(p);
9dc44eff
PC
39#ifdef __WXGTK3__
40 GdkRGBA gdkColor;
41 gtk_color_button_get_rgba(widget, &gdkColor);
42#else
c6685317
PC
43 GdkColor gdkColor;
44 gtk_color_button_get_color(widget, &gdkColor);
9dc44eff
PC
45#endif
46 p->GTKSetColour(gdkColor);
ec376c8f
VZ
47
48 // fire the colour-changed event
49 wxColourPickerEvent event(p, p->GetId(), p->GetColour());
937013e0 50 p->HandleWindowEvent(event);
ec376c8f
VZ
51}
52}
53
54//-----------------------------------------------------------------------------
55// wxColourButton
56//-----------------------------------------------------------------------------
57
ff654490 58IMPLEMENT_DYNAMIC_CLASS(wxColourButton, wxButton)
ec376c8f
VZ
59
60bool wxColourButton::Create( wxWindow *parent, wxWindowID id,
61 const wxColour &col,
62 const wxPoint &pos, const wxSize &size,
63 long style, const wxValidator& validator,
64 const wxString &name )
65{
ff654490
VZ
66 if (!PreCreation( parent, pos, size ) ||
67 !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
ec376c8f 68 {
ff654490
VZ
69 wxFAIL_MSG( wxT("wxColourButton creation failed") );
70 return false;
71 }
ec376c8f 72
ff654490 73 m_colour = col;
9dc44eff
PC
74#ifdef __WXGTK3__
75 m_widget = gtk_color_button_new_with_rgba(m_colour);
76#else
ff654490 77 m_widget = gtk_color_button_new_with_color( m_colour.GetColor() );
9dc44eff 78#endif
9ff9d30c 79 g_object_ref(m_widget);
ec376c8f 80
ff654490
VZ
81 // GtkColourButton signals
82 g_signal_connect(m_widget, "color-set",
83 G_CALLBACK(gtk_clrbutton_setcolor_callback), this);
ec376c8f
VZ
84
85
ff654490
VZ
86 m_parent->DoAddChild( this );
87
88 PostCreation(size);
89 SetInitialSize(size);
ec376c8f 90
ec376c8f
VZ
91 return true;
92}
93
94wxColourButton::~wxColourButton()
95{
96}
97
98void wxColourButton::UpdateColour()
99{
9dc44eff
PC
100#ifdef __WXGTK3__
101 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(m_widget), m_colour);
102#else
ff654490 103 gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor());
9dc44eff 104#endif
ec376c8f
VZ
105}
106
ff654490 107#endif // wxUSE_COLOURPICKERCTRL