diff options
author | crupest <crupest@outlook.com> | 2021-09-29 19:02:50 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-09-29 19:02:50 +0800 |
commit | 0338eb4f547f8eebe8c838c0794ec935db3cf0d8 (patch) | |
tree | 7de1dad266e1855e82a394280167e2f29abcfa87 | |
parent | d7ed676ada2d4f6781e79118e21d1f59745975a2 (diff) | |
download | cru-0338eb4f547f8eebe8c838c0794ec935db3cf0d8.tar.gz cru-0338eb4f547f8eebe8c838c0794ec935db3cf0d8.tar.bz2 cru-0338eb4f547f8eebe8c838c0794ec935db3cf0d8.zip |
...
-rw-r--r-- | include/cru/osx/gui/Window.hpp | 55 | ||||
-rw-r--r-- | src/osx/gui/Window.mm | 27 |
2 files changed, 79 insertions, 3 deletions
diff --git a/include/cru/osx/gui/Window.hpp b/include/cru/osx/gui/Window.hpp index 14ad05ad..1e790a65 100644 --- a/include/cru/osx/gui/Window.hpp +++ b/include/cru/osx/gui/Window.hpp @@ -1,18 +1,67 @@ #pragma once #include "Resource.hpp" -#include "cru/platform/gui/Base.hpp" #include "cru/platform/gui/Window.hpp" +#include <memory> + namespace cru::platform::gui::osx { -class OsxWindow : public OsxGuiResource, public virtual INativeWindow { +namespace details { +class OsxWindowPrivate; +} + +class OsxUiApplication; + +class OsxWindow : public OsxGuiResource, public INativeWindow { + friend details::OsxWindowPrivate; + public: - OsxWindow(); + explicit OsxWindow(OsxUiApplication* ui_application); CRU_DELETE_COPY(OsxWindow) CRU_DELETE_MOVE(OsxWindow) ~OsxWindow() override; + public: + void Close() override; + + INativeWindow* GetParent() override; + + bool IsVisible() override; + void SetVisible(bool is_visible) override; + + Size GetClientSize() override; + void SetClientSize(const Size& size) override; + + Rect GetWindowRect() override; + void SetWindowRect(const Rect& rect) override; + + Point GetMousePosition() override; + + bool CaptureMouse() override; + bool ReleaseMouse() override; + + void SetCursor(std::shared_ptr<ICursor> cursor) override; + + void RequestRepaint() override; + + std::unique_ptr<graphics::IPainter> BeginPaint() override; + + IEvent<std::nullptr_t>* DestroyEvent() override; + IEvent<std::nullptr_t>* PaintEvent() override; + IEvent<Size>* ResizeEvent() override; + IEvent<FocusChangeType>* FocusEvent() override; + IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() override; + IEvent<Point>* MouseMoveEvent() override; + IEvent<NativeMouseButtonEventArgs>* MouseDownEvent() override; + IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() override; + IEvent<NativeMouseWheelEventArgs>* MouseWheelEvent() override; + IEvent<NativeKeyEventArgs>* KeyDownEvent() override; + IEvent<NativeKeyEventArgs>* KeyUpEvent() override; + + IInputMethodContext* GetInputMethodContext() override; + private: + std::unique_ptr<details::OsxWindowPrivate> p_; }; } // namespace cru::platform::gui::osx diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm index e69de29b..1ee0299a 100644 --- a/src/osx/gui/Window.mm +++ b/src/osx/gui/Window.mm @@ -0,0 +1,27 @@ +#include "cru/osx/gui/Window.hpp" + +#include "cru/osx/gui/UiApplication.hpp" + +namespace cru::platform::gui::osx { +namespace details { +class OsxWindowPrivate { + friend OsxWindow; + + public: + explicit OsxWindowPrivate(OsxWindow* osx_window) : osx_window_(osx_window) {} + + CRU_DELETE_COPY(OsxWindowPrivate) + CRU_DELETE_MOVE(OsxWindowPrivate) + + ~OsxWindowPrivate() = default; + + private: + OsxWindow* osx_window_; +}; +} + +OsxWindow::OsxWindow(OsxUiApplication* ui_application) + : OsxGuiResource(ui_application), p_(new details::OsxWindowPrivate(this)) {} + +OsxWindow::~OsxWindow() {} +} |