]> git.saurik.com Git - wxWidgets.git/blob - include/wx/rtti.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / include / wx / rtti.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/rtti.h
3 // Purpose: old RTTI macros (use XTI when possible instead)
4 // Author: Julian Smart
5 // Modified by: Ron Lee
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) 1997 Julian Smart
9 // (c) 2001 Ron Lee <ron@debian.org>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_RTTIH__
14 #define _WX_RTTIH__
15
16 #if !wxUSE_EXTENDED_RTTI // XTI system is meant to replace these macros
17
18 // ----------------------------------------------------------------------------
19 // headers
20 // ----------------------------------------------------------------------------
21
22 #include "wx/memory.h"
23
24 // ----------------------------------------------------------------------------
25 // forward declarations
26 // ----------------------------------------------------------------------------
27
28 class WXDLLIMPEXP_FWD_BASE wxObject;
29 class WXDLLIMPEXP_FWD_BASE wxString;
30 class WXDLLIMPEXP_FWD_BASE wxClassInfo;
31 class WXDLLIMPEXP_FWD_BASE wxHashTable;
32 class WXDLLIMPEXP_FWD_BASE wxObject;
33 class WXDLLIMPEXP_FWD_BASE wxPluginLibrary;
34 class WXDLLIMPEXP_FWD_BASE wxHashTable_Node;
35
36 // ----------------------------------------------------------------------------
37 // wxClassInfo
38 // ----------------------------------------------------------------------------
39
40 typedef wxObject *(*wxObjectConstructorFn)(void);
41
42 class WXDLLIMPEXP_BASE wxClassInfo
43 {
44 friend class WXDLLIMPEXP_FWD_BASE wxObject;
45 friend WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
46 public:
47 wxClassInfo( const wxChar *className,
48 const wxClassInfo *baseInfo1,
49 const wxClassInfo *baseInfo2,
50 int size,
51 wxObjectConstructorFn ctor )
52 : m_className(className)
53 , m_objectSize(size)
54 , m_objectConstructor(ctor)
55 , m_baseInfo1(baseInfo1)
56 , m_baseInfo2(baseInfo2)
57 , m_next(sm_first)
58 {
59 sm_first = this;
60 Register();
61 }
62
63 ~wxClassInfo();
64
65 wxObject *CreateObject() const
66 { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
67 bool IsDynamic() const { return (NULL != m_objectConstructor); }
68
69 const wxChar *GetClassName() const { return m_className; }
70 const wxChar *GetBaseClassName1() const
71 { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; }
72 const wxChar *GetBaseClassName2() const
73 { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; }
74 const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; }
75 const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; }
76 int GetSize() const { return m_objectSize; }
77
78 wxObjectConstructorFn GetConstructor() const
79 { return m_objectConstructor; }
80 static const wxClassInfo *GetFirst() { return sm_first; }
81 const wxClassInfo *GetNext() const { return m_next; }
82 static wxClassInfo *FindClass(const wxString& className);
83
84 // Climb upwards through inheritance hierarchy.
85 // Dual inheritance is catered for.
86
87 bool IsKindOf(const wxClassInfo *info) const
88 {
89 return info != 0 &&
90 ( info == this ||
91 ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
92 ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
93 }
94
95 wxDECLARE_CLASS_INFO_ITERATORS();
96
97 private:
98 const wxChar *m_className;
99 int m_objectSize;
100 wxObjectConstructorFn m_objectConstructor;
101
102 // Pointers to base wxClassInfos
103
104 const wxClassInfo *m_baseInfo1;
105 const wxClassInfo *m_baseInfo2;
106
107 // class info object live in a linked list:
108 // pointers to its head and the next element in it
109
110 static wxClassInfo *sm_first;
111 wxClassInfo *m_next;
112
113 static wxHashTable *sm_classTable;
114
115 protected:
116 // registers the class
117 void Register();
118 void Unregister();
119
120 wxDECLARE_NO_COPY_CLASS(wxClassInfo);
121 };
122
123 WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
124
125 // ----------------------------------------------------------------------------
126 // Dynamic class macros
127 // ----------------------------------------------------------------------------
128
129 #define wxDECLARE_ABSTRACT_CLASS(name) \
130 public: \
131 static wxClassInfo ms_classInfo; \
132 virtual wxClassInfo *GetClassInfo() const
133
134 #define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
135 wxDECLARE_NO_ASSIGN_CLASS(name); \
136 wxDECLARE_DYNAMIC_CLASS(name)
137
138 #define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \
139 wxDECLARE_NO_COPY_CLASS(name); \
140 wxDECLARE_DYNAMIC_CLASS(name)
141
142 #define wxDECLARE_DYNAMIC_CLASS(name) \
143 wxDECLARE_ABSTRACT_CLASS(name); \
144 static wxObject* wxCreateObject()
145
146 #define wxDECLARE_CLASS(name) \
147 wxDECLARE_ABSTRACT_CLASS(name)
148
149
150 // common part of the macros below
151 #define wxIMPLEMENT_CLASS_COMMON(name, basename, baseclsinfo2, func) \
152 wxClassInfo name::ms_classInfo(wxT(#name), \
153 &basename::ms_classInfo, \
154 baseclsinfo2, \
155 (int) sizeof(name), \
156 func); \
157 \
158 wxClassInfo *name::GetClassInfo() const \
159 { return &name::ms_classInfo; }
160
161 #define wxIMPLEMENT_CLASS_COMMON1(name, basename, func) \
162 wxIMPLEMENT_CLASS_COMMON(name, basename, NULL, func)
163
164 #define wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, func) \
165 wxIMPLEMENT_CLASS_COMMON(name, basename1, &basename2::ms_classInfo, func)
166
167 // -----------------------------------
168 // for concrete classes
169 // -----------------------------------
170
171 // Single inheritance with one base class
172 #define wxIMPLEMENT_DYNAMIC_CLASS(name, basename) \
173 wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject) \
174 wxObject* name::wxCreateObject() \
175 { return new name; }
176
177 // Multiple inheritance with two base classes
178 #define wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
179 wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, \
180 name::wxCreateObject) \
181 wxObject* name::wxCreateObject() \
182 { return new name; }
183
184 // -----------------------------------
185 // for abstract classes
186 // -----------------------------------
187
188 // Single inheritance with one base class
189 #define wxIMPLEMENT_ABSTRACT_CLASS(name, basename) \
190 wxIMPLEMENT_CLASS_COMMON1(name, basename, NULL)
191
192 // Multiple inheritance with two base classes
193 #define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
194 wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, NULL)
195
196 // -----------------------------------
197 // XTI-compatible macros
198 // -----------------------------------
199
200 #include "wx/flags.h"
201
202 // these macros only do something when wxUSE_EXTENDED_RTTI=1
203 // (and in that case they are defined by xti.h); however to avoid
204 // to be forced to wrap these macros (in user's source files) with
205 //
206 // #if wxUSE_EXTENDED_RTTI
207 // ...
208 // #endif
209 //
210 // blocks, we define them here as empty.
211
212 #define wxEMPTY_PARAMETER_VALUE /**/
213
214 #define wxBEGIN_ENUM( e ) wxEMPTY_PARAMETER_VALUE
215 #define wxENUM_MEMBER( v ) wxEMPTY_PARAMETER_VALUE
216 #define wxEND_ENUM( e ) wxEMPTY_PARAMETER_VALUE
217
218 #define wxIMPLEMENT_SET_STREAMING(SetName,e) wxEMPTY_PARAMETER_VALUE
219
220 #define wxBEGIN_FLAGS( e ) wxEMPTY_PARAMETER_VALUE
221 #define wxFLAGS_MEMBER( v ) wxEMPTY_PARAMETER_VALUE
222 #define wxEND_FLAGS( e ) wxEMPTY_PARAMETER_VALUE
223
224 #define wxCOLLECTION_TYPE_INFO( element, collection ) wxEMPTY_PARAMETER_VALUE
225
226 #define wxHANDLER(name,eventClassType) wxEMPTY_PARAMETER_VALUE
227 #define wxBEGIN_HANDLERS_TABLE(theClass) wxEMPTY_PARAMETER_VALUE
228 #define wxEND_HANDLERS_TABLE() wxEMPTY_PARAMETER_VALUE
229
230 #define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \
231 wxIMPLEMENT_DYNAMIC_CLASS( name, basename )
232 #define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback ) \
233 wxIMPLEMENT_DYNAMIC_CLASS( name, basename )
234
235 #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \
236 wxIMPLEMENT_DYNAMIC_CLASS( name, basename)
237
238 #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \
239 unit, toString, \
240 fromString ) wxEMPTY_PARAMETER_VALUE
241 #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) wxEMPTY_PARAMETER_VALUE
242 #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) wxEMPTY_PARAMETER_VALUE
243
244 #define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2 )
245
246 #define wxCONSTRUCTOR_0(klass) \
247 wxEMPTY_PARAMETER_VALUE
248 #define wxCONSTRUCTOR_DUMMY(klass) \
249 wxEMPTY_PARAMETER_VALUE
250 #define wxDIRECT_CONSTRUCTOR_0(klass) \
251 wxEMPTY_PARAMETER_VALUE
252 #define wxCONSTRUCTOR_1(klass,t0,v0) \
253 wxEMPTY_PARAMETER_VALUE
254 #define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \
255 wxEMPTY_PARAMETER_VALUE
256 #define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \
257 wxEMPTY_PARAMETER_VALUE
258 #define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
259 wxEMPTY_PARAMETER_VALUE
260 #define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
261 wxEMPTY_PARAMETER_VALUE
262 #define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
263 wxEMPTY_PARAMETER_VALUE
264 #define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
265 wxEMPTY_PARAMETER_VALUE
266 #define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
267 wxEMPTY_PARAMETER_VALUE
268 #define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
269 wxEMPTY_PARAMETER_VALUE
270 #define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
271 wxEMPTY_PARAMETER_VALUE
272 #define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
273 wxEMPTY_PARAMETER_VALUE
274 #define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
275 wxEMPTY_PARAMETER_VALUE
276 #define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
277 wxEMPTY_PARAMETER_VALUE
278 #define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
279 wxEMPTY_PARAMETER_VALUE
280 #define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
281 wxEMPTY_PARAMETER_VALUE
282 #define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
283 wxEMPTY_PARAMETER_VALUE
284
285 #define wxSETTER( property, Klass, valueType, setterMethod ) wxEMPTY_PARAMETER_VALUE
286 #define wxGETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE
287 #define wxADDER( property, Klass, valueType, addermethod ) wxEMPTY_PARAMETER_VALUE
288 #define wxCOLLECTION_GETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE
289
290 #define wxBEGIN_PROPERTIES_TABLE(theClass) wxEMPTY_PARAMETER_VALUE
291 #define wxEND_PROPERTIES_TABLE() wxEMPTY_PARAMETER_VALUE
292 #define wxHIDE_PROPERTY( pname ) wxEMPTY_PARAMETER_VALUE
293
294 #define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \
295 wxEMPTY_PARAMETER_VALUE
296
297 #define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \
298 pflags, help, group) wxEMPTY_PARAMETER_VALUE
299
300 #define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \
301 wxGETTER( pname, class_t, type, getter ) wxEMPTY_PARAMETER_VALUE
302
303 #define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \
304 pflags, help, group) wxEMPTY_PARAMETER_VALUE
305
306 #define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \
307 flags, help, group ) wxEMPTY_PARAMETER_VALUE
308
309 #define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \
310 flags, help, group) wxEMPTY_PARAMETER_VALUE
311 #define wxEVENT_PROPERTY( name, eventType, eventClass ) wxEMPTY_PARAMETER_VALUE
312
313 #define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) wxEMPTY_PARAMETER_VALUE
314
315 #define wxIMPLEMENT_PROPERTY(name, type) wxEMPTY_PARAMETER_VALUE
316
317 #define wxEMPTY_HANDLERS_TABLE(name) wxEMPTY_PARAMETER_VALUE
318
319 #endif // !wxUSE_EXTENDED_RTTI
320 #endif // _WX_RTTIH__