Răsfoiți Sursa

unstub OsWindow

mikymod 12 ani în urmă
părinte
comite
70085b1192
2 a modificat fișierele cu 38 adăugiri și 35 ștergeri
  1. 29 26
      engine/os/win/OsWindow.cpp
  2. 9 9
      engine/os/win/OsWindow.h

+ 29 - 26
engine/os/win/OsWindow.cpp

@@ -24,18 +24,27 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "OsWindow.h"
+#include "StringUtils.h"
 
 namespace crown
 {
 
+HWND m_windows_window = 0;
+
+void oswindow_set_window(HWND handle_win)
+{
+	m_windows_window = handle_win;
+}
+
 //-----------------------------------------------------------------------------
-OsWindow::OsWindow(uint32_t , uint32_t , uint32_t )
-	// m_x(0),
-	// m_y(0),
-	// m_width(width),
-	// m_height(height),
-	// m_resizable(true),
+OsWindow::OsWindow() 
+	: m_x(0)
+	, m_y(0)
+	, m_width(0)
+	, m_height(0)
+	, m_resizable(true)
 {
+	set_title("");
 }
 
 //-----------------------------------------------------------------------------
@@ -46,11 +55,13 @@ OsWindow::~OsWindow()
 //-----------------------------------------------------------------------------
 void OsWindow::show()
 {
+	ShowWindow(m_windows_window, SW_SHOW);
 }
 
 //-----------------------------------------------------------------------------
 void OsWindow::hide()
 {
+	ShowWindow(m_windows_window, SW_HIDE);
 }
 
 //-----------------------------------------------------------------------------
@@ -68,23 +79,27 @@ void OsWindow::get_position(uint32_t& x, uint32_t& y)
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::resize(uint32_t , uint32_t )
+void OsWindow::resize(uint32_t width, uint32_t height)
 {
+	SetWindowPos(m_windows_window, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::move(uint32_t , uint32_t )
+void OsWindow::move(uint32_t x, uint32_t y)
 {
+	SetWindowPos(m_windows_window, NULL, x, y, 0, 0, SWP_NOMOVE | SWP_NOZORDER);
 }
 
 //-----------------------------------------------------------------------------
 void OsWindow::minimize()
 {
+	ShowWindow(m_windows_window, SW_MINIMIZE);
 }
 
 //-----------------------------------------------------------------------------
 void OsWindow::restore()
 {
+	ShowWindow(m_windows_window, SW_RESTORE);
 }
 
 //-----------------------------------------------------------------------------
@@ -94,34 +109,22 @@ bool OsWindow::is_resizable() const
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::set_resizable(bool )
-{
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::show_cursor(bool )
-{
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::get_cursor_xy(int32_t& , int32_t& )
-{
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::set_cursor_xy(int32_t , int32_t )
+void OsWindow::set_resizable(bool resizable)
 {
+	m_resizable = resizable;
 }
 
 //-----------------------------------------------------------------------------
 char* OsWindow::title()
 {
-	return NULL;
+	return m_title;
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::set_title(const char* )
+void OsWindow::set_title(const char* title)
 {
+	string::strncpy(m_title, title, 32);
+	SetWindowText(m_windows_window, m_title);	
 }
 
 } // namespace crown

+ 9 - 9
engine/os/win/OsWindow.h

@@ -24,19 +24,22 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#pragma once
+
+#include <windows.h>
+
 #include "Types.h"
 
 namespace crown
 {
 
+CE_EXPORT void oswindow_set_window(HWND handle_win);
+
 class OsWindow
 {
 public:
 
-	/// Creates the window with the given @a width and @a height.
-	/// When @a parent is != 0, it is interpreted as the OS-specific
-	/// handle of the parent window.
-					OsWindow(uint32_t width, uint32_t height, uint32_t parent);
+					OsWindow();
 					~OsWindow();
 
 	void			show();
@@ -54,16 +57,13 @@ public:
 	bool			is_resizable() const;
 	void			set_resizable(bool resizable);
 
-	void			show_cursor(bool show);
-
-	void			get_cursor_xy(int32_t& x, int32_t& y);
-	void			set_cursor_xy(int32_t x, int32_t y);
-
 	char*			title();
 	void			set_title(const char* title);
 
 private:
 
+	char 			m_title[32];
+
 	uint32_t		m_x;
 	uint32_t		m_y;
 	uint32_t		m_width;