Crazy Eddie's GUI System  0.8.7
WindowManager.h
1 /***********************************************************************
2  created: 21/2/2004
3  author: Paul D Turner
4 
5  purpose: Defines the interface for the WindowManager object
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIWindowManager_h_
30 #define _CEGUIWindowManager_h_
31 
32 #include "CEGUI/Base.h"
33 #include "CEGUI/String.h"
34 #include "CEGUI/Singleton.h"
35 #include "CEGUI/Logger.h"
36 #include "CEGUI/IteratorBase.h"
37 #include "CEGUI/EventSet.h"
38 #include <map>
39 #include <vector>
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4275)
44 # pragma warning(disable : 4251)
45 #endif
46 
47 
48 // Start of CEGUI namespace section
49 namespace CEGUI
50 {
60 class CEGUIEXPORT WindowManager : public Singleton<WindowManager>,
61  public EventSet,
62  public AllocatedObject<WindowManager>
63 {
64 public:
65  /*************************************************************************
66  Public static data
67  *************************************************************************/
69  static const String EventNamespace;
75  static const String EventWindowCreated;
81 
82  static const String GUILayoutSchemaName;
83 
105  typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
106 
107  /*************************************************************************
108  Construction and Destruction
109  *************************************************************************/
118  WindowManager(void);
119 
120 
128  ~WindowManager(void);
129 
130 
131  /*************************************************************************
132  Window Related Methods
133  *************************************************************************/
153  Window* createWindow(const String& type, const String& name = "");
154 
155 
168  void destroyWindow(Window* window);
169 
170 
180  void destroyAllWindows(void);
181 
183  bool isAlive(const Window* window) const;
184 
203  Window* loadLayoutFromContainer(const RawDataContainer& source, PropertyCallback* callback = 0, void* userdata = 0);
204 
229  Window* loadLayoutFromFile(const String& filename, const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
230 
249  Window* loadLayoutFromString(const String& source, PropertyCallback* callback = 0, void* userdata = 0);
250 
259  bool isDeadPoolEmpty(void) const;
260 
272  void cleanDeadPool(void);
273 
287  void writeLayoutToStream(const Window& window, OutStream& out_stream) const;
288 
303  String getLayoutAsString(const Window& window) const;
304 
319  void saveLayoutToFile(const Window& window, const String& filename) const;
320 
330  { return d_defaultResourceGroup; }
331 
342  static void setDefaultResourceGroup(const String& resourceGroup)
343  { d_defaultResourceGroup = resourceGroup; }
344 
358  void lock();
359 
373  void unlock();
374 
391  bool isLocked() const;
392 
393 private:
394  /*************************************************************************
395  Implementation Methods
396  *************************************************************************/
401  String generateUniqueWindowName();
402 
404  void initialiseRenderEffect(Window* wnd, const String& effect) const;
405 
406  /*************************************************************************
407  Implementation Data
408  *************************************************************************/
409  typedef std::vector<Window*
410  CEGUI_VECTOR_ALLOC(Window*)> WindowVector;
411 
413  WindowVector d_windowRegistry;
414  WindowVector d_deathrow;
415 
416  unsigned long d_uid_counter;
417  static String d_defaultResourceGroup;
418  uint d_lockCount;
420 
421 public:
422  /*************************************************************************
423  Iterator stuff
424  *************************************************************************/
425  typedef ConstVectorIterator<WindowVector> WindowIterator;
426 
431  WindowIterator getIterator(void) const;
432 
443  void DEBUG_dumpWindowNames(String zone) const;
444 };
445 
446 } // End of CEGUI namespace section
447 
448 #if defined(_MSC_VER)
449 # pragma warning(pop)
450 #endif
451 
452 #endif // end of guard _CEGUIWindowManager_h_
Definition: MemoryAllocatedObject.h:109
static void setDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading layouts.
Definition: WindowManager.h:342
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
static const String EventWindowCreated
Definition: WindowManager.h:75
std::ostream OutStream
Output stream class.
Definition: Base.h:185
static const String EventWindowDestroyed
Definition: WindowManager.h:80
iterator for vectors
Definition: IteratorBase.h:287
The WindowManager class describes an object that manages creation and lifetime of Window objects...
Definition: WindowManager.h:60
static const String GeneratedWindowNameBase
Definition: WindowManager.h:68
Definition: Singleton.h:55
Class used as the databuffer for loading files throughout the library.
Definition: DataContainer.h:42
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Interface providing event signaling and handling.
Definition: EventSet.h:166
bool PropertyCallback(Window *window, String &propname, String &propvalue, void *userdata)
Function type that is used as a callback when loading layouts from XML; the function is called for ea...
Definition: WindowManager.h:105
static const String & getDefaultResourceGroup()
Returns the default resource group currently set for layouts.
Definition: WindowManager.h:329
String class used within the GUI system.
Definition: String.h:62
static const String GUILayoutSchemaName
Filename of the XML schema used for validating GUILayout files.
Definition: WindowManager.h:82