16ac7032dSJohn Scipione/* 2*85b475f0SNiels Sascha Reedijk * Copyright 2011-2014, 2020 Haiku, Inc. All rights reserved. 36ac7032dSJohn Scipione * Distributed under the terms of the MIT License. 46ac7032dSJohn Scipione * 5820dca4dSJohn Scipione * Authors: 66ac7032dSJohn Scipione * John Scipione, jscipione@gmail.com 7820dca4dSJohn Scipione * 86ac7032dSJohn Scipione * Corresponds to: 9*85b475f0SNiels Sascha Reedijk * headers/os/interface/Control.h hrev47369 10*85b475f0SNiels Sascha Reedijk * src/kits/interface/Control.cpp hrev51550 116ac7032dSJohn Scipione */ 126ac7032dSJohn Scipione 13820dca4dSJohn Scipione 146ac7032dSJohn Scipione/*! 156ac7032dSJohn Scipione \file Control.h 16820dca4dSJohn Scipione \ingroup interface 17820dca4dSJohn Scipione \ingroup libbe 186ac7032dSJohn Scipione \brief BControl class definition and support enums. 196ac7032dSJohn Scipione*/ 206ac7032dSJohn Scipione 216ac7032dSJohn Scipione 226ac7032dSJohn Scipione/*! 236ac7032dSJohn Scipione \var B_CONTROL_ON 24820dca4dSJohn Scipione 25820dca4dSJohn Scipione Control on. Value equal to 1. 2647852bffSJohn Scipione 2747852bffSJohn Scipione \since BeOS R3 286ac7032dSJohn Scipione*/ 296ac7032dSJohn Scipione 306ac7032dSJohn Scipione 316ac7032dSJohn Scipione/*! 326ac7032dSJohn Scipione \var B_CONTROL_OFF 33820dca4dSJohn Scipione 34820dca4dSJohn Scipione Control off. Value equal to 0. 3547852bffSJohn Scipione 3647852bffSJohn Scipione \since BeOS R3 376ac7032dSJohn Scipione*/ 386ac7032dSJohn Scipione 396ac7032dSJohn Scipione 406ac7032dSJohn Scipione/*! 416ac7032dSJohn Scipione \class BControl 426ac7032dSJohn Scipione \ingroup interface 436ac7032dSJohn Scipione \ingroup libbe 446ac7032dSJohn Scipione \brief BControl is the base class for user-event handling objects. 456ac7032dSJohn Scipione 466ac7032dSJohn Scipione Simple controls such as BCheckBox and BButton deviate only a bit from 476ac7032dSJohn Scipione BControl, whereas more complicated controls such as BColorControl and 486ac7032dSJohn Scipione BSlider re-implement much more functionality. Whether you are building 496ac7032dSJohn Scipione a simple control or something more complicated you should inherit from 506ac7032dSJohn Scipione BControl as it provides a common set of methods for intercepting 516ac7032dSJohn Scipione received messages from mouse and keyboard events. 526ac7032dSJohn Scipione 536ac7032dSJohn Scipione Controls have state which they keep in their value. The value of a 546ac7032dSJohn Scipione control, stored as an int32, is read and set by the virtual Value() and 556ac7032dSJohn Scipione SetValue() methods. BControl defines \c B_CONTROL_ON and \c B_CONTROL_OFF 566ac7032dSJohn Scipione values that you can use as a convenience if your control has a simple 576ac7032dSJohn Scipione on/off state. If your BControl derived class stores a larger set of 586ac7032dSJohn Scipione states then you should define your own integer values instead. 5947852bffSJohn Scipione 6047852bffSJohn Scipione \since BeOS R3 616ac7032dSJohn Scipione*/ 626ac7032dSJohn Scipione 636ac7032dSJohn Scipione 646ac7032dSJohn Scipione/*! 656ac7032dSJohn Scipione \fn BControl::BControl(BRect frame, const char* name, const char* label, 66a676c40cSJohn Scipione BMessage* message, uint32 resizingMode, uint32 flags) 676ac7032dSJohn Scipione \brief Construct a control in the \a frame with a \a name, \a label, 686ac7032dSJohn Scipione model \a message, \a resizingMode, and creation \a flags. 696ac7032dSJohn Scipione 706ac7032dSJohn Scipione The initial value of the control is set to 0 (\c B_CONTROL_OFF). 716ac7032dSJohn Scipione The \a label and the \a message parameters can be set to \c NULL. 726ac7032dSJohn Scipione 736ac7032dSJohn Scipione \param frame The \a frame to draw the control in. 746ac7032dSJohn Scipione \param name The \a name of the control. 756ac7032dSJohn Scipione \param label The \a label displayed along with the control. 766ac7032dSJohn Scipione \param message The \a message to send when the control is activated. 776ac7032dSJohn Scipione \param resizingMode Defines the behavior of the control as the parent 78a676c40cSJohn Scipione view resizes, see BView for more details. 79a676c40cSJohn Scipione \param flags Behavior \a flags for the control, see BView for details. 8047852bffSJohn Scipione 8147852bffSJohn Scipione \since BeOS R3 826ac7032dSJohn Scipione*/ 836ac7032dSJohn Scipione 846ac7032dSJohn Scipione 856ac7032dSJohn Scipione/*! 866ac7032dSJohn Scipione \fn BControl::BControl(const char* name, const char* label, 876ac7032dSJohn Scipione BMessage* message, uint32 flags) 886ac7032dSJohn Scipione \brief Construct a control with a \a name, \a label, model \a message, 896ac7032dSJohn Scipione and creation \a flags suitable for use with the Layout API. 906ac7032dSJohn Scipione 916ac7032dSJohn Scipione The initial value of the control is set to 0 (\c B_CONTROL_OFF). 926ac7032dSJohn Scipione The \a label and the \a message parameters can be set to \c NULL. 936ac7032dSJohn Scipione 946ac7032dSJohn Scipione \param name The \a name of the control. 956ac7032dSJohn Scipione \param label The \a label displayed along with the control. 966ac7032dSJohn Scipione \param message The \a message to send when the control is activated. 97a676c40cSJohn Scipione \param flags Behavior \a flags for the control, see BView for details. 9847852bffSJohn Scipione 9947852bffSJohn Scipione \since Haiku R1 1006ac7032dSJohn Scipione*/ 1016ac7032dSJohn Scipione 1026ac7032dSJohn Scipione 1036ac7032dSJohn Scipione/*! 1046ac7032dSJohn Scipione \fn BControl::~BControl() 1056ac7032dSJohn Scipione \brief Frees all memory used by the BControl object including the memory 1066ac7032dSJohn Scipione used by the model message. 10747852bffSJohn Scipione 10847852bffSJohn Scipione \since BeOS R3 1096ac7032dSJohn Scipione*/ 1106ac7032dSJohn Scipione 1116ac7032dSJohn Scipione 1126ac7032dSJohn Scipione/*! 11347852bffSJohn Scipione \name Archiving 11447852bffSJohn Scipione*/ 11547852bffSJohn Scipione 11647852bffSJohn Scipione 11747852bffSJohn Scipione//! @{ 11847852bffSJohn Scipione 11947852bffSJohn Scipione 12047852bffSJohn Scipione/*! 12147852bffSJohn Scipione \fn BControl::BControl(BMessage* data) 12247852bffSJohn Scipione \brief Creates a new BControl object from an \a data message. 1236ac7032dSJohn Scipione 1246ac7032dSJohn Scipione This method is usually not called directly. If you want to build a 1256ac7032dSJohn Scipione control from a message you should call Instantiate() which can 1266ac7032dSJohn Scipione handle errors properly. 1276ac7032dSJohn Scipione 12847852bffSJohn Scipione If the \a data deep, the BControl object will also undata each 1296ac7032dSJohn Scipione of its child views recursively. 1306ac7032dSJohn Scipione 13147852bffSJohn Scipione \param data The \a data message to restore from. 13247852bffSJohn Scipione 13347852bffSJohn Scipione \since BeOS R3 1346ac7032dSJohn Scipione*/ 1356ac7032dSJohn Scipione 1366ac7032dSJohn Scipione 1376ac7032dSJohn Scipione/*! 13847852bffSJohn Scipione \fn BArchivable* BControl::Instantiate(BMessage* data) 13947852bffSJohn Scipione \brief Creates a new object from an \a data. 1406ac7032dSJohn Scipione 1416ac7032dSJohn Scipione If the message is a valid object then the instance created from the 14247852bffSJohn Scipione passed in \a data will be returned. Otherwise this method will 1436ac7032dSJohn Scipione return \c NULL. 1446ac7032dSJohn Scipione 14547852bffSJohn Scipione \param data The \a data message. 1466ac7032dSJohn Scipione 14747852bffSJohn Scipione \returns An instance of the object if \a data is valid or \c NULL. 1486ac7032dSJohn Scipione 1496ac7032dSJohn Scipione \sa BArchivable::Instantiate() 15047852bffSJohn Scipione 15147852bffSJohn Scipione \since BeOS R3 1526ac7032dSJohn Scipione*/ 1536ac7032dSJohn Scipione 1546ac7032dSJohn Scipione 1556ac7032dSJohn Scipione/*! 15647852bffSJohn Scipione \fn status_t BControl::Archive(BMessage* data, bool deep) const 15747852bffSJohn Scipione \brief Archives the control into \a data. 1586ac7032dSJohn Scipione 15947852bffSJohn Scipione \param data The target \a data that the data will go into. 16047852bffSJohn Scipione \param deep Whether or not to recursively data child views. 1616ac7032dSJohn Scipione 16247852bffSJohn Scipione \retval B_OK The data operation was successful. 16347852bffSJohn Scipione \retval B_BAD_VALUE \c NULL \a data message. 1646ac7032dSJohn Scipione \retval B_ERROR The archive operation failed. 1656ac7032dSJohn Scipione 1666ac7032dSJohn Scipione \sa BArchivable::Archive() 16747852bffSJohn Scipione 16847852bffSJohn Scipione \since BeOS R3 1696ac7032dSJohn Scipione*/ 1706ac7032dSJohn Scipione 1716ac7032dSJohn Scipione 17247852bffSJohn Scipione//! @} 17347852bffSJohn Scipione 17447852bffSJohn Scipione 1756ac7032dSJohn Scipione/*! 1766ac7032dSJohn Scipione \fn void BControl::WindowActivated(bool active) 177a676c40cSJohn Scipione \brief Hook method called when the attached window is activated or 178a676c40cSJohn Scipione deactivated. 1796ac7032dSJohn Scipione 18047852bffSJohn Scipione Redraws the focus ring around the control when the window is activated 181a676c40cSJohn Scipione or deactivated if it is the window's current focus view. 1826ac7032dSJohn Scipione 1836ac7032dSJohn Scipione \param active \c true if the window becomes activated, \c false if the 1846ac7032dSJohn Scipione window becomes deactivated. 1856ac7032dSJohn Scipione 1866ac7032dSJohn Scipione \sa BView::WindowActivated() 18747852bffSJohn Scipione 18847852bffSJohn Scipione \since BeOS R3 1896ac7032dSJohn Scipione*/ 1906ac7032dSJohn Scipione 1916ac7032dSJohn Scipione 1926ac7032dSJohn Scipione/*! 1936ac7032dSJohn Scipione \fn void BControl::AttachedToWindow() 194a676c40cSJohn Scipione \brief Hook method called when the control is attached to a window. 1956ac7032dSJohn Scipione 1966ac7032dSJohn Scipione This method overrides BView::AttachedToWindow() setting the low color 1976ac7032dSJohn Scipione and view color of the BControl so that it matches the view color of the 1986ac7032dSJohn Scipione control's parent view. It also makes the attached window the default 1996ac7032dSJohn Scipione target for Invoke() as long as another target has not already been set. 2006ac7032dSJohn Scipione 2016ac7032dSJohn Scipione \sa BView::AttachedToWindow() 2026ac7032dSJohn Scipione \sa Invoke() 2036ac7032dSJohn Scipione \sa BInvoker::SetTarget() 20447852bffSJohn Scipione 20547852bffSJohn Scipione \since BeOS R3 2066ac7032dSJohn Scipione*/ 2076ac7032dSJohn Scipione 2086ac7032dSJohn Scipione 2096ac7032dSJohn Scipione/*! 2106ac7032dSJohn Scipione \fn void BControl::DetachedFromWindow() 21147852bffSJohn Scipione \brief Hook method called when the control is detached from a window. 21278615023SJohn Scipione 21347852bffSJohn Scipione \copydetails BView::DetachedFromWindow() 2146ac7032dSJohn Scipione*/ 2156ac7032dSJohn Scipione 2166ac7032dSJohn Scipione 2176ac7032dSJohn Scipione/*! 2186ac7032dSJohn Scipione \fn void BControl::AllAttached() 2196ac7032dSJohn Scipione \brief Similar to AttachedToWindow() but this method is triggered after 22047852bffSJohn Scipione all child views have already been detached from a window. 2216ac7032dSJohn Scipione 22247852bffSJohn Scipione \copydetails BView::AllAttached() 2236ac7032dSJohn Scipione*/ 2246ac7032dSJohn Scipione 2256ac7032dSJohn Scipione 2266ac7032dSJohn Scipione/*! 2276ac7032dSJohn Scipione \fn void BControl::AllDetached() 2286ac7032dSJohn Scipione \brief Similar to AttachedToWindow() but this method is triggered after 2296ac7032dSJohn Scipione all child views have already been detached from a window. 2306ac7032dSJohn Scipione 23147852bffSJohn Scipione \copydetails BView::AllDetached() 2326ac7032dSJohn Scipione*/ 2336ac7032dSJohn Scipione 2346ac7032dSJohn Scipione 2356ac7032dSJohn Scipione/*! 23647852bffSJohn Scipione \fn void BControl::MakeFocus(bool focus) 2376ac7032dSJohn Scipione \brief Gives or removes focus from the control. 2386ac7032dSJohn Scipione 2396ac7032dSJohn Scipione BControl::MakeFocus() overrides BView::MakeFocus() to call Draw() when 2406ac7032dSJohn Scipione the focus changes. Derived classes generally don't have to re-implement 2416ac7032dSJohn Scipione MakeFocus(). 2426ac7032dSJohn Scipione 2436ac7032dSJohn Scipione IsFocusChanging() returns \c true when Draw() is called from this method. 2446ac7032dSJohn Scipione 24547852bffSJohn Scipione \param focus \a true to set focus, \a false to remove it. 2466ac7032dSJohn Scipione 2476ac7032dSJohn Scipione \sa BView::MakeFocus() 2486ac7032dSJohn Scipione \sa IsFocusChanging() 24947852bffSJohn Scipione 25047852bffSJohn Scipione \since BeOS R3 2516ac7032dSJohn Scipione*/ 2526ac7032dSJohn Scipione 2536ac7032dSJohn Scipione 2546ac7032dSJohn Scipione/*! 2556ac7032dSJohn Scipione \fn void BControl::KeyDown(const char *bytes, int32 numBytes) 256a676c40cSJohn Scipione \brief Hook method called when a keyboard key is pressed. 2576ac7032dSJohn Scipione 2586ac7032dSJohn Scipione Overrides BView::KeyDown() to toggle the control value and then 2596ac7032dSJohn Scipione calls Invoke() for \c B_SPACE or \c B_ENTER. If this is not desired 2606ac7032dSJohn Scipione you should override this method in derived classes. 2616ac7032dSJohn Scipione 2626ac7032dSJohn Scipione The KeyDown() method is only called if the BControl is the focus view 2636ac7032dSJohn Scipione in the active window. If the window has a default button, \c B_ENTER 2646ac7032dSJohn Scipione will be passed to that object instead of the focus view. 2656ac7032dSJohn Scipione 2666ac7032dSJohn Scipione \param bytes The bytes of the key combination pressed. 2676ac7032dSJohn Scipione \param numBytes The number of bytes in \a bytes. 2686ac7032dSJohn Scipione 2696ac7032dSJohn Scipione \sa BView::KeyDown() 2706ac7032dSJohn Scipione \sa MakeFocus() 27147852bffSJohn Scipione 27247852bffSJohn Scipione \since BeOS R3 2736ac7032dSJohn Scipione*/ 2746ac7032dSJohn Scipione 2756ac7032dSJohn Scipione 2766ac7032dSJohn Scipione/*! 27778615023SJohn Scipione \fn void BControl::MessageReceived(BMessage* message) 27878615023SJohn Scipione \brief Handle \a message received by the associated looper. 27978615023SJohn Scipione 28047852bffSJohn Scipione \copydetails BView::MessageReceived() 28178615023SJohn Scipione*/ 28278615023SJohn Scipione 28378615023SJohn Scipione 28478615023SJohn Scipione/*! 28578615023SJohn Scipione \fn void BControl::MouseDown(BPoint where) 286a676c40cSJohn Scipione \brief Hook method called when a mouse button is pressed. 2876ac7032dSJohn Scipione 28847852bffSJohn Scipione \copydetails BView::MouseDown() 2896ac7032dSJohn Scipione*/ 2906ac7032dSJohn Scipione 2916ac7032dSJohn Scipione 2926ac7032dSJohn Scipione/*! 29378615023SJohn Scipione \fn void BControl::MouseMoved(BPoint where, uint32 code, 29478615023SJohn Scipione const BMessage* dragMessage) 295a676c40cSJohn Scipione \brief Hook method called when the mouse is moved. 2966ac7032dSJohn Scipione 29747852bffSJohn Scipione \copydetails BView::MouseMoved() 2986ac7032dSJohn Scipione*/ 2996ac7032dSJohn Scipione 3006ac7032dSJohn Scipione 3016ac7032dSJohn Scipione/*! 30247852bffSJohn Scipione \fn void BControl::MouseUp(BPoint where) 30347852bffSJohn Scipione \brief Hook method called when a mouse button is released. 30447852bffSJohn Scipione 30547852bffSJohn Scipione \copydetails BView::MouseUp() 30647852bffSJohn Scipione*/ 30747852bffSJohn Scipione 30847852bffSJohn Scipione 30947852bffSJohn Scipione 31047852bffSJohn Scipione/*! 3116ac7032dSJohn Scipione \fn void BControl::SetLabel(const char *label) 3126ac7032dSJohn Scipione \brief Sets the \a label of the control. 3136ac7032dSJohn Scipione 3146ac7032dSJohn Scipione If the \a label changes the control is redrawn. 3156ac7032dSJohn Scipione 3166ac7032dSJohn Scipione \param label The \a label to set, can be \c NULL. 31747852bffSJohn Scipione 31847852bffSJohn Scipione \since BeOS R3 3196ac7032dSJohn Scipione*/ 3206ac7032dSJohn Scipione 3216ac7032dSJohn Scipione 3226ac7032dSJohn Scipione/*! 3236ac7032dSJohn Scipione \fn const char* BControl::Label() const 3246ac7032dSJohn Scipione \brief Gets the label of the control. 3256ac7032dSJohn Scipione 326a676c40cSJohn Scipione \return The control's label. 32747852bffSJohn Scipione 32847852bffSJohn Scipione \since BeOS R3 3296ac7032dSJohn Scipione*/ 3306ac7032dSJohn Scipione 3316ac7032dSJohn Scipione 3326ac7032dSJohn Scipione/*! 3336ac7032dSJohn Scipione \fn void BControl::SetValue(int32 value) 3346ac7032dSJohn Scipione \brief Sets the value of the control. 3356ac7032dSJohn Scipione 3366ac7032dSJohn Scipione If the \a value changes the control is redrawn. 3376ac7032dSJohn Scipione 3386ac7032dSJohn Scipione \param value The \a value to set. 3396ac7032dSJohn Scipione 3406ac7032dSJohn Scipione \sa SetValueNoUpdate() 34147852bffSJohn Scipione 34247852bffSJohn Scipione \since BeOS R3 3436ac7032dSJohn Scipione*/ 3446ac7032dSJohn Scipione 3456ac7032dSJohn Scipione 3466ac7032dSJohn Scipione/*! 3476ac7032dSJohn Scipione \fn void BControl::SetValueNoUpdate(int32 value) 3486ac7032dSJohn Scipione \brief Sets the value of the control without redrawing. 3496ac7032dSJohn Scipione 3506ac7032dSJohn Scipione \param value The \a value to set. 3516ac7032dSJohn Scipione 3526ac7032dSJohn Scipione \sa SetValue() 35347852bffSJohn Scipione 35447852bffSJohn Scipione \since Haiku R1 3556ac7032dSJohn Scipione*/ 3566ac7032dSJohn Scipione 3576ac7032dSJohn Scipione 3586ac7032dSJohn Scipione/*! 3596ac7032dSJohn Scipione \fn int32 BControl::Value() const 3606ac7032dSJohn Scipione \brief Gets the value of the control. 3616ac7032dSJohn Scipione 362a676c40cSJohn Scipione \return The control's value. 36347852bffSJohn Scipione 36447852bffSJohn Scipione \since BeOS R3 3656ac7032dSJohn Scipione*/ 3666ac7032dSJohn Scipione 3676ac7032dSJohn Scipione 3686ac7032dSJohn Scipione/*! 3696ac7032dSJohn Scipione \fn void BControl::SetEnabled(bool enabled) 3706ac7032dSJohn Scipione \brief Enables or disables the control. 3716ac7032dSJohn Scipione 3726ac7032dSJohn Scipione BControl objects are enabled by default. If the control changes enabled 3736ac7032dSJohn Scipione state then it is redrawn. 3746ac7032dSJohn Scipione 3756ac7032dSJohn Scipione Disabled controls generally won't allow the user to focus on them 3766ac7032dSJohn Scipione (The \c B_NAVIGABLE flag is turned off), and don't post any messages. 3776ac7032dSJohn Scipione 3786ac7032dSJohn Scipione Disabled controls in derived classes should be drawn in subdued colors 3796ac7032dSJohn Scipione to visually indicate that they are disabled and should not respond to 3806ac7032dSJohn Scipione keyboard or mouse events. 3816ac7032dSJohn Scipione 3826ac7032dSJohn Scipione \param enabled If \c true enables the control, if \c false, disables it. 38347852bffSJohn Scipione 38447852bffSJohn Scipione \since BeOS R3 3856ac7032dSJohn Scipione*/ 3866ac7032dSJohn Scipione 3876ac7032dSJohn Scipione 3886ac7032dSJohn Scipione/*! 3896ac7032dSJohn Scipione \fn bool BControl::IsEnabled() const 3906ac7032dSJohn Scipione \brief Gets whether or not the control is currently enabled. 3916ac7032dSJohn Scipione 392a676c40cSJohn Scipione \return \c true if the control is enabled, \c false if it is disabled. 39347852bffSJohn Scipione 39447852bffSJohn Scipione \since BeOS R3 3956ac7032dSJohn Scipione*/ 3966ac7032dSJohn Scipione 3976ac7032dSJohn Scipione 3986ac7032dSJohn Scipione/*! 3996ac7032dSJohn Scipione \fn void BControl::GetPreferredSize(float *_width, float *_height) 4006ac7032dSJohn Scipione \brief Fill out the preferred width and height of the control 4016ac7032dSJohn Scipione into the \a _width and \a _height parameters. 4026ac7032dSJohn Scipione 4036ac7032dSJohn Scipione Derived classes can override this method to set the preferred 4046ac7032dSJohn Scipione width and height of the control. 4056ac7032dSJohn Scipione 40678615023SJohn Scipione \param[out] _width Pointer to a \c float to hold the width of the control. 40778615023SJohn Scipione \param[out] _height Pointer to a \c float to hold the height of the control. 4086ac7032dSJohn Scipione 4096ac7032dSJohn Scipione \sa BView::GetPreferredSize() 41047852bffSJohn Scipione 41147852bffSJohn Scipione \since BeOS R3 4126ac7032dSJohn Scipione*/ 4136ac7032dSJohn Scipione 4146ac7032dSJohn Scipione 4156ac7032dSJohn Scipione/*! 4166ac7032dSJohn Scipione \fn void BControl::ResizeToPreferred() 4176ac7032dSJohn Scipione \brief Resize the control to its preferred size. 4186ac7032dSJohn Scipione 4196ac7032dSJohn Scipione \sa BView::ResizeToPreferred() 42047852bffSJohn Scipione 42147852bffSJohn Scipione \since BeOS R3 4226ac7032dSJohn Scipione*/ 4236ac7032dSJohn Scipione 4246ac7032dSJohn Scipione 4256ac7032dSJohn Scipione/*! 4266ac7032dSJohn Scipione \fn status_t BControl::Invoke(BMessage* message) 4276ac7032dSJohn Scipione \brief Sends a copy of the model \a message to the designated target. 4286ac7032dSJohn Scipione 4296ac7032dSJohn Scipione BControl::Invoke() overrides BInvoker::Invoke(). Derived classes 4306ac7032dSJohn Scipione should use this method in their MouseDown() and KeyDown() methods 4316ac7032dSJohn Scipione and should call IsEnabled() to check if the control is enabled 4326ac7032dSJohn Scipione before calling Invoke(). 4336ac7032dSJohn Scipione 4346ac7032dSJohn Scipione The following fields added to the BMessage: 4356ac7032dSJohn Scipione - "when" \c B_INT64_TYPE system_time() 4366ac7032dSJohn Scipione - "source" \c B_POINTER_TYPE A pointer to the BControl object. 4376ac7032dSJohn Scipione 4386ac7032dSJohn Scipione \param message The \a message to send. 4396ac7032dSJohn Scipione 44078615023SJohn Scipione \return \c B_OK if the control was invoked, otherwise an error 44178615023SJohn Scipione code is returned. 44278615023SJohn Scipione 4436ac7032dSJohn Scipione \sa BInvoker::Invoke() 4446ac7032dSJohn Scipione \sa IsEnabled() 44547852bffSJohn Scipione 44647852bffSJohn Scipione \since BeOS R3 4476ac7032dSJohn Scipione*/ 4486ac7032dSJohn Scipione 4496ac7032dSJohn Scipione 4506ac7032dSJohn Scipione/*! 4516ac7032dSJohn Scipione \fn BHandler* BControl::ResolveSpecifier(BMessage* message, int32 index, 452a676c40cSJohn Scipione BMessage* specifier, int32 what, const char* property) 45347852bffSJohn Scipione \copydoc BHandler::ResolveSpecifier() 4546ac7032dSJohn Scipione*/ 4556ac7032dSJohn Scipione 4566ac7032dSJohn Scipione 4576ac7032dSJohn Scipione/*! 4586ac7032dSJohn Scipione \fn status_t BControl::GetSupportedSuites(BMessage* message) 45978615023SJohn Scipione \brief Report the suites of messages this control understands. 46078615023SJohn Scipione 46178615023SJohn Scipione Adds the string "suite/vnd.Be-control" to the message. 46278615023SJohn Scipione 463a960a58cSJohn Scipione \copydetails BHandler::GetSupportedSuites() 4646ac7032dSJohn Scipione*/ 4656ac7032dSJohn Scipione 4666ac7032dSJohn Scipione 4676ac7032dSJohn Scipione/*! 4686ac7032dSJohn Scipione \fn status_t BControl::Perform(perform_code code, void* _data) 46947852bffSJohn Scipione \copydoc BView::Perform() 4706ac7032dSJohn Scipione*/ 47178615023SJohn Scipione 47278615023SJohn Scipione 47378615023SJohn Scipione/*! 47478615023SJohn Scipione \fn status_t BControl::SetIcon(const BBitmap* icon, uint32 flags) 47578615023SJohn Scipione \brief This convenience method is used to set the bitmaps 47678615023SJohn Scipione for the standard states from a single bitmap. 47778615023SJohn Scipione 47878615023SJohn Scipione It also supports cropping the icon to its non-transparent area. 47978615023SJohn Scipione The icon is meant as an addition to or replacement of the label. 48078615023SJohn Scipione 48178615023SJohn Scipione \param icon The \a icon to set. 48278615023SJohn Scipione \param flags Modify how the icon is set. 48378615023SJohn Scipione - \c B_TRIM_ICON_BITMAP Crop the bitmap to the not fully transparent 48478615023SJohn Scipione area, may change the icon size. 48578615023SJohn Scipione - \c B_TRIM_ICON_BITMAP_KEEP_ASPECT Like \c B_TRIM_BITMAP, but keeps 48678615023SJohn Scipione the aspect ratio. 48778615023SJohn Scipione - \c B_CREATE_ACTIVE_ICON_BITMAP 48878615023SJohn Scipione - \c B_CREATE_PARTIALLY_ACTIVE_ICON_BITMAP 48978615023SJohn Scipione - \c B_CREATE_DISABLED_ICON_BITMAPS 49078615023SJohn Scipione 49178615023SJohn Scipione \return \c B_OK if the icon was set or an error code otherwise. 49247852bffSJohn Scipione 49347852bffSJohn Scipione \since Haiku R1 49478615023SJohn Scipione*/ 49578615023SJohn Scipione 49678615023SJohn Scipione 49778615023SJohn Scipione/*! 49878615023SJohn Scipione \fn status_t BControl::SetIconBitmap(const BBitmap* bitmap, 49978615023SJohn Scipione uint32 which, uint32 flags) 50078615023SJohn Scipione \brief Icon bitmaps for various states of the control (off, on, 50178615023SJohn Scipione partially on, each enabled or disabled, plus up to 125 50278615023SJohn Scipione custom states) can be set individually. 50378615023SJohn Scipione 50478615023SJohn Scipione \param bitmap The \a bitmap icon to set. 50578615023SJohn Scipione \param which The state to set the icon for. 50678615023SJohn Scipione \param flags Modify how the icon is set. 50778615023SJohn Scipione - \c B_KEEP_ICON_BITMAP Transfer ownership of the bitmap to the control. 50878615023SJohn Scipione 50978615023SJohn Scipione \return \c B_OK if the icon was set or an error code otherwise. 51047852bffSJohn Scipione 51147852bffSJohn Scipione \since Haiku R1 51278615023SJohn Scipione*/ 513*85b475f0SNiels Sascha Reedijk 514*85b475f0SNiels Sascha Reedijk 515*85b475f0SNiels Sascha Reedijk/*! 516*85b475f0SNiels Sascha Reedijk \fn const BBitmap* BControl::IconBitmap(uint32 which) const 517*85b475f0SNiels Sascha Reedijk \brief Get the currently set bitmap for a specific state. 518*85b475f0SNiels Sascha Reedijk 519*85b475f0SNiels Sascha Reedijk \param which The state to retrieve the icon for. 520*85b475f0SNiels Sascha Reedijk 521*85b475f0SNiels Sascha Reedijk \return A pointer to the icon set for the state, or \c NULL in case there 522*85b475f0SNiels Sascha Reedijk is no icon set for that state. 523*85b475f0SNiels Sascha Reedijk 524*85b475f0SNiels Sascha Reedijk \since Haiku R1 525*85b475f0SNiels Sascha Reedijk*/ 526*85b475f0SNiels Sascha Reedijk 527*85b475f0SNiels Sascha Reedijk 528*85b475f0SNiels Sascha Reedijk/*! 529*85b475f0SNiels Sascha Reedijk \fn bool BControl::IsFocusChanging() const 530*85b475f0SNiels Sascha Reedijk \brief Check if the control is changing focus 531*85b475f0SNiels Sascha Reedijk 532*85b475f0SNiels Sascha Reedijk Many controls have different looks depending on whether they have focus or 533*85b475f0SNiels Sascha Reedijk not. You can use this method within your Draw() call to determine whether 534*85b475f0SNiels Sascha Reedijk you are asked to redraw because the focus is changing, meaning your control 535*85b475f0SNiels Sascha Reedijk is getting in or out of focus, so that you can conditionally run the 536*85b475f0SNiels Sascha Reedijk drawing code. 537*85b475f0SNiels Sascha Reedijk 538*85b475f0SNiels Sascha Reedijk \retval true The Draw() method was called because of a focus change for 539*85b475f0SNiels Sascha Reedijk this control. 540*85b475f0SNiels Sascha Reedijk \retval false The Draw() method was not called because of a focus change 541*85b475f0SNiels Sascha Reedijk for this control. 542*85b475f0SNiels Sascha Reedijk 543*85b475f0SNiels Sascha Reedijk \since BeOS R5 544*85b475f0SNiels Sascha Reedijk*/ 545*85b475f0SNiels Sascha Reedijk 546*85b475f0SNiels Sascha Reedijk 547*85b475f0SNiels Sascha Reedijk/*! 548*85b475f0SNiels Sascha Reedijk \fn bool BControl::IsTracking() const 549*85b475f0SNiels Sascha Reedijk \brief Check whether this control is set to tracking 550*85b475f0SNiels Sascha Reedijk 551*85b475f0SNiels Sascha Reedijk See SetTracking() for the usage pattern. By default, the control wil return 552*85b475f0SNiels Sascha Reedijk \c false. 553*85b475f0SNiels Sascha Reedijk 554*85b475f0SNiels Sascha Reedijk \since Haiku R1 555*85b475f0SNiels Sascha Reedijk*/ 556*85b475f0SNiels Sascha Reedijk 557*85b475f0SNiels Sascha Reedijk 558*85b475f0SNiels Sascha Reedijk/*! 559*85b475f0SNiels Sascha Reedijk \fn void BControl::SetTracking(bool state) 560*85b475f0SNiels Sascha Reedijk \brief Modify the control's tracking state 561*85b475f0SNiels Sascha Reedijk 562*85b475f0SNiels Sascha Reedijk The tracking state is a feature of this BControl class, that allows you to 563*85b475f0SNiels Sascha Reedijk set a flag when you are watching the behavior of users when they interact 564*85b475f0SNiels Sascha Reedijk with your control. 565*85b475f0SNiels Sascha Reedijk 566*85b475f0SNiels Sascha Reedijk For example, a button may have a draw state when it is not pressed, and 567*85b475f0SNiels Sascha Reedijk when it is pressed. When the user presses their mouse down, within the 568*85b475f0SNiels Sascha Reedijk control, the control will be drawn in the pressed state. The code can set 569*85b475f0SNiels Sascha Reedijk the tracking flag, so that in the case of the mouse up event, the control 570*85b475f0SNiels Sascha Reedijk knows it has to redraw. 571*85b475f0SNiels Sascha Reedijk 572*85b475f0SNiels Sascha Reedijk This flag does not affect anything within this class, other than the return 573*85b475f0SNiels Sascha Reedijk value of the \ref IsTracking() method, so it can be used at will by custom 574*85b475f0SNiels Sascha Reedijk implementations of this class. 575*85b475f0SNiels Sascha Reedijk 576*85b475f0SNiels Sascha Reedijk \param state Pass \c true if the control is in a tracking state, or 577*85b475f0SNiels Sascha Reedijk \c false if it is not. 578*85b475f0SNiels Sascha Reedijk 579*85b475f0SNiels Sascha Reedijk \since Haiku R1 580*85b475f0SNiels Sascha Reedijk*/ 581