1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @class wxDataViewModel
13 wxDataViewModel is the base class for all data model to be displayed by a
16 All other models derive from it and must implement its pure virtual functions
17 in order to define a complete data model. In detail, you need to override
18 wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren,
19 wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and
20 wxDataViewModel::GetValue in order to define the data model which acts as an
21 interface between your actual data and the wxDataViewCtrl.
23 Since you will usually also allow the wxDataViewCtrl to change your data
24 through its graphical interface, you will also have to override
25 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
26 to some data has been commited.
28 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
29 to store data and its type in a generic way. wxVariant can be extended to contain
30 almost any data without changes to the original class.
32 The data that is presented through this data model is expected to change at
33 run-time. You need to inform the data model when a change happened.
34 Depending on what happened you need to call one of the following methods:
35 - wxDataViewModel::ValueChanged,
36 - wxDataViewModel::ItemAdded,
37 - wxDataViewModel::ItemDeleted,
38 - wxDataViewModel::ItemChanged,
39 - wxDataViewModel::Cleared.
41 There are plural forms for notification of addition, change or removal of
42 several item at once. See:
43 - wxDataViewModel::ItemsAdded,
44 - wxDataViewModel::ItemsDeleted,
45 - wxDataViewModel::ItemsChanged.
47 Note that wxDataViewModel does not define the position or index of any item
48 in the control because different controls might display the same data differently.
49 wxDataViewModel does provide a wxDataViewModel::Compare method which the
50 wxDataViewCtrl may use to sort the data either in conjunction with a column
51 header or without (see wxDataViewModel::HasDefaultCompare).
53 This class maintains a list of wxDataViewModelNotifier which link this class
54 to the specific implementations on the supported platforms so that e.g. calling
55 wxDataViewModel::ValueChanged on this model will just call
56 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
57 You can also add your own notifier in order to get informed about any changes
58 to the data in the list model.
60 Currently wxWidgets provides the following models apart from the base model:
61 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
64 Note that wxDataViewModel is reference counted, derives from wxObjectRefData
65 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
66 This implies that you need to decrease the reference count after
67 associating the model with a control like this:
70 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
71 wxDataViewModel *musicModel = new MyMusicModel;
72 m_musicCtrl-AssociateModel( musicModel );
73 musicModel-DecRef(); // avoid memory leak !!
81 class wxDataViewModel
: public wxObjectRefData
90 Adds a wxDataViewModelNotifier to the model.
92 void AddNotifier(wxDataViewModelNotifier
* notifier
);
95 Called to inform the model that all data has been cleared.
96 The control will reread the data from the model again.
98 virtual bool Cleared();
101 The compare function to be used by control. The default compare function
102 sorts by container and other items separately and in ascending order.
103 Override this for a different sorting behaviour.
105 @see HasDefaultCompare().
107 virtual int Compare(const wxDataViewItem
& item1
,
108 const wxDataViewItem
& item2
,
113 Override this to indicate that the item has special font attributes.
114 This only affects the wxDataViewTextRendererText renderer.
116 @see wxDataViewItemAttr.
118 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
119 wxDataViewItemAttr
& attr
);
122 Override this so the control can query the child items of an item.
123 Returns the number of items.
125 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
126 wxDataViewItemArray
& children
) const = 0;
129 Override this to indicate the number of columns in the model.
131 virtual unsigned int GetColumnCount() const = 0;
134 Override this to indicate what type of data is stored in the
135 column specified by @a col.
137 This should return a string indicating the type of data as reported by wxVariant.
139 virtual wxString
GetColumnType(unsigned int col
) const = 0;
142 Override this to indicate which wxDataViewItem representing the parent
143 of @a item or an invalid wxDataViewItem if the the root item is
146 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
149 Override this to indicate the value of @a item.
150 A wxVariant is used to store the data.
152 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
153 unsigned int col
) const = 0;
156 Override this method to indicate if a container item merely acts as a
157 headline (or for categorisation) or if it also acts a normal item with
158 entries for futher columns. By default returns @false.
160 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
163 Override this to indicate that the model provides a default compare
164 function that the control should use if no wxDataViewColumn has been
165 chosen for sorting. Usually, the user clicks on a column header for
166 sorting, the data will be sorted alphanumerically.
168 If any other order (e.g. by index or order of appearance) is required,
169 then this should be used.
170 See wxDataViewIndexListModel for a model which makes use of this.
172 virtual bool HasDefaultCompare() const;
175 Override this to indicate of @a item is a container, i.e. if
176 it can have child items.
178 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
181 Call this to inform the model that an item has been added to the data.
183 virtual bool ItemAdded(const wxDataViewItem
& parent
,
184 const wxDataViewItem
& item
);
187 Call this to inform the model that an item has changed.
189 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
190 event (in which the column fields will not be set) to the user.
192 virtual bool ItemChanged(const wxDataViewItem
& item
);
195 Call this to inform the model that an item has been deleted from the data.
197 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
198 const wxDataViewItem
& item
);
201 Call this to inform the model that several items have been added to the data.
203 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
204 const wxDataViewItemArray
& items
);
207 Call this to inform the model that several items have changed.
209 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
210 events (in which the column fields will not be set) to the user.
212 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
215 Call this to inform the model that several items have been deleted.
217 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
218 const wxDataViewItemArray
& items
);
221 Remove the @a notifier from the list of notifiers.
223 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
226 Call this to initiate a resort after the sort function has been changed.
228 virtual void Resort();
231 This gets called in order to set a value in the data model.
232 The most common scenario is that the wxDataViewCtrl calls this method
233 after the user changed some data in the view.
235 Afterwards ValueChanged() has to be called!
237 virtual bool SetValue(const wxVariant
& variant
, const wxDataViewItem
& item
,
238 unsigned int col
) = 0;
241 Call this to inform this model that a value in the model has been changed.
242 This is also called from wxDataViewCtrl's internal editing code, e.g. when
243 editing a text field in the control.
245 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
248 virtual bool ValueChanged(const wxDataViewItem
& item
,
254 Destructor. This should not be called directly. Use DecRef() instead.
256 virtual ~wxDataViewModel();
262 @class wxDataViewIndexListModel
264 wxDataViewIndexListModel is a specialized data model which lets you address
265 an item by its position (row) rather than its wxDataViewItem (which you can
266 obtain from this class).
267 This model also provides its own wxDataViewIndexListModel::Compare
268 method which sorts the model's data by the index.
270 This model is not a virtual model since the control stores each wxDataViewItem.
271 Use wxDataViewVirtualListModel if you need to display millions of items or
272 have other reason to use a virtual control.
277 class wxDataViewIndexListModel
: public wxDataViewModel
283 wxDataViewIndexListModel(unsigned int initial_size
= 0);
288 virtual ~wxDataViewIndexListModel();
291 Compare method that sorts the items by their index.
293 int Compare(const wxDataViewItem
& item1
,
294 const wxDataViewItem
& item2
,
295 unsigned int column
, bool ascending
);
298 Override this to indicate that the row has special font attributes.
299 This only affects the wxDataViewTextRendererText() renderer.
301 @see wxDataViewItemAttr.
303 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
304 wxDataViewItemAttr
& attr
);
307 Returns the wxDataViewItem at the given @e row.
309 wxDataViewItem
GetItem(unsigned int row
) const;
312 Returns the position of given @e item.
314 unsigned int GetRow(const wxDataViewItem
& item
) const;
317 Override this to allow getting values from the model.
319 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
320 unsigned int col
) const = 0;
323 Call this after if the data has to be read again from the model.
324 This is useful after major changes when calling the methods below
325 (possibly thousands of times) doesn't make sense.
327 void Reset(unsigned int new_size
);
330 Call this after a row has been appended to the model.
335 Call this after a row has been changed.
337 void RowChanged(unsigned int row
);
340 Call this after a row has been deleted.
342 void RowDeleted(unsigned int row
);
345 Call this after a row has been inserted at the given position.
347 void RowInserted(unsigned int before
);
350 Call this after a row has been prepended to the model.
355 Call this after a value has been changed.
357 void RowValueChanged(unsigned int row
, unsigned int col
);
360 Call this after rows have been deleted.
361 The array will internally get copied and sorted in descending order so
362 that the rows with the highest position will be deleted first.
364 void RowsDeleted(const wxArrayInt
& rows
);
367 Called in order to set a value in the model.
369 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
370 unsigned int col
) = 0;
376 @class wxDataViewVirtualListModel
378 wxDataViewVirtualListModel is a specialized data model which lets you address
379 an item by its position (row) rather than its wxDataViewItem and as such offers
380 the exact same interface as wxDataViewIndexListModel.
381 The important difference is that under platforms other than OS X, using this
382 model will result in a truly virtual control able to handle millions of items
383 as the control doesn't store any item (a feature not supported by the
384 Carbon API under OS X).
386 @see wxDataViewIndexListModel for the API.
391 class wxDataViewVirtualListModel
: public wxDataViewModel
397 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
403 @class wxDataViewItemAttr
405 This class is used to indicate to a wxDataViewCtrl that a certain item
406 (see wxDataViewItem) has extra font attributes for its renderer.
407 For this, it is required to override wxDataViewModel::GetAttr.
409 Attributes are currently only supported by wxDataViewTextRendererText.
414 class wxDataViewItemAttr
420 wxDataViewItemAttr();
423 Call this to indicate that the item shall be displayed in bold text.
425 void SetBold(bool set
);
428 Call this to indicate that the item shall be displayed with that colour.
430 void SetColour(const wxColour
& colour
);
433 Call this to indicate that the item shall be displayed in italic text.
435 void SetItalic(bool set
);
441 @class wxDataViewItem
443 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
444 in a persistent way, i.e. indepent of the position of the item in the control
445 or changes to its contents.
447 It must hold a unique ID of type @e void* in its only field and can be converted
450 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
451 return @false which used in many places in the API of wxDataViewCtrl to
452 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
453 the invisible root. Examples for this are wxDataViewModel::GetParent and
454 wxDataViewModel::GetChildren.
466 wxDataViewItem(void* id
= NULL
);
467 wxDataViewItem(const wxDataViewItem
& item
);
476 Returns @true if the ID is not @NULL.
484 @class wxDataViewCtrl
486 wxDataViewCtrl is a control to display data either in a tree like fashion or
487 in a tabular form or both.
489 If you only need to display a simple tree structure with an API more like the
490 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
491 Likewise, if you only want to display simple table structure you can use
492 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
493 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
495 A wxDataViewItem is used to represent a (visible) item in the control.
497 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
498 virtual functions or by setting it directly. Instead you need to write your own
499 wxDataViewModel and associate it with this control.
500 Then you need to add a number of wxDataViewColumn to this control to define
501 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
502 of a wxDataViewRenderer to render its cells.
504 A number of standard renderers for rendering text, dates, images, toggle,
505 a progress bar etc. are provided. Additionally, the user can write custom
506 renderers deriving from wxDataViewCustomRenderer for displaying anything.
508 All data transfer from the control to the model and the user code is done
509 through wxVariant which can be extended to support more data formats as necessary.
510 Accordingly, all type information uses the strings returned from wxVariant::GetType.
514 Single selection mode. This is the default.
515 @style{wxDV_MULTIPLE}
516 Multiple selection mode.
517 @style{wxDV_ROW_LINES}
518 Use alternating colours for rows if supported by platform and theme.
519 @style{wxDV_HORIZ_RULES}
520 Display fine rules between row if supported.
521 @style{wxDV_VERT_RULES}
522 Display fine rules between columns is supported.
523 @style{wxDV_VARIABLE_LINE_HEIGHT}
524 Allow variable line heights.
525 This can be inefficient when displaying large number of items.
528 @beginEventTable{wxDataViewEvent}
529 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
530 Process a wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
531 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
532 Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
533 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
534 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
535 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
536 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
537 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
538 Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
539 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
540 Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
541 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
542 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
543 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
544 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
545 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
546 Process a wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
547 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
548 Process a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
549 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
550 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
551 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
552 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
553 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
554 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
555 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
556 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
561 @appearance{dataviewctrl.png}
563 class wxDataViewCtrl
: public wxControl
572 Constructor. Calls Create().
574 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
575 const wxPoint
& pos
= wxDefaultPosition
,
576 const wxSize
& size
= wxDefaultSize
,
578 const wxValidator
& validator
= wxDefaultValidator
);
583 virtual ~wxDataViewCtrl();
586 Appends a wxDataViewColumn to the control. Returns @true on success.
588 Note that there is a number of short cut methods which implicitly create
589 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
591 virtual bool AppendColumn(wxDataViewColumn
* col
);
594 Prepends a wxDataViewColumn to the control. Returns @true on success.
596 Note that there is a number of short cut methods which implicitly create
597 a wxDataViewColumn and a wxDataViewRenderer for it.
599 virtual bool PrependColumn(wxDataViewColumn
* col
);
602 Inserts a wxDataViewColumn to the control. Returns @true on success.
604 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
608 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
609 created in the function or @NULL on failure.
611 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
612 unsigned int model_column
,
613 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
615 wxAlignment align
= wxALIGN_CENTER
,
616 int flags
= wxDATAVIEW_COL_RESIZABLE
);
617 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
618 unsigned int model_column
,
619 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
621 wxAlignment align
= wxALIGN_CENTER
,
622 int flags
= wxDATAVIEW_COL_RESIZABLE
);
627 Appends a column for rendering a date. Returns the wxDataViewColumn
628 created in the function or @NULL on failure.
630 @note The @a align parameter is applied to both the column header and
633 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
634 unsigned int model_column
,
635 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
637 wxAlignment align
= wxALIGN_NOT
,
638 int flags
= wxDATAVIEW_COL_RESIZABLE
);
639 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
640 unsigned int model_column
,
641 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
643 wxAlignment align
= wxALIGN_NOT
,
644 int flags
= wxDATAVIEW_COL_RESIZABLE
);
649 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
650 created in the function or @NULL on failure.
651 This method uses the wxDataViewIconTextRenderer class.
653 @note The @a align parameter is applied to both the column header and
656 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
657 unsigned int model_column
,
658 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
660 wxAlignment align
= wxALIGN_NOT
,
661 int flags
= wxDATAVIEW_COL_RESIZABLE
);
662 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
663 unsigned int model_column
,
664 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
666 wxAlignment align
= wxALIGN_NOT
,
667 int flags
= wxDATAVIEW_COL_RESIZABLE
);
672 Appends a column for rendering a progress indicator. Returns the
673 wxDataViewColumn created in the function or @NULL on failure.
675 @note The @a align parameter is applied to both the column header and
678 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
679 unsigned int model_column
,
680 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
682 wxAlignment align
= wxALIGN_CENTER
,
683 int flags
= wxDATAVIEW_COL_RESIZABLE
);
684 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
685 unsigned int model_column
,
686 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
688 wxAlignment align
= wxALIGN_CENTER
,
689 int flags
= wxDATAVIEW_COL_RESIZABLE
);
694 Appends a column for rendering text. Returns the wxDataViewColumn
695 created in the function or @NULL on failure.
697 @note The @a align parameter is applied to both the column header and
700 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
701 unsigned int model_column
,
702 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
704 wxAlignment align
= wxALIGN_NOT
,
705 int flags
= wxDATAVIEW_COL_RESIZABLE
);
706 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
707 unsigned int model_column
,
708 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
710 wxAlignment align
= wxALIGN_NOT
,
711 int flags
= wxDATAVIEW_COL_RESIZABLE
);
716 Appends a column for rendering a toggle. Returns the wxDataViewColumn
717 created in the function or @NULL on failure.
719 @note The @a align parameter is applied to both the column header and
722 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
723 unsigned int model_column
,
724 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
726 wxAlignment align
= wxALIGN_CENTER
,
727 int flags
= wxDATAVIEW_COL_RESIZABLE
);
728 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
729 unsigned int model_column
,
730 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
732 wxAlignment align
= wxALIGN_CENTER
,
733 int flags
= wxDATAVIEW_COL_RESIZABLE
);
737 Associates a wxDataViewModel with the control.
738 This increases the reference count of the model by 1.
740 virtual bool AssociateModel(wxDataViewModel
* model
);
745 virtual bool ClearColumns();
750 virtual void Collapse(const wxDataViewItem
& item
);
753 Create the control. Useful for two step creation.
755 bool Create(wxWindow
* parent
, wxWindowID id
,
756 const wxPoint
& pos
= wxDefaultPosition
,
757 const wxSize
& size
= wxDefaultSize
,
759 const wxValidator
& validator
= wxDefaultValidator
);
762 Deletes given column.
764 virtual bool DeleteColumn(wxDataViewColumn
* column
);
767 Call this to ensure that the given item is visible.
769 virtual void EnsureVisible(const wxDataViewItem
& item
,
770 const wxDataViewColumn
* column
= NULL
);
775 virtual void Expand(const wxDataViewItem
& item
);
778 Expands all ancestors of the @a item. This method also
779 ensures that the item itself as well as all ancestor
780 items have been read from the model by the control.
782 virtual void ExpandAncestors( const wxDataViewItem
& item
);
785 Returns pointer to the column. @a pos refers to the position in the
786 control which may change after reordering columns by the user.
788 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
791 Returns the number of columns.
793 virtual unsigned int GetColumnCount() const;
796 Returns the position of the column or -1 if not found in the control.
798 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
801 Returns column containing the expanders.
803 wxDataViewColumn
* GetExpanderColumn() const;
808 int GetIndent() const;
813 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
814 const wxDataViewColumn
* col
= NULL
) const;
817 Returns pointer to the data model associated with the control (if any).
819 wxDataViewModel
* GetModel();
822 Returns first selected item or an invalid item if none is selected.
824 virtual wxDataViewItem
GetSelection() const;
827 Fills @a sel with currently selected items and returns their number.
829 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
832 Returns the wxDataViewColumn currently responsible for sorting
833 or @NULL if none has been selected.
835 virtual wxDataViewColumn
* GetSortingColumn() const;
840 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
841 wxDataViewColumn
*& col
) const;
844 Return @true if the item is expanded.
846 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
849 Return @true if the item is selected.
851 virtual bool IsSelected(const wxDataViewItem
& item
) const;
854 Select the given item.
856 virtual void Select(const wxDataViewItem
& item
);
861 virtual void SelectAll();
864 Set which column shall contain the tree-like expanders.
866 void SetExpanderColumn(wxDataViewColumn
* col
);
869 Sets the indendation.
871 void SetIndent(int indent
);
874 Sets the selection to the array of wxDataViewItems.
876 virtual void SetSelections(const wxDataViewItemArray
& sel
);
879 Unselect the given item.
881 virtual void Unselect(const wxDataViewItem
& item
);
885 This method only has effect if multiple selections are allowed.
887 virtual void UnselectAll();
893 @class wxDataViewModelNotifier
895 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
896 its notification interface.
897 See the documentation of that class for further information.
902 class wxDataViewModelNotifier
908 wxDataViewModelNotifier();
913 virtual ~wxDataViewModelNotifier();
916 Called by owning model.
918 virtual bool Cleared() = 0;
921 Get owning wxDataViewModel.
923 wxDataViewModel
* GetOwner() const;
926 Called by owning model.
928 virtual bool ItemAdded(const wxDataViewItem
& parent
,
929 const wxDataViewItem
& item
) = 0;
932 Called by owning model.
934 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
937 Called by owning model.
939 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
940 const wxDataViewItem
& item
) = 0;
943 Called by owning model.
945 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
946 const wxDataViewItemArray
& items
);
949 Called by owning model.
951 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
954 Called by owning model.
956 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
957 const wxDataViewItemArray
& items
);
960 Called by owning model.
962 virtual void Resort() = 0;
965 Set owner of this notifier. Used internally.
967 void SetOwner(wxDataViewModel
* owner
);
970 Called by owning model.
972 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
977 The mode of a data-view cell; see wxDataViewRenderer for more info.
979 enum wxDataViewCellMode
981 wxDATAVIEW_CELL_INERT
,
984 Indicates that the user can double click the cell and something will
985 happen (e.g. a window for editing a date will pop up).
987 wxDATAVIEW_CELL_ACTIVATABLE
,
990 Indicates that the user can edit the data in-place, i.e. an control
991 will show up after a slow click on the cell. This behaviour is best
992 known from changing the filename in most file managers etc.
994 wxDATAVIEW_CELL_EDITABLE
998 The values of this enum controls how a wxDataViewRenderer should display
999 its contents in a cell.
1001 enum wxDataViewCellRenderState
1003 wxDATAVIEW_CELL_SELECTED
= 1,
1004 wxDATAVIEW_CELL_PRELIT
= 2,
1005 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1006 wxDATAVIEW_CELL_FOCUSED
= 8
1010 @class wxDataViewRenderer
1012 This class is used by wxDataViewCtrl to render the individual cells.
1013 One instance of a renderer class is owned by a wxDataViewColumn.
1014 There is a number of ready-to-use renderers provided:
1015 - wxDataViewTextRenderer,
1016 - wxDataViewTextRendererAttr,
1017 - wxDataViewIconTextRenderer,
1018 - wxDataViewToggleRenderer,
1019 - wxDataViewProgressRenderer,
1020 - wxDataViewBitmapRenderer,
1021 - wxDataViewDateRenderer,
1022 - wxDataViewSpinRenderer.
1024 Additionally, the user can write own renderers by deriving from
1025 wxDataViewCustomRenderer.
1027 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1028 by the constructors respectively controls what actions the cell data allows
1029 and how the renderer should display its contents in a cell.
1034 class wxDataViewRenderer
: public wxObject
1040 wxDataViewRenderer(const wxString
& varianttype
,
1041 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1042 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1045 Returns the alignment. See SetAlignment()
1047 virtual int GetAlignment() const;
1050 Returns the cell mode.
1052 virtual wxDataViewCellMode
GetMode() const;
1055 Returns pointer to the owning wxDataViewColumn.
1057 wxDataViewColumn
* GetOwner() const;
1060 This methods retrieves the value from the renderer in order to
1061 transfer the value back to the data model.
1063 Returns @false on failure.
1065 virtual bool GetValue(wxVariant
& value
) const = 0;
1068 Returns a string with the type of the wxVariant supported by this renderer.
1070 wxString
GetVariantType() const;
1073 Sets the alignment of the renderer's content.
1074 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1075 should have the same alignment as the column header.
1077 The method is not implemented under OS X and the renderer always aligns
1078 its contents as the column header on that platform. The other platforms
1079 support both vertical and horizontal alignment.
1081 virtual void SetAlignment( int align
);
1083 Sets the owning wxDataViewColumn.
1084 This is usually called from within wxDataViewColumn.
1086 void SetOwner(wxDataViewColumn
* owner
);
1089 Set the value of the renderer (and thus its cell) to @a value.
1090 The internal code will then render this cell with this data.
1092 virtual bool SetValue(const wxVariant
& value
) = 0;
1095 Before data is committed to the data model, it is passed to this
1096 method where it can be checked for validity. This can also be
1097 used for checking a valid range or limiting the user input in
1098 a certain aspect (e.g. max number of characters or only alphanumeric
1099 input, ASCII only etc.). Return @false if the value is not valid.
1101 Please note that due to implementation limitations, this validation
1102 is done after the editing control already is destroyed and the
1103 editing process finished.
1105 virtual bool Validate(wxVariant
& value
);
1111 @class wxDataViewTextRenderer
1113 wxDataViewTextRenderer is used for rendering text.
1114 It supports in-place editing if desired.
1119 class wxDataViewTextRenderer
: public wxDataViewRenderer
1125 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1126 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1127 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1133 @class wxDataViewIconTextRenderer
1135 The wxDataViewIconTextRenderer class is used to display text with
1136 a small icon next to it as it is typically done in a file manager.
1138 This classes uses the wxDataViewIconText helper class to store its data.
1139 wxDataViewIonText can be converted to and from a wxVariant using the left shift
1145 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1151 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1152 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1153 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1159 @class wxDataViewProgressRenderer
1161 This class is used by wxDataViewCtrl to render progress bars.
1166 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1172 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1173 const wxString
& varianttype
= "long",
1174 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1175 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1181 @class wxDataViewSpinRenderer
1183 This is a specialized renderer for rendering integer values.
1184 It supports modifying the values in-place by using a wxSpinCtrl.
1185 The renderer only support variants of type @e long.
1190 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1195 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1197 wxDataViewSpinRenderer(int min
, int max
,
1198 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1199 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1205 @class wxDataViewToggleRenderer
1207 This class is used by wxDataViewCtrl to render toggle controls.
1212 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1218 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1219 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1220 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1226 @class wxDataViewDateRenderer
1228 This class is used by wxDataViewCtrl to render calendar controls.
1233 class wxDataViewDateRenderer
: public wxDataViewRenderer
1239 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1240 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1241 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1247 @class wxDataViewTextRendererAttr
1249 The same as wxDataViewTextRenderer but with support for font attributes.
1250 Font attributes are currently only supported under GTK+ and MSW.
1252 @see wxDataViewModel::GetAttr and wxDataViewItemAttr.
1257 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1263 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1264 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1265 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1271 @class wxDataViewCustomRenderer
1273 You need to derive a new class from wxDataViewCustomRenderer in
1274 order to write a new renderer.
1276 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1277 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1279 If you want your renderer to support in-place editing then you also need to override
1280 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1281 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1283 Note that a special event handler will be pushed onto that editor control
1284 which handles @e \<ENTER\> and focus out events in order to end the editing.
1289 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1295 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1296 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1297 int align
= -1, bool no_init
= false);
1302 virtual ~wxDataViewCustomRenderer();
1305 Override this to react to double clicks or ENTER.
1306 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1308 virtual bool Activate( wxRect cell
,
1309 wxDataViewModel
* model
,
1310 const wxDataViewItem
& item
,
1314 Override this to create the actual editor control once editing
1317 @a parent is the parent of the editor control, @a labelRect indicates the
1318 position and size of the editor control and @a value is its initial value:
1322 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1323 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1327 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1329 const wxVariant
& value
);
1332 Create DC on request. Internal.
1334 virtual wxDC
* GetDC();
1337 Return size required to show content.
1339 virtual wxSize
GetSize() const = 0;
1342 Overrride this so that the renderer can get the value from the editor
1343 control (pointed to by @a editor):
1346 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1347 long l = sc->GetValue();
1353 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1357 Override this and make it return @true in order to
1358 indicate that this renderer supports in-place editing.
1360 virtual bool HasEditorCtrl();
1363 Overrride this to react to a left click.
1364 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1366 virtual bool LeftClick( wxPoint cursor
,
1368 wxDataViewModel
* model
,
1369 const wxDataViewItem
& item
,
1373 Override this to render the cell.
1374 Before this is called, wxDataViewRenderer::SetValue was called
1375 so that this instance knows what to render.
1377 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1380 This method should be called from within Render() whenever you need to
1382 This will ensure that the correct colour, font and vertical alignment will
1383 be chosen so the text will look the same as text drawn by native renderers.
1385 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1386 wxDC
* dc
, int state
);
1389 Overrride this to start a drag operation. Not yet supported.
1391 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1392 wxDataViewModel
* model
,
1393 const wxDataViewItem
& item
,
1400 @class wxDataViewBitmapRenderer
1402 This class is used by wxDataViewCtrl to render bitmap controls.
1407 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1413 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1414 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1415 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1420 The flags used by wxDataViewColumn.
1422 enum wxDataViewColumnFlags
1424 wxDATAVIEW_COL_RESIZABLE
= 1,
1425 wxDATAVIEW_COL_SORTABLE
= 2,
1426 wxDATAVIEW_COL_REORDERABLE
= 4,
1427 wxDATAVIEW_COL_HIDDEN
= 8
1431 @class wxDataViewColumn
1433 This class represents a column in a wxDataViewCtrl.
1434 One wxDataViewColumn is bound to one column in the data model to which the
1435 wxDataViewCtrl has been associated.
1437 An instance of wxDataViewRenderer is used by this class to render its data.
1442 class wxDataViewColumn
: public wxHeaderColumn
1449 wxDataViewColumn(const wxString
& title
,
1450 wxDataViewRenderer
* renderer
,
1451 unsigned int model_column
,
1452 int width
= wxDVC_DEFAULT_WIDTH
,
1453 wxAlignment align
= wxALIGN_CENTER
,
1454 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1455 wxDataViewColumn(const wxBitmap
& bitmap
,
1456 wxDataViewRenderer
* renderer
,
1457 unsigned int model_column
,
1458 int width
= wxDVC_DEFAULT_WIDTH
,
1459 wxAlignment align
= wxALIGN_CENTER
,
1460 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1464 Returns the index of the column of the model, which this
1465 wxDataViewColumn is displaying.
1467 unsigned int GetModelColumn() const;
1470 Returns the owning wxDataViewCtrl.
1472 wxDataViewCtrl
* GetOwner() const;
1475 Returns the renderer of this wxDataViewColumn.
1477 @see wxDataViewRenderer.
1479 wxDataViewRenderer
* GetRenderer() const;
1485 @class wxDataViewListCtrl
1487 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1488 and forwards most of its API to that class.
1490 The purpose of this class is to offer a simple way to display and
1491 edit a small table of data without having to write your own wxDataViewModel.
1494 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, -1 );
1496 listctrl->AppendToggleColumn( "Toggle" );
1497 listctrl->AppendTextColumn( "Text" );
1499 wxVector<wxVariant> data;
1500 data.push_back( true );
1501 data.push_back( "row 1" );
1502 listctrl->AppendItem( data );
1505 data.push_back( false );
1506 data.push_back( "row 3" );
1507 listctrl->AppendItem( data );
1514 class wxDataViewListCtrl
: public wxDataViewCtrl
1520 wxDataViewListCtrl();
1523 Constructor. Calls Create().
1525 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1526 const wxPoint
& pos
= wxDefaultPosition
,
1527 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1528 const wxValidator
& validator
= wxDefaultValidator
);
1531 Destructor. Deletes the image list if any.
1533 ~wxDataViewListCtrl();
1536 Creates the control and a wxDataViewListStore as its internal model.
1538 bool Create( wxWindow
*parent
, wxWindowID id
,
1539 const wxPoint
& pos
= wxDefaultPosition
,
1540 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1541 const wxValidator
& validator
= wxDefaultValidator
);
1547 wxDataViewListStore
*GetStore();
1548 const wxDataViewListStore
*GetStore() const;
1552 Appends a column to the control and additonally appends a
1553 column to the store with the type @a varianttype.
1555 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1558 Prepends a column to the control and additonally prepends a
1559 column to the store with the type @a varianttype.
1561 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1564 Inserts a column to the control and additonally inserts a
1565 column to the store with the type @a varianttype.
1567 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1570 Overridden from wxDataViewCtrl
1572 Appends a column to the control and additonally appends a
1573 column to the store with the type string.
1575 virtual void AppendColumn( wxDataViewColumn
*column
);
1578 Overridden from wxDataViewCtrl
1580 Prepends a column to the control and additonally prepends a
1581 column to the store with the type string.
1583 virtual void PrependColumn( wxDataViewColumn
*column
);
1586 Overridden from wxDataViewCtrl
1588 Inserts a column to the control and additonally inserts a
1589 column to the store with the type string.
1591 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
1594 Inserts a text column to the control and the store.
1596 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1597 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1598 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1601 Inserts a toggle column to the control and the store.
1603 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1604 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1605 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1608 Inserts a progress column to the control and the store.
1610 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1611 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1612 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1615 Inserts a icon and text column to the control and the store.
1617 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1618 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1619 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1622 Appends an item (=row) to the control and store.
1624 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1627 Prepends an item (=row) to the control and store.
1629 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1632 Inserts an item (=row) to the control and store.
1634 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1637 Delete the row at position @a row.
1639 void DeleteItem( unsigned row
);
1642 Delete all items (= all rows).
1644 void DeleteAllItems();
1647 Sets the value in the store and update the control.
1649 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
1652 Returns the value from the store.
1654 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
1657 Sets the value in the store and update the control.
1659 This method assumes that the a string is stored in respective
1662 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
1665 Returns the value from the store.
1667 This method assumes that the a string is stored in respective
1670 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
1673 Sets the value in the store and update the control.
1675 This method assumes that the a boolean value is stored in
1678 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
1681 Returns the value from the store.
1683 This method assumes that the a boolean value is stored in
1686 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
1691 @class wxDataViewTreeCtrl
1693 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1694 and forwards most of its API to that class.
1695 Additionally, it uses a wxImageList to store a list of icons.
1697 The main purpose of this class is to look like a wxTreeCtrl to make a transition
1698 from it to the wxDataViewCtrl class simpler.
1702 @appearance{dataviewtreectrl.png}
1704 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1710 wxDataViewTreeCtrl();
1713 Constructor. Calls Create().
1715 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1716 const wxPoint
& pos
= wxDefaultPosition
,
1717 const wxSize
& size
= wxDefaultSize
,
1718 long style
= wxDV_NO_HEADER
,
1719 const wxValidator
& validator
= wxDefaultValidator
);
1722 Destructor. Deletes the image list if any.
1724 virtual ~wxDataViewTreeCtrl();
1727 Appends a container to the given @a parent.
1729 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1730 const wxString
& text
,
1733 wxClientData
* data
= NULL
);
1736 Appends an item to the given @a parent.
1738 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1739 const wxString
& text
,
1741 wxClientData
* data
= NULL
);
1744 Creates the control and a wxDataViewTreeStore as its internal model.
1746 bool Create(wxWindow
* parent
, wxWindowID id
,
1747 const wxPoint
& pos
= wxDefaultPosition
,
1748 const wxSize
& size
= wxDefaultSize
,
1749 long style
= wxDV_NO_HEADER
,
1750 const wxValidator
& validator
= wxDefaultValidator
);
1753 Calls the identical method from wxDataViewTreeStore.
1755 void DeleteAllItems();
1758 Calls the identical method from wxDataViewTreeStore.
1760 void DeleteChildren(const wxDataViewItem
& item
);
1763 Calls the identical method from wxDataViewTreeStore.
1765 void DeleteItem(const wxDataViewItem
& item
);
1768 Calls the identical method from wxDataViewTreeStore.
1770 int GetChildCount(const wxDataViewItem
& parent
) const;
1773 Returns the image list.
1775 wxImageList
* GetImageList();
1778 Calls the identical method from wxDataViewTreeStore.
1780 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1783 Calls the identical method from wxDataViewTreeStore.
1785 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1788 Calls the identical method from wxDataViewTreeStore.
1790 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
1793 Calls the identical method from wxDataViewTreeStore.
1795 wxString
GetItemText(const wxDataViewItem
& item
) const;
1798 Calls the identical method from wxDataViewTreeStore.
1800 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1801 unsigned int pos
) const;
1807 wxDataViewTreeStore
* GetStore();
1808 const wxDataViewTreeStore
* GetStore() const;
1812 Calls the same method from wxDataViewTreeStore but uses
1813 an index position in the image list instead of a wxIcon.
1815 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1816 const wxDataViewItem
& previous
,
1817 const wxString
& text
,
1820 wxClientData
* data
= NULL
);
1823 Calls the same method from wxDataViewTreeStore but uses
1824 an index position in the image list instead of a wxIcon.
1826 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1827 const wxDataViewItem
& previous
,
1828 const wxString
& text
,
1830 wxClientData
* data
= NULL
);
1833 Calls the same method from wxDataViewTreeStore but uses
1834 an index position in the image list instead of a wxIcon.
1836 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1837 const wxString
& text
,
1840 wxClientData
* data
= NULL
);
1843 Calls the same method from wxDataViewTreeStore but uses
1844 an index position in the image list instead of a wxIcon.
1846 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1847 const wxString
& text
,
1849 wxClientData
* data
= NULL
);
1852 Sets the image list.
1854 void SetImageList(wxImageList
* imagelist
);
1857 Calls the identical method from wxDataViewTreeStore.
1859 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1862 Calls the identical method from wxDataViewTreeStore.
1864 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1865 const wxIcon
& icon
);
1868 Calls the identical method from wxDataViewTreeStore.
1870 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1873 Calls the identical method from wxDataViewTreeStore.
1875 void SetItemText(const wxDataViewItem
& item
,
1876 const wxString
& text
);
1881 @class wxDataViewListStore
1883 wxDataViewListStore is a specialised wxDataViewModel for storing
1884 a simple table of data. Since it derives from wxDataViewIndexListModel
1885 its data is be accessed by row (i.e. by index) instead of only
1888 This class actually stores the values (therefore its name)
1889 and implements all virtual methods from the base classes so it can be
1890 used directly without having to derive any class from it, but it is
1891 mostly used from within wxDataViewListCtrl.
1897 class wxDataViewListStore
: public wxDataViewIndexListModel
1903 wxDataViewListStore();
1908 ~wxDataViewListStore();
1911 Prepends a data column.
1913 @a variantype indicates the type of values store in the column.
1915 This does not automatically fill in any (default) values in
1916 rows which exist in the store already.
1918 void PrependColumn( const wxString
&varianttype
);
1921 Inserts a data column before @a pos.
1923 @a variantype indicates the type of values store in the column.
1925 This does not automatically fill in any (default) values in
1926 rows which exist in the store already.
1928 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1931 Apppends a data column.
1933 @a variantype indicates the type of values store in the column.
1935 This does not automatically fill in any (default) values in
1936 rows which exist in the store already.
1938 void AppendColumn( const wxString
&varianttype
);
1941 Appends an item (=row) and fills it with @a values.
1943 The values must match the values specifies in the column
1944 in number and type. No (default) values are filled in
1947 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1950 Prepends an item (=row) and fills it with @a values.
1952 The values must match the values specifies in the column
1953 in number and type. No (default) values are filled in
1956 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1959 Inserts an item (=row) and fills it with @a values.
1961 The values must match the values specifies in the column
1962 in number and type. No (default) values are filled in
1965 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1968 Delete the item (=row) at position @a pos.
1970 void DeleteItem( unsigned pos
);
1973 Delete all item (=all rows) in the store.
1975 void DeleteAllItems();
1978 Overriden from wxDataViewModel
1980 virtual unsigned int GetColumnCount() const;
1983 Overriden from wxDataViewModel
1985 virtual wxString
GetColumnType( unsigned int col
) const;
1988 Overriden from wxDataViewIndexListModel
1990 virtual void GetValueByRow( wxVariant
&value
,
1991 unsigned int row
, unsigned int col
) const;
1994 Overriden from wxDataViewIndexListModel
1996 virtual bool SetValueByRow( const wxVariant
&value
,
1997 unsigned int row
, unsigned int col
);
2002 @class wxDataViewTreeStore
2004 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2005 trees very much like wxTreeCtrl does and it offers a similar API.
2007 This class actually stores the entire tree and the values (therefore its name)
2008 and implements all virtual methods from the base class so it can be used directly
2009 without having to derive any class from it, but it is mostly used from within
2015 class wxDataViewTreeStore
: public wxDataViewModel
2019 Constructor. Creates the invisible root node internally.
2021 wxDataViewTreeStore();
2026 virtual ~wxDataViewTreeStore();
2031 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2032 const wxString
& text
,
2033 const wxIcon
& icon
= wxNullIcon
,
2034 const wxIcon
& expanded
= wxNullIcon
,
2035 wxClientData
* data
= NULL
);
2040 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2041 const wxString
& text
,
2042 const wxIcon
& icon
= wxNullIcon
,
2043 wxClientData
* data
= NULL
);
2046 Delete all item in the model.
2048 void DeleteAllItems();
2051 Delete all children of the item, but not the item itself.
2053 void DeleteChildren(const wxDataViewItem
& item
);
2058 void DeleteItem(const wxDataViewItem
& item
);
2061 Return the number of children of item.
2063 int GetChildCount(const wxDataViewItem
& parent
) const;
2066 Returns the client data asoociated with the item.
2068 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2071 Returns the icon to display in expanded containers.
2073 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2076 Returns the icon of the item.
2078 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2081 Returns the text of the item.
2083 wxString
GetItemText(const wxDataViewItem
& item
) const;
2086 Returns the nth child item of item.
2088 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2089 unsigned int pos
) const;
2092 Inserts a container after @a previous.
2094 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2095 const wxDataViewItem
& previous
,
2096 const wxString
& text
,
2097 const wxIcon
& icon
= wxNullIcon
,
2098 const wxIcon
& expanded
= wxNullIcon
,
2099 wxClientData
* data
= NULL
);
2102 Inserts an item after @a previous.
2104 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2105 const wxDataViewItem
& previous
,
2106 const wxString
& text
,
2107 const wxIcon
& icon
= wxNullIcon
,
2108 wxClientData
* data
= NULL
);
2111 Inserts a container before the first child item or @a parent.
2113 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2114 const wxString
& text
,
2115 const wxIcon
& icon
= wxNullIcon
,
2116 const wxIcon
& expanded
= wxNullIcon
,
2117 wxClientData
* data
= NULL
);
2120 Inserts an item before the first child item or @a parent.
2122 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2123 const wxString
& text
,
2124 const wxIcon
& icon
= wxNullIcon
,
2125 wxClientData
* data
= NULL
);
2128 Sets the client data associated with the item.
2130 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2133 Sets the expanded icon for the item.
2135 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2136 const wxIcon
& icon
);
2139 Sets the icon for the item.
2141 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2146 @class wxDataViewIconText
2148 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2149 This class can be converted to and from a wxVariant.
2154 class wxDataViewIconText
: public wxObject
2161 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2162 const wxIcon
& icon
= wxNullIcon
);
2163 wxDataViewIconText(const wxDataViewIconText
& other
);
2169 const wxIcon
& GetIcon() const;
2174 wxString
GetText() const;
2179 void SetIcon(const wxIcon
& icon
);
2184 void SetText(const wxString
& text
);
2190 @class wxDataViewEvent
2192 This is the event class for the wxDataViewCtrl notifications.
2195 @category{events,dvc}
2197 class wxDataViewEvent
: public wxNotifyEvent
2202 Constructor. Typically used by wxWidgets internals only.
2204 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2206 wxDataViewEvent(const wxDataViewEvent
& event
);
2210 Returns the position of the column in the control or -1
2211 if no column field was set by the event emitter.
2213 int GetColumn() const;
2216 Returns a pointer to the wxDataViewColumn from which
2217 the event was emitted or @NULL.
2219 wxDataViewColumn
* GetDataViewColumn() const;
2222 Returns the wxDataViewModel associated with the event.
2224 wxDataViewModel
* GetModel() const;
2227 Returns a the position of a context menu event in screen coordinates.
2229 wxPoint
GetPosition() const;
2232 Returns a reference to a value.
2234 const wxVariant
& GetValue() const;
2237 Sets the column index associated with this event.
2239 void SetColumn(int col
);
2242 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2244 void SetDataViewColumn(wxDataViewColumn
* col
);
2247 Sets the dataview model associated with this event.
2249 void SetModel(wxDataViewModel
* model
);
2252 Sets the value associated with this event.
2254 void SetValue(const wxVariant
& value
);