]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/treectrl.cpp
Read TIFF images from top to bottom instead of bottom to top.
[wxWidgets.git] / src / palmos / treectrl.cpp
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/imaglist.h"
39
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 // ----------------------------------------------------------------------------
70 // constants
71 // ----------------------------------------------------------------------------
72
73 // indices in gs_expandEvents table below
74 enum
75 {
76 IDX_COLLAPSE,
77 IDX_EXPAND,
78 IDX_WHAT_MAX
79 };
80
81 enum
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
90 static /* 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
109 void wxTreeCtrl::Init()
110 {
111 }
112
113 bool 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
124 wxTreeCtrl::~wxTreeCtrl()
125 {
126 }
127
128 // ----------------------------------------------------------------------------
129 // accessors
130 // ----------------------------------------------------------------------------
131
132 /* static */ wxVisualAttributes
133 wxTreeCtrl::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
143 bool wxTreeCtrl::DoGetItem(wxTreeViewItem* tvItem) const
144 {
145 return false;
146 }
147
148 void wxTreeCtrl::DoSetItem(wxTreeViewItem* tvItem)
149 {
150 }
151
152 unsigned int wxTreeCtrl::GetCount() const
153 {
154 // TODO
155 return 0;
156 }
157
158 unsigned int wxTreeCtrl::GetIndent() const
159 {
160 return 0;
161 }
162
163 void wxTreeCtrl::SetIndent(unsigned int indent)
164 {
165 }
166
167 wxImageList *wxTreeCtrl::GetImageList() const
168 {
169 return m_imageListNormal;
170 }
171
172 wxImageList *wxTreeCtrl::GetStateImageList() const
173 {
174 return m_imageListState;
175 }
176
177 void wxTreeCtrl::SetAnyImageList(wxImageList *imageList, int which)
178 {
179 }
180
181 void wxTreeCtrl::SetImageList(wxImageList *imageList)
182 {
183 }
184
185 void wxTreeCtrl::SetStateImageList(wxImageList *imageList)
186 {
187 }
188
189 void wxTreeCtrl::AssignImageList(wxImageList *imageList)
190 {
191 }
192
193 void wxTreeCtrl::AssignStateImageList(wxImageList *imageList)
194 {
195 }
196
197 size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item,
198 bool recursively) const
199 {
200 return 0;
201 }
202
203 // ----------------------------------------------------------------------------
204 // control colours
205 // ----------------------------------------------------------------------------
206
207 bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour)
208 {
209 return false;
210 }
211
212 bool wxTreeCtrl::SetForegroundColour(const wxColour &colour)
213 {
214 return false;
215 }
216
217 // ----------------------------------------------------------------------------
218 // Item access
219 // ----------------------------------------------------------------------------
220
221 wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const
222 {
223 return wxString(wxT(""));
224 }
225
226 void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text)
227 {
228 }
229
230 int wxTreeCtrl::DoGetItemImageFromData(const wxTreeItemId& item,
231 wxTreeItemIcon which) const
232 {
233 return -1;
234 }
235
236 void wxTreeCtrl::DoSetItemImageFromData(const wxTreeItemId& item,
237 int image,
238 wxTreeItemIcon which) const
239 {
240 }
241
242 void wxTreeCtrl::DoSetItemImages(const wxTreeItemId& item,
243 int image,
244 int imageSel)
245 {
246 }
247
248 int wxTreeCtrl::GetItemImage(const wxTreeItemId& item,
249 wxTreeItemIcon which) const
250 {
251 return -1;
252 }
253
254 void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image,
255 wxTreeItemIcon which)
256 {
257 }
258
259 wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const
260 {
261 return NULL;
262 }
263
264 void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data)
265 {
266 }
267
268 void wxTreeCtrl::SetIndirectItemData(const wxTreeItemId& item,
269 wxTreeItemIndirectData *data)
270 {
271 }
272
273 bool wxTreeCtrl::HasIndirectData(const wxTreeItemId& item) const
274 {
275 return false;
276 }
277
278 void wxTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has)
279 {
280 }
281
282 void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold)
283 {
284 }
285
286 void wxTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item, bool highlight)
287 {
288 }
289
290 void wxTreeCtrl::RefreshItem(const wxTreeItemId& item)
291 {
292 }
293
294 wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const
295 {
296 return wxNullColour;
297 }
298
299 wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const
300 {
301 return wxNullColour;
302 }
303
304 wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const
305 {
306 return wxNullFont;
307 }
308
309 void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
310 const wxColour& col)
311 {
312 }
313
314 void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item,
315 const wxColour& col)
316 {
317 }
318
319 void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font)
320 {
321 }
322
323 // ----------------------------------------------------------------------------
324 // Item status
325 // ----------------------------------------------------------------------------
326
327 bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const
328 {
329 return false;
330 }
331
332 bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const
333 {
334 return false;
335 }
336
337 bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const
338 {
339 return false;
340 }
341
342 bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const
343 {
344 return false;
345 }
346
347 bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const
348 {
349 return false;
350 }
351
352 // ----------------------------------------------------------------------------
353 // navigation
354 // ----------------------------------------------------------------------------
355
356 wxTreeItemId wxTreeCtrl::GetRootItem() const
357 {
358 return wxTreeItemId();
359 }
360
361 wxTreeItemId wxTreeCtrl::GetSelection() const
362 {
363 return 0;
364 }
365
366 wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const
367 {
368 return 0;
369 }
370
371 wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item,
372 wxTreeItemIdValue& cookie) const
373 {
374 return 0;
375 }
376
377 wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item),
378 wxTreeItemIdValue& cookie) const
379 {
380 return 0;
381 }
382
383 wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const
384 {
385 return 0;
386 }
387
388 wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const
389 {
390 return 0;
391 }
392
393 wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const
394 {
395 return 0;
396 }
397
398 wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const
399 {
400 return 0;
401 }
402
403 wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const
404 {
405 return 0;
406 }
407
408 wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const
409 {
410 return 0;
411 }
412
413 // ----------------------------------------------------------------------------
414 // multiple selections emulation
415 // ----------------------------------------------------------------------------
416
417 bool wxTreeCtrl::IsItemChecked(const wxTreeItemId& item) const
418 {
419 return false;
420 }
421
422 void wxTreeCtrl::SetItemCheck(const wxTreeItemId& item, bool check)
423 {
424 }
425
426 size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const
427 {
428 return 0;
429 }
430
431 // ----------------------------------------------------------------------------
432 // Usual operations
433 // ----------------------------------------------------------------------------
434
435 wxTreeItemId 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
444 wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text,
445 int image, int selectedImage,
446 wxTreeItemData *data)
447 {
448 return 0;
449 }
450
451 wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent,
452 const wxString& text,
453 int image, int selectedImage,
454 wxTreeItemData *data)
455 {
456 return 0;
457 }
458
459 wxTreeItemId 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
468 wxTreeItemId 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
477 wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent,
478 const wxString& text,
479 int image, int selectedImage,
480 wxTreeItemData *data)
481 {
482 return 0;
483 }
484
485 void wxTreeCtrl::Delete(const wxTreeItemId& item)
486 {
487 }
488
489 // delete all children (but don't delete the item itself)
490 void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item)
491 {
492 }
493
494 void wxTreeCtrl::DeleteAllItems()
495 {
496 }
497
498 void wxTreeCtrl::DoExpand(const wxTreeItemId& item, int flag)
499 {
500 }
501
502 void wxTreeCtrl::Expand(const wxTreeItemId& item)
503 {
504 }
505
506 void wxTreeCtrl::Collapse(const wxTreeItemId& item)
507 {
508 }
509
510 void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item)
511 {
512 }
513
514 void wxTreeCtrl::Toggle(const wxTreeItemId& item)
515 {
516 }
517
518 void wxTreeCtrl::Unselect()
519 {
520 }
521
522 void wxTreeCtrl::UnselectAll()
523 {
524 }
525
526 void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
527 {
528 }
529
530 void wxTreeCtrl::UnselectItem(const wxTreeItemId& item)
531 {
532 }
533
534 void wxTreeCtrl::ToggleItemSelection(const wxTreeItemId& item)
535 {
536 }
537
538 void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
539 {
540 }
541
542 void wxTreeCtrl::ScrollTo(const wxTreeItemId& item)
543 {
544 }
545
546 wxTextCtrl *wxTreeCtrl::GetEditControl() const
547 {
548 return NULL;
549 }
550
551 void wxTreeCtrl::DeleteTextCtrl()
552 {
553 }
554
555 wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item,
556 wxClassInfo* textControlClass)
557 {
558 return NULL;
559 }
560
561 // End label editing, optionally cancelling the edit
562 void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges)
563 {
564 }
565
566 wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
567 {
568 return 0;
569 }
570
571 bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item,
572 wxRect& rect,
573 bool textOnly) const
574 {
575 return false;
576 }
577
578 // ----------------------------------------------------------------------------
579 // sorting stuff
580 // ----------------------------------------------------------------------------
581
582 /*
583 // this is just a tiny namespace which is friend to wxTreeCtrl and so can use
584 // functions such as IsDataIndirect()
585 class wxTreeSortHelper
586 {
587 public:
588 static int CALLBACK Compare(LPARAM data1, LPARAM data2, LPARAM tree);
589
590 private:
591 static wxTreeItemId GetIdFromData(LPARAM lParam)
592 {
593 return ((wxTreeItemParam*)lParam)->GetItem();
594 }
595 };
596
597 int 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 }
609 */
610 int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
611 const wxTreeItemId& item2)
612 {
613 return wxStrcmp(GetItemText(item1), GetItemText(item2));
614 }
615
616 void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
617 {
618 wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
619
620 }
621
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
629 void wxTreeCtrl::SetState(const wxTreeItemId& node, int state)
630 {
631 }
632
633 int wxTreeCtrl::GetState(const wxTreeItemId& node)
634 {
635 return 0;
636 }
637
638 #endif // wxUSE_TREECTRL