122 lines
3.2 KiB
C++
122 lines
3.2 KiB
C++
/*
|
|
* Copyright 2012, Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef ALM_LAYOUT_BUILDER_H
|
|
#define ALM_LAYOUT_BUILDER_H
|
|
|
|
|
|
#include "ALMLayout.h"
|
|
|
|
|
|
class BLayoutItem;
|
|
class BView;
|
|
class BWindow;
|
|
|
|
|
|
namespace BALM {
|
|
|
|
|
|
class BALMLayoutBuilder {
|
|
public:
|
|
BALMLayoutBuilder(BView* view, float hSpacing,
|
|
float vSpacing,
|
|
BALMLayout* friendLayout = NULL);
|
|
BALMLayoutBuilder(BView* view,
|
|
BALMLayout* layout);
|
|
BALMLayoutBuilder(BWindow* window,
|
|
float hSpacing, float vSpacing,
|
|
BALMLayout* friendLayout = NULL);
|
|
BALMLayoutBuilder(BWindow* window,
|
|
BALMLayout* layout);
|
|
BALMLayoutBuilder(BALMLayout* layout);
|
|
|
|
BALMLayoutBuilder& Add(BView* view, XTab* left, YTab* top,
|
|
XTab* right = NULL, YTab* bottom = NULL);
|
|
BALMLayoutBuilder& Add(BView* view, Row* row, Column* column);
|
|
|
|
BALMLayoutBuilder& Add(BLayoutItem* item, XTab* left,
|
|
YTab* top, XTab* right = NULL,
|
|
YTab* bottom = NULL);
|
|
BALMLayoutBuilder& Add(BLayoutItem* item, Row* row,
|
|
Column* column);
|
|
|
|
BALMLayoutBuilder& SetInsets(float insets);
|
|
BALMLayoutBuilder& SetInsets(float horizontal, float vertical);
|
|
BALMLayoutBuilder& SetInsets(float left, float top, float right,
|
|
float bottom);
|
|
|
|
BALMLayoutBuilder& SetSpacing(float horizontal, float vertical);
|
|
|
|
struct Snake;
|
|
|
|
// context setters
|
|
Snake StartingAt(BView* view);
|
|
Snake StartingAt(BLayoutItem* item);
|
|
|
|
struct Snake {
|
|
BALMLayoutBuilder::Snake& AddToLeft(BView* view,
|
|
XTab* left = NULL, YTab* top = NULL,
|
|
YTab* bottom = NULL);
|
|
BALMLayoutBuilder::Snake& AddToRight(BView* view,
|
|
XTab* right = NULL, YTab* top = NULL,
|
|
YTab* bottom = NULL);
|
|
BALMLayoutBuilder::Snake& AddAbove(BView* view,
|
|
YTab* top = NULL, XTab* left = NULL,
|
|
XTab* right = NULL);
|
|
BALMLayoutBuilder::Snake& AddBelow(BView* view, YTab* bottom = NULL,
|
|
XTab* left = NULL, XTab* right = NULL);
|
|
|
|
BALMLayoutBuilder::Snake& AddToLeft(BLayoutItem* item,
|
|
XTab* left = NULL, YTab* top = NULL,
|
|
YTab* bottom = NULL);
|
|
BALMLayoutBuilder::Snake& AddToRight(BLayoutItem* item,
|
|
XTab* right = NULL, YTab* top = NULL,
|
|
YTab* bottom = NULL);
|
|
BALMLayoutBuilder::Snake& AddAbove(BLayoutItem* item,
|
|
YTab* top = NULL, XTab* left = NULL,
|
|
XTab* right = NULL);
|
|
BALMLayoutBuilder::Snake& AddBelow(BLayoutItem* item,
|
|
YTab* bottom = NULL, XTab* left = NULL,
|
|
XTab* right = NULL);
|
|
|
|
|
|
// these methods throw away the stack
|
|
Snake StartingAt(BView* view);
|
|
Snake StartingAt(BLayoutItem* item);
|
|
|
|
Snake Push();
|
|
Snake& Pop();
|
|
|
|
BALMLayoutBuilder& End();
|
|
|
|
private:
|
|
friend class BALMLayoutBuilder;
|
|
|
|
Snake(Area* area, BALMLayoutBuilder* root);
|
|
Snake(Area* area, Snake* previous);
|
|
|
|
BALMLayout* _Layout();
|
|
Area* _AddToLayout(BView* view, XTab* left, YTab* top,
|
|
XTab* right, YTab* bottom);
|
|
Area* _AddToLayout(BLayoutItem* item, XTab* left,
|
|
YTab* top, XTab* right, YTab* bottom);
|
|
|
|
BALMLayoutBuilder* fRootBuilder;
|
|
Snake* fPreviousSnake;
|
|
Area* fCurrentArea;
|
|
};
|
|
|
|
|
|
private:
|
|
friend struct Snake;
|
|
|
|
BALMLayout* fLayout;
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif
|