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