Boost.UI
User Interface Boost library
layout.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_LAYOUT_HPP
9 #define BOOST_UI_LAYOUT_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 namespace boost {
18 namespace ui {
19 
20 class widget;
21 class box_layout;
22 
25 
26 class BOOST_UI_DECL layout
27 {
28 public:
29  class item;
30 };
31 
34 
35 class BOOST_UI_DECL layout::item
36 {
37  class impl;
38 
39 public:
40  item();
42  item(const widget& w);
44  item(const box_layout& l);
45  ~item();
46 
47 #ifndef DOXYGEN
48  item(const item& other);
49  item& operator=(const item& other);
50 #endif
51 
53  item& append(const item& item);
55  { return append(item); }
57 
60  { return margin(0); }
61 
63  item& margin(int all)
64  { return margin(all, all); }
65  item& margin(int vertical, int horizontal)
66  { return margin(vertical, horizontal, vertical, horizontal); }
67  item& margin(int top, int right, int bottom, int left);
69 
71  item& margin_px(int all)
72  { return margin_px(all, all); }
73  item& margin_px(int vertical, int horizontal)
74  { return margin_px(vertical, horizontal, vertical, horizontal); }
75  item& margin_px(int top, int right, int bottom, int left);
77 
79  item& stretch(int value = 1);
80 
82  item& left();
83  item& right();
84  item& top();
85  item& bottom();
86  item& vcenter();
87  item& hcenter();
88  item& center();
89  item& justify();
91 
92 private:
93  impl* m_impl;
94  widget* m_widget;
95  box_layout* m_layout;
96 #ifndef DOXYGEN
97  friend class box_layout;
98 #endif
99 };
100 
103 
104 class BOOST_UI_DECL box_layout : public layout
105 {
106 public:
109  { return ui::layout::item(*this); }
110 
112  box_layout& append(const item& item);
114  { return append(item); }
116 
117 protected:
118 #ifndef DOXYGEN
119  explicit box_layout(bool horizontal);
120  explicit box_layout(widget& parent, bool horizontal);
121 #endif
122 
123 private:
124  class impl;
125  impl* m_impl;
126 };
127 
130 
131 class BOOST_UI_DECL hbox : public box_layout
132 {
133 public:
134  hbox() : box_layout(true) {}
135 
137  explicit hbox(widget& parent) : box_layout(parent, true) {}
138 };
139 
142 
143 class BOOST_UI_DECL vbox : public box_layout
144 {
145 public:
146  vbox() : box_layout(false) {}
147 
149  explicit vbox(widget& parent) : box_layout(parent, false) {}
150 };
151 
152 } // namespace ui
153 } // namespace boost
154 
155 #endif // BOOST_UI_LAYOUT_HPP
boost::ui::layout::item::margin
item & margin(int all)
Sets layout item margin in spaces, that are backed-dependent.
Definition: layout.hpp:63
config.hpp
Configuration options.
boost::ui::box_layout::layout
item layout()
Returns layout::item with this widget.
Definition: layout.hpp:108
boost::ui::vbox::vbox
vbox(widget &parent)
Constructs and sets layout to the widget.
Definition: layout.hpp:149
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::box_layout
Abstract vertical or horizontal box layout.
Definition: layout.hpp:104
boost::ui::vbox
Vertical box layout.
Definition: layout.hpp:143
boost::ui::hbox::hbox
hbox(widget &parent)
Constructs and sets layout to the widget.
Definition: layout.hpp:137
boost::ui::hbox
Horizontal box layout.
Definition: layout.hpp:131
boost::ui::layout::item
Layout item with arrangement parameters.
Definition: layout.hpp:35
boost::ui::layout
Base class for all layouts.
Definition: layout.hpp:26
boost::ui::layout::item::no_margin
item & no_margin()
Resets layout item margin.
Definition: layout.hpp:59
boost::ui::layout::item::margin_px
item & margin_px(int vertical, int horizontal)
Sets layout item margin in pixels.
Definition: layout.hpp:73
boost::ui::box_layout::operator<<
box_layout & operator<<(const item &item)
Appends a layout item to the layout.
Definition: layout.hpp:113
boost::ui::layout::item::margin_px
item & margin_px(int all)
Sets layout item margin in pixels.
Definition: layout.hpp:71
boost::ui::widget
Base class for all widgets.
Definition: widget.hpp:45
boost::ui::layout::item::operator<<
item & operator<<(const item &item)
Appends subitem.
Definition: layout.hpp:54
boost::ui::layout::item::margin
item & margin(int vertical, int horizontal)
Sets layout item margin in spaces, that are backed-dependent.
Definition: layout.hpp:65