Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
WindowFactory.h
1/***********************************************************************
2 created: 21/2/2004
3 author: Paul D Turner
4
5 purpose: Defines abstract base class for WindowFactory objects
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 _CEGUIWindowFactory_h_
30#define _CEGUIWindowFactory_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/String.h"
34#include "CEGUI/Window.h"
35
55#define CEGUI_DECLARE_WINDOW_FACTORY( T )\
56 class T ## Factory : public WindowFactory\
57 {\
58 public:\
59 T ## Factory() : WindowFactory( T::WidgetTypeName ) {}\
60 Window* createWindow(const String& name)\
61 {\
62 return CEGUI_NEW_AO T(d_type, name);\
63 }\
64 void destroyWindow(Window* window)\
65 {\
66 CEGUI_DELETE_AO window;\
67 }\
68 };\
69 T ## Factory& get ## T ## Factory();
70
76#define CEGUI_DEFINE_WINDOW_FACTORY( T )\
77 T ## Factory& get ## T ## Factory()\
78 {\
79 static T ## Factory s_factory;\
80 return s_factory;\
81 }
82
88#define CEGUI_WINDOW_FACTORY( T ) (get ## T ## Factory())
89
90// Start of CEGUI namespace section
91namespace CEGUI
92{
115class CEGUIEXPORT WindowFactory :
116 public AllocatedObject<WindowFactory>
117{
118public:
129 virtual Window* createWindow(const String& name) = 0;
130
141 virtual void destroyWindow(Window* window) = 0;
142
152 const String& getTypeName() const
153 { return d_type; }
154
157 {}
158
159protected:
161 WindowFactory(const String& type) :
162 d_type(type)
163 {}
164
165protected:
168};
169
170} // End of CEGUI namespace section
171
172#endif // end of guard _CEGUIWindowFactory_h_
Definition MemoryAllocatedObject.h:110
String class used within the GUI system.
Definition String.h:64
Abstract class that defines the required interface for all WindowFactory objects.
Definition WindowFactory.h:117
virtual ~WindowFactory()
Destructor.
Definition WindowFactory.h:156
virtual void destroyWindow(Window *window)=0
Destroys the given Window object.
virtual Window * createWindow(const String &name)=0
Create a new Window object of whatever type this WindowFactory produces.
String d_type
String holding the type of object created by this factory.
Definition WindowFactory.h:167
const String & getTypeName() const
Get the string that describes the type of Window object this WindowFactory produces.
Definition WindowFactory.h:152
WindowFactory(const String &type)
Constructor.
Definition WindowFactory.h:161
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