Torque3D Documentation / _generateds / platformWindowMgr.h

platformWindowMgr.h

Engine/source/windowManager/platformWindowMgr.h

More...

Classes:

class

Abstract representation of a manager for native OS windows.

Public Defines

define

Public Functions

Global function to allocate a new platform window manager.

Detailed Description

Public Defines

WindowManager() ()

Public Functions

CreatePlatformWindowManager()

Global function to allocate a new platform window manager.

This returns an instance of the appropriate window manager for the current OS.

Depending on situation (for instance, if we are a web plugin) we may need to get the window manager from somewhere else.

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _PLATFORM_PLATFORMWINDOWMGR_H_
 25#define _PLATFORM_PLATFORMWINDOWMGR_H_
 26
 27#include "math/mRect.h"
 28#include "core/util/journal/journaledSignal.h"
 29#include "windowManager/platformWindow.h"
 30
 31
 32// Global macro
 33#define WindowManager PlatformWindowManager::get()
 34
 35/// Abstract representation of a manager for native OS windows.
 36///
 37/// The PlatformWindowManager interface provides a variety of methods for querying 
 38/// the current desktop configuration, as well as allocating and retrieving
 39/// existing windows. It may also manage application-level event handling.
 40class PlatformWindowManager
 41{
 42   // Generator for window IDs.
 43   S32 mIdSource;
 44   
 45protected:
 46   /// Get the next available window Id
 47   inline S32 getNextId() { return mIdSource++; }
 48public:
 49
 50   /// Get Global Singleton
 51   static PlatformWindowManager *get();
 52   
 53   PlatformWindowManager() : mIdSource(0) {};
 54
 55   virtual ~PlatformWindowManager() 
 56   {
 57   }
 58
 59   static void processCmdLineArgs(const S32 argc, const char **argv);
 60
 61   /// Return the extents in window coordinates of the primary desktop
 62   /// area. On a single monitor system this is just the display extents.
 63   /// On a multimon system this is the primary monitor (which Torque should
 64   /// launch on).
 65   virtual RectI getPrimaryDesktopArea() = 0;
 66
 67   /// Retrieve the currently set desktop bit depth
 68   /// @return The current desktop bit depth, or -1 if an error occurred
 69   virtual S32 getDesktopBitDepth() = 0;
 70
 71   /// Retrieve the currently set desktop resolution
 72   /// @return The current desktop bit depth, or Point2I(-1,-1) if an error occurred
 73   virtual Point2I getDesktopResolution() = 0;
 74
 75   // Build out the monitor list.
 76   virtual void buildMonitorsList() {}
 77
 78   // Find the first monitor index that matches the given name.  The actual match
 79   // algorithm depends on the implementation.  Provides a default value of -1 to
 80   // indicate no match.
 81   virtual S32 findFirstMatchingMonitor(const char* name) { return -1; }
 82
 83   // Retrieve the number of monitors.  Provides a default count of 0 for systems that
 84   // don't provide information on connected monitors.
 85   virtual U32 getMonitorCount() { return 0; }
 86
 87   // Get the name of the requested monitor.  Provides a default of "" for platorms
 88   // that do not provide information on connected monitors.
 89   virtual const char* getMonitorName(U32 index) { return ""; }
 90
 91   // Get the requested monitor's rectangular region.
 92   virtual RectI getMonitorRect(U32 index) { return RectI(0, 0, 0, 0); }
 93
 94   // Get the requested monitor's rectangular region.
 95   // Use this function to get the usable desktop area represented by a display,
 96   // with the primary display located at 0,0. 
 97   virtual RectI getMonitorUsableRect(U32 index) { return RectI(0, 0, 0, 0); }
 98
 99   // Retrieve the number of display modes available on a monitor.  Provides a default
100   // count of 0 for systems that don't provide information on connected monitors.
101   virtual U32 getMonitorModeCount(U32 monitorIndex) { return 0; }
102
103   // Gets a display mode for a specific monitor.  Provides a default of "" for platorms
104   // that do not provide information on connected monitors.
105   virtual const String getMonitorMode(U32 monitorIndex, U32 modeIndex) { return String::EmptyString; }
106
107   // Gets the current desktop display mode for a specific monitor.  Provides a default
108   // of "" for platorms that do not provide information on connected monitors.
109   virtual const String getMonitorDesktopMode(U32 monitorIndex) { return String::EmptyString; }
110
111   /// Populate a vector with all monitors and their extents in window space.
112   virtual void getMonitorRegions(Vector<RectI> &regions) = 0;
113
114   /// Create a new window, appropriate for the specified device and mode.
115   ///
116   /// @return Pointer to the new window.
117   virtual PlatformWindow *createWindow(GFXDevice *device, const GFXVideoMode &mode) = 0;
118
119   /// Populate a list with references to all the windows created from this manager.
120   virtual void getWindows(VectorPtr<PlatformWindow*> &windows) = 0;
121
122   /// Get the window that currently has the input focus or NULL.
123   virtual PlatformWindow* getFocusedWindow() = 0;
124
125   /// Get a window from a device ID.
126   ///
127   /// @return The window associated with the specified ID, or NULL if no
128   ///         match was found.
129   virtual PlatformWindow *getWindowById(WindowId id)=0;
130
131   /// Get the first window in the window list
132   ///
133   /// @return The first window in the list, or NULL if no windows found
134   virtual PlatformWindow *getFirstWindow()=0;
135
136
137   /// Set the parent window
138   ///
139   /// This can be used to render in a child window.
140   virtual void setParentWindow(void* newParent) = 0;
141
142   /// Get the parent window
143   virtual void* getParentWindow() = 0;
144
145
146   /// This method cues the appearance of that window ("lowering the curtain").
147   virtual void lowerCurtain()=0;
148
149   /// @see lowerCurtain
150   ///
151   /// This method removes the curtain window.
152   virtual void raiseCurtain()=0;
153
154   /// This method indicates to created windows to show as normal.
155   virtual void setDisplayWindow(bool set){}
156
157private:
158   /// Process command line arguments from StandardMainLoop. This is done to
159   /// allow web plugin functionality, where we are passed platform-specific
160   /// information allowing us to set ourselves up in the web browser,
161   /// to occur in a platform-neutral way.
162   virtual void _processCmdLineArgs(const S32 argc, const char **argv)=0;
163};
164
165/// Global function to allocate a new platform window manager.
166///
167/// This returns an instance of the appropriate window manager for the current OS.
168///
169/// Depending on situation (for instance, if we are a web plugin) we may
170/// need to get the window manager from somewhere else.
171PlatformWindowManager *CreatePlatformWindowManager();
172
173#endif
174