]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/windowptr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/windowptr.h
3 // Purpose: smart pointer for holding wxWindow instances
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2013 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_WINDOWPTR_H_
11 #define _WX_WINDOWPTR_H_
13 #include "wx/sharedptr.h"
15 // ----------------------------------------------------------------------------
16 // wxWindowPtr: A smart pointer with correct wxWindow destruction.
17 // ----------------------------------------------------------------------------
22 struct wxWindowDeleter
24 void operator()(wxWindow
*win
)
30 } // namespace wxPrivate
33 class wxWindowPtr
: public wxSharedPtr
<T
>
36 typedef T element_type
;
38 wxEXPLICIT
wxWindowPtr(element_type
* win
)
39 : wxSharedPtr
<T
>(win
, wxPrivate::wxWindowDeleter())
44 wxWindowPtr(const wxWindowPtr
& tocopy
) : wxSharedPtr
<T
>(tocopy
) {}
46 wxWindowPtr
& operator=(const wxWindowPtr
& tocopy
)
48 wxSharedPtr
<T
>::operator=(tocopy
);
52 wxWindowPtr
& operator=(element_type
* win
)
54 return operator=(wxWindowPtr(win
));
57 void reset(T
* ptr
= NULL
)
59 wxSharedPtr
<T
>::reset(ptr
, wxPrivate::wxWindowDeleter());
63 #endif // _WX_WINDOWPTR_H_