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