cgv
Loading...
Searching...
No Matches
layout.h
1#pragma once
2
3#include <cgv/base/base.h>
4#include <cgv/base/group.h>
5#include <cgv/gui/resizable.h>
6#include <cgv/signal/signal.h>
7#include <cgv/signal/rebind.h>
8#include <cgv/data/ref_ptr.h>
9#include <cgv/type/variant.h>
10
11#include <cgv/gui/layout_spacings.h>
12
13#include "lib_begin.h"
14
15namespace cgv {
16 namespace gui {
17
34 {
35 LH_HSHRINK = 1<<0,
36 LH_HEXPAND = 1<<1,
37 LH_HFILL = 1<<2,
38 LH_LEFT = 1<<3,
39 LH_CENTER = 1<<4,
40 LH_RIGHT = 1<<5,
41
42 LH_VSHRINK = 1<<6,
43 LH_VEXPAND = 1<<7,
44 LH_VFILL = 1<<8,
45 LH_TOP = 1<<9,
46 LH_MIDDLE = 1<<10,
47 LH_BOTTOM = 1<<11,
48
49 LH_HHINTS = 0,
50 LH_VHINTS = 6
51 };
52
53 // abstract class to define a layout on containers.
54 class CGV_API layout: public cgv::base::base
55 {
56 public:
57 // constructor that sets a container
58 layout(cgv::base::group_ptr container = 0);
59 // empty destructor
60 ~layout();
61
62 // set a container to be layouted
63 void set_container(cgv::base::group_ptr container);
64
65 // set the spacing parameters
66 void set_spacings(const layout_spacings spacings);
67
68 // update children
69 virtual void update() {};
70
71 // resize
72 void resize(int w, int h);
73
74 virtual std::string get_property_declarations();
75 virtual bool set_void(const std::string &property, const std::string &value_type, const void *value_ptr);
76 virtual bool get_void(const std::string &property, const std::string &value_type, void *value_ptr);
77
78 protected:
79 cgv::base::group_ptr container;
80 int w, h, true_w, true_h;
81 int min_w, min_h, default_w, default_h;
82 layout_spacings spacings;
83 std::string spacings_name;
84
85 // get the layout hints for a child
86 int get_child_layout_hints(cgv::base::base_ptr child);
87
88 // get the layouted container
89 cgv::base::group_ptr get_container();
90
91 // get a child from the container.
92 cgv::base::base_ptr get_child(unsigned int i);
93
94 // get the size of a child
95 void get_child_size(const cgv::base::base_ptr child, int &width, int &height);
96 // set the size of a child
97 void set_child_size(const cgv::base::base_ptr child, int width, int height);
98
99 // get the default size of a child
100 void get_child_default_size(const cgv::base::base_ptr child, int &width, int &height);
101
102 // get the position of a child
103 void get_child_position(const cgv::base::base_ptr child, int &x, int &y);
104 // set the position of a child
105 void set_child_position(const cgv::base::base_ptr child, int x, int y);
106
107 // get the mimimum size of a child
108 void get_child_minimum_size(const cgv::base::base_ptr child, int &width, int &height);
109 };
110
113
114
115 }
116}
117
118
119#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
Definition base.h:75
virtual void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
Definition layout.h:69
cgv::data::ref_ptr< layout > layout_ptr
ref counted pointer to layout
Definition layout.h:112
layout_hint
Allowed hints: s - horizontal shrink S - vertical shrink x - horizontal expand X - vertical expand f ...
Definition layout.h:34
the cgv namespace
Definition print.h:11