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