]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/itemid.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxItemId class declaration.
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
14 // ----------------------------------------------------------------------------
15 // wxItemId: an opaque item identifier used with wx{Tree,TreeList,DataView}Ctrl.
16 // ----------------------------------------------------------------------------
18 // The template argument T is typically a pointer to some opaque type. While
19 // wxTreeItemId and wxDataViewItem use a pointer to void, this is dangerous and
20 // not recommended for the new item id classes.
27 // This ctor is implicit which is fine for non-void* types, but if you use
28 // this class with void* you're strongly advised to make the derived class
29 // ctor explicit as implicitly converting from any pointer is simply too
31 wxItemId(Type item
= NULL
) : m_pItem(item
) { }
33 // Default copy ctor, assignment operator and dtor are ok.
35 bool IsOk() const { return m_pItem
!= NULL
; }
36 Type
GetID() const { return m_pItem
; }
37 operator const Type() const { return m_pItem
; }
39 // This is used for implementation purposes only.
40 Type
operator->() const { return m_pItem
; }
42 void Unset() { m_pItem
= NULL
; }
44 // This field is public *only* for compatibility with the old wxTreeItemId
45 // implementation and must not be used in any new code.
51 bool operator==(const wxItemId
<T
>& left
, const wxItemId
<T
>& right
)
53 return left
.GetID() == right
.GetID();
57 bool operator!=(const wxItemId
<T
>& left
, const wxItemId
<T
>& right
)
59 return !(left
== right
);
62 #endif // _WX_ITEMID_H_