]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/itemid.h
Update setup for OpenVMS
[wxWidgets.git] / include / wx / itemid.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/itemid.h
3// Purpose: wxItemId class declaration.
4// Author: Vadim Zeitlin
5// Created: 2011-08-17
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///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_ITEMID_H_
12#define _WX_ITEMID_H_
13
14// ----------------------------------------------------------------------------
15// wxItemId: an opaque item identifier used with wx{Tree,TreeList,DataView}Ctrl.
16// ----------------------------------------------------------------------------
17
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.
21template <typename T>
22class wxItemId
23{
24public:
25 typedef T Type;
26
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
30 // dangerous.
31 wxItemId(Type item = NULL) : m_pItem(item) { }
32
33 // Default copy ctor, assignment operator and dtor are ok.
34
35 bool IsOk() const { return m_pItem != NULL; }
36 Type GetID() const { return m_pItem; }
37 operator const Type() const { return m_pItem; }
38
39 void Unset() { m_pItem = NULL; }
40
41 // This field is public *only* for compatibility with the old wxTreeItemId
42 // implementation and must not be used in any new code.
43//private:
44 Type m_pItem;
45};
46
47template <typename T>
48bool operator==(const wxItemId<T>& left, const wxItemId<T>& right)
49{
50 return left.GetID() == right.GetID();
51}
52
53template <typename T>
54bool operator!=(const wxItemId<T>& left, const wxItemId<T>& right)
55{
56 return !(left == right);
57}
58
59#endif // _WX_ITEMID_H_