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   /// Populate a vector with all monitors and their extents in window space.
 95   virtual void getMonitorRegions(Vector<RectI> &regions) = 0;
 96
 97   /// Create a new window, appropriate for the specified device and mode.
 98   ///
 99   /// @return Pointer to the new window.
100   virtual PlatformWindow *createWindow(GFXDevice *device, const GFXVideoMode &mode) = 0;
101
102   /// Populate a list with references to all the windows created from this manager.
103   virtual void getWindows(VectorPtr<PlatformWindow*> &windows) = 0;
104
105   /// Get the window that currently has the input focus or NULL.
106   virtual PlatformWindow* getFocusedWindow() = 0;
107
108   /// Get a window from a device ID.
109   ///
110   /// @return The window associated with the specified ID, or NULL if no
111   ///         match was found.
112   virtual PlatformWindow *getWindowById(WindowId id)=0;
113
114   /// Get the first window in the window list
115   ///
116   /// @return The first window in the list, or NULL if no windows found
117   virtual PlatformWindow *getFirstWindow()=0;
118
119
120   /// Set the parent window
121   ///
122   /// This can be used to render in a child window.
123   virtual void setParentWindow(void* newParent) = 0;
124
125   /// Get the parent window
126   virtual void* getParentWindow() = 0;
127
128
129   /// This method cues the appearance of that window ("lowering the curtain").
130   virtual void lowerCurtain()=0;
131
132   /// @see lowerCurtain
133   ///
134   /// This method removes the curtain window.
135   virtual void raiseCurtain()=0;
136
137   /// This method indicates to created windows to show as normal.
138   virtual void setDisplayWindow(bool set){}
139
140private:
141   /// Process command line arguments from StandardMainLoop. This is done to
142   /// allow web plugin functionality, where we are passed platform-specific
143   /// information allowing us to set ourselves up in the web browser,
144   /// to occur in a platform-neutral way.
145   virtual void _processCmdLineArgs(const S32 argc, const char **argv)=0;
146};
147
148/// Global function to allocate a new platform window manager.
149///
150/// This returns an instance of the appropriate window manager for the current OS.
151///
152/// Depending on situation (for instance, if we are a web plugin) we may
153/// need to get the window manager from somewhere else.
154PlatformWindowManager *CreatePlatformWindowManager();
155
156#endif
157