2009-06-17 23:38:51 +04:00
|
|
|
/*
|
2012-11-04 13:53:34 +04:00
|
|
|
* Copyright 2009-2012, Haiku, Inc. All rights reserved.
|
2009-06-17 23:38:51 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _LAYOUT_BUILDER_H
|
|
|
|
#define _LAYOUT_BUILDER_H
|
|
|
|
|
2009-07-30 18:03:48 +04:00
|
|
|
|
2010-11-19 17:29:37 +03:00
|
|
|
#include <new>
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
#include <GridLayout.h>
|
|
|
|
#include <GridView.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupView.h>
|
2010-11-19 17:29:37 +03:00
|
|
|
#include <Menu.h>
|
2009-07-30 18:03:48 +04:00
|
|
|
#include <MenuField.h>
|
2010-11-19 17:29:37 +03:00
|
|
|
#include <MenuItem.h>
|
2009-06-17 23:38:51 +04:00
|
|
|
#include <SpaceLayoutItem.h>
|
|
|
|
#include <SplitView.h>
|
2009-07-30 18:03:48 +04:00
|
|
|
#include <TextControl.h>
|
2009-06-19 19:28:00 +04:00
|
|
|
#include <Window.h>
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
namespace BLayoutBuilder {
|
|
|
|
|
|
|
|
template<typename ParentBuilder> class Base;
|
|
|
|
template<typename ParentBuilder = void*> class Group;
|
|
|
|
template<typename ParentBuilder = void*> class Grid;
|
|
|
|
template<typename ParentBuilder = void*> class Split;
|
2010-11-19 17:29:37 +03:00
|
|
|
template<typename ParentBuilder = void*> class Menu;
|
|
|
|
template<typename ParentBuilder = void*> class MenuItem;
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
class Base {
|
|
|
|
protected:
|
|
|
|
inline Base();
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline void SetParent(ParentBuilder* parent);
|
2009-08-14 20:24:41 +04:00
|
|
|
// conceptually private
|
2009-06-17 23:38:51 +04:00
|
|
|
inline ParentBuilder& End();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ParentBuilder* fParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
class Group : public Base<ParentBuilder> {
|
|
|
|
public:
|
|
|
|
typedef Group<ParentBuilder> ThisBuilder;
|
|
|
|
typedef Group<ThisBuilder> GroupBuilder;
|
|
|
|
typedef Grid<ThisBuilder> GridBuilder;
|
|
|
|
typedef Split<ThisBuilder> SplitBuilder;
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline Group(enum orientation orientation
|
|
|
|
= B_HORIZONTAL,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING);
|
2009-06-19 19:28:00 +04:00
|
|
|
inline Group(BWindow* window,
|
|
|
|
enum orientation orientation = B_HORIZONTAL,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING);
|
2011-06-18 05:12:29 +04:00
|
|
|
inline Group(BView* view,
|
|
|
|
enum orientation orientation = B_HORIZONTAL,
|
|
|
|
float spacing = B_USE_DEFAULT_SPACING);
|
2009-06-17 23:38:51 +04:00
|
|
|
inline Group(BGroupLayout* layout);
|
|
|
|
inline Group(BGroupView* view);
|
|
|
|
|
|
|
|
inline BGroupLayout* Layout() const;
|
|
|
|
inline BView* View() const;
|
|
|
|
inline ThisBuilder& GetLayout(BGroupLayout** _layout);
|
|
|
|
inline ThisBuilder& GetView(BView** _view);
|
|
|
|
|
|
|
|
inline ThisBuilder& Add(BView* view);
|
|
|
|
inline ThisBuilder& Add(BView* view, float weight);
|
|
|
|
inline ThisBuilder& Add(BLayoutItem* item);
|
|
|
|
inline ThisBuilder& Add(BLayoutItem* item, float weight);
|
|
|
|
|
|
|
|
inline GroupBuilder AddGroup(enum orientation orientation,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING,
|
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GroupBuilder AddGroup(BGroupView* groupView,
|
|
|
|
float weight = 1.0f);
|
|
|
|
inline GroupBuilder AddGroup(BGroupLayout* groupLayout,
|
|
|
|
float weight = 1.0f);
|
|
|
|
|
2010-09-03 02:58:24 +04:00
|
|
|
inline GridBuilder AddGrid(float horizontal
|
|
|
|
= B_USE_DEFAULT_SPACING,
|
|
|
|
float vertical = B_USE_DEFAULT_SPACING,
|
2009-06-17 23:38:51 +04:00
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GridBuilder AddGrid(BGridLayout* gridLayout,
|
|
|
|
float weight = 1.0f);
|
|
|
|
inline GridBuilder AddGrid(BGridView* gridView,
|
|
|
|
float weight = 1.0f);
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline SplitBuilder AddSplit(enum orientation orientation,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING,
|
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline SplitBuilder AddSplit(BSplitView* splitView,
|
|
|
|
float weight = 1.0f);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
inline ThisBuilder& AddGlue(float weight = 1.0f);
|
|
|
|
inline ThisBuilder& AddStrut(float size);
|
|
|
|
|
|
|
|
inline ThisBuilder& SetInsets(float left, float top, float right,
|
|
|
|
float bottom);
|
2011-06-10 00:58:52 +04:00
|
|
|
inline ThisBuilder& SetInsets(float horizontal, float vertical);
|
|
|
|
inline ThisBuilder& SetInsets(float insets);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
inline ThisBuilder& SetExplicitMinSize(BSize size);
|
|
|
|
inline ThisBuilder& SetExplicitMaxSize(BSize size);
|
|
|
|
inline ThisBuilder& SetExplicitPreferredSize(BSize size);
|
2012-11-04 20:22:32 +04:00
|
|
|
inline ThisBuilder& SetExplicitAlignment(BAlignment alignment);
|
2012-11-04 13:53:34 +04:00
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline operator BGroupLayout*();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BGroupLayout* fLayout;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
class Grid : public Base<ParentBuilder> {
|
|
|
|
public:
|
|
|
|
typedef Grid<ParentBuilder> ThisBuilder;
|
|
|
|
typedef Group<ThisBuilder> GroupBuilder;
|
|
|
|
typedef Grid<ThisBuilder> GridBuilder;
|
|
|
|
typedef Split<ThisBuilder> SplitBuilder;
|
|
|
|
|
|
|
|
public:
|
2010-09-03 02:58:24 +04:00
|
|
|
inline Grid(float horizontal
|
|
|
|
= B_USE_DEFAULT_SPACING,
|
|
|
|
float vertical = B_USE_DEFAULT_SPACING);
|
2009-06-19 19:28:00 +04:00
|
|
|
inline Grid(BWindow* window,
|
2010-09-03 02:58:24 +04:00
|
|
|
float horizontal = B_USE_DEFAULT_SPACING,
|
|
|
|
float vertical = B_USE_DEFAULT_SPACING);
|
2011-06-18 05:12:29 +04:00
|
|
|
inline Grid(BView* view,
|
|
|
|
float horizontal = B_USE_DEFAULT_SPACING,
|
|
|
|
float vertical = B_USE_DEFAULT_SPACING);
|
2009-06-17 23:38:51 +04:00
|
|
|
inline Grid(BGridLayout* layout);
|
|
|
|
inline Grid(BGridView* view);
|
|
|
|
|
|
|
|
inline BGridLayout* Layout() const;
|
|
|
|
inline BView* View() const;
|
|
|
|
inline ThisBuilder& GetLayout(BGridLayout** _layout);
|
|
|
|
inline ThisBuilder& GetView(BView** _view);
|
|
|
|
|
|
|
|
inline ThisBuilder& Add(BView* view, int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
|
|
|
inline ThisBuilder& Add(BLayoutItem* item, int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
2009-07-30 18:03:48 +04:00
|
|
|
inline ThisBuilder& AddMenuField(BMenuField* menuField,
|
|
|
|
int32 column, int32 row,
|
|
|
|
alignment labelAlignment
|
|
|
|
= B_ALIGN_HORIZONTAL_UNSET,
|
2010-11-17 19:29:06 +03:00
|
|
|
int32 labelColumnCount = 1,
|
|
|
|
int32 fieldColumnCount = 1,
|
|
|
|
int32 rowCount = 1);
|
2009-07-30 18:03:48 +04:00
|
|
|
inline ThisBuilder& AddTextControl(BTextControl* textControl,
|
|
|
|
int32 column, int32 row,
|
|
|
|
alignment labelAlignment
|
|
|
|
= B_ALIGN_HORIZONTAL_UNSET,
|
2010-11-17 19:29:06 +03:00
|
|
|
int32 labelColumnCount = 1,
|
|
|
|
int32 textColumnCount = 1,
|
|
|
|
int32 rowCount = 1);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
inline GroupBuilder AddGroup(enum orientation orientation,
|
|
|
|
float spacing, int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GroupBuilder AddGroup(BGroupView* groupView, int32 column,
|
|
|
|
int32 row, int32 columnCount = 1,
|
|
|
|
int32 rowCount = 1);
|
2010-11-17 19:29:06 +03:00
|
|
|
inline GroupBuilder AddGroup(BGroupLayout* groupLayout,
|
2010-08-17 22:43:41 +04:00
|
|
|
int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline GridBuilder AddGrid(float horizontalSpacing,
|
|
|
|
float verticalSpacing, int32 column,
|
|
|
|
int32 row, int32 columnCount = 1,
|
|
|
|
int32 rowCount = 1);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GridBuilder AddGrid(BGridLayout* gridLayout,
|
|
|
|
int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
|
|
|
inline GridBuilder AddGrid(BGridView* gridView,
|
|
|
|
int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline SplitBuilder AddSplit(enum orientation orientation,
|
|
|
|
float spacing, int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline SplitBuilder AddSplit(BSplitView* splitView, int32 column,
|
|
|
|
int32 row, int32 columnCount = 1,
|
|
|
|
int32 rowCount = 1);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
inline ThisBuilder& AddGlue(int32 column, int32 row,
|
|
|
|
int32 columnCount = 1, int32 rowCount = 1);
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline ThisBuilder& SetColumnWeight(int32 column, float weight);
|
|
|
|
inline ThisBuilder& SetRowWeight(int32 row, float weight);
|
|
|
|
|
|
|
|
inline ThisBuilder& SetInsets(float left, float top, float right,
|
|
|
|
float bottom);
|
2011-06-10 00:58:52 +04:00
|
|
|
inline ThisBuilder& SetInsets(float horizontal, float vertical);
|
|
|
|
inline ThisBuilder& SetInsets(float insets);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
inline ThisBuilder& SetExplicitMinSize(BSize size);
|
|
|
|
inline ThisBuilder& SetExplicitMaxSize(BSize size);
|
|
|
|
inline ThisBuilder& SetExplicitPreferredSize(BSize size);
|
2012-11-04 20:22:32 +04:00
|
|
|
inline ThisBuilder& SetExplicitAlignment(BAlignment alignment);
|
2012-11-04 13:53:34 +04:00
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline operator BGridLayout*();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BGridLayout* fLayout;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
class Split : public Base<ParentBuilder> {
|
|
|
|
public:
|
|
|
|
typedef Split<ParentBuilder> ThisBuilder;
|
|
|
|
typedef Group<ThisBuilder> GroupBuilder;
|
|
|
|
typedef Grid<ThisBuilder> GridBuilder;
|
|
|
|
typedef Split<ThisBuilder> SplitBuilder;
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline Split(enum orientation orientation
|
|
|
|
= B_HORIZONTAL,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING);
|
2009-06-17 23:38:51 +04:00
|
|
|
inline Split(BSplitView* view);
|
|
|
|
|
|
|
|
inline BSplitView* View() const;
|
2010-08-17 22:43:41 +04:00
|
|
|
inline ThisBuilder& GetView(BView** _view);
|
|
|
|
inline ThisBuilder& GetSplitView(BSplitView** _view);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
inline ThisBuilder& Add(BView* view);
|
|
|
|
inline ThisBuilder& Add(BView* view, float weight);
|
|
|
|
inline ThisBuilder& Add(BLayoutItem* item);
|
|
|
|
inline ThisBuilder& Add(BLayoutItem* item, float weight);
|
|
|
|
|
|
|
|
inline GroupBuilder AddGroup(enum orientation orientation,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING,
|
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GroupBuilder AddGroup(BGroupView* groupView,
|
|
|
|
float weight = 1.0f);
|
|
|
|
inline GroupBuilder AddGroup(BGroupLayout* groupLayout,
|
|
|
|
float weight = 1.0f);
|
|
|
|
|
2010-09-03 02:58:24 +04:00
|
|
|
inline GridBuilder AddGrid(float horizontal
|
|
|
|
= B_USE_DEFAULT_SPACING,
|
|
|
|
float vertical = B_USE_DEFAULT_SPACING,
|
2009-06-17 23:38:51 +04:00
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline GridBuilder AddGrid(BGridView* gridView,
|
|
|
|
float weight = 1.0f);
|
|
|
|
inline GridBuilder AddGrid(BGridLayout* gridLayout,
|
|
|
|
float weight = 1.0f);
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline SplitBuilder AddSplit(enum orientation orientation,
|
2010-09-03 02:58:24 +04:00
|
|
|
float spacing = B_USE_DEFAULT_SPACING,
|
|
|
|
float weight = 1.0f);
|
2010-08-17 22:43:41 +04:00
|
|
|
inline SplitBuilder AddSplit(BSplitView* splitView,
|
|
|
|
float weight = 1.0f);
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
inline ThisBuilder& SetCollapsible(bool collapsible);
|
|
|
|
inline ThisBuilder& SetCollapsible(int32 index, bool collapsible);
|
|
|
|
inline ThisBuilder& SetCollapsible(int32 first, int32 last,
|
|
|
|
bool collapsible);
|
|
|
|
|
2009-06-23 14:56:22 +04:00
|
|
|
inline ThisBuilder& SetInsets(float left, float top, float right,
|
|
|
|
float bottom);
|
2011-06-10 00:58:52 +04:00
|
|
|
inline ThisBuilder& SetInsets(float horizontal, float vertical);
|
|
|
|
inline ThisBuilder& SetInsets(float insets);
|
2009-06-23 14:56:22 +04:00
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
inline operator BSplitView*();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BSplitView* fView;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-19 17:29:37 +03:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
class Menu : public Base<ParentBuilder> {
|
|
|
|
public:
|
|
|
|
typedef Menu<ParentBuilder> ThisBuilder;
|
|
|
|
typedef MenuItem<ParentBuilder> ItemBuilder;
|
|
|
|
typedef Menu<ThisBuilder> MenuBuilder;
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline Menu(BMenu* menu);
|
|
|
|
|
|
|
|
inline ThisBuilder& GetMenu(BMenu*& _menu);
|
|
|
|
|
|
|
|
inline ItemBuilder AddItem(BMenuItem* item);
|
|
|
|
inline ItemBuilder AddItem(BMenu* menu);
|
|
|
|
inline ItemBuilder AddItem(const char* label, BMessage* message,
|
|
|
|
char shortcut = 0, uint32 modifiers = 0);
|
|
|
|
inline ItemBuilder AddItem(const char* label, uint32 messageWhat,
|
|
|
|
char shortcut = 0, uint32 modifiers = 0);
|
|
|
|
|
|
|
|
inline MenuBuilder AddMenu(BMenu* menu);
|
|
|
|
inline MenuBuilder AddMenu(const char* title,
|
|
|
|
menu_layout layout = B_ITEMS_IN_COLUMN);
|
|
|
|
|
|
|
|
inline ThisBuilder& AddSeparator();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BMenu* fMenu;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
class MenuItem : public Menu<ParentBuilder> {
|
|
|
|
public:
|
|
|
|
typedef MenuItem<ParentBuilder> ThisBuilder;
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline MenuItem(ParentBuilder* parentBuilder,
|
|
|
|
BMenu* menu, BMenuItem* item);
|
|
|
|
|
|
|
|
inline ThisBuilder& GetItem(BMenuItem*& _item);
|
|
|
|
|
|
|
|
inline ThisBuilder& SetEnabled(bool enabled);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BMenuItem* fMenuItem;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
// #pragma mark - Base
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Base<ParentBuilder>::Base()
|
|
|
|
:
|
|
|
|
fParent(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
void
|
|
|
|
Base<ParentBuilder>::SetParent(ParentBuilder* parent)
|
|
|
|
{
|
|
|
|
fParent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
ParentBuilder&
|
|
|
|
Base<ParentBuilder>::End()
|
|
|
|
{
|
|
|
|
return *fParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - Group
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::Group(enum orientation orientation, float spacing)
|
|
|
|
:
|
|
|
|
fLayout((new BGroupView(orientation, spacing))->GroupLayout())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 19:28:00 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::Group(BWindow* window, enum orientation orientation,
|
|
|
|
float spacing)
|
|
|
|
:
|
2010-05-07 19:08:27 +04:00
|
|
|
fLayout(new BGroupLayout(orientation, spacing))
|
2009-06-19 19:28:00 +04:00
|
|
|
{
|
|
|
|
window->SetLayout(fLayout);
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
2010-05-07 19:08:27 +04:00
|
|
|
// TODO: we get a white background if we don't do this
|
2010-05-07 15:32:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-18 05:12:29 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::Group(BView* view, enum orientation orientation,
|
|
|
|
float spacing)
|
|
|
|
:
|
|
|
|
fLayout(new BGroupLayout(orientation, spacing))
|
|
|
|
{
|
|
|
|
view->SetLayout(fLayout);
|
|
|
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
|
|
// TODO: we get a white background if we don't do this
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::Group(BGroupLayout* layout)
|
|
|
|
:
|
|
|
|
fLayout(layout)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::Group(BGroupView* view)
|
|
|
|
:
|
|
|
|
fLayout(view->GroupLayout())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
BGroupLayout*
|
|
|
|
Group<ParentBuilder>::Layout() const
|
|
|
|
{
|
|
|
|
return fLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
BView*
|
|
|
|
Group<ParentBuilder>::View() const
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
return fLayout->Owner();
|
2009-06-17 23:38:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::GetLayout(BGroupLayout** _layout)
|
|
|
|
{
|
|
|
|
*_layout = fLayout;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::GetView(BView** _view)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
*_view = fLayout->Owner();
|
2009-06-17 23:38:51 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::Add(BView* view)
|
|
|
|
{
|
|
|
|
fLayout->AddView(view);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::Add(BView* view, float weight)
|
|
|
|
{
|
|
|
|
fLayout->AddView(view, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::Add(BLayoutItem* item)
|
|
|
|
{
|
|
|
|
fLayout->AddItem(item);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::Add(BLayoutItem* item, float weight)
|
|
|
|
{
|
|
|
|
fLayout->AddItem(item, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GroupBuilder
|
|
|
|
Group<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
|
|
|
|
float weight)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GroupBuilder builder(new BGroupLayout(orientation, spacing));
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
2010-08-17 22:43:41 +04:00
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GroupBuilder
|
|
|
|
Group<ParentBuilder>::AddGroup(BGroupView* groupView, float weight)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GroupBuilder
|
|
|
|
Group<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, float weight)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupLayout);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
2009-06-17 23:38:51 +04:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GridBuilder
|
2010-08-17 22:43:41 +04:00
|
|
|
Group<ParentBuilder>::AddGrid(float horizontalSpacing,
|
|
|
|
float verticalSpacing, float weight)
|
2009-06-17 23:38:51 +04:00
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
2010-08-17 22:43:41 +04:00
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GridBuilder
|
|
|
|
Group<ParentBuilder>::AddGrid(BGridLayout* gridLayout, float weight)
|
|
|
|
{
|
|
|
|
GridBuilder builder(gridLayout);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::GridBuilder
|
|
|
|
Group<ParentBuilder>::AddGrid(BGridView* gridView, float weight)
|
|
|
|
{
|
|
|
|
GridBuilder builder(gridView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), weight);
|
2009-06-17 23:38:51 +04:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::SplitBuilder
|
|
|
|
Group<ParentBuilder>::AddSplit(enum orientation orientation, float spacing,
|
|
|
|
float weight)
|
|
|
|
{
|
|
|
|
SplitBuilder builder(orientation, spacing);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddView(builder.View(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::SplitBuilder
|
|
|
|
Group<ParentBuilder>::AddSplit(BSplitView* splitView, float weight)
|
|
|
|
{
|
|
|
|
SplitBuilder builder(splitView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddView(builder.View(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::AddGlue(float weight)
|
|
|
|
{
|
|
|
|
fLayout->AddItem(BSpaceLayoutItem::CreateGlue(), weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::AddStrut(float size)
|
|
|
|
{
|
|
|
|
if (fLayout->Orientation() == B_HORIZONTAL)
|
|
|
|
fLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(size));
|
|
|
|
else
|
|
|
|
fLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(size));
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetInsets(float left, float top, float right,
|
|
|
|
float bottom)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(left, top, right, bottom);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-10 00:58:52 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetInsets(float horizontal, float vertical)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(horizontal, vertical);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetInsets(float insets)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(insets);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetExplicitMinSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitMinSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetExplicitMaxSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitMaxSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetExplicitPreferredSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitPreferredSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-04 20:22:32 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Group<ParentBuilder>::ThisBuilder&
|
|
|
|
Group<ParentBuilder>::SetExplicitAlignment(BAlignment alignment)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitAlignment(alignment);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Group<ParentBuilder>::operator BGroupLayout*()
|
|
|
|
{
|
|
|
|
return fLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - Grid
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::Grid(float horizontalSpacing, float verticalSpacing)
|
|
|
|
:
|
|
|
|
fLayout((new BGridView(horizontalSpacing, verticalSpacing))->GridLayout())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 19:28:00 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::Grid(BWindow* window, float horizontalSpacing,
|
|
|
|
float verticalSpacing)
|
|
|
|
:
|
2010-05-07 19:08:27 +04:00
|
|
|
fLayout(new BGridLayout(horizontalSpacing, verticalSpacing))
|
2009-06-19 19:28:00 +04:00
|
|
|
{
|
|
|
|
window->SetLayout(fLayout);
|
2010-05-07 19:08:27 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
2010-05-07 19:08:27 +04:00
|
|
|
// TODO: we get a white background if we don't do this
|
2009-06-19 19:28:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-18 05:12:29 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::Grid(BView* view, float horizontalSpacing,
|
|
|
|
float verticalSpacing)
|
|
|
|
:
|
|
|
|
fLayout(new BGridLayout(horizontalSpacing, verticalSpacing))
|
|
|
|
{
|
|
|
|
view->SetLayout(fLayout);
|
|
|
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
|
|
// TODO: we get a white background if we don't do this
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::Grid(BGridLayout* layout)
|
|
|
|
:
|
|
|
|
fLayout(layout)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::Grid(BGridView* view)
|
|
|
|
:
|
|
|
|
fLayout(view->GridLayout())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
BGridLayout*
|
|
|
|
Grid<ParentBuilder>::Layout() const
|
|
|
|
{
|
|
|
|
return fLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
BView*
|
|
|
|
Grid<ParentBuilder>::View() const
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
return fLayout->Owner();
|
2009-06-17 23:38:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::GetLayout(BGridLayout** _layout)
|
|
|
|
{
|
|
|
|
*_layout = fLayout;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::GetView(BView** _view)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
*_view = fLayout->Owner();
|
2009-06-17 23:38:51 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::Add(BView* view, int32 column, int32 row,
|
|
|
|
int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
fLayout->AddView(view, column, row, columnCount, rowCount);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::Add(BLayoutItem* item, int32 column, int32 row,
|
|
|
|
int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
fLayout->AddItem(item, column, row, columnCount, rowCount);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-30 18:03:48 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::AddMenuField(BMenuField* menuField, int32 column,
|
2010-11-17 19:29:06 +03:00
|
|
|
int32 row, alignment labelAlignment, int32 labelColumnCount,
|
|
|
|
int32 fieldColumnCount, int32 rowCount)
|
2009-07-30 18:03:48 +04:00
|
|
|
{
|
|
|
|
BLayoutItem* item = menuField->CreateLabelLayoutItem();
|
|
|
|
item->SetExplicitAlignment(
|
|
|
|
BAlignment(labelAlignment, B_ALIGN_VERTICAL_UNSET));
|
2010-11-17 19:29:06 +03:00
|
|
|
fLayout->AddItem(item, column, row, labelColumnCount, rowCount);
|
|
|
|
fLayout->AddItem(menuField->CreateMenuBarLayoutItem(),
|
|
|
|
column + labelColumnCount, row, fieldColumnCount, rowCount);
|
2009-07-30 18:03:48 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::AddTextControl(BTextControl* textControl, int32 column,
|
2010-11-17 19:29:06 +03:00
|
|
|
int32 row, alignment labelAlignment, int32 labelColumnCount,
|
|
|
|
int32 textColumnCount, int32 rowCount)
|
2009-07-30 18:03:48 +04:00
|
|
|
{
|
|
|
|
BLayoutItem* item = textControl->CreateLabelLayoutItem();
|
|
|
|
item->SetExplicitAlignment(
|
|
|
|
BAlignment(labelAlignment, B_ALIGN_VERTICAL_UNSET));
|
2010-11-17 19:29:06 +03:00
|
|
|
fLayout->AddItem(item, column, row, labelColumnCount, rowCount);
|
2009-07-30 18:03:48 +04:00
|
|
|
fLayout->AddItem(textControl->CreateTextViewLayoutItem(),
|
2010-11-17 19:29:06 +03:00
|
|
|
column + labelColumnCount, row, textColumnCount, rowCount);
|
2009-07-30 18:03:48 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::GroupBuilder
|
|
|
|
Grid<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
|
|
|
|
int32 column, int32 row, int32 columnCount, int32 rowCount)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GroupBuilder builder(new BGroupLayout(orientation, spacing));
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
2010-08-17 22:43:41 +04:00
|
|
|
fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::GroupBuilder
|
|
|
|
Grid<ParentBuilder>::AddGroup(BGroupView* groupView, int32 column, int32 row,
|
|
|
|
int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::GroupBuilder
|
|
|
|
Grid<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, int32 column,
|
|
|
|
int32 row, int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupLayout);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
|
2009-06-17 23:38:51 +04:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::GridBuilder
|
|
|
|
Grid<ParentBuilder>::AddGrid(float horizontalSpacing, float verticalSpacing,
|
|
|
|
int32 column, int32 row, int32 columnCount, int32 rowCount)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddItem(builder.Layout(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::GridBuilder
|
|
|
|
Grid<ParentBuilder>::AddGrid(BGridView* gridView, int32 column, int32 row,
|
|
|
|
int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
GridBuilder builder(gridView);
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::SplitBuilder
|
|
|
|
Grid<ParentBuilder>::AddSplit(enum orientation orientation, float spacing,
|
|
|
|
int32 column, int32 row, int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
SplitBuilder builder(orientation, spacing);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
2010-11-17 19:29:06 +03:00
|
|
|
}
|
2010-08-17 22:43:41 +04:00
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::SplitBuilder
|
|
|
|
Grid<ParentBuilder>::AddSplit(BSplitView* splitView, int32 column, int32 row,
|
|
|
|
int32 columnCount, int32 rowCount)
|
|
|
|
{
|
|
|
|
SplitBuilder builder(splitView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
|
|
|
|
return builder;
|
2010-11-17 19:29:06 +03:00
|
|
|
}
|
2009-06-17 23:38:51 +04:00
|
|
|
|
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::AddGlue(int32 column, int32 row, int32 columnCount,
|
|
|
|
int32 rowCount)
|
|
|
|
{
|
|
|
|
fLayout->AddItem(BSpaceLayoutItem::CreateGlue(), column, row, columnCount,
|
|
|
|
rowCount);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetColumnWeight(int32 column, float weight)
|
|
|
|
{
|
|
|
|
fLayout->SetColumnWeight(column, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetRowWeight(int32 row, float weight)
|
|
|
|
{
|
|
|
|
fLayout->SetRowWeight(row, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetInsets(float left, float top, float right,
|
|
|
|
float bottom)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(left, top, right, bottom);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-10 00:58:52 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetInsets(float horizontal, float vertical)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(horizontal, vertical);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetInsets(float insets)
|
|
|
|
{
|
|
|
|
fLayout->SetInsets(insets);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-04 13:53:34 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetExplicitMinSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitMinSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetExplicitMaxSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitMaxSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetExplicitPreferredSize(BSize size)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitPreferredSize(size);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-04 20:22:32 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Grid<ParentBuilder>::ThisBuilder&
|
|
|
|
Grid<ParentBuilder>::SetExplicitAlignment(BAlignment alignment)
|
|
|
|
{
|
|
|
|
fLayout->SetExplicitAlignment(alignment);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Grid<ParentBuilder>::operator BGridLayout*()
|
|
|
|
{
|
|
|
|
return fLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - Split
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Split<ParentBuilder>::Split(enum orientation orientation, float spacing)
|
|
|
|
:
|
|
|
|
fView(new BSplitView(orientation, spacing))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Split<ParentBuilder>::Split(BSplitView* view)
|
|
|
|
:
|
|
|
|
fView(view)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
BSplitView*
|
|
|
|
Split<ParentBuilder>::View() const
|
|
|
|
{
|
|
|
|
return fView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
2010-08-17 22:43:41 +04:00
|
|
|
Split<ParentBuilder>::GetView(BView** _view)
|
|
|
|
{
|
|
|
|
*_view = fView;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::GetSplitView(BSplitView** _view)
|
2009-06-17 23:38:51 +04:00
|
|
|
{
|
|
|
|
*_view = fView;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::Add(BView* view)
|
|
|
|
{
|
|
|
|
fView->AddChild(view);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::Add(BView* view, float weight)
|
|
|
|
{
|
|
|
|
fView->AddChild(view, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::Add(BLayoutItem* item)
|
|
|
|
{
|
|
|
|
fView->AddChild(item);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::Add(BLayoutItem* item, float weight)
|
|
|
|
{
|
|
|
|
fView->AddChild(item, weight);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GroupBuilder
|
|
|
|
Split<ParentBuilder>::AddGroup(enum orientation orientation, float spacing,
|
|
|
|
float weight)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GroupBuilder builder(new BGroupLayout(orientation, spacing));
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
2010-08-17 22:43:41 +04:00
|
|
|
fView->AddChild(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GroupBuilder
|
|
|
|
Split<ParentBuilder>::AddGroup(BGroupView* groupView, float weight)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fView->AddChild(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GroupBuilder
|
|
|
|
Split<ParentBuilder>::AddGroup(BGroupLayout* groupLayout, float weight)
|
|
|
|
{
|
|
|
|
GroupBuilder builder(groupLayout);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fView->AddChild(builder.Layout(), weight);
|
2009-06-17 23:38:51 +04:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GridBuilder
|
|
|
|
Split<ParentBuilder>::AddGrid(float horizontalSpacing, float verticalSpacing,
|
|
|
|
float weight)
|
|
|
|
{
|
2010-08-17 22:43:41 +04:00
|
|
|
GridBuilder builder(new BGridLayout(horizontalSpacing, verticalSpacing));
|
2009-06-17 23:38:51 +04:00
|
|
|
builder.SetParent(this);
|
2010-08-17 22:43:41 +04:00
|
|
|
fView->AddChild(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GridBuilder
|
|
|
|
Split<ParentBuilder>::AddGrid(BGridView* gridView, float weight)
|
|
|
|
{
|
|
|
|
GridBuilder builder(gridView);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fView->AddChild(builder.Layout(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::GridBuilder
|
|
|
|
Split<ParentBuilder>::AddGrid(BGridLayout* layout, float weight)
|
|
|
|
{
|
|
|
|
GridBuilder builder(layout);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fView->AddChild(builder.Layout(), weight);
|
2009-06-17 23:38:51 +04:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::SplitBuilder
|
|
|
|
Split<ParentBuilder>::AddSplit(enum orientation orientation, float spacing,
|
|
|
|
float weight)
|
|
|
|
{
|
|
|
|
SplitBuilder builder(orientation, spacing);
|
|
|
|
builder.SetParent(this);
|
|
|
|
fView->AddChild(builder.View(), weight);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetCollapsible(bool collapsible)
|
|
|
|
{
|
|
|
|
fView->SetCollapsible(collapsible);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetCollapsible(int32 index, bool collapsible)
|
|
|
|
{
|
|
|
|
fView->SetCollapsible(index, collapsible);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetCollapsible(int32 first, int32 last, bool collapsible)
|
|
|
|
{
|
|
|
|
fView->SetCollapsible(first, last, collapsible);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-23 14:56:22 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetInsets(float left, float top, float right,
|
|
|
|
float bottom)
|
|
|
|
{
|
|
|
|
fView->SetInsets(left, top, right, bottom);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-10 00:58:52 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetInsets(float horizontal, float vertical)
|
|
|
|
{
|
|
|
|
fView->SetInsets(horizontal, vertical);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Split<ParentBuilder>::ThisBuilder&
|
|
|
|
Split<ParentBuilder>::SetInsets(float insets)
|
|
|
|
{
|
|
|
|
fView->SetInsets(insets);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
template<typename ParentBuilder>
|
|
|
|
Split<ParentBuilder>::operator BSplitView*()
|
|
|
|
{
|
|
|
|
return fView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 17:29:37 +03:00
|
|
|
// #pragma mark - Menu
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
Menu<ParentBuilder>::Menu(BMenu* menu)
|
|
|
|
:
|
|
|
|
fMenu(menu)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ThisBuilder&
|
|
|
|
Menu<ParentBuilder>::GetMenu(BMenu*& _menu)
|
|
|
|
{
|
|
|
|
_menu = fMenu;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ItemBuilder
|
|
|
|
Menu<ParentBuilder>::AddItem(BMenuItem* item)
|
|
|
|
{
|
|
|
|
fMenu->AddItem(item);
|
|
|
|
return MenuItem<ParentBuilder>(this->fParent, fMenu, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ItemBuilder
|
|
|
|
Menu<ParentBuilder>::AddItem(BMenu* menu)
|
|
|
|
{
|
|
|
|
if (!fMenu->AddItem(menu))
|
|
|
|
throw std::bad_alloc();
|
|
|
|
|
|
|
|
return MenuItem<ParentBuilder>(this->fParent, fMenu,
|
|
|
|
fMenu->ItemAt(fMenu->CountItems() - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ItemBuilder
|
|
|
|
Menu<ParentBuilder>::AddItem(const char* label, BMessage* message,
|
|
|
|
char shortcut, uint32 modifiers)
|
|
|
|
{
|
|
|
|
BMenuItem* item = new BMenuItem(label, message, shortcut, modifiers);
|
|
|
|
if (!fMenu->AddItem(item))
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
return MenuItem<ParentBuilder>(this->fParent, fMenu, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ItemBuilder
|
|
|
|
Menu<ParentBuilder>::AddItem(const char* label, uint32 messageWhat,
|
|
|
|
char shortcut, uint32 modifiers)
|
|
|
|
{
|
|
|
|
BMessage* message = new BMessage(messageWhat);
|
|
|
|
BMenuItem* item;
|
|
|
|
try {
|
|
|
|
item = new BMenuItem(label, message, shortcut, modifiers);
|
|
|
|
} catch (...) {
|
|
|
|
delete message;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fMenu->AddItem(item))
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
return MenuItem<ParentBuilder>(this->fParent, fMenu, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::ThisBuilder&
|
|
|
|
Menu<ParentBuilder>::AddSeparator()
|
|
|
|
{
|
|
|
|
fMenu->AddSeparatorItem();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::MenuBuilder
|
|
|
|
Menu<ParentBuilder>::AddMenu(BMenu* menu)
|
|
|
|
{
|
|
|
|
if (!fMenu->AddItem(menu))
|
|
|
|
throw std::bad_alloc();
|
|
|
|
|
|
|
|
MenuBuilder builder(menu);
|
|
|
|
builder.SetParent(this);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename Menu<ParentBuilder>::MenuBuilder
|
|
|
|
Menu<ParentBuilder>::AddMenu(const char* title, menu_layout layout)
|
|
|
|
{
|
|
|
|
BMenu* menu = new BMenu(title, layout);
|
|
|
|
if (!fMenu->AddItem(menu)) {
|
|
|
|
delete menu;
|
|
|
|
throw std::bad_alloc();
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuBuilder builder(menu);
|
|
|
|
builder.SetParent(this);
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark - MenuItem
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
MenuItem<ParentBuilder>::MenuItem(ParentBuilder* parentBuilder, BMenu* menu,
|
|
|
|
BMenuItem* item)
|
|
|
|
:
|
|
|
|
Menu<ParentBuilder>(menu),
|
|
|
|
fMenuItem(item)
|
|
|
|
{
|
2012-11-16 02:55:57 +04:00
|
|
|
this->SetParent(parentBuilder);
|
2010-11-19 17:29:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename MenuItem<ParentBuilder>::ThisBuilder&
|
|
|
|
MenuItem<ParentBuilder>::GetItem(BMenuItem*& _item)
|
|
|
|
{
|
|
|
|
_item = fMenuItem;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename ParentBuilder>
|
|
|
|
typename MenuItem<ParentBuilder>::ThisBuilder&
|
|
|
|
MenuItem<ParentBuilder>::SetEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
fMenuItem->SetEnabled(enabled);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-17 23:38:51 +04:00
|
|
|
} // namespace BLayoutBuilder
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _LAYOUT_BUILDER_H
|