acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
window.h
1// Created by camilo on 2024-09-13 15:55 <3ThomasBorregaardSorensen
2#pragma once
3
4
5#undef USUAL_OPERATING_SYSTEM_SUPPRESSIONS
6#include "acme/_operating_system.h"
7#include "acme/windowing/window.h"
8#include "acme/operating_system/window.h"
9
10
11namespace operating_system
12{
13
14
16 {
17
18
19 HWND m_hwndWindowsWindow;
20
21
22 void Null() { m_hwndWindowsWindow = nullptr; }
23
24 bool is_null() const { return !m_hwndWindowsWindow; }
25
26 };
27
28
29 class windows_window : public ::operating_system::a_window<::windowing::e_operating_ambient_windows, windows_window_t>
30 {
31 public:
32
33
35
36
37 using BASE_TYPE::BASE_TYPE;
38
39
40 windows_window(HWND hwnd)
41 {
42
43 this->operator=(hwnd);
44
45 }
46
47
48 HWND as_HWND() const
49 {
50
51 if(this->m_eoperatingambient == ::windowing::e_operating_ambient_windows)
52 {
53
54 return this->m_window.m_hwndWindowsWindow;
55
56 }
57 else if (this->m_window.m_hwndWindowsWindow)
58 {
59
60 throw ::exception(error_wrong_state);
61
62 }
63 else
64 {
65
66 return nullptr;
67
68 }
69
70 }
71
72
73 using BASE_TYPE::operator=;
74
75 windows_window & operator=(HWND hwnd)
76 {
77
78 this->m_eoperatingambient = ::windowing::e_operating_ambient_windows;
79
80 this->m_window.m_hwndWindowsWindow = hwnd;
81
82 return *this;
83
84 }
85
86 };
87
88
89} // namespace operating_system
90
91#define WIN32_COLOR_WINDOW 5 // WinUser.h (windows.h) COLOR_WINDOW
92#define WIN32_CW_USEDEFAULT ((::i32)0x80000000) // WinUser.h (windows.h) CW_USEDEFAULT
93
94namespace windows
95{
96
97
98 class CLASS_DECL_ACME window :
99 virtual public ::acme::windowing::window
100 {
101 public:
102
103
104 static const ::i32 ID_SHOW_ABOUT_BOX = 64800;
105
106
108 ::f64 m_dVelocity;
109 class ::time m_timeLastSizeMove;
110 ::i32_point m_pointSizeMoveStart;
111 bool m_bMovingNow;
112 bool m_bDefaultSystemMenu;
113 bool m_bSizeMoveMode;
114 //HWND m_hwnd;
115 HMENU m_hmenuSystem;
116 ::i32 m_iDebugAtom = 0;
117 WNDPROC m_wndprocDefault;
118
119 window();
120 ~window() override;
121
122
123 //virtual bool on_window_procedure(LRESULT & lresult, UINT message, WPARAM wparam, LPARAM lparam);
124 virtual bool call_window_procedure(::lresult & lresult, ::u32 message, ::wparam wparam, ::lparam lparam);
125 virtual bool on_window_procedure(::lresult & lresult, ::u32 message, ::wparam wparam, ::lparam lparam);
126 virtual bool _on_default_system_menu_init_menu(::lresult & lresult, ::wparam wparam);
127 virtual bool _on_default_system_menu_command(::lresult & lresult, ::wparam wparam, ::lparam lparam);
128 virtual void _defer_show_system_menu(::user::mouse * ppmouse);
129
130 virtual bool is_window_class_registered(const_char_pointer pszWindowClassName);
131 virtual bool register_window_class(const_char_pointer pszWindowClassName, ::i32 iWindowClassStyle = 0, void * pHCURSOR = nullptr, void * pHBRUSH_Background = (void *) (HBRUSH)WIN32_COLOR_WINDOW);
132 virtual bool _register_window_class(WNDCLASSEXW &wndclassexw, const_char_pointer pszWindowClassName);
133
134
135 virtual ::operating_system::window _create_window_ex(
136 ::u32 dwExStyle,
137 const ::scoped_string & scopedstrWindowClassName,
138 const ::scoped_string & scopedstrWindowName,
139 ::u32 dwStyle,
140 const ::i32_origin_size & originsize = {WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT},
141 const ::operating_system::window & operatingsystemwindowParent = nullptr,
142 void * pHMENU = nullptr,
143 ::hinstance hinstance = nullptr,
144 void * pLPARAM = nullptr);
145
146 inline ::operating_system::window _create_window(
147 const ::scoped_string & scopedstrWindowClassName,
148 const ::scoped_string & scopedstrWindowName,
149 ::u32 dwStyle,
150 const ::i32_origin_size & originsize = {WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT},
151 const ::operating_system::window & operatingsystemwindowParent = nullptr,
152 void * pHMENU = nullptr,
153 ::hinstance hinstance = nullptr,
154 void * pLPARAM = nullptr)
155 {
156 return _create_window_ex(
157 0,
158 scopedstrWindowClassName,
159 scopedstrWindowName,
160 dwStyle,
161 originsize,
162 operatingsystemwindowParent,
163 pHMENU,
164 hinstance,
165 pLPARAM);
166 }
167
168 virtual void createWindowEx(
169 ::u32 dwExStyle,
170 const ::scoped_string & scopedstrWindowClassName,
171 const ::scoped_string & scopedstrWindowName,
172 ::u32 dwStyle,
173 const ::i32_origin_size & originsize = {WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT},
174 const ::operating_system::window & operatingsystemwindowParent = nullptr,
175 void * pHMENU = nullptr);
176
177 inline void createWindow(
178 const ::scoped_string & scopedstrWindowClassName,
179 const ::scoped_string & scopedstrWindowName,
180 ::u32 dwStyle,
181 const ::i32_origin_size & originsize = {WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT,WIN32_CW_USEDEFAULT},
182 const ::operating_system::window & operatingsystemwindowParent = nullptr,
183 void * pHMENU = nullptr)
184 {
185 createWindowEx(
186 0,
187 scopedstrWindowClassName,
188 scopedstrWindowName,
189 dwStyle,
190 originsize,
191 operatingsystemwindowParent,
192 pHMENU);
193 }
194
195 virtual void * _HWND() const;
196 virtual void * _WNDPROC_default() const;
197
198 static LRESULT CALLBACK s_window_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
199 static HINSTANCE s_window_procedure_hinstance();
200
201 virtual void postMessage(::user::enum_message emessage, ::wparam wparam = 0, ::lparam lparam = 0);
202
203
204 bool is_window_visible() override;
205 bool is_window_iconic() override;
206 ::f32 get_window_scale() override;
207
208
209 ::i32_point screen_to_window_client(const ::i32_point & point);
210 ::i32_rectangle screen_to_window_client(const ::i32_rectangle & rectangle);
211 ::i32_point window_client_to_screen(const ::i32_point & point);
212 ::i32_rectangle window_client_to_screen(const ::i32_rectangle & rectangle);
213
214
215
216 void show_window(::i32 iShowFlags) override;
217 void set_window_style(::i32 iStyle) override;
218 ::i64 get_window_style() override;
219
220 void post_message(user::enum_message eusermessage, wparam wparam = {}, lparam lparam = {}) override;
221
222 void set_active_window() override;
223 void set_window_text(const scoped_string &scopedstr) override;
224 void set_window_position(const ::operating_system::window & operatingsystemwindow, const ::i32_point & point, const ::i32_size & size, ::i32 iSetWindowPosFlags) override;
225 void window_invalidate_rect(const i32_rectangle *prectangle, bool bErase) override;
226 void update_window() override;
227 void redraw_window(const i32_rectangle *prectangle, void *pHRGN, ::i32 iRedrawFlags) override;
228 void window_set_focus() override;
229 void set_foreground_window(::user::activation_token *puseractivationtoken) override;
230 ::i32_rectangle window_get_client_rect() override;
231 ::i32_rectangle get_window_rect() override;
232 bool defer_update_system_menu() override;
233 void dump_operating_system_child_window_hierarchy() override;
234
235
236 virtual ::i32 _on_non_client_hit_test(const ::i32_point &point);
237
238
239 };
240
241
242 //CLASS_DECL_ACME LRESULT CALLBACK window_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
243
244
245} // namespace windows
246
247
248
249
250
251
Definition window.h:50
Definition lparam.h:9
Definition window.h:289
Definition window.h:30
static LRESULT CALLBACK s_window_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition window.cpp:919
Definition wparam.h:10