2011-11-02 12:36:02 +04:00
|
|
|
/*
|
2014-06-04 19:57:42 +04:00
|
|
|
* Copyright 2011-2014 Haiku, Inc. All rights reserved.
|
2013-02-07 06:05:00 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
2011-11-02 12:36:02 +04:00
|
|
|
*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Authors:
|
2011-11-02 12:36:02 +04:00
|
|
|
* Stephan Aßmus, superstippi@gmx.de
|
|
|
|
* Marc Flerackers, mflerackers@androme.be
|
|
|
|
* John Scipione, jscipione@gmail.com
|
2013-02-07 06:05:00 +04:00
|
|
|
*
|
2011-11-02 12:36:02 +04:00
|
|
|
* Corresponds to:
|
2014-05-28 22:09:56 +04:00
|
|
|
* headers/os/interface/CheckBox.h hrev47274
|
|
|
|
* src/kits/interface/CheckBox.cpp hrev47274
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
|
2011-11-02 12:36:02 +04:00
|
|
|
/*!
|
|
|
|
\file CheckBox.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
2011-11-02 12:36:02 +04:00
|
|
|
\brief Defines the BCheckBox class
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class BCheckBox
|
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief A user interface element used to make a binary decision.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
A BCheckBox is used to draw a check box UI control. This simple control
|
|
|
|
has 2 states, \c B_CONTROL_OFF when the check box is unchecked and
|
|
|
|
\c B_CONTROL_ON when the check box is checked. A check box can also have a
|
|
|
|
descriptive label drawn to the right of the check box.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
When the check box is checked it has an X drawn inside of it. The check box
|
2011-11-02 12:36:02 +04:00
|
|
|
can be checked by a mouse click or by pushing \key{Space} on the
|
2014-05-28 22:09:56 +04:00
|
|
|
keyboard when the check box has focus. A check box object with focus
|
|
|
|
is surrounded by a blue border. A check box can also be set
|
2011-11-02 12:36:02 +04:00
|
|
|
programmatically by calling the SetValue() method.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
A few check box examples can be seen below in unchecked state, checked
|
|
|
|
state, and another unchecked check box with focus on it.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
|
|
|
\image html BCheckBox_example.png
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-05-28 22:09:56 +04:00
|
|
|
\fn BCheckBox::BCheckBox(BRect frame, const char* name, const char* label,
|
|
|
|
BMessage* message, uint32 resizingMode, uint32 flags)
|
|
|
|
\brief Construct a check box in the \a frame with a \a name, \a label,
|
2011-11-02 12:36:02 +04:00
|
|
|
model \a message, \a resizingMode, and creation \a flags.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\note This constructor will resize the control to it's minimum height if needed
|
|
|
|
for compatibility with BeOS R5.
|
|
|
|
|
|
|
|
The initial value of the check box is 0 (\c B_CONTROL_OFF).
|
2011-11-02 12:36:02 +04:00
|
|
|
The \a label and the \a message parameters can be set to \c NULL.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\param frame The \a frame to draw the check box in.
|
|
|
|
\param name The \a name of the check box.
|
|
|
|
\param label The \a label displayed along with the check box control.
|
|
|
|
\param message The \a message to send when the check box is activated.
|
|
|
|
\param resizingMode Defines the behavior of the check box as the parent
|
|
|
|
view resizes. See BView for details.
|
|
|
|
\param flags Behavior \a flags for the check box. See BView for details.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-05-28 22:09:56 +04:00
|
|
|
\fn BCheckBox::BCheckBox(const char* name, const char* label,
|
|
|
|
BMessage* message, uint32 flags)
|
|
|
|
\brief Construct a check box with a \a name, \a label, model \a message,
|
2011-11-02 12:36:02 +04:00
|
|
|
and creation \a flags suitable for use with the Layout API.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
The initial value of the check box is 0 (\c B_CONTROL_OFF).
|
2011-11-02 12:36:02 +04:00
|
|
|
The \a label and the \a message parameters can be set to \c NULL.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\param name The \a name of the check box.
|
|
|
|
\param label The \a label displayed along with the check box control.
|
|
|
|
\param message The \a message to send when the check box is activated.
|
|
|
|
See BView for details.
|
|
|
|
\param flags Behavior \a flags for the check box. See BView for details.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-05-28 22:09:56 +04:00
|
|
|
\fn BCheckBox::BCheckBox(const char* label, BMessage* message)
|
2011-11-02 12:36:02 +04:00
|
|
|
\brief Constructs a BCheckBox object with just a \a label and model
|
|
|
|
\a message.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
The initial value of the check box is set to 0 (\c B_CONTROL_OFF).
|
2011-11-02 12:36:02 +04:00
|
|
|
The \a label and the \a message parameters can be set to \c NULL.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\param label The \a label displayed along with the check box.
|
|
|
|
\param message The \a message to send when the check box is activated.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-05-28 22:09:56 +04:00
|
|
|
\fn BCheckBox::BCheckBox(BMessage* archive)
|
2011-11-02 12:36:02 +04:00
|
|
|
\brief Constructs a BCheckBox object from an \a archive message.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
This method is usually not called directly, if you want to build a
|
|
|
|
check box from an archived message you should call Instantiate() instead
|
|
|
|
because it can handle errors properly.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\param archive The message to construct the BCheckBox object from.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BCheckBox::~BCheckBox()
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief Destructor, does nothing.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\name Archiving
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BArchivable* BCheckBox::Instantiate(BMessage* archive)
|
|
|
|
\brief Creates a new BCheckBox object from the \a archive message.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\param archive The \a archive message to restore from.
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\return A newly created check box or \c NULL if the message doesn't
|
|
|
|
contain an archived BCheckBox.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BCheckBox::Archive(BMessage* data, bool deep) const
|
|
|
|
\brief Archives the object into the \a data message.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::Archive()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\name Hook Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::AttachedToWindow()
|
|
|
|
\brief Hook method called when the control is attached to a window.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::AttachedToWindow()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::DetachedFromWindow()
|
|
|
|
\brief Hook method called when the control is detached from a window.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::DetachedFromWindow()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::AllAttached()
|
|
|
|
\brief Similar to AttachedToWindow() but this method is triggered after
|
|
|
|
all child views have already been attached to a window.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BView::AllAttached()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::AllDetached()
|
|
|
|
\brief Similar to AttachedToWindow() but this method is triggered after
|
|
|
|
all child views have already been detached from a window.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BView::AllDetached()
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::Draw(BRect updateRect)
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief Draws the area of the check box that intersects \a updateRect.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
|
|
|
\note This is an hook method called by the Interface Kit, you don't
|
2014-05-28 22:09:56 +04:00
|
|
|
have to call it yourself. If you need to forcefully redraw a
|
|
|
|
check box consider calling Invalidate() instead.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
|
|
|
\param updateRect The rectangular area to be drawn.
|
|
|
|
|
|
|
|
\sa BView::Draw()
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::FrameMoved(BPoint newPosition)
|
|
|
|
\brief Hook method called when the check box is moved.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BView::FrameMoved()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-14 01:25:02 +04:00
|
|
|
\fn void BCheckBox::FrameResized(float newWidth, float newHeight)
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief Hook method called when the check box is resized.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BView::FrameResized()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-11-02 12:36:02 +04:00
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::GetPreferredSize(float* _width, float* _height)
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief Fill out the preferred width and height of the check box
|
|
|
|
into the \a _width and \a _height parameters.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BView::GetPreferredSize()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BCheckBox::GetSupportedSuites(BMessage* message)
|
|
|
|
\brief Report the suites of messages this control understands.
|
|
|
|
|
|
|
|
\param message Allows you to add the names of the suites the check box
|
|
|
|
implements to the suites array.
|
|
|
|
|
|
|
|
\return \c B_OK if all went well or an error code otherwise.
|
|
|
|
|
|
|
|
\sa BControl::GetSupportedSuites();
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\since BeOS R3
|
|
|
|
*/
|
2014-05-28 22:09:56 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::KeyDown(const char* bytes, int32 numBytes)
|
|
|
|
\brief Hook method called when a keyboard key is pressed.
|
|
|
|
|
|
|
|
Inverts the value on \a B_ENTER or \a B_SPACE.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::KeyDown()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::MessageReceived(BMessage* message)
|
|
|
|
\brief Handle \a message received by the associated looper.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::MessageReceived()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::MouseDown(BPoint where)
|
|
|
|
\brief Hook method called when a mouse button is pressed.
|
|
|
|
|
|
|
|
Begins tracking the mouse cursor.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::MouseDown()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::MouseMoved(BPoint where, uint32 code,
|
|
|
|
const BMessage* dragMessage)
|
|
|
|
\brief Hook method called when the mouse is moved.
|
|
|
|
|
|
|
|
Once MouseDown() has been called on a check box this method updates
|
|
|
|
the outline when the cursor is inside the control redrawing as necessary.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::MouseMoved()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
2011-11-02 12:36:02 +04:00
|
|
|
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::MouseUp(BPoint where)
|
|
|
|
\brief Hook method called when a mouse button is released.
|
|
|
|
|
|
|
|
Inverts the check box value.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::MouseUp()
|
2014-05-28 22:09:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::WindowActivated(bool active)
|
|
|
|
\brief Hook method called when the attached window is activated or
|
|
|
|
deactivated.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\copydetails BControl::WindowActivated()
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
2011-11-02 12:36:02 +04:00
|
|
|
/*!
|
|
|
|
\fn void BCheckBox::SetValue(int32 value)
|
2014-05-28 22:09:56 +04:00
|
|
|
\brief Turn the check box on or off.
|
2011-11-02 12:36:02 +04:00
|
|
|
|
2014-05-28 22:09:56 +04:00
|
|
|
\param value The value to set the check box to, should be
|
2011-11-02 12:36:02 +04:00
|
|
|
either \c B_CONTROL_ON or \c B_CONTROL_OFF.
|
|
|
|
|
|
|
|
\sa BControl::SetValue()
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BHandler* BCheckBox::ResolveSpecifier(BMessage* message, int32 index,
|
|
|
|
BMessage* specifier, int32 what, const char* property)
|
|
|
|
\copydoc BHandler::ResolveSpecifier()
|
2011-11-02 12:36:02 +04:00
|
|
|
*/
|