haiku/headers/os/interface/GridLayout.h
Alex Wilson 82ab316723 Add default spacing for Layouts (#5614)
* introduce B_USE_DEFAULT_SPACING, which works somewhat like B_SIZE_UNSET and B_ALIGN_HORIZONTAL_UNSET
* introduce static float BControlLook::ComposeItemSpacing(float spacing), which checks uses be_control_look->DefaultItemSpacing().
* modify layouts to use BControlLook::ComposeItemSpacing() in SetInsets and SetSpacing methods.
* default insets are still 0, 0, 0, 0, but can be set to default spacing by passing B_USE_DEFAULT_SPACING
* I've found two regressions, patches incoming, please report others on #5614.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38512 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-09-02 22:58:24 +00:00

109 lines
3.2 KiB
C++

/*
* Copyright 2006-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _GRID_LAYOUT_H
#define _GRID_LAYOUT_H
#include <TwoDimensionalLayout.h>
class BGridLayout : public BTwoDimensionalLayout {
public:
BGridLayout(float horizontal
= B_USE_DEFAULT_SPACING,
float vertical = B_USE_DEFAULT_SPACING);
BGridLayout(BMessage* from);
virtual ~BGridLayout();
int32 CountColumns() const;
int32 CountRows() const;
float HorizontalSpacing() const;
float VerticalSpacing() const;
void SetHorizontalSpacing(float spacing);
void SetVerticalSpacing(float spacing);
void SetSpacing(float horizontal, float vertical);
float ColumnWeight(int32 column) const;
void SetColumnWeight(int32 column, float weight);
float MinColumnWidth(int32 column) const;
void SetMinColumnWidth(int32 column, float width);
float MaxColumnWidth(int32 column) const;
void SetMaxColumnWidth(int32 column, float width);
float RowWeight(int32 row) const;
void SetRowWeight(int32 row, float weight);
float MinRowHeight(int row) const;
void SetMinRowHeight(int32 row, float height);
float MaxRowHeight(int32 row) const;
void SetMaxRowHeight(int32 row, float height);
virtual BLayoutItem* AddView(BView* child);
virtual BLayoutItem* AddView(int32 index, BView* child);
virtual BLayoutItem* AddView(BView* child, int32 column, int32 row,
int32 columnCount = 1, int32 rowCount = 1);
virtual bool AddItem(BLayoutItem* item);
virtual bool AddItem(int32 index, BLayoutItem* item);
virtual bool AddItem(BLayoutItem* item, int32 column,
int32 row, int32 columnCount = 1,
int32 rowCount = 1);
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* from);
virtual status_t ItemArchived(BMessage* into,
BLayoutItem* item, int32 index) const;
virtual status_t ItemUnarchived(const BMessage* from,
BLayoutItem* item, int32 index);
protected:
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
virtual bool HasMultiColumnItems();
virtual bool HasMultiRowItems();
virtual int32 InternalCountColumns();
virtual int32 InternalCountRows();
virtual void GetColumnRowConstraints(
enum orientation orientation,
int32 index,
ColumnRowConstraints* constraints);
virtual void GetItemDimensions(BLayoutItem* item,
Dimensions* dimensions);
private:
class DummyLayoutItem;
class RowInfoArray;
struct ItemLayoutData;
bool _IsGridCellEmpty(int32 column, int32 row);
bool _AreGridCellsEmpty(int32 column, int32 row,
int32 columnCount, int32 rowCount);
bool _InsertItemIntoGrid(BLayoutItem* item);
bool _ResizeGrid(int32 columnCount, int32 rowCount);
ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const;
private:
BLayoutItem*** fGrid;
int32 fColumnCount;
int32 fRowCount;
RowInfoArray* fRowInfos;
RowInfoArray* fColumnInfos;
int32 fMultiColumnItems;
int32 fMultiRowItems;
};
#endif // _GRID_LAYOUT_H