]> git.saurik.com Git - wxWidgets.git/blame - include/wx/object.h
switched to using wxPopupWindow
[wxWidgets.git] / include / wx / object.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
b2edef6f 2// Name: wx/object.h
c801d85f
KB
3// Purpose: wxObject class, plus run-time type information macros
4// Author: Julian Smart
0b9ab0bd 5// Modified by: Ron Lee
c801d85f
KB
6// Created: 01/02/97
7// RCS-ID: $Id$
371a5b4e 8// Copyright: (c) 1997 Julian Smart
0b9ab0bd 9// (c) 2001 Ron Lee <ron@debian.org>
65571936 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
34138703
JS
13#ifndef _WX_OBJECTH__
14#define _WX_OBJECTH__
c801d85f 15
12028905 16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
0d3820b3 17#pragma interface "object.h"
c801d85f
KB
18#endif
19
0b9ab0bd
RL
20// ----------------------------------------------------------------------------
21// headers
22// ----------------------------------------------------------------------------
23
c801d85f 24#include "wx/defs.h"
e55ad60e 25#include "wx/memory.h"
c801d85f 26
bddd7a8d 27class WXDLLIMPEXP_BASE wxObject;
c801d85f 28
4393b50c 29#ifndef wxUSE_EXTENDED_RTTI
6d553b5f 30#define wxUSE_EXTENDED_RTTI 0
a095505c
SC
31#endif
32
6d553b5f 33#if wxUSE_EXTENDED_RTTI
a095505c 34#include "wx/xti.h"
a095505c
SC
35#else
36
0b9ab0bd
RL
37// ----------------------------------------------------------------------------
38// conditional compilation
39// ----------------------------------------------------------------------------
40
b2edef6f
VZ
41// this shouldn't be needed any longer as <wx/msw/private.h> does it but it
42// doesn't hurt neither
c801d85f
KB
43#ifdef GetClassName
44#undef GetClassName
45#endif
3f1af920
JS
46#ifdef GetClassInfo
47#undef GetClassInfo
c801d85f
KB
48#endif
49
bddd7a8d
VZ
50class WXDLLIMPEXP_BASE wxClassInfo;
51class WXDLLIMPEXP_BASE wxHashTable;
52class WXDLLIMPEXP_BASE wxObjectRefData;
c801d85f 53
0b9ab0bd
RL
54// ----------------------------------------------------------------------------
55// wxClassInfo
56// ----------------------------------------------------------------------------
57
58typedef wxObject *(*wxObjectConstructorFn)(void);
c801d85f 59
bddd7a8d 60class WXDLLIMPEXP_BASE wxClassInfo
c801d85f 61{
aac65598 62public:
38befbee 63 wxClassInfo( const wxChar *className,
d1d738f1
VS
64 const wxClassInfo *baseInfo1,
65 const wxClassInfo *baseInfo2,
38befbee
RL
66 int size,
67 wxObjectConstructorFn ctor )
0b9ab0bd 68 : m_className(className)
0b9ab0bd
RL
69 , m_objectSize(size)
70 , m_objectConstructor(ctor)
d1d738f1
VS
71 , m_baseInfo1(baseInfo1)
72 , m_baseInfo2(baseInfo2)
0b9ab0bd 73 , m_next(sm_first)
7e548f6b 74 {
d1d738f1
VS
75 sm_first = this;
76 Register();
77 }
0b9ab0bd 78
aa4b7ef9 79 ~wxClassInfo();
1d2eddff 80
0b9ab0bd
RL
81 wxObject *CreateObject() { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
82
83 const wxChar *GetClassName() const { return m_className; }
469349b5
MB
84 const wxChar *GetBaseClassName1() const
85 { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; }
86 const wxChar *GetBaseClassName2() const
87 { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; }
0b9ab0bd
RL
88 const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; }
89 const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; }
90 int GetSize() const { return m_objectSize; }
91
92 wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
93 static const wxClassInfo *GetFirst() { return sm_first; }
94 const wxClassInfo *GetNext() const { return m_next; }
95 static wxClassInfo *FindClass(const wxChar *className);
807d8487 96
0b9ab0bd
RL
97 // Climb upwards through inheritance hierarchy.
98 // Dual inheritance is catered for.
99
100 bool IsKindOf(const wxClassInfo *info) const
101 {
102 return info != 0 &&
103 ( info == this ||
104 ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
105 ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
106 }
3f4a0c5b 107
45bbbc54 108#if WXWIN_COMPATIBILITY_2_4
d1d738f1 109 // Initializes parent pointers and hash table for fast searching.
45bbbc54 110 wxDEPRECATED( static void InitializeClasses() );
d1d738f1 111 // Cleans up hash table used for fast searching.
45bbbc54 112 wxDEPRECATED( static void CleanUpClasses() );
cafc76a4
VS
113#endif
114 static void CleanUp();
7e548f6b 115
0c32066b 116public:
0b9ab0bd 117 const wxChar *m_className;
0b9ab0bd
RL
118 int m_objectSize;
119 wxObjectConstructorFn m_objectConstructor;
120
121 // Pointers to base wxClassInfos: set in InitializeClasses
122
123 const wxClassInfo *m_baseInfo1;
124 const wxClassInfo *m_baseInfo2;
125
126 // class info object live in a linked list:
127 // pointers to its head and the next element in it
128
129 static wxClassInfo *sm_first;
130 wxClassInfo *m_next;
131
1f428942
VZ
132 // FIXME: this should be private (currently used directly by way too
133 // many clients)
0b9ab0bd 134 static wxHashTable *sm_classTable;
1f428942
VZ
135
136private:
137 // InitializeClasses() helper
138 static wxClassInfo *GetBaseByName(const wxChar *name);
684242c6
GD
139
140 DECLARE_NO_COPY_CLASS(wxClassInfo)
7e548f6b
WS
141
142protected:
d1d738f1
VS
143 // registers the class
144 void Register();
145 void Unregister();
c801d85f
KB
146};
147
bddd7a8d 148WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name);
c801d85f 149
45bbbc54 150#if WXWIN_COMPATIBILITY_2_4
cafc76a4
VS
151inline void wxClassInfo::InitializeClasses() {}
152inline void wxClassInfo::CleanUpClasses() {}
153#endif
154
0b9ab0bd
RL
155// ----------------------------------------------------------------------------
156// Dynamic class macros
157// ----------------------------------------------------------------------------
158
159#define DECLARE_DYNAMIC_CLASS(name) \
160 public: \
c0db9626
VZ
161 static wxClassInfo ms_classInfo; \
162 static wxObject* wxCreateObject(); \
0b9ab0bd 163 virtual wxClassInfo *GetClassInfo() const \
c0db9626 164 { return &name::ms_classInfo; }
c801d85f 165
fc7a2a60 166#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
a6cbc4db 167 DECLARE_NO_ASSIGN_CLASS(name) \
fc7a2a60
VZ
168 DECLARE_DYNAMIC_CLASS(name)
169
170#define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
171 DECLARE_NO_COPY_CLASS(name) \
172 DECLARE_DYNAMIC_CLASS(name)
173
c801d85f
KB
174#define DECLARE_ABSTRACT_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
175#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
176
0b9ab0bd
RL
177// -----------------------------------
178// for concrete classes
179// -----------------------------------
180
181 // Single inheritance with one base class
c801d85f 182
0b9ab0bd 183#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
9a84ce0d 184 wxObject* name::wxCreateObject() \
0b9ab0bd 185 { return new name; } \
c0db9626
VZ
186 wxClassInfo name::ms_classInfo(wxT(#name), \
187 &basename::ms_classInfo, NULL, \
d1d738f1 188 (int) sizeof(name), \
c0db9626 189 (wxObjectConstructorFn) name::wxCreateObject);
c801d85f 190
0b9ab0bd 191 // Multiple inheritance with two base classes
c801d85f 192
0b9ab0bd 193#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
9a84ce0d 194 wxObject* name::wxCreateObject() \
0b9ab0bd 195 { return new name; } \
c0db9626
VZ
196 wxClassInfo name::ms_classInfo(wxT(#name), \
197 &basename1::ms_classInfo, \
198 &basename2::ms_classInfo, \
9a84ce0d 199 (int) sizeof(name), \
c0db9626 200 (wxObjectConstructorFn) name::wxCreateObject);
c801d85f 201
0b9ab0bd
RL
202// -----------------------------------
203// for abstract classes
204// -----------------------------------
c801d85f 205
0b9ab0bd
RL
206 // Single inheritance with one base class
207
208#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
c0db9626
VZ
209 wxClassInfo name::ms_classInfo(wxT(#name), \
210 &basename::ms_classInfo, NULL, \
d1d738f1 211 (int) sizeof(name), (wxObjectConstructorFn) 0);
0b9ab0bd
RL
212
213 // Multiple inheritance with two base classes
214
215#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
c0db9626
VZ
216 wxClassInfo name::ms_classInfo(wxT(#name), \
217 &basename1::ms_classInfo, \
218 &basename2::ms_classInfo, \
d1d738f1 219 (int) sizeof(name), \
0b9ab0bd 220 (wxObjectConstructorFn) 0);
c801d85f
KB
221
222#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
223#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
224
6d553b5f 225#endif // !wxUSE_EXTENDED_RTTI
a095505c
SC
226
227
0b9ab0bd
RL
228// -----------------------------------
229// for pluggable classes
230// -----------------------------------
231
232 // NOTE: this should probably be the very first statement
233 // in the class declaration so wxPluginSentinel is
234 // the first member initialised and the last destroyed.
235
236// _DECLARE_DL_SENTINEL(name) wxPluginSentinel m_pluginsentinel;
237
238#if wxUSE_NESTED_CLASSES
239
60b73526
RL
240#define _DECLARE_DL_SENTINEL(name, exportdecl) \
241class exportdecl name##PluginSentinel { \
242private: \
243 static const wxString sm_className; \
244public: \
245 name##PluginSentinel(); \
2e0b1b11 246 ~name##PluginSentinel(); \
60b73526 247}; \
0b9ab0bd 248name##PluginSentinel m_pluginsentinel;
0b9ab0bd
RL
249
250#define _IMPLEMENT_DL_SENTINEL(name) \
251 const wxString name::name##PluginSentinel::sm_className(#name); \
252 name::name##PluginSentinel::name##PluginSentinel() { \
4f89dbc4 253 wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \
7c1e2b44 254 if( e != 0 ) { e->RefObj(); } \
0b9ab0bd 255 } \
abad5367 256 name::name##PluginSentinel::~name##PluginSentinel() { \
4f89dbc4 257 wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \
7c1e2b44 258 if( e != 0 ) { e->UnrefObj(); } \
0b9ab0bd
RL
259 }
260#else
261
262#define _DECLARE_DL_SENTINEL(name)
263#define _IMPLEMENT_DL_SENTINEL(name)
264
265#endif // wxUSE_NESTED_CLASSES
266
267#define DECLARE_PLUGGABLE_CLASS(name) \
60b73526 268 DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT)
0b9ab0bd 269#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \
60b73526
RL
270 DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT)
271
272#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \
273 DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo)
274#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \
275 DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo)
0b9ab0bd
RL
276
277#define IMPLEMENT_PLUGGABLE_CLASS(name, basename) \
278 IMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
279#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \
280 IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
0b9ab0bd
RL
281#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \
282 IMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
283#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
284 IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
285
60b73526
RL
286#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \
287 IMPLEMENT_PLUGGABLE_CLASS(name, basename)
288#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \
289 IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2)
290#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \
291 IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename)
292#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
293 IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
294
c0db9626 295#define CLASSINFO(name) (&name::ms_classInfo)
c801d85f 296
c0db9626 297#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::ms_classInfo)
3013b6f4 298
b2edef6f 299// Just seems a bit nicer-looking (pretend it's not a macro)
c0db9626 300#define wxIsKindOf(obj, className) obj->IsKindOf(&className::ms_classInfo)
c801d85f 301
b2edef6f 302// to be replaced by dynamic_cast<> in the future
34636400 303#define wxDynamicCast(obj, className) \
5232d996
VZ
304 ((className *) wxCheckDynamicCast( \
305 wx_const_cast(wxObject *, wx_static_cast(const wxObject *, \
306 wx_const_cast(className *, wx_static_cast(const className *, obj)))), \
307 &className::ms_classInfo))
0b9ab0bd 308
b2edef6f
VZ
309// The 'this' pointer is always true, so use this version
310// to cast the this pointer and avoid compiler warnings.
f7637829 311#define wxDynamicCastThis(className) \
c0db9626 312 (IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0)
33ac7e6f 313
f6bcfd97 314#ifdef __WXDEBUG__
e32d4836 315inline void* wxCheckCast(void *ptr)
0b9ab0bd
RL
316{
317 wxASSERT_MSG( ptr, _T("wxStaticCast() used incorrectly") );
e32d4836 318 return ptr;
0b9ab0bd
RL
319}
320#define wxStaticCast(obj, className) \
e32d4836 321 ((className *)wxCheckCast(wxDynamicCast(obj, className)))
f6bcfd97 322
0b9ab0bd
RL
323#else // !__WXDEBUG__
324#define wxStaticCast(obj, className) ((className *)(obj))
f6bcfd97 325
0b9ab0bd 326#endif // __WXDEBUG__
f6bcfd97 327
b2edef6f
VZ
328// ----------------------------------------------------------------------------
329// set up memory debugging macros
330// ----------------------------------------------------------------------------
331
332/*
333 Which new/delete operator variants do we want?
334
335 _WX_WANT_NEW_SIZET_WXCHAR_INT = void *operator new (size_t size, wxChar *fileName = 0, int lineNum = 0)
336 _WX_WANT_DELETE_VOID = void operator delete (void * buf)
337 _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET = void operator delete (void *buf, const char *_fname, size_t _line)
338 _WX_WANT_DELETE_VOID_WXCHAR_INT = void operator delete(void *buf, wxChar*, int)
339 _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT = void *operator new[] (size_t size, wxChar *fileName , int lineNum = 0)
340 _WX_WANT_ARRAY_DELETE_VOID = void operator delete[] (void *buf)
341 _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT = void operator delete[] (void* buf, wxChar*, int )
342*/
343
344#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
345
346// All compilers get this one
347#define _WX_WANT_NEW_SIZET_WXCHAR_INT
348
349// Everyone except Visage gets the next one
350#ifndef __VISAGECPP__
351 #define _WX_WANT_DELETE_VOID
c801d85f 352#endif
b2edef6f
VZ
353
354// Only visage gets this one under the correct circumstances
355#if defined(__VISAGECPP__) && __DEBUG_ALLOC__
356 #define _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET
357#endif
358
359// Only VC++ 6.0 and CodeWarrior compilers get overloaded delete that matches new
684242c6 360#if ( defined(__VISUALC__) && (__VISUALC__ >= 1200) ) || (defined(__MWERKS__) && (__MWERKS__ >= 0x2400))
b2edef6f 361 #define _WX_WANT_DELETE_VOID_WXCHAR_INT
fd85b064 362#endif
c801d85f 363
b2edef6f
VZ
364// Now see who (if anyone) gets the array memory operators
365#if wxUSE_ARRAY_MEMORY_OPERATORS
366
367 // Everyone except Visual C++ (cause problems for VC++ - crashes)
368 #if !defined(__VISUALC__)
369 #define _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT
370 #endif
371
372 // Everyone except Visual C++ (cause problems for VC++ - crashes)
373 #if !defined(__VISUALC__)
374 #define _WX_WANT_ARRAY_DELETE_VOID
375 #endif
376
377 // Only CodeWarrior 6 or higher
378 #if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
379 #define _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT
380 #endif
381
382#endif // wxUSE_ARRAY_MEMORY_OPERATORS
383
384#endif // WXDEBUG && wxUSE_MEMORY_TRACING
385
0b9ab0bd 386// ----------------------------------------------------------------------------
77ffb593 387// wxObject: the root class of wxWidgets object hierarchy
0b9ab0bd
RL
388// ----------------------------------------------------------------------------
389
bddd7a8d 390class WXDLLIMPEXP_BASE wxObject
c801d85f 391{
684242c6 392 DECLARE_ABSTRACT_CLASS(wxObject)
c801d85f 393
a6391d30
GD
394private:
395 void InitFrom(const wxObject& other);
4393b50c 396
0b9ab0bd 397public:
b2edef6f 398 wxObject() { m_refData = NULL; }
0b9ab0bd 399 virtual ~wxObject() { UnRef(); }
4393b50c 400
a6391d30
GD
401 wxObject(const wxObject& other)
402 {
403 InitFrom(other);
404 }
4393b50c 405
a6391d30
GD
406 wxObject& operator=(const wxObject& other)
407 {
408 if ( this != &other )
409 {
410 UnRef();
411 InitFrom(other);
412 }
413 return *this;
414 }
415
0b9ab0bd 416 bool IsKindOf(wxClassInfo *info) const;
c801d85f 417
0b9ab0bd 418
b2edef6f
VZ
419 // Turn on the correct set of new and delete operators
420
421#ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT
cf760e4c 422 void *operator new ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 );
0b9ab0bd 423#endif
27198be4 424
b2edef6f
VZ
425#ifdef _WX_WANT_DELETE_VOID
426 void operator delete ( void * buf );
427#endif
0b9ab0bd 428
b2edef6f
VZ
429#ifdef _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET
430 void operator delete ( void *buf, const char *_fname, size_t _line );
0b9ab0bd 431#endif
76626af2 432
b2edef6f 433#ifdef _WX_WANT_DELETE_VOID_WXCHAR_INT
cf760e4c 434 void operator delete ( void *buf, const wxChar*, int );
b2edef6f 435#endif
8cfc5426 436
b2edef6f 437#ifdef _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT
cf760e4c 438 void *operator new[] ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 );
0b9ab0bd
RL
439#endif
440
b2edef6f
VZ
441#ifdef _WX_WANT_ARRAY_DELETE_VOID
442 void operator delete[] ( void *buf );
0b9ab0bd 443#endif
27198be4 444
b2edef6f 445#ifdef _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT
cf760e4c 446 void operator delete[] (void* buf, const wxChar*, int );
b2edef6f 447#endif
c801d85f 448
807d8487
VZ
449 // ref counted data handling methods
450
451 // get/set
452 wxObjectRefData *GetRefData() const { return m_refData; }
453 void SetRefData(wxObjectRefData *data) { m_refData = data; }
454
455 // make a 'clone' of the object
0b9ab0bd 456 void Ref(const wxObject& clone);
c801d85f 457
807d8487 458 // destroy a reference
0b9ab0bd 459 void UnRef();
c801d85f 460
c801d85f 461protected:
807d8487
VZ
462 // ensure that our data is not shared with anybody else: if we have no
463 // data, it is created using CreateRefData() below, if we have shared data
464 // it is copied using CloneRefData(), otherwise nothing is done
465 void AllocExclusive();
466
467 // both methods must be implemented if Unshare() is used, not pure virtual
468 // only because of the backwards compatibility reasons
469
470 // create a new m_refData
471 virtual wxObjectRefData *CreateRefData() const;
472
473 // create a new m_refData initialized with the given one
b8027888 474 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
807d8487 475
0b9ab0bd 476 wxObjectRefData *m_refData;
c801d85f
KB
477};
478
b2edef6f
VZ
479// ----------------------------------------------------------------------------
480// wxObjectRefData: ref counted data meant to be stored in wxObject
481// ----------------------------------------------------------------------------
c801d85f 482
bddd7a8d 483class WXDLLIMPEXP_BASE wxObjectRefData
0b9ab0bd 484{
bddd7a8d 485 friend class WXDLLIMPEXP_BASE wxObject;
c801d85f
KB
486
487public:
b2edef6f
VZ
488 wxObjectRefData() : m_count(1) { }
489 virtual ~wxObjectRefData() { }
490
491 int GetRefCount() const { return m_count; }
c801d85f 492
c801d85f
KB
493private:
494 int m_count;
495};
496
0b9ab0bd 497
ea1e6c4b
RL
498inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
499{
b2edef6f 500 return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : NULL;
ea1e6c4b
RL
501}
502
2d51f067
SC
503#if wxUSE_EXTENDED_RTTI
504class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject
505{
8f2b1cfd 506 friend class WXDLLIMPEXP_BASE wxDynamicClassInfo ;
2d51f067
SC
507public:
508 // instantiates this object with an instance of its superclass
509 wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ;
510 ~wxDynamicObject();
511
8f2b1cfd
SC
512 void SetProperty (const wxChar *propertyName, const wxxVariant &value);
513 wxxVariant GetProperty (const wxChar *propertyName) const ;
2d51f067
SC
514
515 // get the runtime identity of this object
516 wxClassInfo *GetClassInfo() const
517 {
f525dc35
JS
518#ifdef _MSC_VER
519 return (wxClassInfo*) m_classInfo;
520#else
7e548f6b 521 return wx_const_cast(wxClassInfo *, m_classInfo);
f525dc35 522#endif
2d51f067
SC
523 }
524
525 wxObject* GetSuperClassInstance() const
526 {
527 return m_superClassInstance ;
528 }
529private :
8f2b1cfd
SC
530 // removes an existing runtime-property
531 void RemoveProperty( const wxChar *propertyName ) ;
532
533 // renames an existing runtime-property
534 void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ;
535
2d51f067
SC
536 wxObject *m_superClassInstance ;
537 const wxDynamicClassInfo *m_classInfo;
538 struct wxDynamicObjectInternal;
539 wxDynamicObjectInternal *m_data;
540};
541#endif
542
b2edef6f
VZ
543// ----------------------------------------------------------------------------
544// more debugging macros
545// ----------------------------------------------------------------------------
546
7fe7d506 547#ifdef __WXDEBUG__
b2edef6f
VZ
548 #ifndef WXDEBUG_NEW
549 #define WXDEBUG_NEW new(__TFILE__,__LINE__)
550 #endif
551#else // !__WXDEBUG__
552 #define WXDEBUG_NEW new
7fe7d506
JS
553#endif
554
b2edef6f
VZ
555// Redefine new to be the debugging version. This doesn't work with all
556// compilers, in which case you need to use WXDEBUG_NEW explicitly if you wish
557// to use the debugging version.
7fe7d506
JS
558
559#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
b2edef6f 560 #define new new(__TFILE__,__LINE__)
70dfc4ed 561#elif (defined(__WXDEBUG__) && defined(__VISUALC__) && !wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS)
c86abb56
JS
562 // Including this file redefines new and allows leak reports to contain line numbers
563 #include "wx/msw/msvcrt.h"
c801d85f
KB
564#endif
565
0b9ab0bd 566#endif // _WX_OBJECTH__
c801d85f 567