From 586ed2dfd2a62f1f858486f03389c82996f04ca3 Mon Sep 17 00:00:00 2001
From: Karutoh <NelsonArron@outlook.com>
Date: Mon, 5 Feb 2024 23:55:53 -0800
Subject: [PATCH] Fixed window for Windows.

---
 include/ehs/io/BaseWindow.h | 12 ++++++------
 include/ehs/io/Window_W32.h | 36 +++++++++++++++++++++---------------
 src/io/Window_W32.cpp       | 33 +++++++++++++++++++++++----------
 3 files changed, 50 insertions(+), 31 deletions(-)

diff --git a/include/ehs/io/BaseWindow.h b/include/ehs/io/BaseWindow.h
index 21466a9..3dd0def 100644
--- a/include/ehs/io/BaseWindow.h
+++ b/include/ehs/io/BaseWindow.h
@@ -40,11 +40,11 @@ namespace ehs
 
 		BaseWindow& operator=(const BaseWindow& win);
 
-        virtual void Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale) = 0;
+        virtual void Create_32(const Str_32& title, const Vec2_s32& pos, Vec2_u32 scale) = 0;
 
-        virtual void Create_16(const Str_16& title, const Vec2_s32& pos, const Vec2_u32 scale) = 0;
+        virtual void Create_16(const Str_16& title, const Vec2_s32& pos, Vec2_u32 scale) = 0;
 
-        virtual void Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale) = 0;
+        virtual void Create_8(const Str_8& title, const Vec2_s32& pos, Vec2_u32 scale) = 0;
 
 		virtual void OnCreated() = 0;
 
@@ -60,7 +60,7 @@ namespace ehs
 
 		bool HasFocus() const;
 
-    	void EnableResizing(const bool enable);
+    	void EnableResizing(bool enable);
 
     	bool IsResizable() const;
 
@@ -77,7 +77,7 @@ namespace ehs
 		/// @returns The current status.
 		bool IsCursorVisible() const;
 
-		virtual void ConstrainCursor(const bool constrain) = 0;
+		virtual void ConstrainCursor(bool constrain) = 0;
 
 		bool IsCursorConstrained() const;
 
@@ -109,6 +109,6 @@ namespace ehs
 
     	virtual void SetClipboard(Serializer<UInt_64> data) = 0;
 
-    	virtual void SetCursorImg(const CursorImg img) = 0;
+    	virtual void SetCursorImg(CursorImg img) = 0;
     };
 }
diff --git a/include/ehs/io/Window_W32.h b/include/ehs/io/Window_W32.h
index af81557..e88e1e8 100644
--- a/include/ehs/io/Window_W32.h
+++ b/include/ehs/io/Window_W32.h
@@ -26,7 +26,7 @@ namespace ehs
         static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
     public:
-		virtual ~Window() override;
+        ~Window() override;
 
         Window();
 
@@ -34,22 +34,22 @@ namespace ehs
 
         Window& operator=(const Window &win);
 
-        virtual bool Poll() override;
+        bool Poll() override;
 
         ///Creates the native window.
-        void Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
+        void Create_32(const Str_32& title, const Vec2_s32& pos, Vec2_u32 scale) override;
 
         ///Creates the native window.
-        void Create_16(const Str_16& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
+        void Create_16(const Str_16& title, const Vec2_s32& pos, Vec2_u32 scale) override;
 
         ///Creates the native window.
-        void Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
+        void Create_8(const Str_8& title, const Vec2_s32& pos, Vec2_u32 scale) override;
 
         ///Uses an already existing window to render an overlay.
         void Use(HWND windowHdl);
 
         ///Closes the window.
-        virtual void Close() override;
+        void Close() override;
 
         ///Shows the window.
         void Show() override;
@@ -59,15 +59,15 @@ namespace ehs
 
         void SetTitle_32(const Str_32& title) override;
 
-        Str_32 GetTitle_32();
+        Str_32 GetTitle_32() const override;
 
         void SetTitle_16(const Str_16& title) override;
 
-        Str_16 GetTitle_16();
+        Str_16 GetTitle_16() const override;
 
         void SetTitle_8(const Str_8& title) override;
 
-        Str_8 GetTitle_8();
+        Str_8 GetTitle_8() const override;
 
 		void SetIcon(const Str_8& filePath);
 
@@ -99,29 +99,35 @@ namespace ehs
         /// Sets the windows position on the desktop.
         /// @param [in] x The x axis in pixels.
         /// @param [in] y The y axis in pixels.
-        void SetPos(int x, int y);
+        void SetPos(const Vec2_s32& newPos) override;
 
         /// Gets the windows current position on the desktop.
         /// @returns The current value.
-        Vec2<Int_32> GetPos();
+        Vec2_s32 GetPos() const override;
 
         virtual void OnResized(const Vec2<UInt_32>& newSize);
 
         /// Sets the windows scale which includes the border.
         /// @param [in] w The width in pixels.
         /// @param [in] h The height in pixels.
-        void SetSize(int w, int h);
+        void SetScale(const Vec2_u32& newScale) override;
 
         /// Gets the windows current scale.
         /// @returns The current value.
-        Vec2<Int_32> GetSize();
+        Vec2_u32 GetScale() const override;
 
 		void ShowCursor(bool toggle) override;
 
-		void ConstrainCursor(const bool toggle) override;
+		void ConstrainCursor(bool toggle) override;
+
+        Serializer<UInt_64> GetClipboard() override;
+
+        void SetClipboard(Serializer<UInt_64> data) override;
+
+        void SetCursorImg(CursorImg img) override;
 
     protected:
-        void SendMsg(const UINT msg, const WPARAM wParam, const LPARAM lParam);
+        void SendMsg(UINT msg, WPARAM wParam, LPARAM lParam);
 
     };
 }
\ No newline at end of file
diff --git a/src/io/Window_W32.cpp b/src/io/Window_W32.cpp
index 3ed1165..2ae1097 100644
--- a/src/io/Window_W32.cpp
+++ b/src/io/Window_W32.cpp
@@ -437,7 +437,7 @@ namespace ehs
 			EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
 	}
 
-	Str_32 Window::GetTitle_32()
+	Str_32 Window::GetTitle_32() const
 	{
 		int size = GetWindowTextLengthW(hdl);
 		if (!size)
@@ -474,7 +474,7 @@ namespace ehs
 			EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
 	}
 
-	Str_16 Window::GetTitle_16()
+	Str_16 Window::GetTitle_16() const
 	{
 		int size = GetWindowTextLengthW(hdl);
 		if (!size)
@@ -511,7 +511,7 @@ namespace ehs
 			EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
 	}
 
-	Str_8 Window::GetTitle_8()
+	Str_8 Window::GetTitle_8() const
 	{
 		int size = GetWindowTextLengthW(hdl);
 		if (!size)
@@ -590,15 +590,15 @@ namespace ehs
 		return IsWindowEnabled(hdl);
 	}
 
-	void Window::SetPos(int x, int y)
+	void Window::SetPos(const Vec2_s32& newPos)
 	{
 		if (!created)
 			return;
 
-		SetWindowPos(hdl, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+		SetWindowPos(hdl, nullptr, newPos.x, newPos.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
 	}
 
-	Vec2<Int_32> Window::GetPos()
+    Vec2_s32 Window::GetPos() const
 	{
 		if (!created)
 			return {};
@@ -643,15 +643,15 @@ namespace ehs
 	{
 	}
 
-	void Window::SetSize(int w, int h)
+	void Window::SetScale(const Vec2_u32& newScale)
 	{
 		if (!created)
 			return;
 
-		SetWindowPos(hdl, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+		SetWindowPos(hdl, nullptr, 0, 0, (int)newScale.x, (int)newScale.y, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
 	}
 
-	Vec2<Int_32> Window::GetSize()
+    Vec2_u32 Window::GetScale() const
 	{
 		if (!created)
 			return {};
@@ -659,7 +659,7 @@ namespace ehs
 		RECT tmp = {};
 		GetWindowRect(hdl, &tmp);
 
-		return {(Int_32)(tmp.right - tmp.left), (Int_32)(tmp.bottom - tmp.top)};
+		return {(UInt_32)(tmp.right - tmp.left), (UInt_32)(tmp.bottom - tmp.top)};
 	}
 
 	void Window::ShowCursor(bool toggle)
@@ -717,6 +717,19 @@ namespace ehs
 		cursorConstrained = toggle;
 	}
 
+    Serializer<UInt_64> Window::GetClipboard()
+    {
+        return {};
+    }
+
+    void Window::SetClipboard(Serializer<UInt_64> data)
+    {
+    }
+
+    void Window::SetCursorImg(CursorImg img)
+    {
+    }
+
 	void Window::SendMsg(const UINT msg, const WPARAM wParam, const LPARAM lParam)
 	{
 		if (!hdl)