1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataViewIconText
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDataViewIconText
13 wxDataViewIconText is used by
14 wxDataViewIconTextRenderer
15 for data transfer. This class can be converted to a from
21 class wxDataViewIconText
: public wxObject
28 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
29 const wxIcon
& icon
= wxNullIcon
);
30 wxDataViewIconText(const wxDataViewIconText
& other
);
36 const wxIcon
GetIcon() const;
41 wxString
GetText() const;
46 void SetIcon(const wxIcon
& icon
);
51 void SetText(const wxString
& text
);
57 @class wxDataViewEvent
60 wxDataViewEvent - the event class for the wxDataViewCtrl notifications
65 class wxDataViewEvent
: public wxNotifyEvent
72 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
74 wxDataViewEvent(const wxDataViewEvent
& event
);
78 Used to clone the event.
80 wxEvent
* Clone() const;
83 Returns the position of the column in the control or -1
84 if no column field was set by the event emitter.
86 int GetColumn() const;
89 Returns a pointer to the wxDataViewColumn from which
90 the event was emitted or @NULL.
92 wxDataViewColumn
* GetDataViewColumn();
95 Returns the wxDataViewModel associated with the event.
97 wxDataViewModel
* GetModel() const;
100 Returns a the position of a context menu event in screen coordinates.
102 wxPoint
GetPosition() const;
105 Returns a reference to a value.
107 const wxVariant
GetValue() const;
112 void SetColumn(int col
);
115 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
117 void SetDataViewColumn(wxDataViewColumn
* col
);
122 void SetModel(wxDataViewModel
* model
);
127 void SetValue(const wxVariant
& value
);
130 @class wxDataViewModel
131 @wxheader{dataview.h}
133 wxDataViewModel is the base class for all data model to be
134 displayed by a wxDataViewCtrl.
135 All other models derive from it and must implement its
136 pure virtual functions in order to define a complete
137 data model. In detail, you need to override
138 wxDataViewModel::IsContainer,
139 wxDataViewModel::GetParent,
140 wxDataViewModel::GetChildren,
141 wxDataViewModel::GetColumnCount,
142 wxDataViewModel::GetColumnType and
143 wxDataViewModel::GetValue in order to
144 define the data model which acts as an interface between
145 your actual data and the wxDataViewCtrl. Since you will
146 usually also allow the wxDataViewCtrl to change your data
147 through its graphical interface, you will also have to override
148 wxDataViewModel::SetValue which the
149 wxDataViewCtrl will call when a change to some data has been
152 wxDataViewModel (as indeed the entire wxDataViewCtrl
153 code) is using wxVariant to store data and
154 its type in a generic way. wxVariant can be extended to contain
155 almost any data without changes to the original class.
157 The data that is presented through this data model is expected
158 to change at run-time. You need to inform the data model when
159 a change happened. Depending on what happened you need to call
160 one of the following methods:
161 wxDataViewModel::ValueChanged,
162 wxDataViewModel::ItemAdded,
163 wxDataViewModel::ItemDeleted,
164 wxDataViewModel::ItemChanged,
165 wxDataViewModel::Cleared. There are
166 plural forms for notification of addition, change
167 or removal of several item at once. See
168 wxDataViewModel::ItemsAdded,
169 wxDataViewModel::ItemsDeleted,
170 wxDataViewModel::ItemsChanged.
172 Note that wxDataViewModel does not define the position or
173 index of any item in the control because different controls
174 might display the same data differently. wxDataViewModel does
175 provide a wxDataViewModel::Compare method
176 which the wxDataViewCtrl may use to sort the data either
177 in conjunction with a column header or without (see
178 wxDataViewModel::HasDefaultCompare).
180 This class maintains a list of
181 wxDataViewModelNotifier
182 which link this class to the specific implementations on the
183 supported platforms so that e.g. calling
184 wxDataViewModel::ValueChanged
185 on this model will just call
186 wxDataViewModelNotifier::ValueChanged
187 for each notifier that has been added. You can also add
188 your own notifier in order to get informed about any changes
189 to the data in the list model.
191 Currently wxWidgets provides the following models apart
193 wxDataViewIndexListModel,
194 wxDataViewVirtualListModel,
197 Note that wxDataViewModel is reference counted, derives from
198 wxObjectRefData and cannot be deleted
199 directly as it can be shared by several wxDataViewCtrls. This
200 implies that you need to decrease the reference count after
201 associating the model with a control like this:
204 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
205 wxDataViewModel *musicModel = new MyMusicModel;
206 m_musicCtrl-AssociateModel( musicModel );
207 musicModel-DecRef(); // avoid memory leak !!
215 class wxDataViewModel
: public wxObjectRefData
224 Destructor. This should not be called directly. Use DecRef() instead.
229 Adds a wxDataViewModelNotifier
232 void AddNotifier(wxDataViewModelNotifier
* notifier
);
235 Called to inform the model that all data has been cleared. The
236 control will reread the data from the model again.
238 virtual bool Cleared();
241 The compare function to be used by control. The default compare function
242 sorts by container and other items separately and in ascending order.
243 Override this for a different sorting behaviour.
244 See also HasDefaultCompare().
246 virtual int Compare(const wxDataViewItem
& item1
,
247 const wxDataViewItem
& item2
,
252 Oberride this to indicate that the item has special font attributes.
253 This only affects the
254 wxDataViewTextRendererText() renderer.
255 See also wxDataViewItemAttr.
257 bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
258 wxDataViewItemAttr
& attr
);
261 Override this so the control can query the child items of
262 an item. Returns the number of items.
264 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
265 wxDataViewItemArray
& children
) const;
268 Override this to indicate the number of columns in the model.
270 virtual unsigned int GetColumnCount() const;
273 Override this to indicate what type of data is stored in the
274 column specified by @e col. This should return a string
275 indicating the type of data as reported by wxVariant.
277 virtual wxString
GetColumnType(unsigned int col
) const;
280 Override this to indicate which wxDataViewItem representing the parent
281 of @a item or an invalid wxDataViewItem if the the root item is
284 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const;
287 Override this to indicate the value of @e item
288 A wxVariant is used to store the data.
290 virtual void GetValue(wxVariant
& variant
,
291 const wxDataViewItem
& item
,
292 unsigned int col
) const;
295 Override this method to indicate if a container item merely
296 acts as a headline (or for categorisation) or if it also
297 acts a normal item with entries for futher columns. By
298 default returns @e @false.
300 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
303 Override this to indicate that the model provides a default compare
304 function that the control should use if no wxDataViewColumn has been
305 chosen for sorting. Usually, the user clicks on a column header for
306 sorting, the data will be sorted alphanumerically. If any other
307 order (e.g. by index or order of appearance) is required, then this
308 should be used. See also wxDataViewIndexListModel
309 for a model which makes use of this.
311 virtual bool HasDefaultCompare() const;
314 Override this to indicate of @a item is a container, i.e. if
315 it can have child items.
317 virtual bool IsContainer(const wxDataViewItem
& item
) const;
320 Call this to inform the model that an item has been added
323 virtual bool ItemAdded(const wxDataViewItem
& parent
,
324 const wxDataViewItem
& item
);
327 Call this to inform the model that an item has changed.
328 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
329 event (in which the column fields will not be set) to the user.
331 virtual bool ItemChanged(const wxDataViewItem
& item
);
334 Call this to inform the model that an item has been deleted from the data.
336 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
337 const wxDataViewItem
& item
);
340 Call this to inform the model that several items have been added
343 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
344 const wxDataViewItemArray
& items
);
347 Call this to inform the model that several items have changed.
348 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
349 events (in which the column fields will not be set) to the user.
351 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
354 Call this to inform the model that several items have been deleted.
356 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
357 const wxDataViewItemArray
& items
);
360 Remove the @a notifier from the list of notifiers.
362 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
365 Call this to initiate a resort after the sort function has
368 virtual void Resort();
371 This gets called in order to set a value in the data model.
372 The most common scenario is that the wxDataViewCtrl calls
373 this method after the user changed some data in the view.
374 Afterwards ValueChanged()
377 virtual bool SetValue(const wxVariant
& variant
,
378 const wxDataViewItem
& item
,
382 Call this to inform this model that a value in the model has
383 been changed. This is also called from wxDataViewCtrl's
384 internal editing code, e.g. when editing a text field
386 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
389 virtual bool ValueChanged(const wxDataViewItem
& item
,
397 @class wxDataViewIndexListModel
398 @wxheader{dataview.h}
400 wxDataViewIndexListModel is a specialized data model which lets
401 you address an item by its position (row) rather than its
402 wxDataViewItem (which you can obtain from this class).
403 This model also provides its own wxDataViewIndexListModel::Compare
404 method which sorts the model's data by the index.
406 This model is not a virtual model since the control stores
407 each wxDataViewItem. Use wxDataViewVirtualListModel if you
408 need to display millions of items or have other reason to
409 use a virtual control.
414 class wxDataViewIndexListModel
: public wxDataViewModel
420 wxDataViewIndexListModel(unsigned int initial_size
= 0);
425 ~wxDataViewIndexListModel();
428 Compare method that sorts the items by their index.
430 int Compare(const wxDataViewItem
& item1
,
431 const wxDataViewItem
& item2
,
432 unsigned int column
, bool ascending
);
435 Oberride this to indicate that the row has special font attributes.
436 This only affects the
437 wxDataViewTextRendererText() renderer.
438 See also wxDataViewItemAttr.
440 bool GetAttr(unsigned int row
, unsigned int col
,
441 wxDataViewItemAttr
& attr
);
444 Returns the wxDataViewItem at the given @e row.
446 wxDataViewItem
GetItem(unsigned int row
) const;
449 Returns the position of given @e item.
451 unsigned int GetRow(const wxDataViewItem
& item
) const;
454 Override this to allow getting values from the model.
456 void GetValue(wxVariant
& variant
, unsigned int row
,
457 unsigned int col
) const;
460 Call this after if the data has to be read again from
461 the model. This is useful after major changes when
462 calling the methods below (possibly thousands of times)
465 void Reset(unsigned int new_size
);
468 Call this after a row has been appended to the model.
473 Call this after a row has been changed.
475 void RowChanged(unsigned int row
);
478 Call this after a row has been deleted.
480 void RowDeleted(unsigned int row
);
483 Call this after a row has been inserted at the given position.
485 void RowInserted(unsigned int before
);
488 Call this after a row has been prepended to the model.
493 Call this after a value has been changed.
495 void RowValueChanged(unsigned int row
, unsigned int col
);
498 Call this after rows have been deleted. The array will internally
499 get copied and sorted in descending order so that the rows with
500 the highest position will be deleted first.
502 void RowsDeleted(const wxArrayInt
& rows
);
505 Called in order to set a value in the model.
507 bool SetValue(const wxVariant
& variant
, unsigned int row
,
514 @class wxDataViewVirtualListModel
515 @wxheader{dataview.h}
517 wxDataViewVirtualListModel is a specialized data model which lets
518 you address an item by its position (row) rather than its
519 wxDataViewItem and as such offers the exact same interface as
520 wxDataViewIndexListModel. The important difference is that under
521 platforms other than OS X, using this model will result in a
522 truely virtual control able to handle millions of items as the
523 control doesn't store any item (a feature not supported by the
524 Carbon API under OS X).
526 @see wxDataViewIndexListModel for the API.
531 class wxDataViewVirtualListModel
: public wxDataViewModel
537 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
545 @class wxDataViewItemAttr
546 @wxheader{dataview.h}
548 This class is used to indicate to a wxDataViewCtrl
549 that a certain Item() has extra font attributes
550 for its renderer. For this, it is required to override
551 wxDataViewModel::GetAttr.
553 Attributes are currently only supported by
554 wxDataViewTextRendererText().
559 class wxDataViewItemAttr
565 wxDataViewItemAttr();
568 Call this to indicate that the item shall be displayed in bold text.
570 void SetBold(bool set
);
573 Call this to indicate that the item shall be displayed with
576 void SetColour(const wxColour
& colour
);
579 Call this to indicate that the item shall be displayed in italic text.
581 void SetItalic(bool set
);
587 @class wxDataViewItem
588 @wxheader{dataview.h}
590 wxDataViewItem is a small opaque class that represents an
591 item in a wxDataViewCtrl in a
592 persistent way, i.e. indepent of the position of the
593 item in the control or changes to its contents. It must
594 hold a unique ID of type @e void* in its only field
595 and can be converted to a from it.
597 If the ID is @e @NULL the wxDataViewItem is invalid and
598 wxDataViewItem::IsOk will return @e @false
599 which used in many places in the API of wxDataViewCtrl
600 to indicate that e.g. no item was found. An ID of @NULL
601 is also used to indicate the invisible root. Examples
603 wxDataViewModel::GetParent and
604 wxDataViewModel::GetChildren.
616 wxDataViewItem(void* id
= NULL
);
617 wxDataViewItem(const wxDataViewItem
& item
);
626 Returns @true if the ID is not @e @NULL.
634 @class wxDataViewCtrl
635 @wxheader{dataview.h}
637 wxDataViewCtrl is a control to display data either
638 in a tree like fashion or in a tabular form or both.
639 If you only need to display a simple tree structure
640 with an API more like the older wxTreeCtrl class,
641 then the specialized wxDataViewTreeCtrl
644 A wxDataViewItem is used
645 to represent a (visible) item in the control.
647 Unlike wxListCtrl wxDataViewCtrl doesn't
648 get its data from the user through virtual functions or by
649 setting it directly. Instead you need to write your own
650 wxDataViewModel and associate
651 it with this control. Then you need to add a number of
652 wxDataViewColumn to this control to
653 define what each column shall display. Each wxDataViewColumn
654 in turn owns 1 instance of a
655 wxDataViewRenderer to render its
656 cells. A number of standard renderers for rendering text, dates,
657 images, toggle, a progress bar etc. are provided. Additionally,
658 the user can write custom renderes deriving from
659 wxDataViewCustomRenderer
660 for displaying anything.
662 All data transfer from the control to the model and the user
663 code is done through wxVariant which can
664 be extended to support more data formats as necessary.
665 Accordingly, all type information uses the strings returned
666 from wxVariant::GetType.
670 Single selection mode. This is the default.
671 @style{wxDV_MULTIPLE}
672 Multiple selection mode.
673 @style{wxDV_ROW_LINES}
674 Use alternating colours for rows if supported by platform and theme.
675 @style{wxDV_HORIZ_RULES}
676 Display fine rules between row if supported.
677 @style{wxDV_VERT_RULES}
678 Display fine rules between columns is supported.
683 @appearance{dataviewctrl.png}
685 class wxDataViewCtrl
: public wxControl
690 Constructor. Calls Create().
693 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
694 const wxPoint
& pos
= wxDefaultPosition
,
695 const wxSize
& size
= wxDefaultSize
,
697 const wxValidator
& validator
= wxDefaultValidator
);
706 Add a wxDataViewColumn to the control. Returns
708 Note that there is a number of short cut methods which implicitly create
709 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
711 virtual bool AppendColumn(wxDataViewColumn
* col
);
715 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
716 created in the function or @NULL on failure.
718 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
719 unsigned int model_column
,
720 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
722 wxAlignment align
= wxALIGN_CENTER
,
723 int flags
= wxDATAVIEW_COL_RESIZABLE
);
724 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
725 unsigned int model_column
,
726 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
728 wxAlignment align
= wxALIGN_CENTER
,
729 int flags
= wxDATAVIEW_COL_RESIZABLE
);
734 Appends a column for rendering a date. Returns the wxDataViewColumn
735 created in the function or @NULL on failure.
737 NB: The @e align parameter is applied to both the column header and
740 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
741 unsigned int model_column
,
742 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
744 wxAlignment align
= wxALIGN_CENTER
,
745 int flags
= wxDATAVIEW_COL_RESIZABLE
);
746 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
747 unsigned int model_column
,
748 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
750 wxAlignment align
= wxALIGN_CENTER
,
751 int flags
= wxDATAVIEW_COL_RESIZABLE
);
756 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
757 created in the function or @NULL on failure. This method uses the
758 wxDataViewIconTextRenderer class.
760 NB: The @e align parameter is applied to both the column header and
763 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
764 unsigned int model_column
,
765 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
767 wxAlignment align
= wxALIGN_LEFT
,
768 int flags
= wxDATAVIEW_COL_RESIZABLE
);
769 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
770 unsigned int model_column
,
771 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
773 wxAlignment align
= wxALIGN_LEFT
,
774 int flags
= wxDATAVIEW_COL_RESIZABLE
);
779 Appends a column for rendering a progress indicator. Returns the
780 wxDataViewColumn created in the function or @NULL on failure.
782 NB: The @e align parameter is applied to both the column header and
785 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
786 unsigned int model_column
,
787 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
789 wxAlignment align
= wxALIGN_CENTER
,
790 int flags
= wxDATAVIEW_COL_RESIZABLE
);
791 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
792 unsigned int model_column
,
793 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
795 wxAlignment align
= wxALIGN_CENTER
,
796 int flags
= wxDATAVIEW_COL_RESIZABLE
);
801 Appends a column for rendering text. Returns the wxDataViewColumn
802 created in the function or @NULL on failure.
804 NB: The @e align parameter is applied to both the column header and
807 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
808 unsigned int model_column
,
809 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
811 wxAlignment align
= wxALIGN_LEFT
,
812 int flags
= wxDATAVIEW_COL_RESIZABLE
);
813 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
814 unsigned int model_column
,
815 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
817 wxAlignment align
= wxALIGN_LEFT
,
818 int flags
= wxDATAVIEW_COL_RESIZABLE
);
823 Appends a column for rendering a toggle. Returns the wxDataViewColumn
824 created in the function or @NULL on failure.
826 NB: The @e align parameter is applied to both the column header and
829 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
830 unsigned int model_column
,
831 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
833 wxAlignment align
= wxALIGN_CENTER
,
834 int flags
= wxDATAVIEW_COL_RESIZABLE
);
835 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
836 unsigned int model_column
,
837 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
839 wxAlignment align
= wxALIGN_CENTER
,
840 int flags
= wxDATAVIEW_COL_RESIZABLE
);
844 Associates a wxDataViewModel with the control. This increases the reference
845 count of the model by 1.
847 virtual bool AssociateModel(wxDataViewModel
* model
);
852 virtual bool ClearColumns();
857 void ClearSelection();
862 void Collapse(const wxDataViewItem
& item
);
865 Create the control. Useful for two step creation.
867 bool Create(wxWindow
* parent
, wxWindowID id
,
868 const wxPoint
& pos
= wxDefaultPosition
,
869 const wxSize
& size
= wxDefaultSize
,
871 const wxValidator
& validator
= wxDefaultValidator
);
874 Deletes given column.
876 virtual bool DeleteColumn(const wxDataViewColumn
* column
);
879 Call this to ensure that the given item is visible.
881 void EnsureVisible(const wxDataViewItem
& item
,
882 const wxDataViewColumn
* column
= NULL
);
887 void Expand(const wxDataViewItem
& item
);
890 Returns pointer to the column. @a pos refers to the
891 position in the control which may change after reordering
894 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
897 Returns the number of columns.
899 virtual unsigned int GetColumnCount() const;
902 Returns the position of the column or -1 if not found in the control.
904 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
907 Returns column containing the expanders.
909 wxDataViewColumn
* GetExpanderColumn() const;
914 int GetIndent() const;
919 wxRect
GetItemRect(const wxDataViewItem
& item
,
920 const wxDataViewColumn
* col
= NULL
) const;
923 Returns pointer to the data model associated with the
926 virtual wxDataViewModel
* GetModel() const;
929 Returns first selected item or an invalid item if none is selected.
931 wxDataViewItem
GetSelection() const;
934 Fills @a sel with currently selected items and returns
937 int GetSelections(wxDataViewItemArray
& sel
) const;
940 Returns the wxDataViewColumn currently responsible for sorting
941 or @NULL if none has been selected.
943 virtual wxDataViewColumn
* GetSortingColumn() const;
948 void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
949 wxDataViewColumn
*& col
) const;
952 Return @true if the item is selected.
954 bool IsSelected(const wxDataViewItem
& item
) const;
957 Select the given item.
959 void Select(const wxDataViewItem
& item
);
967 Set which column shall contain the tree-like expanders.
969 void SetExpanderColumn(wxDataViewColumn
* col
);
972 Sets the indendation.
974 void SetIndent(int indent
);
977 Sets the selection to the array of wxDataViewItems.
979 void SetSelections(const wxDataViewItemArray
& sel
);
982 Unselect the given item.
984 void Unselect(const wxDataViewItem
& item
);
987 Unselect all item. This method only has effect if multiple
988 selections are allowed.
996 @class wxDataViewModelNotifier
997 @wxheader{dataview.h}
999 A wxDataViewModelNotifier instance is owned by a
1001 and mirrors its notification interface. See
1002 the documentation of that class for further
1008 class wxDataViewModelNotifier
1014 wxDataViewModelNotifier();
1019 ~wxDataViewModelNotifier();
1022 Called by owning model.
1027 Get owning wxDataViewModel.
1029 wxDataViewModel
* GetOwner() const;
1032 Called by owning model.
1034 bool ItemAdded(const wxDataViewItem
& parent
,
1035 const wxDataViewItem
& item
);
1038 Called by owning model.
1040 bool ItemChanged(const wxDataViewItem
& item
);
1043 Called by owning model.
1045 bool ItemDeleted(const wxDataViewItem
& parent
,
1046 const wxDataViewItem
& item
);
1049 Called by owning model.
1051 bool ItemsAdded(const wxDataViewItem
& parent
,
1052 const wxDataViewItemArray
& items
);
1055 Called by owning model.
1057 bool ItemsChanged(const wxDataViewItemArray
& items
);
1060 Called by owning model.
1062 bool ItemsDeleted(const wxDataViewItem
& parent
,
1063 const wxDataViewItemArray
& items
);
1066 Called by owning model.
1071 Set owner of this notifier. Used internally.
1073 void SetOwner(wxDataViewModel
* owner
);
1076 Called by owning model.
1078 bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
);
1084 @class wxDataViewRenderer
1085 @wxheader{dataview.h}
1087 This class is used by wxDataViewCtrl to render the individual cells.
1088 One instance of a renderer class is owned by a wxDataViewColumn. There
1089 is a number of ready-to-use renderers provided:
1090 wxDataViewTextRenderer,
1091 wxDataViewTextRendererAttr,
1092 wxDataViewIconTextRenderer,
1093 wxDataViewToggleRenderer,
1094 wxDataViewProgressRenderer,
1095 wxDataViewBitmapRenderer,
1096 wxDataViewDateRenderer.
1097 wxDataViewSpinRenderer.
1099 Additionally, the user can write own renderers by deriving from
1100 wxDataViewCustomRenderer.
1102 The @e wxDataViewCellMode flag controls, what actions
1103 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1104 indicates that the user can double click the cell and
1105 something will happen (e.g. a window for editing a date
1106 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1107 that the user can edit the data in-place, i.e. an control
1108 will show up after a slow click on the cell. This behaviour
1109 is best known from changing the filename in most file
1114 enum wxDataViewCellMode
1116 wxDATAVIEW_CELL_INERT,
1117 wxDATAVIEW_CELL_ACTIVATABLE,
1118 wxDATAVIEW_CELL_EDITABLE
1122 The @e wxDataViewCellRenderState flag controls how the
1123 the renderer should display its contents in a cell:
1126 enum wxDataViewCellRenderState
1128 wxDATAVIEW_CELL_SELECTED = 1,
1129 wxDATAVIEW_CELL_PRELIT = 2,
1130 wxDATAVIEW_CELL_INSENSITIVE = 4,
1131 wxDATAVIEW_CELL_FOCUSED = 8
1139 class wxDataViewRenderer
: public wxObject
1145 wxDataViewRenderer(const wxString
& varianttype
,
1146 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1147 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1150 Returns the alignment. See SetAlignment()
1152 virtual int GetAlignment() const;
1155 Returns the cell mode.
1157 virtual wxDataViewCellMode
GetMode();
1160 Returns pointer to the owning wxDataViewColumn.
1162 virtual wxDataViewColumn
* GetOwner() const;
1165 This methods retrieves the value from the renderer in order to
1166 transfer the value back to the data model. Returns @e @false
1169 virtual bool GetValue(wxVariant
& value
);
1172 Returns a string with the type of the wxVariant
1173 supported by this renderer.
1175 virtual wxString
GetVariantType();
1178 Sets the alignment of the renderer's content. The default value
1179 of wxDVR_DEFAULT_ALIGMENT indicates that the content should
1180 have the same alignment as the column header. The method is
1181 not implemented under OS X and the renderer always aligns its
1182 contents as the column header on that platform. The other platforms
1183 support both vertical and horizontal alignment.
1185 virtual void SetAlignment( int align
);
1187 Sets the owning wxDataViewColumn. This
1188 is usually called from within wxDataViewColumn.
1190 virtual void SetOwner(wxDataViewColumn
* owner
);
1193 Set the value of the renderer (and thus its cell) to @e value.
1194 The internal code will then render this cell with this data.
1196 virtual bool SetValue(const wxVariant
& value
);
1199 Before data is committed to the data model, it is passed to this
1200 method where it can be checked for validity. This can also be
1201 used for checking a valid range or limiting the user input in
1202 a certain aspect (e.g. max number of characters or only alphanumeric
1203 input, ASCII only etc.). Return @e @false if the value is
1205 Please note that due to implementation limitations, this validation
1206 is done after the editing control already is destroyed and the
1207 editing process finished.
1209 virtual bool Validate(wxVariant
& value
);
1215 @class wxDataViewTextRenderer
1216 @wxheader{dataview.h}
1218 wxDataViewTextRenderer is used for rendering text. It supports
1219 in-place editing if desired.
1224 class wxDataViewTextRenderer
: public wxDataViewRenderer
1230 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1231 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1232 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1238 @class wxDataViewIconTextRenderer
1239 @wxheader{dataview.h}
1241 The wxDataViewIconTextRenderer class is used to display text with
1242 a small icon next to it as it is typically done in a file manager.
1243 This classes uses the wxDataViewIconText
1244 helper class to store its data. wxDataViewIonText can be converted
1245 to a from a wxVariant using the left shift
1251 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1257 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1258 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1259 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1267 @class wxDataViewProgressRenderer
1268 @wxheader{dataview.h}
1270 wxDataViewProgressRenderer
1275 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1281 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1282 const wxString
& varianttype
= "long",
1283 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1284 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1290 @class wxDataViewSpinRenderer
1291 @wxheader{dataview.h}
1293 This is a specialized renderer for rendering integer values. It
1294 supports modifying the values in-place by using a wxSpinCtrl.
1295 The renderer only support variants of type @e long.
1300 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1304 Constructor. @a min and @a max indicate the minimum und
1305 maximum values of for the wxSpinCtrl.
1307 wxDataViewSpinRenderer(int min
, int max
,
1308 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1309 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1315 @class wxDataViewToggleRenderer
1316 @wxheader{dataview.h}
1318 wxDataViewToggleRenderer
1323 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1329 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1330 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1336 @class wxDataViewDateRenderer
1337 @wxheader{dataview.h}
1339 wxDataViewDateRenderer
1344 class wxDataViewDateRenderer
: public wxDataViewRenderer
1350 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1351 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
1357 @class wxDataViewTextRendererAttr
1358 @wxheader{dataview.h}
1360 The same as wxDataViewTextRenderer but with
1361 support for font attributes. Font attributes are currently only supported
1364 See also wxDataViewModel::GetAttr and
1370 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1376 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1377 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1378 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1383 @class wxDataViewCustomRenderer
1384 @wxheader{dataview.h}
1386 You need to derive a new class from wxDataViewCustomRenderer in
1387 order to write a new renderer. You need to override at least
1388 wxDataViewRenderer::SetValue,
1389 wxDataViewRenderer::GetValue,
1390 wxDataViewCustomRenderer::GetSize
1391 and wxDataViewCustomRenderer::Render.
1393 If you want your renderer to support in-place editing then you
1394 also need to override
1395 wxDataViewCustomRenderer::HasEditorCtrl,
1396 wxDataViewCustomRenderer::CreateEditorCtrl
1397 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1398 Note that a special event handler will be pushed onto that
1399 editor control which handles ENTER and focus out events
1400 in order to end the editing.
1405 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1411 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1412 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1413 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1418 ~wxDataViewCustomRenderer();
1421 Override this to react to double clicks or ENTER. This method will
1422 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1424 virtual bool Activate( wxRect cell
,
1425 wxDataViewModel
* model
,
1426 const wxDataViewItem
& item
,
1430 Override this to create the actual editor control once editing
1431 is about to start. @a parent is the parent of the editor
1432 control, @a labelRect indicates the position and
1433 size of the editor control and @a value is its initial value:
1435 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1437 const wxVariant
& value
);
1440 Create DC on request. Internal.
1442 virtual wxDC
* GetDC();
1445 Return size required to show content.
1447 virtual wxSize
GetSize();
1450 Overrride this so that the renderer can get the value
1451 from the editor control (pointed to by @e editor):
1453 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1457 Override this and make it return @e @true in order to
1458 indicate that this renderer supports in-place editing.
1460 virtual bool HasEditorCtrl();
1463 Overrride this to react to a left click. This method will
1464 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1466 virtual bool LeftClick( wxPoint cursor
,
1468 wxDataViewModel
* model
,
1469 const wxDataViewItem
& item
,
1473 Override this to render the cell. Before this is called,
1474 wxDataViewRenderer::SetValue was called
1475 so that this instance knows what to render.
1477 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
);
1480 This method should be called from within Render()
1481 whenever you need to render simple text. This will ensure that the
1482 correct colour, font and vertical alignment will be chosen so the
1483 text will look the same as text drawn by native renderers.
1485 bool RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1486 wxDC
* dc
, int state
);
1489 Overrride this to start a drag operation. Not yet
1492 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1493 wxDataViewModel
* model
,
1494 const wxDataViewItem
& item
,
1501 @class wxDataViewBitmapRenderer
1502 @wxheader{dataview.h}
1504 wxDataViewBitmapRenderer
1509 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1515 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1516 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1517 int align
= wxDVR_DEFAULT_ALIGNMENT
,
1524 @class wxDataViewColumn
1525 @wxheader{dataview.h}
1527 This class represents a column in a wxDataViewCtrl.
1528 One wxDataViewColumn is bound to one column in the data model,
1529 to which the wxDataViewCtrl has been associated.
1531 An instance of wxDataViewRenderer is used by
1532 this class to render its data.
1537 class wxDataViewColumn
: public wxObject
1544 wxDataViewColumn(const wxString
& title
,
1545 wxDataViewRenderer
* renderer
,
1546 unsigned int model_column
,
1547 int width
= wxDVC_DEFAULT_WIDTH
,
1548 wxAlignment align
= wxALIGN_CENTRE
,
1549 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1550 wxDataViewColumn(const wxBitmap
& bitmap
,
1551 wxDataViewRenderer
* renderer
,
1552 unsigned int model_column
,
1553 int width
= wxDVC_DEFAULT_WIDTH
,
1554 wxAlignment align
= wxALIGN_CENTRE
,
1555 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1561 ~wxDataViewColumn();
1564 Returns the bitmap in the header of the column, if any.
1566 const wxBitmap
GetBitmap();
1569 Returns the index of the column of the model, which this
1570 wxDataViewColumn is displaying.
1572 unsigned int GetModelColumn();
1575 Returns the owning wxDataViewCtrl.
1577 wxDataViewCtrl
* GetOwner() const;
1580 Returns the renderer of this wxDataViewColumn.
1581 See also wxDataViewRenderer.
1583 wxDataViewRenderer
* GetRenderer();
1586 Returns @true if the column is reorderable.
1588 bool GetReorderable();
1591 Returns @true if the column is sortable.
1597 Returns the width of the column.
1602 Returns @true, if the sort order is ascending.
1603 See also SetSortOrder()
1605 bool IsSortOrderAscending();
1608 Set the alignment of the column header.
1610 void SetAlignment(wxAlignment align
);
1613 Set the bitmap of the column header.
1615 void SetBitmap(const wxBitmap
& bitmap
);
1618 Indicate wether the column can be reordered by the
1619 user using the mouse. This is typically implemented
1620 visually by dragging the header button around.
1622 void SetReorderable(bool reorderable
);
1625 Indicate the sort order if the implementation of the
1626 wxDataViewCtrl supports it, most commonly by showing
1629 void SetSortOrder(bool ascending
);
1632 Indicate that the column is sortable. This does
1633 not show any sorting indicate yet, but it does
1634 make the column header clickable. Call
1636 afterwards to actually make the sort indicator appear.
1637 If @a sortable is @false, the column header is
1638 no longer clickable and the sort indicator (little
1639 arrow) will disappear.
1641 void SetSortable(bool sortable
);
1644 Set the title of the column header to @e title.
1646 void SetTitle(const wxString
& title
);
1652 @class wxDataViewTreeCtrl
1653 @wxheader{dataview.h}
1655 This class is a wxDataViewCtrl which internally
1656 uses a wxDataViewTreeStore and forwards
1657 most of its API to that class. Additionally, it uses a wxImageList
1658 to store a list of icons. The main purpose of this class is to look
1659 like a wxTreeCtrl to make a transition from it
1660 to the wxDataViewCtrl class simpler.
1664 @appearance{dataviewtreectrl.png}
1666 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1671 Constructor. Calls Create().
1673 wxDataViewTreeCtrl();
1674 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1675 const wxPoint
& pos
= wxDefaultPosition
,
1676 const wxSize
& size
= wxDefaultSize
,
1677 long style
= wxDV_NO_HEADER
,
1678 const wxValidator
& validator
= wxDefaultValidator
);
1682 Destructor. Deletes the image list if any.
1684 ~wxDataViewTreeCtrl();
1689 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1690 const wxString
& text
,
1693 wxClientData
* data
= NULL
);
1698 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1699 const wxString
& text
,
1701 wxClientData
* data
= NULL
);
1704 Creates the control and a wxDataViewTreeStore as
1707 bool Create(wxWindow
* parent
, wxWindowID id
,
1708 const wxPoint
& pos
= wxDefaultPosition
,
1709 const wxSize
& size
= wxDefaultSize
,
1710 long style
= wxDV_NO_HEADER
,
1711 const wxValidator
& validator
= wxDefaultValidator
);
1714 Calls the identical method from wxDataViewTreeStore.
1716 void DeleteAllItems();
1719 Calls the identical method from wxDataViewTreeStore.
1721 void DeleteChildren(const wxDataViewItem
& item
);
1724 Calls the identical method from wxDataViewTreeStore.
1726 void DeleteItem(const wxDataViewItem
& item
);
1729 Calls the identical method from wxDataViewTreeStore.
1731 int GetChildCount(const wxDataViewItem
& parent
) const;
1734 Returns the image list.
1736 wxImageList
* GetImageList();
1739 Calls the identical method from wxDataViewTreeStore.
1741 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1744 Calls the identical method from wxDataViewTreeStore.
1746 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1749 Calls the identical method from wxDataViewTreeStore.
1751 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1754 Calls the identical method from wxDataViewTreeStore.
1756 wxString
GetItemText(const wxDataViewItem
& item
) const;
1759 Calls the identical method from wxDataViewTreeStore.
1761 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1762 unsigned int pos
) const;
1768 wxDataViewTreeStore
* GetStore() const;
1769 const wxDataViewTreeStore
* GetStore() const;
1773 Calls the same method from wxDataViewTreeStore but uess
1774 and index position in the image list instead of a wxIcon.
1776 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1777 const wxDataViewItem
& previous
,
1778 const wxString
& text
,
1781 wxClientData
* data
= NULL
);
1784 Calls the same method from wxDataViewTreeStore but uess
1785 and index position in the image list instead of a wxIcon.
1787 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1788 const wxDataViewItem
& previous
,
1789 const wxString
& text
,
1791 wxClientData
* data
= NULL
);
1794 Calls the same method from wxDataViewTreeStore but uess
1795 and index position in the image list instead of a wxIcon.
1797 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1798 const wxString
& text
,
1801 wxClientData
* data
= NULL
);
1804 Calls the same method from wxDataViewTreeStore but uess
1805 and index position in the image list instead of a wxIcon.
1807 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1808 const wxString
& text
,
1810 wxClientData
* data
= NULL
);
1813 Sets the image list.
1815 void SetImageList(wxImageList
* imagelist
);
1818 Calls the identical method from wxDataViewTreeStore.
1820 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1823 Calls the identical method from wxDataViewTreeStore.
1825 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1826 const wxIcon
& icon
);
1829 Calls the identical method from wxDataViewTreeStore.
1831 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1834 Calls the identical method from wxDataViewTreeStore.
1836 void SetItemText(const wxDataViewItem
& item
,
1837 const wxString
& text
);
1843 @class wxDataViewTreeStore
1844 @wxheader{dataview.h}
1846 wxDataViewTreeStore is a specialised wxDataViewModel
1847 for displaying simple trees very much like wxTreeCtrl
1848 does and it offers a similar API. This class actually stores the entire
1849 tree (therefore its name) and implements all virtual methods from the base
1850 class so it can be used directly without having to derive any class from it.
1851 This comes at the price of much reduced flexibility.
1856 class wxDataViewTreeStore
: public wxDataViewModel
1860 Constructor. Creates the invisible root node internally.
1862 wxDataViewTreeStore();
1867 ~wxDataViewTreeStore();
1872 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1873 const wxString
& text
,
1874 const wxIcon
& icon
= wxNullIcon
,
1875 const wxIcon
& expanded
= wxNullIcon
,
1876 wxClientData
* data
= NULL
);
1881 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1882 const wxString
& text
,
1883 const wxIcon
& icon
= wxNullIcon
,
1884 wxClientData
* data
= NULL
);
1887 Delete all item in the model.
1889 void DeleteAllItems();
1892 Delete all children of the item, but not the item itself.
1894 void DeleteChildren(const wxDataViewItem
& item
);
1899 void DeleteItem(const wxDataViewItem
& item
);
1902 Return the number of children of item.
1904 int GetChildCount(const wxDataViewItem
& parent
) const;
1907 Returns the client data asoociated with the item.
1909 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1912 Returns the icon to display in expanded containers.
1914 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1917 Returns the icon of the item.
1919 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1922 Returns the text of the item.
1924 wxString
GetItemText(const wxDataViewItem
& item
) const;
1927 Returns the nth child item of item.
1929 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1930 unsigned int pos
) const;
1933 Inserts a container after @e previous.
1935 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1936 const wxDataViewItem
& previous
,
1937 const wxString
& text
,
1938 const wxIcon
& icon
= wxNullIcon
,
1939 const wxIcon
& expanded
= wxNullIcon
,
1940 wxClientData
* data
= NULL
);
1943 Inserts an item after @e previous.
1945 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1946 const wxDataViewItem
& previous
,
1947 const wxString
& text
,
1948 const wxIcon
& icon
= wxNullIcon
,
1949 wxClientData
* data
= NULL
);
1952 Inserts a container before the first child item or @e parent.
1954 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1955 const wxString
& text
,
1956 const wxIcon
& icon
= wxNullIcon
,
1957 const wxIcon
& expanded
= wxNullIcon
,
1958 wxClientData
* data
= NULL
);
1961 Inserts an item before the first child item or @e parent.
1963 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1964 const wxString
& text
,
1965 const wxIcon
& icon
= wxNullIcon
,
1966 wxClientData
* data
= NULL
);
1969 Sets the client data associated with the item.
1971 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1974 Sets the expanded icon for the item.
1976 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1977 const wxIcon
& icon
);
1980 Sets the icon for the item.
1982 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);