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