16ac7032dSJohn Scipione/* 2*820dca4dSJohn Scipione * Copyright 2011 Haiku Inc. All rights reserved. 3*820dca4dSJohn Scipione * Distributed under the terms of the MIT License. 46ac7032dSJohn Scipione * 5*820dca4dSJohn Scipione * Authors: 66ac7032dSJohn Scipione * Stephan Aßmus, superstippi@gmx.de 76ac7032dSJohn Scipione * Marc Flerackers, mflerackers@androme.be 86ac7032dSJohn Scipione * John Scipione, jscipione@gmail.com 9*820dca4dSJohn Scipione * 106ac7032dSJohn Scipione * Corresponds to: 116ac7032dSJohn Scipione * /trunk/headers/os/interface/CheckBox.h rev 42794 126ac7032dSJohn Scipione * /trunk/src/kits/interface/CheckBox.cpp rev 42794 136ac7032dSJohn Scipione */ 146ac7032dSJohn Scipione 15*820dca4dSJohn Scipione 166ac7032dSJohn Scipione/*! 176ac7032dSJohn Scipione \file CheckBox.h 18*820dca4dSJohn Scipione \ingroup interface 19*820dca4dSJohn Scipione \ingroup libbe 206ac7032dSJohn Scipione \brief Defines the BCheckBox class 216ac7032dSJohn Scipione*/ 226ac7032dSJohn Scipione 236ac7032dSJohn Scipione 246ac7032dSJohn Scipione/*! 256ac7032dSJohn Scipione \class BCheckBox 266ac7032dSJohn Scipione \ingroup interface 276ac7032dSJohn Scipione \ingroup libbe 286ac7032dSJohn Scipione \brief BCheckBox is a user interface element used to make a binary 296ac7032dSJohn Scipione decision. 306ac7032dSJohn Scipione 316ac7032dSJohn Scipione A BCheckBox object is used to draw a checkbox element. This simple control 326ac7032dSJohn Scipione has 2 states, \c B_CONTROL_OFF when the checkbox is unchecked and 336ac7032dSJohn Scipione \c B_CONTROL_ON when the checkbox is checked. A checkbox can also have a 346ac7032dSJohn Scipione descriptive label drawn to the right of the checkbox. 356ac7032dSJohn Scipione 366ac7032dSJohn Scipione When the checkbox is checked it has an X drawn inside of it. The checkbox 376ac7032dSJohn Scipione can be checked by a mouse click or by pushing \key{Space} on the 386ac7032dSJohn Scipione keyboard when the checkbox has focus. A checkbox object with focus 396ac7032dSJohn Scipione is surrounded by a blue border. A checkbox can also be set 406ac7032dSJohn Scipione programmatically by calling the SetValue() method. 416ac7032dSJohn Scipione 426ac7032dSJohn Scipione A few checkbox examples can be seen below in unchecked state, checked 436ac7032dSJohn Scipione state, and another unchecked checkbox with focus on it. 446ac7032dSJohn Scipione 456ac7032dSJohn Scipione \image html BCheckBox_example.png 466ac7032dSJohn Scipione*/ 476ac7032dSJohn Scipione 486ac7032dSJohn Scipione 496ac7032dSJohn Scipione/*! 506ac7032dSJohn Scipione \fn BCheckBox::BCheckBox(BRect frame, const char *name, const char *label, 516ac7032dSJohn Scipione BMessage *message, uint32 resizingMode, 526ac7032dSJohn Scipione uint32 flags) 536ac7032dSJohn Scipione \brief Construct a checkbox in the \a frame with a \a name, \a label, 546ac7032dSJohn Scipione model \a message, \a resizingMode, and creation \a flags. 556ac7032dSJohn Scipione 566ac7032dSJohn Scipione The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF). 576ac7032dSJohn Scipione The \a label and the \a message parameters can be set to \c NULL. 586ac7032dSJohn Scipione 596ac7032dSJohn Scipione \param frame The frame to draw the checkbox in. 606ac7032dSJohn Scipione \param name The name of the checkbox. 616ac7032dSJohn Scipione \param label The label displayed along with the checkbox. 626ac7032dSJohn Scipione \param message The message to send when the checkbox is activated. 636ac7032dSJohn Scipione \param resizingMode Defines the behavior of the checkbox as the parent 646ac7032dSJohn Scipione view resizes. 656ac7032dSJohn Scipione \param flags Behavior flags for the checkbox. See BView for details. 666ac7032dSJohn Scipione*/ 676ac7032dSJohn Scipione 686ac7032dSJohn Scipione 696ac7032dSJohn Scipione/*! 706ac7032dSJohn Scipione \fn BCheckBox::BCheckBox(const char *name, const char *label, 716ac7032dSJohn Scipione BMessage *message, uint32 flags) 726ac7032dSJohn Scipione \brief Construct a checkbox with a \a name, \a label, model \a message, 736ac7032dSJohn Scipione and creation \a flags suitable for use with the Layout API. 746ac7032dSJohn Scipione 756ac7032dSJohn Scipione The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF). 766ac7032dSJohn Scipione The \a label and the \a message parameters can be set to \c NULL. 776ac7032dSJohn Scipione 786ac7032dSJohn Scipione \param name The name of the checkbox. 796ac7032dSJohn Scipione \param label The label displayed along with the checkbox. 806ac7032dSJohn Scipione \param message The message to send when the checkbox is activated. 816ac7032dSJohn Scipione \param flags Behavior flags for the checkbox. See BView for details. 826ac7032dSJohn Scipione*/ 836ac7032dSJohn Scipione 846ac7032dSJohn Scipione 856ac7032dSJohn Scipione/*! 866ac7032dSJohn Scipione \fn BCheckBox::BCheckBox(const char *label, BMessage *message) 876ac7032dSJohn Scipione \brief Constructs a BCheckBox object with just a \a label and model 886ac7032dSJohn Scipione \a message. 896ac7032dSJohn Scipione 906ac7032dSJohn Scipione The initial value of the checkbox is set to 0 (\c B_CONTROL_OFF). 916ac7032dSJohn Scipione The \a label and the \a message parameters can be set to \c NULL. 926ac7032dSJohn Scipione 936ac7032dSJohn Scipione \param label The label displayed along with the checkbox. 946ac7032dSJohn Scipione \param message The message to send when the checkbox is activated. 956ac7032dSJohn Scipione*/ 966ac7032dSJohn Scipione 976ac7032dSJohn Scipione 986ac7032dSJohn Scipione/*! 996ac7032dSJohn Scipione \fn BCheckBox::BCheckBox(BMessage *archive) 1006ac7032dSJohn Scipione \brief Constructs a BCheckBox object from an \a archive message. 1016ac7032dSJohn Scipione 1026ac7032dSJohn Scipione This method is usually not called directly. If you want to build a 1036ac7032dSJohn Scipione checkbox from a message you should call Instantiate() which can 1046ac7032dSJohn Scipione handle errors properly. 1056ac7032dSJohn Scipione 1066ac7032dSJohn Scipione If the \a archive deep, the BCheckBox object will also unarchive each 1076ac7032dSJohn Scipione of its child views recursively. 1086ac7032dSJohn Scipione 1096ac7032dSJohn Scipione \param archive The \a archive message to restore from. 1106ac7032dSJohn Scipione*/ 1116ac7032dSJohn Scipione 1126ac7032dSJohn Scipione 1136ac7032dSJohn Scipione/*! 1146ac7032dSJohn Scipione \fn BCheckBox::~BCheckBox() 1156ac7032dSJohn Scipione \brief Destructor Method. 1166ac7032dSJohn Scipione*/ 1176ac7032dSJohn Scipione 1186ac7032dSJohn Scipione 1196ac7032dSJohn Scipione/*! 1206ac7032dSJohn Scipione \fn void BCheckBox::Draw(BRect updateRect) 1216ac7032dSJohn Scipione \brief Draws the area of the checkbox that intersects \a updateRect. 1226ac7032dSJohn Scipione 1236ac7032dSJohn Scipione \note This is an hook method called by the Interface Kit, you don't 1246ac7032dSJohn Scipione have to call it yourself. If you need to forcefully redraw the checkbox 1256ac7032dSJohn Scipione consider calling Invalidate() instead. 1266ac7032dSJohn Scipione 1276ac7032dSJohn Scipione \param updateRect The rectangular area to be drawn. 1286ac7032dSJohn Scipione 1296ac7032dSJohn Scipione \sa BView::Draw() 1306ac7032dSJohn Scipione*/ 1316ac7032dSJohn Scipione 1326ac7032dSJohn Scipione 1336ac7032dSJohn Scipione/*! 1346ac7032dSJohn Scipione \fn void BCheckBox::GetPreferredSize(float* _width, float* _height) 1356ac7032dSJohn Scipione \brief Fill out the preferred width and height of the checkbox 1366ac7032dSJohn Scipione into the \a _width and \a _height parameters. 1376ac7032dSJohn Scipione 1386ac7032dSJohn Scipione \param _width Pointer to a \c float to hold the width of the checkbox. 1396ac7032dSJohn Scipione \param _height Pointer to a \c float to hold the height of the checkbox. 1406ac7032dSJohn Scipione 1416ac7032dSJohn Scipione \sa BView::GetPreferredSize() 1426ac7032dSJohn Scipione*/ 1436ac7032dSJohn Scipione 1446ac7032dSJohn Scipione 1456ac7032dSJohn Scipione/*! 1466ac7032dSJohn Scipione \fn void BCheckBox::SetValue(int32 value) 1476ac7032dSJohn Scipione \brief Turn the checkbox on or off. 1486ac7032dSJohn Scipione 1496ac7032dSJohn Scipione \param value The value to set the checkbox to, should be 1506ac7032dSJohn Scipione either \c B_CONTROL_ON or \c B_CONTROL_OFF. 1516ac7032dSJohn Scipione 1526ac7032dSJohn Scipione \sa BControl::SetValue() 1536ac7032dSJohn Scipione*/ 154