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.