neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
window_events.hpp
Go to the documentation of this file.
1// window_events.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>
25#include <neogfx/hid/mouse.hpp>
27
28namespace neogfx
29{
50
52 {
53 public:
54 typedef window_event abstract_type; // todo
55 public:
57 public:
59 iType(aType), iParameter(aParameter)
60 {
61 }
62 public:
64 {
65 return iType;
66 }
67 bool has_parameter() const
68 {
69 return !std::holds_alternative<std::monostate>(iParameter);
70 }
72 {
73 return static_variant_cast<neogfx::size>(iParameter);
74 }
76 {
77 return static_variant_cast<neogfx::point>(iParameter);
78 }
79 void set_extents(const neogfx::size& aExtents)
80 {
81 static_variant_cast<neogfx::size&>(iParameter) = aExtents;
82 }
83 void set_position(const neogfx::point& aPosition)
84 {
85 static_variant_cast<neogfx::point&>(iParameter) = aPosition;
86 }
87 private:
89 parameter_type iParameter;
90 };
91
93 {
94 None,
95 Client,
97 };
98
107
108 template <mouse_event_location Location>
110 {
111 typedef basic_mouse_event<Location> self_type;
112 public:
113 typedef self_type abstract_type; // todo
114 public:
116 public:
118 mouse_event_type aType,
119 const parameter_type& aParameter1 = parameter_type{},
120 const parameter_type& aParameter2 = parameter_type{},
121 const parameter_type& aParameter3 = parameter_type{},
122 const parameter_type& aParameter4 = parameter_type{}) :
123 iType{ aType }, iParameter1{ aParameter1 }, iParameter2{ aParameter2 }, iParameter3{ aParameter3 }, iParameter4{ aParameter4 }
124 {
125 }
126 public:
128 {
129 return iType;
130 }
132 {
133 return static_variant_cast<neogfx::point>(iParameter1);
134 }
135 self_type with_position(neogfx::point const& aPosition) const
136 {
137 return self_type{ iType, aPosition, iParameter2, iParameter3, iParameter4 };
138 }
140 {
141 return static_variant_cast<neogfx::mouse_button>(iParameter2);
142 }
144 {
145 return static_variant_cast<neogfx::mouse_wheel>(iParameter2);
146 }
148 {
149 return static_variant_cast<neogfx::key_modifiers_e>(iParameter3);
150 }
152 {
153 return static_variant_cast<neogfx::delta>(iParameter4);
154 }
155 public:
168 bool is_x1_button() const
169 {
171 }
172 bool is_x2_button() const
173 {
175 }
176 private:
177 mouse_event_type iType;
178 parameter_type iParameter1;
179 parameter_type iParameter2;
180 parameter_type iParameter3;
181 parameter_type iParameter4;
182 };
183
186
188 {
191 TextInput,
193 };
194
196 {
197 public:
199 public:
201 public:
202 keyboard_event(keyboard_event_type aType, const parameter_type& aParameter1 = parameter_type(), const parameter_type& aParameter2 = parameter_type(), const parameter_type& aParameter3 = parameter_type()) :
203 iType(aType), iParameter1(aParameter1), iParameter2(aParameter2), iParameter3(aParameter3)
204 {
205 }
206 public:
208 {
209 return iType;
210 }
212 {
213 return static_variant_cast<neogfx::scan_code_e>(iParameter1);
214 }
216 {
217 return static_variant_cast<neogfx::key_code_e>(iParameter2);
218 }
220 {
221 return static_variant_cast<neogfx::key_modifiers_e>(iParameter3);
222 }
223 std::string text() const
224 {
225 return static_variant_cast<string>(iParameter1);
226 }
227 private:
229 parameter_type iParameter1;
230 parameter_type iParameter2;
231 parameter_type iParameter3;
232 };
233}
self_type with_position(neogfx::point const &aPosition) const
basic_mouse_event(mouse_event_type aType, const parameter_type &aParameter1=parameter_type{}, const parameter_type &aParameter2=parameter_type{}, const parameter_type &aParameter3=parameter_type{}, const parameter_type &aParameter4=parameter_type{})
mouse_event_type type() const
neogfx::key_modifiers_e key_modifiers() const
neogfx::mouse_button mouse_button() const
neolib::variant< neogfx::point, neogfx::delta, neogfx::mouse_button, neogfx::mouse_wheel, neogfx::key_modifiers_e > parameter_type
neogfx::point position() const
neogfx::mouse_wheel mouse_wheel() const
neogfx::delta wheel_delta() const
keyboard_event(keyboard_event_type aType, const parameter_type &aParameter1=parameter_type(), const parameter_type &aParameter2=parameter_type(), const parameter_type &aParameter3=parameter_type())
neogfx::scan_code_e scan_code() const
keyboard_event abstract_type
neogfx::key_modifiers_e key_modifiers() const
std::string text() const
neolib::variant< neogfx::scan_code_e, neogfx::key_code_e, neogfx::key_modifiers_e, string > parameter_type
keyboard_event_type type() const
neogfx::key_code_e key_code() const
neogfx::point position() const
window_event_type type() const
window_event abstract_type
void set_position(const neogfx::point &aPosition)
void set_extents(const neogfx::size &aExtents)
window_event(window_event_type aType, const parameter_type &aParameter=parameter_type{})
neolib::variant< neogfx::size, neogfx::point > parameter_type
bool has_parameter() const
neogfx::size extents() const
basic_mouse_event< mouse_event_location::NonClient > non_client_mouse_event
mouse_wheel
Definition i_mouse.hpp:42
mouse_button
Definition i_mouse.hpp:31
basic_mouse_event< mouse_event_location::Client > mouse_event