DockingLayout.h
1/* Copyright (C) 2015 Marc Boris Duerner
2 Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 As a special exception, you may use this file as part of a free
10 software library without restriction. Specifically, if other files
11 instantiate templates or use macros or inline functions from this
12 file, or you compile this file and link it with other files to
13 produce an executable, this file does not by itself cause the
14 resulting executable to be covered by the GNU General Public
15 License. This exception does not however invalidate any other
16 reasons why the executable file might be covered by the GNU Library
17 General Public License.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 02110-1301 USA
28*/
29
30#ifndef Pt_Forms_DockingLayout_H
31#define Pt_Forms_DockingLayout_H
32
33#include <Pt/Forms/Api.h>
34#include <Pt/Forms/Layout.h>
35#include <map>
36
37namespace Pt {
38
39namespace Forms {
40
68class PT_FORMS_API DockingLayout : public Layout
69{
70 typedef Layout Base;
71
72 public:
76 {
79 None = 0,
80
84
88
92
96
100 };
101
102 public:
106
109 virtual ~DockingLayout();
110
115 void addItem(Control& control, DockMode ds);
116
119 void removeItem(Control& control);
120
123 void setDockingStyle(Control& control, DockMode ds);
124
125 protected:
128 virtual void onAddControl(Control& control);
129
132 virtual void onRemoveControl(Control& control);
133
136 virtual Gfx::SizeF onMeasure(const SizePolicy& policy);
137
140 virtual void onLayout(const Gfx::RectF& rect);
141
142 private:
143 std::map<Control*, DockMode> _docking;
144 DockMode _defaultDocking;
145};
146
147} // namespace
148
149} // namespace
150
151#endif // include guard
Reusable view used as application content.
Definition Control.h:107
void removeItem(Control &control)
Detaches control without destroying it.
DockMode
Edge or leftover region assigned to a child.
Definition DockingLayout.h:76
@ Bottom
Docks to the bottom edge.
Definition DockingLayout.h:95
@ Fill
Fills leftover space after edge docks.
Definition DockingLayout.h:99
@ Top
Docks to the top edge.
Definition DockingLayout.h:87
@ Left
Docks to the left edge.
Definition DockingLayout.h:83
@ None
The child is not docked.
Definition DockingLayout.h:79
@ Right
Docks to the right edge.
Definition DockingLayout.h:91
void addItem(Control &control, DockMode ds)
Attaches control with dock mode ds.
DockingLayout(DockMode ds=None)
Creates an empty docking layout.
virtual void onLayout(const Gfx::RectF &rect)
Assigns edge docks, then leftover space to Fill children.
virtual void onAddControl(Control &control)
Handles attachment of control.
void setDockingStyle(Control &control, DockMode ds)
Sets the dock mode of attached control to ds.
virtual void onRemoveControl(Control &control)
Removes the stored dock mode for control.
virtual Gfx::SizeF onMeasure(const SizePolicy &policy)
Measures docked children and leftover Fill space.
virtual ~DockingLayout()
Destroys the layout. Attached controls are not destroyed.
Constraint used when measuring a control.
Definition SizePolicy.h:48
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33