neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
group_box.hpp
Go to the documentation of this file.
1// group_box.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>
26#include "widget.hpp"
27
28namespace neogfx
29{
30 class group_box : public widget<>
31 {
33 private:
35 private:
36 typedef std::unique_ptr<neogfx::label> label_ptr;
37 typedef std::unique_ptr<neogfx::check_box> check_box_ptr;
38 class item_container : public widget<>
39 {
40 public:
41 item_container(group_box& aParent);
42 protected:
43 void paint(i_graphics_context& aGc) const override;
44 protected:
45 color palette_color(color_role aColorRole) const override;
46 private:
47 group_box& iParent;
48 };
49 private:
50 static constexpr scalar DEFAULT_PADDING = 5.0;
51 public:
52 struct not_checkable : std::logic_error { not_checkable() : std::logic_error("neogfx::group_box::not_checkable") {} };
53 public:
54 group_box(std::string const& aText = std::string());
55 group_box(i_widget& aParent, std::string const& aText = std::string());
56 group_box(i_layout& aLayout, std::string const& aText = std::string());
57 public:
58 i_string const& text() const;
59 void set_text(i_string const& aText);
60 bool is_checkable() const;
61 void set_checkable(bool aCheckable, bool aUpdateItemsEnabledState = false);
62 const neogfx::label& label() const;
63 neogfx::label& label();
64 bool has_check_box() const;
67 void set_item_layout(i_layout& aItemLayout);
68 void set_item_layout(i_ref_ptr<i_layout> const& aItemLayout);
69 const i_layout& item_layout() const;
71 template <typename LayoutT, typename... Args>
72 LayoutT& with_item_layout(Args&&... args)
73 {
74 set_item_layout(to_abstract(make_ref<LayoutT>(std::forward<Args>(args)...)));
75 return static_cast<LayoutT&>(item_layout());
76 }
77 public:
78 neogfx::size_policy size_policy() const override;
79 public:
80 color palette_color(color_role aColorRole) const override;
81 public:
82 virtual bool has_border_color() const;
83 virtual color border_color() const;
84 virtual void set_border_color(const optional_color& aBorderColor);
85 virtual bool has_fill_color() const;
86 virtual color fill_color() const;
87 virtual void set_fill_color(const optional_color& aFillColor);
88 virtual double fill_opacity() const;
89 virtual void set_fill_opacity(double aFillOpacity);
90 private:
91 void init();
92 void update_widgets();
93 private:
94 vertical_layout iLayout;
95 horizontal_layout iTitleLayout;
96 std::variant<std::monostate, label_ptr, check_box_ptr> iTitle;
97 item_container iItemContainer;
98 ref_ptr<i_layout> iItemLayout;
99 define_property(property_category::color, optional_color, BorderColor, border_color)
100 define_property(property_category::color, optional_color, FillColor, fill_color)
101 define_property(property_category::other_appearance, double, FillOpacity, fill_opacity, 1.0)
102 sink iSink;
103 };
104}
void set_checkable(bool aCheckable, bool aUpdateItemsEnabledState=false)
group_box(std::string const &aText=std::string())
virtual color fill_color() const
i_layout & item_layout()
group_box(i_layout &aLayout, std::string const &aText=std::string())
void set_item_layout(i_layout &aItemLayout)
virtual void set_fill_color(const optional_color &aFillColor)
color palette_color(color_role aColorRole) const override
bool has_check_box() const
neogfx::label & label()
virtual double fill_opacity() const
i_string const & text() const
neogfx::size_policy size_policy() const override
group_box(i_widget &aParent, std::string const &aText=std::string())
const neogfx::label & label() const
void set_text(i_string const &aText)
virtual color border_color() const
const i_layout & item_layout() const
neogfx::check_box & check_box()
void set_item_layout(i_ref_ptr< i_layout > const &aItemLayout)
bool is_checkable() const
virtual bool has_fill_color() const
virtual void set_border_color(const optional_color &aBorderColor)
virtual bool has_border_color() const
LayoutT & with_item_layout(Args &&... args)
Definition group_box.hpp:72
const neogfx::check_box & check_box() const
virtual void set_fill_opacity(double aFillOpacity)
double scalar
Definition numerical.hpp:63
#define meta_object(...)
Definition i_object.hpp:28
#define define_property(category, type, name, calculator,...)
Definition property.hpp:536