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