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
);
133 @class wxDataViewModel
134 @wxheader{dataview.h}
136 wxDataViewModel is the base class for all data model to be
137 displayed by a wxDataViewCtrl.
138 All other models derive from it and must implement its
139 pure virtual functions in order to define a complete
140 data model. In detail, you need to override
141 wxDataViewModel::IsContainer,
142 wxDataViewModel::GetParent,
143 wxDataViewModel::GetChildren,
144 wxDataViewModel::GetColumnCount,
145 wxDataViewModel::GetColumnType and
146 wxDataViewModel::GetValue in order to
147 define the data model which acts as an interface between
148 your actual data and the wxDataViewCtrl. Since you will
149 usually also allow the wxDataViewCtrl to change your data
150 through its graphical interface, you will also have to override
151 wxDataViewModel::SetValue which the
152 wxDataViewCtrl will call when a change to some data has been
155 wxDataViewModel (as indeed the entire wxDataViewCtrl
156 code) is using wxVariant to store data and
157 its type in a generic way. wxVariant can be extended to contain
158 almost any data without changes to the original class.
160 The data that is presented through this data model is expected
161 to change at run-time. You need to inform the data model when
162 a change happened. Depending on what happened you need to call
163 one of the following methods:
164 wxDataViewModel::ValueChanged,
165 wxDataViewModel::ItemAdded,
166 wxDataViewModel::ItemDeleted,
167 wxDataViewModel::ItemChanged,
168 wxDataViewModel::Cleared. There are
169 plural forms for notification of addition, change
170 or removal of several item at once. See
171 wxDataViewModel::ItemsAdded,
172 wxDataViewModel::ItemsDeleted,
173 wxDataViewModel::ItemsChanged.
175 Note that wxDataViewModel does not define the position or
176 index of any item in the control because different controls
177 might display the same data differently. wxDataViewModel does
178 provide a wxDataViewModel::Compare method
179 which the wxDataViewCtrl may use to sort the data either
180 in conjunction with a column header or without (see
181 wxDataViewModel::HasDefaultCompare).
183 This class maintains a list of
184 wxDataViewModelNotifier
185 which link this class to the specific implementations on the
186 supported platforms so that e.g. calling
187 wxDataViewModel::ValueChanged
188 on this model will just call
189 wxDataViewModelNotifier::ValueChanged
190 for each notifier that has been added. You can also add
191 your own notifier in order to get informed about any changes
192 to the data in the list model.
194 Currently wxWidgets provides the following models apart
196 wxDataViewIndexListModel,
197 wxDataViewVirtualListModel,
200 Note that wxDataViewModel is reference counted, derives from
201 wxObjectRefData and cannot be deleted
202 directly as it can be shared by several wxDataViewCtrls. This
203 implies that you need to decrease the reference count after
204 associating the model with a control like this:
207 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
208 wxDataViewModel *musicModel = new MyMusicModel;
209 m_musicCtrl-AssociateModel( musicModel );
210 musicModel-DecRef(); // avoid memory leak !!
218 class wxDataViewModel
: public wxObjectRefData
227 Destructor. This should not be called directly. Use DecRef() instead.
232 Adds a wxDataViewModelNotifier
235 void AddNotifier(wxDataViewModelNotifier
* notifier
);
238 Called to inform the model that all data has been cleared. The
239 control will reread the data from the model again.
241 virtual bool Cleared();
244 The compare function to be used by control. The default compare function
245 sorts by container and other items separately and in ascending order.
246 Override this for a different sorting behaviour.
247 See also HasDefaultCompare().
249 virtual int Compare(const wxDataViewItem
& item1
,
250 const wxDataViewItem
& item2
,
255 Oberride this to indicate that the item has special font attributes.
256 This only affects the
257 wxDataViewTextRendererText() renderer.
258 See also wxDataViewItemAttr.
260 bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
261 wxDataViewItemAttr
& attr
);
264 Override this so the control can query the child items of
265 an item. Returns the number of items.
267 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
268 wxDataViewItemArray
& children
) const;
271 Override this to indicate the number of columns in the model.
273 virtual unsigned int GetColumnCount() const;
276 Override this to indicate what type of data is stored in the
277 column specified by @e col. This should return a string
278 indicating the type of data as reported by wxVariant.
280 virtual wxString
GetColumnType(unsigned int col
) const;
283 Override this to indicate which wxDataViewItem representing the parent
284 of @a item or an invalid wxDataViewItem if the the root item is
287 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const;
290 Override this to indicate the value of @e item
291 A wxVariant is used to store the data.
293 virtual void GetValue(wxVariant
& variant
,
294 const wxDataViewItem
& item
,
295 unsigned int col
) const;
298 Override this method to indicate if a container item merely
299 acts as a headline (or for categorisation) or if it also
300 acts a normal item with entries for futher columns. By
301 default returns @e @false.
303 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
306 Override this to indicate that the model provides a default compare
307 function that the control should use if no wxDataViewColumn has been
308 chosen for sorting. Usually, the user clicks on a column header for
309 sorting, the data will be sorted alphanumerically. If any other
310 order (e.g. by index or order of appearance) is required, then this
311 should be used. See also wxDataViewIndexListModel
312 for a model which makes use of this.
314 virtual bool HasDefaultCompare() const;
317 Override this to indicate of @a item is a container, i.e. if
318 it can have child items.
320 virtual bool IsContainer(const wxDataViewItem
& item
) const;
323 Call this to inform the model that an item has been added
326 virtual bool ItemAdded(const wxDataViewItem
& parent
,
327 const wxDataViewItem
& item
);
330 Call this to inform the model that an item has changed.
331 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
332 event (in which the column fields will not be set) to the user.
334 virtual bool ItemChanged(const wxDataViewItem
& item
);
337 Call this to inform the model that an item has been deleted from the data.
339 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
340 const wxDataViewItem
& item
);
343 Call this to inform the model that several items have been added
346 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
347 const wxDataViewItemArray
& items
);
350 Call this to inform the model that several items have changed.
351 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
352 events (in which the column fields will not be set) to the user.
354 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
357 Call this to inform the model that several items have been deleted.
359 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
360 const wxDataViewItemArray
& items
);
363 Remove the @a notifier from the list of notifiers.
365 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
368 Call this to initiate a resort after the sort function has
371 virtual void Resort();
374 This gets called in order to set a value in the data model.
375 The most common scenario is that the wxDataViewCtrl calls
376 this method after the user changed some data in the view.
377 Afterwards ValueChanged()
380 virtual bool SetValue(const wxVariant
& variant
,
381 const wxDataViewItem
& item
,
385 Call this to inform this model that a value in the model has
386 been changed. This is also called from wxDataViewCtrl's
387 internal editing code, e.g. when editing a text field
389 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
392 virtual bool ValueChanged(const wxDataViewItem
& item
,
399 @class wxDataViewIndexListModel
400 @wxheader{dataview.h}
402 wxDataViewIndexListModel is a specialized data model which lets
403 you address an item by its position (row) rather than its
404 wxDataViewItem (which you can obtain from this class).
405 This model also provides its own wxDataViewIndexListModel::Compare
406 method which sorts the model's data by the index.
408 This model is not a virtual model since the control stores
409 each wxDataViewItem. Use wxDataViewVirtualListModel if you
410 need to display millions of items or have other reason to
411 use a virtual control.
416 class wxDataViewIndexListModel
: public wxDataViewModel
422 wxDataViewIndexListModel(unsigned int initial_size
= 0);
427 ~wxDataViewIndexListModel();
430 Compare method that sorts the items by their index.
432 int Compare(const wxDataViewItem
& item1
,
433 const wxDataViewItem
& item2
,
434 unsigned int column
, bool ascending
);
437 Oberride this to indicate that the row has special font attributes.
438 This only affects the
439 wxDataViewTextRendererText() renderer.
440 See also wxDataViewItemAttr.
442 bool GetAttr(unsigned int row
, unsigned int col
,
443 wxDataViewItemAttr
& attr
);
446 Returns the wxDataViewItem at the given @e row.
448 wxDataViewItem
GetItem(unsigned int row
) const;
451 Returns the position of given @e item.
453 unsigned int GetRow(const wxDataViewItem
& item
) const;
456 Override this to allow getting values from the model.
458 void GetValue(wxVariant
& variant
, unsigned int row
,
459 unsigned int col
) const;
462 Call this after if the data has to be read again from
463 the model. This is useful after major changes when
464 calling the methods below (possibly thousands of times)
467 void Reset(unsigned int new_size
);
470 Call this after a row has been appended to the model.
475 Call this after a row has been changed.
477 void RowChanged(unsigned int row
);
480 Call this after a row has been deleted.
482 void RowDeleted(unsigned int row
);
485 Call this after a row has been inserted at the given position.
487 void RowInserted(unsigned int before
);
490 Call this after a row has been prepended to the model.
495 Call this after a value has been changed.
497 void RowValueChanged(unsigned int row
, unsigned int col
);
500 Call this after rows have been deleted. The array will internally
501 get copied and sorted in descending order so that the rows with
502 the highest position will be deleted first.
504 void RowsDeleted(const wxArrayInt
& rows
);
507 Called in order to set a value in the model.
509 bool SetValue(const wxVariant
& variant
, unsigned int row
,
516 @class wxDataViewVirtualListModel
517 @wxheader{dataview.h}
519 wxDataViewVirtualListModel is a specialized data model which lets
520 you address an item by its position (row) rather than its
521 wxDataViewItem and as such offers the exact same interface as
522 wxDataViewIndexListModel. The important difference is that under
523 platforms other than OS X, using this model will result in a
524 truely virtual control able to handle millions of items as the
525 control doesn't store any item (a feature not supported by the
526 Carbon API under OS X).
528 @see wxDataViewIndexListModel for the API.
533 class wxDataViewVirtualListModel
: public wxDataViewModel
539 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.
679 @style{wxDV_VARIABLE_LINE_HEIGHT}
680 Allow variable line heights. This can be inefficient when displaying large number of items.
685 <!-- @appearance{dataviewctrl.png} -->
687 class wxDataViewCtrl
: public wxControl
696 Constructor. Calls Create().
698 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
699 const wxPoint
& pos
= wxDefaultPosition
,
700 const wxSize
& size
= wxDefaultSize
,
702 const wxValidator
& validator
= wxDefaultValidator
);
710 Appends a wxDataViewColumn to the control. Returns @true on success.
711 Note that there is a number of short cut methods which implicitly create
712 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
714 virtual bool AppendColumn(wxDataViewColumn
* col
);
717 Prepends a wxDataViewColumn to the control. Returns @true on success.
718 Note that there is a number of short cut methods which implicitly create
719 a wxDataViewColumn and a wxDataViewRenderer for it.
721 virtual bool PrependColumn(wxDataViewColumn
* col
);
724 Inserts a wxDataViewColumn to the control. Returns @true on success.
726 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
730 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
731 created in the function or @NULL on failure.
733 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
734 unsigned int model_column
,
735 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
737 wxAlignment align
= wxALIGN_CENTER
,
738 int flags
= wxDATAVIEW_COL_RESIZABLE
);
739 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
740 unsigned int model_column
,
741 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
743 wxAlignment align
= wxALIGN_CENTER
,
744 int flags
= wxDATAVIEW_COL_RESIZABLE
);
749 Appends a column for rendering a date. Returns the wxDataViewColumn
750 created in the function or @NULL on failure.
752 NB: The @e align parameter is applied to both the column header and
755 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
756 unsigned int model_column
,
757 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
759 wxAlignment align
= wxALIGN_CENTER
,
760 int flags
= wxDATAVIEW_COL_RESIZABLE
);
761 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
762 unsigned int model_column
,
763 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
765 wxAlignment align
= wxALIGN_CENTER
,
766 int flags
= wxDATAVIEW_COL_RESIZABLE
);
771 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
772 created in the function or @NULL on failure. This method uses the
773 wxDataViewIconTextRenderer class.
775 NB: The @e align parameter is applied to both the column header and
778 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
779 unsigned int model_column
,
780 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
782 wxAlignment align
= wxALIGN_LEFT
,
783 int flags
= wxDATAVIEW_COL_RESIZABLE
);
784 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
785 unsigned int model_column
,
786 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
788 wxAlignment align
= wxALIGN_LEFT
,
789 int flags
= wxDATAVIEW_COL_RESIZABLE
);
794 Appends a column for rendering a progress indicator. Returns the
795 wxDataViewColumn created in the function or @NULL on failure.
797 NB: The @e align parameter is applied to both the column header and
800 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
801 unsigned int model_column
,
802 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
804 wxAlignment align
= wxALIGN_CENTER
,
805 int flags
= wxDATAVIEW_COL_RESIZABLE
);
806 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
807 unsigned int model_column
,
808 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
810 wxAlignment align
= wxALIGN_CENTER
,
811 int flags
= wxDATAVIEW_COL_RESIZABLE
);
816 Appends a column for rendering text. Returns the wxDataViewColumn
817 created in the function or @NULL on failure.
819 NB: The @e align parameter is applied to both the column header and
822 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
823 unsigned int model_column
,
824 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
826 wxAlignment align
= wxALIGN_LEFT
,
827 int flags
= wxDATAVIEW_COL_RESIZABLE
);
828 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
829 unsigned int model_column
,
830 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
832 wxAlignment align
= wxALIGN_LEFT
,
833 int flags
= wxDATAVIEW_COL_RESIZABLE
);
838 Appends a column for rendering a toggle. Returns the wxDataViewColumn
839 created in the function or @NULL on failure.
841 NB: The @e align parameter is applied to both the column header and
844 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
845 unsigned int model_column
,
846 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
848 wxAlignment align
= wxALIGN_CENTER
,
849 int flags
= wxDATAVIEW_COL_RESIZABLE
);
850 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
851 unsigned int model_column
,
852 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
854 wxAlignment align
= wxALIGN_CENTER
,
855 int flags
= wxDATAVIEW_COL_RESIZABLE
);
859 Associates a wxDataViewModel with the control. This increases the reference
860 count of the model by 1.
862 virtual bool AssociateModel(wxDataViewModel
* model
);
867 virtual bool ClearColumns();
872 void ClearSelection();
877 void Collapse(const wxDataViewItem
& item
);
880 Create the control. Useful for two step creation.
882 bool Create(wxWindow
* parent
, wxWindowID id
,
883 const wxPoint
& pos
= wxDefaultPosition
,
884 const wxSize
& size
= wxDefaultSize
,
886 const wxValidator
& validator
= wxDefaultValidator
);
889 Deletes given column.
891 virtual bool DeleteColumn(const wxDataViewColumn
* column
);
894 Call this to ensure that the given item is visible.
896 void EnsureVisible(const wxDataViewItem
& item
,
897 const wxDataViewColumn
* column
= NULL
);
902 void Expand(const wxDataViewItem
& item
);
905 Returns pointer to the column. @a pos refers to the
906 position in the control which may change after reordering
909 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
912 Returns the number of columns.
914 virtual unsigned int GetColumnCount() const;
917 Returns the position of the column or -1 if not found in the control.
919 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
922 Returns column containing the expanders.
924 wxDataViewColumn
* GetExpanderColumn() const;
929 int GetIndent() const;
934 wxRect
GetItemRect(const wxDataViewItem
& item
,
935 const wxDataViewColumn
* col
= NULL
) const;
938 Returns pointer to the data model associated with the
941 virtual wxDataViewModel
* GetModel() const;
944 Returns first selected item or an invalid item if none is selected.
946 wxDataViewItem
GetSelection() const;
949 Fills @a sel with currently selected items and returns
952 int GetSelections(wxDataViewItemArray
& sel
) const;
955 Returns the wxDataViewColumn currently responsible for sorting
956 or @NULL if none has been selected.
958 virtual wxDataViewColumn
* GetSortingColumn() const;
963 void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
964 wxDataViewColumn
*& col
) const;
967 Return @true if the item is selected.
969 bool IsSelected(const wxDataViewItem
& item
) const;
972 Select the given item.
974 void Select(const wxDataViewItem
& item
);
982 Set which column shall contain the tree-like expanders.
984 void SetExpanderColumn(wxDataViewColumn
* col
);
987 Sets the indendation.
989 void SetIndent(int indent
);
992 Sets the selection to the array of wxDataViewItems.
994 void SetSelections(const wxDataViewItemArray
& sel
);
997 Unselect the given item.
999 void Unselect(const wxDataViewItem
& item
);
1002 Unselect all item. This method only has effect if multiple
1003 selections are allowed.
1011 @class wxDataViewModelNotifier
1012 @wxheader{dataview.h}
1014 A wxDataViewModelNotifier instance is owned by a
1016 and mirrors its notification interface. See
1017 the documentation of that class for further
1023 class wxDataViewModelNotifier
1029 wxDataViewModelNotifier();
1034 ~wxDataViewModelNotifier();
1037 Called by owning model.
1042 Get owning wxDataViewModel.
1044 wxDataViewModel
* GetOwner() const;
1047 Called by owning model.
1049 bool ItemAdded(const wxDataViewItem
& parent
,
1050 const wxDataViewItem
& item
);
1053 Called by owning model.
1055 bool ItemChanged(const wxDataViewItem
& item
);
1058 Called by owning model.
1060 bool ItemDeleted(const wxDataViewItem
& parent
,
1061 const wxDataViewItem
& item
);
1064 Called by owning model.
1066 bool ItemsAdded(const wxDataViewItem
& parent
,
1067 const wxDataViewItemArray
& items
);
1070 Called by owning model.
1072 bool ItemsChanged(const wxDataViewItemArray
& items
);
1075 Called by owning model.
1077 bool ItemsDeleted(const wxDataViewItem
& parent
,
1078 const wxDataViewItemArray
& items
);
1081 Called by owning model.
1086 Set owner of this notifier. Used internally.
1088 void SetOwner(wxDataViewModel
* owner
);
1091 Called by owning model.
1093 bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
);
1099 @class wxDataViewRenderer
1100 @wxheader{dataview.h}
1102 This class is used by wxDataViewCtrl to render the individual cells.
1103 One instance of a renderer class is owned by a wxDataViewColumn. There
1104 is a number of ready-to-use renderers provided:
1105 wxDataViewTextRenderer,
1106 wxDataViewTextRendererAttr,
1107 wxDataViewIconTextRenderer,
1108 wxDataViewToggleRenderer,
1109 wxDataViewProgressRenderer,
1110 wxDataViewBitmapRenderer,
1111 wxDataViewDateRenderer.
1112 wxDataViewSpinRenderer.
1114 Additionally, the user can write own renderers by deriving from
1115 wxDataViewCustomRenderer.
1117 The @e wxDataViewCellMode flag controls, what actions
1118 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1119 indicates that the user can double click the cell and
1120 something will happen (e.g. a window for editing a date
1121 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1122 that the user can edit the data in-place, i.e. an control
1123 will show up after a slow click on the cell. This behaviour
1124 is best known from changing the filename in most file
1129 enum wxDataViewCellMode
1131 wxDATAVIEW_CELL_INERT,
1132 wxDATAVIEW_CELL_ACTIVATABLE,
1133 wxDATAVIEW_CELL_EDITABLE
1137 The @e wxDataViewCellRenderState flag controls how the
1138 the renderer should display its contents in a cell:
1141 enum wxDataViewCellRenderState
1143 wxDATAVIEW_CELL_SELECTED = 1,
1144 wxDATAVIEW_CELL_PRELIT = 2,
1145 wxDATAVIEW_CELL_INSENSITIVE = 4,
1146 wxDATAVIEW_CELL_FOCUSED = 8
1154 class wxDataViewRenderer
: public wxObject
1160 wxDataViewRenderer(const wxString
& varianttype
,
1161 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1162 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1165 Returns the alignment. See SetAlignment()
1167 virtual int GetAlignment() const;
1170 Returns the cell mode.
1172 virtual wxDataViewCellMode
GetMode();
1175 Returns pointer to the owning wxDataViewColumn.
1177 virtual wxDataViewColumn
* GetOwner() const;
1180 This methods retrieves the value from the renderer in order to
1181 transfer the value back to the data model. Returns @e @false
1184 virtual bool GetValue(wxVariant
& value
);
1187 Returns a string with the type of the wxVariant
1188 supported by this renderer.
1190 virtual wxString
GetVariantType();
1193 Sets the alignment of the renderer's content. The default value
1194 of wxDVR_DEFAULT_ALIGMENT indicates that the content should
1195 have the same alignment as the column header. The method is
1196 not implemented under OS X and the renderer always aligns its
1197 contents as the column header on that platform. The other platforms
1198 support both vertical and horizontal alignment.
1200 virtual void SetAlignment( int align
);
1202 Sets the owning wxDataViewColumn. This
1203 is usually called from within wxDataViewColumn.
1205 virtual void SetOwner(wxDataViewColumn
* owner
);
1208 Set the value of the renderer (and thus its cell) to @e value.
1209 The internal code will then render this cell with this data.
1211 virtual bool SetValue(const wxVariant
& value
);
1214 Before data is committed to the data model, it is passed to this
1215 method where it can be checked for validity. This can also be
1216 used for checking a valid range or limiting the user input in
1217 a certain aspect (e.g. max number of characters or only alphanumeric
1218 input, ASCII only etc.). Return @e @false if the value is
1220 Please note that due to implementation limitations, this validation
1221 is done after the editing control already is destroyed and the
1222 editing process finished.
1224 virtual bool Validate(wxVariant
& value
);
1230 @class wxDataViewTextRenderer
1231 @wxheader{dataview.h}
1233 wxDataViewTextRenderer is used for rendering text. It supports
1234 in-place editing if desired.
1239 class wxDataViewTextRenderer
: public wxDataViewRenderer
1245 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1246 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1247 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1253 @class wxDataViewIconTextRenderer
1254 @wxheader{dataview.h}
1256 The wxDataViewIconTextRenderer class is used to display text with
1257 a small icon next to it as it is typically done in a file manager.
1258 This classes uses the wxDataViewIconText
1259 helper class to store its data. wxDataViewIonText can be converted
1260 to a from a wxVariant using the left shift
1266 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1272 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1273 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1274 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1280 @class wxDataViewProgressRenderer
1281 @wxheader{dataview.h}
1283 wxDataViewProgressRenderer
1288 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1294 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1295 const wxString
& varianttype
= "long",
1296 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1297 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1303 @class wxDataViewSpinRenderer
1304 @wxheader{dataview.h}
1306 This is a specialized renderer for rendering integer values. It
1307 supports modifying the values in-place by using a wxSpinCtrl.
1308 The renderer only support variants of type @e long.
1313 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1317 Constructor. @a min and @a max indicate the minimum und
1318 maximum values of for the wxSpinCtrl.
1320 wxDataViewSpinRenderer(int min
, int max
,
1321 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1322 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1328 @class wxDataViewToggleRenderer
1329 @wxheader{dataview.h}
1331 wxDataViewToggleRenderer
1336 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1342 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1343 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1349 @class wxDataViewDateRenderer
1350 @wxheader{dataview.h}
1352 wxDataViewDateRenderer
1357 class wxDataViewDateRenderer
: public wxDataViewRenderer
1363 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1364 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
1370 @class wxDataViewTextRendererAttr
1371 @wxheader{dataview.h}
1373 The same as wxDataViewTextRenderer but with
1374 support for font attributes. Font attributes are currently only supported
1377 See also wxDataViewModel::GetAttr and
1383 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1389 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1390 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1391 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1397 @class wxDataViewCustomRenderer
1398 @wxheader{dataview.h}
1400 You need to derive a new class from wxDataViewCustomRenderer in
1401 order to write a new renderer. You need to override at least
1402 wxDataViewRenderer::SetValue,
1403 wxDataViewRenderer::GetValue,
1404 wxDataViewCustomRenderer::GetSize
1405 and wxDataViewCustomRenderer::Render.
1407 If you want your renderer to support in-place editing then you
1408 also need to override
1409 wxDataViewCustomRenderer::HasEditorCtrl,
1410 wxDataViewCustomRenderer::CreateEditorCtrl
1411 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1412 Note that a special event handler will be pushed onto that
1413 editor control which handles ENTER and focus out events
1414 in order to end the editing.
1419 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1425 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1426 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1427 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1432 ~wxDataViewCustomRenderer();
1435 Override this to react to double clicks or ENTER. This method will
1436 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1438 virtual bool Activate( wxRect cell
,
1439 wxDataViewModel
* model
,
1440 const wxDataViewItem
& item
,
1444 Override this to create the actual editor control once editing
1445 is about to start. @a parent is the parent of the editor
1446 control, @a labelRect indicates the position and
1447 size of the editor control and @a value is its initial value:
1449 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1451 const wxVariant
& value
);
1454 Create DC on request. Internal.
1456 virtual wxDC
* GetDC();
1459 Return size required to show content.
1461 virtual wxSize
GetSize();
1464 Overrride this so that the renderer can get the value
1465 from the editor control (pointed to by @e editor):
1467 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1471 Override this and make it return @e @true in order to
1472 indicate that this renderer supports in-place editing.
1474 virtual bool HasEditorCtrl();
1477 Overrride this to react to a left click. This method will
1478 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1480 virtual bool LeftClick( wxPoint cursor
,
1482 wxDataViewModel
* model
,
1483 const wxDataViewItem
& item
,
1487 Override this to render the cell. Before this is called,
1488 wxDataViewRenderer::SetValue was called
1489 so that this instance knows what to render.
1491 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
);
1494 This method should be called from within Render()
1495 whenever you need to render simple text. This will ensure that the
1496 correct colour, font and vertical alignment will be chosen so the
1497 text will look the same as text drawn by native renderers.
1499 bool RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1500 wxDC
* dc
, int state
);
1503 Overrride this to start a drag operation. Not yet
1506 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1507 wxDataViewModel
* model
,
1508 const wxDataViewItem
& item
,
1515 @class wxDataViewBitmapRenderer
1516 @wxheader{dataview.h}
1518 wxDataViewBitmapRenderer
1523 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1529 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1530 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1531 int align
= wxDVR_DEFAULT_ALIGNMENT
,
1537 @class wxDataViewColumn
1538 @wxheader{dataview.h}
1540 This class represents a column in a wxDataViewCtrl.
1541 One wxDataViewColumn is bound to one column in the data model,
1542 to which the wxDataViewCtrl has been associated.
1544 An instance of wxDataViewRenderer is used by
1545 this class to render its data.
1550 class wxDataViewColumn
: public wxObject
1557 wxDataViewColumn(const wxString
& title
,
1558 wxDataViewRenderer
* renderer
,
1559 unsigned int model_column
,
1560 int width
= wxDVC_DEFAULT_WIDTH
,
1561 wxAlignment align
= wxALIGN_CENTRE
,
1562 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1563 wxDataViewColumn(const wxBitmap
& bitmap
,
1564 wxDataViewRenderer
* renderer
,
1565 unsigned int model_column
,
1566 int width
= wxDVC_DEFAULT_WIDTH
,
1567 wxAlignment align
= wxALIGN_CENTRE
,
1568 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1574 ~wxDataViewColumn();
1577 Returns the bitmap in the header of the column, if any.
1579 const wxBitmap
GetBitmap();
1582 Returns the index of the column of the model, which this
1583 wxDataViewColumn is displaying.
1585 unsigned int GetModelColumn();
1588 Returns the owning wxDataViewCtrl.
1590 wxDataViewCtrl
* GetOwner() const;
1593 Returns the renderer of this wxDataViewColumn.
1594 See also wxDataViewRenderer.
1596 wxDataViewRenderer
* GetRenderer();
1599 Returns @true if the column is reorderable.
1601 bool GetReorderable();
1604 Returns @true if the column is sortable.
1610 Returns the width of the column.
1615 Returns @true, if the sort order is ascending.
1616 See also SetSortOrder()
1618 bool IsSortOrderAscending();
1621 Set the alignment of the column header.
1623 void SetAlignment(wxAlignment align
);
1626 Set the bitmap of the column header.
1628 void SetBitmap(const wxBitmap
& bitmap
);
1631 Indicate wether the column can be reordered by the
1632 user using the mouse. This is typically implemented
1633 visually by dragging the header button around.
1635 void SetReorderable(bool reorderable
);
1638 Indicate the sort order if the implementation of the
1639 wxDataViewCtrl supports it, most commonly by showing
1642 void SetSortOrder(bool ascending
);
1645 Indicate that the column is sortable. This does
1646 not show any sorting indicate yet, but it does
1647 make the column header clickable. Call
1649 afterwards to actually make the sort indicator appear.
1650 If @a sortable is @false, the column header is
1651 no longer clickable and the sort indicator (little
1652 arrow) will disappear.
1654 void SetSortable(bool sortable
);
1657 Set the title of the column header to @e title.
1659 void SetTitle(const wxString
& title
);
1665 @class wxDataViewTreeCtrl
1666 @wxheader{dataview.h}
1668 This class is a wxDataViewCtrl which internally
1669 uses a wxDataViewTreeStore and forwards
1670 most of its API to that class. Additionally, it uses a wxImageList
1671 to store a list of icons. The main purpose of this class is to look
1672 like a wxTreeCtrl to make a transition from it
1673 to the wxDataViewCtrl class simpler.
1677 <!-- @appearance{dataviewtreectrl.png} -->
1679 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1684 Constructor. Calls Create().
1686 wxDataViewTreeCtrl();
1687 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1688 const wxPoint
& pos
= wxDefaultPosition
,
1689 const wxSize
& size
= wxDefaultSize
,
1690 long style
= wxDV_NO_HEADER
,
1691 const wxValidator
& validator
= wxDefaultValidator
);
1695 Destructor. Deletes the image list if any.
1697 ~wxDataViewTreeCtrl();
1702 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1703 const wxString
& text
,
1706 wxClientData
* data
= NULL
);
1711 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1712 const wxString
& text
,
1714 wxClientData
* data
= NULL
);
1717 Creates the control and a wxDataViewTreeStore as
1720 bool Create(wxWindow
* parent
, wxWindowID id
,
1721 const wxPoint
& pos
= wxDefaultPosition
,
1722 const wxSize
& size
= wxDefaultSize
,
1723 long style
= wxDV_NO_HEADER
,
1724 const wxValidator
& validator
= wxDefaultValidator
);
1727 Calls the identical method from wxDataViewTreeStore.
1729 void DeleteAllItems();
1732 Calls the identical method from wxDataViewTreeStore.
1734 void DeleteChildren(const wxDataViewItem
& item
);
1737 Calls the identical method from wxDataViewTreeStore.
1739 void DeleteItem(const wxDataViewItem
& item
);
1742 Calls the identical method from wxDataViewTreeStore.
1744 int GetChildCount(const wxDataViewItem
& parent
) const;
1747 Returns the image list.
1749 wxImageList
* GetImageList();
1752 Calls the identical method from wxDataViewTreeStore.
1754 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1757 Calls the identical method from wxDataViewTreeStore.
1759 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1762 Calls the identical method from wxDataViewTreeStore.
1764 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1767 Calls the identical method from wxDataViewTreeStore.
1769 wxString
GetItemText(const wxDataViewItem
& item
) const;
1772 Calls the identical method from wxDataViewTreeStore.
1774 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1775 unsigned int pos
) const;
1781 wxDataViewTreeStore
* GetStore() const;
1782 const wxDataViewTreeStore
* GetStore() const;
1786 Calls the same method from wxDataViewTreeStore but uess
1787 and index position in the image list instead of a wxIcon.
1789 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1790 const wxDataViewItem
& previous
,
1791 const wxString
& text
,
1794 wxClientData
* data
= NULL
);
1797 Calls the same method from wxDataViewTreeStore but uess
1798 and index position in the image list instead of a wxIcon.
1800 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1801 const wxDataViewItem
& previous
,
1802 const wxString
& text
,
1804 wxClientData
* data
= NULL
);
1807 Calls the same method from wxDataViewTreeStore but uess
1808 and index position in the image list instead of a wxIcon.
1810 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1811 const wxString
& text
,
1814 wxClientData
* data
= NULL
);
1817 Calls the same method from wxDataViewTreeStore but uess
1818 and index position in the image list instead of a wxIcon.
1820 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1821 const wxString
& text
,
1823 wxClientData
* data
= NULL
);
1826 Sets the image list.
1828 void SetImageList(wxImageList
* imagelist
);
1831 Calls the identical method from wxDataViewTreeStore.
1833 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1836 Calls the identical method from wxDataViewTreeStore.
1838 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1839 const wxIcon
& icon
);
1842 Calls the identical method from wxDataViewTreeStore.
1844 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1847 Calls the identical method from wxDataViewTreeStore.
1849 void SetItemText(const wxDataViewItem
& item
,
1850 const wxString
& text
);
1856 @class wxDataViewTreeStore
1857 @wxheader{dataview.h}
1859 wxDataViewTreeStore is a specialised wxDataViewModel
1860 for displaying simple trees very much like wxTreeCtrl
1861 does and it offers a similar API. This class actually stores the entire
1862 tree (therefore its name) and implements all virtual methods from the base
1863 class so it can be used directly without having to derive any class from it.
1864 This comes at the price of much reduced flexibility.
1869 class wxDataViewTreeStore
: public wxDataViewModel
1873 Constructor. Creates the invisible root node internally.
1875 wxDataViewTreeStore();
1880 ~wxDataViewTreeStore();
1885 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1886 const wxString
& text
,
1887 const wxIcon
& icon
= wxNullIcon
,
1888 const wxIcon
& expanded
= wxNullIcon
,
1889 wxClientData
* data
= NULL
);
1894 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1895 const wxString
& text
,
1896 const wxIcon
& icon
= wxNullIcon
,
1897 wxClientData
* data
= NULL
);
1900 Delete all item in the model.
1902 void DeleteAllItems();
1905 Delete all children of the item, but not the item itself.
1907 void DeleteChildren(const wxDataViewItem
& item
);
1912 void DeleteItem(const wxDataViewItem
& item
);
1915 Return the number of children of item.
1917 int GetChildCount(const wxDataViewItem
& parent
) const;
1920 Returns the client data asoociated with the item.
1922 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1925 Returns the icon to display in expanded containers.
1927 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1930 Returns the icon of the item.
1932 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1935 Returns the text of the item.
1937 wxString
GetItemText(const wxDataViewItem
& item
) const;
1940 Returns the nth child item of item.
1942 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1943 unsigned int pos
) const;
1946 Inserts a container after @e previous.
1948 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1949 const wxDataViewItem
& previous
,
1950 const wxString
& text
,
1951 const wxIcon
& icon
= wxNullIcon
,
1952 const wxIcon
& expanded
= wxNullIcon
,
1953 wxClientData
* data
= NULL
);
1956 Inserts an item after @e previous.
1958 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1959 const wxDataViewItem
& previous
,
1960 const wxString
& text
,
1961 const wxIcon
& icon
= wxNullIcon
,
1962 wxClientData
* data
= NULL
);
1965 Inserts a container before the first child item or @e parent.
1967 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1968 const wxString
& text
,
1969 const wxIcon
& icon
= wxNullIcon
,
1970 const wxIcon
& expanded
= wxNullIcon
,
1971 wxClientData
* data
= NULL
);
1974 Inserts an item before the first child item or @e parent.
1976 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1977 const wxString
& text
,
1978 const wxIcon
& icon
= wxNullIcon
,
1979 wxClientData
* data
= NULL
);
1982 Sets the client data associated with the item.
1984 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1987 Sets the expanded icon for the item.
1989 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1990 const wxIcon
& icon
);
1993 Sets the icon for the item.
1995 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);