1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @class wxDataViewModel
13 wxDataViewModel is the base class for all data model to be displayed by a
16 All other models derive from it and must implement its pure virtual functions
17 in order to define a complete data model. In detail, you need to override
18 wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren,
19 wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and
20 wxDataViewModel::GetValue in order to define the data model which acts as an
21 interface between your actual data and the wxDataViewCtrl.
23 Since you will usually also allow the wxDataViewCtrl to change your data
24 through its graphical interface, you will also have to override
25 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
26 to some data has been commited.
28 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
29 to store data and its type in a generic way. wxVariant can be extended to contain
30 almost any data without changes to the original class.
32 The data that is presented through this data model is expected to change at
33 run-time. You need to inform the data model when a change happened.
34 Depending on what happened you need to call one of the following methods:
35 - wxDataViewModel::ValueChanged,
36 - wxDataViewModel::ItemAdded,
37 - wxDataViewModel::ItemDeleted,
38 - wxDataViewModel::ItemChanged,
39 - wxDataViewModel::Cleared.
41 There are plural forms for notification of addition, change or removal of
42 several item at once. See:
43 - wxDataViewModel::ItemsAdded,
44 - wxDataViewModel::ItemsDeleted,
45 - wxDataViewModel::ItemsChanged.
47 Note that wxDataViewModel does not define the position or index of any item
48 in the control because different controls might display the same data differently.
49 wxDataViewModel does provide a wxDataViewModel::Compare method which the
50 wxDataViewCtrl may use to sort the data either in conjunction with a column
51 header or without (see wxDataViewModel::HasDefaultCompare).
53 This class maintains a list of wxDataViewModelNotifier which link this class
54 to the specific implementations on the supported platforms so that e.g. calling
55 wxDataViewModel::ValueChanged on this model will just call
56 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
57 You can also add your own notifier in order to get informed about any changes
58 to the data in the list model.
60 Currently wxWidgets provides the following models apart from the base model:
61 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
64 Note that wxDataViewModel is reference counted, derives from wxObjectRefData
65 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
66 This implies that you need to decrease the reference count after
67 associating the model with a control like this:
70 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
71 wxDataViewModel *musicModel = new MyMusicModel;
72 m_musicCtrl->AssociateModel( musicModel );
73 musicModel->DecRef(); // avoid memory leak !!
81 class wxDataViewModel
: public wxObjectRefData
90 Adds a wxDataViewModelNotifier to the model.
92 void AddNotifier(wxDataViewModelNotifier
* notifier
);
95 Called to inform the model that all data has been cleared.
96 The control will reread the data from the model again.
98 virtual bool Cleared();
101 The compare function to be used by control. The default compare function
102 sorts by container and other items separately and in ascending order.
103 Override this for a different sorting behaviour.
105 @see HasDefaultCompare().
107 virtual int Compare(const wxDataViewItem
& item1
,
108 const wxDataViewItem
& item2
,
110 bool ascending
) const;
113 Override this to indicate that the item has special font attributes.
114 This only affects the wxDataViewTextRendererText renderer.
116 @see wxDataViewItemAttr.
118 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
119 wxDataViewItemAttr
& attr
);
122 Override this so the control can query the child items of an item.
123 Returns the number of items.
125 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
126 wxDataViewItemArray
& children
) const = 0;
129 Override this to indicate the number of columns in the model.
131 virtual unsigned int GetColumnCount() const = 0;
134 Override this to indicate what type of data is stored in the
135 column specified by @a col.
137 This should return a string indicating the type of data as reported by wxVariant.
139 virtual wxString
GetColumnType(unsigned int col
) const = 0;
142 Override this to indicate which wxDataViewItem representing the parent
143 of @a item or an invalid wxDataViewItem if the the root item is
146 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
149 Override this to indicate the value of @a item.
150 A wxVariant is used to store the data.
152 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
153 unsigned int col
) const = 0;
156 Override this method to indicate if a container item merely acts as a
157 headline (or for categorisation) or if it also acts a normal item with
158 entries for futher columns. By default returns @false.
160 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
163 Override this to indicate that the model provides a default compare
164 function that the control should use if no wxDataViewColumn has been
165 chosen for sorting. Usually, the user clicks on a column header for
166 sorting, the data will be sorted alphanumerically.
168 If any other order (e.g. by index or order of appearance) is required,
169 then this should be used.
170 See wxDataViewIndexListModel for a model which makes use of this.
172 virtual bool HasDefaultCompare() const;
175 Override this to indicate of @a item is a container, i.e. if
176 it can have child items.
178 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
181 Call this to inform the model that an item has been added to the data.
183 virtual bool ItemAdded(const wxDataViewItem
& parent
,
184 const wxDataViewItem
& item
);
187 Call this to inform the model that an item has changed.
189 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
190 event (in which the column fields will not be set) to the user.
192 virtual bool ItemChanged(const wxDataViewItem
& item
);
195 Call this to inform the model that an item has been deleted from the data.
197 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
198 const wxDataViewItem
& item
);
201 Call this to inform the model that several items have been added to the data.
203 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
204 const wxDataViewItemArray
& items
);
207 Call this to inform the model that several items have changed.
209 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
210 events (in which the column fields will not be set) to the user.
212 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
215 Call this to inform the model that several items have been deleted.
217 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
218 const wxDataViewItemArray
& items
);
221 Remove the @a notifier from the list of notifiers.
223 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
226 Call this to initiate a resort after the sort function has been changed.
228 virtual void Resort();
231 This gets called in order to set a value in the data model.
232 The most common scenario is that the wxDataViewCtrl calls this method
233 after the user changed some data in the view.
235 Afterwards ValueChanged() has to be called!
237 virtual bool SetValue(const wxVariant
& variant
, const wxDataViewItem
& item
,
238 unsigned int col
) = 0;
241 Call this to inform this model that a value in the model has been changed.
242 This is also called from wxDataViewCtrl's internal editing code, e.g. when
243 editing a text field in the control.
245 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
248 virtual bool ValueChanged(const wxDataViewItem
& item
,
254 Destructor. This should not be called directly. Use DecRef() instead.
256 virtual ~wxDataViewModel();
262 @class wxDataViewIndexListModel
264 wxDataViewIndexListModel is a specialized data model which lets you address
265 an item by its position (row) rather than its wxDataViewItem (which you can
266 obtain from this class).
267 This model also provides its own wxDataViewIndexListModel::Compare
268 method which sorts the model's data by the index.
270 This model is not a virtual model since the control stores each wxDataViewItem.
271 Use wxDataViewVirtualListModel if you need to display millions of items or
272 have other reason to use a virtual control.
277 class wxDataViewIndexListModel
: public wxDataViewModel
283 wxDataViewIndexListModel(unsigned int initial_size
= 0);
288 virtual ~wxDataViewIndexListModel();
291 Compare method that sorts the items by their index.
293 int Compare(const wxDataViewItem
& item1
,
294 const wxDataViewItem
& item2
,
295 unsigned int column
, bool ascending
);
298 Override this to indicate that the row has special font attributes.
299 This only affects the wxDataViewTextRendererText() renderer.
301 @see wxDataViewItemAttr.
303 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
304 wxDataViewItemAttr
& attr
);
307 Returns the wxDataViewItem at the given @e row.
309 wxDataViewItem
GetItem(unsigned int row
) const;
312 Returns the position of given @e item.
314 unsigned int GetRow(const wxDataViewItem
& item
) const;
317 Override this to allow getting values from the model.
319 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
320 unsigned int col
) const = 0;
323 Call this after if the data has to be read again from the model.
324 This is useful after major changes when calling the methods below
325 (possibly thousands of times) doesn't make sense.
327 void Reset(unsigned int new_size
);
330 Call this after a row has been appended to the model.
335 Call this after a row has been changed.
337 void RowChanged(unsigned int row
);
340 Call this after a row has been deleted.
342 void RowDeleted(unsigned int row
);
345 Call this after a row has been inserted at the given position.
347 void RowInserted(unsigned int before
);
350 Call this after a row has been prepended to the model.
355 Call this after a value has been changed.
357 void RowValueChanged(unsigned int row
, unsigned int col
);
360 Call this after rows have been deleted.
361 The array will internally get copied and sorted in descending order so
362 that the rows with the highest position will be deleted first.
364 void RowsDeleted(const wxArrayInt
& rows
);
367 Called in order to set a value in the model.
369 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
370 unsigned int col
) = 0;
376 @class wxDataViewVirtualListModel
378 wxDataViewVirtualListModel is a specialized data model which lets you address
379 an item by its position (row) rather than its wxDataViewItem and as such offers
380 the exact same interface as wxDataViewIndexListModel.
381 The important difference is that under platforms other than OS X, using this
382 model will result in a truly virtual control able to handle millions of items
383 as the control doesn't store any item (a feature not supported by the
384 Carbon API under OS X).
386 @see wxDataViewIndexListModel for the API.
391 class wxDataViewVirtualListModel
: public wxDataViewModel
397 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
403 @class wxDataViewItemAttr
405 This class is used to indicate to a wxDataViewCtrl that a certain item
406 (see wxDataViewItem) has extra font attributes for its renderer.
407 For this, it is required to override wxDataViewModel::GetAttr.
409 Attributes are currently only supported by wxDataViewTextRendererText.
414 class wxDataViewItemAttr
420 wxDataViewItemAttr();
423 Call this to indicate that the item shall be displayed in bold text.
425 void SetBold(bool set
);
428 Call this to indicate that the item shall be displayed with that colour.
430 void SetColour(const wxColour
& colour
);
433 Call this to indicate that the item shall be displayed in italic text.
435 void SetItalic(bool set
);
441 @class wxDataViewItem
443 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
444 in a persistent way, i.e. indepent of the position of the item in the control
445 or changes to its contents.
447 It must hold a unique ID of type @e void* in its only field and can be converted
450 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
451 return @false which used in many places in the API of wxDataViewCtrl to
452 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
453 the invisible root. Examples for this are wxDataViewModel::GetParent and
454 wxDataViewModel::GetChildren.
466 wxDataViewItem(void* id
= NULL
);
467 wxDataViewItem(const wxDataViewItem
& item
);
476 Returns @true if the ID is not @NULL.
484 @class wxDataViewCtrl
486 wxDataViewCtrl is a control to display data either in a tree like fashion or
487 in a tabular form or both.
489 If you only need to display a simple tree structure with an API more like the
490 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
491 Likewise, if you only want to display simple table structure you can use
492 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
493 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
495 A wxDataViewItem is used to represent a (visible) item in the control.
497 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
498 virtual functions or by setting it directly. Instead you need to write your own
499 wxDataViewModel and associate it with this control.
500 Then you need to add a number of wxDataViewColumn to this control to define
501 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
502 of a wxDataViewRenderer to render its cells.
504 A number of standard renderers for rendering text, dates, images, toggle,
505 a progress bar etc. are provided. Additionally, the user can write custom
506 renderers deriving from wxDataViewCustomRenderer for displaying anything.
508 All data transfer from the control to the model and the user code is done
509 through wxVariant which can be extended to support more data formats as necessary.
510 Accordingly, all type information uses the strings returned from wxVariant::GetType.
514 Single selection mode. This is the default.
515 @style{wxDV_MULTIPLE}
516 Multiple selection mode.
517 @style{wxDV_ROW_LINES}
518 Use alternating colours for rows if supported by platform and theme.
519 @style{wxDV_HORIZ_RULES}
520 Display fine rules between row if supported.
521 @style{wxDV_VERT_RULES}
522 Display fine rules between columns is supported.
523 @style{wxDV_VARIABLE_LINE_HEIGHT}
524 Allow variable line heights.
525 This can be inefficient when displaying large number of items.
528 @beginEventEmissionTable{wxDataViewEvent}
529 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
530 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
531 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
532 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
533 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
534 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This
535 event can be vetoed in order to prevent editing on an item by item
536 basis. Still experimental.
537 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
538 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
539 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
540 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
541 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
542 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
543 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
544 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
545 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
546 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
547 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
548 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
549 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
550 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
551 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
552 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
553 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
554 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
555 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
556 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
557 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
558 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
559 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
560 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
561 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
562 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
563 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
564 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
565 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
566 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
571 @appearance{dataviewctrl.png}
573 class wxDataViewCtrl
: public wxControl
582 Constructor. Calls Create().
584 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
585 const wxPoint
& pos
= wxDefaultPosition
,
586 const wxSize
& size
= wxDefaultSize
,
588 const wxValidator
& validator
= wxDefaultValidator
);
593 virtual ~wxDataViewCtrl();
596 Appends a wxDataViewColumn to the control. Returns @true on success.
598 Note that there is a number of short cut methods which implicitly create
599 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
601 virtual bool AppendColumn(wxDataViewColumn
* col
);
604 Prepends a wxDataViewColumn to the control. Returns @true on success.
606 Note that there is a number of short cut methods which implicitly create
607 a wxDataViewColumn and a wxDataViewRenderer for it.
609 virtual bool PrependColumn(wxDataViewColumn
* col
);
612 Inserts a wxDataViewColumn to the control. Returns @true on success.
614 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
618 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
619 created in the function or @NULL on failure.
621 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
622 unsigned int model_column
,
623 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
625 wxAlignment align
= wxALIGN_CENTER
,
626 int flags
= wxDATAVIEW_COL_RESIZABLE
);
627 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
628 unsigned int model_column
,
629 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
631 wxAlignment align
= wxALIGN_CENTER
,
632 int flags
= wxDATAVIEW_COL_RESIZABLE
);
637 Appends a column for rendering a date. Returns the wxDataViewColumn
638 created in the function or @NULL on failure.
640 @note The @a align parameter is applied to both the column header and
643 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
644 unsigned int model_column
,
645 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
647 wxAlignment align
= wxALIGN_NOT
,
648 int flags
= wxDATAVIEW_COL_RESIZABLE
);
649 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
650 unsigned int model_column
,
651 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
653 wxAlignment align
= wxALIGN_NOT
,
654 int flags
= wxDATAVIEW_COL_RESIZABLE
);
659 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
660 created in the function or @NULL on failure.
661 This method uses the wxDataViewIconTextRenderer class.
663 @note The @a align parameter is applied to both the column header and
666 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
667 unsigned int model_column
,
668 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
670 wxAlignment align
= wxALIGN_NOT
,
671 int flags
= wxDATAVIEW_COL_RESIZABLE
);
672 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
673 unsigned int model_column
,
674 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
676 wxAlignment align
= wxALIGN_NOT
,
677 int flags
= wxDATAVIEW_COL_RESIZABLE
);
682 Appends a column for rendering a progress indicator. Returns the
683 wxDataViewColumn created in the function or @NULL on failure.
685 @note The @a align parameter is applied to both the column header and
688 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
689 unsigned int model_column
,
690 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
692 wxAlignment align
= wxALIGN_CENTER
,
693 int flags
= wxDATAVIEW_COL_RESIZABLE
);
694 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
695 unsigned int model_column
,
696 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
698 wxAlignment align
= wxALIGN_CENTER
,
699 int flags
= wxDATAVIEW_COL_RESIZABLE
);
704 Appends a column for rendering text. Returns the wxDataViewColumn
705 created in the function or @NULL on failure.
707 @note The @a align parameter is applied to both the column header and
710 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
711 unsigned int model_column
,
712 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
714 wxAlignment align
= wxALIGN_NOT
,
715 int flags
= wxDATAVIEW_COL_RESIZABLE
);
716 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
717 unsigned int model_column
,
718 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
720 wxAlignment align
= wxALIGN_NOT
,
721 int flags
= wxDATAVIEW_COL_RESIZABLE
);
726 Appends a column for rendering a toggle. Returns the wxDataViewColumn
727 created in the function or @NULL on failure.
729 @note The @a align parameter is applied to both the column header and
732 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
733 unsigned int model_column
,
734 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
736 wxAlignment align
= wxALIGN_CENTER
,
737 int flags
= wxDATAVIEW_COL_RESIZABLE
);
738 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
739 unsigned int model_column
,
740 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
742 wxAlignment align
= wxALIGN_CENTER
,
743 int flags
= wxDATAVIEW_COL_RESIZABLE
);
747 Associates a wxDataViewModel with the control.
748 This increases the reference count of the model by 1.
750 virtual bool AssociateModel(wxDataViewModel
* model
);
755 virtual bool ClearColumns();
760 virtual void Collapse(const wxDataViewItem
& item
);
763 Create the control. Useful for two step creation.
765 bool Create(wxWindow
* parent
, wxWindowID id
,
766 const wxPoint
& pos
= wxDefaultPosition
,
767 const wxSize
& size
= wxDefaultSize
,
769 const wxValidator
& validator
= wxDefaultValidator
);
772 Deletes given column.
774 virtual bool DeleteColumn(wxDataViewColumn
* column
);
777 Enable drag operations using the given @a format.
779 virtual bool EnableDragSource( const wxDataFormat
&format
);
782 Enable drop operations using the given @a format.
784 virtual bool EnableDropTarget( const wxDataFormat
&format
);
787 Call this to ensure that the given item is visible.
789 virtual void EnsureVisible(const wxDataViewItem
& item
,
790 const wxDataViewColumn
* column
= NULL
);
795 virtual void Expand(const wxDataViewItem
& item
);
798 Expands all ancestors of the @a item. This method also
799 ensures that the item itself as well as all ancestor
800 items have been read from the model by the control.
802 virtual void ExpandAncestors( const wxDataViewItem
& item
);
805 Returns pointer to the column. @a pos refers to the position in the
806 control which may change after reordering columns by the user.
808 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
811 Returns the number of columns.
813 virtual unsigned int GetColumnCount() const;
816 Returns the position of the column or -1 if not found in the control.
818 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
821 Returns column containing the expanders.
823 wxDataViewColumn
* GetExpanderColumn() const;
828 int GetIndent() const;
833 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
834 const wxDataViewColumn
* col
= NULL
) const;
837 Returns pointer to the data model associated with the control (if any).
839 wxDataViewModel
* GetModel();
842 Returns first selected item or an invalid item if none is selected.
844 virtual wxDataViewItem
GetSelection() const;
847 Fills @a sel with currently selected items and returns their number.
849 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
852 Returns the wxDataViewColumn currently responsible for sorting
853 or @NULL if none has been selected.
855 virtual wxDataViewColumn
* GetSortingColumn() const;
860 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
861 wxDataViewColumn
*& col
) const;
864 Return @true if the item is expanded.
866 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
869 Return @true if the item is selected.
871 virtual bool IsSelected(const wxDataViewItem
& item
) const;
874 Select the given item.
876 virtual void Select(const wxDataViewItem
& item
);
881 virtual void SelectAll();
884 Set which column shall contain the tree-like expanders.
886 void SetExpanderColumn(wxDataViewColumn
* col
);
889 Sets the indendation.
891 void SetIndent(int indent
);
894 Sets the selection to the array of wxDataViewItems.
896 virtual void SetSelections(const wxDataViewItemArray
& sel
);
899 Unselect the given item.
901 virtual void Unselect(const wxDataViewItem
& item
);
905 This method only has effect if multiple selections are allowed.
907 virtual void UnselectAll();
913 @class wxDataViewModelNotifier
915 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
916 its notification interface.
917 See the documentation of that class for further information.
922 class wxDataViewModelNotifier
928 wxDataViewModelNotifier();
933 virtual ~wxDataViewModelNotifier();
936 Called by owning model.
938 virtual bool Cleared() = 0;
941 Get owning wxDataViewModel.
943 wxDataViewModel
* GetOwner() const;
946 Called by owning model.
948 virtual bool ItemAdded(const wxDataViewItem
& parent
,
949 const wxDataViewItem
& item
) = 0;
952 Called by owning model.
954 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
957 Called by owning model.
959 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
960 const wxDataViewItem
& item
) = 0;
963 Called by owning model.
965 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
966 const wxDataViewItemArray
& items
);
969 Called by owning model.
971 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
974 Called by owning model.
976 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
977 const wxDataViewItemArray
& items
);
980 Called by owning model.
982 virtual void Resort() = 0;
985 Set owner of this notifier. Used internally.
987 void SetOwner(wxDataViewModel
* owner
);
990 Called by owning model.
992 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
997 The mode of a data-view cell; see wxDataViewRenderer for more info.
999 enum wxDataViewCellMode
1001 wxDATAVIEW_CELL_INERT
,
1004 Indicates that the user can double click the cell and something will
1005 happen (e.g. a window for editing a date will pop up).
1007 wxDATAVIEW_CELL_ACTIVATABLE
,
1010 Indicates that the user can edit the data in-place, i.e. an control
1011 will show up after a slow click on the cell. This behaviour is best
1012 known from changing the filename in most file managers etc.
1014 wxDATAVIEW_CELL_EDITABLE
1018 The values of this enum controls how a wxDataViewRenderer should display
1019 its contents in a cell.
1021 enum wxDataViewCellRenderState
1023 wxDATAVIEW_CELL_SELECTED
= 1,
1024 wxDATAVIEW_CELL_PRELIT
= 2,
1025 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1026 wxDATAVIEW_CELL_FOCUSED
= 8
1030 @class wxDataViewRenderer
1032 This class is used by wxDataViewCtrl to render the individual cells.
1033 One instance of a renderer class is owned by a wxDataViewColumn.
1034 There is a number of ready-to-use renderers provided:
1035 - wxDataViewTextRenderer,
1036 - wxDataViewTextRendererAttr,
1037 - wxDataViewIconTextRenderer,
1038 - wxDataViewToggleRenderer,
1039 - wxDataViewProgressRenderer,
1040 - wxDataViewBitmapRenderer,
1041 - wxDataViewDateRenderer,
1042 - wxDataViewSpinRenderer.
1044 Additionally, the user can write own renderers by deriving from
1045 wxDataViewCustomRenderer.
1047 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1048 by the constructors respectively controls what actions the cell data allows
1049 and how the renderer should display its contents in a cell.
1054 class wxDataViewRenderer
: public wxObject
1060 wxDataViewRenderer(const wxString
& varianttype
,
1061 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1062 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1065 Returns the alignment. See SetAlignment()
1067 virtual int GetAlignment() const;
1070 Returns the cell mode.
1072 virtual wxDataViewCellMode
GetMode() const;
1075 Returns pointer to the owning wxDataViewColumn.
1077 wxDataViewColumn
* GetOwner() const;
1080 This methods retrieves the value from the renderer in order to
1081 transfer the value back to the data model.
1083 Returns @false on failure.
1085 virtual bool GetValue(wxVariant
& value
) const = 0;
1088 Returns a string with the type of the wxVariant supported by this renderer.
1090 wxString
GetVariantType() const;
1093 Sets the alignment of the renderer's content.
1094 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1095 should have the same alignment as the column header.
1097 The method is not implemented under OS X and the renderer always aligns
1098 its contents as the column header on that platform. The other platforms
1099 support both vertical and horizontal alignment.
1101 virtual void SetAlignment( int align
);
1103 Sets the owning wxDataViewColumn.
1104 This is usually called from within wxDataViewColumn.
1106 void SetOwner(wxDataViewColumn
* owner
);
1109 Set the value of the renderer (and thus its cell) to @a value.
1110 The internal code will then render this cell with this data.
1112 virtual bool SetValue(const wxVariant
& value
) = 0;
1115 Before data is committed to the data model, it is passed to this
1116 method where it can be checked for validity. This can also be
1117 used for checking a valid range or limiting the user input in
1118 a certain aspect (e.g. max number of characters or only alphanumeric
1119 input, ASCII only etc.). Return @false if the value is not valid.
1121 Please note that due to implementation limitations, this validation
1122 is done after the editing control already is destroyed and the
1123 editing process finished.
1125 virtual bool Validate(wxVariant
& value
);
1131 @class wxDataViewTextRenderer
1133 wxDataViewTextRenderer is used for rendering text.
1134 It supports in-place editing if desired.
1139 class wxDataViewTextRenderer
: public wxDataViewRenderer
1145 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1146 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1147 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1153 @class wxDataViewIconTextRenderer
1155 The wxDataViewIconTextRenderer class is used to display text with
1156 a small icon next to it as it is typically done in a file manager.
1158 This classes uses the wxDataViewIconText helper class to store its data.
1159 wxDataViewIonText can be converted to and from a wxVariant using the left shift
1165 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1171 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1172 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1173 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1179 @class wxDataViewProgressRenderer
1181 This class is used by wxDataViewCtrl to render progress bars.
1186 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1192 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1193 const wxString
& varianttype
= "long",
1194 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1195 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1201 @class wxDataViewSpinRenderer
1203 This is a specialized renderer for rendering integer values.
1204 It supports modifying the values in-place by using a wxSpinCtrl.
1205 The renderer only support variants of type @e long.
1210 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1215 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1217 wxDataViewSpinRenderer(int min
, int max
,
1218 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1219 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1225 @class wxDataViewToggleRenderer
1227 This class is used by wxDataViewCtrl to render toggle controls.
1232 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1238 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1239 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1240 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1246 @class wxDataViewDateRenderer
1248 This class is used by wxDataViewCtrl to render calendar controls.
1253 class wxDataViewDateRenderer
: public wxDataViewRenderer
1259 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1260 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1261 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1267 @class wxDataViewTextRendererAttr
1269 The same as wxDataViewTextRenderer but with support for font attributes.
1270 Font attributes are currently only supported under GTK+ and MSW.
1272 @see wxDataViewModel::GetAttr and wxDataViewItemAttr.
1277 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1283 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1284 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1285 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1291 @class wxDataViewCustomRenderer
1293 You need to derive a new class from wxDataViewCustomRenderer in
1294 order to write a new renderer.
1296 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1297 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1299 If you want your renderer to support in-place editing then you also need to override
1300 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1301 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1303 Note that a special event handler will be pushed onto that editor control
1304 which handles @e \<ENTER\> and focus out events in order to end the editing.
1309 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1315 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1316 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1317 int align
= -1, bool no_init
= false);
1322 virtual ~wxDataViewCustomRenderer();
1325 Override this to react to double clicks or ENTER.
1326 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1328 virtual bool Activate( wxRect cell
,
1329 wxDataViewModel
* model
,
1330 const wxDataViewItem
& item
,
1334 Override this to create the actual editor control once editing
1337 @a parent is the parent of the editor control, @a labelRect indicates the
1338 position and size of the editor control and @a value is its initial value:
1342 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1343 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1347 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1349 const wxVariant
& value
);
1352 Create DC on request. Internal.
1354 virtual wxDC
* GetDC();
1357 Return size required to show content.
1359 virtual wxSize
GetSize() const = 0;
1362 Overrride this so that the renderer can get the value from the editor
1363 control (pointed to by @a editor):
1366 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1367 long l = sc->GetValue();
1373 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1377 Override this and make it return @true in order to
1378 indicate that this renderer supports in-place editing.
1380 virtual bool HasEditorCtrl() const;
1383 Overrride this to react to a left click.
1384 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1386 virtual bool LeftClick( wxPoint cursor
,
1388 wxDataViewModel
* model
,
1389 const wxDataViewItem
& item
,
1393 Override this to render the cell.
1394 Before this is called, wxDataViewRenderer::SetValue was called
1395 so that this instance knows what to render.
1397 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1400 This method should be called from within Render() whenever you need to
1402 This will ensure that the correct colour, font and vertical alignment will
1403 be chosen so the text will look the same as text drawn by native renderers.
1405 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1406 wxDC
* dc
, int state
);
1409 Overrride this to start a drag operation. Not yet supported.
1411 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1412 wxDataViewModel
* model
,
1413 const wxDataViewItem
& item
,
1420 @class wxDataViewBitmapRenderer
1422 This class is used by wxDataViewCtrl to render bitmap controls.
1427 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1433 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1434 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1435 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1440 The flags used by wxDataViewColumn.
1441 Can be combined together.
1443 enum wxDataViewColumnFlags
1445 wxDATAVIEW_COL_RESIZABLE
= 1,
1446 wxDATAVIEW_COL_SORTABLE
= 2,
1447 wxDATAVIEW_COL_REORDERABLE
= 4,
1448 wxDATAVIEW_COL_HIDDEN
= 8
1452 @class wxDataViewColumn
1454 This class represents a column in a wxDataViewCtrl.
1455 One wxDataViewColumn is bound to one column in the data model to which the
1456 wxDataViewCtrl has been associated.
1458 An instance of wxDataViewRenderer is used by this class to render its data.
1463 class wxDataViewColumn
: public wxSettableHeaderColumn
1467 Constructs a text column.
1470 The title of the column.
1472 The class which will render the contents of this column.
1474 The index of the model's column which is associated with this object.
1476 The width of the column.
1477 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1479 The alignment of the column title.
1481 One or more flags of the ::wxDataViewColumnFlags enumeration.
1483 wxDataViewColumn(const wxString
& title
,
1484 wxDataViewRenderer
* renderer
,
1485 unsigned int model_column
,
1486 int width
= wxDVC_DEFAULT_WIDTH
,
1487 wxAlignment align
= wxALIGN_CENTER
,
1488 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1491 Constructs a bitmap column.
1494 The bitmap of the column.
1496 The class which will render the contents of this column.
1498 The index of the model's column which is associated with this object.
1500 The width of the column.
1501 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1503 The alignment of the column title.
1505 One or more flags of the ::wxDataViewColumnFlags enumeration.
1507 wxDataViewColumn(const wxBitmap
& bitmap
,
1508 wxDataViewRenderer
* renderer
,
1509 unsigned int model_column
,
1510 int width
= wxDVC_DEFAULT_WIDTH
,
1511 wxAlignment align
= wxALIGN_CENTER
,
1512 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1515 Returns the index of the column of the model, which this
1516 wxDataViewColumn is displaying.
1518 unsigned int GetModelColumn() const;
1521 Returns the owning wxDataViewCtrl.
1523 wxDataViewCtrl
* GetOwner() const;
1526 Returns the renderer of this wxDataViewColumn.
1528 @see wxDataViewRenderer.
1530 wxDataViewRenderer
* GetRenderer() const;
1536 @class wxDataViewListCtrl
1538 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1539 and forwards most of its API to that class.
1541 The purpose of this class is to offer a simple way to display and
1542 edit a small table of data without having to write your own wxDataViewModel.
1545 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
1547 listctrl->AppendToggleColumn( "Toggle" );
1548 listctrl->AppendTextColumn( "Text" );
1550 wxVector<wxVariant> data;
1551 data.push_back( wxVariant(true) );
1552 data.push_back( wxVariant("row 1") );
1553 listctrl->AppendItem( data );
1556 data.push_back( wxVariant(false) );
1557 data.push_back( wxVariant("row 3") );
1558 listctrl->AppendItem( data );
1562 See wxDataViewCtrl for the list of supported styles.
1565 @beginEventEmissionTable
1566 See wxDataViewCtrl for the list of events emitted by this class.
1572 class wxDataViewListCtrl
: public wxDataViewCtrl
1578 wxDataViewListCtrl();
1581 Constructor. Calls Create().
1583 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1584 const wxPoint
& pos
= wxDefaultPosition
,
1585 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1586 const wxValidator
& validator
= wxDefaultValidator
);
1589 Destructor. Deletes the image list if any.
1591 ~wxDataViewListCtrl();
1594 Creates the control and a wxDataViewListStore as its internal model.
1596 bool Create( wxWindow
*parent
, wxWindowID id
,
1597 const wxPoint
& pos
= wxDefaultPosition
,
1598 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1599 const wxValidator
& validator
= wxDefaultValidator
);
1605 wxDataViewListStore
*GetStore();
1606 const wxDataViewListStore
*GetStore() const;
1610 @name Column management functions
1615 Appends a column to the control and additionally appends a
1616 column to the store with the type string.
1618 virtual void AppendColumn( wxDataViewColumn
*column
);
1621 Appends a column to the control and additionally appends a
1622 column to the list store with the type @a varianttype.
1624 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1627 Appends a text column to the control and the store.
1629 See wxDataViewColumn::wxDataViewColumn for more info about
1632 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1633 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1634 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1635 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1638 Appends a toggle column to the control and the store.
1640 See wxDataViewColumn::wxDataViewColumn for more info about
1643 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1644 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1645 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1646 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1649 Appends a progress column to the control and the store.
1651 See wxDataViewColumn::wxDataViewColumn for more info about
1654 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1655 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1656 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1657 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1660 Appends an icon-and-text column to the control and the store.
1662 See wxDataViewColumn::wxDataViewColumn for more info about
1665 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1666 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1667 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1668 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1671 Inserts a column to the control and additionally inserts a
1672 column to the store with the type string.
1674 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
1677 Inserts a column to the control and additionally inserts a
1678 column to the list store with the type @a varianttype.
1680 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
,
1681 const wxString
&varianttype
);
1684 Prepends a column to the control and additionally prepends a
1685 column to the store with the type string.
1687 virtual void PrependColumn( wxDataViewColumn
*column
);
1690 Prepends a column to the control and additionally prepends a
1691 column to the list store with the type @a varianttype.
1693 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1699 @name Item management functions
1704 Appends an item (=row) to the control and store.
1706 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1709 Prepends an item (=row) to the control and store.
1711 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1714 Inserts an item (=row) to the control and store.
1716 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1719 Delete the row at position @a row.
1721 void DeleteItem( unsigned row
);
1724 Delete all items (= all rows).
1726 void DeleteAllItems();
1729 Sets the value in the store and update the control.
1731 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
1734 Returns the value from the store.
1736 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
1739 Sets the value in the store and update the control.
1741 This method assumes that the a string is stored in respective
1744 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
1747 Returns the value from the store.
1749 This method assumes that the a string is stored in respective
1752 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
1755 Sets the value in the store and update the control.
1757 This method assumes that the a boolean value is stored in
1760 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
1763 Returns the value from the store.
1765 This method assumes that the a boolean value is stored in
1768 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
1775 @class wxDataViewTreeCtrl
1777 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1778 and forwards most of its API to that class.
1779 Additionally, it uses a wxImageList to store a list of icons.
1781 The main purpose of this class is to represent a possible replacement for
1785 See wxDataViewCtrl for the list of supported styles.
1788 @beginEventEmissionTable
1789 See wxDataViewCtrl for the list of events emitted by this class.
1794 @appearance{dataviewtreectrl.png}
1796 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1802 wxDataViewTreeCtrl();
1805 Constructor. Calls Create().
1807 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1808 const wxPoint
& pos
= wxDefaultPosition
,
1809 const wxSize
& size
= wxDefaultSize
,
1810 long style
= wxDV_NO_HEADER
,
1811 const wxValidator
& validator
= wxDefaultValidator
);
1814 Destructor. Deletes the image list if any.
1816 virtual ~wxDataViewTreeCtrl();
1819 Appends a container to the given @a parent.
1821 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1822 const wxString
& text
,
1825 wxClientData
* data
= NULL
);
1828 Appends an item to the given @a parent.
1830 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1831 const wxString
& text
,
1833 wxClientData
* data
= NULL
);
1836 Creates the control and a wxDataViewTreeStore as its internal model.
1838 bool Create(wxWindow
* parent
, wxWindowID id
,
1839 const wxPoint
& pos
= wxDefaultPosition
,
1840 const wxSize
& size
= wxDefaultSize
,
1841 long style
= wxDV_NO_HEADER
,
1842 const wxValidator
& validator
= wxDefaultValidator
);
1845 Calls the identical method from wxDataViewTreeStore.
1847 void DeleteAllItems();
1850 Calls the identical method from wxDataViewTreeStore.
1852 void DeleteChildren(const wxDataViewItem
& item
);
1855 Calls the identical method from wxDataViewTreeStore.
1857 void DeleteItem(const wxDataViewItem
& item
);
1860 Calls the identical method from wxDataViewTreeStore.
1862 int GetChildCount(const wxDataViewItem
& parent
) const;
1865 Returns the image list.
1867 wxImageList
* GetImageList();
1870 Calls the identical method from wxDataViewTreeStore.
1872 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1875 Calls the identical method from wxDataViewTreeStore.
1877 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1880 Calls the identical method from wxDataViewTreeStore.
1882 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
1885 Calls the identical method from wxDataViewTreeStore.
1887 wxString
GetItemText(const wxDataViewItem
& item
) const;
1890 Calls the identical method from wxDataViewTreeStore.
1892 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1893 unsigned int pos
) const;
1899 wxDataViewTreeStore
* GetStore();
1900 const wxDataViewTreeStore
* GetStore() const;
1904 Calls the same method from wxDataViewTreeStore but uses
1905 an index position in the image list instead of a wxIcon.
1907 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1908 const wxDataViewItem
& previous
,
1909 const wxString
& text
,
1912 wxClientData
* data
= NULL
);
1915 Calls the same method from wxDataViewTreeStore but uses
1916 an index position in the image list instead of a wxIcon.
1918 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1919 const wxDataViewItem
& previous
,
1920 const wxString
& text
,
1922 wxClientData
* data
= NULL
);
1925 Calls the same method from wxDataViewTreeStore but uses
1926 an index position in the image list instead of a wxIcon.
1928 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1929 const wxString
& text
,
1932 wxClientData
* data
= NULL
);
1935 Calls the same method from wxDataViewTreeStore but uses
1936 an index position in the image list instead of a wxIcon.
1938 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1939 const wxString
& text
,
1941 wxClientData
* data
= NULL
);
1944 Sets the image list.
1946 void SetImageList(wxImageList
* imagelist
);
1949 Calls the identical method from wxDataViewTreeStore.
1951 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1954 Calls the identical method from wxDataViewTreeStore.
1956 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1957 const wxIcon
& icon
);
1960 Calls the identical method from wxDataViewTreeStore.
1962 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1965 Calls the identical method from wxDataViewTreeStore.
1967 void SetItemText(const wxDataViewItem
& item
,
1968 const wxString
& text
);
1973 @class wxDataViewListStore
1975 wxDataViewListStore is a specialised wxDataViewModel for storing
1976 a simple table of data. Since it derives from wxDataViewIndexListModel
1977 its data is be accessed by row (i.e. by index) instead of only
1980 This class actually stores the values (therefore its name)
1981 and implements all virtual methods from the base classes so it can be
1982 used directly without having to derive any class from it, but it is
1983 mostly used from within wxDataViewListCtrl.
1989 class wxDataViewListStore
: public wxDataViewIndexListModel
1995 wxDataViewListStore();
2000 ~wxDataViewListStore();
2003 Prepends a data column.
2005 @a variantype indicates the type of values store in the column.
2007 This does not automatically fill in any (default) values in
2008 rows which exist in the store already.
2010 void PrependColumn( const wxString
&varianttype
);
2013 Inserts a data column before @a pos.
2015 @a variantype indicates the type of values store in the column.
2017 This does not automatically fill in any (default) values in
2018 rows which exist in the store already.
2020 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
2023 Appends a data column.
2025 @a variantype indicates the type of values store in the column.
2027 This does not automatically fill in any (default) values in
2028 rows which exist in the store already.
2030 void AppendColumn( const wxString
&varianttype
);
2033 Appends an item (=row) and fills it with @a values.
2035 The values must match the values specifies in the column
2036 in number and type. No (default) values are filled in
2039 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2042 Prepends an item (=row) and fills it with @a values.
2044 The values must match the values specifies in the column
2045 in number and type. No (default) values are filled in
2048 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2051 Inserts an item (=row) and fills it with @a values.
2053 The values must match the values specifies in the column
2054 in number and type. No (default) values are filled in
2057 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2060 Delete the item (=row) at position @a pos.
2062 void DeleteItem( unsigned pos
);
2065 Delete all item (=all rows) in the store.
2067 void DeleteAllItems();
2070 Overriden from wxDataViewModel
2072 virtual unsigned int GetColumnCount() const;
2075 Overriden from wxDataViewModel
2077 virtual wxString
GetColumnType( unsigned int col
) const;
2080 Overriden from wxDataViewIndexListModel
2082 virtual void GetValueByRow( wxVariant
&value
,
2083 unsigned int row
, unsigned int col
) const;
2086 Overriden from wxDataViewIndexListModel
2088 virtual bool SetValueByRow( const wxVariant
&value
,
2089 unsigned int row
, unsigned int col
);
2094 @class wxDataViewTreeStore
2096 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2097 trees very much like wxTreeCtrl does and it offers a similar API.
2099 This class actually stores the entire tree and the values (therefore its name)
2100 and implements all virtual methods from the base class so it can be used directly
2101 without having to derive any class from it, but it is mostly used from within
2107 class wxDataViewTreeStore
: public wxDataViewModel
2111 Constructor. Creates the invisible root node internally.
2113 wxDataViewTreeStore();
2118 virtual ~wxDataViewTreeStore();
2123 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2124 const wxString
& text
,
2125 const wxIcon
& icon
= wxNullIcon
,
2126 const wxIcon
& expanded
= wxNullIcon
,
2127 wxClientData
* data
= NULL
);
2132 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2133 const wxString
& text
,
2134 const wxIcon
& icon
= wxNullIcon
,
2135 wxClientData
* data
= NULL
);
2138 Delete all item in the model.
2140 void DeleteAllItems();
2143 Delete all children of the item, but not the item itself.
2145 void DeleteChildren(const wxDataViewItem
& item
);
2150 void DeleteItem(const wxDataViewItem
& item
);
2153 Return the number of children of item.
2155 int GetChildCount(const wxDataViewItem
& parent
) const;
2158 Returns the client data asoociated with the item.
2160 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2163 Returns the icon to display in expanded containers.
2165 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2168 Returns the icon of the item.
2170 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2173 Returns the text of the item.
2175 wxString
GetItemText(const wxDataViewItem
& item
) const;
2178 Returns the nth child item of item.
2180 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2181 unsigned int pos
) const;
2184 Inserts a container after @a previous.
2186 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2187 const wxDataViewItem
& previous
,
2188 const wxString
& text
,
2189 const wxIcon
& icon
= wxNullIcon
,
2190 const wxIcon
& expanded
= wxNullIcon
,
2191 wxClientData
* data
= NULL
);
2194 Inserts an item after @a previous.
2196 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2197 const wxDataViewItem
& previous
,
2198 const wxString
& text
,
2199 const wxIcon
& icon
= wxNullIcon
,
2200 wxClientData
* data
= NULL
);
2203 Inserts a container before the first child item or @a parent.
2205 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2206 const wxString
& text
,
2207 const wxIcon
& icon
= wxNullIcon
,
2208 const wxIcon
& expanded
= wxNullIcon
,
2209 wxClientData
* data
= NULL
);
2212 Inserts an item before the first child item or @a parent.
2214 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2215 const wxString
& text
,
2216 const wxIcon
& icon
= wxNullIcon
,
2217 wxClientData
* data
= NULL
);
2220 Sets the client data associated with the item.
2222 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2225 Sets the expanded icon for the item.
2227 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2228 const wxIcon
& icon
);
2231 Sets the icon for the item.
2233 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2238 @class wxDataViewIconText
2240 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2241 This class can be converted to and from a wxVariant.
2246 class wxDataViewIconText
: public wxObject
2253 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2254 const wxIcon
& icon
= wxNullIcon
);
2255 wxDataViewIconText(const wxDataViewIconText
& other
);
2261 const wxIcon
& GetIcon() const;
2266 wxString
GetText() const;
2271 void SetIcon(const wxIcon
& icon
);
2276 void SetText(const wxString
& text
);
2282 @class wxDataViewEvent
2284 This is the event class for the wxDataViewCtrl notifications.
2286 @beginEventTable{wxDataViewEvent}
2287 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2288 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2289 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2290 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2291 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2292 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2293 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2294 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2295 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2296 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2297 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2298 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2299 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2300 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2301 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2302 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2303 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2304 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2305 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2306 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2307 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2308 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2309 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2310 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2311 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2312 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2313 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2314 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2315 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2316 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2317 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2318 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2319 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2320 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2324 @category{events,dvc}
2326 class wxDataViewEvent
: public wxNotifyEvent
2330 Constructor. Typically used by wxWidgets internals only.
2332 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2336 Returns the position of the column in the control or -1
2337 if no column field was set by the event emitter.
2339 int GetColumn() const;
2342 Returns a pointer to the wxDataViewColumn from which
2343 the event was emitted or @NULL.
2345 wxDataViewColumn
* GetDataViewColumn() const;
2348 Returns the wxDataViewModel associated with the event.
2350 wxDataViewModel
* GetModel() const;
2353 Returns a the position of a context menu event in screen coordinates.
2355 wxPoint
GetPosition() const;
2358 Returns a reference to a value.
2360 const wxVariant
& GetValue() const;
2363 Sets the column index associated with this event.
2365 void SetColumn(int col
);
2368 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2370 void SetDataViewColumn(wxDataViewColumn
* col
);
2373 Sets the dataview model associated with this event.
2375 void SetModel(wxDataViewModel
* model
);
2378 Sets the value associated with this event.
2380 void SetValue(const wxVariant
& value
);
2383 Set wxDataObject for data transfer within a drag operation.
2385 void SetDataObject( wxDataObject
*obj
);
2388 Used internally. Gets associated wxDataObject for data transfer
2389 within a drag operation.
2391 wxDataObject
*GetDataObject() const;
2394 Used internally. Sets the wxDataFormat during a drop operation.
2396 void SetDataFormat( const wxDataFormat
&format
);
2399 Gets the wxDataFormat during a drop operation.
2401 wxDataFormat
GetDataFormat() const;
2404 Used internally. Sets the data size for a drop data transfer.
2406 void SetDataSize( size_t size
);
2409 Gets the data size for a drop data transfer.
2411 size_t GetDataSize() const;
2414 Used internally. Sets the data buffer for a drop data transfer.
2416 void SetDataBuffer( void* buf
);
2419 Gets the data buffer for a drop data transfer.
2421 void *GetDataBuffer() const;