]> git.saurik.com Git - wxWidgets.git/blame - include/wx/object.h
Fixed problem in InsertItems of always adding ownerdraw data even when
[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$
0b9ab0bd
RL
8// Copyright: (c) 1997 Julian Smart and Markus Holzem
9// (c) 2001 Ron Lee <ron@debian.org>
3f4a0c5b 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
34138703
JS
13#ifndef _WX_OBJECTH__
14#define _WX_OBJECTH__
c801d85f
KB
15
16#ifdef __GNUG__
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
KB
26
27class WXDLLEXPORT wxObject;
28
47d67540 29#if wxUSE_DYNAMIC_CLASSES
c801d85f 30
0b9ab0bd
RL
31// ----------------------------------------------------------------------------
32// conditional compilation
33// ----------------------------------------------------------------------------
34
b2edef6f
VZ
35// this shouldn't be needed any longer as <wx/msw/private.h> does it but it
36// doesn't hurt neither
c801d85f
KB
37#ifdef GetClassName
38#undef GetClassName
39#endif
3f1af920
JS
40#ifdef GetClassInfo
41#undef GetClassInfo
c801d85f
KB
42#endif
43
44class WXDLLEXPORT wxClassInfo;
f4a8c29f 45class WXDLLEXPORT wxHashTable;
b2edef6f 46class WXDLLEXPORT wxObjectRefData;
c801d85f 47
38830220 48#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
b2edef6f 49 #include "wx/ioswrap.h"
fbc535ff
JS
50#endif
51
c801d85f 52
0b9ab0bd
RL
53// ----------------------------------------------------------------------------
54// wxClassInfo
55// ----------------------------------------------------------------------------
56
57typedef wxObject *(*wxObjectConstructorFn)(void);
c801d85f 58
c801d85f
KB
59class WXDLLEXPORT wxClassInfo
60{
aac65598 61public:
38befbee
RL
62 wxClassInfo( const wxChar *className,
63 const wxChar *baseName1,
64 const wxChar *baseName2,
65 int size,
66 wxObjectConstructorFn ctor )
0b9ab0bd
RL
67 : m_className(className)
68 , m_baseClassName1(baseName1)
69 , m_baseClassName2(baseName2)
70 , m_objectSize(size)
71 , m_objectConstructor(ctor)
72 , m_baseInfo1(0)
73 , m_baseInfo2(0)
74 , m_next(sm_first)
75 { sm_first = this; }
76
77 wxObject *CreateObject() { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
78
79 const wxChar *GetClassName() const { return m_className; }
80 const wxChar *GetBaseClassName1() const { return m_baseClassName1; }
81 const wxChar *GetBaseClassName2() const { return m_baseClassName2; }
82 const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; }
83 const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; }
84 int GetSize() const { return m_objectSize; }
85
86 wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
87 static const wxClassInfo *GetFirst() { return sm_first; }
88 const wxClassInfo *GetNext() const { return m_next; }
89 static wxClassInfo *FindClass(const wxChar *className);
807d8487 90
0b9ab0bd
RL
91 // Climb upwards through inheritance hierarchy.
92 // Dual inheritance is catered for.
93
94 bool IsKindOf(const wxClassInfo *info) const
95 {
96 return info != 0 &&
97 ( info == this ||
98 ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
99 ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
100 }
3f4a0c5b 101
0b9ab0bd 102 // Initializes parent pointers and hash table for fast searching.
c801d85f 103
0b9ab0bd 104 static void InitializeClasses();
0c32066b 105
0b9ab0bd 106 // Cleans up hash table used for fast searching.
0c32066b 107
0b9ab0bd 108 static void CleanUpClasses();
0c32066b
JS
109
110public:
0b9ab0bd
RL
111 const wxChar *m_className;
112 const wxChar *m_baseClassName1;
113 const wxChar *m_baseClassName2;
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);
c801d85f
KB
135};
136
0b9ab0bd 137WXDLLEXPORT wxObject *wxCreateDynamicObject(const wxChar *name);
c801d85f 138
0b9ab0bd
RL
139// ----------------------------------------------------------------------------
140// Dynamic class macros
141// ----------------------------------------------------------------------------
142
143#define DECLARE_DYNAMIC_CLASS(name) \
144 public: \
145 static wxClassInfo sm_class##name; \
146 virtual wxClassInfo *GetClassInfo() const \
0c32066b 147 { return &name::sm_class##name; }
c801d85f
KB
148
149#define DECLARE_ABSTRACT_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
150#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
151
0b9ab0bd
RL
152// -----------------------------------
153// for concrete classes
154// -----------------------------------
155
156 // Single inheritance with one base class
c801d85f 157
0b9ab0bd
RL
158#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
159 wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name() \
160 { return new name; } \
161 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename), \
162 0, (int) sizeof(name), \
163 (wxObjectConstructorFn) wxConstructorFor##name);
c801d85f 164
0b9ab0bd 165 // Multiple inheritance with two base classes
c801d85f 166
0b9ab0bd
RL
167#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
168 wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name() \
169 { return new name; } \
170 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
171 wxT(#basename2), (int) sizeof(name), \
172 (wxObjectConstructorFn) wxConstructorFor##name);
c801d85f 173
0b9ab0bd
RL
174// -----------------------------------
175// for abstract classes
176// -----------------------------------
c801d85f 177
0b9ab0bd
RL
178 // Single inheritance with one base class
179
180#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
181 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename), \
182 0, (int) sizeof(name), (wxObjectConstructorFn) 0);
183
184 // Multiple inheritance with two base classes
185
186#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
187 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
188 wxT(#basename2), (int) sizeof(name), \
189 (wxObjectConstructorFn) 0);
c801d85f
KB
190
191#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
192#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
193
0b9ab0bd
RL
194// -----------------------------------
195// for pluggable classes
196// -----------------------------------
197
198 // NOTE: this should probably be the very first statement
199 // in the class declaration so wxPluginSentinel is
200 // the first member initialised and the last destroyed.
201
202// _DECLARE_DL_SENTINEL(name) wxPluginSentinel m_pluginsentinel;
203
204#if wxUSE_NESTED_CLASSES
205
60b73526
RL
206#define _DECLARE_DL_SENTINEL(name, exportdecl) \
207class exportdecl name##PluginSentinel { \
208private: \
209 static const wxString sm_className; \
210public: \
211 name##PluginSentinel(); \
2e0b1b11 212 ~name##PluginSentinel(); \
60b73526 213}; \
0b9ab0bd 214name##PluginSentinel m_pluginsentinel;
0b9ab0bd
RL
215
216#define _IMPLEMENT_DL_SENTINEL(name) \
217 const wxString name::name##PluginSentinel::sm_className(#name); \
218 name::name##PluginSentinel::name##PluginSentinel() { \
4f89dbc4 219 wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \
7c1e2b44 220 if( e != 0 ) { e->RefObj(); } \
0b9ab0bd 221 } \
abad5367 222 name::name##PluginSentinel::~name##PluginSentinel() { \
4f89dbc4 223 wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \
7c1e2b44 224 if( e != 0 ) { e->UnrefObj(); } \
0b9ab0bd
RL
225 }
226#else
227
228#define _DECLARE_DL_SENTINEL(name)
229#define _IMPLEMENT_DL_SENTINEL(name)
230
231#endif // wxUSE_NESTED_CLASSES
232
233#define DECLARE_PLUGGABLE_CLASS(name) \
60b73526 234 DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT)
0b9ab0bd 235#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \
60b73526
RL
236 DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT)
237
238#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \
239 DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo)
240#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \
241 DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo)
0b9ab0bd
RL
242
243#define IMPLEMENT_PLUGGABLE_CLASS(name, basename) \
244 IMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
245#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \
246 IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
0b9ab0bd
RL
247#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \
248 IMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
249#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
250 IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
251
60b73526
RL
252#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \
253 IMPLEMENT_PLUGGABLE_CLASS(name, basename)
254#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \
255 IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2)
256#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \
257 IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename)
258#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
259 IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
260
0b9ab0bd 261
0c32066b 262#define CLASSINFO(name) (&name::sm_class##name)
c801d85f 263
34636400 264#else // !wxUSE_DYNAMIC_CLASSES
c801d85f 265
0b9ab0bd
RL
266 // No dynamic class system: so stub out the macros
267
c801d85f
KB
268#define DECLARE_DYNAMIC_CLASS(name)
269#define DECLARE_ABSTRACT_CLASS(name)
270#define DECLARE_CLASS(name)
271#define IMPLEMENT_DYNAMIC_CLASS(name, basename)
272#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2)
273#define IMPLEMENT_ABSTRACT_CLASS(name, basename)
274#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2)
275#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
276#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
277
0b9ab0bd
RL
278#define DECLARE_PLUGGABLE_CLASS(name)
279#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name)
280#define IMPLEMENT_PLUGGABLE_CLASS(name, basename)
281#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2)
282#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename)
283#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
284
60b73526
RL
285#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo)
286#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo)
287#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename)
288#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2)
289#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename)
290#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
291
0b9ab0bd
RL
292#endif // wxUSE_DYNAMIC_CLASSES
293
c801d85f 294
3013b6f4
JS
295#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::sm_class##className)
296
b2edef6f 297// Just seems a bit nicer-looking (pretend it's not a macro)
3013b6f4 298#define wxIsKindOf(obj, className) obj->IsKindOf(&className::sm_class##className)
c801d85f 299
b2edef6f 300// to be replaced by dynamic_cast<> in the future
34636400 301#define wxDynamicCast(obj, className) \
0b9ab0bd
RL
302 (className *) wxCheckDynamicCast((wxObject*)(obj), &className::sm_class##className)
303
b2edef6f
VZ
304// The 'this' pointer is always true, so use this version
305// to cast the this pointer and avoid compiler warnings.
f7637829 306#define wxDynamicCastThis(className) \
0b9ab0bd 307 (IsKindOf(&className::sm_class##className) ? (className *)(this) : (className *)0)
33ac7e6f 308
f6bcfd97
BP
309#define wxConstCast(obj, className) ((className *)(obj))
310
0b9ab0bd 311
f6bcfd97 312#ifdef __WXDEBUG__
0b9ab0bd
RL
313inline void wxCheckCast(void *ptr)
314{
315 wxASSERT_MSG( ptr, _T("wxStaticCast() used incorrectly") );
316}
317#define wxStaticCast(obj, className) \
318 (wxCheckCast(wxDynamicCast(obj, className)), ((className *)(obj)))
f6bcfd97 319
0b9ab0bd
RL
320#else // !__WXDEBUG__
321#define wxStaticCast(obj, className) ((className *)(obj))
f6bcfd97 322
0b9ab0bd 323#endif // __WXDEBUG__
f6bcfd97 324
0b9ab0bd 325
b2edef6f 326// for some reason Borland seems to need this include.
0b9ab0bd
RL
327#if wxUSE_STD_IOSTREAM \
328 && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) \
329 && defined(__BORLANDC__)
b2edef6f
VZ
330 #if wxUSE_IOSTREAMH
331 #include <iostream.h>
332 #else
333 #include <iostream>
334 #endif
335#endif // wxUSE_IOSTREAMH
336
337// ----------------------------------------------------------------------------
338// set up memory debugging macros
339// ----------------------------------------------------------------------------
340
341/*
342 Which new/delete operator variants do we want?
343
344 _WX_WANT_NEW_SIZET_WXCHAR_INT = void *operator new (size_t size, wxChar *fileName = 0, int lineNum = 0)
345 _WX_WANT_DELETE_VOID = void operator delete (void * buf)
346 _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET = void operator delete (void *buf, const char *_fname, size_t _line)
347 _WX_WANT_DELETE_VOID_WXCHAR_INT = void operator delete(void *buf, wxChar*, int)
348 _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT = void *operator new[] (size_t size, wxChar *fileName , int lineNum = 0)
349 _WX_WANT_ARRAY_DELETE_VOID = void operator delete[] (void *buf)
350 _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT = void operator delete[] (void* buf, wxChar*, int )
351*/
352
353#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
354
355// All compilers get this one
356#define _WX_WANT_NEW_SIZET_WXCHAR_INT
357
358// Everyone except Visage gets the next one
359#ifndef __VISAGECPP__
360 #define _WX_WANT_DELETE_VOID
c801d85f 361#endif
b2edef6f
VZ
362
363// Only visage gets this one under the correct circumstances
364#if defined(__VISAGECPP__) && __DEBUG_ALLOC__
365 #define _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET
366#endif
367
368// Only VC++ 6.0 and CodeWarrior compilers get overloaded delete that matches new
369#if ( defined(__VISUALC__) && (__VISUALC__ >= 1200) ) || defined(__MWERKS__)
370 #define _WX_WANT_DELETE_VOID_WXCHAR_INT
fd85b064 371#endif
c801d85f 372
b2edef6f
VZ
373// Now see who (if anyone) gets the array memory operators
374#if wxUSE_ARRAY_MEMORY_OPERATORS
375
376 // Everyone except Visual C++ (cause problems for VC++ - crashes)
377 #if !defined(__VISUALC__)
378 #define _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT
379 #endif
380
381 // Everyone except Visual C++ (cause problems for VC++ - crashes)
382 #if !defined(__VISUALC__)
383 #define _WX_WANT_ARRAY_DELETE_VOID
384 #endif
385
386 // Only CodeWarrior 6 or higher
387 #if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
388 #define _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT
389 #endif
390
391#endif // wxUSE_ARRAY_MEMORY_OPERATORS
392
393#endif // WXDEBUG && wxUSE_MEMORY_TRACING
394
0b9ab0bd
RL
395
396// ----------------------------------------------------------------------------
b2edef6f 397// wxObject: the root class of wxWindows object hierarchy
0b9ab0bd
RL
398// ----------------------------------------------------------------------------
399
c801d85f
KB
400class WXDLLEXPORT wxObject
401{
0b9ab0bd 402DECLARE_ABSTRACT_CLASS(wxObject)
c801d85f 403
0b9ab0bd 404public:
b2edef6f 405 wxObject() { m_refData = NULL; }
0b9ab0bd 406 virtual ~wxObject() { UnRef(); }
c801d85f 407
0b9ab0bd 408 bool IsKindOf(wxClassInfo *info) const;
c801d85f 409
0b9ab0bd 410
b2edef6f
VZ
411 // Turn on the correct set of new and delete operators
412
413#ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT
cf760e4c 414 void *operator new ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 );
0b9ab0bd 415#endif
27198be4 416
b2edef6f
VZ
417#ifdef _WX_WANT_DELETE_VOID
418 void operator delete ( void * buf );
419#endif
0b9ab0bd 420
b2edef6f
VZ
421#ifdef _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET
422 void operator delete ( void *buf, const char *_fname, size_t _line );
0b9ab0bd 423#endif
76626af2 424
b2edef6f 425#ifdef _WX_WANT_DELETE_VOID_WXCHAR_INT
cf760e4c 426 void operator delete ( void *buf, const wxChar*, int );
b2edef6f 427#endif
8cfc5426 428
b2edef6f 429#ifdef _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT
cf760e4c 430 void *operator new[] ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 );
0b9ab0bd
RL
431#endif
432
b2edef6f
VZ
433#ifdef _WX_WANT_ARRAY_DELETE_VOID
434 void operator delete[] ( void *buf );
0b9ab0bd 435#endif
27198be4 436
b2edef6f 437#ifdef _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT
cf760e4c 438 void operator delete[] (void* buf, const wxChar*, int );
b2edef6f 439#endif
c801d85f 440
c801d85f 441
0b9ab0bd
RL
442#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
443 virtual void Dump(wxSTD ostream& str);
c801d85f
KB
444#endif
445
807d8487
VZ
446 // ref counted data handling methods
447
448 // get/set
449 wxObjectRefData *GetRefData() const { return m_refData; }
450 void SetRefData(wxObjectRefData *data) { m_refData = data; }
451
452 // make a 'clone' of the object
0b9ab0bd 453 void Ref(const wxObject& clone);
c801d85f 454
807d8487 455 // destroy a reference
0b9ab0bd 456 void UnRef();
c801d85f 457
c801d85f 458protected:
807d8487
VZ
459 // ensure that our data is not shared with anybody else: if we have no
460 // data, it is created using CreateRefData() below, if we have shared data
461 // it is copied using CloneRefData(), otherwise nothing is done
462 void AllocExclusive();
463
464 // both methods must be implemented if Unshare() is used, not pure virtual
465 // only because of the backwards compatibility reasons
466
467 // create a new m_refData
468 virtual wxObjectRefData *CreateRefData() const;
469
470 // create a new m_refData initialized with the given one
b8027888 471 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
807d8487 472
0b9ab0bd 473 wxObjectRefData *m_refData;
c801d85f
KB
474};
475
b2edef6f
VZ
476// ----------------------------------------------------------------------------
477// wxObjectRefData: ref counted data meant to be stored in wxObject
478// ----------------------------------------------------------------------------
c801d85f 479
0b9ab0bd
RL
480class WXDLLEXPORT wxObjectRefData
481{
c801d85f
KB
482 friend class wxObject;
483
484public:
b2edef6f
VZ
485 wxObjectRefData() : m_count(1) { }
486 virtual ~wxObjectRefData() { }
487
488 int GetRefCount() const { return m_count; }
c801d85f 489
c801d85f
KB
490private:
491 int m_count;
492};
493
0b9ab0bd 494
ea1e6c4b
RL
495inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
496{
b2edef6f 497 return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : NULL;
ea1e6c4b
RL
498}
499
b2edef6f
VZ
500// ----------------------------------------------------------------------------
501// more debugging macros
502// ----------------------------------------------------------------------------
503
7fe7d506 504#ifdef __WXDEBUG__
b2edef6f
VZ
505 #ifndef WXDEBUG_NEW
506 #define WXDEBUG_NEW new(__TFILE__,__LINE__)
507 #endif
508#else // !__WXDEBUG__
509 #define WXDEBUG_NEW new
7fe7d506
JS
510#endif
511
b2edef6f
VZ
512// Redefine new to be the debugging version. This doesn't work with all
513// compilers, in which case you need to use WXDEBUG_NEW explicitly if you wish
514// to use the debugging version.
7fe7d506
JS
515
516#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
b2edef6f 517 #define new new(__TFILE__,__LINE__)
c801d85f
KB
518#endif
519
0b9ab0bd 520#endif // _WX_OBJECTH__
c801d85f 521