neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_style.hpp
Go to the documentation of this file.
1// i_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 <neogfx/core/event.hpp>
27
28namespace neogfx
29{
30 enum class style_aspect : uint32_t
31 {
32 None = 0x0000,
33 Geometry = 0x0001,
34 Font = 0x0002,
35 Color = 0x0004,
37 };
38
39 enum class box_role : uint32_t
40 {
41 Layout = 0x0000,
42 Widget = 0x0001,
43 Window = 0x0002,
44 Dialog = 0x0003,
45 Menu = 0x0004,
46 Dock = 0x0005,
47
48 COUNT
49 };
50
54
55 inline constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
56 {
57 return static_cast<style_aspect>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
58 }
59
60 inline constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
61 {
62 return static_cast<style_aspect>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
63 }
64
65 enum class font_role : uint32_t
66 {
67 Caption,
68 Menu,
69 Toolbar,
71 Widget
72 };
73
75
76 class i_style
77 {
78 public:
79 struct no_font_for_role : std::runtime_error { no_font_for_role() : std::runtime_error{ "neogfx::i_style::no_font_for_role" } {} };
80 public:
82 public:
83 typedef std::array<neogfx::margin, static_cast<std::size_t>(margin_role::COUNT)> margin_list;
84 typedef std::array<neogfx::border, static_cast<std::size_t>(border_role::COUNT)> border_list;
85 typedef std::array<neogfx::padding, static_cast<std::size_t>(padding_role::COUNT)> padding_list;
86 public:
87 virtual ~i_style() = default;
88 public:
89 virtual std::string const& name() const = 0;
90 virtual const margin_list& all_margin() const = 0;
91 virtual const neogfx::margin& margin(margin_role aMarginRole) const = 0;
92 virtual void set_margin(margin_role aMarginRole, const neogfx::margin& aMargin) = 0;
93 virtual const border_list& all_border() const = 0;
94 virtual const neogfx::border& border(border_role aBorderRole) const = 0;
95 virtual void set_border(border_role aBorderRole, const neogfx::border& aBorder) = 0;
96 virtual const padding_list& all_padding() const = 0;
97 virtual const neogfx::padding& padding(padding_role aPaddingRole) const = 0;
98 virtual void set_padding(padding_role aPaddingRole, const neogfx::padding& aPadding) = 0;
99 virtual const size& spacing() const = 0;
100 virtual void set_spacing(const size& aSpacing) = 0;
101 virtual const i_palette& palette() const = 0;
102 virtual i_palette& palette() = 0;
103 virtual void set_palette(const i_palette& aPalette) = 0;
104 virtual void set_palette_color(color_role aRole, const optional_color& aColor) = 0;
105 virtual bool font_available(font_role aRole) const = 0;
106 virtual const neogfx::font_info& font_info(font_role aRole) const = 0;
108 virtual void set_font_info(font_role aRole, const neogfx::font_info& aFontInfo) = 0;
109 virtual const neogfx::font& font(font_role aRole) const = 0;
110 public:
111 const neogfx::font_info& font_info() const
112 {
114 }
115 void set_font_info(const neogfx::font_info& aFontInfo)
116 {
118 }
119 const neogfx::font& font() const
120 {
121 return font(font_role::Widget);
122 }
123 };
124}
void set_font_info(const neogfx::font_info &aFontInfo)
Definition i_style.hpp:115
virtual const padding_list & all_padding() const =0
virtual ~i_style()=default
virtual const neogfx::padding & padding(padding_role aPaddingRole) const =0
virtual std::string const & name() const =0
virtual const neogfx::font_info & font_info(font_role aRole) const =0
virtual const neogfx::font & font(font_role aRole) const =0
virtual void set_font_info(font_role aRole, const neogfx::font_info &aFontInfo)=0
virtual const neogfx::border & border(border_role aBorderRole) const =0
virtual i_palette & palette()=0
virtual bool font_available(font_role aRole) const =0
const neogfx::font & font() const
Definition i_style.hpp:119
virtual const i_optional< neogfx::font_info > & maybe_font_info(font_role aRole) const =0
virtual void set_palette(const i_palette &aPalette)=0
virtual const size & spacing() const =0
virtual void set_padding(padding_role aPaddingRole, const neogfx::padding &aPadding)=0
virtual void set_palette_color(color_role aRole, const optional_color &aColor)=0
virtual const neogfx::margin & margin(margin_role aMarginRole) const =0
virtual const i_palette & palette() const =0
virtual void set_spacing(const size &aSpacing)=0
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
virtual void set_margin(margin_role aMarginRole, const neogfx::margin &aMargin)=0
virtual void set_border(border_role aBorderRole, const neogfx::border &aBorder)=0
virtual const border_list & all_border() const =0
virtual const margin_list & all_margin() const =0
style_aspect
Definition i_style.hpp:31
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:60
optional< font_role > optional_font_role
Definition i_style.hpp:74
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:55
#define declare_event(declName,...)
Definition i_event.hpp:305