os_window_windows.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "config.h"
  6. #if CROWN_PLATFORM_WINDOWS
  7. #include "os_window_windows.h"
  8. #include "string_utils.h"
  9. namespace crown
  10. {
  11. HWND m_windows_window = 0;
  12. void oswindow_set_window(HWND handle_win)
  13. {
  14. m_windows_window = handle_win;
  15. }
  16. OsWindow::OsWindow()
  17. : m_resizable(true)
  18. {
  19. set_title("");
  20. }
  21. OsWindow::~OsWindow()
  22. {
  23. }
  24. void OsWindow::show()
  25. {
  26. ShowWindow(m_windows_window, SW_SHOW);
  27. }
  28. void OsWindow::hide()
  29. {
  30. ShowWindow(m_windows_window, SW_HIDE);
  31. }
  32. void OsWindow::resize(uint32_t width, uint32_t height)
  33. {
  34. SetWindowPos(m_windows_window, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
  35. }
  36. void OsWindow::move(uint32_t x, uint32_t y)
  37. {
  38. SetWindowPos(m_windows_window, NULL, x, y, 0, 0, SWP_NOMOVE | SWP_NOZORDER);
  39. }
  40. void OsWindow::minimize()
  41. {
  42. ShowWindow(m_windows_window, SW_MINIMIZE);
  43. }
  44. void OsWindow::restore()
  45. {
  46. ShowWindow(m_windows_window, SW_RESTORE);
  47. }
  48. bool OsWindow::is_resizable() const
  49. {
  50. return m_resizable;
  51. }
  52. void OsWindow::set_resizable(bool resizable)
  53. {
  54. m_resizable = resizable;
  55. }
  56. char* OsWindow::title()
  57. {
  58. return m_title;
  59. }
  60. void OsWindow::set_title(const char* title)
  61. {
  62. strncpy(m_title, title, 32);
  63. SetWindowText(m_windows_window, m_title);
  64. }
  65. } // namespace crown
  66. #endif // CROWN_PLATFORM_WINDOWS