Crazy Eddies GUI System  0.7.7
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;
75  static const String EventWindowCreated;
81 
103  typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
104 
105  /*************************************************************************
106  Construction and Destruction
107  *************************************************************************/
116  WindowManager(void);
117 
118 
126  ~WindowManager(void);
127 
128 
129  /*************************************************************************
130  Window Related Methods
131  *************************************************************************/
152  Window* createWindow(const String& type, const String& name = "");
153 
154 
167  void destroyWindow(Window* window);
168 
169 
182  void destroyWindow(const String& window);
183 
184 
197  Window* getWindow(const String& name) const;
198 
199 
210  bool isWindowPresent(const String& name) const;
211 
212 
222  void destroyAllWindows(void);
223 
224 
255  Window* loadWindowLayout(const String& filename, const String& name_prefix = "", const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
256 
265  bool isDeadPoolEmpty(void) const;
266 
278  void cleanDeadPool(void);
279 
297  void writeWindowLayoutToStream(const Window& window, OutStream& out_stream, bool writeParent = false) const;
298 
316  void writeWindowLayoutToStream(const String& window, OutStream& out_stream, bool writeParent = false) const;
317 
337  void saveWindowLayout(const String& window, const String& filename, const bool writeParent = false) const;
338 
357  void saveWindowLayout(const Window& window, const String& filename, const bool writeParent = false) const;
358 
375  void renameWindow(const String& window, const String& new_name);
376 
390  void renameWindow(Window* window, const String& new_name);
391 
400  static const String& getDefaultResourceGroup()
401  { return d_defaultResourceGroup; }
402 
413  static void setDefaultResourceGroup(const String& resourceGroup)
414  { d_defaultResourceGroup = resourceGroup; }
415 
429  void lock();
430 
444  void unlock();
445 
462  bool isLocked() const;
463 
464 private:
465  /*************************************************************************
466  Implementation Methods
467  *************************************************************************/
472  String generateUniqueWindowName();
473 
475  void initialiseRenderEffect(Window* wnd, const String& effect) const;
476 
477  /*************************************************************************
478  Implementation Constants
479  *************************************************************************/
480  static const char GUILayoutSchemaName[];
481 
482 
483  /*************************************************************************
484  Implementation Data
485  *************************************************************************/
486  typedef std::map<String, Window*, String::FastLessCompare> WindowRegistry;
487  typedef std::vector<Window*> WindowVector;
488 
489  WindowRegistry d_windowRegistry;
490  WindowVector d_deathrow;
491 
492  unsigned long d_uid_counter;
493  static String d_defaultResourceGroup;
494 
495  uint d_lockCount;
496 
497 public:
498  /*************************************************************************
499  Iterator stuff
500  *************************************************************************/
501  typedef ConstBaseIterator<WindowRegistry> WindowIterator;
502 
507  WindowIterator getIterator(void) const;
508 
519  void DEBUG_dumpWindowNames(String zone);
520 };
521 
522 } // End of CEGUI namespace section
523 
524 #if defined(_MSC_VER)
525 # pragma warning(pop)
526 #endif
527 
528 #endif // end of guard _CEGUIWindowManager_h_