]> git.saurik.com Git - wxWidgets.git/blob - interface/dataview.h
Ticket #9592: gtk-choice-setcolumns.2.diff
[wxWidgets.git] / interface / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dataview.h
3 // Purpose: interface of wxDataViewIconText
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxDataViewIconText
11 @wxheader{dataview.h}
12
13 wxDataViewIconText is used by
14 wxDataViewIconTextRenderer
15 for data transfer. This class can be converted to a from
16 a wxVariant.
17
18 @library{wxbase}
19 @category{dvc}
20 */
21 class wxDataViewIconText : public wxObject
22 {
23 public:
24 //@{
25 /**
26 Constructor.
27 */
28 wxDataViewIconText(const wxString& text = wxEmptyString,
29 const wxIcon& icon = wxNullIcon);
30 wxDataViewIconText(const wxDataViewIconText& other);
31 //@}
32
33 /**
34 Gets the icon.
35 */
36 const wxIcon GetIcon() const;
37
38 /**
39 Gets the text.
40 */
41 wxString GetText() const;
42
43 /**
44 Set the icon.
45 */
46 void SetIcon(const wxIcon& icon);
47
48 /**
49 Set the text.
50 */
51 void SetText(const wxString& text);
52 };
53
54
55
56 /**
57 @class wxDataViewEvent
58 @wxheader{dataview.h}
59
60 wxDataViewEvent - the event class for the wxDataViewCtrl notifications
61
62 @library{wxadv}
63 @category{events,dvc}
64 */
65 class wxDataViewEvent : public wxNotifyEvent
66 {
67 public:
68 //@{
69 /**
70
71 */
72 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
73 int winid = 0);
74 wxDataViewEvent(const wxDataViewEvent& event);
75 //@}
76
77 /**
78 Used to clone the event.
79 */
80 wxEvent* Clone() const;
81
82 /**
83 Returns the position of the column in the control or -1
84 if no column field was set by the event emitter.
85 */
86 int GetColumn() const;
87
88 /**
89 Returns a pointer to the wxDataViewColumn from which
90 the event was emitted or @NULL.
91 */
92 wxDataViewColumn* GetDataViewColumn();
93
94 /**
95 Returns the wxDataViewModel associated with the event.
96 */
97 wxDataViewModel* GetModel() const;
98
99 /**
100 Returns a the position of a context menu event in screen coordinates.
101 */
102 wxPoint GetPosition() const;
103
104 /**
105 Returns a reference to a value.
106 */
107 const wxVariant GetValue() const;
108
109 /**
110
111 */
112 void SetColumn(int col);
113
114 /**
115 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
116 */
117 void SetDataViewColumn(wxDataViewColumn* col);
118
119 /**
120
121 */
122 void SetModel(wxDataViewModel* model);
123
124 /**
125
126 */
127 void SetValue(const wxVariant& value);
128 };
129
130
131
132 /**
133 @class wxDataViewModel
134 @wxheader{dataview.h}
135
136 wxDataViewModel is the base class for all data model to be
137 displayed by a wxDataViewCtrl.
138 All other models derive from it and must implement its
139 pure virtual functions in order to define a complete
140 data model. In detail, you need to override
141 wxDataViewModel::IsContainer,
142 wxDataViewModel::GetParent,
143 wxDataViewModel::GetChildren,
144 wxDataViewModel::GetColumnCount,
145 wxDataViewModel::GetColumnType and
146 wxDataViewModel::GetValue in order to
147 define the data model which acts as an interface between
148 your actual data and the wxDataViewCtrl. Since you will
149 usually also allow the wxDataViewCtrl to change your data
150 through its graphical interface, you will also have to override
151 wxDataViewModel::SetValue which the
152 wxDataViewCtrl will call when a change to some data has been
153 commited.
154
155 wxDataViewModel (as indeed the entire wxDataViewCtrl
156 code) is using wxVariant to store data and
157 its type in a generic way. wxVariant can be extended to contain
158 almost any data without changes to the original class.
159
160 The data that is presented through this data model is expected
161 to change at run-time. You need to inform the data model when
162 a change happened. Depending on what happened you need to call
163 one of the following methods:
164 wxDataViewModel::ValueChanged,
165 wxDataViewModel::ItemAdded,
166 wxDataViewModel::ItemDeleted,
167 wxDataViewModel::ItemChanged,
168 wxDataViewModel::Cleared. There are
169 plural forms for notification of addition, change
170 or removal of several item at once. See
171 wxDataViewModel::ItemsAdded,
172 wxDataViewModel::ItemsDeleted,
173 wxDataViewModel::ItemsChanged.
174
175 Note that wxDataViewModel does not define the position or
176 index of any item in the control because different controls
177 might display the same data differently. wxDataViewModel does
178 provide a wxDataViewModel::Compare method
179 which the wxDataViewCtrl may use to sort the data either
180 in conjunction with a column header or without (see
181 wxDataViewModel::HasDefaultCompare).
182
183 This class maintains a list of
184 wxDataViewModelNotifier
185 which link this class to the specific implementations on the
186 supported platforms so that e.g. calling
187 wxDataViewModel::ValueChanged
188 on this model will just call
189 wxDataViewModelNotifier::ValueChanged
190 for each notifier that has been added. You can also add
191 your own notifier in order to get informed about any changes
192 to the data in the list model.
193
194 Currently wxWidgets provides the following models apart
195 from the base model:
196 wxDataViewIndexListModel,
197 wxDataViewVirtualListModel,
198 wxDataViewTreeStore.
199
200 Note that wxDataViewModel is reference counted, derives from
201 wxObjectRefData and cannot be deleted
202 directly as it can be shared by several wxDataViewCtrls. This
203 implies that you need to decrease the reference count after
204 associating the model with a control like this:
205
206 @code
207 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
208 wxDataViewModel *musicModel = new MyMusicModel;
209 m_musicCtrl-AssociateModel( musicModel );
210 musicModel-DecRef(); // avoid memory leak !!
211 // add columns now
212 @endcode
213
214
215 @library{wxadv}
216 @category{dvc}
217 */
218 class wxDataViewModel : public wxObjectRefData
219 {
220 public:
221 /**
222 Constructor.
223 */
224 wxDataViewModel();
225
226 /**
227 Destructor. This should not be called directly. Use DecRef() instead.
228 */
229 ~wxDataViewModel();
230
231 /**
232 Adds a wxDataViewModelNotifier
233 to the model.
234 */
235 void AddNotifier(wxDataViewModelNotifier* notifier);
236
237 /**
238 Called to inform the model that all data has been cleared. The
239 control will reread the data from the model again.
240 */
241 virtual bool Cleared();
242
243 /**
244 The compare function to be used by control. The default compare function
245 sorts by container and other items separately and in ascending order.
246 Override this for a different sorting behaviour.
247 See also HasDefaultCompare().
248 */
249 virtual int Compare(const wxDataViewItem& item1,
250 const wxDataViewItem& item2,
251 unsigned int column,
252 bool ascending);
253
254 /**
255 Oberride this to indicate that the item has special font attributes.
256 This only affects the
257 wxDataViewTextRendererText() renderer.
258 See also wxDataViewItemAttr.
259 */
260 bool GetAttr(const wxDataViewItem& item, unsigned int col,
261 wxDataViewItemAttr& attr);
262
263 /**
264 Override this so the control can query the child items of
265 an item. Returns the number of items.
266 */
267 virtual unsigned int GetChildren(const wxDataViewItem& item,
268 wxDataViewItemArray& children) const;
269
270 /**
271 Override this to indicate the number of columns in the model.
272 */
273 virtual unsigned int GetColumnCount() const;
274
275 /**
276 Override this to indicate what type of data is stored in the
277 column specified by @e col. This should return a string
278 indicating the type of data as reported by wxVariant.
279 */
280 virtual wxString GetColumnType(unsigned int col) const;
281
282 /**
283 Override this to indicate which wxDataViewItem representing the parent
284 of @a item or an invalid wxDataViewItem if the the root item is
285 the parent item.
286 */
287 virtual wxDataViewItem GetParent(const wxDataViewItem& item) const;
288
289 /**
290 Override this to indicate the value of @e item
291 A wxVariant is used to store the data.
292 */
293 virtual void GetValue(wxVariant& variant,
294 const wxDataViewItem& item,
295 unsigned int col) const;
296
297 /**
298 Override this method to indicate if a container item merely
299 acts as a headline (or for categorisation) or if it also
300 acts a normal item with entries for futher columns. By
301 default returns @e @false.
302 */
303 virtual bool HasContainerColumns(const wxDataViewItem& item) const;
304
305 /**
306 Override this to indicate that the model provides a default compare
307 function that the control should use if no wxDataViewColumn has been
308 chosen for sorting. Usually, the user clicks on a column header for
309 sorting, the data will be sorted alphanumerically. If any other
310 order (e.g. by index or order of appearance) is required, then this
311 should be used. See also wxDataViewIndexListModel
312 for a model which makes use of this.
313 */
314 virtual bool HasDefaultCompare() const;
315
316 /**
317 Override this to indicate of @a item is a container, i.e. if
318 it can have child items.
319 */
320 virtual bool IsContainer(const wxDataViewItem& item) const;
321
322 /**
323 Call this to inform the model that an item has been added
324 to the data.
325 */
326 virtual bool ItemAdded(const wxDataViewItem& parent,
327 const wxDataViewItem& item);
328
329 /**
330 Call this to inform the model that an item has changed.
331 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
332 event (in which the column fields will not be set) to the user.
333 */
334 virtual bool ItemChanged(const wxDataViewItem& item);
335
336 /**
337 Call this to inform the model that an item has been deleted from the data.
338 */
339 virtual bool ItemDeleted(const wxDataViewItem& parent,
340 const wxDataViewItem& item);
341
342 /**
343 Call this to inform the model that several items have been added
344 to the data.
345 */
346 virtual bool ItemsAdded(const wxDataViewItem& parent,
347 const wxDataViewItemArray& items);
348
349 /**
350 Call this to inform the model that several items have changed.
351 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
352 events (in which the column fields will not be set) to the user.
353 */
354 virtual bool ItemsChanged(const wxDataViewItemArray& items);
355
356 /**
357 Call this to inform the model that several items have been deleted.
358 */
359 virtual bool ItemsDeleted(const wxDataViewItem& parent,
360 const wxDataViewItemArray& items);
361
362 /**
363 Remove the @a notifier from the list of notifiers.
364 */
365 void RemoveNotifier(wxDataViewModelNotifier* notifier);
366
367 /**
368 Call this to initiate a resort after the sort function has
369 been changed.
370 */
371 virtual void Resort();
372
373 /**
374 This gets called in order to set a value in the data model.
375 The most common scenario is that the wxDataViewCtrl calls
376 this method after the user changed some data in the view.
377 Afterwards ValueChanged()
378 has to be called!
379 */
380 virtual bool SetValue(const wxVariant& variant,
381 const wxDataViewItem& item,
382 unsigned int col);
383
384 /**
385 Call this to inform this model that a value in the model has
386 been changed. This is also called from wxDataViewCtrl's
387 internal editing code, e.g. when editing a text field
388 in the control.
389 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
390 event to the user.
391 */
392 virtual bool ValueChanged(const wxDataViewItem& item,
393 unsigned int col);
394 };
395
396
397
398 /**
399 @class wxDataViewIndexListModel
400 @wxheader{dataview.h}
401
402 wxDataViewIndexListModel is a specialized data model which lets
403 you address an item by its position (row) rather than its
404 wxDataViewItem (which you can obtain from this class).
405 This model also provides its own wxDataViewIndexListModel::Compare
406 method which sorts the model's data by the index.
407
408 This model is not a virtual model since the control stores
409 each wxDataViewItem. Use wxDataViewVirtualListModel if you
410 need to display millions of items or have other reason to
411 use a virtual control.
412
413 @library{wxbase}
414 @category{dvc}
415 */
416 class wxDataViewIndexListModel : public wxDataViewModel
417 {
418 public:
419 /**
420 Constructor.
421 */
422 wxDataViewIndexListModel(unsigned int initial_size = 0);
423
424 /**
425 Destructor.
426 */
427 ~wxDataViewIndexListModel();
428
429 /**
430 Compare method that sorts the items by their index.
431 */
432 int Compare(const wxDataViewItem& item1,
433 const wxDataViewItem& item2,
434 unsigned int column, bool ascending);
435
436 /**
437 Oberride this to indicate that the row has special font attributes.
438 This only affects the
439 wxDataViewTextRendererText() renderer.
440 See also wxDataViewItemAttr.
441 */
442 bool GetAttr(unsigned int row, unsigned int col,
443 wxDataViewItemAttr& attr);
444
445 /**
446 Returns the wxDataViewItem at the given @e row.
447 */
448 wxDataViewItem GetItem(unsigned int row) const;
449
450 /**
451 Returns the position of given @e item.
452 */
453 unsigned int GetRow(const wxDataViewItem& item) const;
454
455 /**
456 Override this to allow getting values from the model.
457 */
458 void GetValue(wxVariant& variant, unsigned int row,
459 unsigned int col) const;
460
461 /**
462 Call this after if the data has to be read again from
463 the model. This is useful after major changes when
464 calling the methods below (possibly thousands of times)
465 doesn't make sense.
466 */
467 void Reset(unsigned int new_size);
468
469 /**
470 Call this after a row has been appended to the model.
471 */
472 void RowAppended();
473
474 /**
475 Call this after a row has been changed.
476 */
477 void RowChanged(unsigned int row);
478
479 /**
480 Call this after a row has been deleted.
481 */
482 void RowDeleted(unsigned int row);
483
484 /**
485 Call this after a row has been inserted at the given position.
486 */
487 void RowInserted(unsigned int before);
488
489 /**
490 Call this after a row has been prepended to the model.
491 */
492 void RowPrepended();
493
494 /**
495 Call this after a value has been changed.
496 */
497 void RowValueChanged(unsigned int row, unsigned int col);
498
499 /**
500 Call this after rows have been deleted. The array will internally
501 get copied and sorted in descending order so that the rows with
502 the highest position will be deleted first.
503 */
504 void RowsDeleted(const wxArrayInt& rows);
505
506 /**
507 Called in order to set a value in the model.
508 */
509 bool SetValue(const wxVariant& variant, unsigned int row,
510 unsigned int col);
511 };
512
513
514
515 /**
516 @class wxDataViewVirtualListModel
517 @wxheader{dataview.h}
518
519 wxDataViewVirtualListModel is a specialized data model which lets
520 you address an item by its position (row) rather than its
521 wxDataViewItem and as such offers the exact same interface as
522 wxDataViewIndexListModel. The important difference is that under
523 platforms other than OS X, using this model will result in a
524 truely virtual control able to handle millions of items as the
525 control doesn't store any item (a feature not supported by the
526 Carbon API under OS X).
527
528 @see wxDataViewIndexListModel for the API.
529
530 @library{wxbase}
531 @category{dvc}
532 */
533 class wxDataViewVirtualListModel : public wxDataViewModel
534 {
535 public:
536 /**
537 Constructor.
538 */
539 wxDataViewVirtualListModel(unsigned int initial_size = 0);
540 };
541
542
543
544 /**
545 @class wxDataViewItemAttr
546 @wxheader{dataview.h}
547
548 This class is used to indicate to a wxDataViewCtrl
549 that a certain Item() has extra font attributes
550 for its renderer. For this, it is required to override
551 wxDataViewModel::GetAttr.
552
553 Attributes are currently only supported by
554 wxDataViewTextRendererText().
555
556 @library{wxadv}
557 @category{dvc}
558 */
559 class wxDataViewItemAttr
560 {
561 public:
562 /**
563 Constructor.
564 */
565 wxDataViewItemAttr();
566
567 /**
568 Call this to indicate that the item shall be displayed in bold text.
569 */
570 void SetBold(bool set);
571
572 /**
573 Call this to indicate that the item shall be displayed with
574 that colour.
575 */
576 void SetColour(const wxColour& colour);
577
578 /**
579 Call this to indicate that the item shall be displayed in italic text.
580 */
581 void SetItalic(bool set);
582 };
583
584
585
586 /**
587 @class wxDataViewItem
588 @wxheader{dataview.h}
589
590 wxDataViewItem is a small opaque class that represents an
591 item in a wxDataViewCtrl in a
592 persistent way, i.e. indepent of the position of the
593 item in the control or changes to its contents. It must
594 hold a unique ID of type @e void* in its only field
595 and can be converted to a from it.
596
597 If the ID is @e @NULL the wxDataViewItem is invalid and
598 wxDataViewItem::IsOk will return @e @false
599 which used in many places in the API of wxDataViewCtrl
600 to indicate that e.g. no item was found. An ID of @NULL
601 is also used to indicate the invisible root. Examples
602 for this are
603 wxDataViewModel::GetParent and
604 wxDataViewModel::GetChildren.
605
606 @library{wxadv}
607 @category{dvc}
608 */
609 class wxDataViewItem
610 {
611 public:
612 //@{
613 /**
614
615 */
616 wxDataViewItem(void* id = NULL);
617 wxDataViewItem(const wxDataViewItem& item);
618 //@}
619
620 /**
621 Returns the ID.
622 */
623 void* GetID() const;
624
625 /**
626 Returns @true if the ID is not @e @NULL.
627 */
628 bool IsOk() const;
629 };
630
631
632
633 /**
634 @class wxDataViewCtrl
635 @wxheader{dataview.h}
636
637 wxDataViewCtrl is a control to display data either
638 in a tree like fashion or in a tabular form or both.
639 If you only need to display a simple tree structure
640 with an API more like the older wxTreeCtrl class,
641 then the specialized wxDataViewTreeCtrl
642 can be used.
643
644 A wxDataViewItem is used
645 to represent a (visible) item in the control.
646
647 Unlike wxListCtrl wxDataViewCtrl doesn't
648 get its data from the user through virtual functions or by
649 setting it directly. Instead you need to write your own
650 wxDataViewModel and associate
651 it with this control. Then you need to add a number of
652 wxDataViewColumn to this control to
653 define what each column shall display. Each wxDataViewColumn
654 in turn owns 1 instance of a
655 wxDataViewRenderer to render its
656 cells. A number of standard renderers for rendering text, dates,
657 images, toggle, a progress bar etc. are provided. Additionally,
658 the user can write custom renderes deriving from
659 wxDataViewCustomRenderer
660 for displaying anything.
661
662 All data transfer from the control to the model and the user
663 code is done through wxVariant which can
664 be extended to support more data formats as necessary.
665 Accordingly, all type information uses the strings returned
666 from wxVariant::GetType.
667
668 @beginStyleTable
669 @style{wxDV_SINGLE}
670 Single selection mode. This is the default.
671 @style{wxDV_MULTIPLE}
672 Multiple selection mode.
673 @style{wxDV_ROW_LINES}
674 Use alternating colours for rows if supported by platform and theme.
675 @style{wxDV_HORIZ_RULES}
676 Display fine rules between row if supported.
677 @style{wxDV_VERT_RULES}
678 Display fine rules between columns is supported.
679 @style{wxDV_VARIABLE_LINE_HEIGHT}
680 Allow variable line heights. This can be inefficient when displaying large number of items.
681 @endStyleTable
682
683 @library{wxadv}
684 @category{ctrl,dvc}
685 <!-- @appearance{dataviewctrl.png} -->
686 */
687 class wxDataViewCtrl : public wxControl
688 {
689 public:
690 /**
691 Default Constructor.
692 */
693 wxDataViewCtrl();
694
695 /**
696 Constructor. Calls Create().
697 */
698 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
699 const wxPoint& pos = wxDefaultPosition,
700 const wxSize& size = wxDefaultSize,
701 long style = 0,
702 const wxValidator& validator = wxDefaultValidator);
703
704 /**
705 Destructor.
706 */
707 ~wxDataViewCtrl();
708
709 /**
710 Appends a wxDataViewColumn to the control. Returns @true on success.
711 Note that there is a number of short cut methods which implicitly create
712 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
713 */
714 virtual bool AppendColumn(wxDataViewColumn* col);
715
716 /**
717 Prepends a wxDataViewColumn to the control. Returns @true on success.
718 Note that there is a number of short cut methods which implicitly create
719 a wxDataViewColumn and a wxDataViewRenderer for it.
720 */
721 virtual bool PrependColumn(wxDataViewColumn* col);
722
723 /**
724 Inserts a wxDataViewColumn to the control. Returns @true on success.
725 */
726 virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
727
728 //@{
729 /**
730 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
731 created in the function or @NULL on failure.
732 */
733 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
734 unsigned int model_column,
735 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
736 int width = -1,
737 wxAlignment align = wxALIGN_CENTER,
738 int flags = wxDATAVIEW_COL_RESIZABLE);
739 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
740 unsigned int model_column,
741 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
742 int width = -1,
743 wxAlignment align = wxALIGN_CENTER,
744 int flags = wxDATAVIEW_COL_RESIZABLE);
745 //@}
746
747 //@{
748 /**
749 Appends a column for rendering a date. Returns the wxDataViewColumn
750 created in the function or @NULL on failure.
751
752 NB: The @e align parameter is applied to both the column header and
753 the column renderer.
754 */
755 wxDataViewColumn* AppendDateColumn(const wxString& label,
756 unsigned int model_column,
757 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
758 int width = -1,
759 wxAlignment align = wxALIGN_CENTER,
760 int flags = wxDATAVIEW_COL_RESIZABLE);
761 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
762 unsigned int model_column,
763 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
764 int width = -1,
765 wxAlignment align = wxALIGN_CENTER,
766 int flags = wxDATAVIEW_COL_RESIZABLE);
767 //@}
768
769 //@{
770 /**
771 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
772 created in the function or @NULL on failure. This method uses the
773 wxDataViewIconTextRenderer class.
774
775 NB: The @e align parameter is applied to both the column header and
776 the column renderer.
777 */
778 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
779 unsigned int model_column,
780 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
781 int width = -1,
782 wxAlignment align = wxALIGN_LEFT,
783 int flags = wxDATAVIEW_COL_RESIZABLE);
784 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
785 unsigned int model_column,
786 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
787 int width = -1,
788 wxAlignment align = wxALIGN_LEFT,
789 int flags = wxDATAVIEW_COL_RESIZABLE);
790 //@}
791
792 //@{
793 /**
794 Appends a column for rendering a progress indicator. Returns the
795 wxDataViewColumn created in the function or @NULL on failure.
796
797 NB: The @e align parameter is applied to both the column header and
798 the column renderer.
799 */
800 wxDataViewColumn* AppendProgressColumn(const wxString& label,
801 unsigned int model_column,
802 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
803 int width = 80,
804 wxAlignment align = wxALIGN_CENTER,
805 int flags = wxDATAVIEW_COL_RESIZABLE);
806 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
807 unsigned int model_column,
808 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
809 int width = 80,
810 wxAlignment align = wxALIGN_CENTER,
811 int flags = wxDATAVIEW_COL_RESIZABLE);
812 //@}
813
814 //@{
815 /**
816 Appends a column for rendering text. Returns the wxDataViewColumn
817 created in the function or @NULL on failure.
818
819 NB: The @e align parameter is applied to both the column header and
820 the column renderer.
821 */
822 wxDataViewColumn* AppendTextColumn(const wxString& label,
823 unsigned int model_column,
824 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
825 int width = -1,
826 wxAlignment align = wxALIGN_LEFT,
827 int flags = wxDATAVIEW_COL_RESIZABLE);
828 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
829 unsigned int model_column,
830 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
831 int width = -1,
832 wxAlignment align = wxALIGN_LEFT,
833 int flags = wxDATAVIEW_COL_RESIZABLE);
834 //@}
835
836 //@{
837 /**
838 Appends a column for rendering a toggle. Returns the wxDataViewColumn
839 created in the function or @NULL on failure.
840
841 NB: The @e align parameter is applied to both the column header and
842 the column renderer.
843 */
844 wxDataViewColumn* AppendToggleColumn(const wxString& label,
845 unsigned int model_column,
846 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
847 int width = 30,
848 wxAlignment align = wxALIGN_CENTER,
849 int flags = wxDATAVIEW_COL_RESIZABLE);
850 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
851 unsigned int model_column,
852 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
853 int width = 30,
854 wxAlignment align = wxALIGN_CENTER,
855 int flags = wxDATAVIEW_COL_RESIZABLE);
856 //@}
857
858 /**
859 Associates a wxDataViewModel with the control. This increases the reference
860 count of the model by 1.
861 */
862 virtual bool AssociateModel(wxDataViewModel* model);
863
864 /**
865 Removes all columns.
866 */
867 virtual bool ClearColumns();
868
869 /**
870 Unselects all rows.
871 */
872 void ClearSelection();
873
874 /**
875 Collapses the item.
876 */
877 void Collapse(const wxDataViewItem& item);
878
879 /**
880 Create the control. Useful for two step creation.
881 */
882 bool Create(wxWindow* parent, wxWindowID id,
883 const wxPoint& pos = wxDefaultPosition,
884 const wxSize& size = wxDefaultSize,
885 long style = 0,
886 const wxValidator& validator = wxDefaultValidator);
887
888 /**
889 Deletes given column.
890 */
891 virtual bool DeleteColumn(const wxDataViewColumn* column);
892
893 /**
894 Call this to ensure that the given item is visible.
895 */
896 void EnsureVisible(const wxDataViewItem& item,
897 const wxDataViewColumn* column = NULL);
898
899 /**
900 Expands the item.
901 */
902 void Expand(const wxDataViewItem& item);
903
904 /**
905 Returns pointer to the column. @a pos refers to the
906 position in the control which may change after reordering
907 columns by the user.
908 */
909 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
910
911 /**
912 Returns the number of columns.
913 */
914 virtual unsigned int GetColumnCount() const;
915
916 /**
917 Returns the position of the column or -1 if not found in the control.
918 */
919 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
920
921 /**
922 Returns column containing the expanders.
923 */
924 wxDataViewColumn* GetExpanderColumn() const;
925
926 /**
927 Returns indentation.
928 */
929 int GetIndent() const;
930
931 /**
932 Returns item rect.
933 */
934 wxRect GetItemRect(const wxDataViewItem& item,
935 const wxDataViewColumn* col = NULL) const;
936
937 /**
938 Returns pointer to the data model associated with the
939 control (if any).
940 */
941 virtual wxDataViewModel* GetModel() const;
942
943 /**
944 Returns first selected item or an invalid item if none is selected.
945 */
946 wxDataViewItem GetSelection() const;
947
948 /**
949 Fills @a sel with currently selected items and returns
950 their number.
951 */
952 int GetSelections(wxDataViewItemArray& sel) const;
953
954 /**
955 Returns the wxDataViewColumn currently responsible for sorting
956 or @NULL if none has been selected.
957 */
958 virtual wxDataViewColumn* GetSortingColumn() const;
959
960 /**
961 Hittest.
962 */
963 void HitTest(const wxPoint& point, wxDataViewItem& item,
964 wxDataViewColumn*& col) const;
965
966 /**
967 Return @true if the item is selected.
968 */
969 bool IsSelected(const wxDataViewItem& item) const;
970
971 /**
972 Select the given item.
973 */
974 void Select(const wxDataViewItem& item);
975
976 /**
977 Select all items.
978 */
979 void SelectAll();
980
981 /**
982 Set which column shall contain the tree-like expanders.
983 */
984 void SetExpanderColumn(wxDataViewColumn* col);
985
986 /**
987 Sets the indendation.
988 */
989 void SetIndent(int indent);
990
991 /**
992 Sets the selection to the array of wxDataViewItems.
993 */
994 void SetSelections(const wxDataViewItemArray& sel);
995
996 /**
997 Unselect the given item.
998 */
999 void Unselect(const wxDataViewItem& item);
1000
1001 /**
1002 Unselect all item. This method only has effect if multiple
1003 selections are allowed.
1004 */
1005 void UnselectAll();
1006 };
1007
1008
1009
1010 /**
1011 @class wxDataViewModelNotifier
1012 @wxheader{dataview.h}
1013
1014 A wxDataViewModelNotifier instance is owned by a
1015 wxDataViewModel
1016 and mirrors its notification interface. See
1017 the documentation of that class for further
1018 information.
1019
1020 @library{wxbase}
1021 @category{dvc}
1022 */
1023 class wxDataViewModelNotifier
1024 {
1025 public:
1026 /**
1027 Constructor.
1028 */
1029 wxDataViewModelNotifier();
1030
1031 /**
1032 Destructor.
1033 */
1034 ~wxDataViewModelNotifier();
1035
1036 /**
1037 Called by owning model.
1038 */
1039 bool Cleared();
1040
1041 /**
1042 Get owning wxDataViewModel.
1043 */
1044 wxDataViewModel* GetOwner() const;
1045
1046 /**
1047 Called by owning model.
1048 */
1049 bool ItemAdded(const wxDataViewItem& parent,
1050 const wxDataViewItem& item);
1051
1052 /**
1053 Called by owning model.
1054 */
1055 bool ItemChanged(const wxDataViewItem& item);
1056
1057 /**
1058 Called by owning model.
1059 */
1060 bool ItemDeleted(const wxDataViewItem& parent,
1061 const wxDataViewItem& item);
1062
1063 /**
1064 Called by owning model.
1065 */
1066 bool ItemsAdded(const wxDataViewItem& parent,
1067 const wxDataViewItemArray& items);
1068
1069 /**
1070 Called by owning model.
1071 */
1072 bool ItemsChanged(const wxDataViewItemArray& items);
1073
1074 /**
1075 Called by owning model.
1076 */
1077 bool ItemsDeleted(const wxDataViewItem& parent,
1078 const wxDataViewItemArray& items);
1079
1080 /**
1081 Called by owning model.
1082 */
1083 void Resort();
1084
1085 /**
1086 Set owner of this notifier. Used internally.
1087 */
1088 void SetOwner(wxDataViewModel* owner);
1089
1090 /**
1091 Called by owning model.
1092 */
1093 bool ValueChanged(const wxDataViewItem& item, unsigned int col);
1094 };
1095
1096
1097
1098 /**
1099 @class wxDataViewRenderer
1100 @wxheader{dataview.h}
1101
1102 This class is used by wxDataViewCtrl to render the individual cells.
1103 One instance of a renderer class is owned by a wxDataViewColumn. There
1104 is a number of ready-to-use renderers provided:
1105 wxDataViewTextRenderer,
1106 wxDataViewTextRendererAttr,
1107 wxDataViewIconTextRenderer,
1108 wxDataViewToggleRenderer,
1109 wxDataViewProgressRenderer,
1110 wxDataViewBitmapRenderer,
1111 wxDataViewDateRenderer.
1112 wxDataViewSpinRenderer.
1113
1114 Additionally, the user can write own renderers by deriving from
1115 wxDataViewCustomRenderer.
1116
1117 The @e wxDataViewCellMode flag controls, what actions
1118 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1119 indicates that the user can double click the cell and
1120 something will happen (e.g. a window for editing a date
1121 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1122 that the user can edit the data in-place, i.e. an control
1123 will show up after a slow click on the cell. This behaviour
1124 is best known from changing the filename in most file
1125 managers etc.
1126
1127
1128 @code
1129 enum wxDataViewCellMode
1130 {
1131 wxDATAVIEW_CELL_INERT,
1132 wxDATAVIEW_CELL_ACTIVATABLE,
1133 wxDATAVIEW_CELL_EDITABLE
1134 };
1135 @endcode
1136
1137 The @e wxDataViewCellRenderState flag controls how the
1138 the renderer should display its contents in a cell:
1139
1140 @code
1141 enum wxDataViewCellRenderState
1142 {
1143 wxDATAVIEW_CELL_SELECTED = 1,
1144 wxDATAVIEW_CELL_PRELIT = 2,
1145 wxDATAVIEW_CELL_INSENSITIVE = 4,
1146 wxDATAVIEW_CELL_FOCUSED = 8
1147 };
1148 @endcode
1149
1150
1151 @library{wxadv}
1152 @category{dvc}
1153 */
1154 class wxDataViewRenderer : public wxObject
1155 {
1156 public:
1157 /**
1158 Constructor.
1159 */
1160 wxDataViewRenderer(const wxString& varianttype,
1161 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1162 int align = wxDVR_DEFAULT_ALIGNMENT );
1163
1164 /**
1165 Returns the alignment. See SetAlignment()
1166 */
1167 virtual int GetAlignment() const;
1168
1169 /**
1170 Returns the cell mode.
1171 */
1172 virtual wxDataViewCellMode GetMode();
1173
1174 /**
1175 Returns pointer to the owning wxDataViewColumn.
1176 */
1177 virtual wxDataViewColumn* GetOwner() const;
1178
1179 /**
1180 This methods retrieves the value from the renderer in order to
1181 transfer the value back to the data model. Returns @e @false
1182 on failure.
1183 */
1184 virtual bool GetValue(wxVariant& value);
1185
1186 /**
1187 Returns a string with the type of the wxVariant
1188 supported by this renderer.
1189 */
1190 virtual wxString GetVariantType();
1191
1192 /**
1193 Sets the alignment of the renderer's content. The default value
1194 of wxDVR_DEFAULT_ALIGMENT indicates that the content should
1195 have the same alignment as the column header. The method is
1196 not implemented under OS X and the renderer always aligns its
1197 contents as the column header on that platform. The other platforms
1198 support both vertical and horizontal alignment.
1199 */
1200 virtual void SetAlignment( int align );
1201 /**
1202 Sets the owning wxDataViewColumn. This
1203 is usually called from within wxDataViewColumn.
1204 */
1205 virtual void SetOwner(wxDataViewColumn* owner);
1206
1207 /**
1208 Set the value of the renderer (and thus its cell) to @e value.
1209 The internal code will then render this cell with this data.
1210 */
1211 virtual bool SetValue(const wxVariant& value);
1212
1213 /**
1214 Before data is committed to the data model, it is passed to this
1215 method where it can be checked for validity. This can also be
1216 used for checking a valid range or limiting the user input in
1217 a certain aspect (e.g. max number of characters or only alphanumeric
1218 input, ASCII only etc.). Return @e @false if the value is
1219 not valid.
1220 Please note that due to implementation limitations, this validation
1221 is done after the editing control already is destroyed and the
1222 editing process finished.
1223 */
1224 virtual bool Validate(wxVariant& value);
1225 };
1226
1227
1228
1229 /**
1230 @class wxDataViewTextRenderer
1231 @wxheader{dataview.h}
1232
1233 wxDataViewTextRenderer is used for rendering text. It supports
1234 in-place editing if desired.
1235
1236 @library{wxadv}
1237 @category{dvc}
1238 */
1239 class wxDataViewTextRenderer : public wxDataViewRenderer
1240 {
1241 public:
1242 /**
1243
1244 */
1245 wxDataViewTextRenderer(const wxString& varianttype = "string",
1246 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1247 int align = wxDVR_DEFAULT_ALIGNMENT );
1248 };
1249
1250
1251
1252 /**
1253 @class wxDataViewIconTextRenderer
1254 @wxheader{dataview.h}
1255
1256 The wxDataViewIconTextRenderer class is used to display text with
1257 a small icon next to it as it is typically done in a file manager.
1258 This classes uses the wxDataViewIconText
1259 helper class to store its data. wxDataViewIonText can be converted
1260 to a from a wxVariant using the left shift
1261 operator.
1262
1263 @library{wxadv}
1264 @category{dvc}
1265 */
1266 class wxDataViewIconTextRenderer : public wxDataViewRenderer
1267 {
1268 public:
1269 /**
1270
1271 */
1272 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
1273 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1274 int align = wxDVR_DEFAULT_ALIGNMENT );
1275 };
1276
1277
1278
1279 /**
1280 @class wxDataViewProgressRenderer
1281 @wxheader{dataview.h}
1282
1283 wxDataViewProgressRenderer
1284
1285 @library{wxadv}
1286 @category{dvc}
1287 */
1288 class wxDataViewProgressRenderer : public wxDataViewRenderer
1289 {
1290 public:
1291 /**
1292
1293 */
1294 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1295 const wxString& varianttype = "long",
1296 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1297 int align = wxDVR_DEFAULT_ALIGNMENT );
1298 };
1299
1300
1301
1302 /**
1303 @class wxDataViewSpinRenderer
1304 @wxheader{dataview.h}
1305
1306 This is a specialized renderer for rendering integer values. It
1307 supports modifying the values in-place by using a wxSpinCtrl.
1308 The renderer only support variants of type @e long.
1309
1310 @library{wxbase}
1311 @category{dvc}
1312 */
1313 class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1314 {
1315 public:
1316 /**
1317 Constructor. @a min and @a max indicate the minimum und
1318 maximum values of for the wxSpinCtrl.
1319 */
1320 wxDataViewSpinRenderer(int min, int max,
1321 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1322 int align = wxDVR_DEFAULT_ALIGNMENT);
1323 };
1324
1325
1326
1327 /**
1328 @class wxDataViewToggleRenderer
1329 @wxheader{dataview.h}
1330
1331 wxDataViewToggleRenderer
1332
1333 @library{wxadv}
1334 @category{dvc}
1335 */
1336 class wxDataViewToggleRenderer : public wxDataViewRenderer
1337 {
1338 public:
1339 /**
1340
1341 */
1342 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
1343 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT);
1344 };
1345
1346
1347
1348 /**
1349 @class wxDataViewDateRenderer
1350 @wxheader{dataview.h}
1351
1352 wxDataViewDateRenderer
1353
1354 @library{wxadv}
1355 @category{dvc}
1356 */
1357 class wxDataViewDateRenderer : public wxDataViewRenderer
1358 {
1359 public:
1360 /**
1361
1362 */
1363 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
1364 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE);
1365 };
1366
1367
1368
1369 /**
1370 @class wxDataViewTextRendererAttr
1371 @wxheader{dataview.h}
1372
1373 The same as wxDataViewTextRenderer but with
1374 support for font attributes. Font attributes are currently only supported
1375 under GTK+ and MSW.
1376
1377 See also wxDataViewModel::GetAttr and
1378 wxDataViewItemAttr.
1379
1380 @library{wxadv}
1381 @category{dvc}
1382 */
1383 class wxDataViewTextRendererAttr : public wxDataViewTextRenderer
1384 {
1385 public:
1386 /**
1387
1388 */
1389 wxDataViewTextRendererAttr(const wxString& varianttype = "string",
1390 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1391 int align = wxDVR_DEFAULT_ALIGNMENT);
1392 };
1393
1394
1395
1396 /**
1397 @class wxDataViewCustomRenderer
1398 @wxheader{dataview.h}
1399
1400 You need to derive a new class from wxDataViewCustomRenderer in
1401 order to write a new renderer. You need to override at least
1402 wxDataViewRenderer::SetValue,
1403 wxDataViewRenderer::GetValue,
1404 wxDataViewCustomRenderer::GetSize
1405 and wxDataViewCustomRenderer::Render.
1406
1407 If you want your renderer to support in-place editing then you
1408 also need to override
1409 wxDataViewCustomRenderer::HasEditorCtrl,
1410 wxDataViewCustomRenderer::CreateEditorCtrl
1411 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1412 Note that a special event handler will be pushed onto that
1413 editor control which handles ENTER and focus out events
1414 in order to end the editing.
1415
1416 @library{wxadv}
1417 @category{dvc}
1418 */
1419 class wxDataViewCustomRenderer : public wxDataViewRenderer
1420 {
1421 public:
1422 /**
1423 Constructor.
1424 */
1425 wxDataViewCustomRenderer(const wxString& varianttype = "string",
1426 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1427 int align = wxDVR_DEFAULT_ALIGNMENT );
1428
1429 /**
1430 Destructor.
1431 */
1432 ~wxDataViewCustomRenderer();
1433
1434 /**
1435 Override this to react to double clicks or ENTER. This method will
1436 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1437 */
1438 virtual bool Activate( wxRect cell,
1439 wxDataViewModel* model,
1440 const wxDataViewItem & item,
1441 unsigned int col );
1442
1443 /**
1444 Override this to create the actual editor control once editing
1445 is about to start. @a parent is the parent of the editor
1446 control, @a labelRect indicates the position and
1447 size of the editor control and @a value is its initial value:
1448 */
1449 virtual wxControl* CreateEditorCtrl(wxWindow* parent,
1450 wxRect labelRect,
1451 const wxVariant& value);
1452
1453 /**
1454 Create DC on request. Internal.
1455 */
1456 virtual wxDC* GetDC();
1457
1458 /**
1459 Return size required to show content.
1460 */
1461 virtual wxSize GetSize();
1462
1463 /**
1464 Overrride this so that the renderer can get the value
1465 from the editor control (pointed to by @e editor):
1466 */
1467 virtual bool GetValueFromEditorCtrl(wxControl* editor,
1468 wxVariant& value);
1469
1470 /**
1471 Override this and make it return @e @true in order to
1472 indicate that this renderer supports in-place editing.
1473 */
1474 virtual bool HasEditorCtrl();
1475
1476 /**
1477 Overrride this to react to a left click. This method will
1478 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1479 */
1480 virtual bool LeftClick( wxPoint cursor,
1481 wxRect cell,
1482 wxDataViewModel * model,
1483 const wxDataViewItem & item,
1484 unsigned int col );
1485
1486 /**
1487 Override this to render the cell. Before this is called,
1488 wxDataViewRenderer::SetValue was called
1489 so that this instance knows what to render.
1490 */
1491 virtual bool Render(wxRect cell, wxDC* dc, int state);
1492
1493 /**
1494 This method should be called from within Render()
1495 whenever you need to render simple text. This will ensure that the
1496 correct colour, font and vertical alignment will be chosen so the
1497 text will look the same as text drawn by native renderers.
1498 */
1499 bool RenderText(const wxString& text, int xoffset, wxRect cell,
1500 wxDC* dc, int state);
1501
1502 /**
1503 Overrride this to start a drag operation. Not yet
1504 supported
1505 */
1506 virtual bool StartDrag(wxPoint cursor, wxRect cell,
1507 wxDataViewModel* model,
1508 const wxDataViewItem & item,
1509 unsigned int col);
1510 };
1511
1512
1513
1514 /**
1515 @class wxDataViewBitmapRenderer
1516 @wxheader{dataview.h}
1517
1518 wxDataViewBitmapRenderer
1519
1520 @library{wxadv}
1521 @category{dvc}
1522 */
1523 class wxDataViewBitmapRenderer : public wxDataViewRenderer
1524 {
1525 public:
1526 /**
1527
1528 */
1529 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
1530 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1531 int align = wxDVR_DEFAULT_ALIGNMENT,
1532 };
1533
1534
1535
1536 /**
1537 @class wxDataViewColumn
1538 @wxheader{dataview.h}
1539
1540 This class represents a column in a wxDataViewCtrl.
1541 One wxDataViewColumn is bound to one column in the data model,
1542 to which the wxDataViewCtrl has been associated.
1543
1544 An instance of wxDataViewRenderer is used by
1545 this class to render its data.
1546
1547 @library{wxadv}
1548 @category{dvc}
1549 */
1550 class wxDataViewColumn : public wxObject
1551 {
1552 public:
1553 //@{
1554 /**
1555 Constructors.
1556 */
1557 wxDataViewColumn(const wxString& title,
1558 wxDataViewRenderer* renderer,
1559 unsigned int model_column,
1560 int width = wxDVC_DEFAULT_WIDTH,
1561 wxAlignment align = wxALIGN_CENTRE,
1562 int flags = wxDATAVIEW_COL_RESIZABLE);
1563 wxDataViewColumn(const wxBitmap& bitmap,
1564 wxDataViewRenderer* renderer,
1565 unsigned int model_column,
1566 int width = wxDVC_DEFAULT_WIDTH,
1567 wxAlignment align = wxALIGN_CENTRE,
1568 int flags = wxDATAVIEW_COL_RESIZABLE);
1569 //@}
1570
1571 /**
1572 Destructor.
1573 */
1574 ~wxDataViewColumn();
1575
1576 /**
1577 Returns the bitmap in the header of the column, if any.
1578 */
1579 const wxBitmap GetBitmap();
1580
1581 /**
1582 Returns the index of the column of the model, which this
1583 wxDataViewColumn is displaying.
1584 */
1585 unsigned int GetModelColumn();
1586
1587 /**
1588 Returns the owning wxDataViewCtrl.
1589 */
1590 wxDataViewCtrl* GetOwner() const;
1591
1592 /**
1593 Returns the renderer of this wxDataViewColumn.
1594 See also wxDataViewRenderer.
1595 */
1596 wxDataViewRenderer* GetRenderer();
1597
1598 /**
1599 Returns @true if the column is reorderable.
1600 */
1601 bool GetReorderable();
1602
1603 /**
1604 Returns @true if the column is sortable.
1605 See SetSortable()
1606 */
1607 bool GetSortable();
1608
1609 /**
1610 Returns the width of the column.
1611 */
1612 int GetWidth();
1613
1614 /**
1615 Returns @true, if the sort order is ascending.
1616 See also SetSortOrder()
1617 */
1618 bool IsSortOrderAscending();
1619
1620 /**
1621 Set the alignment of the column header.
1622 */
1623 void SetAlignment(wxAlignment align);
1624
1625 /**
1626 Set the bitmap of the column header.
1627 */
1628 void SetBitmap(const wxBitmap& bitmap);
1629
1630 /**
1631 Indicate wether the column can be reordered by the
1632 user using the mouse. This is typically implemented
1633 visually by dragging the header button around.
1634 */
1635 void SetReorderable(bool reorderable);
1636
1637 /**
1638 Indicate the sort order if the implementation of the
1639 wxDataViewCtrl supports it, most commonly by showing
1640 a little arrow.
1641 */
1642 void SetSortOrder(bool ascending);
1643
1644 /**
1645 Indicate that the column is sortable. This does
1646 not show any sorting indicate yet, but it does
1647 make the column header clickable. Call
1648 SetSortOrder()
1649 afterwards to actually make the sort indicator appear.
1650 If @a sortable is @false, the column header is
1651 no longer clickable and the sort indicator (little
1652 arrow) will disappear.
1653 */
1654 void SetSortable(bool sortable);
1655
1656 /**
1657 Set the title of the column header to @e title.
1658 */
1659 void SetTitle(const wxString& title);
1660 };
1661
1662
1663
1664 /**
1665 @class wxDataViewTreeCtrl
1666 @wxheader{dataview.h}
1667
1668 This class is a wxDataViewCtrl which internally
1669 uses a wxDataViewTreeStore and forwards
1670 most of its API to that class. Additionally, it uses a wxImageList
1671 to store a list of icons. The main purpose of this class is to look
1672 like a wxTreeCtrl to make a transition from it
1673 to the wxDataViewCtrl class simpler.
1674
1675 @library{wxbase}
1676 @category{ctrl,dvc}
1677 <!-- @appearance{dataviewtreectrl.png} -->
1678 */
1679 class wxDataViewTreeCtrl : public wxDataViewCtrl
1680 {
1681 public:
1682 //@{
1683 /**
1684 Constructor. Calls Create().
1685 */
1686 wxDataViewTreeCtrl();
1687 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
1688 const wxPoint& pos = wxDefaultPosition,
1689 const wxSize& size = wxDefaultSize,
1690 long style = wxDV_NO_HEADER,
1691 const wxValidator& validator = wxDefaultValidator);
1692 //@}
1693
1694 /**
1695 Destructor. Deletes the image list if any.
1696 */
1697 ~wxDataViewTreeCtrl();
1698
1699 /**
1700
1701 */
1702 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
1703 const wxString& text,
1704 int icon = -1,
1705 int expanded = -1,
1706 wxClientData* data = NULL);
1707
1708 /**
1709
1710 */
1711 wxDataViewItem AppendItem(const wxDataViewItem& parent,
1712 const wxString& text,
1713 int icon = -1,
1714 wxClientData* data = NULL);
1715
1716 /**
1717 Creates the control and a wxDataViewTreeStore as
1718 its internal model.
1719 */
1720 bool Create(wxWindow* parent, wxWindowID id,
1721 const wxPoint& pos = wxDefaultPosition,
1722 const wxSize& size = wxDefaultSize,
1723 long style = wxDV_NO_HEADER,
1724 const wxValidator& validator = wxDefaultValidator);
1725
1726 /**
1727 Calls the identical method from wxDataViewTreeStore.
1728 */
1729 void DeleteAllItems();
1730
1731 /**
1732 Calls the identical method from wxDataViewTreeStore.
1733 */
1734 void DeleteChildren(const wxDataViewItem& item);
1735
1736 /**
1737 Calls the identical method from wxDataViewTreeStore.
1738 */
1739 void DeleteItem(const wxDataViewItem& item);
1740
1741 /**
1742 Calls the identical method from wxDataViewTreeStore.
1743 */
1744 int GetChildCount(const wxDataViewItem& parent) const;
1745
1746 /**
1747 Returns the image list.
1748 */
1749 wxImageList* GetImageList();
1750
1751 /**
1752 Calls the identical method from wxDataViewTreeStore.
1753 */
1754 wxClientData* GetItemData(const wxDataViewItem& item) const;
1755
1756 /**
1757 Calls the identical method from wxDataViewTreeStore.
1758 */
1759 const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
1760
1761 /**
1762 Calls the identical method from wxDataViewTreeStore.
1763 */
1764 const wxIcon GetItemIcon(const wxDataViewItem& item) const;
1765
1766 /**
1767 Calls the identical method from wxDataViewTreeStore.
1768 */
1769 wxString GetItemText(const wxDataViewItem& item) const;
1770
1771 /**
1772 Calls the identical method from wxDataViewTreeStore.
1773 */
1774 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
1775 unsigned int pos) const;
1776
1777 //@{
1778 /**
1779 Returns the store.
1780 */
1781 wxDataViewTreeStore* GetStore() const;
1782 const wxDataViewTreeStore* GetStore() const;
1783 //@}
1784
1785 /**
1786 Calls the same method from wxDataViewTreeStore but uess
1787 and index position in the image list instead of a wxIcon.
1788 */
1789 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
1790 const wxDataViewItem& previous,
1791 const wxString& text,
1792 int icon = -1,
1793 int expanded = -1,
1794 wxClientData* data = NULL);
1795
1796 /**
1797 Calls the same method from wxDataViewTreeStore but uess
1798 and index position in the image list instead of a wxIcon.
1799 */
1800 wxDataViewItem InsertItem(const wxDataViewItem& parent,
1801 const wxDataViewItem& previous,
1802 const wxString& text,
1803 int icon = -1,
1804 wxClientData* data = NULL);
1805
1806 /**
1807 Calls the same method from wxDataViewTreeStore but uess
1808 and index position in the image list instead of a wxIcon.
1809 */
1810 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
1811 const wxString& text,
1812 int icon = -1,
1813 int expanded = -1,
1814 wxClientData* data = NULL);
1815
1816 /**
1817 Calls the same method from wxDataViewTreeStore but uess
1818 and index position in the image list instead of a wxIcon.
1819 */
1820 wxDataViewItem PrependItem(const wxDataViewItem& parent,
1821 const wxString& text,
1822 int icon = -1,
1823 wxClientData* data = NULL);
1824
1825 /**
1826 Sets the image list.
1827 */
1828 void SetImageList(wxImageList* imagelist);
1829
1830 /**
1831 Calls the identical method from wxDataViewTreeStore.
1832 */
1833 void SetItemData(const wxDataViewItem& item, wxClientData* data);
1834
1835 /**
1836 Calls the identical method from wxDataViewTreeStore.
1837 */
1838 void SetItemExpandedIcon(const wxDataViewItem& item,
1839 const wxIcon& icon);
1840
1841 /**
1842 Calls the identical method from wxDataViewTreeStore.
1843 */
1844 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
1845
1846 /**
1847 Calls the identical method from wxDataViewTreeStore.
1848 */
1849 void SetItemText(const wxDataViewItem& item,
1850 const wxString& text);
1851 };
1852
1853
1854
1855 /**
1856 @class wxDataViewTreeStore
1857 @wxheader{dataview.h}
1858
1859 wxDataViewTreeStore is a specialised wxDataViewModel
1860 for displaying simple trees very much like wxTreeCtrl
1861 does and it offers a similar API. This class actually stores the entire
1862 tree (therefore its name) and implements all virtual methods from the base
1863 class so it can be used directly without having to derive any class from it.
1864 This comes at the price of much reduced flexibility.
1865
1866 @library{wxadv}
1867 @category{dvc}
1868 */
1869 class wxDataViewTreeStore : public wxDataViewModel
1870 {
1871 public:
1872 /**
1873 Constructor. Creates the invisible root node internally.
1874 */
1875 wxDataViewTreeStore();
1876
1877 /**
1878 Destructor.
1879 */
1880 ~wxDataViewTreeStore();
1881
1882 /**
1883 Append a container.
1884 */
1885 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
1886 const wxString& text,
1887 const wxIcon& icon = wxNullIcon,
1888 const wxIcon& expanded = wxNullIcon,
1889 wxClientData* data = NULL);
1890
1891 /**
1892 Append an item.
1893 */
1894 wxDataViewItem AppendItem(const wxDataViewItem& parent,
1895 const wxString& text,
1896 const wxIcon& icon = wxNullIcon,
1897 wxClientData* data = NULL);
1898
1899 /**
1900 Delete all item in the model.
1901 */
1902 void DeleteAllItems();
1903
1904 /**
1905 Delete all children of the item, but not the item itself.
1906 */
1907 void DeleteChildren(const wxDataViewItem& item);
1908
1909 /**
1910 Delete this item.
1911 */
1912 void DeleteItem(const wxDataViewItem& item);
1913
1914 /**
1915 Return the number of children of item.
1916 */
1917 int GetChildCount(const wxDataViewItem& parent) const;
1918
1919 /**
1920 Returns the client data asoociated with the item.
1921 */
1922 wxClientData* GetItemData(const wxDataViewItem& item) const;
1923
1924 /**
1925 Returns the icon to display in expanded containers.
1926 */
1927 const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
1928
1929 /**
1930 Returns the icon of the item.
1931 */
1932 const wxIcon GetItemIcon(const wxDataViewItem& item) const;
1933
1934 /**
1935 Returns the text of the item.
1936 */
1937 wxString GetItemText(const wxDataViewItem& item) const;
1938
1939 /**
1940 Returns the nth child item of item.
1941 */
1942 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
1943 unsigned int pos) const;
1944
1945 /**
1946 Inserts a container after @e previous.
1947 */
1948 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
1949 const wxDataViewItem& previous,
1950 const wxString& text,
1951 const wxIcon& icon = wxNullIcon,
1952 const wxIcon& expanded = wxNullIcon,
1953 wxClientData* data = NULL);
1954
1955 /**
1956 Inserts an item after @e previous.
1957 */
1958 wxDataViewItem InsertItem(const wxDataViewItem& parent,
1959 const wxDataViewItem& previous,
1960 const wxString& text,
1961 const wxIcon& icon = wxNullIcon,
1962 wxClientData* data = NULL);
1963
1964 /**
1965 Inserts a container before the first child item or @e parent.
1966 */
1967 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
1968 const wxString& text,
1969 const wxIcon& icon = wxNullIcon,
1970 const wxIcon& expanded = wxNullIcon,
1971 wxClientData* data = NULL);
1972
1973 /**
1974 Inserts an item before the first child item or @e parent.
1975 */
1976 wxDataViewItem PrependItem(const wxDataViewItem& parent,
1977 const wxString& text,
1978 const wxIcon& icon = wxNullIcon,
1979 wxClientData* data = NULL);
1980
1981 /**
1982 Sets the client data associated with the item.
1983 */
1984 void SetItemData(const wxDataViewItem& item, wxClientData* data);
1985
1986 /**
1987 Sets the expanded icon for the item.
1988 */
1989 void SetItemExpandedIcon(const wxDataViewItem& item,
1990 const wxIcon& icon);
1991
1992 /**
1993 Sets the icon for the item.
1994 */
1995 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
1996 };
1997