]>
Commit | Line | Data |
---|---|---|
e9576ca5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
68204d23 | 2 | // Name: src/mac/carbon/treectrl.cpp |
e9576ca5 | 3 | // Purpose: wxTreeCtrl. See also Robert's generic wxTreeCtrl. |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3d1a4878 SC |
12 | #include "wx/wxprec.h" |
13 | ||
e9576ca5 | 14 | #include "wx/stubs/textctrl.h" |
03e11df5 | 15 | #include "wx/treebase.h" |
e9576ca5 SC |
16 | #include "wx/stubs/treectrl.h" |
17 | ||
68204d23 | 18 | |
e9576ca5 SC |
19 | IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) |
20 | IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject) | |
21 | ||
68204d23 | 22 | |
e9576ca5 SC |
23 | wxTreeCtrl::wxTreeCtrl() |
24 | { | |
25 | m_imageListNormal = NULL; | |
26 | m_imageListState = NULL; | |
27 | m_textCtrl = NULL; | |
28 | } | |
29 | ||
68204d23 DS |
30 | bool wxTreeCtrl::Create(wxWindow *parent, |
31 | wxWindowID id, const wxPoint& pos, const wxSize& size, | |
32 | long style, const wxValidator& validator, const wxString& name) | |
e9576ca5 | 33 | { |
e9576ca5 SC |
34 | m_imageListNormal = NULL; |
35 | m_imageListState = NULL; | |
36 | m_textCtrl = NULL; | |
37 | ||
68204d23 DS |
38 | SetName(name); |
39 | SetValidator(validator); | |
e9576ca5 SC |
40 | SetParent(parent); |
41 | ||
68204d23 DS |
42 | m_windowStyle = style; |
43 | ||
e9576ca5 SC |
44 | m_windowId = (id == -1) ? NewControlId() : id; |
45 | ||
68204d23 DS |
46 | if (parent) |
47 | parent->AddChild(this); | |
e9576ca5 | 48 | |
68204d23 | 49 | // TODO: create tree control |
e9576ca5 | 50 | |
68204d23 | 51 | return false; |
e9576ca5 SC |
52 | } |
53 | ||
54 | wxTreeCtrl::~wxTreeCtrl() | |
55 | { | |
68204d23 | 56 | delete m_textCtrl; |
e9576ca5 SC |
57 | } |
58 | ||
59 | // Attributes | |
60 | int wxTreeCtrl::GetCount() const | |
61 | { | |
62 | // TODO | |
63 | return 0; | |
64 | } | |
65 | ||
66 | int wxTreeCtrl::GetIndent() const | |
67 | { | |
68 | // TODO | |
69 | return 0; | |
70 | } | |
71 | ||
72 | void wxTreeCtrl::SetIndent(int indent) | |
73 | { | |
74 | // TODO | |
75 | } | |
76 | ||
77 | wxImageList *wxTreeCtrl::GetImageList(int which) const | |
78 | { | |
e40298d5 | 79 | if ( which == wxIMAGE_LIST_NORMAL ) |
e40298d5 | 80 | return m_imageListNormal; |
e40298d5 | 81 | else if ( which == wxIMAGE_LIST_STATE ) |
e40298d5 | 82 | return m_imageListState; |
68204d23 | 83 | |
e40298d5 | 84 | return NULL; |
e9576ca5 SC |
85 | } |
86 | ||
87 | void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) | |
88 | { | |
89 | if ( which == wxIMAGE_LIST_NORMAL ) | |
e9576ca5 | 90 | m_imageListNormal = imageList; |
e9576ca5 | 91 | else if ( which == wxIMAGE_LIST_STATE ) |
e9576ca5 | 92 | m_imageListState = imageList; |
68204d23 | 93 | |
e9576ca5 SC |
94 | // TODO |
95 | } | |
96 | ||
97 | long wxTreeCtrl::GetNextItem(long item, int code) const | |
98 | { | |
99 | // TODO | |
100 | return 0; | |
101 | } | |
102 | ||
103 | bool wxTreeCtrl::ItemHasChildren(long item) const | |
104 | { | |
105 | // TODO | |
68204d23 | 106 | return false; |
e9576ca5 SC |
107 | } |
108 | ||
109 | long wxTreeCtrl::GetChild(long item) const | |
110 | { | |
111 | // TODO | |
112 | return 0; | |
113 | } | |
114 | ||
99006e44 | 115 | long wxTreeCtrl::GetItemParent(long item) const |
e9576ca5 SC |
116 | { |
117 | // TODO | |
118 | return 0; | |
119 | } | |
120 | ||
121 | long wxTreeCtrl::GetFirstVisibleItem() const | |
122 | { | |
123 | // TODO | |
124 | return 0; | |
125 | } | |
126 | ||
127 | long wxTreeCtrl::GetNextVisibleItem(long item) const | |
128 | { | |
129 | // TODO | |
130 | return 0; | |
131 | } | |
132 | ||
133 | long wxTreeCtrl::GetSelection() const | |
134 | { | |
135 | // TODO | |
136 | return 0; | |
137 | } | |
138 | ||
139 | long wxTreeCtrl::GetRootItem() const | |
140 | { | |
141 | // TODO | |
142 | return 0; | |
143 | } | |
144 | ||
145 | bool wxTreeCtrl::GetItem(wxTreeItem& info) const | |
146 | { | |
147 | // TODO | |
68204d23 | 148 | return false; |
e9576ca5 SC |
149 | } |
150 | ||
151 | bool wxTreeCtrl::SetItem(wxTreeItem& info) | |
152 | { | |
153 | // TODO | |
68204d23 | 154 | return false; |
e9576ca5 SC |
155 | } |
156 | ||
157 | int wxTreeCtrl::GetItemState(long item, long stateMask) const | |
158 | { | |
159 | wxTreeItem info; | |
160 | ||
68204d23 | 161 | info.m_mask = wxTREE_MASK_STATE; |
e9576ca5 SC |
162 | info.m_stateMask = stateMask; |
163 | info.m_itemId = item; | |
164 | ||
165 | if (!GetItem(info)) | |
166 | return 0; | |
167 | ||
168 | return info.m_state; | |
169 | } | |
170 | ||
171 | bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) | |
172 | { | |
173 | wxTreeItem info; | |
174 | ||
68204d23 | 175 | info.m_mask = wxTREE_MASK_STATE; |
e9576ca5 SC |
176 | info.m_state = state; |
177 | info.m_stateMask = stateMask; | |
178 | info.m_itemId = item; | |
179 | ||
180 | return SetItem(info); | |
181 | } | |
182 | ||
183 | bool wxTreeCtrl::SetItemImage(long item, int image, int selImage) | |
184 | { | |
185 | wxTreeItem info; | |
186 | ||
68204d23 | 187 | info.m_mask = wxTREE_MASK_IMAGE; |
e9576ca5 SC |
188 | info.m_image = image; |
189 | if ( selImage > -1) | |
190 | { | |
191 | info.m_selectedImage = selImage; | |
192 | info.m_mask |= wxTREE_MASK_SELECTED_IMAGE; | |
193 | } | |
68204d23 | 194 | |
e9576ca5 SC |
195 | info.m_itemId = item; |
196 | ||
197 | return SetItem(info); | |
198 | } | |
199 | ||
200 | wxString wxTreeCtrl::GetItemText(long item) const | |
201 | { | |
202 | wxTreeItem info; | |
203 | ||
68204d23 | 204 | info.m_mask = wxTREE_MASK_TEXT; |
e9576ca5 SC |
205 | info.m_itemId = item; |
206 | ||
207 | if (!GetItem(info)) | |
68204d23 DS |
208 | return wxEmptyString; |
209 | ||
e9576ca5 SC |
210 | return info.m_text; |
211 | } | |
212 | ||
213 | void wxTreeCtrl::SetItemText(long item, const wxString& str) | |
214 | { | |
215 | wxTreeItem info; | |
216 | ||
68204d23 | 217 | info.m_mask = wxTREE_MASK_TEXT; |
e9576ca5 SC |
218 | info.m_itemId = item; |
219 | info.m_text = str; | |
220 | ||
221 | SetItem(info); | |
222 | } | |
223 | ||
224 | long wxTreeCtrl::GetItemData(long item) const | |
225 | { | |
226 | wxTreeItem info; | |
227 | ||
68204d23 | 228 | info.m_mask = wxTREE_MASK_DATA; |
e9576ca5 SC |
229 | info.m_itemId = item; |
230 | ||
231 | if (!GetItem(info)) | |
232 | return 0; | |
68204d23 | 233 | |
e9576ca5 SC |
234 | return info.m_data; |
235 | } | |
236 | ||
237 | bool wxTreeCtrl::SetItemData(long item, long data) | |
238 | { | |
239 | wxTreeItem info; | |
240 | ||
68204d23 | 241 | info.m_mask = wxTREE_MASK_DATA; |
e9576ca5 SC |
242 | info.m_itemId = item; |
243 | info.m_data = data; | |
244 | ||
245 | return SetItem(info); | |
246 | } | |
247 | ||
248 | bool wxTreeCtrl::GetItemRect(long item, wxRect& rect, bool textOnly) const | |
249 | { | |
250 | // TODO | |
68204d23 | 251 | return false; |
e9576ca5 SC |
252 | } |
253 | ||
68204d23 | 254 | wxTextCtrl * wxTreeCtrl::GetEditControl() const |
e9576ca5 SC |
255 | { |
256 | return m_textCtrl; | |
257 | } | |
258 | ||
259 | // Operations | |
260 | bool wxTreeCtrl::DeleteItem(long item) | |
261 | { | |
262 | // TODO | |
68204d23 | 263 | return false; |
e9576ca5 SC |
264 | } |
265 | ||
266 | bool wxTreeCtrl::ExpandItem(long item, int action) | |
267 | { | |
268 | // TODO | |
e40298d5 JS |
269 | switch ( action ) |
270 | { | |
e9576ca5 | 271 | case wxTREE_EXPAND_EXPAND: |
e40298d5 | 272 | break; |
68204d23 | 273 | |
e9576ca5 | 274 | case wxTREE_EXPAND_COLLAPSE: |
e40298d5 | 275 | break; |
68204d23 | 276 | |
e9576ca5 | 277 | case wxTREE_EXPAND_COLLAPSE_RESET: |
e40298d5 | 278 | break; |
68204d23 | 279 | |
e9576ca5 | 280 | case wxTREE_EXPAND_TOGGLE: |
e40298d5 | 281 | break; |
68204d23 | 282 | |
e9576ca5 | 283 | default: |
68204d23 | 284 | wxFAIL_MSG(wxT("unknown action in wxTreeCtrl::ExpandItem"); |
e40298d5 | 285 | } |
68204d23 DS |
286 | |
287 | // TODO: expand item | |
288 | bool bOk = false; | |
289 | ||
e40298d5 | 290 | // May not send messages, so emulate them |
68204d23 DS |
291 | if ( bOk ) |
292 | { | |
e40298d5 | 293 | wxTreeEvent event(wxEVT_NULL, m_windowId); |
68204d23 DS |
294 | event.m_item.m_itemId = item; |
295 | event.m_item.m_mask = event.m_item.m_stateMask = 0xFFFF; // get all | |
e40298d5 | 296 | GetItem(event.m_item); |
68204d23 | 297 | |
e40298d5 | 298 | bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; |
68204d23 | 299 | |
e40298d5 JS |
300 | event.m_code = action; |
301 | event.SetEventObject(this); | |
68204d23 | 302 | |
e40298d5 | 303 | // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded |
68204d23 DS |
304 | event.SetEventType( |
305 | bIsExpanded | |
306 | ? wxEVT_COMMAND_TREE_ITEM_EXPANDING | |
e40298d5 JS |
307 | : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); |
308 | GetEventHandler()->ProcessEvent(event); | |
68204d23 DS |
309 | |
310 | event.SetEventType( | |
311 | bIsExpanded | |
312 | ? wxEVT_COMMAND_TREE_ITEM_EXPANDED | |
e40298d5 JS |
313 | : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); |
314 | GetEventHandler()->ProcessEvent(event); | |
315 | } | |
68204d23 | 316 | |
e40298d5 | 317 | return bOk; |
e9576ca5 SC |
318 | } |
319 | ||
320 | long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) | |
321 | { | |
322 | // TODO | |
323 | return 0; | |
324 | } | |
325 | ||
68204d23 DS |
326 | long wxTreeCtrl::InsertItem(long parent, const wxString& label, |
327 | int image, int selImage, long insertAfter) | |
e9576ca5 SC |
328 | { |
329 | wxTreeItem info; | |
330 | info.m_text = label; | |
331 | info.m_mask = wxTREE_MASK_TEXT; | |
332 | if ( image > -1 ) | |
333 | { | |
334 | info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE; | |
335 | info.m_image = image; | |
336 | if ( selImage == -1 ) | |
337 | info.m_selectedImage = image; | |
338 | else | |
339 | info.m_selectedImage = selImage; | |
340 | } | |
341 | ||
342 | return InsertItem(parent, info, insertAfter); | |
343 | } | |
344 | ||
345 | bool wxTreeCtrl::SelectItem(long item) | |
346 | { | |
347 | // TODO | |
68204d23 | 348 | return false; |
e9576ca5 SC |
349 | } |
350 | ||
351 | bool wxTreeCtrl::ScrollTo(long item) | |
352 | { | |
353 | // TODO | |
68204d23 | 354 | return false; |
e9576ca5 SC |
355 | } |
356 | ||
357 | bool wxTreeCtrl::DeleteAllItems() | |
358 | { | |
359 | // TODO | |
68204d23 | 360 | return false; |
e9576ca5 SC |
361 | } |
362 | ||
68204d23 | 363 | wxTextCtrl * wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) |
e9576ca5 SC |
364 | { |
365 | // TODO | |
366 | return NULL; | |
367 | } | |
368 | ||
369 | // End label editing, optionally cancelling the edit | |
370 | bool wxTreeCtrl::EndEditLabel(bool cancel) | |
371 | { | |
372 | // TODO | |
68204d23 | 373 | return false; |
e9576ca5 SC |
374 | } |
375 | ||
376 | long wxTreeCtrl::HitTest(const wxPoint& point, int& flags) | |
377 | { | |
378 | // TODO | |
379 | return 0; | |
380 | } | |
381 | ||
382 | bool wxTreeCtrl::SortChildren(long item) | |
383 | { | |
384 | // TODO | |
68204d23 | 385 | return false; |
e9576ca5 SC |
386 | } |
387 | ||
388 | bool wxTreeCtrl::EnsureVisible(long item) | |
389 | { | |
390 | // TODO | |
68204d23 | 391 | return false; |
e9576ca5 SC |
392 | } |
393 | ||
394 | // Tree item structure | |
395 | wxTreeItem::wxTreeItem() | |
396 | { | |
397 | m_mask = 0; | |
398 | m_itemId = 0; | |
399 | m_state = 0; | |
400 | m_stateMask = 0; | |
401 | m_image = -1; | |
402 | m_selectedImage = -1; | |
403 | m_children = 0; | |
404 | m_data = 0; | |
405 | } | |
406 | ||
407 | // Tree event | |
408 | IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) | |
409 | ||
68204d23 DS |
410 | wxTreeEvent::wxTreeEvent(wxEventType commandType, int id) |
411 | : wxCommandEvent(commandType, id) | |
e9576ca5 SC |
412 | { |
413 | m_code = 0; | |
414 | m_oldItem = 0; | |
415 | } | |
416 |