xref: /haiku/docs/user/interface/CheckBox.dox (revision 98057dd02a2411868fd4c35f7a48d20acfd92c23)
1/*
2 * Copyright 2011, Haiku inc.
3 * Distributed under the terms of the MIT Licence.
4 *
5 * Documentation by:
6 *		Stephan Aßmus, superstippi@gmx.de
7 *		Marc Flerackers, mflerackers@androme.be
8 *		John Scipione, jscipione@gmail.com
9 * Corresponds to:
10 *		/trunk/headers/os/interface/CheckBox.h	 rev 42794
11 *		/trunk/src/kits/interface/CheckBox.cpp	 rev 42794
12 */
13
14/*!
15	\file CheckBox.h
16	\brief Defines the BCheckBox class
17*/
18
19
20/*!
21	\class BCheckBox
22	\ingroup interface
23	\ingroup libbe
24	\brief BCheckBox is a user interface element used to make a binary
25		decision.
26
27	A BCheckBox object is used to draw a checkbox element. This simple control
28	has 2 states, \c B_CONTROL_OFF when the checkbox is unchecked and
29	\c B_CONTROL_ON when the checkbox is checked. A checkbox can also have a
30	descriptive label drawn to the right of the checkbox.
31
32	When the checkbox is checked it has an X drawn inside of it. The checkbox
33	can be checked by a mouse click or by pushing \key{Space} on the
34	keyboard when the checkbox has focus. A checkbox object with focus
35	is surrounded by a blue border. A checkbox can also be set
36	programmatically by calling the SetValue() method.
37
38	A few checkbox examples can be seen below in unchecked state, checked
39	state, and another unchecked checkbox with focus on it.
40
41	\image html BCheckBox_example.png
42*/
43
44
45/*!
46	\fn BCheckBox::BCheckBox(BRect frame, const char *name, const char *label,
47							 BMessage *message, uint32 resizingMode,
48							 uint32 flags)
49	\brief Construct a checkbox in the \a frame with a \a name, \a label,
50		model \a message, \a resizingMode, and creation \a flags.
51
52	The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF).
53	The \a label and the \a message parameters can be set to \c NULL.
54
55	\param frame The frame to draw the checkbox in.
56	\param name The name of the checkbox.
57	\param label The label displayed along with the checkbox.
58	\param message The message to send when the checkbox is activated.
59	\param resizingMode Defines the behavior of the checkbox as the parent
60		view resizes.
61	\param flags Behavior flags for the checkbox. See BView for details.
62*/
63
64
65/*!
66	\fn BCheckBox::BCheckBox(const char *name, const char *label,
67							 BMessage *message, uint32 flags)
68	\brief Construct a checkbox with a \a name, \a label, model \a message,
69		and creation \a flags suitable for use with the Layout API.
70
71	The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF).
72	The \a label and the \a message parameters can be set to \c NULL.
73
74	\param name The name of the checkbox.
75	\param label The label displayed along with the checkbox.
76	\param message The message to send when the checkbox is activated.
77	\param flags Behavior flags for the checkbox. See BView for details.
78*/
79
80
81/*!
82	\fn BCheckBox::BCheckBox(const char *label, BMessage *message)
83	\brief Constructs a BCheckBox object with just a \a label and model
84		\a message.
85
86	The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF).
87	The \a label and the \a message parameters can be set to \c NULL.
88
89	\param label The label displayed along with the checkbox.
90	\param message The message to send when the checkbox is activated.
91*/
92
93
94/*!
95	\fn BCheckBox::BCheckBox(BMessage *archive)
96	\brief Constructs a BCheckBox object from an \a archive message.
97
98	This method is usually not called directly. If you want to build a
99	checkbox from a message you should call Instantiate() which can
100	handle errors properly.
101
102	If the \a archive deep, the BCheckBox object will also unarchive each
103	of its child views recursively.
104
105	\param archive The \a archive message to restore from.
106*/
107
108
109/*!
110	\fn BCheckBox::~BCheckBox()
111	\brief Destructor Method.
112*/
113
114
115/*!
116	\fn void BCheckBox::Draw(BRect updateRect)
117	\brief Draws the area of the checkbox that intersects \a updateRect.
118
119	\note This is an hook method called by the Interface Kit, you don't
120	have to call it yourself. If you need to forcefully redraw the checkbox
121	consider calling Invalidate() instead.
122
123	\param updateRect The rectangular area to be drawn.
124
125	\sa BView::Draw()
126*/
127
128
129/*!
130	\fn void BCheckBox::FrameMoved(BPoint newLocation)
131	\brief Hook method that gets called when the checkbox is moved.
132
133	\param newLocation The point that the top left corner of the frame
134		is moved to.
135
136	\sa BView::FrameMoved()
137*/
138
139
140/*!
141	\fn void BCheckBox::FrameResized(float width, float height)
142	\brief Hook method that gets called when the checkbox is resized.
143
144	\param width The new \a width of the checkbox.
145	\param height The new \a height of the checkbox.
146
147	\sa BView::FrameResized()
148*/
149
150
151/*!
152	\fn void BCheckBox::GetPreferredSize(float* _width, float* _height)
153	\brief Fill out the preferred width and height of the checkbox
154		into the \a _width and \a _height parameters.
155
156	\param _width Pointer to a \c float to hold the width of the checkbox.
157	\param _height Pointer to a \c float to hold the height of the checkbox.
158
159	\sa BView::GetPreferredSize()
160*/
161
162
163/*!
164	\fn void BCheckBox::ResizeToPreferred()
165	\brief Resize the checkbox to its preferred size.
166
167	\sa BView::ResizeToPreferred()
168*/
169
170
171/*!
172	\fn void BCheckBox::InvalidateLayout(bool descendants)
173	\brief \brief Redraws the checkbox.
174
175	\param descendants Redraw child views as well.
176
177	\sa BLayout::InvalidateLayout()
178*/
179
180
181/*!
182	\fn BSize BCheckBox::MinSize()
183	\brief Get the minimum size of the checkbox.
184
185	\return The minimum size of the checkbox as a BSize.
186
187	\sa BAbstractLayout::MinSize()
188*/
189
190
191/*!
192	\fn BSize BCheckBox::MaxSize()
193	\brief Get the maximum size of the checkbox.
194
195	\return The maximum size of the checkbox as a BSize.
196
197	\sa BAbstractLayout::MaxSize()
198*/
199
200
201/*!
202	\fn BSize BCheckBox::PreferredSize()
203	\brief Get the preferred size of the checkbox.
204
205	\return The preferred size of the checkbox as a BSize.
206
207	\sa BAbstractLayout::PreferredSize()
208*/
209
210
211/*!
212	\fn void BCheckBox::MakeFocus(bool focused)
213	\brief Gives or removes focus from the checkbox.
214
215	\param focused \a true to set focus, \a false to remove it.
216
217	\sa BControl::MakeFocus()
218*/
219
220
221/*!
222	\fn void BCheckBox::SetValue(int32 value)
223	\brief Turn the checkbox on or off.
224
225	\param value The value to set the checkbox to, should be
226		either \c B_CONTROL_ON or \c B_CONTROL_OFF.
227
228	\sa BControl::SetValue()
229*/
230
231
232/*!
233	\fn status_t BCheckBox::Invoke(BMessage *message)
234	\brief Tells the messenger to send a message.
235
236	\param message The \a message to send.
237
238	\sa BInvoker::Invoke()
239*/
240