]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/itemid.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxItemId class declaration.
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
13 // ----------------------------------------------------------------------------
14 // wxItemId: an opaque item identifier used with wx{Tree,TreeList,DataView}Ctrl.
15 // ----------------------------------------------------------------------------
17 // The template argument T is typically a pointer to some opaque type. While
18 // wxTreeItemId and wxDataViewItem use a pointer to void, this is dangerous and
19 // not recommended for the new item id classes.
26 // This ctor is implicit which is fine for non-void* types, but if you use
27 // this class with void* you're strongly advised to make the derived class
28 // ctor explicit as implicitly converting from any pointer is simply too
30 wxItemId(Type item
= NULL
) : m_pItem(item
) { }
32 // Default copy ctor, assignment operator and dtor are ok.
34 bool IsOk() const { return m_pItem
!= NULL
; }
35 Type
GetID() const { return m_pItem
; }
36 operator const Type() const { return m_pItem
; }
38 // This is used for implementation purposes only.
39 Type
operator->() const { return m_pItem
; }
41 void Unset() { m_pItem
= NULL
; }
43 // This field is public *only* for compatibility with the old wxTreeItemId
44 // implementation and must not be used in any new code.
50 bool operator==(const wxItemId
<T
>& left
, const wxItemId
<T
>& right
)
52 return left
.GetID() == right
.GetID();
56 bool operator!=(const wxItemId
<T
>& left
, const wxItemId
<T
>& right
)
58 return !(left
== right
);
61 #endif // _WX_ITEMID_H_