neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
status_bar.hpp
Go to the documentation of this file.
1// status_bar.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#pragma once
20
21#include <neogfx/neogfx.hpp>
30
31namespace neogfx
32{
33 extern template class widget<i_status_bar>;
34
36 {
38 public:
40 enum class style : uint32_t
41 {
42 DisplayNone = 0x0000,
43 DisplayMessage = 0x0001,
44 DisplayKeyboardLocks = 0x0010,
45 DisplaySizeGrip = 0x4000,
46 BackgroundAsWindowBorder = 0x8000
47 };
48 friend constexpr style operator|(style aLhs, style aRhs)
49 {
50 return static_cast<style>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
51 }
52 friend constexpr style operator&(style aLhs, style aRhs)
53 {
54 return static_cast<style>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
55 }
56 public:
57 class separator : public widget<>
58 {
59 public:
60 separator(i_widget& aStatusBar);
61 separator(i_layout& aStatusBarLayout);
62 public:
63 neogfx::size_policy size_policy() const override;
64 size minimum_size(optional_size const& aAvailableSpace) const override;
65 public:
66 void paint(i_graphics_context& aGc) const override;
67 private:
68 i_widget& iStatusBar;
69 };
70 private:
71 class keyboard_lock_status : public widget<>
72 {
73 public:
74 keyboard_lock_status(i_layout& aLayout);
75 public:
76 neogfx::size_policy size_policy() const override;
77 private:
78 horizontal_layout iLayout;
79 std::unique_ptr<widget_timer> iUpdater;
80 };
81 class size_grip_widget : public image_widget
82 {
83 public:
84 size_grip_widget(i_layout& aLayout);
85 public:
86 neogfx::size_policy size_policy() const override;
87 public:
88 widget_part part(const point& aPosition) const override;
89 };
90 public:
91 struct style_conflict : std::runtime_error { style_conflict() : std::runtime_error("neogfx::status_bar::style_conflict") {} };
92 struct no_message : std::runtime_error { no_message() : std::runtime_error("neogfx::status_bar::no_message") {} };
93 public:
94 status_bar(i_standard_layout_container& aContainer, style aStyle = style::DisplayMessage | style::DisplayKeyboardLocks | style::DisplaySizeGrip);
95 public:
96 bool have_message() const override;
97 i_string const& message() const override;
98 void set_message(i_string const& aMessage) override;
99 void clear_message() override;
100 void add_normal_widget(i_widget& aWidget) override;
101 void add_normal_widget_at(widget_index aPosition, i_widget& aWidget) override;
102 void add_normal_widget(i_ref_ptr<i_widget> const &aWidget) override;
103 void add_normal_widget_at(widget_index aPosition, i_ref_ptr<i_widget> const& aWidget) override;
104 void add_permanent_widget(i_widget& aWidget) override;
105 void add_permanent_widget_at(widget_index aPosition, i_widget& aWidget) override;
106 void add_permanent_widget(i_ref_ptr<i_widget> const& aWidget) override;
107 void add_permanent_widget_at(widget_index aPosition, i_ref_ptr<i_widget> const& aWidget) override;
108 public:
111 public:
112 label& message_widget() override;
113 label& idle_widget() override;
114 protected:
115 neogfx::size_policy size_policy() const override;
116 protected:
117 widget_part part(const point& aPosition) const override;
118 protected:
119 bool is_managing_layout() const override;
120 protected:
121 bool has_palette_color(color_role aColorRole) const override;
122 color palette_color(color_role aColorRole) const override;
123 public:
124 void set_font(optional_font const& aFont) override;
125 protected:
126 const i_widget& size_grip() const override;
127 private:
128 void init();
129 void update_widgets();
130 private:
131 sink iSink;
132 style iStyle;
133 std::optional<string> iMessage;
134 horizontal_layout iLayout;
135 stack_layout iNormalLayout;
136 horizontal_layout iMessageLayout;
137 label iMessageLabel;
138 horizontal_layout iIdleLayout;
139 label iIdleLabel;
140 widget<> iNormalWidgetContainer;
141 horizontal_layout iNormalWidgetLayout;
142 horizontal_layout iPermanentWidgetLayout;
143 keyboard_lock_status iKeyboardLockStatus;
144 mutable std::map<color, std::optional<texture>> iSizeGripTexture;
145 size_grip_widget iSizeGrip;
146 };
147}
neogfx::size_policy size_policy() const override
void paint(i_graphics_context &aGc) const override
separator(i_layout &aStatusBarLayout)
separator(i_widget &aStatusBar)
size minimum_size(optional_size const &aAvailableSpace) const override
void clear_message() override
const i_widget & size_grip() const override
i_layout & normal_layout() override
widget_part part(const point &aPosition) const override
void add_permanent_widget_at(widget_index aPosition, i_ref_ptr< i_widget > const &aWidget) override
void add_normal_widget(i_ref_ptr< i_widget > const &aWidget) override
void add_normal_widget_at(widget_index aPosition, i_ref_ptr< i_widget > const &aWidget) override
bool is_managing_layout() const override
i_layout & permanent_layout() override
color palette_color(color_role aColorRole) const override
bool have_message() const override
void set_message(i_string const &aMessage) override
void add_permanent_widget(i_ref_ptr< i_widget > const &aWidget) override
void add_permanent_widget_at(widget_index aPosition, i_widget &aWidget) override
label & idle_widget() override
neogfx::size_policy size_policy() const override
friend constexpr style operator|(style aLhs, style aRhs)
i_string const & message() const override
void add_normal_widget(i_widget &aWidget) override
void add_permanent_widget(i_widget &aWidget) override
label & message_widget() override
void set_font(optional_font const &aFont) override
void add_normal_widget_at(widget_index aPosition, i_widget &aWidget) override
bool has_palette_color(color_role aColorRole) const override
status_bar(i_standard_layout_container &aContainer, style aStyle=style::DisplayMessage|style::DisplayKeyboardLocks|style::DisplaySizeGrip)
friend constexpr style operator&(style aLhs, style aRhs)
#define meta_object(...)
Definition i_object.hpp:28