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