From e84fd6a105588b59473868a221c694e89adc98c2 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 7 Apr 2008 10:46:15 +0000 Subject: [PATCH] Put sample code back in, removed during conversion to Doxygen git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53079 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/weakref.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/interface/weakref.h b/interface/weakref.h index f33ee60548..903de9a876 100644 --- a/interface/weakref.h +++ b/interface/weakref.h @@ -55,6 +55,42 @@ public: wxWeakRef is a small object and the mechanism behind it is fast (@b O(1)). So the overall cost of using it is small. + Example + + @code + wxWindow *wnd = new wxWindow( parent, wxID_ANY, "wxWindow" ); + wxWeakRef wr = wnd; + wxWindowRef wr2 = wnd; // Same as above, but using a typedef + // Do things with window + wnd->Show( true ); + // Weak ref is used like an ordinary pointer + wr->Show( false ); + wnd->Destroy(); + // Now the weak ref has been reset, so we don't risk accessing + // a dangling pointer: + wxASSERT( wr==NULL ); + @endcode + + wxWeakRef works for any objects that are derived from wxTrackable. By default, + wxEvtHandler and wxWindow derive from wxTrackable. However, wxObject does not, so + types like wxFont and wxColour are not trackable. The example below shows how to + create a wxObject derived class that is trackable: + + @code + class wxMyTrackableObject : public wxObject, public wxTrackable + { + // ... other members here + }; + @endcode + + The following types of weak references are predefined: + + @code + typedef wxWeakRef wxEvtHandlerRef; + typedef wxWeakRef wxWindowRef; + @endcode + + @library{wxbase} @category{FIXME} -- 2.45.2