neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
style.hpp
Go to the documentation of this file.
1// style.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 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 <unordered_map>
24#include "i_style.hpp"
25#include "palette.hpp"
26
27namespace neogfx
28{
29 class style : public i_style
30 {
31 public:
32 define_declared_event(Changed, changed, style_aspect)
33 public:
34 style(std::string const& aName);
35 style(std::string const& aName, const i_style& aOther);
36 style(const i_style& aOther);
37 style(const style& aOther);
38 virtual ~style();
39 public:
40 style& operator=(const i_style& aOther);
41 public:
42 bool operator==(const i_style& aOther) const;
43 bool operator!=(const i_style& aOther) const;
44 public:
45 std::string const& name() const final;
46 const margin_list& all_margin() const final;
47 const neogfx::margin& margin(margin_role aMarginRole) const final;
48 void set_margin(margin_role aMarginRole, const neogfx::margin& aMargin) final;
49 const border_list& all_border() const final;
50 const neogfx::border& border(border_role aBorderRole) const final;
51 void set_border(border_role aBorderRole, const neogfx::border& aBorder) final;
52 const padding_list& all_padding() const final;
53 const neogfx::padding& padding(padding_role aPaddingRole) const final;
54 void set_padding(padding_role aPaddingRole, const neogfx::padding& aPadding) final;
55 const size& spacing() const final;
56 void set_spacing(const size& aSpacing) final;
57 const i_palette& palette() const final;
59 void set_palette(const i_palette& aPalette) final;
60 void set_palette_color(color_role aRole, const optional_color& aColor) final;
61 bool font_available(font_role aRole) const final;
62 const neogfx::font_info& font_info(font_role aRole) const final;
64 void set_font_info(font_role aRole, const neogfx::font_info& aFontInfo) final;
65 const neogfx::font& font(font_role aRole) const final;
66 private:
67 void handle_change(style_aspect aAspect);
68 private:
69 std::string iName;
70 margin_list iMargin;
71 border_list iBorder;
72 padding_list iPadding;
73 size iSpacing;
74 neogfx::palette iPalette;
75 mutable std::unordered_map<font_role, optional_font_info> iFontInfo;
76 mutable std::unordered_map<font_role, optional_font> iFont;
77 };
78}
const neogfx::font & font() const
Definition i_style.hpp:119
std::array< neogfx::padding, static_cast< std::size_t >(padding_role::COUNT)> padding_list
Definition i_style.hpp:85
const neogfx::font_info & font_info() const
Definition i_style.hpp:111
declare_event(changed, style_aspect) public typedef std::array< neogfx::border, static_cast< std::size_t >(border_role::COUNT)> border_list
Definition i_style.hpp:81
const margin_list & all_margin() const final
style & operator=(const i_style &aOther)
std::string const & name() const final
void set_palette_color(color_role aRole, const optional_color &aColor) final
style(const style &aOther)
bool font_available(font_role aRole) const final
const size & spacing() const final
style(const i_style &aOther)
void set_padding(padding_role aPaddingRole, const neogfx::padding &aPadding) final
const border_list & all_border() const final
define_declared_event(Changed, changed, style_aspect) public style(std::string const &aName, const i_style &aOther)
const i_optional< neogfx::font_info > & maybe_font_info(font_role aRole) const final
void set_border(border_role aBorderRole, const neogfx::border &aBorder) final
void set_margin(margin_role aMarginRole, const neogfx::margin &aMargin) final
void set_font_info(font_role aRole, const neogfx::font_info &aFontInfo) final
virtual ~style()
bool operator==(const i_style &aOther) const
const padding_list & all_padding() const final
void set_spacing(const size &aSpacing) final
void set_palette(const i_palette &aPalette) final
bool operator!=(const i_style &aOther) const
style_aspect
Definition i_style.hpp:31
Definition plf_hive.h:79
#define define_declared_event(name, declName,...)
Definition event.hpp:195