Contents Up Previous Next

wxDataViewCtrl

This class and its documentation are work in progress and certainly subject to change.

wxDataViewCtrl is planned to be a control to display data either in a tree like fashion or in a tabular form or both. Currently, only the tabular form is implemented. wxDataViewCtrl doesn't get its data from the user through virtual functions or events, instead you need to write your own wxDataViewListModel 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 renderes 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.

So far, this control has only be implemented for GTK+ and there are only barely working stubs for a generic implementation. It is planned to implement the control natively under OS X and use generic code under Windows (and elsewhere).

Window styles

wxDV_SINGLE Single selection mode. This is the default.
wxDV_MULTIPLE Multiple selection mode.

Event handling

To process input from a dataview control, use the following event handler macros to direct input to member functions that take a wxDataViewEvent argument.

EVT_DATAVIEW_ROW_SELECTED(id, func) Processes a wxEVT_COMMAND_DATAVIEW_ROW_SELECTED event.
EVT_DATAVIEW_ROW_ACTIVATED(id, func) Processes a wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED event.
EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func) Processes a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func) Processes a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.

Derived from

wxControl

Include files

<wx/dataview.h>

wxDataViewCtrl::wxDataViewCtrl
wxDataViewCtrl::~wxDataViewCtrl
wxDataViewCtrl::AppendColumn
wxDataViewCtrl::AppendBitmapColumn
wxDataViewCtrl::AppendDateColumn
wxDataViewCtrl::AppendProgressColumn
wxDataViewCtrl::AppendTextColumn
wxDataViewCtrl::AppendToggleColumn
wxDataViewCtrl::AssociateModel
wxDataViewCtrl::Create
wxDataViewCtrl::ClearColumns
wxDataViewCtrl::ClearSelection
wxDataViewCtrl::DeleteColumn
wxDataViewCtrl::GetColumn
wxDataViewCtrl::GetModel
wxDataViewCtrl::GetNumberOfColumns
wxDataViewCtrl::GetSelection
wxDataViewCtrl::GetSelections
wxDataViewCtrl::IsSelected
wxDataViewCtrl::SetSelection
wxDataViewCtrl::SetSelectionRange
wxDataViewCtrl::SetSelections
wxDataViewCtrl::Unselect


wxDataViewCtrl::wxDataViewCtrl

wxDataViewCtrl()

wxDataViewCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator)

Constructor. Calls Create.


wxDataViewCtrl::~wxDataViewCtrl

~wxDataViewCtrl()

Destructor.


wxDataViewCtrl::AppendColumn

virtual bool AppendColumn(wxDataViewColumn* col)

Add 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).


wxDataViewCtrl::AppendBitmapColumn

bool AppendBitmapColumn(const wxString& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1)

bool AppendBitmapColumn(const wxBitmap& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1)

Appends a column for rendering a bitmap.


wxDataViewCtrl::AppendDateColumn

bool AppendDateColumn(const wxString& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1)

bool AppendDateColumn(const wxBitmap& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1)

Appends a column for rendering a date.


wxDataViewCtrl::AppendProgressColumn

bool AppendProgressColumn(const wxString& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80)

bool AppendProgressColumn(const wxBitmap& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80)

Appends a column for rendering a progress indicator.


wxDataViewCtrl::AppendTextColumn

bool AppendTextColumn(const wxString& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1)

bool AppendTextColumn(const wxBitmap& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1)

Appends a column for rendering text.


wxDataViewCtrl::AppendToggleColumn

bool AppendToggleColumn(const wxString& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30)

bool AppendToggleColumn(const wxBitmap& label, unsigned int model_column, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30)

Appends a column for rendering a toggle.


wxDataViewCtrl::AssociateModel

virtual bool AssociateModel(wxDataViewListModel* model)

Associates a wxDataViewListModel with the control. In the future this should be changed to supporting any data model including a to-be-written wxDataViewTreeModel.


wxDataViewCtrl::Create

bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator)

Create the control. Useful for two step creation.


wxDataViewCtrl::ClearColumns

virtual bool ClearColumns()

Removes all columns.


wxDataViewCtrl::ClearSelection

void ClearSelection()

Unselects all rows.


wxDataViewCtrl::DeleteColumn

virtual bool DeleteColumn(unsigned int pos)

Deletes given column.


wxDataViewCtrl::GetColumn

virtual wxDataViewColumn* GetColumn(unsigned int pos)

Returns pointer to the column.


wxDataViewCtrl::GetModel

virtual wxDataViewListModel* GetModel()

Returns pointer to the data model associated with the control (if any).


wxDataViewCtrl::GetNumberOfColumns

virtual unsigned int GetNumberOfColumns()

Returns the number of columns.


wxDataViewCtrl::GetSelection

virtual int GetSelection() const

Returns the index of the currently selected row. It will return -1 if no row is selected and the index of the first selected row if more than one row are selected.


wxDataViewCtrl::GetSelections

virtual int GetSelections(wxArrayInt& aSelections) const

Returns the number of selected rows and fills an array of int with the indeces of the selected rows.


wxDataViewCtrl::IsSelected

virtual bool IsSelected(unsigned int row) const

Returns true if the row is selected, false otherwise.


wxDataViewCtrl::SetSelection

virtual void SetSelection(int row)

Sets the selection. Use -1 to unselect all rows.


wxDataViewCtrl::SetSelectionRange

virtual void SetSelectionRange(unsigned int from, unsigned int to)

Set a range of selection.


wxDataViewCtrl::SetSelections

virtual void SetSelections(const wxArrayInt& aSelections)

Set the selection to the array of int.


wxDataViewCtrl::Unselect

virtual void Unselect(unsigned int row)

Unselect a particular row.