Crazy Eddies GUI System  0.6.2
CEGUIWindowManager.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 "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUISingleton.h"
36 #include "CEGUILogger.h"
37 #include "CEGUIIteratorBase.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 {
62 public:
63  /*************************************************************************
64  Public static data
65  *************************************************************************/
67 
89  typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
90 
91  /*************************************************************************
92  Construction and Destruction
93  *************************************************************************/
102  WindowManager(void);
103 
104 
112  ~WindowManager(void);
113 
114 
115  /*************************************************************************
116  Window Related Methods
117  *************************************************************************/
138  Window* createWindow(const String& type, const String& name = "", const String& prefix = "");
139 
140 
153  void destroyWindow(Window* window);
154 
155 
168  void destroyWindow(const String& window);
169 
170 
183  Window* getWindow(const String& name) const;
184 
185 
196  bool isWindowPresent(const String& name) const;
197 
198 
208  void destroyAllWindows(void);
209 
210 
256  Window* loadWindowLayout(const String& filename, const String& name_prefix = "", const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
257 
258  Window* loadWindowLayout(const String& filename, bool generateRandomPrefix);
259 
268  bool isDeadPoolEmpty(void) const;
269 
281  void cleanDeadPool(void);
282 
300  void writeWindowLayoutToStream(const Window& window, OutStream& out_stream, bool writeParent = false) const;
301 
319  void writeWindowLayoutToStream(const String& window, OutStream& out_stream, bool writeParent = false) const;
320 
337  void renameWindow(const String& window, const String& new_name);
338 
352  void renameWindow(Window* window, const String& new_name);
353 
362  static const String& getDefaultResourceGroup()
363  { return d_defaultResourceGroup; }
364 
375  static void setDefaultResourceGroup(const String& resourceGroup)
376  { d_defaultResourceGroup = resourceGroup; }
377 
391  void lock();
392 
406  void unlock();
407 
424  bool isLocked() const;
425 
426 private:
427  /*************************************************************************
428  Implementation Methods
429  *************************************************************************/
434  String generateUniqueWindowName();
435 
436  String generateUniqueWindowPrefix();
437 
438  /*************************************************************************
439  Implementation Constants
440  *************************************************************************/
441  static const char GUILayoutSchemaName[];
442 
443 
444  /*************************************************************************
445  Implementation Data
446  *************************************************************************/
447  typedef std::map<String, Window*, String::FastLessCompare> WindowRegistry;
448  typedef std::vector<Window*> WindowVector;
449 
450  WindowRegistry d_windowRegistry;
451  WindowVector d_deathrow;
452 
453  unsigned long d_uid_counter;
454  static String d_defaultResourceGroup;
455 
456  uint d_lockCount;
457 
458 public:
459  /*************************************************************************
460  Iterator stuff
461  *************************************************************************/
463 
468  WindowIterator getIterator(void) const;
469 
480  void DEBUG_dumpWindowNames(String zone);
481 };
482 
483 } // End of CEGUI namespace section
484 
485 #if defined(_MSC_VER)
486 # pragma warning(pop)
487 #endif
488 
489 #endif // end of guard _CEGUIWindowManager_h_