neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
toolbar.hpp
Go to the documentation of this file.
1// toolbar.hpp
2/*
3neogfx C++ App/Game Engine
4Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along 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/app/action.hpp>
27
28namespace neogfx
29{
30 enum class toolbar_style : uint32_t
31 {
32 Horizontal = 0x00000001,
33 Vertical = 0x00000002,
34
35 Flow = 0x00000010,
36 Collapsible = 0x00000020, // todo
37
39 };
40
42 {
43 return static_cast<toolbar_style>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
44 }
45
47 {
48 return static_cast<toolbar_style>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
49 }
50
51 class toolbar : public widget<>, public i_action_container
52 {
54 private:
55 typedef std::unique_ptr<toolbar_button> button_pointer;
56 typedef std::vector<button_pointer> button_list;
57 public:
58 typedef uint32_t button_index;
59 public:
60 struct bad_button_index : std::logic_error { bad_button_index() : std::logic_error("neogfx::toolbar::bad_button_index") {} };
61 public:
65 public:
67 public:
68 neogfx::size_policy size_policy() const override;
69 public:
70 virtual size button_image_extents() const;
71 virtual void set_button_image_extents(optional_size const& aExtents);
72 virtual uint32_t button_count() const;
73 virtual const toolbar_button& button(button_index aButtonIndex) const;
74 virtual toolbar_button& button(button_index aButtonIndex);
75 i_action& add_action(i_action& aAction) override;
76 i_action& add_action(i_ref_ptr<i_action> const& aAction) override;
77 virtual void add_separator();
78 virtual i_action& insert_action(button_index aButtonIndex, i_action& aAction);
79 virtual i_action& insert_action(button_index aButtonIndex, i_ref_ptr<i_action> const& aAction);
80 virtual void insert_separator(button_index aButtonIndex);
81 private:
82 toolbar_style iStyle;
83 std::unique_ptr<i_layout> iLayout;
84 button_list iButtons;
85 action iSeparator;
86 optional_size iButtonImageExtents;
87 };
88}
virtual toolbar_button & button(button_index aButtonIndex)
i_action & add_action(i_ref_ptr< i_action > const &aAction) override
virtual const toolbar_button & button(button_index aButtonIndex) const
virtual void set_button_image_extents(optional_size const &aExtents)
toolbar(i_widget &aParent, toolbar_style aStyle=toolbar_style::Default)
toolbar(toolbar_style aStyle=toolbar_style::Default)
virtual uint32_t button_count() const
uint32_t button_index
Definition toolbar.hpp:58
toolbar_style style() const
virtual i_action & insert_action(button_index aButtonIndex, i_ref_ptr< i_action > const &aAction)
virtual size button_image_extents() const
toolbar(i_layout &aLayout, toolbar_style aStyle=toolbar_style::Default)
i_action & add_action(i_action &aAction) override
neogfx::size_policy size_policy() const override
virtual void insert_separator(button_index aButtonIndex)
virtual void add_separator()
virtual i_action & insert_action(button_index aButtonIndex, i_action &aAction)
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:60
toolbar_style
Definition toolbar.hpp:31
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:55
#define meta_object(...)
Definition i_object.hpp:28