Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
WindowManager.h
1 /***********************************************************************
2  filename: CEGUIWindowManager.h
3  created: 21/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines the interface for the WindowManager object
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIWindowManager_h_
31 #define _CEGUIWindowManager_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/Singleton.h"
36 #include "CEGUI/Logger.h"
37 #include "CEGUI/IteratorBase.h"
38 #include "CEGUI/EventSet.h"
39 #include <map>
40 #include <vector>
41 
42 #if defined(_MSC_VER)
43 # pragma warning(push)
44 # pragma warning(disable : 4275)
45 # pragma warning(disable : 4251)
46 #endif
47 
48 
49 // Start of CEGUI namespace section
50 namespace CEGUI
51 {
61 class CEGUIEXPORT WindowManager : public Singleton<WindowManager>,
62  public EventSet,
63  public AllocatedObject<WindowManager>
64 {
65 public:
66  /*************************************************************************
67  Public static data
68  *************************************************************************/
70 
71  static const String EventNamespace;
76  static const String EventWindowCreated;
82 
83  static const String GUILayoutSchemaName;
84 
106  typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
107 
108  /*************************************************************************
109  Construction and Destruction
110  *************************************************************************/
119  WindowManager(void);
120 
121 
129  ~WindowManager(void);
130 
131 
132  /*************************************************************************
133  Window Related Methods
134  *************************************************************************/
154  Window* createWindow(const String& type, const String& name = "");
155 
156 
169  void destroyWindow(Window* window);
170 
171 
181  void destroyAllWindows(void);
182 
184  bool isAlive(const Window* window) const;
185 
204  Window* loadLayoutFromContainer(const RawDataContainer& source, PropertyCallback* callback = 0, void* userdata = 0);
205 
230  Window* loadLayoutFromFile(const String& filename, const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
231 
250  Window* loadLayoutFromString(const String& source, PropertyCallback* callback = 0, void* userdata = 0);
251 
260  bool isDeadPoolEmpty(void) const;
261 
273  void cleanDeadPool(void);
274 
288  void writeLayoutToStream(const Window& window, OutStream& out_stream) const;
289 
304  String getLayoutAsString(const Window& window) const;
305 
320  void saveLayoutToFile(const Window& window, const String& filename) const;
321 
330  static const String& getDefaultResourceGroup()
331  { return d_defaultResourceGroup; }
332 
343  static void setDefaultResourceGroup(const String& resourceGroup)
344  { d_defaultResourceGroup = resourceGroup; }
345 
359  void lock();
360 
374  void unlock();
375 
392  bool isLocked() const;
393 
394 private:
395  /*************************************************************************
396  Implementation Methods
397  *************************************************************************/
402  String generateUniqueWindowName();
403 
405  void initialiseRenderEffect(Window* wnd, const String& effect) const;
406 
407  /*************************************************************************
408  Implementation Data
409  *************************************************************************/
410  typedef std::vector<Window*
411  CEGUI_VECTOR_ALLOC(Window*)> WindowVector;
412 
414  WindowVector d_windowRegistry;
415  WindowVector d_deathrow;
416 
417  unsigned long d_uid_counter;
418  static String d_defaultResourceGroup;
419 
420  uint d_lockCount;
421 
422 public:
423  /*************************************************************************
424  Iterator stuff
425  *************************************************************************/
426  typedef ConstVectorIterator<WindowVector> WindowIterator;
427 
432  WindowIterator getIterator(void) const;
433 
444  void DEBUG_dumpWindowNames(String zone) const;
445 };
446 
447 } // End of CEGUI namespace section
448 
449 #if defined(_MSC_VER)
450 # pragma warning(pop)
451 #endif
452 
453 #endif // end of guard _CEGUIWindowManager_h_