2011-08-10 01:46:13 +04:00
|
|
|
/*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Copyright 2010 Haiku, Inc. All rights reserved.
|
2011-08-10 01:46:13 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Authors:
|
|
|
|
* Alex Wilson, yourpalal2@gmail.com
|
|
|
|
*
|
2011-08-10 01:46:13 +04:00
|
|
|
* Corresponds to:
|
2013-02-07 06:05:00 +04:00
|
|
|
* headers/os/interface/GroupLayout.h rev 38207
|
|
|
|
* src/kits/interface/GroupLayout.cpp rev 38207
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-01-15 06:11:15 +04:00
|
|
|
/*!
|
|
|
|
\file GroupLayout.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup interface
|
|
|
|
\ingroup layout
|
|
|
|
\ingroup libbe
|
2013-01-15 06:11:15 +04:00
|
|
|
\brief Describes the BGroupLayout class.
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-10-23 06:33:08 +04:00
|
|
|
/*! \class BGroupLayout
|
|
|
|
\ingroup interface
|
|
|
|
\ingroup layout
|
|
|
|
\ingroup libbe
|
|
|
|
\brief The BGroupLayout class is a simple BLayout subclass that
|
2013-02-07 06:05:00 +04:00
|
|
|
arranges the items it holds within a vertical or horizontal box.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
In a horizontal BGroupLayout, each BLayoutItem is given the same vertical
|
|
|
|
area, but different horizontal areas. In a vertical BGroupLayout, each
|
|
|
|
BLayoutItem is given the same horizontal area, but different vertical areas.
|
|
|
|
Despite this, because of alignment and size constraints, the items in a
|
|
|
|
BGroupLayout may not all use the same vertical or horizontal area on screen.
|
|
|
|
Some BLayoutItems may have alignments that cause them to sit at the bottom
|
|
|
|
of the area they are given, for example. This is not a flaw or bug, but
|
|
|
|
something that you may come across when using this class.
|
|
|
|
|
|
|
|
In a BGroupLayout, each BLayoutItem or BView has a weight, the default
|
|
|
|
weight is \c 1.0f. When a BGroupLayout is not given enough space to satisfy
|
|
|
|
the minimum sizes of all items, then space is distributed according to
|
|
|
|
weight, while still attempting to satisfy minimum size constraints.
|
|
|
|
Weighting is scaled over the sum weight of all the items in this layout.
|
|
|
|
If a particular item has half of the sum weight of all items, it
|
|
|
|
will get half of the total space, unless this exceeds that item's maximum
|
|
|
|
size. If the space for an item exceeds the items maximum size, the excess
|
|
|
|
will be distributed to other items.
|
|
|
|
|
|
|
|
\warning This class is not yet finalized, if you use it in your software
|
|
|
|
assume that it will break some time in the future.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BGroupLayout::BGroupLayout(enum orientation orientation, float spacing)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Creates a new BGroupLayout.
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\param orientation The #orientation of this BGroupLayout.
|
2010-10-23 06:33:08 +04:00
|
|
|
\param spacing The spacing between BLayoutItems in this BGroupLayout.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BGroupLayout::~BGroupLayout()
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Destructor method.
|
|
|
|
|
|
|
|
Standard Destructor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BGroupLayout::BGroupLayout(BMessage* from)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Archive constructor.
|
2011-08-10 01:46:13 +04:00
|
|
|
|
|
|
|
\param from The message to construct the BGroupLayout from.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn float BGroupLayout::Spacing() const
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Get the amount of spacing (in pixels) between each item.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn void BGroupLayout::SetSpacing(float spacing)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Set the amount of spacing (in pixels) between each item.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn orientation BGroupLayout::Orientation() const
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Get the #orientation of this BGroupLayout.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn void BGroupLayout::SetOrientation(enum orientation orientation)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Set the #orientation of this BGroupLayout.
|
|
|
|
\param orientation The new #orientation of this BGroupLayout.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn float BGroupLayout::ItemWeight(int32 index) const
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Get the weight of the item at \a index.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn void BGroupLayout::SetItemWeight(int32 index, float weight)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Set the weight of the item at \a index.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BLayoutItem* BGroupLayout::AddView(BView* child)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Adds \a child to this layout as the last item. In a vertical
|
2011-08-10 01:46:13 +04:00
|
|
|
BGroupLayout, \a child will be on the right, in a horizontal
|
|
|
|
BGroupLayout, \a child will be at the bottom.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\a child will have a weight of \c 1.0f.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a child to this layout at \a index.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\a child will have a weight of \c 1.0f.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BLayoutItem* BGroupLayout::AddView(BView* child, float weight)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a child to the end of this layout with a weight of
|
|
|
|
\a weight.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn BLayoutItem* BGroupLayout::AddView(int32 index, BView* child,
|
2010-10-23 06:33:08 +04:00
|
|
|
float weight)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a child this layout at \a index with a weight of
|
|
|
|
\a weight.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn bool BGroupLayout::AddItem(BLayoutItem* item)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Adds \a item to this layout as the last item. In a vertical
|
2011-08-10 01:46:13 +04:00
|
|
|
BGroupLayout, \a item will be on the right, in a horizontal
|
|
|
|
BGroupLayout, \a item will be at the bottom.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\a item will have a weight of \c 1.0f.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a item to this layout at \a index.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
\a item will have a weight of \c 1.0f.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn bool BGroupLayout::AddItem(BLayoutItem* item, float weight)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a item to the end of this layout with a weight of
|
|
|
|
\a weight.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\fn bool BGroupLayout::AddItem(int32 index, BLayoutItem* item, float weight)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Adds \a item this layout at \a index with a weight of
|
|
|
|
\a weight.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|