1/* 2 * Copyright 2010 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Alex Wilson, yourpalal2@gmail.com 7 * 8 * Corresponds to: 9 * headers/os/interface/GroupLayout.h rev 38207 10 * src/kits/interface/GroupLayout.cpp rev 38207 11 */ 12 13 14/*! 15 \file GroupLayout.h 16 \ingroup interface 17 \ingroup layout 18 \ingroup libbe 19 \brief Describes the BGroupLayout class. 20*/ 21 22 23/*! \class BGroupLayout 24 \ingroup interface 25 \ingroup layout 26 \ingroup libbe 27 \brief The BGroupLayout class is a simple BLayout subclass that 28 arranges the items it holds within a vertical or horizontal box. 29 30 In a horizontal BGroupLayout, each BLayoutItem is given the same vertical 31 area, but different horizontal areas. In a vertical BGroupLayout, each 32 BLayoutItem is given the same horizontal area, but different vertical areas. 33 Despite this, because of alignment and size constraints, the items in a 34 BGroupLayout may not all use the same vertical or horizontal area on screen. 35 Some BLayoutItems may have alignments that cause them to sit at the bottom 36 of the area they are given, for example. This is not a flaw or bug, but 37 something that you may come across when using this class. 38 39 In a BGroupLayout, each BLayoutItem or BView has a weight, the default 40 weight is \c 1.0f. When a BGroupLayout is not given enough space to satisfy 41 the minimum sizes of all items, then space is distributed according to 42 weight, while still attempting to satisfy minimum size constraints. 43 Weighting is scaled over the sum weight of all the items in this layout. 44 If a particular item has half of the sum weight of all items, it 45 will get half of the total space, unless this exceeds that item's maximum 46 size. If the space for an item exceeds the items maximum size, the excess 47 will be distributed to other items. 48 49 \warning This class is not yet finalized, if you use it in your software 50 assume that it will break some time in the future. 51*/ 52 53 54/*! 55 \fn BGroupLayout::BGroupLayout(orientation orientation, float spacing) 56 \brief Creates a new BGroupLayout. 57 58 \param orientation The orientation of this BGroupLayout. 59 \param spacing The spacing between BLayoutItems in this BGroupLayout. 60*/ 61 62 63/*! 64 \fn BGroupLayout::~BGroupLayout() 65 \brief Destructor method. 66 67 Standard Destructor. 68*/ 69 70 71/*! 72 \fn BGroupLayout::BGroupLayout(BMessage* from) 73 \brief Archive constructor. 74 75 \param from The message to construct the BGroupLayout from. 76*/ 77 78 79/*! 80 \fn float BGroupLayout::Spacing() const 81 \brief Get the amount of spacing (in pixels) between each item. 82*/ 83 84 85/*! 86 \fn void BGroupLayout::SetSpacing(float spacing) 87 \brief Set the amount of spacing (in pixels) between each item. 88*/ 89 90 91/*! 92 \fn orientation BGroupLayout::Orientation() const 93 \brief Get the #orientation of this BGroupLayout. 94*/ 95 96 97/*! 98 \fn void BGroupLayout::SetOrientation(orientation orientation) 99 \brief Set the #orientation of this BGroupLayout. 100 \param orientation The new #orientation of this BGroupLayout. 101*/ 102 103 104/*! 105 \fn float BGroupLayout::ItemWeight(int32 index) const 106 \brief Get the weight of the item at \a index. 107*/ 108 109 110/*! 111 \fn void BGroupLayout::SetItemWeight(int32 index, float weight) 112 \brief Set the weight of the item at \a index. 113*/ 114 115 116/*! 117 \fn BLayoutItem* BGroupLayout::AddView(BView* child) 118 \brief Adds \a child to this layout as the last item. In a vertical 119 BGroupLayout, \a child will be on the right, in a horizontal 120 BGroupLayout, \a child will be at the bottom. 121 122 \a child will have a weight of \c 1.0f. 123*/ 124 125 126/*! 127 \fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child) 128 \brief Adds \a child to this layout at \a index. 129 130 \a child will have a weight of \c 1.0f. 131*/ 132 133 134/*! 135 \fn BLayoutItem* BGroupLayout::AddView(BView* child, float weight) 136 \brief Adds \a child to the end of this layout with a weight of 137 \a weight. 138*/ 139 140 141/*! 142 \fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child, 143 float weight) 144 \brief Adds \a child this layout at \a index with a weight of 145 \a weight. 146*/ 147 148 149/*! 150 \fn bool BGroupLayout::AddItem(BLayoutItem* item) 151 \brief Adds \a item to this layout as the last item. In a vertical 152 BGroupLayout, \a item will be on the right, in a horizontal 153 BGroupLayout, \a item will be at the bottom. 154 155 \a item will have a weight of \c 1.0f. 156*/ 157 158 159/*! 160 \fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item) 161 \brief Adds \a item to this layout at \a index. 162 163 \a item will have a weight of \c 1.0f. 164*/ 165 166 167/*! 168 \fn bool BGroupLayout::AddItem(BLayoutItem* item, float weight) 169 \brief Adds \a item to the end of this layout with a weight of 170 \a weight. 171*/ 172 173 174/*! 175 \fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item, float weight) 176 \brief Adds \a item this layout at \a index with a weight of 177 \a weight. 178*/ 179