Merge from layout management branch.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18649 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ABSTRACT_LAYOUT_ITEM_H
|
||||
#define _ABSTRACT_LAYOUT_ITEM_H
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <LayoutItem.h>
|
||||
#include <Size.h>
|
||||
|
||||
|
||||
class BAbstractLayoutItem : public BLayoutItem {
|
||||
public:
|
||||
BAbstractLayoutItem();
|
||||
virtual ~BAbstractLayoutItem();
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BAlignment Alignment();
|
||||
|
||||
virtual void SetExplicitMinSize(BSize size);
|
||||
virtual void SetExplicitMaxSize(BSize size);
|
||||
virtual void SetExplicitPreferredSize(BSize size);
|
||||
virtual void SetExplicitAlignment(BAlignment alignment);
|
||||
|
||||
virtual BSize BaseMinSize();
|
||||
virtual BSize BaseMaxSize();
|
||||
virtual BSize BasePreferredSize();
|
||||
virtual BAlignment BaseAlignment();
|
||||
|
||||
private:
|
||||
BSize fMinSize;
|
||||
BSize fMaxSize;
|
||||
BSize fPreferredSize;
|
||||
BAlignment fAlignment;
|
||||
};
|
||||
|
||||
#endif // _ABSTRACT_LAYOUT_ITEM_H
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ALIGNMENT_H
|
||||
#define _ALIGNMENT_H
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
class BAlignment {
|
||||
public:
|
||||
alignment horizontal;
|
||||
vertical_alignment vertical;
|
||||
|
||||
inline BAlignment();
|
||||
inline BAlignment(const BAlignment& other);
|
||||
inline BAlignment(alignment horizontal,
|
||||
vertical_alignment vertical);
|
||||
|
||||
inline alignment Horizontal() const;
|
||||
inline vertical_alignment Vertical() const;
|
||||
|
||||
float RelativeHorizontal() const;
|
||||
float RelativeVertical() const;
|
||||
|
||||
inline void SetHorizontal(alignment horizontal);
|
||||
inline void SetVertical(vertical_alignment vertical);
|
||||
|
||||
inline bool IsHorizontalSet() const;
|
||||
inline bool IsVerticalSet() const;
|
||||
|
||||
inline bool operator==(const BAlignment& other) const;
|
||||
inline bool operator!=(const BAlignment& other) const;
|
||||
|
||||
inline BAlignment& operator=(const BAlignment& other);
|
||||
};
|
||||
|
||||
|
||||
// constructor
|
||||
inline
|
||||
BAlignment::BAlignment()
|
||||
: horizontal(B_ALIGN_HORIZONTAL_UNSET),
|
||||
vertical(B_ALIGN_VERTICAL_UNSET)
|
||||
{
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
inline
|
||||
BAlignment::BAlignment(const BAlignment& other)
|
||||
: horizontal(other.horizontal),
|
||||
vertical(other.vertical)
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
inline
|
||||
BAlignment::BAlignment(alignment horizontal, vertical_alignment vertical)
|
||||
: horizontal(horizontal),
|
||||
vertical(vertical)
|
||||
{
|
||||
}
|
||||
|
||||
// Horizontal
|
||||
inline alignment
|
||||
BAlignment::Horizontal() const
|
||||
{
|
||||
return horizontal;
|
||||
}
|
||||
|
||||
// Vertical
|
||||
inline vertical_alignment
|
||||
BAlignment::Vertical() const
|
||||
{
|
||||
return vertical;
|
||||
}
|
||||
|
||||
// SetHorizontal
|
||||
inline void
|
||||
BAlignment::SetHorizontal(alignment horizontal)
|
||||
{
|
||||
this->horizontal = horizontal;
|
||||
}
|
||||
|
||||
// SetVertical
|
||||
inline void
|
||||
BAlignment::SetVertical(vertical_alignment vertical)
|
||||
{
|
||||
this->vertical = vertical;
|
||||
}
|
||||
|
||||
// IsHorizontalSet
|
||||
inline bool
|
||||
BAlignment::IsHorizontalSet() const
|
||||
{
|
||||
return (horizontal != B_ALIGN_HORIZONTAL_UNSET);
|
||||
}
|
||||
|
||||
// IsVerticalSet
|
||||
inline bool
|
||||
BAlignment::IsVerticalSet() const
|
||||
{
|
||||
return (vertical != B_ALIGN_VERTICAL_UNSET);
|
||||
}
|
||||
|
||||
// ==
|
||||
inline bool
|
||||
BAlignment::operator==(const BAlignment& other) const
|
||||
{
|
||||
return (horizontal == other.horizontal && vertical == other.vertical);
|
||||
}
|
||||
|
||||
// !=
|
||||
inline bool
|
||||
BAlignment::operator!=(const BAlignment& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
// =
|
||||
inline BAlignment&
|
||||
BAlignment::operator=(const BAlignment& other)
|
||||
{
|
||||
horizontal = other.horizontal;
|
||||
vertical = other.vertical;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _ALIGNMENT_H
|
||||
@@ -52,6 +52,10 @@ public:
|
||||
BMessage *message,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BButton(const char* name, const char* label,
|
||||
BMessage *message,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BButton(const char* label, BMessage *message);
|
||||
|
||||
virtual ~BButton();
|
||||
|
||||
@@ -92,6 +96,9 @@ virtual BHandler *ResolveSpecifier(BMessage *message,
|
||||
virtual status_t GetSupportedSuites(BMessage *message);
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
|
||||
virtual BSize MaxSize();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedButton1();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _CARD_LAYOUT_H
|
||||
#define _CARD_LAYOUT_H
|
||||
|
||||
#include <Layout.h>
|
||||
|
||||
|
||||
class BCardLayout : public BLayout {
|
||||
public:
|
||||
BCardLayout();
|
||||
virtual ~BCardLayout();
|
||||
|
||||
BLayoutItem* VisibleItem() const;
|
||||
int32 VisibleIndex() const;
|
||||
void SetVisibleItem(int32 index);
|
||||
void SetVisibleItem(BLayoutItem* item);
|
||||
|
||||
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();
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
private:
|
||||
BSize fMin;
|
||||
BSize fMax;
|
||||
BSize fPreferred;
|
||||
BLayoutItem* fVisibleItem;
|
||||
bool fMinMaxValid;
|
||||
|
||||
void _ValidateMinMax();
|
||||
};
|
||||
|
||||
#endif // _CARD_LAYOUT_H
|
||||
@@ -33,6 +33,8 @@ class BColorControl : public BControl {
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
|
||||
virtual void SetValue(int32 color_value);
|
||||
void SetValue(rgb_color color);
|
||||
rgb_color ValueAsColor();
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* 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 = 0.0f,
|
||||
float vertical = 0.0f);
|
||||
virtual ~BGridLayout();
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
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 _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
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _GRID_LAYOUT_BUILDER_H
|
||||
#define _GRID_LAYOUT_BUILDER_H
|
||||
|
||||
#include <GridView.h>
|
||||
|
||||
class BGridLayoutBuilder {
|
||||
public:
|
||||
BGridLayoutBuilder(
|
||||
float horizontalSpacing = 0.0f,
|
||||
float verticalSpacing = 0.0f);
|
||||
BGridLayoutBuilder(BGridLayout* layout);
|
||||
BGridLayoutBuilder(BGridView* view);
|
||||
|
||||
BGridLayout* GridLayout() const;
|
||||
BView* View() const;
|
||||
BGridLayoutBuilder& GetGridLayout(BGridLayout** _layout);
|
||||
BGridLayoutBuilder& GetView(BView** _view);
|
||||
|
||||
BGridLayoutBuilder& Add(BView* view, int32 column, int32 row,
|
||||
int32 columnCount = 1, int32 rowCount = 1);
|
||||
BGridLayoutBuilder& Add(BLayoutItem* item, int32 column, int32 row,
|
||||
int32 columnCount = 1, int32 rowCount = 1);
|
||||
|
||||
BGridLayoutBuilder& SetColumnWeight(int32 column, float weight);
|
||||
BGridLayoutBuilder& SetRowWeight(int32 row, float weight);
|
||||
|
||||
operator BGridLayout*();
|
||||
operator BView*();
|
||||
|
||||
private:
|
||||
BGridLayout* fLayout;
|
||||
};
|
||||
|
||||
#endif // _GRID_LAYOUT_BUILDER_H
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _GRID_VIEW_H
|
||||
#define _GRID_VIEW_H
|
||||
|
||||
#include <GridLayout.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class BGridView : public BView {
|
||||
public:
|
||||
BGridView(float horizontalSpacing = 0.0f,
|
||||
float verticalSpacing = 0.0f);
|
||||
virtual ~BGridView();
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
|
||||
BGridLayout* GridLayout() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // _GRID_VIEW_H
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _GROUP_LAYOUT_H
|
||||
#define _GROUP_LAYOUT_H
|
||||
|
||||
#include <TwoDimensionalLayout.h>
|
||||
|
||||
class BGroupLayout : public BTwoDimensionalLayout {
|
||||
public:
|
||||
BGroupLayout(enum orientation orientation,
|
||||
float spacing = 0.0f);
|
||||
virtual ~BGroupLayout();
|
||||
|
||||
float Spacing() const;
|
||||
void SetSpacing(float spacing);
|
||||
|
||||
orientation Orientation() const;
|
||||
void SetOrientation(enum orientation orientation);
|
||||
|
||||
float ItemWeight(int32 index) const;
|
||||
void SetItemWeight(int32 index, float weight);
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
virtual void PrepareItems(enum orientation orientation);
|
||||
|
||||
virtual int32 InternalCountColumns();
|
||||
virtual int32 InternalCountRows();
|
||||
virtual void GetColumnRowConstraints(
|
||||
enum orientation orientation,
|
||||
int32 index,
|
||||
ColumnRowConstraints* constraints);
|
||||
virtual void GetItemDimensions(BLayoutItem* item,
|
||||
Dimensions* dimensions);
|
||||
|
||||
private:
|
||||
struct ItemLayoutData;
|
||||
|
||||
ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const;
|
||||
|
||||
orientation fOrientation;
|
||||
BList fVisibleItems;
|
||||
};
|
||||
|
||||
#endif // _GROUP_LAYOUT_H
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _GROUP_LAYOUT_BUILDER_H
|
||||
#define _GROUP_LAYOUT_BUILDER_H
|
||||
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupView.h>
|
||||
#include <List.h>
|
||||
|
||||
class BGroupLayoutBuilder {
|
||||
public:
|
||||
BGroupLayoutBuilder(
|
||||
enum orientation orientation = B_HORIZONTAL,
|
||||
float spacing = 0.0f);
|
||||
BGroupLayoutBuilder(BGroupLayout* layout);
|
||||
BGroupLayoutBuilder(BGroupView* view);
|
||||
|
||||
BGroupLayout* RootLayout() const;
|
||||
BGroupLayout* TopLayout() const;
|
||||
BGroupLayoutBuilder& GetTopLayout(BGroupLayout** _layout);
|
||||
BGroupLayoutBuilder& GetTopView(BView** _view);
|
||||
|
||||
BGroupLayoutBuilder& Add(BView* view);
|
||||
BGroupLayoutBuilder& Add(BView* view, float weight);
|
||||
BGroupLayoutBuilder& Add(BLayoutItem* item);
|
||||
BGroupLayoutBuilder& Add(BLayoutItem* item, float weight);
|
||||
|
||||
BGroupLayoutBuilder& AddGroup(enum orientation orientation,
|
||||
float spacing = 0.0f, float weight = 1.0f);
|
||||
BGroupLayoutBuilder& End();
|
||||
|
||||
BGroupLayoutBuilder& AddGlue(float weight = 1.0f);
|
||||
BGroupLayoutBuilder& AddStrut(float size);
|
||||
|
||||
operator BGroupLayout*();
|
||||
operator BView*();
|
||||
|
||||
private:
|
||||
bool _PushLayout(BGroupLayout* layout);
|
||||
void _PopLayout();
|
||||
|
||||
private:
|
||||
BGroupLayout* fRootLayout;
|
||||
BList fLayoutStack;
|
||||
};
|
||||
|
||||
#endif // _GROUP_LAYOUT_BUILDER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _GROUP_VIEW_H
|
||||
#define _GROUP_VIEW_H
|
||||
|
||||
#include <GroupLayout.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class BGroupView : public BView {
|
||||
public:
|
||||
BGroupView(
|
||||
enum orientation orientation = B_HORIZONTAL,
|
||||
float spacing = 0.0f);
|
||||
virtual ~BGroupView();
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
|
||||
BGroupLayout* GroupLayout() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // _GROUP_VIEW_H
|
||||
@@ -179,14 +179,24 @@ struct scroll_bar_info {
|
||||
enum alignment {
|
||||
B_ALIGN_LEFT,
|
||||
B_ALIGN_RIGHT,
|
||||
B_ALIGN_CENTER
|
||||
B_ALIGN_CENTER,
|
||||
|
||||
B_ALIGN_HORIZONTAL_CENTER = B_ALIGN_CENTER,
|
||||
|
||||
B_ALIGN_HORIZONTAL_UNSET = -1L,
|
||||
B_ALIGN_USE_FULL_WIDTH = -2L,
|
||||
};
|
||||
|
||||
enum vertical_alignment {
|
||||
B_ALIGN_TOP = 0x10L,
|
||||
B_ALIGN_MIDDLE = 0x20,
|
||||
B_ALIGN_BOTTOM = 0x30,
|
||||
B_ALIGN_NO_VERTICAL = -1L
|
||||
|
||||
B_ALIGN_VERTICAL_CENTER = B_ALIGN_MIDDLE,
|
||||
|
||||
B_ALIGN_VERTICAL_UNSET = -1L,
|
||||
B_ALIGN_NO_VERTICAL = B_ALIGN_VERTICAL_UNSET,
|
||||
B_ALIGN_USE_FULL_HEIGHT = -2L,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LAYOUT_H
|
||||
#define _LAYOUT_H
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <List.h>
|
||||
#include <Size.h>
|
||||
|
||||
class BLayoutItem;
|
||||
class BView;
|
||||
|
||||
|
||||
class BLayout {
|
||||
public:
|
||||
BLayout();
|
||||
virtual ~BLayout();
|
||||
|
||||
BView* View() const;
|
||||
|
||||
virtual BLayoutItem* AddView(BView* child);
|
||||
virtual BLayoutItem* AddView(int32 index, BView* child);
|
||||
|
||||
virtual bool AddItem(BLayoutItem* item);
|
||||
virtual bool AddItem(int32 index, BLayoutItem* item);
|
||||
|
||||
virtual bool RemoveView(BView* child);
|
||||
virtual bool RemoveItem(BLayoutItem* item);
|
||||
virtual BLayoutItem* RemoveItem(int32 index);
|
||||
|
||||
BLayoutItem* ItemAt(int32 index) const;
|
||||
int32 CountItems() const;
|
||||
int32 IndexOfItem(BLayoutItem* item) const;
|
||||
int32 IndexOfView(BView* child) const;
|
||||
|
||||
virtual BSize MinSize() = 0;
|
||||
virtual BSize MaxSize() = 0;
|
||||
virtual BSize PreferredSize() = 0;
|
||||
virtual BAlignment Alignment() = 0;
|
||||
|
||||
virtual bool HasHeightForWidth() = 0;
|
||||
virtual void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred) = 0;
|
||||
|
||||
virtual void InvalidateLayout();
|
||||
|
||||
virtual void LayoutView() = 0;
|
||||
|
||||
protected:
|
||||
// TODO: Since memory allocations can fail, we should return a bool and
|
||||
// undo the addition, if false.
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
|
||||
|
||||
private:
|
||||
friend class BView;
|
||||
|
||||
void SetView(BView* view);
|
||||
|
||||
BView* fView;
|
||||
BList fItems;
|
||||
};
|
||||
|
||||
#endif // _LAYOUT_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LAYOUT_CONTEXT_H
|
||||
#define _LAYOUT_CONTEXT_H
|
||||
|
||||
#include <List.h>
|
||||
|
||||
class BLayoutContext;
|
||||
|
||||
|
||||
class BLayoutContextListener {
|
||||
public:
|
||||
BLayoutContextListener();
|
||||
virtual ~BLayoutContextListener();
|
||||
|
||||
virtual void LayoutContextLeft(BLayoutContext* context) = 0;
|
||||
};
|
||||
|
||||
|
||||
class BLayoutContext {
|
||||
public:
|
||||
BLayoutContext();
|
||||
~BLayoutContext();
|
||||
|
||||
void AddListener(BLayoutContextListener* listener);
|
||||
void RemoveListener(
|
||||
BLayoutContextListener* listener);
|
||||
|
||||
private:
|
||||
BList fListeners;
|
||||
};
|
||||
|
||||
#endif // _LAYOUT_CONTEXT_H
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LAYOUT_ITEM_H
|
||||
#define _LAYOUT_ITEM_H
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <Rect.h>
|
||||
#include <Size.h>
|
||||
|
||||
class BLayout;
|
||||
class BView;
|
||||
|
||||
class BLayoutItem {
|
||||
public:
|
||||
BLayoutItem();
|
||||
virtual ~BLayoutItem();
|
||||
|
||||
BLayout* Layout() const;
|
||||
|
||||
virtual BSize MinSize() = 0;
|
||||
virtual BSize MaxSize() = 0;
|
||||
virtual BSize PreferredSize() = 0;
|
||||
virtual BAlignment Alignment() = 0;
|
||||
|
||||
virtual void SetExplicitMinSize(BSize size) = 0;
|
||||
virtual void SetExplicitMaxSize(BSize size) = 0;
|
||||
virtual void SetExplicitPreferredSize(BSize size) = 0;
|
||||
virtual void SetExplicitAlignment(BAlignment alignment) = 0;
|
||||
|
||||
virtual bool IsVisible() = 0;
|
||||
virtual void SetVisible(bool visible) = 0;
|
||||
|
||||
virtual BRect Frame() = 0;
|
||||
virtual void SetFrame(BRect frame) = 0;
|
||||
|
||||
virtual bool HasHeightForWidth();
|
||||
virtual void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred);
|
||||
|
||||
virtual BView* View();
|
||||
|
||||
virtual void InvalidateLayout();
|
||||
|
||||
void* LayoutData() const;
|
||||
void SetLayoutData(void* data);
|
||||
|
||||
void AlignInFrame(BRect frame);
|
||||
|
||||
private:
|
||||
friend class BLayout;
|
||||
|
||||
void SetLayout(BLayout* layout);
|
||||
|
||||
BLayout* fLayout;
|
||||
void* fLayoutData;
|
||||
};
|
||||
|
||||
#endif // _LAYOUT_ITEM_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LAYOUT_UTILS_H
|
||||
#define _LAYOUT_UTILS_H
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <Rect.h>
|
||||
#include <Size.h>
|
||||
|
||||
class BView;
|
||||
|
||||
class BLayoutUtils {
|
||||
public:
|
||||
// static float AddSizesFloat(float a, float b);
|
||||
// static float AddSizesFloat(float a, float b, float c);
|
||||
static float AddDistances(float a, float b);
|
||||
static float AddDistances(float a, float b, float c);
|
||||
static int32 AddSizesInt32(int32 a, int32 b);
|
||||
static int32 AddSizesInt32(int32 a, int32 b, int32 c);
|
||||
// static float SubtractSizesFloat(float a, float b);
|
||||
static int32 SubtractSizesInt32(int32 a, int32 b);
|
||||
static float SubtractDistances(float a, float b);
|
||||
|
||||
static BSize ComposeSize(BSize size, BSize layoutSize);
|
||||
static BAlignment ComposeAlignment(BAlignment alignment,
|
||||
BAlignment layoutAlignment);
|
||||
|
||||
static BRect AlignInFrame(BRect frame, BSize maxSize,
|
||||
BAlignment alignment);
|
||||
static void AlignInFrame(BView* view, BRect frame);
|
||||
};
|
||||
|
||||
#endif // _LAYOUT_UTILS_H
|
||||
@@ -126,6 +126,9 @@ class BListView : public BView, public BInvoker
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
protected:
|
||||
enum MiscCode { B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP };
|
||||
union MiscData {
|
||||
|
||||
@@ -36,82 +36,86 @@ class BMenuField;
|
||||
class BMenuBar : public BMenu
|
||||
{
|
||||
public:
|
||||
BMenuBar( BRect frame,
|
||||
const char *title,
|
||||
uint32 resizeMask =
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||
menu_layout layout = B_ITEMS_IN_ROW,
|
||||
bool resizeToFit = true);
|
||||
BMenuBar(BMessage *data);
|
||||
virtual ~BMenuBar();
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
BMenuBar( BRect frame,
|
||||
const char *title,
|
||||
uint32 resizeMask =
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||
menu_layout layout = B_ITEMS_IN_ROW,
|
||||
bool resizeToFit = true);
|
||||
BMenuBar(BMessage *data);
|
||||
virtual ~BMenuBar();
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
|
||||
virtual void SetBorder(menu_bar_border border);
|
||||
menu_bar_border Border() const;
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
virtual void SetBorder(menu_bar_border border);
|
||||
menu_bar_border Border() const;
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
|
||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
|
||||
|
||||
// layout related
|
||||
virtual BSize MaxSize();
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
|
||||
private:
|
||||
friend class BWindow;
|
||||
friend class BMenuItem;
|
||||
friend class BMenuField;
|
||||
friend class BMenu;
|
||||
friend class BWindow;
|
||||
friend class BMenuItem;
|
||||
friend class BMenuField;
|
||||
friend class BMenu;
|
||||
|
||||
virtual void _ReservedMenuBar1();
|
||||
virtual void _ReservedMenuBar2();
|
||||
virtual void _ReservedMenuBar3();
|
||||
virtual void _ReservedMenuBar4();
|
||||
virtual void _ReservedMenuBar1();
|
||||
virtual void _ReservedMenuBar2();
|
||||
virtual void _ReservedMenuBar3();
|
||||
virtual void _ReservedMenuBar4();
|
||||
|
||||
BMenuBar &operator=(const BMenuBar &);
|
||||
BMenuBar &operator=(const BMenuBar &);
|
||||
|
||||
void StartMenuBar( int32 menuIndex,
|
||||
bool sticky = true,
|
||||
bool show_menu = false,
|
||||
BRect *special_rect = NULL);
|
||||
static long TrackTask(void *arg);
|
||||
BMenuItem *Track( int32 *action,
|
||||
int32 startIndex = -1,
|
||||
bool showMenu = false);
|
||||
void StealFocus();
|
||||
void RestoreFocus();
|
||||
void InitData(menu_layout layout);
|
||||
void StartMenuBar( int32 menuIndex,
|
||||
bool sticky = true,
|
||||
bool show_menu = false,
|
||||
BRect *special_rect = NULL);
|
||||
static long TrackTask(void *arg);
|
||||
BMenuItem *Track( int32 *action,
|
||||
int32 startIndex = -1,
|
||||
bool showMenu = false);
|
||||
void StealFocus();
|
||||
void RestoreFocus();
|
||||
void InitData(menu_layout layout);
|
||||
|
||||
menu_bar_border fBorder;
|
||||
thread_id fTrackingPID;
|
||||
int32 fPrevFocusToken;
|
||||
sem_id fMenuSem;
|
||||
BRect* fLastBounds;
|
||||
uint32 _reserved[2]; // was 3
|
||||
menu_bar_border fBorder;
|
||||
thread_id fTrackingPID;
|
||||
int32 fPrevFocusToken;
|
||||
sem_id fMenuSem;
|
||||
BRect* fLastBounds;
|
||||
uint32 _reserved[2]; // was 3
|
||||
|
||||
bool fTracking;
|
||||
bool fTracking;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: MenuField.h
|
||||
/
|
||||
/ Description: BMenuField displays a labeled pop-up menu.
|
||||
/
|
||||
/ Copyright 1994-98, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef _MENU_FIELD_H
|
||||
#define _MENU_FIELD_H
|
||||
@@ -18,108 +12,118 @@
|
||||
|
||||
class BMenuBar;
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----- BMenuField class -----------------------------------------*/
|
||||
class BMenuField : public BView {
|
||||
public:
|
||||
BMenuField(BRect frame, const char* name,
|
||||
const char* label, BMenu* menu,
|
||||
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BMenuField(BRect frame, const char* name,
|
||||
const char* label, BMenu* menu,
|
||||
bool fixed_size,
|
||||
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BMenuField(const char* name,
|
||||
const char* label, BMenu* menu,
|
||||
BMessage* message,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BMenuField(const char* label,
|
||||
BMenu* menu, BMessage* message);
|
||||
BMenuField(BMessage* data);
|
||||
virtual ~BMenuField();
|
||||
|
||||
class BMenuField : public BView
|
||||
{
|
||||
public:
|
||||
BMenuField( BRect frame,
|
||||
const char *name,
|
||||
const char *label,
|
||||
BMenu *menu,
|
||||
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BMenuField( BRect frame,
|
||||
const char *name,
|
||||
const char *label,
|
||||
BMenu *menu,
|
||||
bool fixed_size,
|
||||
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BMenuField(BMessage *data);
|
||||
virtual ~BMenuField();
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void MakeFocus(bool state);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllDetached();
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
virtual void Draw(BRect update);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void MakeFocus(bool state);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code,
|
||||
const BMessage* dragMessage);
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllDetached();
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
|
||||
BMenu *Menu() const;
|
||||
BMenuBar *MenuBar() const;
|
||||
BMenuItem *MenuItem() const;
|
||||
BMenu* Menu() const;
|
||||
BMenuBar* MenuBar() const;
|
||||
BMenuItem* MenuItem() const;
|
||||
|
||||
virtual void SetLabel(const char *label);
|
||||
const char *Label() const;
|
||||
virtual void SetLabel(const char* label);
|
||||
const char* Label() const;
|
||||
|
||||
virtual void SetEnabled(bool on);
|
||||
bool IsEnabled() const;
|
||||
virtual void SetEnabled(bool on);
|
||||
bool IsEnabled() const;
|
||||
|
||||
virtual void SetAlignment(alignment label);
|
||||
alignment Alignment() const;
|
||||
virtual void SetDivider(float dividing_line);
|
||||
float Divider() const;
|
||||
virtual void SetAlignment(alignment label);
|
||||
alignment Alignment() const;
|
||||
virtual void SetDivider(float dividing_line);
|
||||
float Divider() const;
|
||||
|
||||
void ShowPopUpMarker();
|
||||
void HidePopUpMarker();
|
||||
void ShowPopUpMarker();
|
||||
void HidePopUpMarker();
|
||||
|
||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message,
|
||||
int32 index, BMessage* specifier,
|
||||
int32 form, const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* width, float* height);
|
||||
|
||||
BLayoutItem* CreateLabelLayoutItem();
|
||||
BLayoutItem* CreateMenuBarLayoutItem();
|
||||
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
private:
|
||||
class LabelLayoutItem;
|
||||
class MenuBarLayoutItem;
|
||||
|
||||
friend class _BMCMenuBar_;
|
||||
friend class LabelLayoutItem;
|
||||
friend class MenuBarLayoutItem;
|
||||
|
||||
virtual void _ReservedMenuField1();
|
||||
virtual void _ReservedMenuField2();
|
||||
virtual void _ReservedMenuField3();
|
||||
|
||||
BMenuField &operator=(const BMenuField&);
|
||||
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
void InitObject(const char* label);
|
||||
void InitObject2();
|
||||
void DrawLabel(BRect bounds, BRect update);
|
||||
static void InitMenu(BMenu* menu);
|
||||
static long MenuTask(void* arg);
|
||||
void _UpdateFrame();
|
||||
void _InitMenuBar(BMenu* menu,
|
||||
BRect frame, bool fixedSize);
|
||||
|
||||
private:
|
||||
friend class _BMCMenuBar_;
|
||||
char* fLabel;
|
||||
BMenu* fMenu;
|
||||
BMenuBar* fMenuBar;
|
||||
alignment fAlign;
|
||||
float fDivider;
|
||||
float fStringWidth;
|
||||
bool fEnabled;
|
||||
bool fSelected;
|
||||
bool fTransition;
|
||||
bool fFixedSizeMB;
|
||||
thread_id fMenuTaskID;
|
||||
|
||||
virtual void _ReservedMenuField1();
|
||||
virtual void _ReservedMenuField2();
|
||||
virtual void _ReservedMenuField3();
|
||||
BLayoutItem* fLabelLayoutItem;
|
||||
BLayoutItem* fMenuBarLayoutItem;
|
||||
|
||||
BMenuField &operator=(const BMenuField &);
|
||||
|
||||
|
||||
void InitObject(const char *label);
|
||||
void InitObject2();
|
||||
void DrawLabel(BRect bounds, BRect update);
|
||||
static void InitMenu(BMenu *menu);
|
||||
static long MenuTask(void *arg);
|
||||
|
||||
char *fLabel;
|
||||
BMenu *fMenu;
|
||||
BMenuBar *fMenuBar;
|
||||
alignment fAlign;
|
||||
float fDivider;
|
||||
float fStringWidth;
|
||||
bool fEnabled;
|
||||
bool fSelected;
|
||||
bool fTransition;
|
||||
bool fFixedSizeMB;
|
||||
thread_id fMenuTaskID;
|
||||
uint32 _reserved[3];
|
||||
uint32 _reserved[1];
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
#endif /* _MENU_FIELD_H */
|
||||
#endif // _MENU_FIELD_H
|
||||
|
||||
@@ -54,6 +54,12 @@ public:
|
||||
BMessage *message,
|
||||
uint32 resizMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BRadioButton(const char *name,
|
||||
const char *label,
|
||||
BMessage *message,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BRadioButton(const char *label,
|
||||
BMessage *message);
|
||||
|
||||
BRadioButton(BMessage *archive);
|
||||
virtual ~BRadioButton();
|
||||
@@ -91,6 +97,9 @@ virtual status_t GetSupportedSuites(BMessage *message);
|
||||
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
|
||||
virtual BSize MaxSize();
|
||||
|
||||
|
||||
private:
|
||||
friend status_t _init_interface_kit_();
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ class BScrollView : public BView {
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
// private or reserved methods are following
|
||||
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SIZE_H
|
||||
#define _SIZE_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <Rect.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
enum {
|
||||
B_SIZE_UNSET = -1,
|
||||
B_SIZE_UNLIMITED = 1024 * 1024 * 1024,
|
||||
};
|
||||
|
||||
class BSize {
|
||||
public:
|
||||
float width;
|
||||
float height;
|
||||
|
||||
inline BSize();
|
||||
inline BSize(const BSize& other);
|
||||
inline BSize(float width, float height);
|
||||
inline BSize(const BRect& rect);
|
||||
|
||||
inline float Width() const;
|
||||
inline float Height() const;
|
||||
|
||||
inline void SetWidth(float width);
|
||||
inline void SetHeight(float height);
|
||||
|
||||
inline int32 IntegerWidth() const;
|
||||
inline int32 IntegerHeight() const;
|
||||
|
||||
inline bool IsWidthSet() const;
|
||||
inline bool IsHeightSet() const;
|
||||
|
||||
inline bool operator==(const BSize& other) const;
|
||||
inline bool operator!=(const BSize& other) const;
|
||||
|
||||
inline BSize& operator=(const BSize& other);
|
||||
};
|
||||
|
||||
|
||||
// constructor
|
||||
inline
|
||||
BSize::BSize()
|
||||
: width(B_SIZE_UNSET),
|
||||
height(B_SIZE_UNSET)
|
||||
{
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
inline
|
||||
BSize::BSize(const BSize& other)
|
||||
: width(other.width),
|
||||
height(other.height)
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
inline
|
||||
BSize::BSize(float width, float height)
|
||||
: width(width),
|
||||
height(height)
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
inline
|
||||
BSize::BSize(const BRect& rect)
|
||||
: width(rect.Width()),
|
||||
height(rect.Height())
|
||||
{
|
||||
}
|
||||
|
||||
// Width
|
||||
inline float
|
||||
BSize::Width() const
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
// Height
|
||||
inline float
|
||||
BSize::Height() const
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
// SetWidth
|
||||
inline void
|
||||
BSize::SetWidth(float width)
|
||||
{
|
||||
this->width = width;
|
||||
}
|
||||
|
||||
// SetHeight
|
||||
inline void
|
||||
BSize::SetHeight(float height)
|
||||
{
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
// IntegerWidth
|
||||
inline int32
|
||||
BSize::IntegerWidth() const
|
||||
{
|
||||
return (int32)width;
|
||||
}
|
||||
|
||||
// IntegerHeight
|
||||
inline int32
|
||||
BSize::IntegerHeight() const
|
||||
{
|
||||
return (int32)height;
|
||||
}
|
||||
|
||||
// IsWidthSet
|
||||
inline bool
|
||||
BSize::IsWidthSet() const
|
||||
{
|
||||
return width != B_SIZE_UNSET;
|
||||
}
|
||||
|
||||
// IsHeightSet
|
||||
inline bool
|
||||
BSize::IsHeightSet() const
|
||||
{
|
||||
return height != B_SIZE_UNSET;
|
||||
}
|
||||
|
||||
// ==
|
||||
inline bool
|
||||
BSize::operator==(const BSize& other) const
|
||||
{
|
||||
return (width == other.width && height == other.height);
|
||||
}
|
||||
|
||||
// !=
|
||||
inline bool
|
||||
BSize::operator!=(const BSize& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
// =
|
||||
inline BSize&
|
||||
BSize::operator=(const BSize& other)
|
||||
{
|
||||
width = other.width;
|
||||
height = other.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _SIZE_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SPACE_LAYOUT_ITEM_H
|
||||
#define _SPACE_LAYOUT_ITEM_H
|
||||
|
||||
#include <LayoutItem.h>
|
||||
|
||||
|
||||
class BSpaceLayoutItem : public BLayoutItem {
|
||||
public:
|
||||
BSpaceLayoutItem(BSize minSize, BSize maxSize,
|
||||
BSize preferredSize, BAlignment alignment);
|
||||
virtual ~BSpaceLayoutItem();
|
||||
|
||||
static BSpaceLayoutItem* CreateGlue();
|
||||
static BSpaceLayoutItem* CreateHorizontalStrut(float width);
|
||||
static BSpaceLayoutItem* CreateVerticalStrut(float height);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BAlignment Alignment();
|
||||
|
||||
virtual void SetExplicitMinSize(BSize size);
|
||||
virtual void SetExplicitMaxSize(BSize size);
|
||||
virtual void SetExplicitPreferredSize(BSize size);
|
||||
virtual void SetExplicitAlignment(BAlignment alignment);
|
||||
|
||||
virtual bool IsVisible();
|
||||
virtual void SetVisible(bool visible);
|
||||
|
||||
virtual BRect Frame();
|
||||
virtual void SetFrame(BRect frame);
|
||||
|
||||
private:
|
||||
BRect fFrame;
|
||||
BSize fMinSize;
|
||||
BSize fMaxSize;
|
||||
BSize fPreferredSize;
|
||||
BAlignment fAlignment;
|
||||
bool fVisible;
|
||||
};
|
||||
|
||||
#endif // _SPACE_LAYOUT_ITEM_H
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SPLIT_LAYOUT_BUILDER_H
|
||||
#define _SPLIT_LAYOUT_BUILDER_H
|
||||
|
||||
#include <SplitView.h>
|
||||
|
||||
class BSplitLayoutBuilder {
|
||||
public:
|
||||
BSplitLayoutBuilder(
|
||||
enum orientation orientation = B_HORIZONTAL,
|
||||
float spacing = 0.0f);
|
||||
BSplitLayoutBuilder(BSplitView* view);
|
||||
|
||||
BSplitView* SplitView() const;
|
||||
BSplitLayoutBuilder& GetSplitView(BSplitView** view);
|
||||
|
||||
BSplitLayoutBuilder& Add(BView* view);
|
||||
BSplitLayoutBuilder& Add(BView* view, float weight);
|
||||
BSplitLayoutBuilder& Add(BLayoutItem* item);
|
||||
BSplitLayoutBuilder& Add(BLayoutItem* item, float weight);
|
||||
|
||||
BSplitLayoutBuilder& SetCollapsible(bool collapsible);
|
||||
|
||||
operator BSplitView*();
|
||||
|
||||
private:
|
||||
BSplitView* fView;
|
||||
};
|
||||
|
||||
#endif // _SPLIT_LAYOUT_BUILDER_H
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SPLIT_VIEW_H
|
||||
#define _SPLIT_VIEW_H
|
||||
|
||||
#include <View.h>
|
||||
|
||||
class BSplitLayout;
|
||||
|
||||
|
||||
class BSplitView : public BView {
|
||||
public:
|
||||
BSplitView(
|
||||
enum orientation orientation = B_HORIZONTAL,
|
||||
float spacing = 0.0f);
|
||||
virtual ~BSplitView();
|
||||
|
||||
float Spacing() const;
|
||||
void SetSpacing(float spacing);
|
||||
|
||||
orientation Orientation() const;
|
||||
void SetOrientation(enum orientation orientation);
|
||||
|
||||
float SplitterSize() const;
|
||||
void SetSplitterSize(float size);
|
||||
|
||||
|
||||
void SetCollapsible(bool collapsible);
|
||||
void SetCollapsible(int32 index, bool collapsible);
|
||||
void SetCollapsible(int32 first, int32 last,
|
||||
bool collapsible);
|
||||
|
||||
// void AddChild(BView* child);
|
||||
void AddChild(BView* child, BView* sibling = NULL);
|
||||
bool AddChild(BView* child, float weight);
|
||||
bool AddChild(int32 index, BView* child,
|
||||
float weight);
|
||||
|
||||
bool AddChild(BLayoutItem* child);
|
||||
bool AddChild(BLayoutItem* child, float weight);
|
||||
bool AddChild(int32 index, BLayoutItem* child,
|
||||
float weight);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
const BMessage* message);
|
||||
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
// overridden to avoid use
|
||||
|
||||
protected:
|
||||
virtual void DrawSplitter(BRect frame,
|
||||
enum orientation orientation, bool pressed);
|
||||
|
||||
private:
|
||||
static void _DrawDefaultSplitter(BView* view, BRect frame,
|
||||
enum orientation orientation, bool pressed);
|
||||
|
||||
private:
|
||||
BSplitLayout* fSplitLayout;
|
||||
};
|
||||
|
||||
|
||||
#endif // _SPLIT_VIEW_H
|
||||
@@ -53,6 +53,8 @@ class BStringView : public BView{
|
||||
virtual void AllDetached();
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual BSize MaxSize();
|
||||
|
||||
private:
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
virtual void _ReservedStringView1();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Control.h>
|
||||
#include <TextView.h>
|
||||
|
||||
class BLayoutItem;
|
||||
class _BTextInput_;
|
||||
|
||||
|
||||
@@ -19,6 +20,13 @@ class BTextControl : public BControl {
|
||||
BMessage* message,
|
||||
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BTextControl(const char* name,
|
||||
const char* label, const char* initialText,
|
||||
BMessage* message,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BTextControl(const char* label,
|
||||
const char* initialText,
|
||||
BMessage* message);
|
||||
virtual ~BTextControl();
|
||||
|
||||
BTextControl(BMessage* archive);
|
||||
@@ -68,8 +76,16 @@ class BTextControl : public BControl {
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
virtual void SetFlags(uint32 flags);
|
||||
|
||||
BLayoutItem* CreateLabelLayoutItem();
|
||||
BLayoutItem* CreateTextViewLayoutItem();
|
||||
|
||||
private:
|
||||
class LabelLayoutItem;
|
||||
class TextViewLayoutItem;
|
||||
|
||||
friend class _BTextInput_;
|
||||
friend class LabelLayoutItem;
|
||||
friend class TextViewLayoutItem;
|
||||
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
@@ -84,6 +100,8 @@ class BTextControl : public BControl {
|
||||
void _UpdateTextViewColors(bool enabled);
|
||||
void _InitData(const char* label, const char* initialText,
|
||||
BMessage* archive = NULL);
|
||||
void _ValidateLayout();
|
||||
void _UpdateFrame();
|
||||
|
||||
private:
|
||||
_BTextInput_* fText;
|
||||
@@ -93,8 +111,10 @@ class BTextControl : public BControl {
|
||||
float fDivider;
|
||||
float fPreviousWidth;
|
||||
float fPreviousHeight;
|
||||
BLayoutItem* fLabelLayoutItem;
|
||||
BLayoutItem* fTextViewLayoutItem;
|
||||
|
||||
uint32 _reserved[6];
|
||||
uint32 _reserved[4];
|
||||
|
||||
bool fClean;
|
||||
bool fSkipSetFlags;
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TWO_DIMENSIONAL_LAYOUT_H
|
||||
#define _TWO_DIMENSIONAL_LAYOUT_H
|
||||
|
||||
#include <Layout.h>
|
||||
|
||||
class BLayoutContext;
|
||||
|
||||
|
||||
class BTwoDimensionalLayout : public BLayout {
|
||||
public:
|
||||
BTwoDimensionalLayout();
|
||||
virtual ~BTwoDimensionalLayout();
|
||||
|
||||
void SetInsets(float left, float top, float right,
|
||||
float bottom);
|
||||
void GetInsets(float* left, float* top, float* right,
|
||||
float* bottom);
|
||||
|
||||
void AlignLayoutWith(BTwoDimensionalLayout* other,
|
||||
enum orientation orientation);
|
||||
|
||||
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();
|
||||
|
||||
protected:
|
||||
struct ColumnRowConstraints {
|
||||
float weight;
|
||||
float min;
|
||||
float max;
|
||||
};
|
||||
|
||||
struct Dimensions {
|
||||
int32 x;
|
||||
int32 y;
|
||||
int32 width;
|
||||
int32 height;
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
virtual int32 InternalCountColumns() = 0;
|
||||
virtual int32 InternalCountRows() = 0;
|
||||
virtual void GetColumnRowConstraints(
|
||||
enum orientation orientation,
|
||||
int32 index,
|
||||
ColumnRowConstraints* constraints) = 0;
|
||||
virtual void GetItemDimensions(BLayoutItem* item,
|
||||
Dimensions* dimensions) = 0;
|
||||
|
||||
private:
|
||||
class CompoundLayouter;
|
||||
class LocalLayouter;
|
||||
class VerticalCompoundLayouter;
|
||||
|
||||
friend class LocalLayouter;
|
||||
|
||||
void _ValidateMinMax();
|
||||
BLayoutContext* _CurrentLayoutContext();
|
||||
|
||||
protected:
|
||||
float fLeftInset;
|
||||
float fRightInset;
|
||||
float fTopInset;
|
||||
float fBottomInset;
|
||||
float fHSpacing;
|
||||
float fVSpacing;
|
||||
|
||||
private:
|
||||
LocalLayouter* fLocalLayouter;
|
||||
};
|
||||
|
||||
#endif // _TWO_DIMENSIONAL_LAYOUT_H
|
||||
+64
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -9,11 +9,13 @@
|
||||
#define _VIEW_H
|
||||
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <BeBuild.h>
|
||||
#include <Font.h>
|
||||
#include <Handler.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Rect.h>
|
||||
#include <Size.h>
|
||||
|
||||
|
||||
// mouse button
|
||||
@@ -74,6 +76,8 @@ const uint32 B_SUBPIXEL_PRECISE = 0x01000000UL; /* 24 */
|
||||
const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */
|
||||
const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */
|
||||
const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */
|
||||
const uint32 B_SUPPORTS_LAYOUT = 0x00100000UL; /* 21 */
|
||||
const uint32 B_INVALIDATE_AFTER_LAYOUT = 0x00080000UL; /* 20 */
|
||||
|
||||
#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE | _B_RESERVED1_ | B_WILL_DRAW \
|
||||
| B_PULSE_NEEDED | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE \
|
||||
@@ -104,6 +108,9 @@ inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
|
||||
|
||||
class BBitmap;
|
||||
class BCursor;
|
||||
class BLayout;
|
||||
class BLayoutContext;
|
||||
class BLayoutItem;
|
||||
class BMessage;
|
||||
class BPicture;
|
||||
class BPolygon;
|
||||
@@ -125,6 +132,8 @@ namespace BPrivate {
|
||||
|
||||
class BView : public BHandler {
|
||||
public:
|
||||
BView(const char* name, uint32 flags,
|
||||
BLayout* layout = NULL);
|
||||
BView(BRect frame, const char* name,
|
||||
uint32 resizeMask, uint32 flags);
|
||||
virtual ~BView();
|
||||
@@ -141,6 +150,7 @@ public:
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
void AddChild(BView* child, BView* before = NULL);
|
||||
bool AddChild(BLayoutItem* child);
|
||||
bool RemoveChild(BView* child);
|
||||
int32 CountChildren() const;
|
||||
BView* ChildAt(int32 index) const;
|
||||
@@ -490,31 +500,64 @@ public:
|
||||
|
||||
bool IsPrinting() const;
|
||||
void SetScale(float scale) const;
|
||||
float Scale() const;
|
||||
// new for Haiku
|
||||
|
||||
// Private or reserved ---------------------------------------------------------
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
virtual void DrawAfterChildren(BRect r);
|
||||
|
||||
float Scale() const;
|
||||
// new for Haiku
|
||||
|
||||
// layout related
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BAlignment Alignment();
|
||||
|
||||
void SetExplicitMinSize(BSize size);
|
||||
void SetExplicitMaxSize(BSize size);
|
||||
void SetExplicitPreferredSize(BSize size);
|
||||
void SetExplicitAlignment(BAlignment alignment);
|
||||
|
||||
BSize ExplicitMinSize() const;
|
||||
BSize ExplicitMaxSize() const;
|
||||
BSize ExplicitPreferredSize() const;
|
||||
BAlignment ExplicitAlignment() const;
|
||||
|
||||
virtual bool HasHeightForWidth();
|
||||
virtual void GetHeightForWidth(float width, float* min,
|
||||
float* max, float* preferred);
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
BLayout* GetLayout() const;
|
||||
|
||||
void InvalidateLayout(bool descendants = false);
|
||||
void EnableLayoutInvalidation();
|
||||
void DisableLayoutInvalidation();
|
||||
|
||||
BLayoutContext* LayoutContext() const;
|
||||
|
||||
void Layout(bool force);
|
||||
void Relayout();
|
||||
|
||||
protected:
|
||||
virtual void DoLayout();
|
||||
|
||||
private:
|
||||
friend class BScrollBar;
|
||||
friend class BWindow;
|
||||
void _Layout(bool force, BLayoutContext* context);
|
||||
|
||||
private:
|
||||
struct LayoutData;
|
||||
|
||||
friend class BBitmap;
|
||||
friend class BLayout;
|
||||
friend class BPrintJob;
|
||||
friend class BScrollBar;
|
||||
friend class BShelf;
|
||||
friend class BTabView;
|
||||
friend class BWindow;
|
||||
|
||||
virtual void _ReservedView2();
|
||||
virtual void _ReservedView3();
|
||||
virtual void _ReservedView4();
|
||||
virtual void _ReservedView5();
|
||||
virtual void _ReservedView6();
|
||||
virtual void _ReservedView7();
|
||||
virtual void _ReservedView8();
|
||||
virtual void _ReservedView9();
|
||||
virtual void _ReservedView10();
|
||||
virtual void _ReservedView11();
|
||||
virtual void _ReservedView12();
|
||||
@@ -571,6 +614,9 @@ private:
|
||||
bool _AddChildToList(BView* child, BView* before = NULL);
|
||||
bool _RemoveChildFromList(BView* child);
|
||||
|
||||
bool _AddChild(BView *child, BView *before);
|
||||
bool _RemoveSelf();
|
||||
|
||||
// Debugging methods
|
||||
void PrintToStream();
|
||||
void PrintTree();
|
||||
@@ -601,7 +647,10 @@ private:
|
||||
BShelf* fShelf;
|
||||
uint32 fEventMask;
|
||||
uint32 fEventOptions;
|
||||
uint32 _reserved[9];
|
||||
|
||||
LayoutData* fLayoutData;
|
||||
|
||||
uint32 _reserved[8];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ enum {
|
||||
B_ASYNCHRONOUS_CONTROLS = 0x00080000,
|
||||
B_QUIT_ON_WINDOW_CLOSE = 0x00100000,
|
||||
B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000,
|
||||
B_AUTO_UPDATE_SIZE_LIMITS = 0x00400000,
|
||||
};
|
||||
|
||||
#define B_CURRENT_WORKSPACE 0
|
||||
@@ -257,6 +258,11 @@ public:
|
||||
virtual bool QuitRequested();
|
||||
virtual thread_id Run();
|
||||
|
||||
virtual void SetLayout(BLayout* layout);
|
||||
BLayout* GetLayout() const;
|
||||
|
||||
void InvalidateLayout(bool descendants = false);
|
||||
|
||||
private:
|
||||
typedef BLooper inherited;
|
||||
struct unpack_cookie;
|
||||
|
||||
Reference in New Issue
Block a user