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