neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_window.hpp
Go to the documentation of this file.
1// i_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
20#pragma once
21
22#include <neogfx/neogfx.hpp>
32
33namespace neogfx
34{
35 class i_native_surface;
36 class i_native_window;
37 class i_nested_window;
38 class i_nest;
39 class i_drag_drop_target;
40
41 class i_window : public i_widget, public virtual i_standard_layout_container
42 {
43 public:
45 declare_event(dismissing_children, const i_widget*)
46 declare_event(activated)
47 declare_event(deactivated)
48 declare_event(closed)
49 declare_event(paint_overlay, i_graphics_context&)
50 private:
51 friend class window;
52 friend class surface_window;
53 public:
60 public:
61 struct no_native_surface : std::logic_error { no_native_surface() : std::logic_error("neogfx::i_window::no_native_surface") {} };
62 struct no_native_window : std::logic_error { no_native_window() : std::logic_error("neogfx::i_window::no_native_window") {} };
63 struct no_parent_window : std::logic_error { no_parent_window() : std::logic_error("neogfx::i_window::no_parent_window") {} };
64 struct not_in_nest : std::logic_error { not_in_nest() : std::logic_error("neogfx::i_window::not_in_nest") {} };
65 struct not_nested : std::logic_error { not_nested() : std::logic_error("neogfx::i_window::not_nested") {} };
66 struct not_a_nest : std::logic_error { not_a_nest() : std::logic_error("neogfx::i_window::not_a_nest") {} };
67 public:
68 virtual const i_window_manager& window_manager() const = 0;
70 public:
71 virtual bool is_surface() const = 0;
72 virtual bool has_surface() const = 0;
73 virtual const i_surface& surface() const = 0;
74 virtual i_surface& surface() = 0;
75 virtual void set_surface(i_surface_window& aSurfaceWindow) = 0;
76 virtual bool has_native_surface() const = 0;
77 virtual const i_native_surface& native_surface() const = 0;
79 virtual bool has_native_window() const = 0;
80 virtual const i_native_window& native_window() const = 0;
82 public:
83 virtual bool has_parent_window() const = 0;
84 virtual const i_window& parent_window() const = 0;
85 virtual i_window& parent_window() = 0;
86 virtual bool is_parent_of(const i_window& aChildWindow) const = 0;
87 virtual bool is_owner_of(const i_window& aChildWindow) const = 0;
88 virtual const i_window& ultimate_ancestor() const = 0;
90 public:
91 virtual bool is_nested() const = 0;
92 public:
93 virtual bool is_strong() const = 0;
94 virtual bool is_weak() const = 0;
95 public:
96 virtual bool can_close() const = 0;
97 virtual bool is_closed() const = 0;
98 virtual void close() = 0;
99 public:
100 virtual void widget_added(i_widget&) = 0;
101 virtual void widget_removed(i_widget& aWidget) = 0;
102 public:
103 virtual window_style style() const = 0;
104 virtual void set_style(window_style aStyle) = 0;
105 public:
106 virtual i_string const& title_text() const = 0;
107 virtual void set_title_text(i_string const& aTitleText) = 0;
108 public:
109 virtual bool is_effectively_active() const = 0;
110 virtual bool is_active() const = 0;
111 virtual void activate() = 0;
112 virtual void deactivate() = 0;
113 virtual bool is_iconic() const = 0;
114 virtual void iconize() = 0;
115 virtual bool is_maximized() const = 0;
116 virtual void maximize() = 0;
117 virtual bool is_restored() const = 0;
118 virtual void restore() = 0;
119 virtual bool is_fullscreen() const = 0;
120 virtual void enter_fullscreen(const video_mode& aVideoMode) = 0;
121 virtual point window_position() const = 0;
122 virtual const window_placement& placement() const = 0;
123 virtual void set_placement(const window_placement& aPlacement) = 0;
124 virtual void center(bool aSetMinimumSize = true) = 0;
125 virtual void center_on_parent(bool aSetMinimumSize = true) = 0;
126 virtual bool window_enabled() const = 0;
127 virtual void counted_window_enable(bool aEnable) = 0;
128 virtual void modal_enable(bool aEnable) = 0;
129 public:
130 virtual bool is_dismissing_children() const = 0;
131 virtual bool can_dismiss(const i_widget* aClickedWidget) const = 0;
132 virtual dismissal_type_e dismissal_type() const = 0;
133 virtual bool dismissed() const = 0;
134 virtual void dismiss() = 0;
135 public:
136 virtual bool ready_to_render() const = 0;
137 virtual void set_ready_to_render(bool aReady) = 0;
138 virtual double rendering_priority() const = 0;
139 virtual double fps() const = 0;
140 virtual double potential_fps() const = 0;
141 public:
142 virtual point mouse_position() const = 0;
143 public:
144 virtual neogfx::border window_border() const = 0;
145 virtual rect widget_part_rect(widget_part_e aWidgetPart) const = 0;
146 public:
147 virtual const i_widget& client_widget() const = 0;
148 virtual i_widget& client_widget() = 0;
149 public:
150 virtual bool requires_owner_focus() const = 0;
151 virtual bool has_entered_widget() const = 0;
152 virtual i_widget& entered_widget() const = 0;
153 public:
154 virtual bool has_focused_widget() const = 0;
155 virtual i_widget& focused_widget() const = 0;
156 virtual void set_focused_widget(i_widget& aWidget, focus_reason aFocusReason) = 0;
157 virtual void release_focused_widget(i_widget& aWidget) = 0;
158 protected:
159 virtual void update_modality(bool aEnableAncestors) = 0;
160 virtual void update_click_focus(i_widget& aCandidateWidget, const point& aClickPos) = 0;
161 virtual void dismiss_children(const i_widget* aClickedWidget = nullptr) = 0;
162 public:
163 virtual const i_widget& as_widget() const = 0;
164 virtual i_widget& as_widget() = 0;
165 public:
168 // helpers
169 public:
171 {
172 if (is_surface())
173 return &surface().as_surface_window();
174 else if (has_parent_window())
175 return parent_window().find_surface();
176 else
177 return nullptr;
178 }
180 {
181 return const_cast<i_surface_window*>(to_const(*this).find_surface());
182 }
184 {
185 if (is_surface() && !surface().is_nested_window())
186 return &surface().as_surface_window();
187 else if (has_parent_window())
189 else
190 return nullptr;
191 }
193 {
194 return const_cast<i_surface_window*>(to_const(*this).find_real_surface());
195 }
196 bool is_ancestor_of(const i_window& aWindow) const
197 {
198 const i_window* w = &aWindow;
199 while (w != this && w->has_parent_window())
200 w = &w->parent_window();
201 return w == this;
202 }
203 bool is_descendent_of(const i_window& aWindow) const
204 {
205 return aWindow.is_ancestor_of(*this);
206 }
207 };
208
212
214 {
215 public:
219 public:
221 private:
222 i_surface* iSurface;
223 neolib::optional_destroyed_flag iSurfaceDestroyed;
224 neolib::optional_destroyed_flag iWindowDestroyed;
225 };
226}
virtual const i_surface_window & as_surface_window() const =0
virtual bool can_close() const =0
virtual bool is_effectively_active() const =0
virtual const i_window & parent_window() const =0
virtual bool dismissed() const =0
virtual bool has_focused_widget() const =0
virtual bool is_closed() const =0
i_surface_window * find_real_surface()
Definition i_window.hpp:192
virtual const i_widget & as_widget() const =0
virtual bool has_surface() const =0
virtual bool is_nested() const =0
virtual window_style style() const =0
virtual bool is_restored() const =0
virtual const i_window & ultimate_ancestor() const =0
virtual void dismiss()=0
virtual bool has_native_surface() const =0
virtual i_drag_drop_target & default_drag_drop_target()=0
virtual const i_native_window & native_window() const =0
virtual i_widget & focused_widget() const =0
virtual bool can_dismiss(const i_widget *aClickedWidget) const =0
virtual void widget_added(i_widget &)=0
virtual const i_window_manager & window_manager() const =0
virtual bool has_native_window() const =0
virtual void set_ready_to_render(bool aReady)=0
virtual void center(bool aSetMinimumSize=true)=0
virtual void center_on_parent(bool aSetMinimumSize=true)=0
virtual void update_modality(bool aEnableAncestors)=0
bool is_descendent_of(const i_window &aWindow) const
Definition i_window.hpp:203
virtual point mouse_position() const =0
virtual bool has_entered_widget() const =0
i_surface_window * find_surface()
Definition i_window.hpp:179
virtual bool is_surface() const =0
virtual i_window & ultimate_ancestor()=0
virtual i_string const & title_text() const =0
virtual bool is_fullscreen() const =0
virtual rect widget_part_rect(widget_part_e aWidgetPart) const =0
virtual point window_position() const =0
virtual double fps() const =0
virtual bool is_weak() const =0
virtual const i_drag_drop_target & default_drag_drop_target() const =0
virtual i_widget & as_widget()=0
declare_event(window_event, neogfx::window_event &) declare_event(dismissing_children
virtual void maximize()=0
const i_surface_window * find_real_surface() const
Definition i_window.hpp:183
virtual i_native_surface & native_surface()=0
virtual neogfx::border window_border() const =0
virtual bool window_enabled() const =0
virtual bool ready_to_render() const =0
virtual void iconize()=0
virtual double rendering_priority() const =0
virtual void enter_fullscreen(const video_mode &aVideoMode)=0
virtual bool is_iconic() const =0
virtual dismissal_type_e dismissal_type() const =0
virtual i_widget & entered_widget() const =0
virtual void set_surface(i_surface_window &aSurfaceWindow)=0
virtual void update_click_focus(i_widget &aCandidateWidget, const point &aClickPos)=0
virtual i_native_window & native_window()=0
virtual const i_surface & surface() const =0
virtual void set_style(window_style aStyle)=0
virtual void close()=0
virtual void set_placement(const window_placement &aPlacement)=0
virtual void set_focused_widget(i_widget &aWidget, focus_reason aFocusReason)=0
virtual void release_focused_widget(i_widget &aWidget)=0
virtual const i_widget & client_widget() const =0
virtual bool is_dismissing_children() const =0
virtual const i_native_surface & native_surface() const =0
virtual bool is_owner_of(const i_window &aChildWindow) const =0
bool is_ancestor_of(const i_window &aWindow) const
Definition i_window.hpp:196
virtual i_window & parent_window()=0
virtual i_widget & client_widget()=0
virtual i_window_manager & window_manager()=0
const i_surface_window * find_surface() const
Definition i_window.hpp:170
virtual void dismiss_children(const i_widget *aClickedWidget=nullptr)=0
virtual double potential_fps() const =0
virtual void widget_removed(i_widget &aWidget)=0
virtual void counted_window_enable(bool aEnable)=0
virtual bool is_active() const =0
virtual i_surface & surface()=0
virtual bool is_parent_of(const i_window &aChildWindow) const =0
virtual bool has_parent_window() const =0
virtual bool is_maximized() const =0
virtual void activate()=0
virtual void restore()=0
virtual const window_placement & placement() const =0
virtual bool is_strong() const =0
virtual bool requires_owner_focus() const =0
virtual void modal_enable(bool aEnable)=0
virtual void deactivate()=0
virtual void set_title_text(i_string const &aTitleText)=0
pause_rendering & operator=(pause_rendering &&aOther)
pause_rendering(i_window &aWindow)
pause_rendering(pause_rendering &&aOther)
rect corrected_popup_rect(i_window &aPopup, rect aPopupRect)
void correct_popup_rect(i_window &aPopup)
std::optional< destroyed_flag > optional_destroyed_flag
Definition lifetime.hpp:78
#define declare_event(declName,...)
Definition i_event.hpp:305