Crazy Eddies GUI System  0.6.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 <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  *************************************************************************/
136  Window* createWindow(const String& type, const String& name = "", const String& prefix = "");
137 
138 
151  void destroyWindow(Window* window);
152 
153 
166  void destroyWindow(const String& window);
167 
168 
181  Window* getWindow(const String& name) const;
182 
183 
194  bool isWindowPresent(const String& name) const;
195 
196 
206  void destroyAllWindows(void);
207 
208 
239  Window* loadWindowLayout(const String& filename, const String& name_prefix = "", const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
240 
241  Window* loadWindowLayout(const String& filename, bool generateRandomPrefix);
242 
251  bool isDeadPoolEmpty(void) const;
252 
264  void cleanDeadPool(void);
265 
283  void writeWindowLayoutToStream(const Window& window, OutStream& out_stream, bool writeParent = false) const;
284 
302  void writeWindowLayoutToStream(const String& window, OutStream& out_stream, bool writeParent = false) const;
303 
320  void renameWindow(const String& window, const String& new_name);
321 
335  void renameWindow(Window* window, const String& new_name);
336 
345  static const String& getDefaultResourceGroup()
346  { return d_defaultResourceGroup; }
347 
358  static void setDefaultResourceGroup(const String& resourceGroup)
359  { d_defaultResourceGroup = resourceGroup; }
360 
361 private:
362  /*************************************************************************
363  Implementation Methods
364  *************************************************************************/
369  String generateUniqueWindowName();
370 
371  String generateUniqueWindowPrefix();
372 
373  /*************************************************************************
374  Implementation Constants
375  *************************************************************************/
376  static const char GUILayoutSchemaName[];
377 
378 
379  /*************************************************************************
380  Implementation Data
381  *************************************************************************/
382  typedef std::map<String, Window*, String::FastLessCompare> WindowRegistry;
383  typedef std::vector<Window*> WindowVector;
384 
385  WindowRegistry d_windowRegistry;
386  WindowVector d_deathrow;
387 
388  unsigned long d_uid_counter;
389  static String d_defaultResourceGroup;
390 
391 public:
392  /*************************************************************************
393  Iterator stuff
394  *************************************************************************/
395  typedef ConstBaseIterator<WindowRegistry> WindowIterator;
396 
401  WindowIterator getIterator(void) const;
402 
413  void DEBUG_dumpWindowNames(String zone);
414 };
415 
416 } // End of CEGUI namespace section
417 
418 #if defined(_MSC_VER)
419 # pragma warning(pop)
420 #endif
421 
422 #endif // end of guard _CEGUIWindowManager_h_