wxDataViewCtrl is a control to display data either in a tree like fashion or in a tabular form or both.
If you only need to display a simple tree structure with an API more like the older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used. Likewise, if you only want to display simple table structure you can use the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and wxDataViewListCtrl can be used without defining your own wxDataViewModel.
A wxDataViewItem is used to represent a (visible) item in the control.
Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through virtual functions or by setting it directly. Instead you need to write your own wxDataViewModel and associate it with this control. Then you need to add a number of wxDataViewColumn to this control to define what each column shall display. Each wxDataViewColumn in turn owns 1 instance of a wxDataViewRenderer to render its cells.
A number of standard renderers for rendering text, dates, images, toggle, a progress bar etc. are provided. Additionally, the user can write custom renderers deriving from wxDataViewCustomRenderer for displaying anything.
All data transfer from the control to the model and the user code is done through wxVariant which can be extended to support more data formats as necessary. Accordingly, all type information uses the strings returned from wxVariant::GetType.
Single selection mode. This is the default.
Use alternating colours for rows if supported by platform and theme. Currently only supported by the native GTK and OS X implementations but not by the generic one.
Display the separator lines between rows.
Display the separator lines between columns.
Allow variable line heights. This can be inefficient when displaying large number of items.
Do not show column headers (which are shown by default).
Process a wxEVT_DATAVIEW_ITEM_ACTIVATED event. This event is triggered by double clicking an item or pressing some special key (usually "Enter") when it is focused.
Process a wxEVT_DATAVIEW_ITEM_START_EDITING event. This event can be vetoed in order to prevent editing on an item by item basis.
Process a wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event generated when the user right clicks inside the control. Notice that this menu is generated even if the click didn't occur on any valid item, in this case wxDataViewEvent::GetItem() simply returns an invalid item.
Process a wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event. Notice that currently this event is not generated in the native OS X versions of the control.
Notice that this control doesn't allow to process generic mouse events such as wxEVT_LEFT_DOWN in all ports (notably it doesn't work in wxGTK). If you need to handle any mouse events not covered by the ones above, consider using a custom renderer for the cells that must handle them.
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
Appends a wxDataViewColumn to the control.
Note that there is a number of short cut methods which implicitly create a wxDataViewColumn and a wxDataViewRenderer for it (see below).
Appends a column for rendering a date.
The align parameter is applied to both the column header and the column renderer.
Appends a column for rendering text with an icon.
Returns the wxDataViewColumn created in the function or NULL on failure. This method uses the wxDataViewIconTextRenderer class.
Appends a column for rendering a progress indicator.
Appends a column for rendering text.
Appends a column for rendering a toggle.
Associates a wxDataViewModel with the control.
This increases the reference count of the model by 1.
Useful for two step creation.
Programmatically starts editing given cell of item.
Doesn't do anything if the item or this column is not editable.
Currently not implemented in wxOSX/Carbon.
Enable drag operations using the given format.
Enable drop operations using the given format.
Call this to ensure that the given item is visible.
Expands all ancestors of the item.
This method also ensures that the item itself as well as all ancestor items have been read from the model by the control.
Returns pointer to the column.
pos refers to the position in the control which may change after reordering columns by the user.
Returns the position of the column or -1 if not found in the control.
Returns the column that currently has focus.
If the focus is set to individual cell within the currently focused item (as opposed to being on the item as a whole), then this is the column that the focus is on.
Returns NULL if no column currently has focus.
Returns the currently focused item.
This is the item that the keyboard commands apply to. It may be invalid if there is no focus currently.
This method is mostly useful for the controls with wxDV_MULTIPLE style as in the case of single selection it returns the same thing as GetSelection().
Notice that under all platforms except Mac OS X the currently focused item may be selected or not but under OS X the current item is always selected.
Returns column containing the expanders.
This method is currently not implemented at all in wxGTK and only implemented for non-NULL col argument in wxOSX. It is fully implemented in the generic version of the control.
col If non-NULL, the rectangle returned corresponds to the intersection of the item with the specified column. If NULL, the rectangle spans all the columns.
Returns pointer to the data model associated with the control (if any).
This method may be called for both the controls with single and multiple selections and returns the number of selected item, possibly 0, in any case.
Returns first selected item or an invalid item if none is selected.
This method may be called for both the controls with single and multiple selections but returns an invalid item if more than one item is selected in the latter case, use HasSelection() to determine if there are any selected items when using multiple selection.
Fills sel with currently selected items and returns their number.
This method may be called for both the controls with single and multiple selections. In the single selection case it returns the array with at most one element in it.
Returns the wxDataViewColumn currently responsible for sorting or NULL if none has been selected.
Returns true if any items are currently selected.
This method may be called for both the controls with single and multiple selections.
Calling this method is equivalent to calling GetSelectedItemsCount() and comparing its result with 0 but is more clear and might also be implemented more efficiently in the future.
Inserts a wxDataViewColumn to the control.
Return true if the item is expanded.
Return true if the item is selected.
Prepends a column for rendering a bitmap.
Prepends a wxDataViewColumn to the control.
Note that there is a number of short cut methods which implicitly create a wxDataViewColumn and a wxDataViewRenderer for it.
Prepends a column for rendering a date.
Prepends a column for rendering text with an icon.
Prepends a column for rendering a progress indicator.
Prepends a column for rendering text.
Prepends a column for rendering a toggle.
In single selection mode this changes the (unique) currently selected item. In multi selection mode, the item is selected and the previously selected items remain selected.
Changes the currently focused item.
The item parameter must be valid, there is no way to remove the current item from the control.
In single selection mode, calling this method is the same as calling Select() and is thus not very useful. In multiple selection mode this method only moves the current item however without changing the selection except under OS X where the current item is always selected, so calling SetCurrentItem() selects item if it hadn't been selected before.
Set which column shall contain the tree-like expanders.
This function can only be used when all rows have the same height, i.e. when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
Currently this is implemented in the generic and native GTK versions only and nothing is done (and false returned) when using OS X port.
Also notice that this method can only be used to increase the row height compared with the default one (as determined by the return value of wxDataViewRenderer::GetSize()), if it is set to a too small value then the minimum required by the renderers will be used.
true if the line height was changed or false otherwise.
Sets the selection to the array of wxDataViewItems.
This method only has effect if multiple selections are allowed.