neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
font_widget.hpp
Go to the documentation of this file.
1// font_widget.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>
27
28namespace neogfx
29{
30 enum class font_widget_style : std::uint32_t
31 {
32 Dialog = 0x00000001,
33 DropList = 0x00000002
34 };
35
37 {
38 return static_cast<font_widget_style>(static_cast<std::uint32_t>(lhs) | static_cast<std::uint32_t>(rhs));
39 }
40
42 {
43 return static_cast<font_widget_style>(static_cast<std::uint32_t>(lhs) & static_cast<std::uint32_t>(rhs));
44 }
45
47 {
48 return static_cast<font_widget_style>(~static_cast<std::uint32_t>(lhs));
49 }
50
51 class font_widget : public framed_widget<>
52 {
54 public:
55 define_event(SelectionChanged, selection_changed)
56 private:
57 class font_picker : public button<>
58 {
59 public:
60 font_picker(font_widget& aParent);
61 private:
62 neogfx::size_policy size_policy() const override;
63 size minimum_size(optional_size const& aAvailableSpace) const override;
64 private:
65 void paint(i_graphics_context& aGc) const override;
66 private:
67 glyph_text const& sample_text() const;
68 private:
69 font_widget& iParent;
70 mutable std::optional<glyph_text> iSampleText;
71 };
72 public:
73 font_widget(const neogfx::font& aCurrentFont = neogfx::font{}, font_widget_style aStyle = font_widget_style::Dialog);
74 font_widget(const neogfx::font& aCurrentFont, const text_format& aCurrentTextFormat, font_widget_style aStyle = font_widget_style::Dialog);
75 font_widget(i_widget& aParent, const neogfx::font& aCurrentFont = neogfx::font{}, font_widget_style aStyle = font_widget_style::Dialog);
76 font_widget(i_widget& aParent, const neogfx::font& aCurrentFont, const text_format& aCurrentTextFormat, font_widget_style aStyle = font_widget_style::Dialog);
77 font_widget(i_layout& aLayout, const neogfx::font& aCurrentFont = neogfx::font{}, font_widget_style aStyle = font_widget_style::Dialog);
78 font_widget(i_layout& aLayout, const neogfx::font& aCurrentFont, const text_format& aCurrentTextFormat, font_widget_style aStyle = font_widget_style::Dialog);
80 public:
81 neogfx::font current_font() const;
82 neogfx::font selected_font() const;
83 bool has_format() const;
84 neogfx::text_format current_format() const;
85 neogfx::text_format selected_format() const;
86 void select_font(const neogfx::font& aFont);
87 void select_format(const text_format& aTextFormat);
88 private:
89 void init();
90 void update_selected_font(const i_widget& aUpdatingWidget);
91 void update_selected_format(const i_widget& aUpdatingWidget);
92 private:
93 sink iSink;
94 bool iUpdating;
95 font_widget_style iStyle;
96 neogfx::font iCurrentFont;
97 neogfx::font iSelectedFont;
98 std::optional<text_format> iCurrentTextFormat;
99 std::optional<text_format> iSelectedTextFormat;
100 horizontal_layout iLayout0;
101 std::optional<drop_list> iFamilyPicker;
102 std::optional<drop_list> iStylePicker;
103 std::optional<drop_list> iSizePicker;
104 std::optional<font_picker> iFontPicker;
105 };
106}
font_widget(i_widget &aParent, const neogfx::font &aCurrentFont=neogfx::font{}, font_widget_style aStyle=font_widget_style::Dialog)
font_widget(i_layout &aLayout, const neogfx::font &aCurrentFont=neogfx::font{}, font_widget_style aStyle=font_widget_style::Dialog)
font_widget(i_layout &aLayout, const neogfx::font &aCurrentFont, const text_format &aCurrentTextFormat, font_widget_style aStyle=font_widget_style::Dialog)
neogfx::text_format selected_format() const
font_widget(i_widget &aParent, const neogfx::font &aCurrentFont, const text_format &aCurrentTextFormat, font_widget_style aStyle=font_widget_style::Dialog)
void select_font(const neogfx::font &aFont)
neogfx::text_format current_format() const
void select_format(const text_format &aTextFormat)
font_widget(const neogfx::font &aCurrentFont=neogfx::font{}, font_widget_style aStyle=font_widget_style::Dialog)
neogfx::font current_font() const
bool has_format() const
neogfx::font selected_font() const
font_widget(const neogfx::font &aCurrentFont, const text_format &aCurrentTextFormat, font_widget_style aStyle=font_widget_style::Dialog)
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:60
audio_channel operator~(audio_channel lhs)
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:55
#define meta_object(...)
Definition i_object.hpp:28
#define define_event(name, declName,...)
Definition event.hpp:200