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