]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: clrpicker.h | |
e54c96f1 | 3 | // Purpose: interface of wxColourPickerCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
575821fa RD |
9 | #define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL) |
10 | #define wxCLRP_DEFAULT_STYLE 0 | |
11 | #define wxCLRP_SHOW_LABEL 0x0008 | |
12 | ||
13 | wxEventType wxEVT_COMMAND_COLOURPICKER_CHANGED; | |
14 | ||
15 | ||
23324ae1 FM |
16 | /** |
17 | @class wxColourPickerCtrl | |
7c913512 | 18 | |
d18d9f60 BP |
19 | This control allows the user to select a colour. The generic implementation |
20 | is a button which brings up a wxColourDialog when clicked. Native | |
21 | implementation may differ but this is usually a (small) widget which give | |
22 | access to the colour-chooser dialog. It is only available if | |
23 | @c wxUSE_COLOURPICKERCTRL is set to 1 (the default). | |
7c913512 | 24 | |
23324ae1 | 25 | @beginStyleTable |
8c6791e4 | 26 | @style{wxCLRP_DEFAULT_STYLE} |
23324ae1 | 27 | The default style: 0. |
8c6791e4 | 28 | @style{wxCLRP_USE_TEXTCTRL} |
23324ae1 FM |
29 | Creates a text control to the left of the picker button which is |
30 | completely managed by the wxColourPickerCtrl and which can be used | |
31 | by the user to specify a colour (see SetColour). The text control | |
32 | is automatically synchronized with button's value. Use functions | |
33 | defined in wxPickerBase to modify the text control. | |
8c6791e4 | 34 | @style{wxCLRP_SHOW_LABEL} |
23324ae1 FM |
35 | Shows the colour in HTML form (AABBCC) as colour button label |
36 | (instead of no label at all). | |
37 | @endStyleTable | |
7c913512 | 38 | |
3051a44a | 39 | @beginEventEmissionTable{wxColourPickerEvent} |
d18d9f60 BP |
40 | @event{EVT_COLOURPICKER_CHANGED(id, func)} |
41 | The user changed the colour selected in the control either using the | |
42 | button or using text control (see @c wxCLRP_USE_TEXTCTRL; note that | |
43 | in this case the event is fired only if the user’s input is valid, | |
44 | i.e. recognizable). | |
45 | @endEventTable | |
46 | ||
23324ae1 | 47 | @library{wxcore} |
d18d9f60 | 48 | @category{pickers} |
ce154616 | 49 | @appearance{colourpickerctrl} |
7c913512 | 50 | |
e54c96f1 | 51 | @see wxColourDialog, wxColourPickerEvent |
23324ae1 FM |
52 | */ |
53 | class wxColourPickerCtrl : public wxPickerBase | |
54 | { | |
55 | public: | |
575821fa RD |
56 | wxColourPickerCtrl(); |
57 | ||
23324ae1 | 58 | /** |
d18d9f60 | 59 | Initializes the object and calls Create() with all the parameters. |
23324ae1 | 60 | */ |
4cc4bfaf | 61 | wxColourPickerCtrl(wxWindow* parent, wxWindowID id, |
4707b84c | 62 | const wxColour& colour = *wxBLACK, |
23324ae1 FM |
63 | const wxPoint& pos = wxDefaultPosition, |
64 | const wxSize& size = wxDefaultSize, | |
65 | long style = wxCLRP_DEFAULT_STYLE, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
9d9c1c24 | 67 | const wxString& name = wxColourPickerCtrlNameStr); |
23324ae1 FM |
68 | |
69 | /** | |
d18d9f60 BP |
70 | Creates a colour picker with the given arguments. |
71 | ||
7c913512 | 72 | @param parent |
4cc4bfaf | 73 | Parent window, must not be non-@NULL. |
7c913512 | 74 | @param id |
4cc4bfaf | 75 | The identifier for the control. |
7c913512 | 76 | @param colour |
4cc4bfaf | 77 | The initial colour shown in the control. |
7c913512 | 78 | @param pos |
4cc4bfaf | 79 | Initial position. |
7c913512 | 80 | @param size |
4cc4bfaf | 81 | Initial size. |
7c913512 | 82 | @param style |
4cc4bfaf | 83 | The window style, see wxCRLP_* flags. |
7c913512 | 84 | @param validator |
4cc4bfaf | 85 | Validator which can be used for additional date checks. |
7c913512 | 86 | @param name |
4cc4bfaf | 87 | Control name. |
3c4f71cc | 88 | |
d29a9a8a BP |
89 | @return @true if the control was successfully created or @false if |
90 | creation failed. | |
23324ae1 | 91 | */ |
4cc4bfaf | 92 | bool Create(wxWindow* parent, wxWindowID id, |
4707b84c | 93 | const wxColour& colour = *wxBLACK, |
23324ae1 FM |
94 | const wxPoint& pos = wxDefaultPosition, |
95 | const wxSize& size = wxDefaultSize, | |
96 | long style = wxCLRP_DEFAULT_STYLE, | |
97 | const wxValidator& validator = wxDefaultValidator, | |
9d9c1c24 | 98 | const wxString& name = wxColourPickerCtrlNameStr); |
23324ae1 FM |
99 | |
100 | /** | |
101 | Returns the currently selected colour. | |
102 | */ | |
328f5751 | 103 | wxColour GetColour() const; |
23324ae1 FM |
104 | |
105 | //@{ | |
106 | /** | |
d18d9f60 | 107 | Sets the currently selected colour. See wxColour::Set(). |
23324ae1 | 108 | */ |
4cc4bfaf FM |
109 | void SetColour(const wxColour& col); |
110 | void SetColour(const wxString& colname); | |
23324ae1 FM |
111 | //@} |
112 | }; | |
113 | ||
114 | ||
e54c96f1 | 115 | |
23324ae1 FM |
116 | /** |
117 | @class wxColourPickerEvent | |
7c913512 | 118 | |
d18d9f60 BP |
119 | This event class is used for the events generated by wxColourPickerCtrl. |
120 | ||
121 | @beginEventTable{wxColourPickerEvent} | |
122 | @event{EVT_COLOURPICKER_CHANGED(id, func)} | |
123 | Generated whenever the selected colour changes. | |
124 | @endEventTable | |
7c913512 | 125 | |
23324ae1 | 126 | @library{wxcore} |
d18d9f60 | 127 | @category{events} |
7c913512 | 128 | |
e54c96f1 | 129 | @see wxColourPickerCtrl |
23324ae1 FM |
130 | */ |
131 | class wxColourPickerEvent : public wxCommandEvent | |
132 | { | |
133 | public: | |
575821fa RD |
134 | wxColourPickerEvent(); |
135 | ||
23324ae1 FM |
136 | /** |
137 | The constructor is not normally used by the user code. | |
138 | */ | |
4cc4bfaf | 139 | wxColourPickerEvent(wxObject* generator, int id, |
23324ae1 FM |
140 | const wxColour& colour); |
141 | ||
142 | /** | |
143 | Retrieve the colour the user has just selected. | |
144 | */ | |
328f5751 | 145 | wxColour GetColour() const; |
23324ae1 FM |
146 | |
147 | /** | |
148 | Set the colour associated with the event. | |
149 | */ | |
4cc4bfaf | 150 | void SetColour(const wxColour& pos); |
23324ae1 | 151 | }; |
e54c96f1 | 152 |