]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/palmos/treectrl.cpp | |
3 | // Purpose: wxTreeCtrl | |
4 | // Author: William Osborne - minimal working wxPalmOS port | |
5 | // Modified by: | |
6 | // Created: 10/13/04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) William Osborne | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #if wxUSE_TREECTRL | |
28 | ||
29 | #include "wx/treectrl.h" | |
30 | ||
31 | #ifndef WX_PRECOMP | |
32 | #include "wx/dynarray.h" | |
33 | #include "wx/log.h" | |
34 | #include "wx/app.h" | |
35 | #include "wx/settings.h" | |
36 | #endif | |
37 | ||
38 | #include "wx/palmos/private.h" | |
39 | ||
40 | #include "wx/imaglist.h" | |
41 | ||
42 | // macros to hide the cast ugliness | |
43 | // -------------------------------- | |
44 | ||
45 | // ptr is the real item id, i.e. wxTreeItemId::m_pItem | |
46 | #define HITEM_PTR(ptr) (HTREEITEM)(ptr) | |
47 | ||
48 | // item here is a wxTreeItemId | |
49 | #define HITEM(item) HITEM_PTR((item).m_pItem) | |
50 | ||
51 | // the native control doesn't support multiple selections under MSW and we | |
52 | // have 2 ways to emulate them: either using TVS_CHECKBOXES style and let | |
53 | // checkboxes be the selection status (checked == selected) or by really | |
54 | // emulating everything, i.e. intercepting mouse and key events &c. The first | |
55 | // approach is much easier but doesn't work with comctl32.dll < 4.71 and also | |
56 | // looks quite ugly. | |
57 | #define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0 | |
58 | ||
59 | // ---------------------------------------------------------------------------- | |
60 | // private functions | |
61 | // ---------------------------------------------------------------------------- | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // private classes | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | // ---------------------------------------------------------------------------- | |
68 | // wxWin macros | |
69 | // ---------------------------------------------------------------------------- | |
70 | ||
71 | #if wxUSE_EXTENDED_RTTI | |
72 | WX_DEFINE_FLAGS( wxTreeCtrlStyle ) | |
73 | ||
74 | wxBEGIN_FLAGS( wxTreeCtrlStyle ) | |
75 | // new style border flags, we put them first to | |
76 | // use them for streaming out | |
77 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) | |
78 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
79 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
80 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
81 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
82 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
83 | ||
84 | // old style border flags | |
85 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) | |
86 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
87 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
88 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
89 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
90 | wxFLAGS_MEMBER(wxBORDER) | |
91 | ||
92 | // standard window styles | |
93 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) | |
94 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
95 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
96 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
97 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) | |
98 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
99 | wxFLAGS_MEMBER(wxVSCROLL) | |
100 | wxFLAGS_MEMBER(wxHSCROLL) | |
101 | ||
102 | wxFLAGS_MEMBER(wxTR_EDIT_LABELS) | |
103 | wxFLAGS_MEMBER(wxTR_NO_BUTTONS) | |
104 | wxFLAGS_MEMBER(wxTR_HAS_BUTTONS) | |
105 | wxFLAGS_MEMBER(wxTR_TWIST_BUTTONS) | |
106 | wxFLAGS_MEMBER(wxTR_NO_LINES) | |
107 | wxFLAGS_MEMBER(wxTR_FULL_ROW_HIGHLIGHT) | |
108 | wxFLAGS_MEMBER(wxTR_LINES_AT_ROOT) | |
109 | wxFLAGS_MEMBER(wxTR_HIDE_ROOT) | |
110 | wxFLAGS_MEMBER(wxTR_ROW_LINES) | |
111 | wxFLAGS_MEMBER(wxTR_HAS_VARIABLE_ROW_HEIGHT) | |
112 | wxFLAGS_MEMBER(wxTR_SINGLE) | |
113 | wxFLAGS_MEMBER(wxTR_MULTIPLE) | |
114 | wxFLAGS_MEMBER(wxTR_EXTENDED) | |
115 | wxFLAGS_MEMBER(wxTR_DEFAULT_STYLE) | |
116 | ||
117 | wxEND_FLAGS( wxTreeCtrlStyle ) | |
118 | ||
119 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxTreeCtrl, wxControl,"wx/treectrl.h") | |
120 | ||
121 | wxBEGIN_PROPERTIES_TABLE(wxTreeCtrl) | |
122 | wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) | |
123 | wxEVENT_RANGE_PROPERTY( TreeEvent , wxEVT_COMMAND_TREE_BEGIN_DRAG , wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK , wxTreeEvent ) | |
124 | wxPROPERTY_FLAGS( WindowStyle , wxTreeCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style | |
125 | wxEND_PROPERTIES_TABLE() | |
126 | ||
127 | wxBEGIN_HANDLERS_TABLE(wxTreeCtrl) | |
128 | wxEND_HANDLERS_TABLE() | |
129 | ||
130 | wxCONSTRUCTOR_5( wxTreeCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) | |
131 | #else | |
132 | IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) | |
133 | #endif | |
134 | ||
135 | // ---------------------------------------------------------------------------- | |
136 | // constants | |
137 | // ---------------------------------------------------------------------------- | |
138 | ||
139 | // indices in gs_expandEvents table below | |
140 | enum | |
141 | { | |
142 | IDX_COLLAPSE, | |
143 | IDX_EXPAND, | |
144 | IDX_WHAT_MAX | |
145 | }; | |
146 | ||
147 | enum | |
148 | { | |
149 | IDX_DONE, | |
150 | IDX_DOING, | |
151 | IDX_HOW_MAX | |
152 | }; | |
153 | ||
154 | // handy table for sending events - it has to be initialized during run-time | |
155 | // now so can't be const any more | |
156 | static /* const */ wxEventType gs_expandEvents[IDX_WHAT_MAX][IDX_HOW_MAX]; | |
157 | ||
158 | /* | |
159 | but logically it's a const table with the following entries: | |
160 | = | |
161 | { | |
162 | { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxEVT_COMMAND_TREE_ITEM_COLLAPSING }, | |
163 | { wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxEVT_COMMAND_TREE_ITEM_EXPANDING } | |
164 | }; | |
165 | */ | |
166 | ||
167 | // ============================================================================ | |
168 | // implementation | |
169 | // ============================================================================ | |
170 | ||
171 | // ---------------------------------------------------------------------------- | |
172 | // construction and destruction | |
173 | // ---------------------------------------------------------------------------- | |
174 | ||
175 | void wxTreeCtrl::Init() | |
176 | { | |
177 | } | |
178 | ||
179 | bool wxTreeCtrl::Create(wxWindow *parent, | |
180 | wxWindowID id, | |
181 | const wxPoint& pos, | |
182 | const wxSize& size, | |
183 | long style, | |
184 | const wxValidator& validator, | |
185 | const wxString& name) | |
186 | { | |
187 | return false; | |
188 | } | |
189 | ||
190 | wxTreeCtrl::~wxTreeCtrl() | |
191 | { | |
192 | } | |
193 | ||
194 | // ---------------------------------------------------------------------------- | |
195 | // accessors | |
196 | // ---------------------------------------------------------------------------- | |
197 | ||
198 | /* static */ wxVisualAttributes | |
199 | wxTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant) | |
200 | { | |
201 | wxVisualAttributes attrs; | |
202 | ||
203 | return attrs; | |
204 | } | |
205 | ||
206 | ||
207 | // simple wrappers which add error checking in debug mode | |
208 | ||
209 | bool wxTreeCtrl::DoGetItem(wxTreeViewItem* tvItem) const | |
210 | { | |
211 | return false; | |
212 | } | |
213 | ||
214 | void wxTreeCtrl::DoSetItem(wxTreeViewItem* tvItem) | |
215 | { | |
216 | } | |
217 | ||
218 | unsigned int wxTreeCtrl::GetCount() const | |
219 | { | |
220 | // TODO | |
221 | return 0; | |
222 | } | |
223 | ||
224 | unsigned int wxTreeCtrl::GetIndent() const | |
225 | { | |
226 | return 0; | |
227 | } | |
228 | ||
229 | void wxTreeCtrl::SetIndent(unsigned int indent) | |
230 | { | |
231 | } | |
232 | ||
233 | wxImageList *wxTreeCtrl::GetImageList() const | |
234 | { | |
235 | return m_imageListNormal; | |
236 | } | |
237 | ||
238 | wxImageList *wxTreeCtrl::GetStateImageList() const | |
239 | { | |
240 | return m_imageListState; | |
241 | } | |
242 | ||
243 | void wxTreeCtrl::SetAnyImageList(wxImageList *imageList, int which) | |
244 | { | |
245 | } | |
246 | ||
247 | void wxTreeCtrl::SetImageList(wxImageList *imageList) | |
248 | { | |
249 | } | |
250 | ||
251 | void wxTreeCtrl::SetStateImageList(wxImageList *imageList) | |
252 | { | |
253 | } | |
254 | ||
255 | void wxTreeCtrl::AssignImageList(wxImageList *imageList) | |
256 | { | |
257 | } | |
258 | ||
259 | void wxTreeCtrl::AssignStateImageList(wxImageList *imageList) | |
260 | { | |
261 | } | |
262 | ||
263 | size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, | |
264 | bool recursively) const | |
265 | { | |
266 | return 0; | |
267 | } | |
268 | ||
269 | // ---------------------------------------------------------------------------- | |
270 | // control colours | |
271 | // ---------------------------------------------------------------------------- | |
272 | ||
273 | bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour) | |
274 | { | |
275 | return false; | |
276 | } | |
277 | ||
278 | bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) | |
279 | { | |
280 | return false; | |
281 | } | |
282 | ||
283 | // ---------------------------------------------------------------------------- | |
284 | // Item access | |
285 | // ---------------------------------------------------------------------------- | |
286 | ||
287 | wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const | |
288 | { | |
289 | return wxString; | |
290 | } | |
291 | ||
292 | void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) | |
293 | { | |
294 | } | |
295 | ||
296 | int wxTreeCtrl::DoGetItemImageFromData(const wxTreeItemId& item, | |
297 | wxTreeItemIcon which) const | |
298 | { | |
299 | return -1; | |
300 | } | |
301 | ||
302 | void wxTreeCtrl::DoSetItemImageFromData(const wxTreeItemId& item, | |
303 | int image, | |
304 | wxTreeItemIcon which) const | |
305 | { | |
306 | } | |
307 | ||
308 | void wxTreeCtrl::DoSetItemImages(const wxTreeItemId& item, | |
309 | int image, | |
310 | int imageSel) | |
311 | { | |
312 | } | |
313 | ||
314 | int wxTreeCtrl::GetItemImage(const wxTreeItemId& item, | |
315 | wxTreeItemIcon which) const | |
316 | { | |
317 | return -1; | |
318 | } | |
319 | ||
320 | void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image, | |
321 | wxTreeItemIcon which) | |
322 | { | |
323 | } | |
324 | ||
325 | wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const | |
326 | { | |
327 | return NULL; | |
328 | } | |
329 | ||
330 | void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) | |
331 | { | |
332 | } | |
333 | ||
334 | void wxTreeCtrl::SetIndirectItemData(const wxTreeItemId& item, | |
335 | wxTreeItemIndirectData *data) | |
336 | { | |
337 | } | |
338 | ||
339 | bool wxTreeCtrl::HasIndirectData(const wxTreeItemId& item) const | |
340 | { | |
341 | return false; | |
342 | } | |
343 | ||
344 | void wxTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has) | |
345 | { | |
346 | } | |
347 | ||
348 | void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold) | |
349 | { | |
350 | } | |
351 | ||
352 | void wxTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item, bool highlight) | |
353 | { | |
354 | } | |
355 | ||
356 | void wxTreeCtrl::RefreshItem(const wxTreeItemId& item) | |
357 | { | |
358 | } | |
359 | ||
360 | wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const | |
361 | { | |
362 | return wxNullColour; | |
363 | } | |
364 | ||
365 | wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const | |
366 | { | |
367 | return wxNullColour; | |
368 | } | |
369 | ||
370 | wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const | |
371 | { | |
372 | return wxNullFont; | |
373 | } | |
374 | ||
375 | void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item, | |
376 | const wxColour& col) | |
377 | { | |
378 | } | |
379 | ||
380 | void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item, | |
381 | const wxColour& col) | |
382 | { | |
383 | } | |
384 | ||
385 | void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) | |
386 | { | |
387 | } | |
388 | ||
389 | // ---------------------------------------------------------------------------- | |
390 | // Item status | |
391 | // ---------------------------------------------------------------------------- | |
392 | ||
393 | bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const | |
394 | { | |
395 | return false; | |
396 | } | |
397 | ||
398 | bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const | |
399 | { | |
400 | return false; | |
401 | } | |
402 | ||
403 | bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const | |
404 | { | |
405 | return false; | |
406 | } | |
407 | ||
408 | bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const | |
409 | { | |
410 | return false; | |
411 | } | |
412 | ||
413 | bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const | |
414 | { | |
415 | return false; | |
416 | } | |
417 | ||
418 | // ---------------------------------------------------------------------------- | |
419 | // navigation | |
420 | // ---------------------------------------------------------------------------- | |
421 | ||
422 | wxTreeItemId wxTreeCtrl::GetRootItem() const | |
423 | { | |
424 | // Root may be real (visible) or virtual (hidden). | |
425 | if ( GET_VIRTUAL_ROOT() ) | |
426 | return TVI_ROOT; | |
427 | ||
428 | return wxTreeItemId(TreeView_GetRoot(GetHwnd())); | |
429 | } | |
430 | ||
431 | wxTreeItemId wxTreeCtrl::GetSelection() const | |
432 | { | |
433 | return 0; | |
434 | } | |
435 | ||
436 | wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const | |
437 | { | |
438 | return 0; | |
439 | } | |
440 | ||
441 | wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, | |
442 | wxTreeItemIdValue& cookie) const | |
443 | { | |
444 | return 0; | |
445 | } | |
446 | ||
447 | wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item), | |
448 | wxTreeItemIdValue& cookie) const | |
449 | { | |
450 | return 0; | |
451 | } | |
452 | ||
453 | wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const | |
454 | { | |
455 | return 0; | |
456 | } | |
457 | ||
458 | wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const | |
459 | { | |
460 | return 0; | |
461 | } | |
462 | ||
463 | wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const | |
464 | { | |
465 | return 0; | |
466 | } | |
467 | ||
468 | wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const | |
469 | { | |
470 | return 0; | |
471 | } | |
472 | ||
473 | wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const | |
474 | { | |
475 | return 0; | |
476 | } | |
477 | ||
478 | wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const | |
479 | { | |
480 | return 0; | |
481 | } | |
482 | ||
483 | // ---------------------------------------------------------------------------- | |
484 | // multiple selections emulation | |
485 | // ---------------------------------------------------------------------------- | |
486 | ||
487 | bool wxTreeCtrl::IsItemChecked(const wxTreeItemId& item) const | |
488 | { | |
489 | return false; | |
490 | } | |
491 | ||
492 | void wxTreeCtrl::SetItemCheck(const wxTreeItemId& item, bool check) | |
493 | { | |
494 | } | |
495 | ||
496 | size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const | |
497 | { | |
498 | return 0; | |
499 | } | |
500 | ||
501 | // ---------------------------------------------------------------------------- | |
502 | // Usual operations | |
503 | // ---------------------------------------------------------------------------- | |
504 | ||
505 | wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent, | |
506 | wxTreeItemId hInsertAfter, | |
507 | const wxString& text, | |
508 | int image, int selectedImage, | |
509 | wxTreeItemData *data) | |
510 | { | |
511 | return 0; | |
512 | } | |
513 | ||
514 | wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, | |
515 | int image, int selectedImage, | |
516 | wxTreeItemData *data) | |
517 | { | |
518 | return 0; | |
519 | } | |
520 | ||
521 | wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent, | |
522 | const wxString& text, | |
523 | int image, int selectedImage, | |
524 | wxTreeItemData *data) | |
525 | { | |
526 | return 0; | |
527 | } | |
528 | ||
529 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, | |
530 | const wxTreeItemId& idPrevious, | |
531 | const wxString& text, | |
532 | int image, int selectedImage, | |
533 | wxTreeItemData *data) | |
534 | { | |
535 | return 0; | |
536 | } | |
537 | ||
538 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, | |
539 | size_t index, | |
540 | const wxString& text, | |
541 | int image, int selectedImage, | |
542 | wxTreeItemData *data) | |
543 | { | |
544 | return 0; | |
545 | } | |
546 | ||
547 | wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, | |
548 | const wxString& text, | |
549 | int image, int selectedImage, | |
550 | wxTreeItemData *data) | |
551 | { | |
552 | return 0; | |
553 | } | |
554 | ||
555 | void wxTreeCtrl::Delete(const wxTreeItemId& item) | |
556 | { | |
557 | return 0; | |
558 | } | |
559 | ||
560 | // delete all children (but don't delete the item itself) | |
561 | void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item) | |
562 | { | |
563 | } | |
564 | ||
565 | void wxTreeCtrl::DeleteAllItems() | |
566 | { | |
567 | } | |
568 | ||
569 | void wxTreeCtrl::DoExpand(const wxTreeItemId& item, int flag) | |
570 | { | |
571 | } | |
572 | ||
573 | void wxTreeCtrl::Expand(const wxTreeItemId& item) | |
574 | { | |
575 | } | |
576 | ||
577 | void wxTreeCtrl::Collapse(const wxTreeItemId& item) | |
578 | { | |
579 | } | |
580 | ||
581 | void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) | |
582 | { | |
583 | } | |
584 | ||
585 | void wxTreeCtrl::Toggle(const wxTreeItemId& item) | |
586 | { | |
587 | } | |
588 | ||
589 | void wxTreeCtrl::Unselect() | |
590 | { | |
591 | } | |
592 | ||
593 | void wxTreeCtrl::UnselectAll() | |
594 | { | |
595 | } | |
596 | ||
597 | void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select) | |
598 | { | |
599 | } | |
600 | ||
601 | void wxTreeCtrl::UnselectItem(const wxTreeItemId& item) | |
602 | { | |
603 | } | |
604 | ||
605 | void wxTreeCtrl::ToggleItemSelection(const wxTreeItemId& item) | |
606 | { | |
607 | } | |
608 | ||
609 | void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item) | |
610 | { | |
611 | } | |
612 | ||
613 | void wxTreeCtrl::ScrollTo(const wxTreeItemId& item) | |
614 | { | |
615 | } | |
616 | ||
617 | wxTextCtrl *wxTreeCtrl::GetEditControl() const | |
618 | { | |
619 | return NULL; | |
620 | } | |
621 | ||
622 | void wxTreeCtrl::DeleteTextCtrl() | |
623 | { | |
624 | } | |
625 | ||
626 | wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, | |
627 | wxClassInfo* textControlClass) | |
628 | { | |
629 | return NULL; | |
630 | } | |
631 | ||
632 | // End label editing, optionally cancelling the edit | |
633 | void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges) | |
634 | { | |
635 | } | |
636 | ||
637 | wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags) | |
638 | { | |
639 | return 0; | |
640 | } | |
641 | ||
642 | bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item, | |
643 | wxRect& rect, | |
644 | bool textOnly) const | |
645 | { | |
646 | return false; | |
647 | } | |
648 | ||
649 | // ---------------------------------------------------------------------------- | |
650 | // sorting stuff | |
651 | // ---------------------------------------------------------------------------- | |
652 | ||
653 | // this is just a tiny namespace which is friend to wxTreeCtrl and so can use | |
654 | // functions such as IsDataIndirect() | |
655 | class wxTreeSortHelper | |
656 | { | |
657 | public: | |
658 | static int CALLBACK Compare(LPARAM data1, LPARAM data2, LPARAM tree); | |
659 | ||
660 | private: | |
661 | static wxTreeItemId GetIdFromData(wxTreeCtrl *tree, LPARAM item) | |
662 | { | |
663 | wxTreeItemData *data = (wxTreeItemData *)item; | |
664 | if ( tree->IsDataIndirect(data) ) | |
665 | { | |
666 | data = ((wxTreeItemIndirectData *)data)->GetData(); | |
667 | } | |
668 | ||
669 | return data->GetId(); | |
670 | } | |
671 | }; | |
672 | ||
673 | int CALLBACK wxTreeSortHelper::Compare(LPARAM pItem1, | |
674 | LPARAM pItem2, | |
675 | LPARAM htree) | |
676 | { | |
677 | wxCHECK_MSG( pItem1 && pItem2, 0, | |
678 | wxT("sorting tree without data doesn't make sense") ); | |
679 | ||
680 | wxTreeCtrl *tree = (wxTreeCtrl *)htree; | |
681 | ||
682 | return tree->OnCompareItems(GetIdFromData(tree, pItem1), | |
683 | GetIdFromData(tree, pItem2)); | |
684 | } | |
685 | ||
686 | int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1, | |
687 | const wxTreeItemId& item2) | |
688 | { | |
689 | return wxStrcmp(GetItemText(item1), GetItemText(item2)); | |
690 | } | |
691 | ||
692 | void wxTreeCtrl::SortChildren(const wxTreeItemId& item) | |
693 | { | |
694 | wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); | |
695 | ||
696 | // rely on the fact that TreeView_SortChildren does the same thing as our | |
697 | // default behaviour, i.e. sorts items alphabetically and so call it | |
698 | // directly if we're not in derived class (much more efficient!) | |
699 | if ( GetClassInfo() == CLASSINFO(wxTreeCtrl) ) | |
700 | { | |
701 | TreeView_SortChildren(GetHwnd(), HITEM(item), 0); | |
702 | } | |
703 | else | |
704 | { | |
705 | TV_SORTCB tvSort; | |
706 | tvSort.hParent = HITEM(item); | |
707 | tvSort.lpfnCompare = wxTreeSortHelper::Compare; | |
708 | tvSort.lParam = (LPARAM)this; | |
709 | TreeView_SortChildrenCB(GetHwnd(), &tvSort, 0 /* reserved */); | |
710 | } | |
711 | } | |
712 | ||
713 | // ---------------------------------------------------------------------------- | |
714 | // State control. | |
715 | // ---------------------------------------------------------------------------- | |
716 | ||
717 | // why do they define INDEXTOSTATEIMAGEMASK but not the inverse? | |
718 | #define STATEIMAGEMASKTOINDEX(state) (((state) & TVIS_STATEIMAGEMASK) >> 12) | |
719 | ||
720 | void wxTreeCtrl::SetState(const wxTreeItemId& node, int state) | |
721 | { | |
722 | } | |
723 | ||
724 | int wxTreeCtrl::GetState(const wxTreeItemId& node) | |
725 | { | |
726 | return 0; | |
727 | } | |
728 | ||
729 | #endif // wxUSE_TREECTRL |