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