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/*! 24 \class BGroupLayout 25 \ingroup interface 26 \ingroup layout 27 \ingroup libbe 28 \brief The BGroupLayout class is a simple BLayout subclass that 29 arranges the items it holds within a vertical or horizontal box. 30 31 In a horizontal BGroupLayout, each BLayoutItem is given the same vertical 32 area, but different horizontal areas. In a vertical BGroupLayout, each 33 BLayoutItem is given the same horizontal area, but different vertical areas. 34 Despite this, because of alignment and size constraints, the items in a 35 BGroupLayout may not all use the same vertical or horizontal area on screen. 36 Some BLayoutItems may have alignments that cause them to sit at the bottom 37 of the area they are given, for example. This is not a flaw or bug, but 38 something that you may come across when using this class. 39 40 In a BGroupLayout, each BLayoutItem or BView has a weight, the default 41 weight is \c 1.0f. When a BGroupLayout is not given enough space to satisfy 42 the minimum sizes of all items, then space is distributed according to 43 weight, while still attempting to satisfy minimum size constraints. 44 Weighting is scaled over the sum weight of all the items in this layout. 45 If a particular item has half of the sum weight of all items, it 46 will get half of the total space, unless this exceeds that item's maximum 47 size. If the space for an item exceeds the items maximum size, the excess 48 will be distributed to other items. 49 50 \warning This class is not yet finalized, if you use it in your software 51 assume that it will break some time in the future. 52 53 \since Haiku R1 54*/ 55 56 57/*! 58 \fn BGroupLayout::BGroupLayout(orientation orientation, float spacing) 59 \brief Creates a new BGroupLayout. 60 61 \param orientation The orientation of this BGroupLayout. 62 \param spacing The spacing between BLayoutItems in this BGroupLayout. 63 64 \since Haiku R1 65*/ 66 67 68/*! 69 \fn BGroupLayout::~BGroupLayout() 70 \brief Destructor method. 71 72 Standard Destructor. 73 74 \since Haiku R1 75*/ 76 77 78/*! 79 \fn BGroupLayout::BGroupLayout(BMessage* from) 80 \brief Archive constructor. 81 82 \param from The message to construct the BGroupLayout from. 83 84 \since Haiku R1 85*/ 86 87 88/*! 89 \fn float BGroupLayout::Spacing() const 90 \brief Get the amount of spacing (in pixels) between each item. 91 92 \since Haiku R1 93*/ 94 95 96/*! 97 \fn void BGroupLayout::SetSpacing(float spacing) 98 \brief Set the amount of spacing (in pixels) between each item. 99 100 \since Haiku R1 101*/ 102 103 104/*! 105 \fn orientation BGroupLayout::Orientation() const 106 \brief Get the #orientation of this BGroupLayout. 107 108 \since Haiku R1 109*/ 110 111 112/*! 113 \fn void BGroupLayout::SetOrientation(orientation orientation) 114 \brief Set the #orientation of this BGroupLayout. 115 116 \param orientation The new #orientation of this BGroupLayout. 117 118 \since Haiku R1 119*/ 120 121 122/*! 123 \fn float BGroupLayout::ItemWeight(int32 index) const 124 \brief Get the weight of the item at \a index. 125 126 \since Haiku R1 127*/ 128 129 130/*! 131 \fn void BGroupLayout::SetItemWeight(int32 index, float weight) 132 \brief Set the weight of the item at \a index. 133 134 \since Haiku R1 135*/ 136 137 138/*! 139 \fn BLayoutItem* BGroupLayout::AddView(BView* child) 140 \brief Adds \a child to this layout as the last item. In a vertical 141 BGroupLayout, \a child will be on the right, in a horizontal 142 BGroupLayout, \a child will be at the bottom. 143 144 \a child will have a weight of \c 1.0f. 145 146 \since Haiku R1 147*/ 148 149 150/*! 151 \fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child) 152 \brief Adds \a child to this layout at \a index. 153 154 \a child will have a weight of \c 1.0f. 155 156 \since Haiku R1 157*/ 158 159 160/*! 161 \fn BLayoutItem* BGroupLayout::AddView(BView* child, float weight) 162 \brief Adds \a child to the end of this layout with a weight of 163 \a weight. 164 165 \since Haiku R1 166*/ 167 168 169/*! 170 \fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child, 171 float weight) 172 \brief Adds \a child this layout at \a index with a weight of 173 \a weight. 174 175 \since Haiku R1 176*/ 177 178 179/*! 180 \fn bool BGroupLayout::AddItem(BLayoutItem* item) 181 \brief Adds \a item to this layout as the last item. In a vertical 182 BGroupLayout, \a item will be on the right, in a horizontal 183 BGroupLayout, \a item will be at the bottom. 184 185 \a item will have a weight of \c 1.0f. 186 187 \since Haiku R1 188*/ 189 190 191/*! 192 \fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item) 193 \brief Adds \a item to this layout at \a index. 194 195 \a item will have a weight of \c 1.0f. 196 197 \since Haiku R1 198*/ 199 200 201/*! 202 \fn bool BGroupLayout::AddItem(BLayoutItem* item, float weight) 203 \brief Adds \a item to the end of this layout with a weight of 204 \a weight. 205 206 \since Haiku R1 207*/ 208 209 210/*! 211 \fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item, 212 float weight) 213 \brief Adds \a item this layout at \a index with a weight of 214 \a weight. 215 216 \since Haiku R1 217*/ 218