]> git.saurik.com Git - wxWidgets.git/blobdiff - docs/latex/wx/weakref.tex
add wxXLocale class and wxIsxxx_l() and wxToxxx_l() functions (heavily modified and...
[wxWidgets.git] / docs / latex / wx / weakref.tex
index 35e965c33476d8eea1b04b712d1d27bdd7528b50..ad01dcf198fe12c86adac69ffeb0575699fc2938 100644 (file)
@@ -1,23 +1,22 @@
 \section{\class{wxWeakRef<T>}}\label{wxweakref}
 
-{\bf wxWeakRef} is a template class for weak references to wxWidgets objects, 
-such as {\bf wxEvtHandler}, {\bf wxWindow} and {\bf wxObject}. A weak 
-reference behaves much like an ordinary pointer, but when the object pointed 
-to goes out of scope (is destroyed), the weak reference is automatically 
-reset to a NULL pointer. 
-
-wxWeakref<T> can be used whenever one must keep a pointer to an object 
-that does not directly own, and that may be destroyed before the object 
+wxWeakRef is a template class for weak references to wxWidgets objects, 
+such as \helpref{wxEvtHandler}{wxevthandler}, \helpref{wxWindow}{wxwindow} and 
+\helpref{wxObject}{wxobject}. A weak reference behaves much like an ordinary
+pointer, but when the object pointed is destroyed, the weak reference is
+automatically reset to a NULL pointer. 
+
+wxWeakRef<T> can be used whenever one must keep a pointer to an object 
+that one does not directly own, and that may be destroyed before the object
 holding the reference. 
 
-wxWeakref<T> is a small object and the mechanism behind it is fast 
-({\bf O(1)}). So the overall cost of using it is small. 
+wxWeakRef<T> is a small object and the mechanism behind it is fast 
+(\textbf{O(1)}). So the overall cost of using it is small. 
 
 
 \wxheading{Example}
 
 \begin{verbatim}
-    wxWindow *parent = /* Get parent window from somewhere */;
     wxWindow *wnd = new wxWindow( parent, wxID_ANY, "wxWindow" );
     wxWeakRef<wxWindow> wr = wnd;  
     wxWindowRef wr2 = wnd;        // Same as above, but using a typedef
@@ -31,11 +30,11 @@ wxWeakref<T> is a small object and the mechanism behind it is fast
     wxASSERT( wr==NULL );
 \end{verbatim}
 
-wxWeakref<T> works for any objects that are derived from {\bf wxTrackableBase} 
-or {\bf wxTrackable}. By default, wxEvtHandler and wxWindow derive from 
-wxTrackableBase. However, wxObject does not, so types like {\bf wxFont} and 
-{\bf wxColour} are not trackable. The example below shows how to create a 
-wxObject derived class that is trackable: 
+wxWeakRef<T> works for any objects that are derived from \helpref{wxTrackable}{wxtrackable}.
+By default, wxEvtHandler and wxWindow derive from wxTrackable. However, 
+wxObject does not, so types like \helpref{wxFont}{wxfont} and 
+\helpref{wxColour}{wxcolour} are not trackable. The example below shows how to
+create a wxObject derived class that is trackable: 
 
 \begin{verbatim}
     class wxMyTrackableObject : public wxObject, public wxTrackable { 
@@ -43,19 +42,11 @@ wxObject derived class that is trackable:
     }; 
 \end{verbatim}
 
-{\bf Note:} Custom trackable objects should derive from wxTrackable 
-if one wants to reference them from a {\bf wxWeakRef<wxObject>}. The 
-difference between the two base classes is that wxTrackableBase 
-has no virtual member functions (no VTable), and thus cannot be detected
-through {\bf dynamic_cast<>}.
-
-
 \wxheading{Predefined types}
 
 The following types of weak references are predefined: 
 
 \begin{verbatim}
-typedef wxWeakRef<wxObject>      wxObjectRef;
 typedef wxWeakRef<wxEvtHandler>  wxEvtHandlerRef;
 typedef wxWeakRef<wxWindow>      wxWindowRef;
 \end{verbatim}
@@ -69,8 +60,19 @@ wxTrackerNode
 
 <weakref.h>
 
+\wxheading{See also}
+
+\helpref{wxSharedPtr}{wxsharedptr}, \helpref{wxScopedPtr}{wxscopedptrtemplate}
+
 \wxheading{Data structures}
 
+{\small% 
+\begin{verbatim}
+typedef T element_type
+\end{verbatim}
+}%
+
+
 \latexignore{\rtfignore{\wxheading{Members}}}
 
 
@@ -94,6 +96,12 @@ Destructor.
 
 Returns pointer to the tracked object or NULL.
 
+\membersection{wxWeakRef<T>::operator T*}\label{wxweakrefoperatorconvt}
+
+\constfunc{T*}{operator*}{\void}
+
+Implicit conversion to T*. Returns pointer to the tracked
+object or NULL.
 
 \membersection{wxWeakRef<T>::operator*}\label{wxweakrefoperatorreft}
 
@@ -114,7 +122,7 @@ method will cause an assert in debug mode.
 
 \membersection{wxWeakRef<T>::operator=}\label{wxweakrefoperatorassign}
 
-\func{T* operator}{operator=}{\param{T* }{pobj}}
+\func{T*}{operator=}{\param{T* }{pobj}}
 
 Releases the currently tracked object and starts tracking {\it pobj}.
 A weak reference may be reset by passing {\it NULL} as {\it pobj}.
@@ -122,12 +130,19 @@ A weak reference may be reset by passing {\it NULL} as {\it pobj}.
 
 \membersection{wxWeakRef<T>::operator =}\label{wxweakrefoperatorassign2}
 
-\func{T* operator}{operator =}{\param{wxWeakRef<T>\& }{wr}}
+\func{T*}{operator =}{\param{wxWeakRef<T>\& }{wr}}
 
 Release currently tracked object and start tracking the same object as
 the wxWeakRef {\it wr}.
 
 
+\membersection{wxWeakRef<T>::Release}\label{wxweakrefrelease}
+
+\func{void}{Release}{\void}
+
+Release currently tracked object and rests object reference.
+
+
 \membersection{wxWeakRef<T>::OnObjectDestroy}\label{wxweakrefonobjectdestroy}
 
 \func{virtual void}{OnObjectDestroy}{\void}