1/* 2 * Copyright 2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 * 8 * Corresponds to: 9 * headers/os/interface/PictureButton.h hrev47233 10 * src/kits/interface/PictureButton.cpp hrev47233 11 */ 12 13 14/*! 15 \file PictureButton.h 16 \ingroup interface 17 \ingroup libbe 18 \brief BPictureButton class definition and support structures. 19*/ 20 21 22/*! 23 \var B_ONE_STATE_BUTTON 24 25 Acts like a normal BButton, the value is set to \c B_CONTROL_ON when the 26 button is being pressed and is set to \c B_CONTROL_OFF otherwise. 27 28 \since BeOS R3 29*/ 30 31 32/*! 33 \var B_TWO_STATE_BUTTON 34 35 Acts like a checkbox, the value alternates between \c B_CONTROL_ON and 36 \c B_CONTROL_OFF each time the user presses and releases the button. 37 38 \since BeOS R3 39*/ 40 41 42/*! 43 \class BPictureButton 44 \ingroup interface 45 \ingroup libbe 46 \brief A button draw with a BPicture image instead of a text label. 47 48 There are two types: 49 - \c B_ONE_STATE_BUTTON Acts like a normal BButton, the value is set to 50 \c B_CONTROL_ON when the button is being pressed and is set to 51 \c B_CONTROL_OFF otherwise. 52 - \c B_TWO_STATE_BUTTON Acts like a checkbox, the value alternates between 53 \c B_CONTROL_ON and \c B_CONTROL_OFF each time the user presses and 54 releases the button. 55 56 \since BeOS R3 57*/ 58 59 60/*! 61 \fn BPictureButton::BPictureButton(BRect frame, const char* name, 62 BPicture* off, BPicture* on, BMessage* message, 63 uint32 behavior, uint32 resizingMode, uint32 flags) 64 \brief Initializes a new BPictureButton object. 65 66 \param frame The \a frame rectangle of the button. 67 \param name The \a name of the button used internally. 68 \param off The BPicture object to use when the object is \a off. 69 \param on The BPicture object to use when the object is \a on. 70 \param message The BMessage to send when the object is invoked. 71 \param behavior Either \c B_ONE_STATE_BUTTON or \c B_TWO_STATE_BUTTON. 72 \param resizingMode Defines the view's behavior when its parent is 73 resized, see BView for more details. 74 \param flags The view flags, see BView for more details. 75 76 \sa BPictureButton::SetBehavior() 77 \sa BPictureButton::SetEnabledOn() 78 \sa BPictureButton::SetEnabledOff() 79 \sa BPictureButton::SetDisabledOn() 80 \sa BPictureButton::SetDisabledOff() 81 82 \since BeOS R3 83*/ 84 85 86/*! 87 \fn BPictureButton::BPictureButton(BMessage* data) 88 \brief Initializes an BPictureButton object copying the data from from the 89 passed in \a data archive. 90 91 \since BeOS R3 92*/ 93 94 95/*! 96 \fn BPictureButton::~BPictureButton() 97 \brief Destroys the BPictureButton along with the associated BPicture objects. 98 99 \since BeOS R3 100*/ 101 102 103/*! 104 \name Archiving 105*/ 106 107 108//! @{ 109 110 111/*! 112 \fn BArchivable* BPictureButton::Instantiate(BMessage* data) 113 \brief Returns a pointer to a new BPictureButton object created from the 114 BPictureButton data archived in \a data. 115 116 \returns A newly created BPictureButton object or \c NULL if the message 117 doesn't contain an archived BPictureButton. 118 119 \see BArchivable::Instantiate() 120 121 \since BeOS R3 122*/ 123 124 125/*! 126 \fn status_t BPictureButton::Archive(BMessage* data, bool deep) const 127 \brief Archives the BPictureButton object into the \a data message. 128 129 \param data A pointer to the BMessage object to archive into. 130 \param deep Also archive the associated BPicture objects. 131 132 \return A status code, \c B_OK if everything went well or an error code 133 otherwise. 134 \retval B_OK The object was archived successfully. 135 \retval B_NO_MEMORY Ran out of memory while archiving the object. 136 137 \sa BArchivable::Archive() 138 \sa BPictureButton::Instantiate() 139 140 \since BeOS R3 141*/ 142 143 144//! @} 145 146 147/*! 148 \name Hook Methods 149*/ 150 151 152//! @{ 153 154 155/*! 156 \fn void BPictureButton::AttachedToWindow() 157 \copydoc BControl::AttachedToWindow() 158*/ 159 160 161/*! 162 \fn void BPictureButton::DetachedFromWindow() 163 \copydoc BControl::DetachedFromWindow() 164*/ 165 166 167/*! 168 \fn void BPictureButton::AllAttached() 169 \copydoc BControl::AllAttached() 170*/ 171 172 173/*! 174 \fn void BPictureButton::AllDetached() 175 \copydoc BControl::AllDetached() 176*/ 177 178 179/*! 180 \fn void BPictureButton::Draw(BRect updateRect) 181 \brief Draws the BPictureButton from its associated BPicture objects. 182 183 \copydetails BControl::Draw() 184*/ 185 186 187/*! 188 \fn void BPictureButton::FrameMoved(BPoint newPosition) 189 \copydoc BControl::FrameMoved() 190*/ 191 192 193/*! 194 \fn BPictureButton::FrameResized(float newWidth, float newHeight) 195 \copydoc BControl::FrameResized() 196*/ 197 198 199/*! 200 \fn void BPictureButton::KeyDown(const char* bytes, int32 numBytes) 201 \brief Invokes the button on either \c B_ENTER \c B_SPACE. 202 203 \copydetails BControl::KeyDown() 204*/ 205 206 207/*! 208 \fn void BPictureButton::MessageReceived(BMessage* message) 209 \copydoc BControl::MessageReceived() 210*/ 211 212 213/*! 214 \fn void BPictureButton::MouseDown(BPoint where) 215 \brief Sets the button value based on the buttons Behavior(). 216 217 \copydetails BControl::MouseDown() 218 219 \sa Behavior() 220*/ 221 222 223/*! 224 \fn void BPictureButton::MouseMoved(BPoint where, uint32 code, 225 const BMessage* dragMessage) 226 227 \copydetails BControl::MouseMoved() 228*/ 229 230 231/*! 232 \fn void BPictureButton::MouseUp(BPoint where) 233 \brief Invokes the button. 234 235 \copydetails BControl::MouseUp() 236*/ 237 238 239/*! 240 \fn void BPictureButton::WindowActivated(bool active) 241 \copydoc BControl::WindowActivated() 242*/ 243 244 245//! @} 246 247 248/*! 249 \fn void BPictureButton::ResizeToPreferred() 250 \copydoc BControl::ResizeToPreferred() 251*/ 252 253 254/*! 255 \fn void BPictureButton::GetPreferredSize(float* _width, float* _height) 256 \copydoc BControl::GetPreferredSize() 257*/ 258 259 260/*! 261 \fn void BPictureButton::MakeFocus(bool focus) 262 \copydoc BControl::MakeFocus() 263*/ 264 265 266/*! 267 \fn void BPictureButton::SetEnabledOn(BPicture* picture) 268 \brief Sets the BPicture to draw when the button is enabled and on. 269 270 \param picture A pointer to the BPicture object to set. 271 272 \since BeOS R3 273*/ 274 275 276/*! 277 \fn void BPictureButton::SetEnabledOff(BPicture* picture) 278 \brief Sets the BPicture to draw when the button is enabled and off. 279 280 \param picture A pointer to the BPicture object to set. 281 282 \since BeOS R3 283*/ 284 285 286/*! 287 \fn void BPictureButton::SetDisabledOn(BPicture* picture) 288 \brief Sets the BPicture to draw when the button is disabled and on. 289 290 If the behavior is set to \c B_ONE_STATE_BUTTON this does not need be 291 set because a disabled one-state control can never be on. 292 293 \param picture A pointer to the BPicture object to set. 294 295 \since BeOS R3 296*/ 297 298 299/*! 300 \fn void BPictureButton::SetDisabledOff(BPicture* picture) 301 \brief Sets the BPicture to draw when the button is disabled and off. 302 303 \param picture A pointer to the BPicture object to set. 304 305 \since BeOS R3 306*/ 307 308 309/*! 310 \fn BPicture* BPictureButton::EnabledOn() const 311 \brief Returns a pointer to the BPicture object used when the button 312 is enabled and on. 313 314 \returns A pointer to a BPicture object or \c NULL if not set. 315 316 \since BeOS R3 317*/ 318 319 320/*! 321 \fn BPicture* BPictureButton::EnabledOff() const 322 \brief Returns a pointer to the BPicture object used when the button 323 is enabled and off. 324 325 \returns A pointer to a BPicture object or \c NULL if not set. 326 327 \since BeOS R3 328*/ 329 330 331/*! 332 \fn BPicture* BPictureButton::DisabledOn() const 333 \brief Returns a pointer to the BPicture object used when the button 334 is disabled and on. 335 336 \returns A pointer to a BPicture object or \c NULL if not set. 337 338 \since BeOS R3 339*/ 340 341 342/*! 343 \fn BPicture* BPictureButton::DisabledOff() const 344 \brief Returns a pointer to the BPicture object used when the button 345 is disabled and off. 346 347 \returns A pointer to a BPicture object or \c NULL if not set. 348 349 \since BeOS R3 350*/ 351 352 353/*! 354 \fn void BPictureButton::SetBehavior(uint32 behavior) 355 \brief Set the behavior to either \c B_ONE_STATE_BUTTON or 356 \c B_TWO_STATE_BUTTON. 357 358 A one-state BPictureButton acts like a normal button, the value is set to 359 \c B_CONTROL_ON when the button is being pressed and it is set to 360 \c B_CONTROL_OFF otherwise. A two-state object acts like a checkbox, the 361 value alternates between \c B_CONTROL_ON and \c B_CONTROL_OFF each time 362 the user presses and releases the button. 363 364 \param behavior Either \c B_ONE_STATE_BUTTON or \c B_TWO_STATE_BUTTON. 365 366 \since BeOS R3 367*/ 368 369 370/*! 371 \fn uint32 BPictureButton::Behavior() const 372 \brief Return the currently set behavior. 373 374 \returns Either \c B_ONE_STATE_BUTTON or B_TWO_STATE_BUTTON. 375 376 \see SetBehavior() 377 378 \since BeOS R3 379*/ 380 381 382/*! 383 \fn void BPictureButton::SetValue(int32 value) 384 \copydoc BControl::SetValue() 385*/ 386 387 388/*! 389 \fn status_t BPictureButton::Invoke(BMessage* message) 390 \copydoc BControl::Invoke() 391*/ 392 393 394/*! 395 \fn BHandler* BPictureButton::ResolveSpecifier(BMessage* message, 396 int32 index, BMessage* specifier, int32 what, const char* property) 397 \copydoc BControl::ResolveSpecifier() 398*/ 399 400 401/*! 402 \fn status_t BPictureButton::GetSupportedSuites(BMessage* data) 403 \copydoc BControl::GetSupportedSuites() 404*/ 405 406 407/*! 408 \fn status_t BPictureButton::Perform(perform_code code, void* _data) 409 \copydoc BHandler::GetSupportedSuites() 410*/ 411 412 413/*! 414 \fn status_t BPictureButton::SetIcon(const BBitmap* icon, uint32 flags) 415 \see BControl::SetIcon() 416 417 \since Haiku R1 418*/ 419