1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataViewIconText
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDataViewIconText
12 wxDataViewIconText is used by
13 wxDataViewIconTextRenderer
14 for data transfer. This class can be converted to a from
20 class wxDataViewIconText
: public wxObject
27 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
28 const wxIcon
& icon
= wxNullIcon
);
29 wxDataViewIconText(const wxDataViewIconText
& other
);
35 const wxIcon
GetIcon() const;
40 wxString
GetText() const;
45 void SetIcon(const wxIcon
& icon
);
50 void SetText(const wxString
& text
);
56 @class wxDataViewEvent
58 wxDataViewEvent - the event class for the wxDataViewCtrl notifications
63 class wxDataViewEvent
: public wxNotifyEvent
70 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
72 wxDataViewEvent(const wxDataViewEvent
& event
);
76 Used to clone the event.
78 wxEvent
* Clone() const;
81 Returns the position of the column in the control or -1
82 if no column field was set by the event emitter.
84 int GetColumn() const;
87 Returns a pointer to the wxDataViewColumn from which
88 the event was emitted or @NULL.
90 wxDataViewColumn
* GetDataViewColumn();
93 Returns the wxDataViewModel associated with the event.
95 wxDataViewModel
* GetModel() const;
98 Returns a the position of a context menu event in screen coordinates.
100 wxPoint
GetPosition() const;
103 Returns a reference to a value.
105 const wxVariant
GetValue() const;
110 void SetColumn(int col
);
113 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
115 void SetDataViewColumn(wxDataViewColumn
* col
);
120 void SetModel(wxDataViewModel
* model
);
125 void SetValue(const wxVariant
& value
);
131 @class wxDataViewModel
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
,
396 @class wxDataViewIndexListModel
398 wxDataViewIndexListModel is a specialized data model which lets
399 you address an item by its position (row) rather than its
400 wxDataViewItem (which you can obtain from this class).
401 This model also provides its own wxDataViewIndexListModel::Compare
402 method which sorts the model's data by the index.
404 This model is not a virtual model since the control stores
405 each wxDataViewItem. Use wxDataViewVirtualListModel if you
406 need to display millions of items or have other reason to
407 use a virtual control.
412 class wxDataViewIndexListModel
: public wxDataViewModel
418 wxDataViewIndexListModel(unsigned int initial_size
= 0);
423 ~wxDataViewIndexListModel();
426 Compare method that sorts the items by their index.
428 int Compare(const wxDataViewItem
& item1
,
429 const wxDataViewItem
& item2
,
430 unsigned int column
, bool ascending
);
433 Oberride this to indicate that the row has special font attributes.
434 This only affects the
435 wxDataViewTextRendererText() renderer.
436 See also wxDataViewItemAttr.
438 bool GetAttr(unsigned int row
, unsigned int col
,
439 wxDataViewItemAttr
& attr
);
442 Returns the wxDataViewItem at the given @e row.
444 wxDataViewItem
GetItem(unsigned int row
) const;
447 Returns the position of given @e item.
449 unsigned int GetRow(const wxDataViewItem
& item
) const;
452 Override this to allow getting values from the model.
454 void GetValue(wxVariant
& variant
, unsigned int row
,
455 unsigned int col
) const;
458 Call this after if the data has to be read again from
459 the model. This is useful after major changes when
460 calling the methods below (possibly thousands of times)
463 void Reset(unsigned int new_size
);
466 Call this after a row has been appended to the model.
471 Call this after a row has been changed.
473 void RowChanged(unsigned int row
);
476 Call this after a row has been deleted.
478 void RowDeleted(unsigned int row
);
481 Call this after a row has been inserted at the given position.
483 void RowInserted(unsigned int before
);
486 Call this after a row has been prepended to the model.
491 Call this after a value has been changed.
493 void RowValueChanged(unsigned int row
, unsigned int col
);
496 Call this after rows have been deleted. The array will internally
497 get copied and sorted in descending order so that the rows with
498 the highest position will be deleted first.
500 void RowsDeleted(const wxArrayInt
& rows
);
503 Called in order to set a value in the model.
505 bool SetValue(const wxVariant
& variant
, unsigned int row
,
512 @class wxDataViewVirtualListModel
514 wxDataViewVirtualListModel is a specialized data model which lets
515 you address an item by its position (row) rather than its
516 wxDataViewItem and as such offers the exact same interface as
517 wxDataViewIndexListModel. The important difference is that under
518 platforms other than OS X, using this model will result in a
519 truely virtual control able to handle millions of items as the
520 control doesn't store any item (a feature not supported by the
521 Carbon API under OS X).
523 @see wxDataViewIndexListModel for the API.
528 class wxDataViewVirtualListModel
: public wxDataViewModel
534 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
540 @class wxDataViewItemAttr
542 This class is used to indicate to a wxDataViewCtrl
543 that a certain Item() has extra font attributes
544 for its renderer. For this, it is required to override
545 wxDataViewModel::GetAttr.
547 Attributes are currently only supported by
548 wxDataViewTextRendererText().
553 class wxDataViewItemAttr
559 wxDataViewItemAttr();
562 Call this to indicate that the item shall be displayed in bold text.
564 void SetBold(bool set
);
567 Call this to indicate that the item shall be displayed with
570 void SetColour(const wxColour
& colour
);
573 Call this to indicate that the item shall be displayed in italic text.
575 void SetItalic(bool set
);
581 @class wxDataViewItem
583 wxDataViewItem is a small opaque class that represents an
584 item in a wxDataViewCtrl in a
585 persistent way, i.e. indepent of the position of the
586 item in the control or changes to its contents. It must
587 hold a unique ID of type @e void* in its only field
588 and can be converted to a from it.
590 If the ID is @e @NULL the wxDataViewItem is invalid and
591 wxDataViewItem::IsOk will return @e @false
592 which used in many places in the API of wxDataViewCtrl
593 to indicate that e.g. no item was found. An ID of @NULL
594 is also used to indicate the invisible root. Examples
596 wxDataViewModel::GetParent and
597 wxDataViewModel::GetChildren.
609 wxDataViewItem(void* id
= NULL
);
610 wxDataViewItem(const wxDataViewItem
& item
);
619 Returns @true if the ID is not @e @NULL.
627 @class wxDataViewCtrl
629 wxDataViewCtrl is a control to display data either
630 in a tree like fashion or in a tabular form or both.
631 If you only need to display a simple tree structure
632 with an API more like the older wxTreeCtrl class,
633 then the specialized wxDataViewTreeCtrl
636 A wxDataViewItem is used
637 to represent a (visible) item in the control.
639 Unlike wxListCtrl wxDataViewCtrl doesn't
640 get its data from the user through virtual functions or by
641 setting it directly. Instead you need to write your own
642 wxDataViewModel and associate
643 it with this control. Then you need to add a number of
644 wxDataViewColumn to this control to
645 define what each column shall display. Each wxDataViewColumn
646 in turn owns 1 instance of a
647 wxDataViewRenderer to render its
648 cells. A number of standard renderers for rendering text, dates,
649 images, toggle, a progress bar etc. are provided. Additionally,
650 the user can write custom renderes deriving from
651 wxDataViewCustomRenderer
652 for displaying anything.
654 All data transfer from the control to the model and the user
655 code is done through wxVariant which can
656 be extended to support more data formats as necessary.
657 Accordingly, all type information uses the strings returned
658 from wxVariant::GetType.
662 Single selection mode. This is the default.
663 @style{wxDV_MULTIPLE}
664 Multiple selection mode.
665 @style{wxDV_ROW_LINES}
666 Use alternating colours for rows if supported by platform and theme.
667 @style{wxDV_HORIZ_RULES}
668 Display fine rules between row if supported.
669 @style{wxDV_VERT_RULES}
670 Display fine rules between columns is supported.
671 @style{wxDV_VARIABLE_LINE_HEIGHT}
672 Allow variable line heights. This can be inefficient when displaying large number of items.
677 <!-- @appearance{dataviewctrl.png} -->
679 class wxDataViewCtrl
: public wxControl
688 Constructor. Calls Create().
690 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
691 const wxPoint
& pos
= wxDefaultPosition
,
692 const wxSize
& size
= wxDefaultSize
,
694 const wxValidator
& validator
= wxDefaultValidator
);
702 Appends a wxDataViewColumn to the control. Returns @true on success.
703 Note that there is a number of short cut methods which implicitly create
704 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
706 virtual bool AppendColumn(wxDataViewColumn
* col
);
709 Prepends a wxDataViewColumn to the control. Returns @true on success.
710 Note that there is a number of short cut methods which implicitly create
711 a wxDataViewColumn and a wxDataViewRenderer for it.
713 virtual bool PrependColumn(wxDataViewColumn
* col
);
716 Inserts a wxDataViewColumn to the control. Returns @true on success.
718 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
722 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
723 created in the function or @NULL on failure.
725 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
726 unsigned int model_column
,
727 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
729 wxAlignment align
= wxALIGN_CENTER
,
730 int flags
= wxDATAVIEW_COL_RESIZABLE
);
731 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
732 unsigned int model_column
,
733 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
735 wxAlignment align
= wxALIGN_CENTER
,
736 int flags
= wxDATAVIEW_COL_RESIZABLE
);
741 Appends a column for rendering a date. Returns the wxDataViewColumn
742 created in the function or @NULL on failure.
744 NB: The @e align parameter is applied to both the column header and
747 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
748 unsigned int model_column
,
749 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
751 wxAlignment align
= wxALIGN_CENTER
,
752 int flags
= wxDATAVIEW_COL_RESIZABLE
);
753 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
754 unsigned int model_column
,
755 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
757 wxAlignment align
= wxALIGN_CENTER
,
758 int flags
= wxDATAVIEW_COL_RESIZABLE
);
763 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
764 created in the function or @NULL on failure. This method uses the
765 wxDataViewIconTextRenderer class.
767 NB: The @e align parameter is applied to both the column header and
770 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
771 unsigned int model_column
,
772 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
774 wxAlignment align
= wxALIGN_LEFT
,
775 int flags
= wxDATAVIEW_COL_RESIZABLE
);
776 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
777 unsigned int model_column
,
778 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
780 wxAlignment align
= wxALIGN_LEFT
,
781 int flags
= wxDATAVIEW_COL_RESIZABLE
);
786 Appends a column for rendering a progress indicator. Returns the
787 wxDataViewColumn created in the function or @NULL on failure.
789 NB: The @e align parameter is applied to both the column header and
792 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
793 unsigned int model_column
,
794 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
796 wxAlignment align
= wxALIGN_CENTER
,
797 int flags
= wxDATAVIEW_COL_RESIZABLE
);
798 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
799 unsigned int model_column
,
800 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
802 wxAlignment align
= wxALIGN_CENTER
,
803 int flags
= wxDATAVIEW_COL_RESIZABLE
);
808 Appends a column for rendering text. Returns the wxDataViewColumn
809 created in the function or @NULL on failure.
811 NB: The @e align parameter is applied to both the column header and
814 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
815 unsigned int model_column
,
816 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
818 wxAlignment align
= wxALIGN_LEFT
,
819 int flags
= wxDATAVIEW_COL_RESIZABLE
);
820 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
821 unsigned int model_column
,
822 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
824 wxAlignment align
= wxALIGN_LEFT
,
825 int flags
= wxDATAVIEW_COL_RESIZABLE
);
830 Appends a column for rendering a toggle. Returns the wxDataViewColumn
831 created in the function or @NULL on failure.
833 NB: The @e align parameter is applied to both the column header and
836 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
837 unsigned int model_column
,
838 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
840 wxAlignment align
= wxALIGN_CENTER
,
841 int flags
= wxDATAVIEW_COL_RESIZABLE
);
842 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
843 unsigned int model_column
,
844 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
846 wxAlignment align
= wxALIGN_CENTER
,
847 int flags
= wxDATAVIEW_COL_RESIZABLE
);
851 Associates a wxDataViewModel with the control. This increases the reference
852 count of the model by 1.
854 virtual bool AssociateModel(wxDataViewModel
* model
);
859 virtual bool ClearColumns();
864 void ClearSelection();
869 void Collapse(const wxDataViewItem
& item
);
872 Create the control. Useful for two step creation.
874 bool Create(wxWindow
* parent
, wxWindowID id
,
875 const wxPoint
& pos
= wxDefaultPosition
,
876 const wxSize
& size
= wxDefaultSize
,
878 const wxValidator
& validator
= wxDefaultValidator
);
881 Deletes given column.
883 virtual bool DeleteColumn(const wxDataViewColumn
* column
);
886 Call this to ensure that the given item is visible.
888 void EnsureVisible(const wxDataViewItem
& item
,
889 const wxDataViewColumn
* column
= NULL
);
894 void Expand(const wxDataViewItem
& item
);
897 Returns pointer to the column. @a pos refers to the
898 position in the control which may change after reordering
901 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
904 Returns the number of columns.
906 virtual unsigned int GetColumnCount() const;
909 Returns the position of the column or -1 if not found in the control.
911 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
914 Returns column containing the expanders.
916 wxDataViewColumn
* GetExpanderColumn() const;
921 int GetIndent() const;
926 wxRect
GetItemRect(const wxDataViewItem
& item
,
927 const wxDataViewColumn
* col
= NULL
) const;
930 Returns pointer to the data model associated with the
933 virtual wxDataViewModel
* GetModel() const;
936 Returns first selected item or an invalid item if none is selected.
938 wxDataViewItem
GetSelection() const;
941 Fills @a sel with currently selected items and returns
944 int GetSelections(wxDataViewItemArray
& sel
) const;
947 Returns the wxDataViewColumn currently responsible for sorting
948 or @NULL if none has been selected.
950 virtual wxDataViewColumn
* GetSortingColumn() const;
955 void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
956 wxDataViewColumn
*& col
) const;
959 Return @true if the item is selected.
961 bool IsSelected(const wxDataViewItem
& item
) const;
964 Select the given item.
966 void Select(const wxDataViewItem
& item
);
974 Set which column shall contain the tree-like expanders.
976 void SetExpanderColumn(wxDataViewColumn
* col
);
979 Sets the indendation.
981 void SetIndent(int indent
);
984 Sets the selection to the array of wxDataViewItems.
986 void SetSelections(const wxDataViewItemArray
& sel
);
989 Unselect the given item.
991 void Unselect(const wxDataViewItem
& item
);
994 Unselect all item. This method only has effect if multiple
995 selections are allowed.
1003 @class wxDataViewModelNotifier
1005 A wxDataViewModelNotifier instance is owned by a
1007 and mirrors its notification interface. See
1008 the documentation of that class for further
1014 class wxDataViewModelNotifier
1020 wxDataViewModelNotifier();
1025 ~wxDataViewModelNotifier();
1028 Called by owning model.
1033 Get owning wxDataViewModel.
1035 wxDataViewModel
* GetOwner() const;
1038 Called by owning model.
1040 bool ItemAdded(const wxDataViewItem
& parent
,
1041 const wxDataViewItem
& item
);
1044 Called by owning model.
1046 bool ItemChanged(const wxDataViewItem
& item
);
1049 Called by owning model.
1051 bool ItemDeleted(const wxDataViewItem
& parent
,
1052 const wxDataViewItem
& item
);
1055 Called by owning model.
1057 bool ItemsAdded(const wxDataViewItem
& parent
,
1058 const wxDataViewItemArray
& items
);
1061 Called by owning model.
1063 bool ItemsChanged(const wxDataViewItemArray
& items
);
1066 Called by owning model.
1068 bool ItemsDeleted(const wxDataViewItem
& parent
,
1069 const wxDataViewItemArray
& items
);
1072 Called by owning model.
1077 Set owner of this notifier. Used internally.
1079 void SetOwner(wxDataViewModel
* owner
);
1082 Called by owning model.
1084 bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
);
1090 @class wxDataViewRenderer
1092 This class is used by wxDataViewCtrl to render the individual cells.
1093 One instance of a renderer class is owned by a wxDataViewColumn. There
1094 is a number of ready-to-use renderers provided:
1095 wxDataViewTextRenderer,
1096 wxDataViewTextRendererAttr,
1097 wxDataViewIconTextRenderer,
1098 wxDataViewToggleRenderer,
1099 wxDataViewProgressRenderer,
1100 wxDataViewBitmapRenderer,
1101 wxDataViewDateRenderer.
1102 wxDataViewSpinRenderer.
1104 Additionally, the user can write own renderers by deriving from
1105 wxDataViewCustomRenderer.
1107 The @e wxDataViewCellMode flag controls, what actions
1108 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1109 indicates that the user can double click the cell and
1110 something will happen (e.g. a window for editing a date
1111 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1112 that the user can edit the data in-place, i.e. an control
1113 will show up after a slow click on the cell. This behaviour
1114 is best known from changing the filename in most file
1119 enum wxDataViewCellMode
1121 wxDATAVIEW_CELL_INERT,
1122 wxDATAVIEW_CELL_ACTIVATABLE,
1123 wxDATAVIEW_CELL_EDITABLE
1127 The @e wxDataViewCellRenderState flag controls how the
1128 the renderer should display its contents in a cell:
1131 enum wxDataViewCellRenderState
1133 wxDATAVIEW_CELL_SELECTED = 1,
1134 wxDATAVIEW_CELL_PRELIT = 2,
1135 wxDATAVIEW_CELL_INSENSITIVE = 4,
1136 wxDATAVIEW_CELL_FOCUSED = 8
1144 class wxDataViewRenderer
: public wxObject
1150 wxDataViewRenderer(const wxString
& varianttype
,
1151 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1152 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1155 Returns the alignment. See SetAlignment()
1157 virtual int GetAlignment() const;
1160 Returns the cell mode.
1162 virtual wxDataViewCellMode
GetMode();
1165 Returns pointer to the owning wxDataViewColumn.
1167 virtual wxDataViewColumn
* GetOwner() const;
1170 This methods retrieves the value from the renderer in order to
1171 transfer the value back to the data model. Returns @e @false
1174 virtual bool GetValue(wxVariant
& value
);
1177 Returns a string with the type of the wxVariant
1178 supported by this renderer.
1180 virtual wxString
GetVariantType();
1183 Sets the alignment of the renderer's content. The default value
1184 of wxDVR_DEFAULT_ALIGMENT indicates that the content should
1185 have the same alignment as the column header. The method is
1186 not implemented under OS X and the renderer always aligns its
1187 contents as the column header on that platform. The other platforms
1188 support both vertical and horizontal alignment.
1190 virtual void SetAlignment( int align
);
1192 Sets the owning wxDataViewColumn. This
1193 is usually called from within wxDataViewColumn.
1195 virtual void SetOwner(wxDataViewColumn
* owner
);
1198 Set the value of the renderer (and thus its cell) to @e value.
1199 The internal code will then render this cell with this data.
1201 virtual bool SetValue(const wxVariant
& value
);
1204 Before data is committed to the data model, it is passed to this
1205 method where it can be checked for validity. This can also be
1206 used for checking a valid range or limiting the user input in
1207 a certain aspect (e.g. max number of characters or only alphanumeric
1208 input, ASCII only etc.). Return @e @false if the value is
1210 Please note that due to implementation limitations, this validation
1211 is done after the editing control already is destroyed and the
1212 editing process finished.
1214 virtual bool Validate(wxVariant
& value
);
1220 @class wxDataViewTextRenderer
1222 wxDataViewTextRenderer is used for rendering text. It supports
1223 in-place editing if desired.
1228 class wxDataViewTextRenderer
: public wxDataViewRenderer
1234 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1235 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1236 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1242 @class wxDataViewIconTextRenderer
1244 The wxDataViewIconTextRenderer class is used to display text with
1245 a small icon next to it as it is typically done in a file manager.
1246 This classes uses the wxDataViewIconText
1247 helper class to store its data. wxDataViewIonText can be converted
1248 to a from a wxVariant using the left shift
1254 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1260 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1261 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1262 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1268 @class wxDataViewProgressRenderer
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
1292 This is a specialized renderer for rendering integer values. It
1293 supports modifying the values in-place by using a wxSpinCtrl.
1294 The renderer only support variants of type @e long.
1299 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1303 Constructor. @a min and @a max indicate the minimum und
1304 maximum values of for the wxSpinCtrl.
1306 wxDataViewSpinRenderer(int min
, int max
,
1307 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1308 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1314 @class wxDataViewToggleRenderer
1316 wxDataViewToggleRenderer
1321 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1327 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1328 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1334 @class wxDataViewDateRenderer
1336 wxDataViewDateRenderer
1341 class wxDataViewDateRenderer
: public wxDataViewRenderer
1347 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1348 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
1354 @class wxDataViewTextRendererAttr
1356 The same as wxDataViewTextRenderer but with
1357 support for font attributes. Font attributes are currently only supported
1360 See also wxDataViewModel::GetAttr and
1366 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1372 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1373 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1374 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1380 @class wxDataViewCustomRenderer
1382 You need to derive a new class from wxDataViewCustomRenderer in
1383 order to write a new renderer. You need to override at least
1384 wxDataViewRenderer::SetValue,
1385 wxDataViewRenderer::GetValue,
1386 wxDataViewCustomRenderer::GetSize
1387 and wxDataViewCustomRenderer::Render.
1389 If you want your renderer to support in-place editing then you
1390 also need to override
1391 wxDataViewCustomRenderer::HasEditorCtrl,
1392 wxDataViewCustomRenderer::CreateEditorCtrl
1393 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1394 Note that a special event handler will be pushed onto that
1395 editor control which handles ENTER and focus out events
1396 in order to end the editing.
1401 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1407 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1408 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1409 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1414 ~wxDataViewCustomRenderer();
1417 Override this to react to double clicks or ENTER. This method will
1418 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1420 virtual bool Activate( wxRect cell
,
1421 wxDataViewModel
* model
,
1422 const wxDataViewItem
& item
,
1426 Override this to create the actual editor control once editing
1427 is about to start. @a parent is the parent of the editor
1428 control, @a labelRect indicates the position and
1429 size of the editor control and @a value is its initial value:
1431 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1433 const wxVariant
& value
);
1436 Create DC on request. Internal.
1438 virtual wxDC
* GetDC();
1441 Return size required to show content.
1443 virtual wxSize
GetSize();
1446 Overrride this so that the renderer can get the value
1447 from the editor control (pointed to by @e editor):
1449 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1453 Override this and make it return @e @true in order to
1454 indicate that this renderer supports in-place editing.
1456 virtual bool HasEditorCtrl();
1459 Overrride this to react to a left click. This method will
1460 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1462 virtual bool LeftClick( wxPoint cursor
,
1464 wxDataViewModel
* model
,
1465 const wxDataViewItem
& item
,
1469 Override this to render the cell. Before this is called,
1470 wxDataViewRenderer::SetValue was called
1471 so that this instance knows what to render.
1473 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
);
1476 This method should be called from within Render()
1477 whenever you need to render simple text. This will ensure that the
1478 correct colour, font and vertical alignment will be chosen so the
1479 text will look the same as text drawn by native renderers.
1481 bool RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1482 wxDC
* dc
, int state
);
1485 Overrride this to start a drag operation. Not yet
1488 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1489 wxDataViewModel
* model
,
1490 const wxDataViewItem
& item
,
1497 @class wxDataViewBitmapRenderer
1499 wxDataViewBitmapRenderer
1504 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1510 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1511 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1512 int align
= wxDVR_DEFAULT_ALIGNMENT
,
1518 @class wxDataViewColumn
1520 This class represents a column in a wxDataViewCtrl.
1521 One wxDataViewColumn is bound to one column in the data model,
1522 to which the wxDataViewCtrl has been associated.
1524 An instance of wxDataViewRenderer is used by
1525 this class to render its data.
1530 class wxDataViewColumn
: public wxObject
1537 wxDataViewColumn(const wxString
& title
,
1538 wxDataViewRenderer
* renderer
,
1539 unsigned int model_column
,
1540 int width
= wxDVC_DEFAULT_WIDTH
,
1541 wxAlignment align
= wxALIGN_CENTRE
,
1542 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1543 wxDataViewColumn(const wxBitmap
& bitmap
,
1544 wxDataViewRenderer
* renderer
,
1545 unsigned int model_column
,
1546 int width
= wxDVC_DEFAULT_WIDTH
,
1547 wxAlignment align
= wxALIGN_CENTRE
,
1548 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1554 ~wxDataViewColumn();
1557 Returns the bitmap in the header of the column, if any.
1559 const wxBitmap
GetBitmap();
1562 Returns the index of the column of the model, which this
1563 wxDataViewColumn is displaying.
1565 unsigned int GetModelColumn();
1568 Returns the owning wxDataViewCtrl.
1570 wxDataViewCtrl
* GetOwner() const;
1573 Returns the renderer of this wxDataViewColumn.
1574 See also wxDataViewRenderer.
1576 wxDataViewRenderer
* GetRenderer();
1579 Returns @true if the column is reorderable.
1581 bool GetReorderable();
1584 Returns @true if the column is sortable.
1590 Returns the width of the column.
1595 Returns @true, if the sort order is ascending.
1596 See also SetSortOrder()
1598 bool IsSortOrderAscending();
1601 Set the alignment of the column header.
1603 void SetAlignment(wxAlignment align
);
1606 Set the bitmap of the column header.
1608 void SetBitmap(const wxBitmap
& bitmap
);
1611 Indicate wether the column can be reordered by the
1612 user using the mouse. This is typically implemented
1613 visually by dragging the header button around.
1615 void SetReorderable(bool reorderable
);
1618 Indicate the sort order if the implementation of the
1619 wxDataViewCtrl supports it, most commonly by showing
1622 void SetSortOrder(bool ascending
);
1625 Indicate that the column is sortable. This does
1626 not show any sorting indicate yet, but it does
1627 make the column header clickable. Call
1629 afterwards to actually make the sort indicator appear.
1630 If @a sortable is @false, the column header is
1631 no longer clickable and the sort indicator (little
1632 arrow) will disappear.
1634 void SetSortable(bool sortable
);
1637 Set the title of the column header to @e title.
1639 void SetTitle(const wxString
& title
);
1645 @class wxDataViewTreeCtrl
1647 This class is a wxDataViewCtrl which internally
1648 uses a wxDataViewTreeStore and forwards
1649 most of its API to that class. Additionally, it uses a wxImageList
1650 to store a list of icons. The main purpose of this class is to look
1651 like a wxTreeCtrl to make a transition from it
1652 to the wxDataViewCtrl class simpler.
1656 <!-- @appearance{dataviewtreectrl.png} -->
1658 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1663 Constructor. Calls Create().
1665 wxDataViewTreeCtrl();
1666 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1667 const wxPoint
& pos
= wxDefaultPosition
,
1668 const wxSize
& size
= wxDefaultSize
,
1669 long style
= wxDV_NO_HEADER
,
1670 const wxValidator
& validator
= wxDefaultValidator
);
1674 Destructor. Deletes the image list if any.
1676 ~wxDataViewTreeCtrl();
1681 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1682 const wxString
& text
,
1685 wxClientData
* data
= NULL
);
1690 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1691 const wxString
& text
,
1693 wxClientData
* data
= NULL
);
1696 Creates the control and a wxDataViewTreeStore as
1699 bool Create(wxWindow
* parent
, wxWindowID id
,
1700 const wxPoint
& pos
= wxDefaultPosition
,
1701 const wxSize
& size
= wxDefaultSize
,
1702 long style
= wxDV_NO_HEADER
,
1703 const wxValidator
& validator
= wxDefaultValidator
);
1706 Calls the identical method from wxDataViewTreeStore.
1708 void DeleteAllItems();
1711 Calls the identical method from wxDataViewTreeStore.
1713 void DeleteChildren(const wxDataViewItem
& item
);
1716 Calls the identical method from wxDataViewTreeStore.
1718 void DeleteItem(const wxDataViewItem
& item
);
1721 Calls the identical method from wxDataViewTreeStore.
1723 int GetChildCount(const wxDataViewItem
& parent
) const;
1726 Returns the image list.
1728 wxImageList
* GetImageList();
1731 Calls the identical method from wxDataViewTreeStore.
1733 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1736 Calls the identical method from wxDataViewTreeStore.
1738 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1741 Calls the identical method from wxDataViewTreeStore.
1743 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1746 Calls the identical method from wxDataViewTreeStore.
1748 wxString
GetItemText(const wxDataViewItem
& item
) const;
1751 Calls the identical method from wxDataViewTreeStore.
1753 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1754 unsigned int pos
) const;
1760 wxDataViewTreeStore
* GetStore() const;
1761 const wxDataViewTreeStore
* GetStore() const;
1765 Calls the same method from wxDataViewTreeStore but uess
1766 and index position in the image list instead of a wxIcon.
1768 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1769 const wxDataViewItem
& previous
,
1770 const wxString
& text
,
1773 wxClientData
* data
= NULL
);
1776 Calls the same method from wxDataViewTreeStore but uess
1777 and index position in the image list instead of a wxIcon.
1779 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1780 const wxDataViewItem
& previous
,
1781 const wxString
& text
,
1783 wxClientData
* data
= NULL
);
1786 Calls the same method from wxDataViewTreeStore but uess
1787 and index position in the image list instead of a wxIcon.
1789 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1790 const wxString
& text
,
1793 wxClientData
* data
= NULL
);
1796 Calls the same method from wxDataViewTreeStore but uess
1797 and index position in the image list instead of a wxIcon.
1799 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1800 const wxString
& text
,
1802 wxClientData
* data
= NULL
);
1805 Sets the image list.
1807 void SetImageList(wxImageList
* imagelist
);
1810 Calls the identical method from wxDataViewTreeStore.
1812 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1815 Calls the identical method from wxDataViewTreeStore.
1817 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1818 const wxIcon
& icon
);
1821 Calls the identical method from wxDataViewTreeStore.
1823 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1826 Calls the identical method from wxDataViewTreeStore.
1828 void SetItemText(const wxDataViewItem
& item
,
1829 const wxString
& text
);
1835 @class wxDataViewTreeStore
1837 wxDataViewTreeStore is a specialised wxDataViewModel
1838 for displaying simple trees very much like wxTreeCtrl
1839 does and it offers a similar API. This class actually stores the entire
1840 tree (therefore its name) and implements all virtual methods from the base
1841 class so it can be used directly without having to derive any class from it.
1842 This comes at the price of much reduced flexibility.
1847 class wxDataViewTreeStore
: public wxDataViewModel
1851 Constructor. Creates the invisible root node internally.
1853 wxDataViewTreeStore();
1858 ~wxDataViewTreeStore();
1863 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1864 const wxString
& text
,
1865 const wxIcon
& icon
= wxNullIcon
,
1866 const wxIcon
& expanded
= wxNullIcon
,
1867 wxClientData
* data
= NULL
);
1872 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1873 const wxString
& text
,
1874 const wxIcon
& icon
= wxNullIcon
,
1875 wxClientData
* data
= NULL
);
1878 Delete all item in the model.
1880 void DeleteAllItems();
1883 Delete all children of the item, but not the item itself.
1885 void DeleteChildren(const wxDataViewItem
& item
);
1890 void DeleteItem(const wxDataViewItem
& item
);
1893 Return the number of children of item.
1895 int GetChildCount(const wxDataViewItem
& parent
) const;
1898 Returns the client data asoociated with the item.
1900 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1903 Returns the icon to display in expanded containers.
1905 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1908 Returns the icon of the item.
1910 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1913 Returns the text of the item.
1915 wxString
GetItemText(const wxDataViewItem
& item
) const;
1918 Returns the nth child item of item.
1920 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1921 unsigned int pos
) const;
1924 Inserts a container after @e previous.
1926 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1927 const wxDataViewItem
& previous
,
1928 const wxString
& text
,
1929 const wxIcon
& icon
= wxNullIcon
,
1930 const wxIcon
& expanded
= wxNullIcon
,
1931 wxClientData
* data
= NULL
);
1934 Inserts an item after @e previous.
1936 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1937 const wxDataViewItem
& previous
,
1938 const wxString
& text
,
1939 const wxIcon
& icon
= wxNullIcon
,
1940 wxClientData
* data
= NULL
);
1943 Inserts a container before the first child item or @e parent.
1945 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1946 const wxString
& text
,
1947 const wxIcon
& icon
= wxNullIcon
,
1948 const wxIcon
& expanded
= wxNullIcon
,
1949 wxClientData
* data
= NULL
);
1952 Inserts an item before the first child item or @e parent.
1954 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1955 const wxString
& text
,
1956 const wxIcon
& icon
= wxNullIcon
,
1957 wxClientData
* data
= NULL
);
1960 Sets the client data associated with the item.
1962 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1965 Sets the expanded icon for the item.
1967 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1968 const wxIcon
& icon
);
1971 Sets the icon for the item.
1973 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);