neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
anchorable.hpp
Go to the documentation of this file.
1
// anchorable.hpp
2
/*
3
neogfx C++ App/Game Engine
4
Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6
This program is free software: you can redistribute it and / or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <
neogfx/neogfx.hpp
>
23
#include <
neogfx/gui/layout/i_anchorable.hpp
>
24
25
namespace
neogfx
26
{
27
template
<
typename
Base>
28
class
anchorable
:
public
Base
29
{
30
typedef
anchorable<Base>
self_type;
31
typedef
Base
base_type;
32
// types
33
public
:
34
using
typename base_type::abstract_type;
35
typedef
neolib::map<string, i_anchor*>
anchor_map_type
;
36
// operations
37
public
:
38
~anchorable
()
39
{
40
}
41
public
:
42
using
base_type::anchor_to;
43
i_anchor&
anchor_to
(
i_anchorable
& aRhs,
const
i_string
& aLhsAnchor,
anchor_constraint_function
aLhsFunction,
const
i_string
& aRhsAnchor,
anchor_constraint_function
aRhsFunction)
override
44
{
45
auto
lhsAnchor =
anchors
().find(aLhsAnchor);
46
auto
rhsAnchor = aRhs.
anchors
().find(aRhsAnchor);
47
if
(lhsAnchor ==
anchors
().end())
48
throw
anchor_not_found
(aLhsAnchor);
49
if
(rhsAnchor == aRhs.
anchors
().end())
50
throw
anchor_not_found
(aRhsAnchor);
51
rhsAnchor->second()->constrain(*lhsAnchor->second(), aLhsFunction, aRhsFunction);
52
return
*lhsAnchor->second();
53
}
54
// state
55
public
:
56
const
anchor_map_type
&
anchors
()
const override
57
{
58
return
iAnchors;
59
}
60
anchor_map_type
&
anchors
()
override
61
{
62
return
iAnchors;
63
}
64
// state
65
private
:
66
anchor_map_type
iAnchors;
67
};
68
}
neogfx::anchorable
Definition
anchorable.hpp:29
neogfx::anchorable::~anchorable
~anchorable()
Definition
anchorable.hpp:38
neogfx::anchorable::anchors
anchor_map_type & anchors() override
Definition
anchorable.hpp:60
neogfx::anchorable::anchors
const anchor_map_type & anchors() const override
Definition
anchorable.hpp:56
neogfx::anchorable::anchor_map_type
neolib::map< string, i_anchor * > anchor_map_type
Definition
anchorable.hpp:35
neogfx::anchorable::anchor_to
i_anchor & anchor_to(i_anchorable &aRhs, const i_string &aLhsAnchor, anchor_constraint_function aLhsFunction, const i_string &aRhsAnchor, anchor_constraint_function aRhsFunction) override
Definition
anchorable.hpp:43
neogfx::i_anchorable
Definition
i_anchorable.hpp:34
neogfx::i_anchorable::anchors
virtual const anchor_map_type & anchors() const =0
neolib::i_string
Definition
i_string.hpp:49
neolib::map
Definition
map.hpp:48
i_anchorable.hpp
neogfx
Definition
action.hpp:28
neogfx::anchor_constraint_function
anchor_constraint_function
Definition
i_anchor.hpp:31
neogfx::Base
@ Base
Definition
i_palette.hpp:35
neogfx.hpp
neogfx::anchor_not_found
Definition
i_anchorable.hpp:31
include
neogfx
gui
layout
anchorable.hpp
Generated by
1.9.8