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