CmRenderWindow.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*-------------------------------------------------------------------------
  2. This source file is a part of OGRE
  3. (Object-oriented Graphics Rendering Engine)
  4. For the latest info, see http://www.ogre3d.org/
  5. Copyright (c) 2000-2011 Torus Knot Software Ltd
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE
  21. -------------------------------------------------------------------------*/
  22. #pragma once
  23. #include "CmPrerequisites.h"
  24. #include "CmRenderTarget.h"
  25. #include "CmVector2I.h"
  26. namespace CamelotFramework
  27. {
  28. enum class WindowBorder
  29. {
  30. Normal,
  31. None,
  32. Fixed
  33. };
  34. struct CM_EXPORT RENDER_WINDOW_DESC
  35. {
  36. RENDER_WINDOW_DESC()
  37. :width(0), height(0), fullscreen(false)
  38. , vsync(false), vsyncInterval(1), hidden(false)
  39. , displayFrequency(60), colorDepth(32), depthBuffer(true)
  40. , FSAA(0), FSAAHint(""), gamma(false), left(-1), top(-1)
  41. , title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(true)
  42. , monitorIndex(-1), toolWindow(false)
  43. { }
  44. UINT32 width;
  45. UINT32 height;
  46. bool fullscreen;
  47. bool vsync;
  48. UINT32 vsyncInterval;
  49. bool hidden;
  50. UINT32 displayFrequency;
  51. UINT32 colorDepth;
  52. bool depthBuffer;
  53. UINT32 FSAA;
  54. String FSAAHint;
  55. bool gamma;
  56. INT32 left; // -1 == screen center
  57. INT32 top; // -1 == screen center
  58. String title;
  59. WindowBorder border;
  60. bool outerDimensions;
  61. bool enableDoubleClick;
  62. bool toolWindow;
  63. UINT32 monitorIndex; // -1 == select based on coordinates
  64. NameValuePairList platformSpecific;
  65. };
  66. class CM_EXPORT RenderWindow : public RenderTarget
  67. {
  68. public:
  69. virtual ~RenderWindow();
  70. /**
  71. * @brief Core method. Alter fullscreen mode options.
  72. */
  73. virtual void setFullscreen(bool fullScreen, UINT32 width, UINT32 height)
  74. { (void)fullScreen; (void)width; (void)height; }
  75. /**
  76. * @brief Core method. Set the visibility state.
  77. */
  78. virtual void setHidden(bool hidden);
  79. /**
  80. * @brief Core method. Alter the size of the window.
  81. */
  82. virtual void resize(UINT32 width, UINT32 height) = 0;
  83. /**
  84. * @brief Core method. Reposition the window.
  85. */
  86. virtual void move(INT32 left, INT32 top) = 0;
  87. /**
  88. * @copydoc RenderTarget::isWindow.
  89. */
  90. bool isWindow() const { return true; }
  91. /**
  92. * @brief Indicates whether the window is visible (not minimized or obscured).
  93. */
  94. virtual bool isVisible(void) const { return true; }
  95. /**
  96. * @copydoc RenderTarget::isActive
  97. */
  98. virtual bool isActive() const { return mActive && isVisible(); }
  99. /**
  100. * @brief Indicates whether the window has been closed by the user.
  101. */
  102. virtual bool isClosed() const = 0;
  103. /**
  104. * @brief Returns true if window is running in fullscreen mode.
  105. */
  106. virtual bool isFullScreen() const;
  107. INT32 getLeft() const { return mLeft; }
  108. INT32 getTop() const { return mTop; }
  109. /**
  110. * @brief Indicates whether the window currently has keyboard focus.
  111. */
  112. bool hasFocus() const { return mHasFocus; }
  113. virtual Vector2I screenToWindowPos(const Vector2I& screenPos) const = 0;
  114. virtual Vector2I windowToScreenPos(const Vector2I& windowPos) const = 0;
  115. virtual void destroy();
  116. static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
  117. protected:
  118. friend class RenderWindowManager;
  119. RenderWindow(const RENDER_WINDOW_DESC& desc);
  120. /**
  121. * @brief Internal method. Core method. Called when window is moved or resized.
  122. */
  123. virtual void _windowMovedOrResized();
  124. /**
  125. * @brief Internal method. Core method. Called when window has received focus.
  126. */
  127. virtual void _windowFocusReceived();
  128. /**
  129. * @brief Internal method. Core method. Called when window has lost focus.
  130. */
  131. virtual void _windowFocusLost();
  132. protected:
  133. bool mIsFullScreen;
  134. INT32 mLeft;
  135. INT32 mTop;
  136. bool mHasFocus;
  137. bool mHidden;
  138. RENDER_WINDOW_DESC mDesc;
  139. };
  140. }