]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/tglbtn.h
06bea22a731326b54810ed00e31c9fda586c2d68
[wxWidgets.git] / interface / wx / tglbtn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tglbtn.h
3 // Purpose: interface of wxBitmapToggleButton, wxToggleButton
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 @class wxToggleButton
12
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.
15
16 Since wxWidgets version 2.9.0 this control emits an update UI event.
17
18 You can see wxToggleButton in action in @ref page_samples_controls.
19
20 @beginEventEmissionTable{wxCommandEvent}
21 @event{EVT_TOGGLEBUTTON(id, func)}
22 Handles a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
23 @endEventTable
24
25 @library{wxcore}
26 @category{ctrl}
27 @appearance{togglebutton}
28
29 @see wxCheckBox, wxButton, wxBitmapToggleButton
30 */
31 class wxToggleButton : public wxAnyButton
32 {
33 public:
34 /**
35 Default constructor.
36 */
37 wxToggleButton();
38
39 /**
40 Constructor, creating and showing a toggle button.
41
42 @param parent
43 Parent window. Must not be @NULL.
44 @param id
45 Toggle button identifier. The value wxID_ANY indicates a default value.
46 @param label
47 Text to be displayed next to the toggle button.
48 @param pos
49 Toggle button position.
50 If ::wxDefaultPosition is specified then a default position is chosen.
51 @param size
52 Toggle button size.
53 If ::wxDefaultSize is specified then a default size is chosen.
54 @param style
55 Window style. See wxToggleButton.
56 @param val
57 Window validator.
58 @param name
59 Window name.
60
61 @see Create(), wxValidator
62 */
63 wxToggleButton(wxWindow* parent, wxWindowID id,
64 const wxString& label,
65 const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize,
67 long style = 0,
68 const wxValidator& val = wxDefaultValidator,
69 const wxString& name = wxCheckBoxNameStr);
70
71 /**
72 Destructor, destroying the toggle button.
73 */
74 virtual ~wxToggleButton();
75
76 /**
77 Creates the toggle button for two-step construction.
78 See wxToggleButton() for details.
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,
85 const wxValidator& val = wxDefaultValidator,
86 const wxString& name = wxCheckBoxNameStr);
87
88 /**
89 Gets the state of the toggle button.
90
91 @return Returns @true if it is pressed, @false otherwise.
92 */
93 virtual bool GetValue() const;
94
95 /**
96 Sets the toggle button to the given state.
97 This does not cause a @c EVT_TOGGLEBUTTON event to be emitted.
98
99 @param state
100 If @true, the button is pressed.
101 */
102 virtual void SetValue(bool state);
103 };
104
105
106 /**
107 @class wxBitmapToggleButton
108
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).
117
118 This control emits an update UI event.
119
120 @beginEventEmissionTable{wxCommandEvent}
121 @event{EVT_TOGGLEBUTTON(id, func)}
122 Handles a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
123 @endEventTable
124
125 @library{wxcore}
126 @category{ctrl}
127 */
128 class wxBitmapToggleButton : public wxToggleButton
129 {
130 public:
131 /**
132 Default constructor.
133 */
134 wxBitmapToggleButton();
135
136 /**
137 Constructor, creating and showing a toggle button with the bitmap @e label.
138 Internally calls Create().
139 */
140 wxBitmapToggleButton(wxWindow* parent, wxWindowID id,
141 const wxBitmap& label,
142 const wxPoint& pos = wxDefaultPosition,
143 const wxSize& size = wxDefaultSize,
144 long style = 0,
145 const wxValidator& val = wxDefaultValidator,
146 const wxString& name = wxCheckBoxNameStr);
147
148 /**
149 Create method for two-step construction.
150 */
151 bool Create(wxWindow* parent, wxWindowID id,
152 const wxBitmap& label,
153 const wxPoint& pos = wxDefaultPosition,
154 const wxSize& size = wxDefaultSize,
155 long style = 0,
156 const wxValidator& val = wxDefaultValidator,
157 const wxString& name = wxCheckBoxNameStr);
158
159 /**
160 Gets the state of the toggle button.
161
162 @return Returns @true if it is pressed, @false otherwise.
163 */
164 virtual bool GetValue() const;
165
166 /**
167 Sets the toggle button to the given state.
168 This does not cause a @c EVT_TOGGLEBUTTON event to be emitted.
169
170 @param state
171 If @true, the button is pressed.
172 */
173 virtual void SetValue(bool state);
174 };
175