1/////////////////////////////////////////////////////////////////////////////
2// Name:        wx/generic/clrpickerg.h
3// Purpose:     wxGenericColourButton header
4// Author:      Francesco Montorsi (based on Vadim Zeitlin's code)
5// Modified by:
6// Created:     14/4/2006
7// Copyright:   (c) Vadim Zeitlin, Francesco Montorsi
8// RCS-ID:      $Id: clrpickerg.h 58967 2009-02-17 13:31:28Z SC $
9// Licence:     wxWindows Licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CLRPICKER_H_
13#define _WX_CLRPICKER_H_
14
15#include "wx/button.h"
16#include "wx/cmndata.h"
17
18//-----------------------------------------------------------------------------
19// wxGenericColourButton: a button which brings up a wxColourDialog
20//-----------------------------------------------------------------------------
21
22// show the colour in HTML form (#AABBCC) as colour button label
23#define wxCLRBTN_SHOW_LABEL     100
24
25// the default style
26#define wxCLRBTN_DEFAULT_STYLE  (wxCLRBTN_SHOW_LABEL)
27
28#ifndef wxCLRBTN_USES_BMP_BUTTON
29    #define wxCLRBTN_USES_BMP_BUTTON 0
30#endif
31
32#if wxCLRBTN_USES_BMP_BUTTON
33    #include "wx/bmpbutton.h"
34    #define wxCLRBTN_BASE_CLASS wxBitmapButton
35#else
36     #define wxCLRBTN_BASE_CLASS wxButton
37#endif
38
39class WXDLLIMPEXP_CORE wxGenericColourButton : public wxCLRBTN_BASE_CLASS,
40                                               public wxColourPickerWidgetBase
41{
42public:
43    wxGenericColourButton() {}
44    wxGenericColourButton(wxWindow *parent,
45                          wxWindowID id,
46                          const wxColour& col = *wxBLACK,
47                          const wxPoint& pos = wxDefaultPosition,
48                          const wxSize& size = wxDefaultSize,
49                          long style = wxCLRBTN_DEFAULT_STYLE,
50                          const wxValidator& validator = wxDefaultValidator,
51                          const wxString& name = wxColourPickerWidgetNameStr)
52    {
53        Create(parent, id, col, pos, size, style, validator, name);
54    }
55
56    virtual ~wxGenericColourButton() {}
57
58
59public:     // API extensions specific for wxGenericColourButton
60
61    // user can override this to init colour data in a different way
62    virtual void InitColourData();
63
64    // returns the colour data shown in wxColourDialog
65    wxColourData *GetColourData() { return &ms_data; }
66
67
68public:
69
70    bool Create(wxWindow *parent,
71                wxWindowID id,
72                const wxColour& col = *wxBLACK,
73                const wxPoint& pos = wxDefaultPosition,
74                const wxSize& size = wxDefaultSize,
75                long style = wxCLRBTN_DEFAULT_STYLE,
76                const wxValidator& validator = wxDefaultValidator,
77                const wxString& name = wxColourPickerWidgetNameStr);
78
79    void OnButtonClick(wxCommandEvent &);
80
81
82protected:
83
84    wxSize DoGetBestSize() const;
85
86    void UpdateColour();
87
88    // the colour data shown in wxColourPickerCtrlGeneric
89    // controls. This member is static so that all colour pickers
90    // in the program share the same set of custom colours.
91    static wxColourData ms_data;
92
93private:
94   DECLARE_DYNAMIC_CLASS(wxGenericColourButton)
95};
96
97
98#endif // _WX_CLRPICKER_H_
99