]> git.saurik.com Git - wxWidgets.git/blame - interface/object.h
use wxWANTS_CHARS to allow arrows to work inside the control
[wxWidgets.git] / interface / object.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: object.h
e54c96f1 3// Purpose: interface of wxObjectRefData
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxObjectRefData
11 @wxheader{object.h}
7c913512 12
b64d83f5 13 This class is used to store reference-counted data.
7c913512 14
b64d83f5
FM
15 Derive classes from this to store your own data. When retrieving information
16 from a wxObject's reference data, you will need to cast to your own derived class.
cfa9866b
FM
17
18 @b Example:
19
20 @code
21 // include file
22
23 class MyCar: public wxObject
24 {
25 public:
26 MyCar() { }
27 MyCar( int price );
28
29 bool IsOk() const { return m_refData != NULL; }
30
31 bool operator == ( const MyCar& car ) const;
32 bool operator != (const MyCar& car) const { return !(*this == car); }
33
34 void SetPrice( int price );
35 int GetPrice() const;
36
37 protected:
38 virtual wxObjectRefData *CreateRefData() const;
39 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
40
41 DECLARE_DYNAMIC_CLASS(MyCar)
42 };
43
44
45 // implementation
46
47 class MyCarRefData: public wxObjectRefData
48 {
49 public:
50 MyCarRefData()
51 {
52 m_price = 0;
53 }
54
55 MyCarRefData( const MyCarRefData& data )
56 : wxObjectRefData()
57 {
58 m_price = data.m_price;
59 }
60
61 bool operator == (const MyCarRefData& data) const
62 {
63 return m_price == data.m_price;
64 }
65
66 int m_price;
67 };
68
69
70 #define M_CARDATA ((MyCarRefData *)m_refData)
71
72 IMPLEMENT_DYNAMIC_CLASS(MyCar,wxObject)
73
74 MyCar::MyCar( int price )
75 {
76 m_refData = new MyCarRefData();
77 M_CARDATA->m_price = price;
78 }
79
80 wxObjectRefData *MyCar::CreateRefData() const
81 {
82 return new MyCarRefData;
83 }
84
85 wxObjectRefData *MyCar::CloneRefData(const wxObjectRefData *data) const
86 {
87 return new MyCarRefData(*(MyCarRefData *)data);
88 }
89
90 bool MyCar::operator == ( const MyCar& car ) const
91 {
92 if (m_refData == car.m_refData) return true;
93
94 if (!m_refData || !car.m_refData) return false;
95
96 return ( *(MyCarRefData*)m_refData == *(MyCarRefData*)car.m_refData );
97 }
98
99 void MyCar::SetPrice( int price )
100 {
101 UnShare();
102
103 M_CARDATA->m_price = price;
104 }
105
106 int MyCar::GetPrice() const
107 {
108 wxCHECK_MSG( IsOk(), -1, "invalid car" );
109
110 return (M_CARDATA->m_price);
111 }
112 @endcode
7c913512 113
b64d83f5
FM
114
115 @library{wxbase}
116 @category{rtti}
117
118 @see wxObject, wxObjectDataPtr<T>, @ref overview_refcount
23324ae1 119*/
7c913512 120class wxObjectRefData
23324ae1 121{
b64d83f5 122protected:
23324ae1 123 /**
b64d83f5
FM
124 Destructor.
125
126 It's declared @c protected so that wxObjectRefData instances
127 will never be destroyed directly but only as result of a DecRef() call.
23324ae1 128 */
b64d83f5 129 ~wxObjectRefData();
23324ae1 130
b64d83f5 131public:
23324ae1 132 /**
b64d83f5 133 Default constructor. Initialises the internal reference count to 1.
23324ae1 134 */
b64d83f5 135 wxObjectRefData();
23324ae1
FM
136
137 /**
cfa9866b
FM
138 Decrements the reference count associated with this shared data and, if
139 it reaches zero, destroys this instance of wxObjectRefData releasing its
140 memory.
141
142 Please note that after calling this function, the caller should
143 absolutely avoid to use the pointer to this instance since it may not be
144 valid anymore.
23324ae1
FM
145 */
146 void DecRef();
147
148 /**
149 Returns the reference count associated with this shared data.
b64d83f5
FM
150
151 When this goes to zero during a DecRef() call, the object will auto-free itself.
23324ae1 152 */
328f5751 153 int GetRefCount() const;
23324ae1
FM
154
155 /**
156 Increments the reference count associated with this shared data.
157 */
158 void IncRef();
159};
160
161
e54c96f1 162
23324ae1
FM
163/**
164 @class wxObject
165 @wxheader{object.h}
7c913512 166
23324ae1 167 This is the root class of many of the wxWidgets classes.
b64d83f5 168
cfa9866b
FM
169 It declares a virtual destructor which ensures that destructors get called
170 for all derived class objects where necessary.
7c913512 171
cfa9866b
FM
172 wxObject is the hub of a dynamic object creation scheme, enabling a program
173 to create instances of a class only knowing its string class name, and to
174 query the class hierarchy.
7c913512 175
cfa9866b
FM
176 The class contains optional debugging versions of @b new and @b delete, which
177 can help trace memory allocation and deallocation problems.
7c913512 178
cfa9866b 179 wxObject can be used to implement @ref overview_refcount "reference counted"
b64d83f5
FM
180 objects, such as wxPen, wxBitmap and others
181 (see @ref overview_refcount_list "this list").
7c913512 182
23324ae1
FM
183 @library{wxbase}
184 @category{rtti}
7c913512 185
cfa9866b 186 @see wxClassInfo, @ref overview_debugging, wxObjectRefData
23324ae1 187*/
7c913512 188class wxObject
23324ae1
FM
189{
190public:
cfa9866b
FM
191
192 wxObject();
b64d83f5 193
23324ae1 194 /**
b64d83f5 195 Copy ctor.
23324ae1 196 */
7c913512 197 wxObject(const wxObject& other);
cfa9866b 198
23324ae1
FM
199
200 /**
b64d83f5
FM
201 Destructor.
202
203 Performs dereferencing, for those objects that use reference counting.
23324ae1
FM
204 */
205 wxObject();
206
207 /**
208 A virtual function that may be redefined by derived classes to allow dumping of
209 memory states.
cfa9866b 210
b64d83f5
FM
211 This function is only defined in debug build and exists only if @c __WXDEBUG__
212 is defined.
3c4f71cc 213
7c913512 214 @param stream
4cc4bfaf 215 Stream on which to output dump information.
3c4f71cc 216
b64d83f5
FM
217 @remarks Currently wxWidgets does not define Dump() for derived classes,
218 but programmers may wish to use it for their own applications.
219 Be sure to call the Dump member of the class's base class to allow all
220 information to be dumped.
cfa9866b
FM
221 The implementation of this function in wxObject just writes
222 the class name of the object.
23324ae1
FM
223 */
224 void Dump(ostream& stream);
225
226 /**
227 This virtual function is redefined for every class that requires run-time
b64d83f5 228 type information, when using the ::DECLARE_CLASS macro (or similar).
23324ae1 229 */
4cc4bfaf 230 wxClassInfo* GetClassInfo();
23324ae1
FM
231
232 /**
b64d83f5 233 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
3c4f71cc 234
b64d83f5 235 @see Ref(), UnRef(), wxObject::m_refData, SetRefData(), wxObjectRefData
23324ae1 236 */
328f5751 237 wxObjectRefData* GetRefData() const;
23324ae1
FM
238
239 /**
240 Determines whether this class is a subclass of (or the same class as)
241 the given class.
3c4f71cc 242
b64d83f5
FM
243 Example:
244
245 @code
246 bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
247 @endcode
248
7c913512 249 @param info
4cc4bfaf 250 A pointer to a class information object, which may be obtained
b64d83f5 251 by using the ::CLASSINFO macro.
3c4f71cc 252
23324ae1 253 @returns @true if the class represented by info is the same class as this
4cc4bfaf 254 one or is derived from it.
23324ae1 255 */
4cc4bfaf 256 bool IsKindOf(wxClassInfo* info);
23324ae1
FM
257
258 /**
b64d83f5
FM
259 Returns @true if this object has the same data pointer as @a obj.
260
261 Notice that @true is returned if the data pointers are @NULL in both objects.
cfa9866b 262
b64d83f5 263 This function only does a @e shallow comparison, i.e. it doesn't compare
23324ae1 264 the objects pointed to by the data pointers of these objects.
b64d83f5
FM
265
266 @see @ref overview_refcount
23324ae1
FM
267 */
268 bool IsSameAs(const wxObject& obj);
269
270 /**
b64d83f5 271 Makes this object refer to the data in @a clone.
3c4f71cc 272
7c913512 273 @param clone
4cc4bfaf 274 The object to 'clone'.
3c4f71cc 275
23324ae1 276 @remarks First this function calls UnRef() on itself to decrement
b64d83f5
FM
277 (and perhaps free) the data it is currently referring to.
278 It then sets its own wxObject::m_refData to point to that of @a clone,
cfa9866b
FM
279 and increments the reference count inside the data.
280
b64d83f5 281 @see UnRef(), SetRefData(), GetRefData(), wxObjectRefData
23324ae1 282 */
4cc4bfaf 283 void Ref(const wxObject& clone);
23324ae1
FM
284
285 /**
b64d83f5 286 Sets the wxObject::m_refData pointer.
3c4f71cc 287
b64d83f5 288 @see Ref(), UnRef(), GetRefData(), wxObjectRefData
23324ae1
FM
289 */
290 void SetRefData(wxObjectRefData* data);
291
292 /**
293 Decrements the reference count in the associated data, and if it is zero,
294 deletes the data.
3c4f71cc 295
b64d83f5
FM
296 The wxObject::m_refData member is set to @NULL.
297
298 @see Ref(), SetRefData(), GetRefData(), wxObjectRefData
23324ae1
FM
299 */
300 void UnRef();
301
302 /**
303 Ensure that this object's data is not shared with any other object.
3c4f71cc 304
cfa9866b
FM
305 If we have no data, it is created using CreateRefData() below,
306 if we have shared data, it is copied using CloneRefData(),
307 otherwise nothing is done.
23324ae1 308 */
cfa9866b 309 void UnShare();
23324ae1
FM
310
311 /**
312 The @e delete operator is defined for debugging versions of the library only,
cfa9866b 313 when the identifier @c __WXDEBUG__ is defined.
b64d83f5 314
cfa9866b 315 It takes over memory deallocation, allowing wxDebugContext operations.
23324ae1 316 */
cfa9866b 317 void operator delete(void *buf);
23324ae1
FM
318
319 /**
320 The @e new operator is defined for debugging versions of the library only, when
b64d83f5
FM
321 the identifier @c __WXDEBUG__ is defined.
322
323 It takes over memory allocation, allowing wxDebugContext operations.
23324ae1 324 */
b64d83f5 325 void* operator new(size_t size, const wxString& filename = NULL, int lineNum = 0);
cfa9866b 326
b64d83f5 327protected:
cfa9866b
FM
328
329 /**
330 Pointer to an object which is the object's reference-counted data.
331
b64d83f5 332 @see Ref(), UnRef(), SetRefData(), GetRefData(), wxObjectRefData
cfa9866b
FM
333 */
334 wxObjectRefData* m_refData;
23324ae1
FM
335};
336
337
e54c96f1 338
23324ae1
FM
339/**
340 @class wxClassInfo
341 @wxheader{object.h}
7c913512 342
b64d83f5
FM
343 This class stores meta-information about classes.
344
345 Instances of this class are not generally defined directly by an application,
346 but indirectly through use of macros such as ::DECLARE_DYNAMIC_CLASS and
347 ::IMPLEMENT_DYNAMIC_CLASS.
7c913512 348
23324ae1
FM
349 @library{wxbase}
350 @category{rtti}
7c913512 351
b64d83f5 352 @see @ref overview_rtti_classinfo, wxObject
23324ae1 353*/
7c913512 354class wxClassInfo
23324ae1
FM
355{
356public:
357 /**
b64d83f5
FM
358 Constructs a wxClassInfo object.
359
360 The supplied macros implicitly construct objects of this class, so there is no
361 need to create such objects explicitly in an application.
23324ae1 362 */
4cc4bfaf
FM
363 wxClassInfo(const wxChar* className,
364 const wxClassInfo* baseClass1,
365 const wxClassInfo* baseClass2,
23324ae1
FM
366 int size, wxObjectConstructorFn fn);
367
368 /**
b64d83f5
FM
369 Creates an object of the appropriate kind.
370
371 @returns @NULL if the class has not been declared dynamically creatable
372 (typically, this happens for abstract classes).
23324ae1 373 */
328f5751 374 wxObject* CreateObject() const;
23324ae1
FM
375
376 /**
b64d83f5 377 Finds the wxClassInfo object for a class with the given @a name.
23324ae1 378 */
4cc4bfaf 379 static wxClassInfo* FindClass(wxChar* name);
23324ae1
FM
380
381 /**
382 Returns the name of the first base class (@NULL if none).
383 */
328f5751 384 wxChar* GetBaseClassName1() const;
23324ae1
FM
385
386 /**
387 Returns the name of the second base class (@NULL if none).
388 */
328f5751 389 wxChar* GetBaseClassName2() const;
23324ae1
FM
390
391 /**
392 Returns the string form of the class name.
393 */
328f5751 394 wxChar* GetClassName() const;
23324ae1
FM
395
396 /**
397 Returns the size of the class.
398 */
328f5751 399 int GetSize() const;
23324ae1
FM
400
401 /**
b64d83f5
FM
402 Initializes pointers in the wxClassInfo objects for fast execution of IsKindOf().
403 Called in base wxWidgets library initialization.
23324ae1
FM
404 */
405 static void InitializeClasses();
406
407 /**
408 Returns @true if this class info can create objects of the associated class.
409 */
328f5751 410 bool IsDynamic() const;
23324ae1
FM
411
412 /**
413 Returns @true if this class is a kind of (inherits from) the given class.
414 */
415 bool IsKindOf(wxClassInfo* info);
416};
417
418
e54c96f1 419
23324ae1 420/**
23324ae1 421 @wxheader{object.h}
7c913512 422
b64d83f5
FM
423 This is helper template class primarily written to avoid memory leaks because of
424 missing calls to wxObjectRefData::DecRef().
7c913512 425
b64d83f5
FM
426 Despite the name this template can actually be used as a smart pointer for any
427 class implementing the reference counting interface which only consists of the two
428 methods @b T::IncRef() and @b T::DecRef().
7c913512 429
b64d83f5
FM
430 The difference to wxSharedPtr<T> is that wxObjectDataPtr<T> relies on the reference
431 counting to be in the class pointed to where instead wxSharedPtr<T> implements the
23324ae1 432 reference counting itself.
7c913512 433
cfa9866b
FM
434
435 @b Example:
436
437 @code
438 class MyCarRefData: public wxObjectRefData
439 {
440 public:
441 MyCarRefData() { m_price = 0; }
442
443 MyCarRefData( const MyCarRefData& data )
444 : wxObjectRefData()
445 {
446 m_price = data.m_price;
447 }
448
449 void SetPrice( int price ) { m_price = price; }
450 int GetPrice() { return m_price; }
451
452 protected:
453 int m_price;
454 };
455
456 class MyCar
457 {
458 public:
459 MyCar( int price ) : m_data( new MyCarRefData )
460 {
461 m_data->SetPrice( price );
462 }
463
464 MyCar& operator =( const MyCar& tocopy )
465 {
466 m_data = tocopy.m_data;
467 return *this;
468 }
469
470 bool operator == ( const MyCar& other ) const
471 {
472 if (m_data.get() == other.m_data.get()) return true;
473 return (m_data->GetPrice() == other.m_data->GetPrice());
474 }
475
476 void SetPrice( int price )
477 {
478 UnShare();
479 m_data->SetPrice( price );
480 }
481
482 int GetPrice() const
483 {
484 return m_data->GetPrice();
485 }
486
487 wxObjectDataPtr<MyCarRefData> m_data;
488
489 protected:
490 void UnShare()
491 {
492 if (m_data->GetRefCount() == 1)
493 return;
494
495 m_data.reset( new MyCarRefData( *m_data ) );
496 }
497 };
cfa9866b 498 @endcode
7c913512 499
b64d83f5
FM
500
501 @library{wxbase}
502 @category{rtti,smartpointers}
503
504 @see wxObject, wxObjectRefData, @ref overview_refcount, wxSharedPtr<T>,
505 wxScopedPtr<T>, wxWeakRef<T>
23324ae1 506*/
7c913512 507class wxObjectDataPtr<T>
23324ae1
FM
508{
509public:
cfa9866b 510 /**
b64d83f5
FM
511 Constructor.
512
513 @a ptr is a pointer to the reference counted object to which this class points.
cfa9866b
FM
514 If @a ptr is not NULL @b T::IncRef() will be called on the object.
515 */
516 wxObjectDataPtr<T>(T* ptr = NULL);
517
23324ae1 518 /**
b64d83f5
FM
519 This copy constructor increases the count of the reference counted object to
520 which @a tocopy points and then this class will point to, as well.
23324ae1 521 */
cfa9866b
FM
522 wxObjectDataPtr<T>(const wxObjectDataPtr<T>& tocopy);
523
23324ae1
FM
524
525 /**
b64d83f5 526 Decreases the reference count of the object to which this class points.
23324ae1 527 */
b64d83f5 528 ~wxObjectDataPtr<T>();
23324ae1
FM
529
530 /**
b64d83f5 531 Gets a pointer to the reference counted object to which this class points.
23324ae1 532 */
328f5751 533 T* get() const;
23324ae1 534
b64d83f5
FM
535 /**
536 Reset this class to ptr which points to a reference counted object and
537 calls T::DecRef() on the previously owned object.
538 */
539 void reset(T *ptr)
540
23324ae1 541 /**
7c913512 542 Conversion to a boolean expression (in a variant which is not
b64d83f5
FM
543 convertable to anything but a boolean expression).
544
545 If this class contains a valid pointer it will return @true, if it contains
546 a @NULL pointer it will return @false.
23324ae1 547 */
328f5751 548 operator unspecified_bool_type() const;
23324ae1
FM
549
550 /**
b64d83f5
FM
551 Returns a reference to the object.
552
553 If the internal pointer is @NULL this method will cause an assert in debug mode.
23324ae1 554 */
cfa9866b 555 T& operator*() const;
23324ae1
FM
556
557 /**
b64d83f5
FM
558 Returns a pointer to the reference counted object to which this class points.
559
560 If this the internal pointer is @NULL, this method will assert in debug mode.
23324ae1 561 */
b64d83f5 562 T* operator->() const;
23324ae1
FM
563
564 //@{
565 /**
b64d83f5 566 Assignment operator.
23324ae1 567 */
cfa9866b
FM
568 wxObjectDataPtr<T>& operator=(const wxObjectDataPtr<T>& tocopy);
569 wxObjectDataPtr<T>& operator=(T* ptr);
23324ae1
FM
570 //@}
571};
572
573
e54c96f1 574
23324ae1
FM
575// ============================================================================
576// Global functions/macros
577// ============================================================================
578
8af7f7c1
BP
579/** @ingroup group_funcmacro_rtti */
580//@{
581
23324ae1 582/**
8af7f7c1
BP
583 Returns a pointer to the wxClassInfo object associated with this class.
584
585 @header{wx/object.h}
586*/
587#define CLASSINFO( className )
588
589/**
590 Used inside a class declaration to declare that the class should be made
591 known to the class hierarchy, but objects of this class cannot be created
592 dynamically. The same as DECLARE_ABSTRACT_CLASS().
593
594 @header{wx/object.h}
23324ae1 595*/
8af7f7c1 596#define DECLARE_CLASS( className )
23324ae1
FM
597
598/**
599 Used inside a class declaration to declare that the class should be
600 made known to the class hierarchy, but objects of this class cannot be created
8af7f7c1
BP
601 dynamically. The same as DECLARE_CLASS().
602
603 @header{wx/object.h}
604
23324ae1 605 Example:
4cc4bfaf 606
23324ae1
FM
607 @code
608 class wxCommand: public wxObject
609 {
8af7f7c1 610 DECLARE_ABSTRACT_CLASS(wxCommand)
7c913512 611
8af7f7c1
BP
612 private:
613 ...
614 public:
615 ...
23324ae1
FM
616 };
617 @endcode
618*/
8af7f7c1 619#define DECLARE_ABSTRACT_CLASS( className )
23324ae1
FM
620
621/**
8af7f7c1
BP
622 Used inside a class declaration to make the class known to wxWidgets RTTI
623 system and also declare that the objects of this class should be
624 dynamically creatable from run-time type information. Notice that this
625 implies that the class should have a default constructor, if this is not
626 the case consider using DECLARE_CLASS().
23324ae1 627
8af7f7c1 628 @header{wx/object.h}
7c913512 629
8af7f7c1
BP
630 Example:
631
632 @code
633 class wxFrame: public wxWindow
634 {
635 DECLARE_DYNAMIC_CLASS(wxFrame)
636
637 private:
638 const wxString& frameTitle;
639 public:
640 ...
641 };
642 @endcode
23324ae1 643*/
7baebf86 644#define DECLARE_DYNAMIC_CLASS( className )
23324ae1
FM
645
646/**
8af7f7c1
BP
647 Used in a C++ implementation file to complete the declaration of a class
648 that has run-time type information. The same as IMPLEMENT_ABSTRACT_CLASS().
649
650 @header{wx/object.h}
23324ae1 651*/
8af7f7c1 652#define IMPLEMENT_CLASS( className, baseClassName )
23324ae1
FM
653
654/**
8af7f7c1
BP
655 Used in a C++ implementation file to complete the declaration of a class
656 that has run-time type information and two base classes. The same as
657 IMPLEMENT_ABSTRACT_CLASS2().
7c913512 658
8af7f7c1 659 @header{wx/object.h}
23324ae1 660*/
8af7f7c1 661#define IMPLEMENT_CLASS2( className, baseClassName1, baseClassName2 )
23324ae1
FM
662
663/**
8af7f7c1
BP
664 Used in a C++ implementation file to complete the declaration of a class
665 that has run-time type information. The same as IMPLEMENT_CLASS().
666
667 @header{wx/object.h}
668
23324ae1 669 Example:
4cc4bfaf 670
23324ae1
FM
671 @code
672 IMPLEMENT_ABSTRACT_CLASS(wxCommand, wxObject)
7c913512 673
23324ae1
FM
674 wxCommand::wxCommand(void)
675 {
8af7f7c1 676 ...
23324ae1
FM
677 }
678 @endcode
679*/
8af7f7c1 680#define IMPLEMENT_ABSTRACT_CLASS( className, baseClassName )
23324ae1
FM
681
682/**
8af7f7c1
BP
683 Used in a C++ implementation file to complete the declaration of a class
684 that has run-time type information and two base classes. The same as
685 IMPLEMENT_CLASS2().
686
687 @header{wx/object.h}
23324ae1 688*/
8af7f7c1 689#define IMPLEMENT_ABSTRACT_CLASS2( className, baseClassName1, baseClassName2 )
23324ae1
FM
690
691/**
8af7f7c1
BP
692 Used in a C++ implementation file to complete the declaration of a class
693 that has run-time type information, and whose instances can be created
694 dynamically.
7c913512 695
8af7f7c1
BP
696 @header{wx/object.h}
697
698 Example:
699
700 @code
701 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
702
703 wxFrame::wxFrame(void)
704 {
705 ...
706 }
707 @endcode
23324ae1 708*/
8af7f7c1 709#define IMPLEMENT_DYNAMIC_CLASS( className, baseClassName )
23324ae1
FM
710
711/**
8af7f7c1
BP
712 Used in a C++ implementation file to complete the declaration of a class
713 that has run-time type information, and whose instances can be created
714 dynamically. Use this for classes derived from two base classes.
715
716 @header{wx/object.h}
23324ae1 717*/
8af7f7c1 718#define IMPLEMENT_DYNAMIC_CLASS2( className, baseClassName1, baseClassName2 )
23324ae1
FM
719
720/**
cfa9866b
FM
721 Same as @c const_cast<T>(x) if the compiler supports const cast or @c (T)x for
722 old compilers. Unlike wxConstCast(), the cast it to the type @c T and not to
723 <tt>T *</tt> and also the order of arguments is the same as for the standard cast.
8af7f7c1
BP
724
725 @header{wx/defs.h}
726
727 @see wx_reinterpret_cast(), wx_static_cast()
23324ae1 728*/
8af7f7c1 729#define wx_const_cast(T, x)
23324ae1
FM
730
731/**
cfa9866b
FM
732 Same as @c reinterpret_cast<T>(x) if the compiler supports reinterpret cast or
733 @c (T)x for old compilers.
4cc4bfaf 734
8af7f7c1 735 @header{wx/defs.h}
7c913512 736
8af7f7c1 737 @see wx_const_cast(), wx_static_cast()
23324ae1 738*/
8af7f7c1 739#define wx_reinterpret_cast(T, x)
23324ae1
FM
740
741/**
cfa9866b 742 Same as @c static_cast<T>(x) if the compiler supports static cast or @c (T)x for
8af7f7c1
BP
743 old compilers. Unlike wxStaticCast(), there are no checks being done and
744 the meaning of the macro arguments is exactly the same as for the standard
cfa9866b 745 static cast, i.e. @a T is the full type name and star is not appended to it.
7c913512 746
8af7f7c1
BP
747 @header{wx/defs.h}
748
749 @see wx_const_cast(), wx_reinterpret_cast(), wx_truncate_cast()
23324ae1 750*/
8af7f7c1 751#define wx_static_cast(T, x)
23324ae1
FM
752
753/**
8af7f7c1
BP
754 This case doesn’t correspond to any standard cast but exists solely to make
755 casts which possibly result in a truncation of an integer value more
756 readable.
757
758 @header{wx/defs.h}
23324ae1 759*/
8af7f7c1 760#define wx_truncate_cast(T, x)
23324ae1
FM
761
762/**
cfa9866b 763 This macro expands into <tt>const_cast<classname *>(ptr)</tt> if the compiler
8af7f7c1 764 supports const_cast or into an old, C-style cast, otherwise.
4cc4bfaf 765
8af7f7c1 766 @header{wx/defs.h}
7c913512 767
8af7f7c1 768 @see wx_const_cast(), wxDynamicCast(), wxStaticCast()
23324ae1 769*/
7baebf86 770#define wxConstCast( ptr, classname )
23324ae1 771
23324ae1 772/**
8af7f7c1
BP
773 This macro returns the pointer @e ptr cast to the type @e classname * if
774 the pointer is of this type (the check is done during the run-time) or
775 @NULL otherwise. Usage of this macro is preferred over obsoleted
776 wxObject::IsKindOf() function.
7c913512 777
8af7f7c1
BP
778 The @e ptr argument may be @NULL, in which case @NULL will be returned.
779
780 @header{wx/object.h}
781
782 Example:
783
784 @code
785 wxWindow *win = wxWindow::FindFocus();
786 wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);
787 if ( text )
788 {
789 // a text control has the focus...
790 }
791 else
792 {
793 // no window has the focus or it is not a text control
794 }
795 @endcode
796
b64d83f5 797 @see @ref overview_rtti, wxDynamicCastThis(), wxConstCast(), wxStaticCast()
23324ae1 798*/
7baebf86 799#define wxDynamicCast( ptr, classname )
23324ae1
FM
800
801/**
cfa9866b 802 This macro is equivalent to <tt>wxDynamicCast(this, classname)</tt> but the latter provokes
8af7f7c1
BP
803 spurious compilation warnings from some compilers (because it tests whether
804 @c this pointer is non-@NULL which is always true), so this macro should be
805 used to avoid them.
7c913512 806
8af7f7c1
BP
807 @header{wx/object.h}
808
809 @see wxDynamicCast()
23324ae1 810*/
7baebf86 811#define wxDynamicCastThis( classname )
23324ae1
FM
812
813/**
8af7f7c1
BP
814 This macro checks that the cast is valid in debug mode (an assert failure
815 will result if wxDynamicCast(ptr, classname) == @NULL) and then returns the
cfa9866b 816 result of executing an equivalent of <tt>static_cast<classname *>(ptr)</tt>.
4cc4bfaf 817
8af7f7c1 818 @header{wx/object.h}
7c913512 819
8af7f7c1 820 @see wx_static_cast(), wxDynamicCast(), wxConstCast()
23324ae1 821*/
7baebf86 822#define wxStaticCast( ptr, classname )
8af7f7c1
BP
823
824/**
825 Creates and returns an object of the given class, if the class has been
826 registered with the dynamic class system using DECLARE... and IMPLEMENT...
827 macros.
828
829 @header{wx/object.h}
830*/
7baebf86 831wxObject *wxCreateDynamicObject(const wxString& className);
8af7f7c1
BP
832
833//@}
23324ae1 834
29f86fc1
BP
835/** @ingroup group_funcmacro_debug */
836//@{
837
838/**
839 This is defined in debug mode to be call the redefined new operator
840 with filename and line number arguments. The definition is:
841
842 @code
843 #define WXDEBUG_NEW new(__FILE__,__LINE__)
844 @endcode
845
846 In non-debug mode, this is defined as the normal new operator.
847
848 @header{wx/object.h}
849*/
850#define WXDEBUG_NEW( arg )
851
852//@}
853