Crazy Eddie's GUI System 0.8.7
WindowManager.h
1/***********************************************************************
2 created: 21/2/2004
3 author: Paul D Turner
4
5 purpose: Defines the interface for the WindowManager object
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUIWindowManager_h_
30#define _CEGUIWindowManager_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/String.h"
34#include "CEGUI/Singleton.h"
35#include "CEGUI/Logger.h"
36#include "CEGUI/IteratorBase.h"
37#include "CEGUI/EventSet.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
49namespace CEGUI
50{
60class CEGUIEXPORT WindowManager : public Singleton<WindowManager>,
61 public EventSet,
62 public AllocatedObject<WindowManager>
63{
64public:
65 /*************************************************************************
66 Public static data
67 *************************************************************************/
70 static const String EventNamespace;
81
83
105 typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata);
106
107 /*************************************************************************
108 Construction and Destruction
109 *************************************************************************/
119
120
129
130
131 /*************************************************************************
132 Window Related Methods
133 *************************************************************************/
153 Window* createWindow(const String& type, const String& name = "");
154
155
168 void destroyWindow(Window* window);
169
170
181
183 bool isAlive(const Window* window) const;
184
203 Window* loadLayoutFromContainer(const RawDataContainer& source, PropertyCallback* callback = 0, void* userdata = 0);
204
229 Window* loadLayoutFromFile(const String& filename, const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0);
230
249 Window* loadLayoutFromString(const String& source, PropertyCallback* callback = 0, void* userdata = 0);
250
259 bool isDeadPoolEmpty(void) const;
260
272 void cleanDeadPool(void);
273
287 void writeLayoutToStream(const Window& window, OutStream& out_stream) const;
288
303 String getLayoutAsString(const Window& window) const;
304
319 void saveLayoutToFile(const Window& window, const String& filename) const;
320
330 { return d_defaultResourceGroup; }
331
342 static void setDefaultResourceGroup(const String& resourceGroup)
343 { d_defaultResourceGroup = resourceGroup; }
344
358 void lock();
359
373 void unlock();
374
391 bool isLocked() const;
392
393private:
394 /*************************************************************************
395 Implementation Methods
396 *************************************************************************/
401 String generateUniqueWindowName();
402
404 void initialiseRenderEffect(Window* wnd, const String& effect) const;
405
406 /*************************************************************************
407 Implementation Data
408 *************************************************************************/
409 typedef std::vector<Window*
410 CEGUI_VECTOR_ALLOC(Window*)> WindowVector;
411
413 WindowVector d_windowRegistry;
414 WindowVector d_deathrow;
415
416 unsigned long d_uid_counter;
417 static String d_defaultResourceGroup;
419 uint d_lockCount;
420
421public:
422 /*************************************************************************
423 Iterator stuff
424 *************************************************************************/
426
432
443 void DEBUG_dumpWindowNames(String zone) const;
444};
445
446} // End of CEGUI namespace section
447
448#if defined(_MSC_VER)
449# pragma warning(pop)
450#endif
451
452#endif // end of guard _CEGUIWindowManager_h_
Definition: MemoryAllocatedObject.h:110
iterator for vectors
Definition: IteratorBase.h:288
Interface providing event signaling and handling.
Definition: EventSet.h:167
Class used as the databuffer for loading files throughout the library.
Definition: DataContainer.h:44
Definition: Singleton.h:56
String class used within the GUI system.
Definition: String.h:64
The WindowManager class describes an object that manages creation and lifetime of Window objects.
Definition: WindowManager.h:63
void cleanDeadPool(void)
Permanently destroys any windows placed in the dead pool.
void writeLayoutToStream(const Window &window, OutStream &out_stream) const
Writes a full XML window layout, starting at the given Window to the given OutStream.
Window * loadLayoutFromContainer(const RawDataContainer &source, PropertyCallback *callback=0, void *userdata=0)
Creates a set of windows (a GUI layout) from the information in the specified XML.
void destroyAllWindows(void)
Destroys all Window objects within the system.
WindowIterator getIterator(void) const
Return a WindowManager::WindowIterator object to iterate over the currently defined Windows.
Window * createWindow(const String &type, const String &name="")
Window * loadLayoutFromFile(const String &filename, const String &resourceGroup="", PropertyCallback *callback=0, void *userdata=0)
~WindowManager(void)
Destructor for WindowManager objects.
static const String GUILayoutSchemaName
Filename of the XML schema used for validating GUILayout files.
Definition: WindowManager.h:82
bool PropertyCallback(Window *window, String &propname, String &propvalue, void *userdata)
Function type that is used as a callback when loading layouts from XML; the function is called for ea...
Definition: WindowManager.h:105
static const String EventNamespace
Namespace for global events.
Definition: WindowManager.h:70
void DEBUG_dumpWindowNames(String zone) const
Outputs the names of ALL existing windows to log (DEBUG function).
void unlock()
Put WindowManager into the unlocked state.
static const String EventWindowDestroyed
Definition: WindowManager.h:80
void lock()
Put WindowManager into the locked state.
static const String GeneratedWindowNameBase
Definition: WindowManager.h:68
bool isDeadPoolEmpty(void) const
Return whether the window dead pool is empty.
WindowManager(void)
Constructs a new WindowManager object.
static const String & getDefaultResourceGroup()
Returns the default resource group currently set for layouts.
Definition: WindowManager.h:329
void destroyWindow(Window *window)
Destroy the specified Window object.
static const String EventWindowCreated
Definition: WindowManager.h:75
bool isAlive(const Window *window) const
return whether Window is alive.
Window * loadLayoutFromString(const String &source, PropertyCallback *callback=0, void *userdata=0)
Creates a set of windows (a GUI layout) from the information in the specified XML.
String getLayoutAsString(const Window &window) const
Writes a full XML window layout, starting at the given Window and returns the result as string.
void saveLayoutToFile(const Window &window, const String &filename) const
Save a full XML window layout, starting at the given Window, to a file with the given file name.
bool isLocked() const
Returns whether WindowManager is currently in the locked state.
static void setDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading layouts.
Definition: WindowManager.h:342
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
std::ostream OutStream
Output stream class.
Definition: Base.h:185