Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / interface / wx / treebase.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: treebase.h
3 // Purpose: interface of wxTreeItemId
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
7
8 /**
9 @class wxTreeItemId
10
11 An opaque reference to a tree item.
12
13 @library{wxcore}
14 @category{data}
15
16 @see wxTreeCtrl, wxTreeItemData, @ref overview_treectrl
17 */
18 class wxTreeItemId
19 {
20 public:
21 /**
22 Default constructor. A wxTreeItemId is not meant to be constructed
23 explicitly by the user; only those returned by the wxTreeCtrl functions
24 should be used.
25 */
26 wxTreeItemId();
27
28 /**
29 Returns @true if this instance is referencing a valid tree item.
30 */
31 bool IsOk() const;
32
33 void* GetID() const;
34 void Unset();
35 };
36
37 bool operator==(const wxTreeItemId& left, const wxTreeItemId& right);
38 bool operator!=(const wxTreeItemId& left, const wxTreeItemId& right);
39
40
41
42 /**
43 @class wxTreeItemData
44
45 wxTreeItemData is some (arbitrary) user class associated with some item. The
46 main advantage of having this class is that wxTreeItemData objects are
47 destroyed automatically by the tree and, as this class has virtual
48 destructor, it means that the memory and any other resources associated with
49 a tree item will be automatically freed when it is deleted. Note that we
50 don't use wxObject as the base class for wxTreeItemData because the size of
51 this class is critical: in many applications, each tree leaf will have
52 wxTreeItemData associated with it and the number of leaves may be quite big.
53
54 Also please note that because the objects of this class are deleted by the
55 tree using the operator @c delete, they must always be allocated on the heap
56 using @c new.
57
58 @library{wxcore}
59 @category{containers}
60
61 @see wxTreeCtrl
62 */
63 class wxTreeItemData : public wxClientData
64 {
65 public:
66 /**
67 Default constructor.
68
69 @beginWxPerlOnly
70 In wxPerl the constructor accepts a scalar as an optional parameter
71 and stores it as client data; use
72 - GetData() to retrieve the value.
73 - SetData(data) to set it.
74 @endWxPerlOnly
75 */
76 wxTreeItemData();
77
78 /**
79 Virtual destructor.
80 */
81 virtual ~wxTreeItemData();
82
83 /**
84 Returns the item associated with this node.
85 */
86 const wxTreeItemId& GetId() const;
87
88 /**
89 Sets the item associated with this node.
90
91 Notice that this function is automatically called by wxTreeCtrl methods
92 associating an object of this class with a tree control item such as
93 wxTreeCtrl::AppendItem(), wxTreeCtrl::InsertItem() and
94 wxTreeCtrl::SetItemData() so there is usually no need to call it
95 yourself.
96 */
97 void SetId(const wxTreeItemId& id);
98 };
99
100 /**
101 Indicates which type to associate an image with a wxTreeCtrl item.
102
103 @see wxTreeCtrl::GetItemImage(), wxTreeCtrl::SetItemImage()
104 */
105 enum wxTreeItemIcon
106 {
107 /**
108 To get/set the item image for when the item is
109 @b not selected and @b not expanded.
110 */
111 wxTreeItemIcon_Normal,
112 /**
113 To get/set the item image for when the item is
114 @b selected and @b not expanded.
115 */
116 wxTreeItemIcon_Selected,
117 /**
118 To get/set the item image for when the item is
119 @b not selected and @b expanded.
120 */
121 wxTreeItemIcon_Expanded,
122 /**
123 To get/set the item image for when the item is
124 @b selected and @b expanded.
125 */
126 wxTreeItemIcon_SelectedExpanded,
127 wxTreeItemIcon_Max
128 };
129
130
131 /// special values for the 'state' parameter of wxTreeCtrl::SetItemState()
132 static const int wxTREE_ITEMSTATE_NONE = -1; // not state (no display state image)
133 static const int wxTREE_ITEMSTATE_NEXT = -2; // cycle to the next state
134 static const int wxTREE_ITEMSTATE_PREV = -3; // cycle to the previous state
135
136 #define wxTR_NO_BUTTONS 0x0000 // for convenience
137 #define wxTR_HAS_BUTTONS 0x0001 // draw collapsed/expanded btns
138 #define wxTR_NO_LINES 0x0004 // don't draw lines at all
139 #define wxTR_LINES_AT_ROOT 0x0008 // connect top-level nodes
140 #define wxTR_TWIST_BUTTONS 0x0010 // still used by wxTreeListCtrl
141
142 #define wxTR_SINGLE 0x0000 // for convenience
143 #define wxTR_MULTIPLE 0x0020 // can select multiple items
144
145 #define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says
146
147 #define wxTR_EDIT_LABELS 0x0200 // can edit item labels
148 #define wxTR_ROW_LINES 0x0400 // put border around items
149 #define wxTR_HIDE_ROOT 0x0800 // don't display root node
150
151 #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space
152
153 // make the default control appearance look more native-like depending on the
154 // platform
155 #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT)
156
157
158 // values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
159 // where exactly the specified point is situated:
160
161 static const int wxTREE_HITTEST_ABOVE = 0x0001;
162 static const int wxTREE_HITTEST_BELOW = 0x0002;
163 static const int wxTREE_HITTEST_NOWHERE = 0x0004;
164 // on the button associated with an item.
165 static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
166 // on the bitmap associated with an item.
167 static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
168 // on the indent associated with an item.
169 static const int wxTREE_HITTEST_ONITEMINDENT = 0x0020;
170 // on the label (string) associated with an item.
171 static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
172 // on the right of the label associated with an item.
173 static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
174 // on the label (string) associated with an item.
175 static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
176 // on the left of the wxTreeCtrl.
177 static const int wxTREE_HITTEST_TOLEFT = 0x0200;
178 // on the right of the wxTreeCtrl.
179 static const int wxTREE_HITTEST_TORIGHT = 0x0400;
180 // on the upper part (first half) of the item.
181 static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
182 // on the lower part (second half) of the item.
183 static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
184
185 // anywhere on the item
186 static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
187 wxTREE_HITTEST_ONITEMLABEL;
188
189