]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tglbtn.h | |
78e87bf7 | 3 | // Purpose: interface of wxBitmapToggleButton, wxToggleButton |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
e54c96f1 | 8 | |
ce7fe42e | 9 | wxEventType wxEVT_TOGGLEBUTTON; |
dec0a353 | 10 | |
23324ae1 FM |
11 | /** |
12 | @class wxToggleButton | |
7c913512 | 13 | |
78e87bf7 FM |
14 | wxToggleButton is a button that stays pressed when clicked by the user. |
15 | In other words, it is similar to wxCheckBox in functionality but looks like a wxButton. | |
7c913512 | 16 | |
23324ae1 | 17 | Since wxWidgets version 2.9.0 this control emits an update UI event. |
7c913512 | 18 | |
78e87bf7 | 19 | You can see wxToggleButton in action in @ref page_samples_controls. |
7c913512 | 20 | |
3051a44a | 21 | @beginEventEmissionTable{wxCommandEvent} |
8c6791e4 | 22 | @event{EVT_TOGGLEBUTTON(id, func)} |
ce7fe42e | 23 | Handles a wxEVT_TOGGLEBUTTON event. |
23324ae1 | 24 | @endEventTable |
7c913512 | 25 | |
23324ae1 FM |
26 | @library{wxcore} |
27 | @category{ctrl} | |
ce154616 | 28 | @appearance{togglebutton} |
7c913512 | 29 | |
e54c96f1 | 30 | @see wxCheckBox, wxButton, wxBitmapToggleButton |
23324ae1 | 31 | */ |
884a3e9d | 32 | class wxToggleButton : public wxAnyButton |
23324ae1 FM |
33 | { |
34 | public: | |
23ae751e RR |
35 | /** |
36 | Default constructor. | |
37 | */ | |
38 | wxToggleButton(); | |
98ccd545 | 39 | |
23324ae1 FM |
40 | /** |
41 | Constructor, creating and showing a toggle button. | |
3c4f71cc | 42 | |
7c913512 | 43 | @param parent |
4cc4bfaf | 44 | Parent window. Must not be @NULL. |
7c913512 | 45 | @param id |
4cc4bfaf | 46 | Toggle button identifier. The value wxID_ANY indicates a default value. |
7c913512 | 47 | @param label |
4cc4bfaf | 48 | Text to be displayed next to the toggle button. |
7c913512 | 49 | @param pos |
78e87bf7 | 50 | Toggle button position. |
dc1b07fd | 51 | If ::wxDefaultPosition is specified then a default position is chosen. |
7c913512 | 52 | @param size |
78e87bf7 | 53 | Toggle button size. |
dc1b07fd | 54 | If ::wxDefaultSize is specified then a default size is chosen. |
7c913512 | 55 | @param style |
4cc4bfaf | 56 | Window style. See wxToggleButton. |
77bfb902 | 57 | @param val |
4cc4bfaf | 58 | Window validator. |
7c913512 | 59 | @param name |
4cc4bfaf | 60 | Window name. |
3c4f71cc | 61 | |
4cc4bfaf | 62 | @see Create(), wxValidator |
23324ae1 | 63 | */ |
7c913512 FM |
64 | wxToggleButton(wxWindow* parent, wxWindowID id, |
65 | const wxString& label, | |
66 | const wxPoint& pos = wxDefaultPosition, | |
67 | const wxSize& size = wxDefaultSize, | |
68 | long style = 0, | |
a6052817 | 69 | const wxValidator& val = wxDefaultValidator, |
98ccd545 | 70 | const wxString& name = wxCheckBoxNameStr); |
23324ae1 FM |
71 | |
72 | /** | |
73 | Destructor, destroying the toggle button. | |
74 | */ | |
a6052817 | 75 | virtual ~wxToggleButton(); |
23324ae1 FM |
76 | |
77 | /** | |
78e87bf7 FM |
78 | Creates the toggle button for two-step construction. |
79 | See wxToggleButton() for details. | |
23324ae1 FM |
80 | */ |
81 | bool Create(wxWindow* parent, wxWindowID id, | |
82 | const wxString& label, | |
83 | const wxPoint& pos = wxDefaultPosition, | |
84 | const wxSize& size = wxDefaultSize, | |
85 | long style = 0, | |
a6052817 | 86 | const wxValidator& val = wxDefaultValidator, |
98ccd545 | 87 | const wxString& name = wxCheckBoxNameStr); |
23324ae1 FM |
88 | |
89 | /** | |
90 | Gets the state of the toggle button. | |
3c4f71cc | 91 | |
d29a9a8a | 92 | @return Returns @true if it is pressed, @false otherwise. |
23324ae1 | 93 | */ |
adaaa686 | 94 | virtual bool GetValue() const; |
23324ae1 FM |
95 | |
96 | /** | |
78e87bf7 FM |
97 | Sets the toggle button to the given state. |
98 | This does not cause a @c EVT_TOGGLEBUTTON event to be emitted. | |
3c4f71cc | 99 | |
7c913512 | 100 | @param state |
4cc4bfaf | 101 | If @true, the button is pressed. |
23324ae1 | 102 | */ |
adaaa686 | 103 | virtual void SetValue(bool state); |
23324ae1 | 104 | }; |
e54c96f1 | 105 | |
a6052817 FM |
106 | |
107 | /** | |
108 | @class wxBitmapToggleButton | |
a6052817 | 109 | |
323d36e4 VZ |
110 | wxBitmapToggleButton is a wxToggleButton that contains a bitmap instead of |
111 | text. | |
112 | ||
113 | This class is not available in all ports currently (although it is | |
114 | available in the major ones), test for @c wxHAS_BITMAPTOGGLEBUTTON to | |
115 | determine whether it can be used (in addition for possibly testing for | |
116 | @c wxUSE_TOGGLEBTN which can be set to 0 to explicitly disable support for | |
117 | this class and wxToggleButton). | |
a6052817 FM |
118 | |
119 | This control emits an update UI event. | |
120 | ||
3051a44a | 121 | @beginEventEmissionTable{wxCommandEvent} |
8c6791e4 | 122 | @event{EVT_TOGGLEBUTTON(id, func)} |
ce7fe42e | 123 | Handles a wxEVT_TOGGLEBUTTON event. |
a6052817 FM |
124 | @endEventTable |
125 | ||
126 | @library{wxcore} | |
127 | @category{ctrl} | |
a6052817 | 128 | */ |
884a3e9d | 129 | class wxBitmapToggleButton : public wxToggleButton |
a6052817 FM |
130 | { |
131 | public: | |
23ae751e RR |
132 | /** |
133 | Default constructor. | |
134 | */ | |
135 | wxBitmapToggleButton(); | |
98ccd545 | 136 | |
a6052817 FM |
137 | /** |
138 | Constructor, creating and showing a toggle button with the bitmap @e label. | |
139 | Internally calls Create(). | |
140 | */ | |
a6052817 FM |
141 | wxBitmapToggleButton(wxWindow* parent, wxWindowID id, |
142 | const wxBitmap& label, | |
143 | const wxPoint& pos = wxDefaultPosition, | |
144 | const wxSize& size = wxDefaultSize, | |
145 | long style = 0, | |
146 | const wxValidator& val = wxDefaultValidator, | |
98ccd545 | 147 | const wxString& name = wxCheckBoxNameStr); |
a6052817 FM |
148 | |
149 | /** | |
150 | Create method for two-step construction. | |
151 | */ | |
152 | bool Create(wxWindow* parent, wxWindowID id, | |
153 | const wxBitmap& label, | |
154 | const wxPoint& pos = wxDefaultPosition, | |
155 | const wxSize& size = wxDefaultSize, | |
156 | long style = 0, | |
157 | const wxValidator& val = wxDefaultValidator, | |
98ccd545 | 158 | const wxString& name = wxCheckBoxNameStr); |
a6052817 FM |
159 | |
160 | /** | |
161 | Gets the state of the toggle button. | |
162 | ||
d29a9a8a | 163 | @return Returns @true if it is pressed, @false otherwise. |
a6052817 FM |
164 | */ |
165 | virtual bool GetValue() const; | |
166 | ||
167 | /** | |
78e87bf7 FM |
168 | Sets the toggle button to the given state. |
169 | This does not cause a @c EVT_TOGGLEBUTTON event to be emitted. | |
a6052817 FM |
170 | |
171 | @param state | |
172 | If @true, the button is pressed. | |
173 | */ | |
174 | virtual void SetValue(bool state); | |
175 | }; | |
176 |