]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/treectrl.cpp
adapting to init pattern
[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
ffecfa5a
JS
69// ----------------------------------------------------------------------------
70// constants
71// ----------------------------------------------------------------------------
72
73// indices in gs_expandEvents table below
74enum
75{
76 IDX_COLLAPSE,
77 IDX_EXPAND,
78 IDX_WHAT_MAX
79};
80
81enum
82{
83 IDX_DONE,
84 IDX_DOING,
85 IDX_HOW_MAX
86};
87
88// handy table for sending events - it has to be initialized during run-time
89// now so can't be const any more
90static /* const */ wxEventType gs_expandEvents[IDX_WHAT_MAX][IDX_HOW_MAX];
91
92/*
93 but logically it's a const table with the following entries:
94=
95{
96 { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxEVT_COMMAND_TREE_ITEM_COLLAPSING },
97 { wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxEVT_COMMAND_TREE_ITEM_EXPANDING }
98};
99*/
100
101// ============================================================================
102// implementation
103// ============================================================================
104
105// ----------------------------------------------------------------------------
106// construction and destruction
107// ----------------------------------------------------------------------------
108
109void wxTreeCtrl::Init()
110{
111}
112
113bool wxTreeCtrl::Create(wxWindow *parent,
114 wxWindowID id,
115 const wxPoint& pos,
116 const wxSize& size,
117 long style,
118 const wxValidator& validator,
119 const wxString& name)
120{
121 return false;
122}
123
124wxTreeCtrl::~wxTreeCtrl()
125{
126}
127
128// ----------------------------------------------------------------------------
129// accessors
130// ----------------------------------------------------------------------------
131
132/* static */ wxVisualAttributes
133wxTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
134{
135 wxVisualAttributes attrs;
136
137 return attrs;
138}
139
140
141// simple wrappers which add error checking in debug mode
142
143bool wxTreeCtrl::DoGetItem(wxTreeViewItem* tvItem) const
144{
145 return false;
146}
147
148void wxTreeCtrl::DoSetItem(wxTreeViewItem* tvItem)
149{
150}
151
027d45e8 152unsigned int wxTreeCtrl::GetCount() const
ffecfa5a 153{
027d45e8 154 // TODO
ffecfa5a
JS
155 return 0;
156}
157
158unsigned int wxTreeCtrl::GetIndent() const
159{
160 return 0;
161}
162
163void wxTreeCtrl::SetIndent(unsigned int indent)
164{
165}
166
167wxImageList *wxTreeCtrl::GetImageList() const
168{
169 return m_imageListNormal;
170}
171
172wxImageList *wxTreeCtrl::GetStateImageList() const
173{
174 return m_imageListState;
175}
176
177void wxTreeCtrl::SetAnyImageList(wxImageList *imageList, int which)
178{
179}
180
181void wxTreeCtrl::SetImageList(wxImageList *imageList)
182{
183}
184
185void wxTreeCtrl::SetStateImageList(wxImageList *imageList)
186{
187}
188
189void wxTreeCtrl::AssignImageList(wxImageList *imageList)
190{
191}
192
193void wxTreeCtrl::AssignStateImageList(wxImageList *imageList)
194{
195}
196
197size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item,
198 bool recursively) const
199{
200 return 0;
201}
202
203// ----------------------------------------------------------------------------
204// control colours
205// ----------------------------------------------------------------------------
206
207bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour)
208{
209 return false;
210}
211
212bool wxTreeCtrl::SetForegroundColour(const wxColour &colour)
213{
214 return false;
215}
216
217// ----------------------------------------------------------------------------
218// Item access
219// ----------------------------------------------------------------------------
220
221wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const
222{
6afc1b46 223 return wxString(wxT(""));
ffecfa5a
JS
224}
225
226void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text)
227{
228}
229
230int wxTreeCtrl::DoGetItemImageFromData(const wxTreeItemId& item,
231 wxTreeItemIcon which) const
232{
233 return -1;
234}
235
236void wxTreeCtrl::DoSetItemImageFromData(const wxTreeItemId& item,
237 int image,
238 wxTreeItemIcon which) const
239{
240}
241
242void wxTreeCtrl::DoSetItemImages(const wxTreeItemId& item,
243 int image,
244 int imageSel)
245{
246}
247
248int wxTreeCtrl::GetItemImage(const wxTreeItemId& item,
249 wxTreeItemIcon which) const
250{
251 return -1;
252}
253
254void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image,
255 wxTreeItemIcon which)
256{
257}
258
259wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const
260{
261 return NULL;
262}
263
264void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data)
265{
266}
267
268void wxTreeCtrl::SetIndirectItemData(const wxTreeItemId& item,
269 wxTreeItemIndirectData *data)
270{
271}
272
273bool wxTreeCtrl::HasIndirectData(const wxTreeItemId& item) const
274{
275 return false;
276}
277
278void wxTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has)
279{
280}
281
282void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold)
283{
284}
285
286void wxTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item, bool highlight)
287{
288}
289
290void wxTreeCtrl::RefreshItem(const wxTreeItemId& item)
291{
292}
293
294wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const
295{
296 return wxNullColour;
297}
298
299wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const
300{
301 return wxNullColour;
302}
303
304wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const
305{
306 return wxNullFont;
307}
308
309void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
310 const wxColour& col)
311{
312}
313
314void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item,
315 const wxColour& col)
316{
317}
318
319void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font)
320{
321}
322
323// ----------------------------------------------------------------------------
324// Item status
325// ----------------------------------------------------------------------------
326
327bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const
328{
329 return false;
330}
331
332bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const
333{
334 return false;
335}
336
337bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const
338{
339 return false;
340}
341
342bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const
343{
344 return false;
345}
346
347bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const
348{
349 return false;
350}
351
352// ----------------------------------------------------------------------------
353// navigation
354// ----------------------------------------------------------------------------
355
356wxTreeItemId wxTreeCtrl::GetRootItem() const
357{
6afc1b46 358 return wxTreeItemId();
ffecfa5a
JS
359}
360
361wxTreeItemId wxTreeCtrl::GetSelection() const
362{
363 return 0;
364}
365
366wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const
367{
368 return 0;
369}
370
371wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item,
372 wxTreeItemIdValue& cookie) const
373{
374 return 0;
375}
376
377wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item),
378 wxTreeItemIdValue& cookie) const
379{
380 return 0;
381}
382
ffecfa5a
JS
383wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const
384{
385 return 0;
386}
387
388wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const
389{
390 return 0;
391}
392
393wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const
394{
395 return 0;
396}
397
398wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const
399{
400 return 0;
401}
402
403wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const
404{
405 return 0;
406}
407
408wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const
409{
410 return 0;
411}
412
413// ----------------------------------------------------------------------------
414// multiple selections emulation
415// ----------------------------------------------------------------------------
416
417bool wxTreeCtrl::IsItemChecked(const wxTreeItemId& item) const
418{
419 return false;
420}
421
422void wxTreeCtrl::SetItemCheck(const wxTreeItemId& item, bool check)
423{
424}
425
426size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const
427{
428 return 0;
429}
430
431// ----------------------------------------------------------------------------
432// Usual operations
433// ----------------------------------------------------------------------------
434
435wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
436 wxTreeItemId hInsertAfter,
437 const wxString& text,
438 int image, int selectedImage,
439 wxTreeItemData *data)
440{
441 return 0;
442}
443
ffecfa5a
JS
444wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text,
445 int image, int selectedImage,
446 wxTreeItemData *data)
447{
448 return 0;
449}
450
451wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent,
452 const wxString& text,
453 int image, int selectedImage,
454 wxTreeItemData *data)
455{
456 return 0;
457}
458
459wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent,
460 const wxTreeItemId& idPrevious,
461 const wxString& text,
462 int image, int selectedImage,
463 wxTreeItemData *data)
464{
465 return 0;
466}
467
468wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent,
469 size_t index,
470 const wxString& text,
471 int image, int selectedImage,
472 wxTreeItemData *data)
473{
474 return 0;
475}
476
477wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent,
478 const wxString& text,
479 int image, int selectedImage,
480 wxTreeItemData *data)
481{
482 return 0;
483}
484
485void wxTreeCtrl::Delete(const wxTreeItemId& item)
486{
ffecfa5a
JS
487}
488
489// delete all children (but don't delete the item itself)
490void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item)
491{
492}
493
494void wxTreeCtrl::DeleteAllItems()
495{
496}
497
498void wxTreeCtrl::DoExpand(const wxTreeItemId& item, int flag)
499{
500}
501
502void wxTreeCtrl::Expand(const wxTreeItemId& item)
503{
504}
505
506void wxTreeCtrl::Collapse(const wxTreeItemId& item)
507{
508}
509
510void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item)
511{
512}
513
514void wxTreeCtrl::Toggle(const wxTreeItemId& item)
515{
516}
517
ffecfa5a
JS
518void wxTreeCtrl::Unselect()
519{
520}
521
522void wxTreeCtrl::UnselectAll()
523{
524}
525
526void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
527{
528}
529
530void wxTreeCtrl::UnselectItem(const wxTreeItemId& item)
531{
532}
533
534void wxTreeCtrl::ToggleItemSelection(const wxTreeItemId& item)
535{
536}
537
538void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
539{
540}
541
542void wxTreeCtrl::ScrollTo(const wxTreeItemId& item)
543{
544}
545
546wxTextCtrl *wxTreeCtrl::GetEditControl() const
547{
548 return NULL;
549}
550
551void wxTreeCtrl::DeleteTextCtrl()
552{
553}
554
555wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item,
556 wxClassInfo* textControlClass)
557{
558 return NULL;
559}
560
561// End label editing, optionally cancelling the edit
562void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges)
563{
564}
565
566wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
567{
568 return 0;
569}
570
571bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item,
572 wxRect& rect,
573 bool textOnly) const
574{
575 return false;
576}
577
578// ----------------------------------------------------------------------------
579// sorting stuff
580// ----------------------------------------------------------------------------
581
6afc1b46 582/*
ffecfa5a
JS
583// this is just a tiny namespace which is friend to wxTreeCtrl and so can use
584// functions such as IsDataIndirect()
585class wxTreeSortHelper
586{
587public:
588 static int CALLBACK Compare(LPARAM data1, LPARAM data2, LPARAM tree);
589
590private:
6afc1b46 591 static wxTreeItemId GetIdFromData(LPARAM lParam)
ffecfa5a 592 {
6afc1b46 593 return ((wxTreeItemParam*)lParam)->GetItem();
ffecfa5a
JS
594 }
595};
596
597int CALLBACK wxTreeSortHelper::Compare(LPARAM pItem1,
598 LPARAM pItem2,
599 LPARAM htree)
600{
601 wxCHECK_MSG( pItem1 && pItem2, 0,
602 wxT("sorting tree without data doesn't make sense") );
603
604 wxTreeCtrl *tree = (wxTreeCtrl *)htree;
605
606 return tree->OnCompareItems(GetIdFromData(tree, pItem1),
607 GetIdFromData(tree, pItem2));
608}
6afc1b46 609*/
ffecfa5a
JS
610int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
611 const wxTreeItemId& item2)
612{
613 return wxStrcmp(GetItemText(item1), GetItemText(item2));
614}
615
616void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
617{
618 wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
619
ffecfa5a
JS
620}
621
ffecfa5a
JS
622// ----------------------------------------------------------------------------
623// State control.
624// ----------------------------------------------------------------------------
625
626// why do they define INDEXTOSTATEIMAGEMASK but not the inverse?
627#define STATEIMAGEMASKTOINDEX(state) (((state) & TVIS_STATEIMAGEMASK) >> 12)
628
629void wxTreeCtrl::SetState(const wxTreeItemId& node, int state)
630{
631}
632
633int wxTreeCtrl::GetState(const wxTreeItemId& node)
634{
635 return 0;
636}
637
638#endif // wxUSE_TREECTRL