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/TwoDimensionalLayout.h rev 38207
|
|
|
|
* src/kits/interface/TwoDimensionalLayout.cpp rev 38207
|
2011-08-10 01:46:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file TwoDimensionalLayout.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup interface
|
|
|
|
\ingroup layout
|
|
|
|
\ingroup libbe
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Defines the BTwoDimensionalLayout class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-10-23 06:33:08 +04:00
|
|
|
/*!
|
|
|
|
\class BTwoDimensionalLayout
|
|
|
|
\ingroup interface
|
|
|
|
\ingroup layout
|
|
|
|
\ingroup libbe
|
|
|
|
\brief Abstract BLayout subclass arranging items within rows and columns.
|
|
|
|
|
|
|
|
This class manages all the tricky work of actually positioning/resizing
|
|
|
|
items, as well as calculating size constraints and providing extra features,
|
2011-08-10 01:46:13 +04:00
|
|
|
such as spacing/insets and alignment of multiple
|
|
|
|
BTwoDimensionalLayout's. Derived classes need only implement a few hook
|
|
|
|
methods to get a working layout.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
\warning This class is not yet finalized, if you use it in your software
|
|
|
|
assume that it will break some time in the future.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\struct BTwoDimensionalLayout::ColumnRowConstraints
|
|
|
|
\brief Used by BTwoDimensionalLayout derived classes to communicate the
|
2014-06-14 01:25:02 +04:00
|
|
|
size constraints for a given column or row to the
|
|
|
|
BTwoDimensionalLayout class.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\struct BTwoDimensionalLayout::Dimensions
|
|
|
|
\brief Used by BTwoDimensionalLayout derived classes to communicate the
|
2014-06-14 01:25:02 +04:00
|
|
|
positioning and size of a BLayoutItem, in terms of columns and rows
|
|
|
|
to the BTwoDimensionalLayout class.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BTwoDimensionalLayout::AlignLayoutWith(
|
2013-07-09 02:27:55 +04:00
|
|
|
BTwoDimensionalLayout* other, orientation orientation)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Align the BLayoutItem's in the specified \a orientation within
|
2014-06-14 01:25:02 +04:00
|
|
|
two or more BTwoDimensionalLayout's.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
When two (or more) BTwoDimensionalLayout's are aligned within a
|
|
|
|
certain \a orientation, then the BLayoutItem's within those
|
|
|
|
BTwoDimensionalLayout's will have identical widths or heights
|
|
|
|
(depending on how the BTwoDimensionalLayout's are aligned.)
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
If you align two BGroupLayout's horizontally for example, then the
|
|
|
|
BLayoutItem at index 0 in both BGroupLayout's will be given the same
|
|
|
|
horizontal area. The same is true for the BLayoutItem at index 1,
|
|
|
|
2, etc. Not all BTwoDimensionalLayout's have to have an item at each
|
|
|
|
index for the alignment to proceed.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
\param other The BTwoDimensionalLayout to be aligned with.
|
2011-08-10 01:46:13 +04:00
|
|
|
\param orientation The \a orientation on which to be aligned.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BTwoDimensionalLayout::SetInsets(float left, float top,
|
|
|
|
float right, float bottom)
|
|
|
|
\brief Set the insets for this BTwoDimensionalLayout (in pixels).
|
|
|
|
|
|
|
|
Set the spacing around the edges of this BTwoDimensionalLayout. If you
|
2011-08-10 01:46:13 +04:00
|
|
|
pass \c B_USE_DEFAULT_SPACING for a certain parameter, that parameter will
|
2010-10-23 06:33:08 +04:00
|
|
|
be replaced with the value returned by BControlLook::DefaultItemSpacing().
|
|
|
|
|
|
|
|
\see BTwoDimensionalLayout::GetInsets();
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BTwoDimensionalLayout::GetInsets(float* left, float* top,
|
|
|
|
float* right, float* bottom) const
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Get the insets for the BTwoDimensionalLayout (in pixels).
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
Passing \c NULL for any parameter is not an error, those parameters will
|
2010-10-23 06:33:08 +04:00
|
|
|
be ignored.
|
|
|
|
|
|
|
|
\see BTwoDimensionalLayout::SetInsets();
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-14 01:25:02 +04:00
|
|
|
\name Hook Methods
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
These methods are called automatically as needed during layout, and
|
|
|
|
provide the BTwoDimensionalLayout class with the necessary information
|
2011-08-10 01:46:13 +04:00
|
|
|
to properly layout the BLayoutItem in this BTwoDimensionalLayout.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
2010-10-23 06:33:08 +04:00
|
|
|
/*!
|
2013-07-09 02:27:55 +04:00
|
|
|
\fn void BTwoDimensionalLayout::PrepareItems(orientation orientation)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Prepare the BLayoutItem in this BTwoDimensionalLayout subclass
|
2014-06-14 01:25:02 +04:00
|
|
|
for layout within a certain \a orientation.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
This is a good place to update cache information that will be used in
|
|
|
|
other hook methods, for example.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BTwoDimensionalLayout::HasMultiColumnItems()
|
|
|
|
\brief Tests whether or not this BTwoDimensionalLayout contains any
|
2014-06-14 01:25:02 +04:00
|
|
|
BLayoutItem's spanning more than one column.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
The BTwoDimensionalLayout implementation returns false.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BTwoDimensionalLayout::HasMultiRowItems()
|
|
|
|
\brief Tests whether or not this BTwoDimensionalLayout contains any
|
2014-06-14 01:25:02 +04:00
|
|
|
BLayoutItem's spanning more than one row.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
The BTwoDimensionalLayout implementation returns false.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int32 BTwoDimensionalLayout::InternalCountColumns()
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Get the number of columns in the BTwoDimensionalLayout.
|
|
|
|
|
|
|
|
\returns The number of columns in the BTwoDimensionalLayout.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int32 BTwoDimensionalLayout::InternalCountRows()
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Get the number of rows in the BTwoDimensionalLayout.
|
|
|
|
|
|
|
|
\returns The number of rows in the BTwoDimensionalLayout.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-07-09 02:27:55 +04:00
|
|
|
\fn void BTwoDimensionalLayout::GetColumnRowConstraints(
|
|
|
|
orientation orientation, int32 index, ColumnRowConstraints* constraints)
|
2010-10-23 06:33:08 +04:00
|
|
|
\brief Fill in the ColumnRowConstraints for a certain column or row in
|
2014-06-14 01:25:02 +04:00
|
|
|
the BTwoDimensionalLayout.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
|
|
|
This method is used to communicate the size constraints and weight for
|
2011-08-10 01:46:13 +04:00
|
|
|
a given row/column in the BTwoDimensionalLayout.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BTwoDimensionalLayout::GetItemDimensions(BLayoutItem* item,
|
|
|
|
Dimensions* dimensions)
|
2011-08-10 01:46:13 +04:00
|
|
|
\brief Tell the base class what column and row a BLayoutItem is in as
|
2014-06-14 01:25:02 +04:00
|
|
|
well as how many columns and rows it covers.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:46:13 +04:00
|
|
|
//! @}
|