Crazy Eddies GUI System  0.7.0
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 "CEGUIEventSet.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 {
64 public:
65  /*************************************************************************
66  Public static data
67  *************************************************************************/
69 
70  static const String EventNamespace;
72  static const String EventWindowCreated;
75 
97  typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
98 
99  /*************************************************************************
100  Construction and Destruction
101  *************************************************************************/
110  WindowManager(void);
111 
112 
120  ~WindowManager(void);
121 
122 
123  /*************************************************************************
124  Window Related Methods
125  *************************************************************************/
146  Window* createWindow(const String& type, const String& name = "");
147 
148 
161  void destroyWindow(Window* window);
162 
163 
176  void destroyWindow(const String& window);
177 
178 
191  Window* getWindow(const String& name) const;
192 
193 
204  bool isWindowPresent(const String& name) const;
205 
206 
216  void destroyAllWindows(void);
217 
218 
249  Window* loadWindowLayout(const String& filename, const String& name_prefix = "", const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
250 
259  bool isDeadPoolEmpty(void) const;
260 
272  void cleanDeadPool(void);
273 
291  void writeWindowLayoutToStream(const Window& window, OutStream& out_stream, bool writeParent = false) const;
292 
310  void writeWindowLayoutToStream(const String& window, OutStream& out_stream, bool writeParent = false) const;
311 
328  void renameWindow(const String& window, const String& new_name);
329 
343  void renameWindow(Window* window, const String& new_name);
344 
353  static const String& getDefaultResourceGroup()
354  { return d_defaultResourceGroup; }
355 
366  static void setDefaultResourceGroup(const String& resourceGroup)
367  { d_defaultResourceGroup = resourceGroup; }
368 
382  void lock();
383 
397  void unlock();
398 
415  bool isLocked() const;
416 
417 private:
418  /*************************************************************************
419  Implementation Methods
420  *************************************************************************/
425  String generateUniqueWindowName();
426 
427  /*************************************************************************
428  Implementation Constants
429  *************************************************************************/
430  static const char GUILayoutSchemaName[];
431 
432 
433  /*************************************************************************
434  Implementation Data
435  *************************************************************************/
436  typedef std::map<String, Window*, String::FastLessCompare> WindowRegistry;
437  typedef std::vector<Window*> WindowVector;
438 
439  WindowRegistry d_windowRegistry;
440  WindowVector d_deathrow;
441 
442  unsigned long d_uid_counter;
443  static String d_defaultResourceGroup;
444 
445  uint d_lockCount;
446 
447 public:
448  /*************************************************************************
449  Iterator stuff
450  *************************************************************************/
451  typedef ConstBaseIterator<WindowRegistry> WindowIterator;
452 
457  WindowIterator getIterator(void) const;
458 
469  void DEBUG_dumpWindowNames(String zone);
470 };
471 
472 } // End of CEGUI namespace section
473 
474 #if defined(_MSC_VER)
475 # pragma warning(pop)
476 #endif
477 
478 #endif // end of guard _CEGUIWindowManager_h_