2006-08-26 20:21:15 +04:00
|
|
|
/*
|
2010-07-16 22:11:24 +04:00
|
|
|
* Copyright 2006-2010, Haiku, Inc. All rights reserved.
|
2006-08-26 20:21:15 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _TWO_DIMENSIONAL_LAYOUT_H
|
|
|
|
#define _TWO_DIMENSIONAL_LAYOUT_H
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
#include <AbstractLayout.h>
|
2006-08-26 20:21:15 +04:00
|
|
|
|
|
|
|
class BLayoutContext;
|
|
|
|
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
class BTwoDimensionalLayout : public BAbstractLayout {
|
2006-08-26 20:21:15 +04:00
|
|
|
public:
|
|
|
|
BTwoDimensionalLayout();
|
2010-07-16 22:11:24 +04:00
|
|
|
BTwoDimensionalLayout(BMessage* from);
|
2006-08-26 20:21:15 +04:00
|
|
|
virtual ~BTwoDimensionalLayout();
|
|
|
|
|
|
|
|
void SetInsets(float left, float top, float right,
|
|
|
|
float bottom);
|
2011-06-10 00:58:52 +04:00
|
|
|
void SetInsets(float horizontal, float vertical);
|
|
|
|
void SetInsets(float insets);
|
2006-08-26 20:21:15 +04:00
|
|
|
void GetInsets(float* left, float* top, float* right,
|
2009-06-23 14:56:22 +04:00
|
|
|
float* bottom) const;
|
2006-08-26 20:21:15 +04:00
|
|
|
|
|
|
|
void AlignLayoutWith(BTwoDimensionalLayout* other,
|
|
|
|
enum orientation orientation);
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
virtual BSize BaseMinSize();
|
|
|
|
virtual BSize BaseMaxSize();
|
|
|
|
virtual BSize BasePreferredSize();
|
|
|
|
virtual BAlignment BaseAlignment();
|
2006-08-26 20:21:15 +04:00
|
|
|
|
|
|
|
virtual bool HasHeightForWidth();
|
|
|
|
virtual void GetHeightForWidth(float width, float* min,
|
|
|
|
float* max, float* preferred);
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
virtual void SetFrame(BRect frame);
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
virtual void InvalidateLayout(bool children = false);
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-07-16 22:11:24 +04:00
|
|
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
|
|
|
virtual status_t AllArchived(BMessage* into) const;
|
|
|
|
virtual status_t AllUnarchived(const BMessage* from);
|
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
protected:
|
|
|
|
struct ColumnRowConstraints {
|
|
|
|
float weight;
|
|
|
|
float min;
|
|
|
|
float max;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Dimensions {
|
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 width;
|
|
|
|
int32 height;
|
|
|
|
};
|
|
|
|
|
2011-09-10 01:20:01 +04:00
|
|
|
virtual void DoLayout();
|
2010-08-17 22:43:41 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
BSize AddInsets(BSize size);
|
|
|
|
void AddInsets(float* minHeight, float* maxHeight,
|
|
|
|
float* preferredHeight);
|
|
|
|
BSize SubtractInsets(BSize size);
|
|
|
|
|
|
|
|
virtual void PrepareItems(enum orientation orientation);
|
|
|
|
virtual bool HasMultiColumnItems();
|
|
|
|
virtual bool HasMultiRowItems();
|
2009-06-23 14:56:22 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
virtual int32 InternalCountColumns() = 0;
|
|
|
|
virtual int32 InternalCountRows() = 0;
|
|
|
|
virtual void GetColumnRowConstraints(
|
|
|
|
enum orientation orientation,
|
|
|
|
int32 index,
|
|
|
|
ColumnRowConstraints* constraints) = 0;
|
2010-07-16 22:11:24 +04:00
|
|
|
virtual void GetItemDimensions(BLayoutItem* item,
|
2006-08-26 20:21:15 +04:00
|
|
|
Dimensions* dimensions) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class CompoundLayouter;
|
|
|
|
class LocalLayouter;
|
|
|
|
class VerticalCompoundLayouter;
|
|
|
|
|
|
|
|
friend class LocalLayouter;
|
|
|
|
|
|
|
|
void _ValidateMinMax();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float fLeftInset;
|
|
|
|
float fRightInset;
|
|
|
|
float fTopInset;
|
|
|
|
float fBottomInset;
|
|
|
|
float fHSpacing;
|
|
|
|
float fVSpacing;
|
|
|
|
|
|
|
|
private:
|
|
|
|
LocalLayouter* fLocalLayouter;
|
|
|
|
};
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
#endif // _TWO_DIMENSIONAL_LAYOUT_H
|