diff options
Diffstat (limited to 'include/cru/platform/native/native_window.hpp')
-rw-r--r-- | include/cru/platform/native/native_window.hpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp index 8a067a4c..cd2459e0 100644 --- a/include/cru/platform/native/native_window.hpp +++ b/include/cru/platform/native/native_window.hpp @@ -9,7 +9,7 @@ #include "native_event.hpp" namespace cru::platform::graph { -class Painter; +struct IPainter; } namespace cru::platform::native { @@ -21,28 +21,18 @@ namespace cru::platform::native { // Close or closed by the user, which leads to an invalid instance. You can // check the validity by IsValid. When you call perform native operations on the // invalid instance, there is no effect. -class NativeWindow : public NativeResource { - protected: - NativeWindow() = default; - - public: - NativeWindow(const NativeWindow& other) = delete; - NativeWindow& operator=(const NativeWindow& other) = delete; - - NativeWindow(NativeWindow&& other) = delete; - NativeWindow& operator=(NativeWindow&& other) = delete; - - ~NativeWindow() override = default; - - public: +struct INativeWindow : public virtual INativeResource { // Return if the window is still valid, that is, hasn't been closed or // destroyed. virtual bool IsValid() = 0; + + // Set if the instance is deleted automatically when the window is destroyed + // by other ways. Default is true. virtual void SetDeleteThisOnDestroy(bool value) = 0; virtual void Close() = 0; - virtual NativeWindow* GetParent() = 0; + virtual INativeWindow* GetParent() = 0; virtual bool IsVisible() = 0; virtual void SetVisible(bool is_visible) = 0; @@ -64,16 +54,18 @@ class NativeWindow : public NativeResource { virtual bool CaptureMouse() = 0; virtual bool ReleaseMouse() = 0; - virtual void SetCursor(std::shared_ptr<Cursor> cursor) = 0; + virtual void SetCursor(std::shared_ptr<ICursor> cursor) = 0; + + virtual void RequestRepaint() = 0; - virtual void Repaint() = 0; - virtual graph::Painter* BeginPaint() = 0; + // Remember to call EndDraw on return value and destroy it. + virtual std::unique_ptr<graph::IPainter> BeginPaint() = 0; virtual IEvent<std::nullptr_t>* DestroyEvent() = 0; virtual IEvent<std::nullptr_t>* PaintEvent() = 0; virtual IEvent<Size>* ResizeEvent() = 0; - virtual IEvent<bool>* FocusEvent() = 0; - virtual IEvent<bool>* MouseEnterLeaveEvent() = 0; + virtual IEvent<FocusChangeType>* FocusEvent() = 0; + virtual IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() = 0; virtual IEvent<Point>* MouseMoveEvent() = 0; virtual IEvent<NativeMouseButtonEventArgs>* MouseDownEvent() = 0; virtual IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() = 0; |