neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
window.hpp
Go to the documentation of this file.
1// window.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>
31
32namespace neogfx
33{
34 class i_window_manager;
35
36 class window : public decorated<scrollable_widget<framed_widget<widget<i_window>>>>
37 {
39 public:
41 define_declared_event(DismissingChildren, dismissing_children, const i_widget*)
42 define_declared_event(Activated, activated)
43 define_declared_event(Deactivated, deactivated)
44 define_declared_event(Closed, closed)
45 define_declared_event(PaintOverlay, paint_overlay, i_graphics_context&)
46 private:
47 class client;
48 typedef std::optional<normal_title_bar> optional_title_bar;
49 public:
50 struct fullscreen_window_cannot_nest : std::logic_error { fullscreen_window_cannot_nest() : std::logic_error("neogfx::window::fullscreen_window_cannot_nest") {} };
51 struct parentless_window_cannot_nest : std::logic_error { parentless_window_cannot_nest() : std::logic_error("neogfx::window::parentless_window_cannot_nest") {} };
52 public:
54 window(const window_placement& aPlacement, window_style aStyle = window_style::Default, frame_style aFrameStyle = frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle = neogfx::scrollbar_style::Normal);
55 window(const window_placement& aPlacement, std::string const& aWindowTitle, window_style aStyle = window_style::Default, frame_style aFrameStyle = frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle = neogfx::scrollbar_style::Normal);
58 window(i_widget& aParent, const window_placement& aPlacement, window_style aStyle = window_style::Default, frame_style aFrameStyle = frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle = neogfx::scrollbar_style::Normal);
59 window(i_widget& aParent, const window_placement& aPlacement, std::string const& aWindowTitle, window_style aStyle = window_style::Default, frame_style aFrameStyle = frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle = neogfx::scrollbar_style::Normal);
60 window(i_widget& aParent, std::string const& aWindowTitle, window_style aStyle = window_style::Default, frame_style aFrameStyle = frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle = neogfx::scrollbar_style::Normal);
62 private:
63 window(i_widget* aParent, const window_placement& aPlacement, const std::optional<std::string>& aWindowTitle, window_style aStyle, frame_style aFrameStyle, neogfx::scrollbar_style aScrollbarStyle);
64 public:
65 window_style style() const override;
66 void set_style(window_style aStyle) override;
67 public:
68 const i_window_manager& window_manager() const override;
70 public:
71 bool is_surface() const final;
72 bool has_surface() const final;
73 const i_surface_window& surface() const final;
75 const i_surface_window& real_surface() const final;
77 void set_surface(i_surface_window& aSurfaceWindow) override;
78 bool has_native_surface() const final;
79 const i_native_surface& native_surface() const final;
81 bool has_native_window() const final;
82 const i_native_window& native_window() const final;
84 public:
85 bool has_parent_window() const final;
86 const i_window& parent_window() const final;
88 bool is_parent_of(const i_window& aChildWindow) const final;
89 bool is_owner_of(const i_window& aChildWindow) const final;
90 const i_window& ultimate_ancestor() const override;
92 public:
93 bool is_nested() const override;
94 public:
95 bool is_strong() const override;
96 bool is_weak() const override;
97 public:
98 bool can_close() const override;
99 bool is_closed() const override;
100 void close() override;
101 public:
102 color frame_color() const override;
103 public:
104 void set_parent(i_widget& aParent) override;
105 bool is_managing_layout() const override;
106 void layout_items_completed() override;
107 public:
108 void widget_added(i_widget&) override;
109 void widget_removed(i_widget& aWidget) override;
110 public:
111 bool device_metrics_available() const override;
112 const i_device_metrics& device_metrics() const override;
113 public:
114 layer_t layer() const override;
115 public:
116 widget_part hit_test(const point& aPosition) const override;
117 public:
118 neogfx::size_policy size_policy() const override;
119 size minimum_size(optional_size const& aAvailableSpace = {}) const override;
120 public:
121 using widget::update;
122 bool update(const rect& aUpdateRect) override;
123 void render(i_graphics_context& aGc) const override;
124 void paint(i_graphics_context& aGc) const override;
125 public:
126 color palette_color(color_role aColorRole) const override;
127 public:
128 using widget::show;
129 bool show(bool aVisible) override;
131 void focus_gained(focus_reason aFocusReason) override;
132 void focus_lost(focus_reason aFocusReason) override;
133 public:
135 public:
136 i_string const& title_text() const override;
137 void set_title_text(i_string const& aTitleText) override;
138 public:
139 bool is_effectively_active() const override;
140 bool is_active() const override;
141 void activate() override;
142 void deactivate() override;
143 bool is_iconic() const override;
144 void iconize() override;
145 bool is_maximized() const override;
146 void maximize() override;
147 bool is_restored() const override;
148 void restore() override;
149 bool is_fullscreen() const override;
150 void enter_fullscreen(const video_mode& aVideoMode) override;
151 point window_position() const override;
152 const window_placement& placement() const override;
153 void set_placement(const window_placement& aPlacement) override;
154 void center(bool aSetMinimumSize = true) override;
155 void center_on_parent(bool aSetMinimumSize = true) override;
156 bool window_enabled() const override;
157 void counted_window_enable(bool aEnable) override;
158 void modal_enable(bool aEnable) override;
159 public:
160 bool is_dismissing_children() const override;
161 bool can_dismiss(const i_widget* aClickedWidget) const override;
162 dismissal_type_e dismissal_type() const override;
163 bool dismissed() const override;
164 void dismiss() override;
165 public:
166 bool ready_to_render() const override;
167 void set_ready_to_render(bool aReady) override;
168 double rendering_priority() const override;
169 double fps() const override;
170 double potential_fps() const override;
171 public:
172 point mouse_position() const override;
173 public:
175 rect widget_part_rect(widget_part_e aWidgetPart) const override;
176 public:
177 bool has_client_widget() const override;
178 const i_widget& client_widget() const override;
180 void set_client(i_widget& aClient) override;
181 void set_client(i_ref_ptr<i_widget> const& aClient) override;
182 public:
183 using base_type::has_layout;
184 using base_type::layout;
185 bool has_layout(standard_layout aStandardLayout) const override;
186 const i_layout& layout(standard_layout aStandardLayout, layout_position aPosition = layout_position::None) const override;
187 i_layout& layout(standard_layout aStandardLayout, layout_position aPosition = layout_position::None) override;
188 public:
189 bool requires_owner_focus() const override;
190 bool has_entered_widget() const override;
191 i_widget& entered_widget() const override;
192 public:
193 bool has_focused_widget() const override;
194 i_widget& focused_widget() const override;
195 void set_focused_widget(i_widget& aWidget, focus_reason aFocusReason) override;
196 void release_focused_widget(i_widget& aWidget) override;
197 protected:
198 void mouse_entered(const point& aPosition) override;
199 void mouse_left() override;
200 protected:
201 void update_modality(bool aEnableAncestors) override;
202 void update_click_focus(i_widget& aCandidateWidget, const point& aClickPos) override;
203 void dismiss_children(const i_widget* aClickedWidget = nullptr) override;
204 public:
207 private:
208 void init();
209 private:
210 i_window_manager& iWindowManager;
211 i_window* iParentWindow;
212 mutable neogfx::window_placement iPlacement;
213 bool iCentering;
214 bool iClosed;
215 sink iSink;
216 ref_ptr<i_surface_window> iSurfaceWindow;
217 bool iReadyToRender;
218 string iTitleText;
219 window_style iStyle;
220 int32_t iCountedEnable;
221 i_widget* iEnteredWidget;
222 i_widget* iFocusedWidget;
223 bool iDismissingChildren;
224 std::optional<destroyed_flag> iSurfaceDestroyed;
225 };
226}
bool show(bool aVisible) override
Definition widget.ipp:1618
bool update(bool aIncludeNonClient=false) override
Definition widget.ipp:1159
void set_focused_widget(i_widget &aWidget, focus_reason aFocusReason) override
bool is_closed() const override
window_style style() const override
const i_surface_window & real_surface() const final
i_layout & layout(standard_layout aStandardLayout, layout_position aPosition=layout_position::None) override
void dismiss() override
window(window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
void maximize() override
void set_client(i_ref_ptr< i_widget > const &aClient) override
widget_part hit_test(const point &aPosition) const override
i_widget & entered_widget() const override
bool is_strong() const override
void modal_enable(bool aEnable) override
dismissal_type_e dismissal_type() const override
window(i_widget &aParent, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
void set_surface(i_surface_window &aSurfaceWindow) override
void set_ready_to_render(bool aReady) override
void restore() override
void widget_removed(i_widget &aWidget) override
layer_t layer() const override
void activate() override
bool requires_owner_focus() const override
neogfx::scrolling_disposition scrolling_disposition(const i_widget &aChildWidget) const override
double potential_fps() const override
bool has_entered_widget() const override
bool is_active() const override
bool is_fullscreen() const override
const i_native_window & native_window() const final
void counted_window_enable(bool aEnable) override
void render(i_graphics_context &aGc) const override
bool is_owner_of(const i_window &aChildWindow) const final
window(i_widget &aParent, const window_placement &aPlacement, std::string const &aWindowTitle, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
const i_widget & client_widget() const override
bool has_focused_widget() const override
i_string const & title_text() const override
size minimum_size(optional_size const &aAvailableSpace={}) const override
void set_style(window_style aStyle) override
const i_window & ultimate_ancestor() const override
bool is_nested() const override
double fps() const override
void update_modality(bool aEnableAncestors) override
bool ready_to_render() const override
void iconize() override
bool has_native_surface() const final
bool dismissed() const override
void mouse_left() override
bool has_surface() const final
neogfx::focus_policy focus_policy() const override
color frame_color() const override
i_widget & client_widget() override
void set_parent(i_widget &aParent) override
const window_placement & placement() const override
bool is_effectively_active() const override
void center_on_parent(bool aSetMinimumSize=true) override
const i_window_manager & window_manager() const override
neogfx::border window_border() const override
void deactivate() override
window(const window_placement &aPlacement, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
neogfx::size_policy size_policy() const override
bool is_parent_of(const i_window &aChildWindow) const final
i_widget & focused_widget() const override
bool is_restored() const override
const i_native_surface & native_surface() const final
point mouse_position() const override
const i_drag_drop_target & default_drag_drop_target() const override
void focus_gained(focus_reason aFocusReason) override
bool is_managing_layout() const override
window(i_widget &aParent, std::string const &aWindowTitle, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
window(std::string const &aWindowTitle, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
point window_position() const override
bool is_iconic() const override
bool has_native_window() const final
void mouse_entered(const point &aPosition) override
bool is_surface() const final
void dismiss_children(const i_widget *aClickedWidget=nullptr) override
void release_focused_widget(i_widget &aWidget) override
i_drag_drop_target & default_drag_drop_target() override
void center(bool aSetMinimumSize=true) override
bool is_dismissing_children() const override
bool show(bool aVisible) override
void layout_items_completed() override
bool has_layout(standard_layout aStandardLayout) const override
void widget_added(i_widget &) override
const i_window & parent_window() const final
void close() override
void set_client(i_widget &aClient) override
bool can_close() const override
bool has_client_widget() const override
window(const window_placement &aPlacement, std::string const &aWindowTitle, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
i_window_manager & window_manager() override
void enter_fullscreen(const video_mode &aVideoMode) override
window(i_widget &aParent, const window_placement &aPlacement, window_style aStyle=window_style::Default, frame_style aFrameStyle=frame_style::WindowFrame, neogfx::scrollbar_style aScrollbarStyle=neogfx::scrollbar_style::Normal)
void focus_lost(focus_reason aFocusReason) override
const i_surface_window & surface() const final
bool window_enabled() const override
bool can_dismiss(const i_widget *aClickedWidget) const override
bool has_parent_window() const final
bool is_maximized() const override
color palette_color(color_role aColorRole) const override
bool is_weak() const override
const i_device_metrics & device_metrics() const override
bool device_metrics_available() const override
void set_title_text(i_string const &aTitleText) override
void set_placement(const window_placement &aPlacement) override
void update_click_focus(i_widget &aCandidateWidget, const point &aClickPos) override
const i_layout & layout(standard_layout aStandardLayout, layout_position aPosition=layout_position::None) const override
rect widget_part_rect(widget_part_e aWidgetPart) const override
double rendering_priority() const override
bool update(const rect &aUpdateRect) override
void paint(i_graphics_context &aGc) const override
standard_layout
Definition i_layout.hpp:49
layout_position
Definition i_layout.hpp:39
#define meta_object(...)
Definition i_object.hpp:28
#define define_declared_event(name, declName,...)
Definition event.hpp:195