Crazy Eddies GUI System
0.7.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
cegui
include
CEGUIWidgetModule.h
1
/***********************************************************************
2
filename: CEGUIWidgetModule.h
3
created: Sun Sep 25 2005
4
author: Paul D Turner <paul@cegui.org.uk>
5
*************************************************************************/
6
/***************************************************************************
7
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8
*
9
* Permission is hereby granted, free of charge, to any person obtaining
10
* a copy of this software and associated documentation files (the
11
* "Software"), to deal in the Software without restriction, including
12
* without limitation the rights to use, copy, modify, merge, publish,
13
* distribute, sublicense, and/or sell copies of the Software, and to
14
* permit persons to whom the Software is furnished to do so, subject to
15
* the following conditions:
16
*
17
* The above copyright notice and this permission notice shall be
18
* included in all copies or substantial portions of the Software.
19
*
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
* OTHER DEALINGS IN THE SOFTWARE.
27
***************************************************************************/
28
#ifndef _CEGUIWidgetModule_h_
29
#define _CEGUIWidgetModule_h_
30
31
#include "CEGUIExceptions.h"
32
#include "CEGUIWindowFactoryManager.h"
33
34
#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
35
# ifdef CEGUIWIDGETMODULE_EXPORTS
36
# define CEGUIWIDGETMODULE_API __declspec(dllexport)
37
# else
38
# define CEGUIWIDGETMODULE_API __declspec(dllimport)
39
# endif
40
#else
41
# define CEGUIWIDGETMODULE_API
42
#endif
43
44
#define CEGUI_DECLARE_WIDGET_MODULE( moduleName )\
45
\
46
class CEGUI::WindowFactory;\
47
\
48
extern "C" CEGUIWIDGETMODULE_API void registerFactory(const CEGUI::String& type_name);\
49
extern "C" CEGUIWIDGETMODULE_API CEGUI::uint registerAllFactories(void);\
50
void doSafeFactoryRegistration(CEGUI::WindowFactory* factory);
51
52
53
#define CEGUI_DEFINE_FACTORY( className )\
54
namespace CEGUI {\
55
class className ## Factory : public WindowFactory\
56
{\
57
public:\
58
className ## Factory(void) : WindowFactory(className::WidgetTypeName) { }\
59
Window* createWindow(const String& name)\
60
{ return new className(d_type, name); }\
61
void destroyWindow(Window* window)\
62
{ delete window; }\
63
};\
64
}\
65
static CEGUI::className ## Factory s_ ## className ## Factory;
66
67
#define CEGUI_START_FACTORY_MAP( module )\
68
struct module ## MapEntry\
69
{\
70
const CEGUI::utf8* d_name;\
71
CEGUI::WindowFactory* d_factory;\
72
};\
73
\
74
module ## MapEntry module ## FactoriesMap[] =\
75
{\
76
77
#define CEGUI_END_FACTORY_MAP {0,0}};
78
79
#define CEGUI_FACTORY_MAP_ENTRY( class )\
80
{CEGUI::class::WidgetTypeName, &s_ ## class ## Factory},
81
82
#define CEGUI_DEFINE_WIDGET_MODULE( module )\
83
extern "C" void registerFactory(const CEGUI::String& type_name)\
84
{\
85
module ## MapEntry* entry = module ## FactoriesMap;\
86
while (entry->d_name)\
87
{\
88
if (entry->d_name == type_name)\
89
{\
90
doSafeFactoryRegistration(entry->d_factory);\
91
return;\
92
}\
93
++entry;\
94
}\
95
\
96
CEGUI_THROW(CEGUI::UnknownObjectException("::registerFactory - The window factory for type '" + type_name + "' is not known in this module."));\
97
}\
98
\
99
extern "C" CEGUI::uint registerAllFactories(void)\
100
{\
101
CEGUI::uint count = 0;\
102
module ## MapEntry* entry = module ## FactoriesMap;\
103
while (entry->d_name)\
104
{\
105
doSafeFactoryRegistration(entry->d_factory);\
106
++entry;\
107
++count;\
108
}\
109
return count;\
110
}\
111
\
112
void doSafeFactoryRegistration(CEGUI::WindowFactory* factory)\
113
{\
114
assert(factory != 0);\
115
\
116
CEGUI::WindowFactoryManager& wfm = CEGUI::WindowFactoryManager::getSingleton();\
117
if (wfm.isFactoryPresent(factory->getTypeName()))\
118
{\
119
CEGUI::Logger::getSingleton().logEvent(\
120
"Widget factory '" + factory->getTypeName() + "' appears to be already registered, skipping.",\
121
CEGUI::Informative);\
122
}\
123
else\
124
{\
125
wfm.addFactory(factory);\
126
}\
127
}
128
129
#endif // end of guard _CEGUIWidgetModule_h_
Generated by
1.8.3.1