RenderWindow.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "Types.h"
  24. #include "Str.h"
  25. namespace Crown
  26. {
  27. /**
  28. Rendering window interface.
  29. The primary target for render operations.
  30. */
  31. class RenderWindow
  32. {
  33. public:
  34. static RenderWindow* CreateWindow(uint x, uint y, uint width, uint height, uint depth, bool fullscreen);
  35. static void DestroyWindow(RenderWindow* window);
  36. RenderWindow(); //!< Constructor
  37. virtual ~RenderWindow(); //!< Destructor
  38. virtual bool Create(uint x, uint y, uint width, uint height, uint depth, bool fullscreen) = 0; //! Creates the window
  39. virtual void Destroy() = 0; //!< Destroys the window
  40. virtual bool IsMain() const; //!< Returns whether is the main
  41. virtual bool IsVisible() const; //!< Returns whether is visible
  42. virtual void SetVisible(bool visible) = 0; //!< Sets whether is visible
  43. virtual void GetPosition(uint& x, uint& y); //!< Returns the position
  44. virtual void Move(uint x, uint y) = 0; //!< Sets the position
  45. virtual void GetMetrics(uint& width, uint& height) const; //!< Returns width and height
  46. virtual void Resize(uint width, uint height) = 0; //!< Sets width and height
  47. virtual bool IsFullscreen() const; //!< Returns whether in fullscreen
  48. virtual void SetFullscreen(bool full) = 0; //!< Switches to fullscreen
  49. const Str& GetTitle() const; //!< Returns the title
  50. void SetTitle(const Str& title); //!< Sets the title
  51. const Str& GetAdditionalTitleText() const; //!< Get the additional title text
  52. void SetAdditionalTitleText(const Str& title); //!< Set the additional title text
  53. Str GetDisplayedTitle() const; //!< Returns the actual title
  54. virtual void Update() = 0; //!< Updates displayed content
  55. virtual void EventLoop() = 0; //!< Manages window events
  56. protected:
  57. void _SetMain(bool main); //!< Sets as the main window, only Device should use it
  58. uint mX, mY;
  59. uint mWidth, mHeight;
  60. bool mVisible;
  61. bool mActive;
  62. bool mFull;
  63. bool mCreated;
  64. bool mMain;
  65. Str mTitle;
  66. Str mAdditionalTitleText;
  67. virtual void _SetTitleAndAdditionalTextToWindow() = 0; //!< Sets the title and the additional title text
  68. friend class Device;
  69. };
  70. } // namespace Crown