#include <wx/dataview.h>
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.
This class supports the following styles:
The following event handler macros redirect the events to member function handlers 'func' with prototypes like:
Event macros for events emitted by this class:
wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
event. wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
event. wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
event. This event can be vetoed in order to prevent editing on an item by item basis. Still experimental. wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
event. wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
event. wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
event. wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
event. wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
event. wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
event. wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
event. wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
event. wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED
event. wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED
event. wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
event. wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
event. wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
event. wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
event. wxEVT_COMMAND_DATAVIEW_ITEM_DROP
event. ![]() | ![]() | ![]() |
wxMSW appearance | wxGTK appearance | wxMac appearance |
Public Member Functions | |
wxDataViewCtrl () | |
Default Constructor. | |
wxDataViewCtrl (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator) | |
Constructor. | |
virtual | ~wxDataViewCtrl () |
Destructor. | |
virtual bool | AppendColumn (wxDataViewColumn *col) |
Appends a wxDataViewColumn to the control. | |
virtual bool | PrependColumn (wxDataViewColumn *col) |
Prepends a wxDataViewColumn to the control. | |
virtual bool | InsertColumn (unsigned int pos, wxDataViewColumn *col) |
Inserts a wxDataViewColumn to the control. | |
virtual bool | AssociateModel (wxDataViewModel *model) |
Associates a wxDataViewModel with the control. | |
virtual bool | ClearColumns () |
Removes all columns. | |
virtual void | Collapse (const wxDataViewItem &item) |
Collapses the item. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator) |
Create the control. | |
virtual bool | DeleteColumn (wxDataViewColumn *column) |
Deletes given column. | |
virtual bool | EnableDragSource (const wxDataFormat &format) |
Enable drag operations using the given format. | |
virtual bool | EnableDropTarget (const wxDataFormat &format) |
Enable drop operations using the given format. | |
virtual void | EnsureVisible (const wxDataViewItem &item, const wxDataViewColumn *column=NULL) |
Call this to ensure that the given item is visible. | |
virtual void | Expand (const wxDataViewItem &item) |
Expands the item. | |
virtual void | ExpandAncestors (const wxDataViewItem &item) |
Expands all ancestors of the item. | |
virtual wxDataViewColumn * | GetColumn (unsigned int pos) const |
Returns pointer to the column. | |
virtual unsigned int | GetColumnCount () const |
Returns the number of columns. | |
virtual int | GetColumnPosition (const wxDataViewColumn *column) const |
Returns the position of the column or -1 if not found in the control. | |
wxDataViewColumn * | GetExpanderColumn () const |
Returns column containing the expanders. | |
int | GetIndent () const |
Returns indentation. | |
virtual wxRect | GetItemRect (const wxDataViewItem &item, const wxDataViewColumn *col=NULL) const |
Returns item rect. | |
wxDataViewModel * | GetModel () |
Returns pointer to the data model associated with the control (if any). | |
virtual wxDataViewItem | GetSelection () const |
Returns first selected item or an invalid item if none is selected. | |
virtual int | GetSelections (wxDataViewItemArray &sel) const |
Fills sel with currently selected items and returns their number. | |
virtual wxDataViewColumn * | GetSortingColumn () const |
Returns the wxDataViewColumn currently responsible for sorting or NULL if none has been selected. | |
virtual void | HitTest (const wxPoint &point, wxDataViewItem &item, wxDataViewColumn *&col) const |
Hittest. | |
virtual bool | IsExpanded (const wxDataViewItem &item) const |
Return true if the item is expanded. | |
virtual bool | IsSelected (const wxDataViewItem &item) const |
Return true if the item is selected. | |
virtual void | Select (const wxDataViewItem &item) |
Select the given item. | |
virtual void | SelectAll () |
Select all items. | |
void | SetExpanderColumn (wxDataViewColumn *col) |
Set which column shall contain the tree-like expanders. | |
void | SetIndent (int indent) |
Sets the indendation. | |
virtual void | SetSelections (const wxDataViewItemArray &sel) |
Sets the selection to the array of wxDataViewItems. | |
virtual void | Unselect (const wxDataViewItem &item) |
Unselect the given item. | |
virtual void | UnselectAll () |
Unselect all item. | |
wxDataViewColumn * | AppendBitmapColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendBitmapColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendDateColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a date. | |
wxDataViewColumn * | AppendDateColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendIconTextColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering text with an icon. | |
wxDataViewColumn * | AppendIconTextColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendProgressColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=80, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a progress indicator. | |
wxDataViewColumn * | AppendProgressColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=80, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendTextColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering text. | |
wxDataViewColumn * | AppendTextColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=-1, wxAlignment align=wxALIGN_NOT, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. | |
wxDataViewColumn * | AppendToggleColumn (const wxString &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=30, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a toggle. | |
wxDataViewColumn * | AppendToggleColumn (const wxBitmap &label, unsigned int model_column, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int width=30, wxAlignment align=wxALIGN_CENTER, int flags=wxDATAVIEW_COL_RESIZABLE) |
Appends a column for rendering a bitmap. |
wxDataViewCtrl::wxDataViewCtrl | ( | ) |
Default Constructor.
wxDataViewCtrl::wxDataViewCtrl | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
long | style = 0 , |
|||
const wxValidator & | validator = wxDefaultValidator | |||
) |
Constructor.
Calls Create().
virtual wxDataViewCtrl::~wxDataViewCtrl | ( | ) | [virtual] |
Destructor.
wxDataViewColumn* wxDataViewCtrl::AppendBitmapColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendBitmapColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
virtual bool wxDataViewCtrl::AppendColumn | ( | wxDataViewColumn * | col | ) | [virtual] |
Appends a wxDataViewColumn to the control.
Returns true on success.
Note that there is a number of short cut methods which implicitly create a wxDataViewColumn and a wxDataViewRenderer for it (see below).
Reimplemented in wxDataViewListCtrl.
wxDataViewColumn* wxDataViewCtrl::AppendDateColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_ACTIVATABLE , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendDateColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_ACTIVATABLE , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a date.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendIconTextColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendIconTextColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
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.
wxDataViewColumn* wxDataViewCtrl::AppendProgressColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = 80 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendProgressColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = 80 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a progress indicator.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendTextColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendTextColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = -1 , |
|||
wxAlignment | align = wxALIGN_NOT , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering text.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendToggleColumn | ( | const wxBitmap & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = 30 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a bitmap.
Returns the wxDataViewColumn created in the function or NULL on failure.
wxDataViewColumn* wxDataViewCtrl::AppendToggleColumn | ( | const wxString & | label, | |
unsigned int | model_column, | |||
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
|||
int | width = 30 , |
|||
wxAlignment | align = wxALIGN_CENTER , |
|||
int | flags = wxDATAVIEW_COL_RESIZABLE | |||
) |
Appends a column for rendering a toggle.
Returns the wxDataViewColumn created in the function or NULL on failure.
virtual bool wxDataViewCtrl::AssociateModel | ( | wxDataViewModel * | model | ) | [virtual] |
Associates a wxDataViewModel with the control.
This increases the reference count of the model by 1.
virtual bool wxDataViewCtrl::ClearColumns | ( | ) | [virtual] |
Removes all columns.
virtual void wxDataViewCtrl::Collapse | ( | const wxDataViewItem & | item | ) | [virtual] |
Collapses the item.
bool wxDataViewCtrl::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.
Reimplemented in wxDataViewListCtrl, and wxDataViewTreeCtrl.
virtual bool wxDataViewCtrl::DeleteColumn | ( | wxDataViewColumn * | column | ) | [virtual] |
Deletes given column.
virtual bool wxDataViewCtrl::EnableDragSource | ( | const wxDataFormat & | format | ) | [virtual] |
Enable drag operations using the given format.
virtual bool wxDataViewCtrl::EnableDropTarget | ( | const wxDataFormat & | format | ) | [virtual] |
Enable drop operations using the given format.
virtual void wxDataViewCtrl::EnsureVisible | ( | const wxDataViewItem & | item, | |
const wxDataViewColumn * | column = NULL | |||
) | [virtual] |
Call this to ensure that the given item is visible.
virtual void wxDataViewCtrl::Expand | ( | const wxDataViewItem & | item | ) | [virtual] |
Expands the item.
virtual void wxDataViewCtrl::ExpandAncestors | ( | const wxDataViewItem & | item | ) | [virtual] |
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.
virtual wxDataViewColumn* wxDataViewCtrl::GetColumn | ( | unsigned int | pos | ) | const [virtual] |
Returns pointer to the column.
pos refers to the position in the control which may change after reordering columns by the user.
virtual unsigned int wxDataViewCtrl::GetColumnCount | ( | ) | const [virtual] |
Returns the number of columns.
virtual int wxDataViewCtrl::GetColumnPosition | ( | const wxDataViewColumn * | column | ) | const [virtual] |
Returns the position of the column or -1 if not found in the control.
wxDataViewColumn* wxDataViewCtrl::GetExpanderColumn | ( | ) | const |
Returns column containing the expanders.
int wxDataViewCtrl::GetIndent | ( | ) | const |
Returns indentation.
virtual wxRect wxDataViewCtrl::GetItemRect | ( | const wxDataViewItem & | item, | |
const wxDataViewColumn * | col = NULL | |||
) | const [virtual] |
Returns item rect.
wxDataViewModel* wxDataViewCtrl::GetModel | ( | ) |
Returns pointer to the data model associated with the control (if any).
virtual wxDataViewItem wxDataViewCtrl::GetSelection | ( | ) | const [virtual] |
Returns first selected item or an invalid item if none is selected.
virtual int wxDataViewCtrl::GetSelections | ( | wxDataViewItemArray & | sel | ) | const [virtual] |
Fills sel with currently selected items and returns their number.
virtual wxDataViewColumn* wxDataViewCtrl::GetSortingColumn | ( | ) | const [virtual] |
Returns the wxDataViewColumn currently responsible for sorting or NULL if none has been selected.
virtual void wxDataViewCtrl::HitTest | ( | const wxPoint & | point, | |
wxDataViewItem & | item, | |||
wxDataViewColumn *& | col | |||
) | const [virtual] |
Hittest.
virtual bool wxDataViewCtrl::InsertColumn | ( | unsigned int | pos, | |
wxDataViewColumn * | col | |||
) | [virtual] |
Inserts a wxDataViewColumn to the control.
Returns true on success.
Reimplemented in wxDataViewListCtrl.
virtual bool wxDataViewCtrl::IsExpanded | ( | const wxDataViewItem & | item | ) | const [virtual] |
Return true if the item is expanded.
virtual bool wxDataViewCtrl::IsSelected | ( | const wxDataViewItem & | item | ) | const [virtual] |
Return true if the item is selected.
virtual bool wxDataViewCtrl::PrependColumn | ( | wxDataViewColumn * | col | ) | [virtual] |
Prepends a wxDataViewColumn to the control.
Returns true on success.
Note that there is a number of short cut methods which implicitly create a wxDataViewColumn and a wxDataViewRenderer for it.
Reimplemented in wxDataViewListCtrl.
virtual void wxDataViewCtrl::Select | ( | const wxDataViewItem & | item | ) | [virtual] |
Select the given item.
virtual void wxDataViewCtrl::SelectAll | ( | ) | [virtual] |
Select all items.
void wxDataViewCtrl::SetExpanderColumn | ( | wxDataViewColumn * | col | ) |
Set which column shall contain the tree-like expanders.
void wxDataViewCtrl::SetIndent | ( | int | indent | ) |
Sets the indendation.
virtual void wxDataViewCtrl::SetSelections | ( | const wxDataViewItemArray & | sel | ) | [virtual] |
Sets the selection to the array of wxDataViewItems.
virtual void wxDataViewCtrl::Unselect | ( | const wxDataViewItem & | item | ) | [virtual] |
Unselect the given item.
virtual void wxDataViewCtrl::UnselectAll | ( | ) | [virtual] |
Unselect all item.
This method only has effect if multiple selections are allowed.
![]() |
[ top ] |