aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui
diff options
context:
space:
mode:
Diffstat (limited to 'CruUI/ui')
-rw-r--r--CruUI/ui/events/ui_event.h42
-rw-r--r--CruUI/ui/window.cpp15
-rw-r--r--CruUI/ui/window.h2
3 files changed, 58 insertions, 1 deletions
diff --git a/CruUI/ui/events/ui_event.h b/CruUI/ui/events/ui_event.h
index 4915d63d..a17067c7 100644
--- a/CruUI/ui/events/ui_event.h
+++ b/CruUI/ui/events/ui_event.h
@@ -215,6 +215,47 @@ namespace cru
bool new_state_;
};
+ struct WindowNativeMessage
+ {
+ HWND hwnd;
+ int msg;
+ WPARAM w_param;
+ LPARAM l_param;
+ };
+
+ class WindowNativeMessageEventArgs : public UiEventArgs
+ {
+ public:
+ WindowNativeMessageEventArgs(Object* sender, Object* original_sender, const WindowNativeMessage& message)
+ : UiEventArgs(sender, original_sender), message_(message), result_(std::nullopt)
+ {
+
+ }
+ WindowNativeMessageEventArgs(const WindowNativeMessageEventArgs& other) = default;
+ WindowNativeMessageEventArgs(WindowNativeMessageEventArgs&& other) = default;
+ WindowNativeMessageEventArgs& operator=(const WindowNativeMessageEventArgs& other) = default;
+ WindowNativeMessageEventArgs& operator=(WindowNativeMessageEventArgs&& other) = default;
+ ~WindowNativeMessageEventArgs() override = default;
+
+ WindowNativeMessage GetWindowMessage() const
+ {
+ return message_;
+ }
+
+ std::optional<LRESULT> GetResult() const
+ {
+ return result_;
+ }
+
+ void SetResult(const std::optional<LRESULT> result)
+ {
+ result_ = result;
+ }
+
+ private:
+ WindowNativeMessage message_;
+ std::optional<LRESULT> result_;
+ };
using UiEvent = Event<UiEventArgs>;
using MouseEvent = Event<MouseEventArgs>;
@@ -224,6 +265,7 @@ namespace cru
using SizeChangedEvent = Event<SizeChangedEventArgs>;
using FocusChangeEvent = Event<FocusChangeEventArgs>;
using ToggleEvent = Event<ToggleEventArgs>;
+ using WindowNativeMessageEvent = Event<WindowNativeMessageEventArgs>;
}
}
} \ No newline at end of file
diff --git a/CruUI/ui/window.cpp b/CruUI/ui/window.cpp
index b20abb61..6ff962b6 100644
--- a/CruUI/ui/window.cpp
+++ b/CruUI/ui/window.cpp
@@ -82,7 +82,7 @@ namespace cru
Vector<Window*> windows;
for (auto [key, value] : window_map_)
windows.push_back(value);
- return std::move(windows);
+ return windows;
}
inline Point PiToDip(const POINT& pi_point)
@@ -201,6 +201,19 @@ namespace cru
}
bool Window::HandleWindowMessage(HWND hwnd, int msg, WPARAM w_param, LPARAM l_param, LRESULT & result) {
+
+ if (!native_message_event.IsNoHandler())
+ {
+ const events::WindowNativeMessage message{hwnd, msg, w_param, l_param};
+ events::WindowNativeMessageEventArgs args(this, this, message);
+ native_message_event.Raise(args);
+ if (args.GetResult().has_value())
+ {
+ result = args.GetResult().value();
+ return true;
+ }
+ }
+
switch (msg) {
case WM_PAINT:
OnPaintInternal();
diff --git a/CruUI/ui/window.h b/CruUI/ui/window.h
index b9e9a184..42ebf477 100644
--- a/CruUI/ui/window.h
+++ b/CruUI/ui/window.h
@@ -194,6 +194,8 @@ namespace cru {
events::UiEvent activated_event;
events::UiEvent deactivated_event;
+ events::WindowNativeMessageEvent native_message_event;
+
private:
//*************** region: native operations ***************