1/* 2 * Copyright 2011 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 * Ingo Weinhold, bonefish@cs.tu-berlin.de 8 * 9 * Corresponds to: 10 * headers/os/interface/GroupLayoutBuilder.h rev 42274 11 * src/kits/interface/GroupLayoutBuilder.cpp rev 42274 12 */ 13 14 15/*! 16 \file GroupLayoutBuilder.h 17 \ingroup layout 18 \ingroup libbe 19 \brief Provides the BLayoutBuilder::Group<> class. 20 21 \since Haiku R1 22*/ 23 24 25/*! 26 \class BLayoutBuilder::Group<> 27 \ingroup layout 28 \ingroup libbe 29 \brief BLayoutBuilder::Base subclass for building BGroupLayouts. 30 31 \since Haiku R1 32*/ 33 34 35/*! 36 \typedef BLayoutBuilder::Group<ParentBuilder>::GroupBuilder 37 \brief Shorthand for builders returned by this builder's AddGroup() methods. 38 39 \since Haiku R1 40*/ 41 42 43/*! 44 \typedef BLayoutBuilder::Group<ParentBuilder>::GridBuilder 45 \brief Shorthand for builders returned by this builder's AddGrid() methods. 46 47 \since Haiku R1 48*/ 49 50 51/*! 52 \typedef BLayoutBuilder::Group<ParentBuilder>::SplitBuilder 53 \brief Shorthand for builders returned by this builder's AddSplit() methods. 54 55 \since Haiku R1 56*/ 57 58 59/*! 60 \typedef BLayoutBuilder::Group<ParentBuilder>::ThisBuilder 61 \brief Shorthand representing the type of \c this. 62 63 \since Haiku R1 64*/ 65 66 67/*! 68 \name Constructors 69*/ 70 71 72//! @{ 73 74 75/*! 76 \fn BLayoutBuilder::Group<ParentBuilder>::Group(BWindow *window, 77 orientation orientation, float spacing) 78 \brief Creates a new BGroupLayout, and attaches it to a BWindow. 79 80 \note The top BView* in \a window has its ViewColor set to 81 \c B_PANEL_BACKGROUND_COLOR. 82 \param window Thew BWindow* to attach the newly created BGroupLayout to. 83 \param orientation The orientation for the new BGroupLayout. 84 \param spacing The spacing for the new BGroupLayout. 85 86 \since Haiku R1 87*/ 88 89 90/*! 91 \fn BLayoutBuilder::Group<ParentBuilder>::Group(BGroupLayout* layout) 92 \brief Creates a builder targeting a BGroupLayout. 93 94 Methods called on this builder will be directed to \a layout. 95 96 \param layout The BGroupLayout to target with this builder. 97 98 \since Haiku R1 99*/ 100 101 102/*! 103 \fn BLayoutBuilder::Group<ParentBuilder>::Group(BGroupView* view) 104 \brief Creates a builder targeting a BGroupView. 105 106 Methods called on this builder will be directed to 107 \c view->GroupLayout(). 108 109 \param view The BGroupView this builder will target. 110 111 \since Haiku R1 112*/ 113 114 115/*! 116 \fn BLayoutBuilder::Group<ParentBuilder>::Group( 117 orientation orientation, float spacing) 118 \brief Creates a new BGroupView and targets it. 119 120 Methods called on this builder will be directed to the new BGroupView's 121 BGroupLayout. 122 123 \param orientation The orientation for the new BGroupView. 124 \param spacing The spacing for the new BGroupView. 125 126 \since Haiku R1 127*/ 128 129 130//! @} 131 132 133/*! 134 \name Adding BViews and BLayoutItems 135*/ 136 137 138//! @{ 139 140/*! 141 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::Add(BView* view) 142 \brief Add a BView to the BGroupLayout this builder represents. 143 144 \param view The BView to be added. 145 \see BGroupLayout::AddView(BView*) 146 147 \since Haiku R1 148*/ 149 150 151/*! 152 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::Add(BView* view, 153 float weight) 154 \brief Add BView to the BGroupLayout this builder represents. 155 156 \param view The BView to be added. 157 \param weight The weight to give \a view. 158 159 \see BGroupLayout::AddView(BView* view, float weight) 160 161 \since Haiku R1 162*/ 163 164 165/*! 166 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::Add( 167 BLayoutItem* item) 168 \brief Add a BLayoutItem to the BGroupLayout this builder represents. 169 170 \param item The BLayoutItem to be added. 171 172 \see BGroupLayout::AddItem(BLayoutItem*) 173 174 \since Haiku R1 175*/ 176 177 178/*! 179 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::Add(BLayoutItem* 180 item, float weight) 181 \brief Add a BLayoutItem the BGroupLayout this builder represents. 182 183 \param item The BLayoutItem to be added. 184 \param weight The weight to give \a item. 185 \see BGroupLayout::AddItem(BLayoutItem* item, float weight) 186 187 \since Haiku R1 188*/ 189 190 191//! @} 192 193 194/*! 195 \name Adding BLayouts and their BView Pairs 196 197 A set of methods that add a BLayout or BView subclass and return a 198 BLayoutBuilder::Base subclass representing the newly added object. These 199 methods push a new builder on top of the stack, you will not be using 200 \c this builder again until you call End(). 201*/ 202 203 204//! @{ 205 206 207/*! 208 \fn GroupBuilder BLayoutBuilder::Group<ParentBuilder>::AddGroup( 209 orientation orientation, float spacing, float weight) 210 \brief Construct and add a viewless BGroupLayout, then return a GroupBuilder 211 representing the newly added layout. 212 213 \param orientation The orientation to use for the new BGroupLayout. 214 \param spacing The spacing to use for the new BGroupLayout. 215 \param weight The weight for the new BGroupLayout in the BGroupLayout this 216 builder represents. 217 218 \returns A GroupBuilder representing the newly created BGroupLayout. 219 220 \since Haiku R1 221*/ 222 223 224/*! 225 \fn GroupBuilder BLayoutBuilder::Group<ParentBuilder>::AddGroup(BGroupView* 226 groupView, float weight) 227 \brief Add BGroupView and return a builder representing the newly added 228 BGroupView. 229 230 \param groupView The BGroupView to be added. 231 \param weight The weight for \a groupView in the BGroupLayout this builder 232 represents. 233 234 \returns A GroupBuilder representing \a groupView. 235 236 \since Haiku R1 237*/ 238 239 240/*! 241 \fn GroupBuilder BLayoutBuilder::Group<ParentBuilder>::AddGroup( 242 BGroupLayout* groupLayout, float weight) 243 \brief Add a BGroupLayout and return a builder representing the newly added 244 BGroupLayout. 245 246 \param groupLayout The BGroupLayout to be added. 247 \param weight The weight for \a groupLayout in the BGroupLayout this builder 248 represents. 249 250 \returns A GroupBuilder representing \a groupLayout. 251 252 \since Haiku R1 253*/ 254 255 256/*! 257 \fn GridBuilder BLayoutBuilder::Group<ParentBuilder>::AddGrid( 258 float horizontalSpacing = 0.0f, float verticalSpacing = 0.0f, 259 float weight = 1.0f) 260 \brief Create and add a viewless BGridLayout, then return a builder 261 representing the newly created BGridLayout. 262 263 \param horizontalSpacing The horizontal spacing for the new BGridLayout. 264 \param verticalSpacing The vertical spacing for the new BGridLayout. 265 \param weight The weight for the new BGroupLayout in the BGroupLayout this 266 builder represents. 267 268 \returns A GridBuilder representing the newly created BGridLayout. 269 270 \since Haiku R1 271*/ 272 273 274/*! 275 \fn GridBuilder BLayoutBuilder::Group<ParentBuilder>::AddGrid( 276 BGridLayout* gridLayout, float weight = 1.0f) 277 \brief Add a BGridLayout, then return a builder the newly added BGridLayout. 278 279 \param gridLayout The BGridLayout to be added and used to construct the 280 returned GridBuilder. 281 \param weight The weight for \a groupLayout in the BGroupLayout this builder 282 represents. 283 284 \returns a GridBuilder representing \a gridLayout. 285 286 \since Haiku R1 287*/ 288 289 290/*! 291 \fn GridBuilder BLayoutBuilder::Group<ParentBuilder>::AddGrid( 292 BGridView* gridView, float weight = 1.0f) 293 \brief Add a BGridView, then return a builder the newly added BGridView. 294 295 \param gridView The BGridView to be added and used to construct the 296 returned GridBuilder. 297 \param weight The weight for \a groupLayout in the BGroupLayout this builder 298 represents. 299 300 \returns a GridBuilder representing \a gridView. 301 302 \since Haiku R1 303*/ 304 305 306/*! 307 \fn SplitBuilder BLayoutBuilder::Group<ParentBuilder>::AddSplit( 308 orientation orientation, float spacing, float weight) 309 \brief Create and add a new BSplitView with a weight of \c weight, then 310 return a SplitBuilder representing the new BSplitView. 311 312 \param orientation The orientation of the new BSplitView. 313 \param spacing The spacing of the new BSplitView. 314 \param weight The weight, in this BGroupLayout for the new BSplitView. 315 316 \returns a SplitBuilder representing the new BSplitView. 317 318 \since Haiku R1 319*/ 320 321 322/*! 323 \fn SplitBuilder BLayoutBuilder::Group<ParentBuilder>::AddSplit( 324 BSplitView* splitView, float weight = 1.0f) 325 \brief Add a BSplitView to the BGroupLayout this builder represents and 326 return a SplitBuilder representing the BSplitView. 327 328 \param splitView The BSplitView to be added. 329 \param weight The weight of the BSplitView in the BGroupLayout this builder 330 represents. 331 332 \since Haiku R1 333*/ 334 335 336//! @} 337 338 339/*! 340 \name Adding BSpaceLayoutItems 341 342 Some convenience methods for adding special BSpaceLayoutItems. 343*/ 344 345 346//! @{ 347 348 349/*! 350 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::AddGlue( 351 float weight = 1.0f) 352 \brief Add a BSpaceLayoutItem created by BSpaceLayoutItem::CreateGlue() 353 to the BGroupLayout this builder represents. 354 355 \param weight The weight of the BSpaceLayoutItem in the BGroupLayout this 356 builder represents 357 358 \since Haiku R1 359*/ 360 361 362/*! 363 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::AddStrut(float size) 364 \brief Add a BSpaceLayoutItem created by 365 BSpaceLayoutItem::CreateHorizontalStrut() or 366 BSpaceLayoutItem::CreateVerticalStrut() to the BGroupLayout 367 this builder represents. 368 369 \param size The width or height of the strut to be created (depending on 370 the orientation of the BGroupLayout this builder represents). 371 372 \since Haiku R1 373*/ 374 375 376//!@} 377 378 379/*! 380 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::SetInsets(float left, 381 float top, float right, float bottom) 382 \brief Call the BTwoDimensionalLayout::SetInsets() method on the 383 BGroupLayout this builder represents. 384 385 \since Haiku R1 386*/ 387 388 389/*! 390 \name Accessors 391*/ 392 393 394//! @{ 395 396 397/*! 398 \fn BGroupLayout* BLayoutBuilder::Group<ParentBuilder>::Layout() const 399 \brief Get the BGroupLayout this builder represents. 400 401 \since Haiku R1 402*/ 403 404 405/*! 406 \fn BView* BLayoutBuilder::Group<ParentBuilder>::View() const 407 \brief Get the BView this builder's BGroupLayout is attached to. 408 409 \since Haiku R1 410*/ 411 412 413/*! 414 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::GetLayout( 415 BGroupLayout** _layout) 416 \brief Get the BGroupLayout this builder represents. 417 418 \param[out] _layout The BGroupLayout this builder represents. 419 420 \since Haiku R1 421*/ 422 423 424/*! 425 \fn ThisBuilder& BLayoutBuilder::Group<ParentBuilder>::GetView( 426 BView** _view) 427 \brief Get the BView this builder's BGroupLayout is attached to. 428 429 \param[out] _view The BView this builder's BGroupLayout is attached to. 430 431 \since Haiku R1 432*/ 433 434 435/*! 436 \fn BLayoutBuilder::Group<ParentBuilder>::operator BGroupLayout*() 437 \brief Cast this builder into the BGroupLayout it represents. 438 439 \since Haiku R1 440*/ 441 442 443//!@} 444