neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
surface_window.hpp
Go to the documentation of this file.
1// surface_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>
25
26namespace neogfx
27{
28 class i_native_window;
29
30 class surface_window : public reference_counted<object<i_surface_window>>
31 {
32 public:
33 define_declared_event(DpiChanged, dpi_changed)
34 define_declared_event(Rendering, rendering)
35 define_declared_event(RenderingFinished, rendering_finished)
36 define_declared_event(Closing, closing)
37 define_declared_event(Closed, closed)
38 public:
39 typedef i_surface_window abstract_type;
40 public:
41 surface_window(i_window& aWindow, std::function<void(i_surface_window&)> aNativeWindowCreator);
43 public:
45 dimension vertical_dpi() const final;
46 dimension ppi() const final;
47 bool metrics_available() const final;
48 size extents() const final;
49 dimension em_size() const final;
50 public:
51 bool device_metrics_available() const final;
52 const i_device_metrics& device_metrics() const final;
53 public:
55 public:
56 bool is_strong() const final;
57 bool is_weak() const final;
58 bool can_close() const final;
59 bool is_closed() const final;
60 void close() final;
61 bool has_parent_surface() const final;
62 const i_surface& parent_surface() const final;
64 bool is_owner_of(const i_surface& aChildSurface) const final;
65 public:
66 bool is_window() const final;
67 bool is_nested_window() const final;
68 const i_surface_window& as_surface_window() const final;
70 public:
75 void set_logical_coordinates(const neogfx::logical_coordinates& aCoordinates) final;
76 double z_order() const final;
77 void layout_surface() final;
78 void invalidate_surface(const rect& aInvalidatedRect, bool aInternal = true) final;
79 bool has_invalidated_area() const final;
80 const rect& invalidated_area() const final;
81 rect validate() final;
82 double rendering_priority() const final;
83 void render_surface() final;
84 void pause_rendering() final;
85 void resume_rendering() final;
86 bool has_native_window() const final;
87 const i_native_window& native_window() const final;
89 void set_native_window(i_native_window& aNativeWindow) final;
90 bool has_native_surface() const final;
91 const i_native_surface& native_surface() const final;
93 public:
94 void handle_dpi_changed() final;
95 public:
96 point surface_position() const final;
97 void move_surface(const point& aPosition) final;
98 size surface_extents() const final;
99 void resize_surface(const size& aExtents) final;
100 double surface_opacity() const final;
101 void set_surface_opacity(double aOpacity) final;
102 double surface_transparency() const final;
103 void set_surface_transparency(double aTransparency) final;
104 public:
105 bool has_clicked_widget() const final;
106 i_widget& clicked_widget() const final;
107 bool has_capturing_widget() const final;
109 void set_capture(i_widget& aWidget) final;
110 void release_capture(i_widget& aWidget) final;
111 void non_client_set_capture(i_widget& aWidget) final;
113 private:
114 mouse_event_location current_mouse_event_location() const final;
115 bool is_closing() const final;
116 bool native_window_can_close() const final;
117 void native_window_closing() final;
118 void native_window_closed() final;
119 void native_window_focus_gained() final;
120 void native_window_focus_lost() final;
121 void native_window_resized() final;
122 void native_window_moved() final;
123 double native_window_rendering_priority() const final;
124 bool native_window_ready_to_render() const final;
125 void native_window_render(const rect& aInvalidatedRect) const final;
126 void native_window_dismiss_children() final;
127 void native_window_mouse_wheel_scrolled(mouse_wheel aWheel, const point& aPosition, delta aDelta, key_modifiers_e aKeyModifiers) final;
128 void native_window_mouse_button_pressed(mouse_button aButton, const point& aPosition, key_modifiers_e aKeyModifiers) final;
129 void native_window_mouse_button_double_clicked(mouse_button aButton, const point& aPosition, key_modifiers_e aKeyModifiers) final;
130 void native_window_mouse_button_released(mouse_button aButton, const point& aPosition) final;
131 void native_window_mouse_moved(const point& aPosition, key_modifiers_e aKeyModifiers) final;
132 void native_window_non_client_mouse_wheel_scrolled(mouse_wheel aWheel, const point& aPosition, delta aDelta, key_modifiers_e aKeyModifiers) final;
133 void native_window_non_client_mouse_button_pressed(mouse_button aButton, const point& aPosition, key_modifiers_e aKeyModifiers) final;
134 void native_window_non_client_mouse_button_double_clicked(mouse_button aButton, const point& aPosition, key_modifiers_e aKeyModifiers) final;
135 void native_window_non_client_mouse_button_released(mouse_button aButton, const point& aPosition) final;
136 void native_window_non_client_mouse_moved(const point& aPosition, key_modifiers_e aKeyModifiers) final;
137 void native_window_mouse_entered(const point& aPosition) final;
138 void native_window_mouse_left() final;
139 widget_part native_window_hit_test(const point& aPosition) const final;
140 rect native_window_widget_part_rect(widget_part_e aWidgetPart) const final;
141 void native_window_key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) final;
142 void native_window_key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) final;
143 void native_window_text_input(i_string const& aText) final;
144 void native_window_sys_text_input(i_string const& aText) final;
145 neogfx::mouse_cursor native_window_mouse_cursor() const final;
146 void native_window_title_text_changed(i_string const& aTitleText) final;
147 public:
148 window_style style() const final;
149 void set_style(window_style aStyle) final;
150 public:
151 const i_window& as_window() const final;
153 const i_widget& as_widget() const final;
155 public:
156 const i_window& window_at_position(const point& aPosition, bool aForMouseEvent = false) const;
157 i_window& window_at_position(const point& aPosition, bool aForMouseEvent = false);
158 const i_widget& widget_for_mouse_event(const point& aPosition, bool aForHitTest = false) const;
159 i_widget& widget_for_mouse_event(const point& aPosition, bool aForHitTest = false);
160 private:
161 std::optional<destroyed_flag> iNativeWindowDestroyed;
162 i_window& iWindow;
163 i_rendering_engine& iRenderingEngine;
164 ref_ptr<i_native_window> iNativeWindow;
165 bool iNativeWindowClosing;
166 bool iClosing;
167 bool iClosed;
168 std::optional<char32_t> iSurrogatePairPart;
169 i_widget* iCapturingWidget;
170 i_widget* iClickedWidget;
171 };
172}
void layout_surface() final
bool has_native_surface() const final
bool is_strong() const final
void move_surface(const point &aPosition) final
const i_widget & widget_for_mouse_event(const point &aPosition, bool aForHitTest=false) const
point surface_position() const final
void handle_dpi_changed() final
i_widget & clicked_widget() const final
bool metrics_available() const final
bool has_parent_surface() const final
void non_client_release_capture(i_widget &aWidget) final
bool can_close() const final
bool is_nested_window() const final
bool is_owner_of(const i_surface &aChildSurface) const final
const i_native_window & native_window() const final
bool has_clicked_widget() const final
double surface_transparency() const final
dimension em_size() const final
void release_capture(i_widget &aWidget) final
dimension ppi() const final
bool has_capturing_widget() const final
double z_order() const final
dimension vertical_dpi() const final
dimension horizontal_dpi() const final
void non_client_set_capture(i_widget &aWidget) final
void set_surface_transparency(double aTransparency) final
void set_surface_opacity(double aOpacity) final
void set_native_window(i_native_window &aNativeWindow) final
define_declared_event(DpiChanged, dpi_changed) define_declared_event(Rendering
double surface_opacity() const final
bool has_invalidated_area() const final
void resize_surface(const size &aExtents) final
bool is_weak() const final
const i_surface_window & as_surface_window() const final
bool device_metrics_available() const final
void set_style(window_style aStyle) final
void invalidate_surface(const rect &aInvalidatedRect, bool aInternal=true) final
bool has_native_window() const final
void render_surface() final
const rect & invalidated_area() const final
const i_widget & as_widget() const final
i_rendering_engine & rendering_engine() const final
size extents() const final
const i_native_surface & native_surface() const final
i_widget & capturing_widget() const final
const i_window & window_at_position(const point &aPosition, bool aForMouseEvent=false) const
void resume_rendering() final
bool is_closed() const final
const i_device_metrics & device_metrics() const final
bool is_window() const final
size surface_extents() const final
const i_window & as_window() const final
double rendering_priority() const final
const i_surface & parent_surface() const final
void set_capture(i_widget &aWidget) final
void set_logical_coordinates(const neogfx::logical_coordinates &aCoordinates) final
void set_logical_coordinate_system(neogfx::logical_coordinate_system aSystem) final
logical_coordinate_system
mouse_wheel
Definition i_mouse.hpp:42
default_geometry_value_type dimension
mouse_button
Definition i_mouse.hpp:31
Definition plf_hive.h:79
#define define_declared_event(name, declName,...)
Definition event.hpp:195