1/* 2 * Copyright 2014-2019, 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/ScrollView.h hrev52792 10 * src/kits/interface/ScrollView.cpp hrev52792 11 */ 12 13 14/*! 15 \file ScrollView.h 16 \ingroup interface 17 \ingroup libbe 18 \brief BScrollView class definition. 19 \since BeOS R3 20*/ 21 22 23/*! 24 \class BScrollView 25 \ingroup interface 26 \ingroup libbe 27 \brief A convenience class used to add scrolling to a target view. 28 29 The BScrollView class conveniently provides a container view 30 adding the scroll bars and target view as siblings so that when one 31 is moved or resized the rest can follow. 32 33 \see BScrollBar to learn more about how scroll bars work. 34 35 \sa BView::ScrollTo() 36 \sa BView::ScrollBy() 37 \sa BView::TargetedByScrollView() 38 39 \since BeOS R3 40*/ 41 42 43/*! 44 \fn BScrollView::BScrollView(const char* name, BView* target, 45 uint32 resizingMode, uint32 flags, bool horizontal, bool vertical, 46 border_style border) 47 \brief Instantiates a new scroll view and connects it to the \a target 48 view. 49 50 \param name The name of the scroll bar, can be \c NULL. 51 \param target The \a target view to scroll, can be \c NULL. 52 \param resizingMode Defines the scroll view's behavior when its parent 53 is resized. See BView for details. 54 \param flags The view flags. See BView for details. 55 \param horizontal Whether or not to include a horizontal scroll bar. 56 \param vertical Whether or not to include a vertical scroll bar. 57 \param border The border style to use, options include: 58 - \c B_PLAIN_BORDER 59 - \c B_FANCY_BORDER 60 - \c B_NO_BORDER 61 62 \sa SetTarget() 63 \sa SetBorder() 64 65 \since BeOS R3 66*/ 67 68 69/*! 70 \fn BScrollView::BScrollView(const char* name, BView* target, uint32 flags, 71 bool horizontal, bool vertical, border_style border) 72 \brief Instantiates a new scroll view and connects it to the \a target 73 view suitable for use in a BLayout. 74 75 \param name The name of the scroll bar, can be \c NULL. 76 \param target The \a target view to scroll, can be \c NULL. 77 \param flags The view flags. See BView for details. 78 \param horizontal Whether or not to include a horizontal scroll bar. 79 \param vertical Whether or not to include a vertical scroll bar. 80 \param border The border style to use, options include: 81 - \c B_PLAIN_BORDER 82 - \c B_FANCY_BORDER 83 - \c B_NO_BORDER 84 85 \sa SetTarget() 86 \sa SetBorder() 87 88 \since Haiku R1 89*/ 90 91 92/*! 93 \fn BScrollView::BScrollView(BMessage* archive) 94 \brief Archive constructor. 95 96 \param archive The message \a data to construct the scroll view from. 97 98 \since BeOS R3 99*/ 100 101 102/*! 103 \fn BScrollView::~BScrollView() 104 \brief Destructor method. 105 106 Deletes the scroll view, sets the target to \c NULL and frees any 107 memory used. 108 109 \since BeOS R3 110*/ 111 112 113/*! 114 \name Archiving 115*/ 116 117 118//! @{ 119 120 121/*! 122 \fn BArchivable* BScrollView::Instantiate(BMessage* archive) 123 \brief Creates a new BScrollView object from the \a archive message. 124 125 \return A newly created scroll view or \c NULL if the message doesn't 126 contain an archived BScrollView object. 127 128 \since BeOS R3 129*/ 130 131 132/*! 133 \fn status_t BScrollView::Archive(BMessage* archive, bool deep) const 134 \brief Archives the object into the \a archive message. 135 136 \param archive A pointer to the BMessage object to archive the object into. 137 \param deep Whether or not to archive child views as well. 138 139 \return A status code, \c B_OK if everything went well or an error code 140 otherwise. 141 142 \since BeOS R3 143*/ 144 145 146//! @} 147 148 149/*! 150 \name Hook Methods 151*/ 152 153 154//! @{ 155 156 157/*! 158 \fn void BScrollView::AllAttached() 159 \copydoc BView::AllAttached() 160*/ 161 162 163/*! 164 \fn void BScrollView::AllDetached() 165 \copydoc BView::AllDetached() 166*/ 167 168 169/*! 170 \fn void BScrollView::AttachedToWindow() 171 \brief Hook method called when the scroll bar is attached to a window. 172 173 Checks if the window uses \c B_DOCUMENT_LOOK and adjust the size of the bars 174 to make room for the window resize knob. 175 176 \copydetails BView::AttachedToWindow() 177*/ 178 179 180/*! 181 \fn void BScrollView::DetachedFromWindow() 182 \brief Hook method called when the object is detached from a window. 183 184 \copydetails BView::DetachedFromWindow() 185*/ 186 187 188/*! 189 \fn void BScrollView::Draw(BRect updateRect) 190 \brief Draws the area of the scroll view that intersects \a updateRect. 191 192 \param updateRect The rectangular area to be drawn. 193 194 \since BeOS R3 195*/ 196 197 198/*! 199 \fn void BScrollView::MakeFocus(bool focus) 200 \brief Makes the scroll view the current focus view of the window or gives 201 up being the window's focus view. 202 203 \copydetails BView::MakeFocus() 204*/ 205 206 207/*! 208 \fn void BScrollView::FrameMoved(BPoint newPosition) 209 \brief Hook method called when the scroll view is moved. 210 211 \copydetails BView::FrameMoved() 212*/ 213 214 215/*! 216 \fn void BScrollView::FrameResized(float newWidth, float newHeight) 217 \brief Hook method called when the scroll view is resized. 218 219 If the scroll view is part of a layout, the default implementation will 220 re-proportion the attached scrollbars relative to the new size. 221*/ 222 223 224/*! 225 \fn void BScrollView::MessageReceived(BMessage* message) 226 \copydoc BView::MessageReceived() 227*/ 228 229 230/*! 231 \fn void BScrollView::MouseDown(BPoint where) 232 \copydoc BView::MouseDown() 233*/ 234 235 236/*! 237 \fn void BScrollView::MouseMoved(BPoint where, uint32 code, 238 const BMessage* dragMessage) 239 \copydoc BView::MouseMoved() 240*/ 241 242 243/*! 244 \fn void BScrollView::MouseUp(BPoint where) 245 \copydoc BView::MouseUp() 246*/ 247 248 249/*! 250 \fn void BScrollView::WindowActivated(bool active) 251 \copydoc BView::WindowActivated() 252*/ 253 254 255//! @} 256 257 258/*! 259 \fn void BScrollView::GetPreferredSize(float* _width, float* _height) 260 \brief Fill out the preferred width and height of the scroll view 261 into the \a _width and \a _height parameters. 262 263 \copydetails BView::GetPreferredSize() 264*/ 265 266 267/*! 268 \fn BSize BScrollView::MinSize() 269 \brief Return the scroll view's minimum size. 270 271 \return The minimum size of the scroll view as a BSize. 272 273 \sa BAbstractLayout::MinSize() 274 275 \since Haiku R1 276*/ 277 278 279/*! 280 \fn BSize BScrollView::MaxSize() 281 \brief Return the scroll view's maximum size. 282 283 \return The maximum size of the scroll view as a BSize. 284 285 \sa BAbstractLayout::MaxSize() 286 287 \since Haiku R1 288*/ 289 290 291/*! 292 \fn BSize BScrollView::PreferredSize() 293 \brief Return the scroll view's preferred size. 294 295 \return The preferred size of the scroll view as a BSize. 296 297 \sa BAbstractLayout::PreferredSize() 298 299 \since Haiku R1 300*/ 301 302 303/*! 304 \fn void BScrollView::ResizeToPreferred() 305 \brief Resizes the scroll view to its preferred size keeping the position of 306 the left top corner constant. 307 308 \copydetails BView::ResizeToPreferred() 309*/ 310 311 312/*! 313 \name BScrollBar 314*/ 315 316 317//! @{ 318 319 320/*! 321 \fn BScrollBar* BScrollView::ScrollBar(orientation direction) const 322 \brief Returns the BScrollBar object at the given \a direction. 323 324 \param direction The \a direction of the desired scroll bar, one of the 325 following: 326 - \c B_HORIZONTAL to get the horizontal scroll bar 327 - \c B_VERTICAL to get the vertical scroll bar 328 329 \returns A pointer to the desired BScrollBar object or \c NULL 330 if there was no scroll bar at that location. 331 332 \since BeOS R3 333*/ 334 335 336/*! 337 \fn void BScrollView::SetBorder(border_style border) 338 \brief Set the border style of the scroll view. 339 340 \param border The border style constant to use, one of the following: 341 - \c B_PLAIN_BORDER 342 - \c B_FANCY_BORDER 343 - \c B_NO_BORDER 344 345 \since BeOS R3 346*/ 347 348 349/*! 350 \fn border_style BScrollView::Border() const 351 \brief Return the border style used. 352 353 \return The border style constant used. 354 355 \since BeOS R3 356*/ 357 358 359/*! 360 \fn status_t BScrollView::SetBorderHighlighted(bool highlight) 361 \brief Highlights or unhighlights the border of the scroll view's 362 scroll bars. 363 364 \param highlight \c true to turn highlighting on, \c false to remove it. 365 366 \return If successful returns \c B_OK, otherwise, returns \c B_ERROR. 367 368 \since BeOS R3 369*/ 370 371 372/*! 373 \fn bool BScrollView::IsBorderHighlighted() const 374 \brief Returns whether or not the border is highlighted. 375 376 \return \c true if the border is highlighted, \c false otherwise. 377 378 \since BeOS R3 379*/ 380 381 382/*! 383 \fn void BScrollView::SetTarget(BView* target) 384 \brief Sets the \a target view that the scroll bars operates on unsetting 385 the previous target. 386 387 \param target The \a target view to set. 388 389 \since Haiku R1 390*/ 391 392 393/*! 394 \fn BView* BScrollView::Target() const 395 \brief Returns a pointer to the target view. 396 397 \return A pointer to a BView object that represents the target view or 398 \c NULL if the target is not set. 399 400 \since Haiku R1 401*/ 402 403 404//! @} 405 406 407/*! 408 \name Scripting 409*/ 410 411 412//! @{ 413 414 415/*! 416 \fn BHandler* BScrollView::ResolveSpecifier(BMessage* message, int32 index, 417 BMessage* specifier, int32 what, const char* property) 418 \brief Determine the proper handler for a scripting message. 419 420 \copydetails BView::ResolveSpecifier() 421*/ 422 423 424/*! 425 \fn status_t BScrollView::GetSupportedSuites(BMessage* message) 426 \brief Reports the suites of messages and specifiers understood by the 427 scroll view. 428 429 \copydetails BView::GetSupportedSuites() 430*/ 431 432 433//! @} 434 435 436/*! 437 \fn status_t BScrollView::Perform(perform_code code, void* _data) 438 \brief Perform some action. (Internal Method) 439 440 \since Haiku R1 441*/ 442 443 444/*! 445 \fn void BScrollView::LayoutInvalidated(bool descendants) 446 \brief Hook method called when the layout is invalidated. 447 448 The default implementation does nothing. 449 450 \param descendants Whether or not child views have also been invalidated. 451 452 \since Haiku R1 453*/ 454 455 456/*! 457 \fn void BScrollView::DoLayout() 458 \brief Layout view within the layout context. 459 460 \since Haiku R1 461*/ 462