1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
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 Note that wxDataViewModel does not define the position or index of any item
24 in the control because different controls might display the same data differently.
25 wxDataViewModel does provide a wxDataViewModel::Compare method which the
26 wxDataViewCtrl may use to sort the data either in conjunction with a column
27 header or without (see wxDataViewModel::HasDefaultCompare).
29 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
30 to store data and its type in a generic way. wxVariant can be extended to contain
31 almost any data without changes to the original class. To a certain extent,
32 you can use (the somewhat more elegant) wxAny instead of wxVariant as there
33 is code to convert between the two, but it is unclear what impact this will
36 Since you will usually allow the wxDataViewCtrl to change your data
37 through its graphical interface, you will also have to override
38 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
39 to some data has been committed.
41 If the data represented by the model is changed by something else than its
42 associated wxDataViewCtrl, the control has to be notified about the change.
43 Depending on what happened you need to call one of the following methods:
44 - wxDataViewModel::ValueChanged,
45 - wxDataViewModel::ItemAdded,
46 - wxDataViewModel::ItemDeleted,
47 - wxDataViewModel::ItemChanged,
48 - wxDataViewModel::Cleared.
50 There are plural forms for notification of addition, change or removal of
51 several item at once. See:
52 - wxDataViewModel::ItemsAdded,
53 - wxDataViewModel::ItemsDeleted,
54 - wxDataViewModel::ItemsChanged.
56 This class maintains a list of wxDataViewModelNotifier which link this class
57 to the specific implementations on the supported platforms so that e.g. calling
58 wxDataViewModel::ValueChanged on this model will just call
59 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
60 You can also add your own notifier in order to get informed about any changes
61 to the data in the list model.
63 Currently wxWidgets provides the following models apart from the base model:
64 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
67 Note that wxDataViewModel is reference counted, derives from wxRefCounter
68 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
69 This implies that you need to decrease the reference count after
70 associating the model with a control like this:
73 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
74 wxDataViewModel *musicModel = new MyMusicModel;
75 m_musicCtrl->AssociateModel( musicModel );
76 musicModel->DecRef(); // avoid memory leak !!
81 A potentially better way to avoid memory leaks is to use wxObjectDataPtr
84 wxObjectDataPtr<MyMusicModel> musicModel;
86 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
87 musicModel = new MyMusicModel;
88 m_musicCtrl->AssociateModel( musicModel.get() );
97 class wxDataViewModel
: public wxRefCounter
106 Adds a wxDataViewModelNotifier to the model.
108 void AddNotifier(wxDataViewModelNotifier
* notifier
);
111 Change the value of the given item and update the control to reflect
114 This function simply calls SetValue() and, if it succeeded,
122 The item (row) to update.
124 The column to update.
126 @true if both SetValue() and ValueChanged() returned @true.
128 bool ChangeValue(const wxVariant
& variant
,
129 const wxDataViewItem
& item
,
133 Called to inform the model that all data has been cleared.
134 The control will reread the data from the model again.
136 virtual bool Cleared();
139 The compare function to be used by control. The default compare function
140 sorts by container and other items separately and in ascending order.
141 Override this for a different sorting behaviour.
143 @see HasDefaultCompare().
145 virtual int Compare(const wxDataViewItem
& item1
,
146 const wxDataViewItem
& item2
,
148 bool ascending
) const;
151 Override this to indicate that the item has special font attributes.
152 This only affects the wxDataViewTextRendererText renderer.
154 The base class version always simply returns @false.
156 @see wxDataViewItemAttr.
159 The item for which the attribute is requested.
161 The column of the item for which the attribute is requested.
163 The attribute to be filled in if the function returns @true.
165 @true if this item has an attribute or @false otherwise.
167 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
168 wxDataViewItemAttr
& attr
) const;
171 Override this so the control can query the child items of an item.
172 Returns the number of items.
174 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
175 wxDataViewItemArray
& children
) const = 0;
178 Override this to indicate the number of columns in the model.
180 virtual unsigned int GetColumnCount() const = 0;
183 Override this to indicate what type of data is stored in the
184 column specified by @a col.
186 This should return a string indicating the type of data as reported by wxVariant.
188 virtual wxString
GetColumnType(unsigned int col
) const = 0;
191 Override this to indicate which wxDataViewItem representing the parent
192 of @a item or an invalid wxDataViewItem if the the root item is
195 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
198 Override this to indicate the value of @a item.
199 A wxVariant is used to store the data.
201 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
202 unsigned int col
) const = 0;
205 Override this method to indicate if a container item merely acts as a
206 headline (or for categorisation) or if it also acts a normal item with
207 entries for futher columns. By default returns @false.
209 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
212 Override this to indicate that the model provides a default compare
213 function that the control should use if no wxDataViewColumn has been
214 chosen for sorting. Usually, the user clicks on a column header for
215 sorting, the data will be sorted alphanumerically.
217 If any other order (e.g. by index or order of appearance) is required,
218 then this should be used.
219 See wxDataViewIndexListModel for a model which makes use of this.
221 virtual bool HasDefaultCompare() const;
224 Return true if there is a value in the given column of this item.
226 All normal items have values in all columns but the container items
227 only show their label in the first column (@a col == 0) by default (but
228 see HasContainerColumns()). So this function always returns true for
229 the first column while for the other ones it returns true only if the
230 item is not a container or HasContainerColumns() was overridden to
235 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const;
238 Override this to indicate of @a item is a container, i.e. if
239 it can have child items.
241 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
244 Call this to inform the model that an item has been added to the data.
246 bool ItemAdded(const wxDataViewItem
& parent
,
247 const wxDataViewItem
& item
);
250 Call this to inform the model that an item has changed.
252 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
253 event (in which the column fields will not be set) to the user.
255 bool ItemChanged(const wxDataViewItem
& item
);
258 Call this to inform the model that an item has been deleted from the data.
260 bool ItemDeleted(const wxDataViewItem
& parent
,
261 const wxDataViewItem
& item
);
264 Call this to inform the model that several items have been added to the data.
266 bool ItemsAdded(const wxDataViewItem
& parent
,
267 const wxDataViewItemArray
& items
);
270 Call this to inform the model that several items have changed.
272 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
273 events (in which the column fields will not be set) to the user.
275 bool ItemsChanged(const wxDataViewItemArray
& items
);
278 Call this to inform the model that several items have been deleted.
280 bool ItemsDeleted(const wxDataViewItem
& parent
,
281 const wxDataViewItemArray
& items
);
284 Remove the @a notifier from the list of notifiers.
286 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
289 Call this to initiate a resort after the sort function has been changed.
291 virtual void Resort();
294 This gets called in order to set a value in the data model.
296 The most common scenario is that the wxDataViewCtrl calls this method
297 after the user changed some data in the view.
299 This is the function you need to override in your derived class but if
300 you want to call it, ChangeValue() is usually more convenient as
301 otherwise you need to manually call ValueChanged() to update the
304 virtual bool SetValue(const wxVariant
& variant
,
305 const wxDataViewItem
& item
,
306 unsigned int col
) = 0;
309 Call this to inform this model that a value in the model has been changed.
310 This is also called from wxDataViewCtrl's internal editing code, e.g. when
311 editing a text field in the control.
313 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
316 virtual bool ValueChanged(const wxDataViewItem
& item
,
322 Destructor. This should not be called directly. Use DecRef() instead.
324 virtual ~wxDataViewModel();
330 @class wxDataViewListModel
332 Base class with abstract API for wxDataViewIndexListModel and
333 wxDataViewVirtualListModel.
338 class wxDataViewListModel
: public wxDataViewModel
345 virtual ~wxDataViewIndexListModel();
348 Compare method that sorts the items by their index.
350 int Compare(const wxDataViewItem
& item1
,
351 const wxDataViewItem
& item2
,
352 unsigned int column
, bool ascending
);
355 Override this to indicate that the row has special font attributes.
356 This only affects the wxDataViewTextRendererText() renderer.
358 The base class version always simply returns @false.
360 @see wxDataViewItemAttr.
363 The row for which the attribute is requested.
365 The column for which the attribute is requested.
367 The attribute to be filled in if the function returns @true.
369 @true if this item has an attribute or @false otherwise.
371 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
372 wxDataViewItemAttr
& attr
) const;
375 Returns the number of items (i.e. rows) in the list.
377 unsigned int GetCount() const;
380 Returns the wxDataViewItem at the given @e row.
382 wxDataViewItem
GetItem(unsigned int row
) const;
385 Returns the position of given @e item.
387 unsigned int GetRow(const wxDataViewItem
& item
) const;
390 Override this to allow getting values from the model.
392 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
393 unsigned int col
) const = 0;
396 Call this after if the data has to be read again from the model.
397 This is useful after major changes when calling the methods below
398 (possibly thousands of times) doesn't make sense.
400 void Reset(unsigned int new_size
);
403 Call this after a row has been appended to the model.
408 Call this after a row has been changed.
410 void RowChanged(unsigned int row
);
413 Call this after a row has been deleted.
415 void RowDeleted(unsigned int row
);
418 Call this after a row has been inserted at the given position.
420 void RowInserted(unsigned int before
);
423 Call this after a row has been prepended to the model.
428 Call this after a value has been changed.
430 void RowValueChanged(unsigned int row
, unsigned int col
);
433 Call this after rows have been deleted.
434 The array will internally get copied and sorted in descending order so
435 that the rows with the highest position will be deleted first.
437 void RowsDeleted(const wxArrayInt
& rows
);
440 Called in order to set a value in the model.
442 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
443 unsigned int col
) = 0;
448 @class wxDataViewIndexListModel
450 wxDataViewIndexListModel is a specialized data model which lets you address
451 an item by its position (row) rather than its wxDataViewItem (which you can
452 obtain from this class).
453 This model also provides its own wxDataViewIndexListModel::Compare
454 method which sorts the model's data by the index.
456 This model is not a virtual model since the control stores each wxDataViewItem.
457 Use wxDataViewVirtualListModel if you need to display millions of items or
458 have other reason to use a virtual control.
460 @see wxDataViewListModel for the API.
466 class wxDataViewIndexListModel
: public wxDataViewListModel
472 wxDataViewIndexListModel(unsigned int initial_size
= 0);
477 @class wxDataViewVirtualListModel
479 wxDataViewVirtualListModel is a specialized data model which lets you address
480 an item by its position (row) rather than its wxDataViewItem and as such offers
481 the exact same interface as wxDataViewIndexListModel.
482 The important difference is that under platforms other than OS X, using this
483 model will result in a truly virtual control able to handle millions of items
484 as the control doesn't store any item (a feature not supported by OS X).
486 @see wxDataViewListModel for the API.
492 class wxDataViewVirtualListModel
: public wxDataViewListModel
498 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
505 @class wxDataViewItemAttr
507 This class is used to indicate to a wxDataViewCtrl that a certain item
508 (see wxDataViewItem) has extra font attributes for its renderer.
509 For this, it is required to override wxDataViewModel::GetAttr.
511 Attributes are currently only supported by wxDataViewTextRendererText.
516 class wxDataViewItemAttr
522 wxDataViewItemAttr();
525 Call this to indicate that the item shall be displayed in bold text.
527 void SetBold(bool set
);
530 Call this to indicate that the item shall be displayed with that colour.
532 void SetColour(const wxColour
& colour
);
535 Call this to indicate that the item shall be displayed in italic text.
537 void SetItalic(bool set
);
543 @class wxDataViewItem
545 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
546 in a persistent way, i.e. independent of the position of the item in the control
547 or changes to its contents.
549 It must hold a unique ID of type @e void* in its only field and can be converted
552 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
553 return @false which used in many places in the API of wxDataViewCtrl to
554 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
555 the invisible root. Examples for this are wxDataViewModel::GetParent and
556 wxDataViewModel::GetChildren.
568 wxDataViewItem(void* id
= NULL
);
569 wxDataViewItem(const wxDataViewItem
& item
);
578 Returns @true if the ID is not @NULL.
586 @class wxDataViewCtrl
588 wxDataViewCtrl is a control to display data either in a tree like fashion or
589 in a tabular form or both.
591 If you only need to display a simple tree structure with an API more like the
592 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
593 Likewise, if you only want to display simple table structure you can use
594 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
595 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
597 A wxDataViewItem is used to represent a (visible) item in the control.
599 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
600 virtual functions or by setting it directly. Instead you need to write your own
601 wxDataViewModel and associate it with this control.
602 Then you need to add a number of wxDataViewColumn to this control to define
603 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
604 of a wxDataViewRenderer to render its cells.
606 A number of standard renderers for rendering text, dates, images, toggle,
607 a progress bar etc. are provided. Additionally, the user can write custom
608 renderers deriving from wxDataViewCustomRenderer for displaying anything.
610 All data transfer from the control to the model and the user code is done
611 through wxVariant which can be extended to support more data formats as necessary.
612 Accordingly, all type information uses the strings returned from wxVariant::GetType.
616 Single selection mode. This is the default.
617 @style{wxDV_MULTIPLE}
618 Multiple selection mode.
619 @style{wxDV_ROW_LINES}
620 Use alternating colours for rows if supported by platform and theme.
621 @style{wxDV_HORIZ_RULES}
622 Display fine rules between row if supported.
623 @style{wxDV_VERT_RULES}
624 Display fine rules between columns is supported.
625 @style{wxDV_VARIABLE_LINE_HEIGHT}
626 Allow variable line heights.
627 This can be inefficient when displaying large number of items.
628 @style{wxDV_NO_HEADER}
629 Do not show column headers (which are shown by default).
632 @beginEventEmissionTable{wxDataViewEvent}
633 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
634 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
635 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
636 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
637 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
638 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This
639 event can be vetoed in order to prevent editing on an item by item
640 basis. Still experimental.
641 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
642 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
643 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
644 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
645 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
646 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
647 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
648 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
649 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
650 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
651 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
652 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
653 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
654 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
655 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
656 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
657 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
658 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
659 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
660 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
661 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
662 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
663 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
664 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
665 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
666 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
667 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
668 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
669 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
670 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
675 @appearance{dataviewctrl.png}
677 class wxDataViewCtrl
: public wxControl
686 Constructor. Calls Create().
688 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
689 const wxPoint
& pos
= wxDefaultPosition
,
690 const wxSize
& size
= wxDefaultSize
,
692 const wxValidator
& validator
= wxDefaultValidator
,
693 const wxString
& name
= wxDataViewCtrlNameStr
);
698 virtual ~wxDataViewCtrl();
701 Appends a wxDataViewColumn to the control. Returns @true on success.
703 Note that there is a number of short cut methods which implicitly create
704 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
706 virtual bool AppendColumn(wxDataViewColumn
* col
);
709 Prepends a wxDataViewColumn to the control. Returns @true on success.
711 Note that there is a number of short cut methods which implicitly create
712 a wxDataViewColumn and a wxDataViewRenderer for it.
714 virtual bool PrependColumn(wxDataViewColumn
* col
);
717 Inserts a wxDataViewColumn to the control. Returns @true on success.
719 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
723 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
724 created in the function or @NULL on failure.
726 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
727 unsigned int model_column
,
728 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
730 wxAlignment align
= wxALIGN_CENTER
,
731 int flags
= wxDATAVIEW_COL_RESIZABLE
);
732 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
733 unsigned int model_column
,
734 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
736 wxAlignment align
= wxALIGN_CENTER
,
737 int flags
= wxDATAVIEW_COL_RESIZABLE
);
742 Appends a column for rendering a date. Returns the wxDataViewColumn
743 created in the function or @NULL on failure.
745 @note The @a align parameter is applied to both the column header and
748 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
749 unsigned int model_column
,
750 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
752 wxAlignment align
= wxALIGN_NOT
,
753 int flags
= wxDATAVIEW_COL_RESIZABLE
);
754 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
755 unsigned int model_column
,
756 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
758 wxAlignment align
= wxALIGN_NOT
,
759 int flags
= wxDATAVIEW_COL_RESIZABLE
);
764 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
765 created in the function or @NULL on failure.
766 This method uses the wxDataViewIconTextRenderer class.
768 @note The @a align parameter is applied to both the column header and
771 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
772 unsigned int model_column
,
773 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
775 wxAlignment align
= wxALIGN_NOT
,
776 int flags
= wxDATAVIEW_COL_RESIZABLE
);
777 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
778 unsigned int model_column
,
779 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
781 wxAlignment align
= wxALIGN_NOT
,
782 int flags
= wxDATAVIEW_COL_RESIZABLE
);
787 Appends a column for rendering a progress indicator. Returns the
788 wxDataViewColumn created in the function or @NULL on failure.
790 @note The @a align parameter is applied to both the column header and
793 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
794 unsigned int model_column
,
795 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
797 wxAlignment align
= wxALIGN_CENTER
,
798 int flags
= wxDATAVIEW_COL_RESIZABLE
);
799 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
800 unsigned int model_column
,
801 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
803 wxAlignment align
= wxALIGN_CENTER
,
804 int flags
= wxDATAVIEW_COL_RESIZABLE
);
809 Appends a column for rendering text. Returns the wxDataViewColumn
810 created in the function or @NULL on failure.
812 @note The @a align parameter is applied to both the column header and
815 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
816 unsigned int model_column
,
817 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
819 wxAlignment align
= wxALIGN_NOT
,
820 int flags
= wxDATAVIEW_COL_RESIZABLE
);
821 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
822 unsigned int model_column
,
823 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
825 wxAlignment align
= wxALIGN_NOT
,
826 int flags
= wxDATAVIEW_COL_RESIZABLE
);
831 Appends a column for rendering a toggle. Returns the wxDataViewColumn
832 created in the function or @NULL on failure.
834 @note The @a align parameter is applied to both the column header and
837 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
838 unsigned int model_column
,
839 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
841 wxAlignment align
= wxALIGN_CENTER
,
842 int flags
= wxDATAVIEW_COL_RESIZABLE
);
843 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
844 unsigned int model_column
,
845 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
847 wxAlignment align
= wxALIGN_CENTER
,
848 int flags
= wxDATAVIEW_COL_RESIZABLE
);
852 Associates a wxDataViewModel with the control.
853 This increases the reference count of the model by 1.
855 virtual bool AssociateModel(wxDataViewModel
* model
);
860 virtual bool ClearColumns();
865 virtual void Collapse(const wxDataViewItem
& item
);
868 Create the control. Useful for two step creation.
870 bool Create(wxWindow
* parent
, wxWindowID id
,
871 const wxPoint
& pos
= wxDefaultPosition
,
872 const wxSize
& size
= wxDefaultSize
,
874 const wxValidator
& validator
= wxDefaultValidator
,
875 const wxString
& name
= wxDataViewCtrlNameStr
);
878 Deletes given column.
880 virtual bool DeleteColumn(wxDataViewColumn
* column
);
883 Enable drag operations using the given @a format.
885 virtual bool EnableDragSource( const wxDataFormat
&format
);
888 Enable drop operations using the given @a format.
890 virtual bool EnableDropTarget( const wxDataFormat
&format
);
893 Call this to ensure that the given item is visible.
895 virtual void EnsureVisible(const wxDataViewItem
& item
,
896 const wxDataViewColumn
* column
= NULL
);
901 virtual void Expand(const wxDataViewItem
& item
);
904 Expands all ancestors of the @a item. This method also
905 ensures that the item itself as well as all ancestor
906 items have been read from the model by the control.
908 virtual void ExpandAncestors( const wxDataViewItem
& item
);
911 Returns pointer to the column. @a pos refers to the position in the
912 control which may change after reordering columns by the user.
914 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
917 Returns the number of columns.
919 virtual unsigned int GetColumnCount() const;
922 Returns the position of the column or -1 if not found in the control.
924 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
927 Returns column containing the expanders.
929 wxDataViewColumn
* GetExpanderColumn() const;
932 Returns the currently focused item.
934 This is the item that the keyboard commands apply to. It may be invalid
935 if there is no focus currently.
937 This method is mostly useful for the controls with @c wxDV_MULTIPLE
938 style as in the case of single selection it returns the same thing as
941 Notice that under all platforms except Mac OS X the currently focused
942 item may be selected or not but under OS X the current item is always
945 @see SetCurrentItem()
949 wxDataViewItem
GetCurrentItem() const;
954 int GetIndent() const;
959 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
960 const wxDataViewColumn
* col
= NULL
) const;
963 Returns pointer to the data model associated with the control (if any).
965 wxDataViewModel
* GetModel();
968 Returns first selected item or an invalid item if none is selected.
970 virtual wxDataViewItem
GetSelection() const;
973 Fills @a sel with currently selected items and returns their number.
975 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
978 Returns the wxDataViewColumn currently responsible for sorting
979 or @NULL if none has been selected.
981 virtual wxDataViewColumn
* GetSortingColumn() const;
986 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
987 wxDataViewColumn
*& col
) const;
990 Return @true if the item is expanded.
992 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
995 Return @true if the item is selected.
997 virtual bool IsSelected(const wxDataViewItem
& item
) const;
1000 Select the given item.
1002 In single selection mode this changes the (unique) currently selected
1003 item. In multi selection mode, the @a item is selected and the
1004 previously selected items remain selected.
1006 virtual void Select(const wxDataViewItem
& item
);
1011 virtual void SelectAll();
1014 Set which column shall contain the tree-like expanders.
1016 void SetExpanderColumn(wxDataViewColumn
* col
);
1019 Changes the currently focused item.
1021 The @a item parameter must be valid, there is no way to remove the
1022 current item from the control.
1024 In single selection mode, calling this method is the same as calling
1025 Select() and is thus not very useful. In multiple selection mode this
1026 method only moves the current item however without changing the
1027 selection except under OS X where the current item is always selected,
1028 so calling SetCurrentItem() selects @a item if it hadn't been selected
1031 @see GetCurrentItem()
1035 void SetCurrentItem(const wxDataViewItem
& item
);
1038 Sets the indendation.
1040 void SetIndent(int indent
);
1043 Sets the selection to the array of wxDataViewItems.
1045 virtual void SetSelections(const wxDataViewItemArray
& sel
);
1048 Unselect the given item.
1050 virtual void Unselect(const wxDataViewItem
& item
);
1054 This method only has effect if multiple selections are allowed.
1056 virtual void UnselectAll();
1062 @class wxDataViewModelNotifier
1064 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1065 its notification interface.
1066 See the documentation of that class for further information.
1071 class wxDataViewModelNotifier
1077 wxDataViewModelNotifier();
1082 virtual ~wxDataViewModelNotifier();
1085 Called by owning model.
1087 virtual bool Cleared() = 0;
1090 Get owning wxDataViewModel.
1092 wxDataViewModel
* GetOwner() const;
1095 Called by owning model.
1097 virtual bool ItemAdded(const wxDataViewItem
& parent
,
1098 const wxDataViewItem
& item
) = 0;
1101 Called by owning model.
1103 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
1106 Called by owning model.
1108 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
1109 const wxDataViewItem
& item
) = 0;
1112 Called by owning model.
1114 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
1115 const wxDataViewItemArray
& items
);
1118 Called by owning model.
1120 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
1123 Called by owning model.
1125 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
1126 const wxDataViewItemArray
& items
);
1129 Called by owning model.
1131 virtual void Resort() = 0;
1134 Set owner of this notifier. Used internally.
1136 void SetOwner(wxDataViewModel
* owner
);
1139 Called by owning model.
1141 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
1146 The mode of a data-view cell; see wxDataViewRenderer for more info.
1148 enum wxDataViewCellMode
1150 wxDATAVIEW_CELL_INERT
,
1153 Indicates that the user can double click the cell and something will
1154 happen (e.g. a window for editing a date will pop up).
1156 wxDATAVIEW_CELL_ACTIVATABLE
,
1159 Indicates that the user can edit the data in-place, i.e. an control
1160 will show up after a slow click on the cell. This behaviour is best
1161 known from changing the filename in most file managers etc.
1163 wxDATAVIEW_CELL_EDITABLE
1167 The values of this enum controls how a wxDataViewRenderer should display
1168 its contents in a cell.
1170 enum wxDataViewCellRenderState
1172 wxDATAVIEW_CELL_SELECTED
= 1,
1173 wxDATAVIEW_CELL_PRELIT
= 2,
1174 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1175 wxDATAVIEW_CELL_FOCUSED
= 8
1179 @class wxDataViewRenderer
1181 This class is used by wxDataViewCtrl to render the individual cells.
1182 One instance of a renderer class is owned by a wxDataViewColumn.
1183 There is a number of ready-to-use renderers provided:
1184 - wxDataViewTextRenderer,
1185 - wxDataViewIconTextRenderer,
1186 - wxDataViewToggleRenderer,
1187 - wxDataViewProgressRenderer,
1188 - wxDataViewBitmapRenderer,
1189 - wxDataViewDateRenderer,
1190 - wxDataViewSpinRenderer.
1191 - wxDataViewChoiceRenderer.
1193 Additionally, the user can write own renderers by deriving from
1194 wxDataViewCustomRenderer.
1196 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1197 by the constructors respectively controls what actions the cell data allows
1198 and how the renderer should display its contents in a cell.
1203 class wxDataViewRenderer
: public wxObject
1209 wxDataViewRenderer(const wxString
& varianttype
,
1210 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1211 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1214 Enable or disable replacing parts of the item text with ellipsis to
1215 make it fit the column width.
1217 This method only makes sense for the renderers working with text, such
1218 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1220 By default wxELLIPSIZE_MIDDLE is used.
1223 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1227 void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
);
1230 Disable replacing parts of the item text with ellipsis.
1232 If ellipsizing is disabled, the string will be truncated if it doesn't
1235 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1239 void DisableEllipsize();
1242 Returns the alignment. See SetAlignment()
1244 virtual int GetAlignment() const;
1247 Returns the ellipsize mode used by the renderer.
1249 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1252 @see EnableEllipsize()
1254 wxEllipsizeMode
GetEllipsizeMode() const;
1257 Returns the cell mode.
1259 virtual wxDataViewCellMode
GetMode() const;
1262 Returns pointer to the owning wxDataViewColumn.
1264 wxDataViewColumn
* GetOwner() const;
1267 This methods retrieves the value from the renderer in order to
1268 transfer the value back to the data model.
1270 Returns @false on failure.
1272 virtual bool GetValue(wxVariant
& value
) const = 0;
1275 Returns a string with the type of the wxVariant supported by this renderer.
1277 wxString
GetVariantType() const;
1280 Sets the alignment of the renderer's content.
1281 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1282 should have the same alignment as the column header.
1284 The method is not implemented under OS X and the renderer always aligns
1285 its contents as the column header on that platform. The other platforms
1286 support both vertical and horizontal alignment.
1288 virtual void SetAlignment( int align
);
1290 Sets the owning wxDataViewColumn.
1291 This is usually called from within wxDataViewColumn.
1293 void SetOwner(wxDataViewColumn
* owner
);
1296 Set the value of the renderer (and thus its cell) to @a value.
1297 The internal code will then render this cell with this data.
1299 virtual bool SetValue(const wxVariant
& value
) = 0;
1302 Before data is committed to the data model, it is passed to this
1303 method where it can be checked for validity. This can also be
1304 used for checking a valid range or limiting the user input in
1305 a certain aspect (e.g. max number of characters or only alphanumeric
1306 input, ASCII only etc.). Return @false if the value is not valid.
1308 Please note that due to implementation limitations, this validation
1309 is done after the editing control already is destroyed and the
1310 editing process finished.
1312 virtual bool Validate(wxVariant
& value
);
1318 @class wxDataViewTextRenderer
1320 wxDataViewTextRenderer is used for rendering text.
1321 It supports in-place editing if desired.
1326 class wxDataViewTextRenderer
: public wxDataViewRenderer
1332 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1333 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1334 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1340 @class wxDataViewIconTextRenderer
1342 The wxDataViewIconTextRenderer class is used to display text with
1343 a small icon next to it as it is typically done in a file manager.
1345 This classes uses the wxDataViewIconText helper class to store its data.
1346 wxDataViewIconText can be converted to and from a wxVariant using the left
1352 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1358 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1359 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1360 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1366 @class wxDataViewProgressRenderer
1368 This class is used by wxDataViewCtrl to render progress bars.
1373 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1379 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1380 const wxString
& varianttype
= "long",
1381 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1382 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1388 @class wxDataViewSpinRenderer
1390 This is a specialized renderer for rendering integer values.
1391 It supports modifying the values in-place by using a wxSpinCtrl.
1392 The renderer only support variants of type @e long.
1397 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1402 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1404 wxDataViewSpinRenderer(int min
, int max
,
1405 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1406 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1412 @class wxDataViewToggleRenderer
1414 This class is used by wxDataViewCtrl to render toggle controls.
1419 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1425 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1426 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1427 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1432 @class wxDataViewChoiceRenderer
1434 This class is used by wxDataViewCtrl to render choice controls.
1435 It stores a string so that SetValue() and GetValue() operate
1436 on a variant holding a string.
1442 class wxDataViewChoiceRenderer
: public wxDataViewRenderer
1448 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1449 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1450 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1453 Returns the choice referred to by index.
1455 wxString
GetChoice(size_t index
) const;
1458 Returns all choices.
1460 const wxArrayString
& GetChoices() const;
1465 @class wxDataViewDateRenderer
1467 This class is used by wxDataViewCtrl to render calendar controls.
1472 class wxDataViewDateRenderer
: public wxDataViewRenderer
1478 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1479 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1480 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1486 @class wxDataViewCustomRenderer
1488 You need to derive a new class from wxDataViewCustomRenderer in
1489 order to write a new renderer.
1491 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1492 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1494 If you want your renderer to support in-place editing then you also need to override
1495 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1496 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1498 Note that a special event handler will be pushed onto that editor control
1499 which handles @e \<ENTER\> and focus out events in order to end the editing.
1504 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1510 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1511 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1512 int align
= -1, bool no_init
= false);
1517 virtual ~wxDataViewCustomRenderer();
1520 Override this to react to double clicks or ENTER.
1521 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1523 virtual bool Activate( wxRect cell
,
1524 wxDataViewModel
* model
,
1525 const wxDataViewItem
& item
,
1529 Override this to create the actual editor control once editing
1532 @a parent is the parent of the editor control, @a labelRect indicates the
1533 position and size of the editor control and @a value is its initial value:
1537 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1538 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1542 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1544 const wxVariant
& value
);
1547 Return the attribute to be used for rendering.
1549 This function may be called from Render() implementation to use the
1550 attributes defined for the item if the renderer supports them.
1552 Notice that when Render() is called, the wxDC object passed to it is
1553 already set up to use the correct attributes (e.g. its font is set to
1554 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
1555 returns true) so it may not be necessary to call it explicitly if you
1556 only want to render text using the items attributes.
1560 const wxDataViewItemAttr
& GetAttr() const;
1563 Return size required to show content.
1565 virtual wxSize
GetSize() const = 0;
1568 Override this so that the renderer can get the value from the editor
1569 control (pointed to by @a editor):
1572 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1573 long l = sc->GetValue();
1579 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1583 Override this and make it return @true in order to
1584 indicate that this renderer supports in-place editing.
1586 virtual bool HasEditorCtrl() const;
1589 Override this to react to a left click.
1590 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1592 virtual bool LeftClick( wxPoint cursor
,
1594 wxDataViewModel
* model
,
1595 const wxDataViewItem
& item
,
1599 Override this to render the cell.
1600 Before this is called, wxDataViewRenderer::SetValue was called
1601 so that this instance knows what to render.
1603 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1606 This method should be called from within Render() whenever you need to
1608 This will ensure that the correct colour, font and vertical alignment will
1609 be chosen so the text will look the same as text drawn by native renderers.
1611 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1612 wxDC
* dc
, int state
);
1615 Override this to start a drag operation. Not yet supported.
1617 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1618 wxDataViewModel
* model
,
1619 const wxDataViewItem
& item
,
1626 @class wxDataViewBitmapRenderer
1628 This class is used by wxDataViewCtrl to render bitmap controls.
1633 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1639 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1640 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1641 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1646 The flags used by wxDataViewColumn.
1647 Can be combined together.
1649 enum wxDataViewColumnFlags
1651 wxDATAVIEW_COL_RESIZABLE
= 1,
1652 wxDATAVIEW_COL_SORTABLE
= 2,
1653 wxDATAVIEW_COL_REORDERABLE
= 4,
1654 wxDATAVIEW_COL_HIDDEN
= 8
1658 @class wxDataViewColumn
1660 This class represents a column in a wxDataViewCtrl.
1661 One wxDataViewColumn is bound to one column in the data model to which the
1662 wxDataViewCtrl has been associated.
1664 An instance of wxDataViewRenderer is used by this class to render its data.
1669 class wxDataViewColumn
: public wxSettableHeaderColumn
1673 Constructs a text column.
1676 The title of the column.
1678 The class which will render the contents of this column.
1680 The index of the model's column which is associated with this object.
1682 The width of the column.
1683 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1685 The alignment of the column title.
1687 One or more flags of the ::wxDataViewColumnFlags enumeration.
1689 wxDataViewColumn(const wxString
& title
,
1690 wxDataViewRenderer
* renderer
,
1691 unsigned int model_column
,
1692 int width
= wxDVC_DEFAULT_WIDTH
,
1693 wxAlignment align
= wxALIGN_CENTER
,
1694 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1697 Constructs a bitmap column.
1700 The bitmap of the column.
1702 The class which will render the contents of this column.
1704 The index of the model's column which is associated with this object.
1706 The width of the column.
1707 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1709 The alignment of the column title.
1711 One or more flags of the ::wxDataViewColumnFlags enumeration.
1713 wxDataViewColumn(const wxBitmap
& bitmap
,
1714 wxDataViewRenderer
* renderer
,
1715 unsigned int model_column
,
1716 int width
= wxDVC_DEFAULT_WIDTH
,
1717 wxAlignment align
= wxALIGN_CENTER
,
1718 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1721 Returns the index of the column of the model, which this
1722 wxDataViewColumn is displaying.
1724 unsigned int GetModelColumn() const;
1727 Returns the owning wxDataViewCtrl.
1729 wxDataViewCtrl
* GetOwner() const;
1732 Returns the renderer of this wxDataViewColumn.
1734 @see wxDataViewRenderer.
1736 wxDataViewRenderer
* GetRenderer() const;
1742 @class wxDataViewListCtrl
1744 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1745 and forwards most of its API to that class.
1747 The purpose of this class is to offer a simple way to display and
1748 edit a small table of data without having to write your own wxDataViewModel.
1751 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
1753 listctrl->AppendToggleColumn( "Toggle" );
1754 listctrl->AppendTextColumn( "Text" );
1756 wxVector<wxVariant> data;
1757 data.push_back( wxVariant(true) );
1758 data.push_back( wxVariant("row 1") );
1759 listctrl->AppendItem( data );
1762 data.push_back( wxVariant(false) );
1763 data.push_back( wxVariant("row 3") );
1764 listctrl->AppendItem( data );
1768 See wxDataViewCtrl for the list of supported styles.
1771 @beginEventEmissionTable
1772 See wxDataViewCtrl for the list of events emitted by this class.
1778 class wxDataViewListCtrl
: public wxDataViewCtrl
1784 wxDataViewListCtrl();
1787 Constructor. Calls Create().
1789 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1790 const wxPoint
& pos
= wxDefaultPosition
,
1791 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1792 const wxValidator
& validator
= wxDefaultValidator
);
1795 Destructor. Deletes the image list if any.
1797 ~wxDataViewListCtrl();
1800 Creates the control and a wxDataViewListStore as its internal model.
1802 bool Create( wxWindow
*parent
, wxWindowID id
,
1803 const wxPoint
& pos
= wxDefaultPosition
,
1804 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1805 const wxValidator
& validator
= wxDefaultValidator
);
1811 wxDataViewListStore
*GetStore();
1812 const wxDataViewListStore
*GetStore() const;
1816 Returns the position of given @e item or wxNOT_FOUND if it's
1821 int ItemToRow(const wxDataViewItem
&item
) const;
1824 Returns the wxDataViewItem at the given @e row.
1828 wxDataViewItem
RowToItem(int row
) const;
1832 @name Selection handling functions
1836 Returns index of the selected row or wxNOT_FOUND.
1838 @see wxDataViewCtrl::GetSelection()
1842 int GetSelectedRow() const;
1847 @see wxDataViewCtrl::Select()
1851 void SelectRow(unsigned row
);
1854 Unselects given row.
1856 @see wxDataViewCtrl::Unselect()
1860 void UnselectRow(unsigned row
);
1863 Returns true if @a row is selected.
1865 @see wxDataViewCtrl::IsSelected()
1869 bool IsRowSelected(unsigned row
) const;
1874 @name Column management functions
1879 Appends a column to the control and additionally appends a
1880 column to the store with the type string.
1882 virtual void AppendColumn( wxDataViewColumn
*column
);
1885 Appends a column to the control and additionally appends a
1886 column to the list store with the type @a varianttype.
1888 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1891 Appends a text column to the control and the store.
1893 See wxDataViewColumn::wxDataViewColumn for more info about
1896 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1897 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1898 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1899 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1902 Appends a toggle column to the control and the store.
1904 See wxDataViewColumn::wxDataViewColumn for more info about
1907 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1908 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1909 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1910 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1913 Appends a progress column to the control and the store.
1915 See wxDataViewColumn::wxDataViewColumn for more info about
1918 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1919 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1920 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1921 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1924 Appends an icon-and-text column to the control and the store.
1926 See wxDataViewColumn::wxDataViewColumn for more info about
1929 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1930 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1931 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1932 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1935 Inserts a column to the control and additionally inserts a
1936 column to the store with the type string.
1938 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
1941 Inserts a column to the control and additionally inserts a
1942 column to the list store with the type @a varianttype.
1944 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
,
1945 const wxString
&varianttype
);
1948 Prepends a column to the control and additionally prepends a
1949 column to the store with the type string.
1951 virtual void PrependColumn( wxDataViewColumn
*column
);
1954 Prepends a column to the control and additionally prepends a
1955 column to the list store with the type @a varianttype.
1957 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1963 @name Item management functions
1968 Appends an item (=row) to the control and store.
1970 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1973 Prepends an item (=row) to the control and store.
1975 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1978 Inserts an item (=row) to the control and store.
1980 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1983 Delete the row at position @a row.
1985 void DeleteItem( unsigned row
);
1988 Delete all items (= all rows).
1990 void DeleteAllItems();
1993 Sets the value in the store and update the control.
1995 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
1998 Returns the value from the store.
2000 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
2003 Sets the value in the store and update the control.
2005 This method assumes that the a string is stored in respective
2008 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
2011 Returns the value from the store.
2013 This method assumes that the a string is stored in respective
2016 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
2019 Sets the value in the store and update the control.
2021 This method assumes that the a boolean value is stored in
2024 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
2027 Returns the value from the store.
2029 This method assumes that the a boolean value is stored in
2032 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
2039 @class wxDataViewTreeCtrl
2041 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
2042 and forwards most of its API to that class.
2043 Additionally, it uses a wxImageList to store a list of icons.
2045 The main purpose of this class is to provide a simple upgrade path for code
2049 See wxDataViewCtrl for the list of supported styles.
2052 @beginEventEmissionTable
2053 See wxDataViewCtrl for the list of events emitted by this class.
2058 @appearance{dataviewtreectrl.png}
2060 class wxDataViewTreeCtrl
: public wxDataViewCtrl
2066 wxDataViewTreeCtrl();
2073 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
2074 const wxPoint
& pos
= wxDefaultPosition
,
2075 const wxSize
& size
= wxDefaultSize
,
2076 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2077 const wxValidator
& validator
= wxDefaultValidator
);
2080 Destructor. Deletes the image list if any.
2082 virtual ~wxDataViewTreeCtrl();
2085 Appends a container to the given @a parent.
2087 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2088 const wxString
& text
,
2091 wxClientData
* data
= NULL
);
2094 Appends an item to the given @a parent.
2096 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2097 const wxString
& text
,
2099 wxClientData
* data
= NULL
);
2102 Creates the control and a wxDataViewTreeStore as its internal model.
2104 The default tree column created by this method is an editable column
2105 using wxDataViewIconTextRenderer as its renderer.
2107 bool Create(wxWindow
* parent
, wxWindowID id
,
2108 const wxPoint
& pos
= wxDefaultPosition
,
2109 const wxSize
& size
= wxDefaultSize
,
2110 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2111 const wxValidator
& validator
= wxDefaultValidator
);
2114 Calls the identical method from wxDataViewTreeStore.
2116 void DeleteAllItems();
2119 Calls the identical method from wxDataViewTreeStore.
2121 void DeleteChildren(const wxDataViewItem
& item
);
2124 Calls the identical method from wxDataViewTreeStore.
2126 void DeleteItem(const wxDataViewItem
& item
);
2129 Calls the identical method from wxDataViewTreeStore.
2131 int GetChildCount(const wxDataViewItem
& parent
) const;
2134 Returns the image list.
2136 wxImageList
* GetImageList();
2139 Calls the identical method from wxDataViewTreeStore.
2141 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2144 Calls the identical method from wxDataViewTreeStore.
2146 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2149 Calls the identical method from wxDataViewTreeStore.
2151 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2154 Calls the identical method from wxDataViewTreeStore.
2156 wxString
GetItemText(const wxDataViewItem
& item
) const;
2159 Calls the identical method from wxDataViewTreeStore.
2161 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2162 unsigned int pos
) const;
2168 wxDataViewTreeStore
* GetStore();
2169 const wxDataViewTreeStore
* GetStore() const;
2173 Calls the same method from wxDataViewTreeStore but uses
2174 an index position in the image list instead of a wxIcon.
2176 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2177 const wxDataViewItem
& previous
,
2178 const wxString
& text
,
2181 wxClientData
* data
= NULL
);
2184 Calls the same method from wxDataViewTreeStore but uses
2185 an index position in the image list instead of a wxIcon.
2187 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2188 const wxDataViewItem
& previous
,
2189 const wxString
& text
,
2191 wxClientData
* data
= NULL
);
2194 Returns true if item is a container.
2196 bool IsContainer( const wxDataViewItem
& item
);
2199 Calls the same method from wxDataViewTreeStore but uses
2200 an index position in the image list instead of a wxIcon.
2202 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2203 const wxString
& text
,
2206 wxClientData
* data
= NULL
);
2209 Calls the same method from wxDataViewTreeStore but uses
2210 an index position in the image list instead of a wxIcon.
2212 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2213 const wxString
& text
,
2215 wxClientData
* data
= NULL
);
2218 Sets the image list.
2220 void SetImageList(wxImageList
* imagelist
);
2223 Calls the identical method from wxDataViewTreeStore.
2225 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2228 Calls the identical method from wxDataViewTreeStore.
2230 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2231 const wxIcon
& icon
);
2234 Calls the identical method from wxDataViewTreeStore.
2236 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2239 Calls the identical method from wxDataViewTreeStore.
2241 void SetItemText(const wxDataViewItem
& item
,
2242 const wxString
& text
);
2247 @class wxDataViewListStore
2249 wxDataViewListStore is a specialised wxDataViewModel for storing
2250 a simple table of data. Since it derives from wxDataViewIndexListModel
2251 its data is be accessed by row (i.e. by index) instead of only
2254 This class actually stores the values (therefore its name)
2255 and implements all virtual methods from the base classes so it can be
2256 used directly without having to derive any class from it, but it is
2257 mostly used from within wxDataViewListCtrl.
2263 class wxDataViewListStore
: public wxDataViewIndexListModel
2269 wxDataViewListStore();
2274 ~wxDataViewListStore();
2277 Prepends a data column.
2279 @a variantype indicates the type of values store in the column.
2281 This does not automatically fill in any (default) values in
2282 rows which exist in the store already.
2284 void PrependColumn( const wxString
&varianttype
);
2287 Inserts a data column before @a pos.
2289 @a variantype indicates the type of values store in the column.
2291 This does not automatically fill in any (default) values in
2292 rows which exist in the store already.
2294 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
2297 Appends a data column.
2299 @a variantype indicates the type of values store in the column.
2301 This does not automatically fill in any (default) values in
2302 rows which exist in the store already.
2304 void AppendColumn( const wxString
&varianttype
);
2307 Appends an item (=row) and fills it with @a values.
2309 The values must match the values specifies in the column
2310 in number and type. No (default) values are filled in
2313 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2316 Prepends an item (=row) and fills it with @a values.
2318 The values must match the values specifies in the column
2319 in number and type. No (default) values are filled in
2322 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2325 Inserts an item (=row) and fills it with @a values.
2327 The values must match the values specifies in the column
2328 in number and type. No (default) values are filled in
2331 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2334 Delete the item (=row) at position @a pos.
2336 void DeleteItem( unsigned pos
);
2339 Delete all item (=all rows) in the store.
2341 void DeleteAllItems();
2344 Overriden from wxDataViewModel
2346 virtual unsigned int GetColumnCount() const;
2349 Overriden from wxDataViewModel
2351 virtual wxString
GetColumnType( unsigned int col
) const;
2354 Overriden from wxDataViewIndexListModel
2356 virtual void GetValueByRow( wxVariant
&value
,
2357 unsigned int row
, unsigned int col
) const;
2360 Overriden from wxDataViewIndexListModel
2362 virtual bool SetValueByRow( const wxVariant
&value
,
2363 unsigned int row
, unsigned int col
);
2368 @class wxDataViewTreeStore
2370 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2371 trees very much like wxTreeCtrl does and it offers a similar API.
2373 This class actually stores the entire tree and the values (therefore its name)
2374 and implements all virtual methods from the base class so it can be used directly
2375 without having to derive any class from it, but it is mostly used from within
2381 class wxDataViewTreeStore
: public wxDataViewModel
2385 Constructor. Creates the invisible root node internally.
2387 wxDataViewTreeStore();
2392 virtual ~wxDataViewTreeStore();
2397 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2398 const wxString
& text
,
2399 const wxIcon
& icon
= wxNullIcon
,
2400 const wxIcon
& expanded
= wxNullIcon
,
2401 wxClientData
* data
= NULL
);
2406 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2407 const wxString
& text
,
2408 const wxIcon
& icon
= wxNullIcon
,
2409 wxClientData
* data
= NULL
);
2412 Delete all item in the model.
2414 void DeleteAllItems();
2417 Delete all children of the item, but not the item itself.
2419 void DeleteChildren(const wxDataViewItem
& item
);
2424 void DeleteItem(const wxDataViewItem
& item
);
2427 Return the number of children of item.
2429 int GetChildCount(const wxDataViewItem
& parent
) const;
2432 Returns the client data asoociated with the item.
2434 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2437 Returns the icon to display in expanded containers.
2439 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2442 Returns the icon of the item.
2444 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2447 Returns the text of the item.
2449 wxString
GetItemText(const wxDataViewItem
& item
) const;
2452 Returns the nth child item of item.
2454 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2455 unsigned int pos
) const;
2458 Inserts a container after @a previous.
2460 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2461 const wxDataViewItem
& previous
,
2462 const wxString
& text
,
2463 const wxIcon
& icon
= wxNullIcon
,
2464 const wxIcon
& expanded
= wxNullIcon
,
2465 wxClientData
* data
= NULL
);
2468 Inserts an item after @a previous.
2470 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2471 const wxDataViewItem
& previous
,
2472 const wxString
& text
,
2473 const wxIcon
& icon
= wxNullIcon
,
2474 wxClientData
* data
= NULL
);
2477 Inserts a container before the first child item or @a parent.
2479 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2480 const wxString
& text
,
2481 const wxIcon
& icon
= wxNullIcon
,
2482 const wxIcon
& expanded
= wxNullIcon
,
2483 wxClientData
* data
= NULL
);
2486 Inserts an item before the first child item or @a parent.
2488 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2489 const wxString
& text
,
2490 const wxIcon
& icon
= wxNullIcon
,
2491 wxClientData
* data
= NULL
);
2494 Sets the client data associated with the item.
2496 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2499 Sets the expanded icon for the item.
2501 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2502 const wxIcon
& icon
);
2505 Sets the icon for the item.
2507 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2512 @class wxDataViewIconText
2514 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2515 This class can be converted to and from a wxVariant.
2520 class wxDataViewIconText
: public wxObject
2527 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2528 const wxIcon
& icon
= wxNullIcon
);
2529 wxDataViewIconText(const wxDataViewIconText
& other
);
2535 const wxIcon
& GetIcon() const;
2540 wxString
GetText() const;
2545 void SetIcon(const wxIcon
& icon
);
2550 void SetText(const wxString
& text
);
2556 @class wxDataViewEvent
2558 This is the event class for the wxDataViewCtrl notifications.
2560 @beginEventTable{wxDataViewEvent}
2561 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2562 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2563 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2564 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2565 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2566 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2567 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2568 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2569 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2570 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2571 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2572 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2573 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2574 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2575 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2576 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2577 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2578 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2579 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2580 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2581 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2582 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2583 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2584 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2585 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2586 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2587 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2588 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2589 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2590 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2591 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2592 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2593 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2594 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2595 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
2596 Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
2600 @category{events,dvc}
2602 class wxDataViewEvent
: public wxNotifyEvent
2606 Constructor. Typically used by wxWidgets internals only.
2608 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2612 Returns the position of the column in the control or -1
2613 if no column field was set by the event emitter.
2615 int GetColumn() const;
2618 Returns a pointer to the wxDataViewColumn from which
2619 the event was emitted or @NULL.
2621 wxDataViewColumn
* GetDataViewColumn() const;
2624 Returns the wxDataViewModel associated with the event.
2626 wxDataViewModel
* GetModel() const;
2629 Returns a the position of a context menu event in screen coordinates.
2631 wxPoint
GetPosition() const;
2634 Returns a reference to a value.
2636 const wxVariant
& GetValue() const;
2639 Sets the column index associated with this event.
2641 void SetColumn(int col
);
2644 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2646 void SetDataViewColumn(wxDataViewColumn
* col
);
2649 Sets the dataview model associated with this event.
2651 void SetModel(wxDataViewModel
* model
);
2654 Sets the value associated with this event.
2656 void SetValue(const wxVariant
& value
);
2659 Set wxDataObject for data transfer within a drag operation.
2661 void SetDataObject( wxDataObject
*obj
);
2664 Used internally. Gets associated wxDataObject for data transfer
2665 within a drag operation.
2667 wxDataObject
*GetDataObject() const;
2670 Used internally. Sets the wxDataFormat during a drop operation.
2672 void SetDataFormat( const wxDataFormat
&format
);
2675 Gets the wxDataFormat during a drop operation.
2677 wxDataFormat
GetDataFormat() const;
2680 Used internally. Sets the data size for a drop data transfer.
2682 void SetDataSize( size_t size
);
2685 Gets the data size for a drop data transfer.
2687 size_t GetDataSize() const;
2690 Used internally. Sets the data buffer for a drop data transfer.
2692 void SetDataBuffer( void* buf
);
2695 Gets the data buffer for a drop data transfer.
2697 void *GetDataBuffer() const;
2700 Return the first row that will be displayed.
2702 int GetCacheFrom() const;
2705 Return the last row that will be displayed.
2707 int GetCacheTo() const;