macWindowManager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  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
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _MACWINDOWMANAGER_H_
  23. #define _MACWINDOWMANAGER_H_
  24. #include "windowManager/platformWindowMgr.h"
  25. #include "core/util/tVector.h"
  26. class MacWindow;
  27. class MacWindowManager : public PlatformWindowManager
  28. {
  29. private:
  30. typedef VectorPtr<MacWindow*> WindowList;
  31. WindowList mWindowList;
  32. U32 mFadeToken;
  33. Delegate<bool(void)> mNotifyShutdownDelegate;
  34. public:
  35. MacWindowManager();
  36. ~MacWindowManager();
  37. virtual void setParentWindow(void* newParent) {
  38. }
  39. /// Get the parent window
  40. virtual void* getParentWindow()
  41. {
  42. return NULL;
  43. }
  44. virtual PlatformWindow *createWindow(GFXDevice *device, const GFXVideoMode &mode);
  45. /// @name Desktop Queries
  46. /// @{
  47. /// Return the extents in window coordinates of the primary desktop
  48. /// area. On a single monitor system this is just the display extents.
  49. /// On a multi-monitor system this is the primary monitor (which Torque should
  50. /// launch on).
  51. virtual RectI getPrimaryDesktopArea();
  52. /// Populate a vector with all monitors and their extents in window space.
  53. virtual void getMonitorRegions(Vector<RectI> &regions);
  54. /// Retrieve the currently set desktop bit depth
  55. /// @return The current desktop bit depth, or -1 if an error occurred
  56. virtual S32 getDesktopBitDepth();
  57. /// Retrieve the currently set desktop resolution
  58. /// @return The current desktop bit depth, or Point2I(-1,-1) if an error occurred
  59. virtual Point2I getDesktopResolution();
  60. /// @}
  61. /// @name Window Lookup
  62. /// @{
  63. /// Get the number of Window's in this system
  64. virtual S32 getWindowCount();
  65. /// Populate a list with references to all the windows created from this manager.
  66. virtual void getWindows(VectorPtr<PlatformWindow*> &windows);
  67. /// Get a window from a device ID.
  68. ///
  69. /// @return The window associated with the specified ID, or NULL if no
  70. /// match was found.
  71. virtual PlatformWindow *getWindowById(WindowId id);
  72. virtual PlatformWindow *getFirstWindow();
  73. virtual PlatformWindow* getFocusedWindow();
  74. /// During full-screen toggles we want to suppress ugly transition states,
  75. /// which we do (on Win32) by showing and hiding a full-monitor black window.
  76. ///
  77. /// This method cues the appearance of that window ("lowering the curtain").
  78. virtual void lowerCurtain();
  79. /// @see lowerCurtain
  80. ///
  81. /// This method removes the curtain window.
  82. virtual void raiseCurtain();
  83. /// @}
  84. /// @name Command Line Usage
  85. /// @{
  86. /// Process command line arguments sent to this window manager
  87. /// to manipulate it's windows.
  88. virtual void _processCmdLineArgs(const S32 argc, const char **argv);
  89. /// @}
  90. // static MacWindowManager* get() { return (MacWindowManager*)PlatformWindowManager::get(); }
  91. void _addWindow(MacWindow* window);
  92. void _removeWindow(MacWindow* window);
  93. void _onAppSignal(WindowId wnd, S32 event);
  94. bool onShutdown();
  95. bool canWindowGainFocus(MacWindow* window);
  96. private:
  97. bool mIsShuttingDown;
  98. };
  99. #endif