These files were in CR/LF newline format for some reason.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26084 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+589
-589
File diff suppressed because it is too large
Load Diff
+249
-249
@@ -1,249 +1,249 @@
|
||||
/*
|
||||
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <GroupLayout.h>
|
||||
|
||||
#include <LayoutItem.h>
|
||||
|
||||
|
||||
// ItemLayoutData
|
||||
struct BGroupLayout::ItemLayoutData {
|
||||
float weight;
|
||||
|
||||
ItemLayoutData()
|
||||
: weight(1)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// constructor
|
||||
BGroupLayout::BGroupLayout(enum orientation orientation, float spacing)
|
||||
: BTwoDimensionalLayout(),
|
||||
fOrientation(orientation)
|
||||
{
|
||||
SetSpacing(spacing);
|
||||
}
|
||||
|
||||
// destructor
|
||||
BGroupLayout::~BGroupLayout()
|
||||
{
|
||||
}
|
||||
|
||||
// Spacing
|
||||
float
|
||||
BGroupLayout::Spacing() const
|
||||
{
|
||||
return fHSpacing;
|
||||
}
|
||||
|
||||
// SetSpacing
|
||||
void
|
||||
BGroupLayout::SetSpacing(float spacing)
|
||||
{
|
||||
if (spacing != fHSpacing) {
|
||||
fHSpacing = spacing;
|
||||
fVSpacing = spacing;
|
||||
InvalidateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// Orientation
|
||||
orientation
|
||||
BGroupLayout::Orientation() const
|
||||
{
|
||||
return fOrientation;
|
||||
}
|
||||
|
||||
// SetOrientation
|
||||
void
|
||||
BGroupLayout::SetOrientation(enum orientation orientation)
|
||||
{
|
||||
if (orientation != fOrientation) {
|
||||
fOrientation = orientation;
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// ItemWeight
|
||||
float
|
||||
BGroupLayout::ItemWeight(int32 index) const
|
||||
{
|
||||
if (index < 0 || index >= CountItems())
|
||||
return 0;
|
||||
|
||||
ItemLayoutData* data = _LayoutDataForItem(ItemAt(index));
|
||||
return (data ? data->weight : 0);
|
||||
}
|
||||
|
||||
// SetItemWeight
|
||||
void
|
||||
BGroupLayout::SetItemWeight(int32 index, float weight)
|
||||
{
|
||||
if (index < 0 || index >= CountItems())
|
||||
return;
|
||||
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(ItemAt(index)))
|
||||
data->weight = weight;
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(BView* child)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddView(child);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(int32 index, BView* child)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddView(index, child);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(BView* child, float weight)
|
||||
{
|
||||
return AddView(-1, child, weight);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(int32 index, BView* child, float weight)
|
||||
{
|
||||
BLayoutItem* item = AddView(index, child);
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
data->weight = weight;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(BLayoutItem* item)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddItem(item);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(int32 index, BLayoutItem* item)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddItem(index, item);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(BLayoutItem* item, float weight)
|
||||
{
|
||||
return AddItem(-1, item, weight);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(int32 index, BLayoutItem* item, float weight)
|
||||
{
|
||||
bool success = AddItem(index, item);
|
||||
if (success) {
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
data->weight = weight;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// ItemAdded
|
||||
void
|
||||
BGroupLayout::ItemAdded(BLayoutItem* item)
|
||||
{
|
||||
item->SetLayoutData(new ItemLayoutData);
|
||||
}
|
||||
|
||||
// ItemRemoved
|
||||
void
|
||||
BGroupLayout::ItemRemoved(BLayoutItem* item)
|
||||
{
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item)) {
|
||||
item->SetLayoutData(NULL);
|
||||
delete data;
|
||||
}
|
||||
}
|
||||
|
||||
// PrepareItems
|
||||
void
|
||||
BGroupLayout::PrepareItems(enum orientation orientation)
|
||||
{
|
||||
// filter the visible items
|
||||
fVisibleItems.MakeEmpty();
|
||||
int32 itemCount = CountItems();
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
BLayoutItem* item = ItemAt(i);
|
||||
if (item->IsVisible())
|
||||
fVisibleItems.AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
// InternalCountColumns
|
||||
int32
|
||||
BGroupLayout::InternalCountColumns()
|
||||
{
|
||||
return (fOrientation == B_HORIZONTAL ? fVisibleItems.CountItems() : 1);
|
||||
}
|
||||
|
||||
// InternalCountRows
|
||||
int32
|
||||
BGroupLayout::InternalCountRows()
|
||||
{
|
||||
return (fOrientation == B_VERTICAL ? fVisibleItems.CountItems() : 1);
|
||||
}
|
||||
|
||||
// GetColumnRowConstraints
|
||||
void
|
||||
BGroupLayout::GetColumnRowConstraints(enum orientation orientation, int32 index,
|
||||
ColumnRowConstraints* constraints)
|
||||
{
|
||||
if (index >= 0 && index < fVisibleItems.CountItems()) {
|
||||
BLayoutItem* item = (BLayoutItem*)fVisibleItems.ItemAt(index);
|
||||
constraints->min = -1;
|
||||
constraints->max = B_SIZE_UNLIMITED;
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
constraints->weight = data->weight;
|
||||
else
|
||||
constraints->weight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ItemDimensions
|
||||
void
|
||||
BGroupLayout::GetItemDimensions(BLayoutItem* item, Dimensions* dimensions)
|
||||
{
|
||||
int32 index = fVisibleItems.IndexOf(item);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (fOrientation == B_HORIZONTAL) {
|
||||
dimensions->x = index;
|
||||
dimensions->y = 0;
|
||||
dimensions->width = 1;
|
||||
dimensions->height = 1;
|
||||
} else {
|
||||
dimensions->x = 0;
|
||||
dimensions->y = index;
|
||||
dimensions->width = 1;
|
||||
dimensions->height = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// _LayoutDataForItem
|
||||
BGroupLayout::ItemLayoutData*
|
||||
BGroupLayout::_LayoutDataForItem(BLayoutItem* item) const
|
||||
{
|
||||
if (!item)
|
||||
return NULL;
|
||||
return (ItemLayoutData*)item->LayoutData();
|
||||
}
|
||||
/*
|
||||
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <GroupLayout.h>
|
||||
|
||||
#include <LayoutItem.h>
|
||||
|
||||
|
||||
// ItemLayoutData
|
||||
struct BGroupLayout::ItemLayoutData {
|
||||
float weight;
|
||||
|
||||
ItemLayoutData()
|
||||
: weight(1)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// constructor
|
||||
BGroupLayout::BGroupLayout(enum orientation orientation, float spacing)
|
||||
: BTwoDimensionalLayout(),
|
||||
fOrientation(orientation)
|
||||
{
|
||||
SetSpacing(spacing);
|
||||
}
|
||||
|
||||
// destructor
|
||||
BGroupLayout::~BGroupLayout()
|
||||
{
|
||||
}
|
||||
|
||||
// Spacing
|
||||
float
|
||||
BGroupLayout::Spacing() const
|
||||
{
|
||||
return fHSpacing;
|
||||
}
|
||||
|
||||
// SetSpacing
|
||||
void
|
||||
BGroupLayout::SetSpacing(float spacing)
|
||||
{
|
||||
if (spacing != fHSpacing) {
|
||||
fHSpacing = spacing;
|
||||
fVSpacing = spacing;
|
||||
InvalidateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// Orientation
|
||||
orientation
|
||||
BGroupLayout::Orientation() const
|
||||
{
|
||||
return fOrientation;
|
||||
}
|
||||
|
||||
// SetOrientation
|
||||
void
|
||||
BGroupLayout::SetOrientation(enum orientation orientation)
|
||||
{
|
||||
if (orientation != fOrientation) {
|
||||
fOrientation = orientation;
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// ItemWeight
|
||||
float
|
||||
BGroupLayout::ItemWeight(int32 index) const
|
||||
{
|
||||
if (index < 0 || index >= CountItems())
|
||||
return 0;
|
||||
|
||||
ItemLayoutData* data = _LayoutDataForItem(ItemAt(index));
|
||||
return (data ? data->weight : 0);
|
||||
}
|
||||
|
||||
// SetItemWeight
|
||||
void
|
||||
BGroupLayout::SetItemWeight(int32 index, float weight)
|
||||
{
|
||||
if (index < 0 || index >= CountItems())
|
||||
return;
|
||||
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(ItemAt(index)))
|
||||
data->weight = weight;
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(BView* child)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddView(child);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(int32 index, BView* child)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddView(index, child);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(BView* child, float weight)
|
||||
{
|
||||
return AddView(-1, child, weight);
|
||||
}
|
||||
|
||||
// AddView
|
||||
BLayoutItem*
|
||||
BGroupLayout::AddView(int32 index, BView* child, float weight)
|
||||
{
|
||||
BLayoutItem* item = AddView(index, child);
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
data->weight = weight;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(BLayoutItem* item)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddItem(item);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(int32 index, BLayoutItem* item)
|
||||
{
|
||||
return BTwoDimensionalLayout::AddItem(index, item);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(BLayoutItem* item, float weight)
|
||||
{
|
||||
return AddItem(-1, item, weight);
|
||||
}
|
||||
|
||||
// AddItem
|
||||
bool
|
||||
BGroupLayout::AddItem(int32 index, BLayoutItem* item, float weight)
|
||||
{
|
||||
bool success = AddItem(index, item);
|
||||
if (success) {
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
data->weight = weight;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// ItemAdded
|
||||
void
|
||||
BGroupLayout::ItemAdded(BLayoutItem* item)
|
||||
{
|
||||
item->SetLayoutData(new ItemLayoutData);
|
||||
}
|
||||
|
||||
// ItemRemoved
|
||||
void
|
||||
BGroupLayout::ItemRemoved(BLayoutItem* item)
|
||||
{
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item)) {
|
||||
item->SetLayoutData(NULL);
|
||||
delete data;
|
||||
}
|
||||
}
|
||||
|
||||
// PrepareItems
|
||||
void
|
||||
BGroupLayout::PrepareItems(enum orientation orientation)
|
||||
{
|
||||
// filter the visible items
|
||||
fVisibleItems.MakeEmpty();
|
||||
int32 itemCount = CountItems();
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
BLayoutItem* item = ItemAt(i);
|
||||
if (item->IsVisible())
|
||||
fVisibleItems.AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
// InternalCountColumns
|
||||
int32
|
||||
BGroupLayout::InternalCountColumns()
|
||||
{
|
||||
return (fOrientation == B_HORIZONTAL ? fVisibleItems.CountItems() : 1);
|
||||
}
|
||||
|
||||
// InternalCountRows
|
||||
int32
|
||||
BGroupLayout::InternalCountRows()
|
||||
{
|
||||
return (fOrientation == B_VERTICAL ? fVisibleItems.CountItems() : 1);
|
||||
}
|
||||
|
||||
// GetColumnRowConstraints
|
||||
void
|
||||
BGroupLayout::GetColumnRowConstraints(enum orientation orientation, int32 index,
|
||||
ColumnRowConstraints* constraints)
|
||||
{
|
||||
if (index >= 0 && index < fVisibleItems.CountItems()) {
|
||||
BLayoutItem* item = (BLayoutItem*)fVisibleItems.ItemAt(index);
|
||||
constraints->min = -1;
|
||||
constraints->max = B_SIZE_UNLIMITED;
|
||||
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||
constraints->weight = data->weight;
|
||||
else
|
||||
constraints->weight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ItemDimensions
|
||||
void
|
||||
BGroupLayout::GetItemDimensions(BLayoutItem* item, Dimensions* dimensions)
|
||||
{
|
||||
int32 index = fVisibleItems.IndexOf(item);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (fOrientation == B_HORIZONTAL) {
|
||||
dimensions->x = index;
|
||||
dimensions->y = 0;
|
||||
dimensions->width = 1;
|
||||
dimensions->height = 1;
|
||||
} else {
|
||||
dimensions->x = 0;
|
||||
dimensions->y = index;
|
||||
dimensions->width = 1;
|
||||
dimensions->height = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// _LayoutDataForItem
|
||||
BGroupLayout::ItemLayoutData*
|
||||
BGroupLayout::_LayoutDataForItem(BLayoutItem* item) const
|
||||
{
|
||||
if (!item)
|
||||
return NULL;
|
||||
return (ItemLayoutData*)item->LayoutData();
|
||||
}
|
||||
|
||||
+175
-175
@@ -1,175 +1,175 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SPLIT_LAYOUT_H
|
||||
#define _SPLIT_LAYOUT_H
|
||||
|
||||
|
||||
#include <Layout.h>
|
||||
#include <Point.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Layout {
|
||||
class Layouter;
|
||||
class LayoutInfo;
|
||||
}
|
||||
}
|
||||
|
||||
using BPrivate::Layout::Layouter;
|
||||
using BPrivate::Layout::LayoutInfo;
|
||||
|
||||
|
||||
class BSplitLayout : public BLayout {
|
||||
public:
|
||||
BSplitLayout(enum orientation orientation,
|
||||
float spacing = 0.0f);
|
||||
virtual ~BSplitLayout();
|
||||
|
||||
void SetInsets(float left, float top, float right,
|
||||
float bottom);
|
||||
void GetInsets(float* left, float* top, float* right,
|
||||
float* bottom);
|
||||
|
||||
float Spacing() const;
|
||||
void SetSpacing(float spacing);
|
||||
|
||||
orientation Orientation() const;
|
||||
void SetOrientation(enum orientation orientation);
|
||||
|
||||
float SplitterSize() const;
|
||||
void SetSplitterSize(float size);
|
||||
|
||||
virtual BLayoutItem* AddView(BView* child);
|
||||
virtual BLayoutItem* AddView(int32 index, BView* child);
|
||||
virtual BLayoutItem* AddView(BView* child, float weight);
|
||||
virtual BLayoutItem* AddView(int32 index, BView* child,
|
||||
float weight);
|
||||
|
||||
virtual bool AddItem(BLayoutItem* item);
|
||||
virtual bool AddItem(int32 index, BLayoutItem* item);
|
||||
virtual bool AddItem(BLayoutItem* item, float weight);
|
||||
virtual bool AddItem(int32 index, BLayoutItem* item,
|
||||
float weight);
|
||||
|
||||
|
||||
float ItemWeight(int32 index) const;
|
||||
float ItemWeight(BLayoutItem* item) const;
|
||||
void SetItemWeight(int32 index, float weight,
|
||||
bool invalidateLayout);
|
||||
void SetItemWeight(BLayoutItem* item, float weight);
|
||||
|
||||
void SetCollapsible(bool collapsible);
|
||||
void SetCollapsible(int32 index, bool collapsible);
|
||||
void SetCollapsible(int32 first, int32 last,
|
||||
bool collapsible);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BAlignment Alignment();
|
||||
|
||||
virtual bool HasHeightForWidth();
|
||||
virtual void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred);
|
||||
|
||||
virtual void InvalidateLayout();
|
||||
|
||||
virtual void LayoutView();
|
||||
|
||||
// interface for BSplitView
|
||||
BRect SplitterItemFrame(int32 index) const;
|
||||
|
||||
bool StartDraggingSplitter(BPoint point);
|
||||
bool DragSplitter(BPoint point);
|
||||
bool StopDraggingSplitter();
|
||||
int32 DraggedSplitter() const;
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
private:
|
||||
class ItemLayoutInfo;
|
||||
class ValueRange;
|
||||
class SplitterItem;
|
||||
|
||||
void _InvalidateLayout(bool invalidateView);
|
||||
void _InvalidateCachedHeightForWidth();
|
||||
|
||||
SplitterItem* _SplitterItemAt(int32 index) const;
|
||||
|
||||
void _GetSplitterValueRange(int32 index,
|
||||
ValueRange& range);
|
||||
int32 _SplitterValue(int32 index) const;
|
||||
|
||||
void _LayoutItem(BLayoutItem* item, BRect frame,
|
||||
bool visible);
|
||||
void _LayoutItem(BLayoutItem* item,
|
||||
ItemLayoutInfo* info);
|
||||
|
||||
bool _SetSplitterValue(int32 index, int32 value);
|
||||
|
||||
ItemLayoutInfo* _ItemLayoutInfo(BLayoutItem* item) const;
|
||||
|
||||
|
||||
void _UpdateSplitterWeights();
|
||||
|
||||
void _ValidateMinMax();
|
||||
|
||||
void _InternalGetHeightForWidth(float width,
|
||||
bool realLayout, float* minHeight,
|
||||
float* maxHeight, float* preferredHeight);
|
||||
|
||||
float _SplitterSpace() const;
|
||||
|
||||
BSize _AddInsets(BSize size);
|
||||
void _AddInsets(float* minHeight, float* maxHeight,
|
||||
float* preferredHeight);
|
||||
BSize _SubtractInsets(BSize size);
|
||||
|
||||
private:
|
||||
orientation fOrientation;
|
||||
float fLeftInset;
|
||||
float fRightInset;
|
||||
float fTopInset;
|
||||
float fBottomInset;
|
||||
float fSplitterSize;
|
||||
float fSpacing;
|
||||
|
||||
BList fSplitterItems;
|
||||
BList fVisibleItems;
|
||||
|
||||
BSize fMin;
|
||||
BSize fMax;
|
||||
BSize fPreferred;
|
||||
|
||||
Layouter* fHorizontalLayouter;
|
||||
Layouter* fVerticalLayouter;
|
||||
|
||||
LayoutInfo* fHorizontalLayoutInfo;
|
||||
LayoutInfo* fVerticalLayoutInfo;
|
||||
|
||||
BList fHeightForWidthItems;
|
||||
// Incorporates the children's height for width constraints for a
|
||||
// concrete width. Cloned lazily from fVerticalLayout when needed.
|
||||
Layouter* fHeightForWidthVerticalLayouter;
|
||||
LayoutInfo* fHeightForWidthHorizontalLayoutInfo;
|
||||
// for computing height for width info
|
||||
|
||||
bool fLayoutValid;
|
||||
|
||||
float fCachedHeightForWidthWidth;
|
||||
float fHeightForWidthVerticalLayouterWidth;
|
||||
float fCachedMinHeightForWidth;
|
||||
float fCachedMaxHeightForWidth;
|
||||
float fCachedPreferredHeightForWidth;
|
||||
|
||||
BPoint fDraggingStartPoint;
|
||||
int32 fDraggingStartValue;
|
||||
int32 fDraggingCurrentValue;
|
||||
int32 fDraggingSplitterIndex;
|
||||
};
|
||||
|
||||
#endif // _SPLIT_LAYOUT_H
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SPLIT_LAYOUT_H
|
||||
#define _SPLIT_LAYOUT_H
|
||||
|
||||
|
||||
#include <Layout.h>
|
||||
#include <Point.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Layout {
|
||||
class Layouter;
|
||||
class LayoutInfo;
|
||||
}
|
||||
}
|
||||
|
||||
using BPrivate::Layout::Layouter;
|
||||
using BPrivate::Layout::LayoutInfo;
|
||||
|
||||
|
||||
class BSplitLayout : public BLayout {
|
||||
public:
|
||||
BSplitLayout(enum orientation orientation,
|
||||
float spacing = 0.0f);
|
||||
virtual ~BSplitLayout();
|
||||
|
||||
void SetInsets(float left, float top, float right,
|
||||
float bottom);
|
||||
void GetInsets(float* left, float* top, float* right,
|
||||
float* bottom);
|
||||
|
||||
float Spacing() const;
|
||||
void SetSpacing(float spacing);
|
||||
|
||||
orientation Orientation() const;
|
||||
void SetOrientation(enum orientation orientation);
|
||||
|
||||
float SplitterSize() const;
|
||||
void SetSplitterSize(float size);
|
||||
|
||||
virtual BLayoutItem* AddView(BView* child);
|
||||
virtual BLayoutItem* AddView(int32 index, BView* child);
|
||||
virtual BLayoutItem* AddView(BView* child, float weight);
|
||||
virtual BLayoutItem* AddView(int32 index, BView* child,
|
||||
float weight);
|
||||
|
||||
virtual bool AddItem(BLayoutItem* item);
|
||||
virtual bool AddItem(int32 index, BLayoutItem* item);
|
||||
virtual bool AddItem(BLayoutItem* item, float weight);
|
||||
virtual bool AddItem(int32 index, BLayoutItem* item,
|
||||
float weight);
|
||||
|
||||
|
||||
float ItemWeight(int32 index) const;
|
||||
float ItemWeight(BLayoutItem* item) const;
|
||||
void SetItemWeight(int32 index, float weight,
|
||||
bool invalidateLayout);
|
||||
void SetItemWeight(BLayoutItem* item, float weight);
|
||||
|
||||
void SetCollapsible(bool collapsible);
|
||||
void SetCollapsible(int32 index, bool collapsible);
|
||||
void SetCollapsible(int32 first, int32 last,
|
||||
bool collapsible);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BAlignment Alignment();
|
||||
|
||||
virtual bool HasHeightForWidth();
|
||||
virtual void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred);
|
||||
|
||||
virtual void InvalidateLayout();
|
||||
|
||||
virtual void LayoutView();
|
||||
|
||||
// interface for BSplitView
|
||||
BRect SplitterItemFrame(int32 index) const;
|
||||
|
||||
bool StartDraggingSplitter(BPoint point);
|
||||
bool DragSplitter(BPoint point);
|
||||
bool StopDraggingSplitter();
|
||||
int32 DraggedSplitter() const;
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
private:
|
||||
class ItemLayoutInfo;
|
||||
class ValueRange;
|
||||
class SplitterItem;
|
||||
|
||||
void _InvalidateLayout(bool invalidateView);
|
||||
void _InvalidateCachedHeightForWidth();
|
||||
|
||||
SplitterItem* _SplitterItemAt(int32 index) const;
|
||||
|
||||
void _GetSplitterValueRange(int32 index,
|
||||
ValueRange& range);
|
||||
int32 _SplitterValue(int32 index) const;
|
||||
|
||||
void _LayoutItem(BLayoutItem* item, BRect frame,
|
||||
bool visible);
|
||||
void _LayoutItem(BLayoutItem* item,
|
||||
ItemLayoutInfo* info);
|
||||
|
||||
bool _SetSplitterValue(int32 index, int32 value);
|
||||
|
||||
ItemLayoutInfo* _ItemLayoutInfo(BLayoutItem* item) const;
|
||||
|
||||
|
||||
void _UpdateSplitterWeights();
|
||||
|
||||
void _ValidateMinMax();
|
||||
|
||||
void _InternalGetHeightForWidth(float width,
|
||||
bool realLayout, float* minHeight,
|
||||
float* maxHeight, float* preferredHeight);
|
||||
|
||||
float _SplitterSpace() const;
|
||||
|
||||
BSize _AddInsets(BSize size);
|
||||
void _AddInsets(float* minHeight, float* maxHeight,
|
||||
float* preferredHeight);
|
||||
BSize _SubtractInsets(BSize size);
|
||||
|
||||
private:
|
||||
orientation fOrientation;
|
||||
float fLeftInset;
|
||||
float fRightInset;
|
||||
float fTopInset;
|
||||
float fBottomInset;
|
||||
float fSplitterSize;
|
||||
float fSpacing;
|
||||
|
||||
BList fSplitterItems;
|
||||
BList fVisibleItems;
|
||||
|
||||
BSize fMin;
|
||||
BSize fMax;
|
||||
BSize fPreferred;
|
||||
|
||||
Layouter* fHorizontalLayouter;
|
||||
Layouter* fVerticalLayouter;
|
||||
|
||||
LayoutInfo* fHorizontalLayoutInfo;
|
||||
LayoutInfo* fVerticalLayoutInfo;
|
||||
|
||||
BList fHeightForWidthItems;
|
||||
// Incorporates the children's height for width constraints for a
|
||||
// concrete width. Cloned lazily from fVerticalLayout when needed.
|
||||
Layouter* fHeightForWidthVerticalLayouter;
|
||||
LayoutInfo* fHeightForWidthHorizontalLayoutInfo;
|
||||
// for computing height for width info
|
||||
|
||||
bool fLayoutValid;
|
||||
|
||||
float fCachedHeightForWidthWidth;
|
||||
float fHeightForWidthVerticalLayouterWidth;
|
||||
float fCachedMinHeightForWidth;
|
||||
float fCachedMaxHeightForWidth;
|
||||
float fCachedPreferredHeightForWidth;
|
||||
|
||||
BPoint fDraggingStartPoint;
|
||||
int32 fDraggingStartValue;
|
||||
int32 fDraggingCurrentValue;
|
||||
int32 fDraggingSplitterIndex;
|
||||
};
|
||||
|
||||
#endif // _SPLIT_LAYOUT_H
|
||||
|
||||
Reference in New Issue
Block a user