neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_skin.hpp
Go to the documentation of this file.
1// i_skin.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>
29
30namespace neogfx
31{
32 class i_skin
33 {
34 public:
35 struct no_fallback : std::logic_error { no_fallback() : std::logic_error{ "neogfx::i_skin::no_fallback" } {} };
36 public:
37 virtual ~i_skin() = default;
38 public:
39 virtual std::string const& name() const = 0;
40 virtual bool has_fallback() const = 0;
41 virtual i_skin& fallback() = 0;
42 public:
43 virtual void activate() = 0;
44 virtual void deactivate() = 0;
45 public:
46 virtual size preferred_size(skin_element aElement, optional_size const& aDesiredSize = {}) const = 0;
47 public:
48 virtual void draw_scrollbar(i_graphics_context& aGc, const i_skinnable_item& aItem, const i_scrollbar& aScrollbar) const = 0;
49 virtual void draw_check_box(i_graphics_context& aGc, const i_skinnable_item& aItem, const button_checked_state& aCheckedState) const = 0;
50 virtual void draw_radio_button(i_graphics_context& aGc, const i_skinnable_item& aItem, const button_checked_state& aCheckedState) const = 0;
51 virtual void draw_tree_expander(i_graphics_context& aGc, const i_skinnable_item& aItem, bool aExpandedState) const = 0;
52 virtual void draw_progress_bar(i_graphics_context& aGc, const i_skinnable_item& aItem, const i_progress_bar& aProgressBar) const = 0;
53 virtual void draw_separators(i_graphics_context& aGc, const i_skinnable_item& aItem, const i_layout& aLayout) const = 0;
54 };
55
56 typedef std::pair<uint32_t, uint32_t> separator_index;
57
58 inline rect separator_rect(const i_layout& aLayout, separator_index aSeparator)
59 {
60 rect r1(aLayout.item_at(aSeparator.first).position(), aLayout.item_at(aSeparator.first).extents());
61 rect r2(aLayout.item_at(aSeparator.second).position(), aLayout.item_at(aSeparator.second).extents());
63 {
64 rect r3(point(r1.right(), r1.top()), size(r2.left() - r1.right(), r1.height()));
65 rect r4 = r3;
66 r4.x -= r3.width();
67 r4.cx *= 3.0;
68 return r4;
69 }
70 else
71 {
72 rect r3(point(r1.left(), r1.bottom()), size(r2.width(), r2.top() - r1.bottom()));
73 rect r4 = r3;
74 r4.y -= r3.height();
75 r4.cy *= 3.0;
76 return r4;
77 }
78 }
79}
coordinate_type x
coordinate_type y
dimension_type height() const
coordinate_type bottom() const
dimension_type width() const
coordinate_type right() const
coordinate_type top() const
coordinate_type left() const
dimension_type cy
dimension_type cx
virtual layout_direction direction() const =0
virtual const i_layout_item & item_at(layout_item_index aIndex) const =0
virtual size preferred_size(skin_element aElement, optional_size const &aDesiredSize={}) const =0
virtual void draw_tree_expander(i_graphics_context &aGc, const i_skinnable_item &aItem, bool aExpandedState) const =0
virtual void draw_progress_bar(i_graphics_context &aGc, const i_skinnable_item &aItem, const i_progress_bar &aProgressBar) const =0
virtual ~i_skin()=default
virtual void deactivate()=0
virtual void draw_check_box(i_graphics_context &aGc, const i_skinnable_item &aItem, const button_checked_state &aCheckedState) const =0
virtual void draw_scrollbar(i_graphics_context &aGc, const i_skinnable_item &aItem, const i_scrollbar &aScrollbar) const =0
virtual void draw_separators(i_graphics_context &aGc, const i_skinnable_item &aItem, const i_layout &aLayout) const =0
virtual i_skin & fallback()=0
virtual void activate()=0
virtual void draw_radio_button(i_graphics_context &aGc, const i_skinnable_item &aItem, const button_checked_state &aCheckedState) const =0
virtual std::string const & name() const =0
virtual bool has_fallback() const =0
rect separator_rect(const i_layout &aLayout, separator_index aSeparator)
Definition i_skin.hpp:58
std::pair< uint32_t, uint32_t > separator_index
Definition i_skin.hpp:56
basic_point< coordinate > point