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, ID_MUSIC_CTRL );
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
,
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 @beginEventTable{wxDataViewEvent}
529 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
530 Process a wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
531 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
532 Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
533 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
534 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
535 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
536 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
537 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
538 Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
539 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
540 Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
541 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
542 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
543 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
544 Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
545 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
546 Process a wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
547 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
548 Process a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
549 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
550 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
551 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
552 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
553 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
554 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
555 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
556 Process a wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
557 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
558 Process a wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
559 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
560 Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
561 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
562 Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
567 @appearance{dataviewctrl.png}
569 class wxDataViewCtrl
: public wxControl
578 Constructor. Calls Create().
580 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
581 const wxPoint
& pos
= wxDefaultPosition
,
582 const wxSize
& size
= wxDefaultSize
,
584 const wxValidator
& validator
= wxDefaultValidator
);
589 virtual ~wxDataViewCtrl();
592 Appends a wxDataViewColumn to the control. Returns @true on success.
594 Note that there is a number of short cut methods which implicitly create
595 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
597 virtual bool AppendColumn(wxDataViewColumn
* col
);
600 Prepends a wxDataViewColumn to the control. Returns @true on success.
602 Note that there is a number of short cut methods which implicitly create
603 a wxDataViewColumn and a wxDataViewRenderer for it.
605 virtual bool PrependColumn(wxDataViewColumn
* col
);
608 Inserts a wxDataViewColumn to the control. Returns @true on success.
610 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
614 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
615 created in the function or @NULL on failure.
617 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
618 unsigned int model_column
,
619 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
621 wxAlignment align
= wxALIGN_CENTER
,
622 int flags
= wxDATAVIEW_COL_RESIZABLE
);
623 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
624 unsigned int model_column
,
625 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
627 wxAlignment align
= wxALIGN_CENTER
,
628 int flags
= wxDATAVIEW_COL_RESIZABLE
);
633 Appends a column for rendering a date. Returns the wxDataViewColumn
634 created in the function or @NULL on failure.
636 @note The @a align parameter is applied to both the column header and
639 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
640 unsigned int model_column
,
641 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
643 wxAlignment align
= wxALIGN_NOT
,
644 int flags
= wxDATAVIEW_COL_RESIZABLE
);
645 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
646 unsigned int model_column
,
647 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
649 wxAlignment align
= wxALIGN_NOT
,
650 int flags
= wxDATAVIEW_COL_RESIZABLE
);
655 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
656 created in the function or @NULL on failure.
657 This method uses the wxDataViewIconTextRenderer class.
659 @note The @a align parameter is applied to both the column header and
662 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
663 unsigned int model_column
,
664 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
666 wxAlignment align
= wxALIGN_NOT
,
667 int flags
= wxDATAVIEW_COL_RESIZABLE
);
668 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
669 unsigned int model_column
,
670 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
672 wxAlignment align
= wxALIGN_NOT
,
673 int flags
= wxDATAVIEW_COL_RESIZABLE
);
678 Appends a column for rendering a progress indicator. Returns the
679 wxDataViewColumn created in the function or @NULL on failure.
681 @note The @a align parameter is applied to both the column header and
684 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
685 unsigned int model_column
,
686 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
688 wxAlignment align
= wxALIGN_CENTER
,
689 int flags
= wxDATAVIEW_COL_RESIZABLE
);
690 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
691 unsigned int model_column
,
692 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
694 wxAlignment align
= wxALIGN_CENTER
,
695 int flags
= wxDATAVIEW_COL_RESIZABLE
);
700 Appends a column for rendering text. Returns the wxDataViewColumn
701 created in the function or @NULL on failure.
703 @note The @a align parameter is applied to both the column header and
706 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
707 unsigned int model_column
,
708 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
710 wxAlignment align
= wxALIGN_NOT
,
711 int flags
= wxDATAVIEW_COL_RESIZABLE
);
712 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
713 unsigned int model_column
,
714 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
716 wxAlignment align
= wxALIGN_NOT
,
717 int flags
= wxDATAVIEW_COL_RESIZABLE
);
722 Appends a column for rendering a toggle. Returns the wxDataViewColumn
723 created in the function or @NULL on failure.
725 @note The @a align parameter is applied to both the column header and
728 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
729 unsigned int model_column
,
730 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
732 wxAlignment align
= wxALIGN_CENTER
,
733 int flags
= wxDATAVIEW_COL_RESIZABLE
);
734 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
735 unsigned int model_column
,
736 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
738 wxAlignment align
= wxALIGN_CENTER
,
739 int flags
= wxDATAVIEW_COL_RESIZABLE
);
743 Associates a wxDataViewModel with the control.
744 This increases the reference count of the model by 1.
746 virtual bool AssociateModel(wxDataViewModel
* model
);
751 virtual bool ClearColumns();
756 virtual void Collapse(const wxDataViewItem
& item
);
759 Create the control. Useful for two step creation.
761 bool Create(wxWindow
* parent
, wxWindowID id
,
762 const wxPoint
& pos
= wxDefaultPosition
,
763 const wxSize
& size
= wxDefaultSize
,
765 const wxValidator
& validator
= wxDefaultValidator
);
768 Deletes given column.
770 virtual bool DeleteColumn(wxDataViewColumn
* column
);
773 Enable drag operations using the given @a format.
775 virtual bool EnableDragSource( const wxDataFormat
&format
);
778 Enable drop operations using the given @a format.
780 virtual bool EnableDropTarget( const wxDataFormat
&format
);
783 Call this to ensure that the given item is visible.
785 virtual void EnsureVisible(const wxDataViewItem
& item
,
786 const wxDataViewColumn
* column
= NULL
);
791 virtual void Expand(const wxDataViewItem
& item
);
794 Expands all ancestors of the @a item. This method also
795 ensures that the item itself as well as all ancestor
796 items have been read from the model by the control.
798 virtual void ExpandAncestors( const wxDataViewItem
& item
);
801 Returns pointer to the column. @a pos refers to the position in the
802 control which may change after reordering columns by the user.
804 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
807 Returns the number of columns.
809 virtual unsigned int GetColumnCount() const;
812 Returns the position of the column or -1 if not found in the control.
814 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
817 Returns column containing the expanders.
819 wxDataViewColumn
* GetExpanderColumn() const;
824 int GetIndent() const;
829 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
830 const wxDataViewColumn
* col
= NULL
) const;
833 Returns pointer to the data model associated with the control (if any).
835 wxDataViewModel
* GetModel();
838 Returns first selected item or an invalid item if none is selected.
840 virtual wxDataViewItem
GetSelection() const;
843 Fills @a sel with currently selected items and returns their number.
845 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
848 Returns the wxDataViewColumn currently responsible for sorting
849 or @NULL if none has been selected.
851 virtual wxDataViewColumn
* GetSortingColumn() const;
856 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
857 wxDataViewColumn
*& col
) const;
860 Return @true if the item is expanded.
862 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
865 Return @true if the item is selected.
867 virtual bool IsSelected(const wxDataViewItem
& item
) const;
870 Select the given item.
872 virtual void Select(const wxDataViewItem
& item
);
877 virtual void SelectAll();
880 Set which column shall contain the tree-like expanders.
882 void SetExpanderColumn(wxDataViewColumn
* col
);
885 Sets the indendation.
887 void SetIndent(int indent
);
890 Sets the selection to the array of wxDataViewItems.
892 virtual void SetSelections(const wxDataViewItemArray
& sel
);
895 Unselect the given item.
897 virtual void Unselect(const wxDataViewItem
& item
);
901 This method only has effect if multiple selections are allowed.
903 virtual void UnselectAll();
909 @class wxDataViewModelNotifier
911 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
912 its notification interface.
913 See the documentation of that class for further information.
918 class wxDataViewModelNotifier
924 wxDataViewModelNotifier();
929 virtual ~wxDataViewModelNotifier();
932 Called by owning model.
934 virtual bool Cleared() = 0;
937 Get owning wxDataViewModel.
939 wxDataViewModel
* GetOwner() const;
942 Called by owning model.
944 virtual bool ItemAdded(const wxDataViewItem
& parent
,
945 const wxDataViewItem
& item
) = 0;
948 Called by owning model.
950 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
953 Called by owning model.
955 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
956 const wxDataViewItem
& item
) = 0;
959 Called by owning model.
961 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
962 const wxDataViewItemArray
& items
);
965 Called by owning model.
967 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
970 Called by owning model.
972 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
973 const wxDataViewItemArray
& items
);
976 Called by owning model.
978 virtual void Resort() = 0;
981 Set owner of this notifier. Used internally.
983 void SetOwner(wxDataViewModel
* owner
);
986 Called by owning model.
988 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
993 The mode of a data-view cell; see wxDataViewRenderer for more info.
995 enum wxDataViewCellMode
997 wxDATAVIEW_CELL_INERT
,
1000 Indicates that the user can double click the cell and something will
1001 happen (e.g. a window for editing a date will pop up).
1003 wxDATAVIEW_CELL_ACTIVATABLE
,
1006 Indicates that the user can edit the data in-place, i.e. an control
1007 will show up after a slow click on the cell. This behaviour is best
1008 known from changing the filename in most file managers etc.
1010 wxDATAVIEW_CELL_EDITABLE
1014 The values of this enum controls how a wxDataViewRenderer should display
1015 its contents in a cell.
1017 enum wxDataViewCellRenderState
1019 wxDATAVIEW_CELL_SELECTED
= 1,
1020 wxDATAVIEW_CELL_PRELIT
= 2,
1021 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1022 wxDATAVIEW_CELL_FOCUSED
= 8
1026 @class wxDataViewRenderer
1028 This class is used by wxDataViewCtrl to render the individual cells.
1029 One instance of a renderer class is owned by a wxDataViewColumn.
1030 There is a number of ready-to-use renderers provided:
1031 - wxDataViewTextRenderer,
1032 - wxDataViewTextRendererAttr,
1033 - wxDataViewIconTextRenderer,
1034 - wxDataViewToggleRenderer,
1035 - wxDataViewProgressRenderer,
1036 - wxDataViewBitmapRenderer,
1037 - wxDataViewDateRenderer,
1038 - wxDataViewSpinRenderer.
1040 Additionally, the user can write own renderers by deriving from
1041 wxDataViewCustomRenderer.
1043 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1044 by the constructors respectively controls what actions the cell data allows
1045 and how the renderer should display its contents in a cell.
1050 class wxDataViewRenderer
: public wxObject
1056 wxDataViewRenderer(const wxString
& varianttype
,
1057 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1058 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1061 Returns the alignment. See SetAlignment()
1063 virtual int GetAlignment() const;
1066 Returns the cell mode.
1068 virtual wxDataViewCellMode
GetMode() const;
1071 Returns pointer to the owning wxDataViewColumn.
1073 wxDataViewColumn
* GetOwner() const;
1076 This methods retrieves the value from the renderer in order to
1077 transfer the value back to the data model.
1079 Returns @false on failure.
1081 virtual bool GetValue(wxVariant
& value
) const = 0;
1084 Returns a string with the type of the wxVariant supported by this renderer.
1086 wxString
GetVariantType() const;
1089 Sets the alignment of the renderer's content.
1090 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1091 should have the same alignment as the column header.
1093 The method is not implemented under OS X and the renderer always aligns
1094 its contents as the column header on that platform. The other platforms
1095 support both vertical and horizontal alignment.
1097 virtual void SetAlignment( int align
);
1099 Sets the owning wxDataViewColumn.
1100 This is usually called from within wxDataViewColumn.
1102 void SetOwner(wxDataViewColumn
* owner
);
1105 Set the value of the renderer (and thus its cell) to @a value.
1106 The internal code will then render this cell with this data.
1108 virtual bool SetValue(const wxVariant
& value
) = 0;
1111 Before data is committed to the data model, it is passed to this
1112 method where it can be checked for validity. This can also be
1113 used for checking a valid range or limiting the user input in
1114 a certain aspect (e.g. max number of characters or only alphanumeric
1115 input, ASCII only etc.). Return @false if the value is not valid.
1117 Please note that due to implementation limitations, this validation
1118 is done after the editing control already is destroyed and the
1119 editing process finished.
1121 virtual bool Validate(wxVariant
& value
);
1127 @class wxDataViewTextRenderer
1129 wxDataViewTextRenderer is used for rendering text.
1130 It supports in-place editing if desired.
1135 class wxDataViewTextRenderer
: public wxDataViewRenderer
1141 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1142 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1143 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1149 @class wxDataViewIconTextRenderer
1151 The wxDataViewIconTextRenderer class is used to display text with
1152 a small icon next to it as it is typically done in a file manager.
1154 This classes uses the wxDataViewIconText helper class to store its data.
1155 wxDataViewIonText can be converted to and from a wxVariant using the left shift
1161 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1167 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1168 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1169 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1175 @class wxDataViewProgressRenderer
1177 This class is used by wxDataViewCtrl to render progress bars.
1182 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1188 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1189 const wxString
& varianttype
= "long",
1190 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1191 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1197 @class wxDataViewSpinRenderer
1199 This is a specialized renderer for rendering integer values.
1200 It supports modifying the values in-place by using a wxSpinCtrl.
1201 The renderer only support variants of type @e long.
1206 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1211 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1213 wxDataViewSpinRenderer(int min
, int max
,
1214 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1215 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1221 @class wxDataViewToggleRenderer
1223 This class is used by wxDataViewCtrl to render toggle controls.
1228 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1234 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1235 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1236 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1242 @class wxDataViewDateRenderer
1244 This class is used by wxDataViewCtrl to render calendar controls.
1249 class wxDataViewDateRenderer
: public wxDataViewRenderer
1255 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1256 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1257 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1263 @class wxDataViewTextRendererAttr
1265 The same as wxDataViewTextRenderer but with support for font attributes.
1266 Font attributes are currently only supported under GTK+ and MSW.
1268 @see wxDataViewModel::GetAttr and wxDataViewItemAttr.
1273 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1279 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1280 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1281 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1287 @class wxDataViewCustomRenderer
1289 You need to derive a new class from wxDataViewCustomRenderer in
1290 order to write a new renderer.
1292 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1293 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1295 If you want your renderer to support in-place editing then you also need to override
1296 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1297 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1299 Note that a special event handler will be pushed onto that editor control
1300 which handles @e \<ENTER\> and focus out events in order to end the editing.
1305 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1311 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1312 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1313 int align
= -1, bool no_init
= false);
1318 virtual ~wxDataViewCustomRenderer();
1321 Override this to react to double clicks or ENTER.
1322 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1324 virtual bool Activate( wxRect cell
,
1325 wxDataViewModel
* model
,
1326 const wxDataViewItem
& item
,
1330 Override this to create the actual editor control once editing
1333 @a parent is the parent of the editor control, @a labelRect indicates the
1334 position and size of the editor control and @a value is its initial value:
1338 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1339 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1343 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1345 const wxVariant
& value
);
1348 Create DC on request. Internal.
1350 virtual wxDC
* GetDC();
1353 Return size required to show content.
1355 virtual wxSize
GetSize() const = 0;
1358 Overrride this so that the renderer can get the value from the editor
1359 control (pointed to by @a editor):
1362 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1363 long l = sc->GetValue();
1369 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1373 Override this and make it return @true in order to
1374 indicate that this renderer supports in-place editing.
1376 virtual bool HasEditorCtrl();
1379 Overrride this to react to a left click.
1380 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1382 virtual bool LeftClick( wxPoint cursor
,
1384 wxDataViewModel
* model
,
1385 const wxDataViewItem
& item
,
1389 Override this to render the cell.
1390 Before this is called, wxDataViewRenderer::SetValue was called
1391 so that this instance knows what to render.
1393 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1396 This method should be called from within Render() whenever you need to
1398 This will ensure that the correct colour, font and vertical alignment will
1399 be chosen so the text will look the same as text drawn by native renderers.
1401 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1402 wxDC
* dc
, int state
);
1405 Overrride this to start a drag operation. Not yet supported.
1407 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1408 wxDataViewModel
* model
,
1409 const wxDataViewItem
& item
,
1416 @class wxDataViewBitmapRenderer
1418 This class is used by wxDataViewCtrl to render bitmap controls.
1423 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1429 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1430 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1431 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1436 The flags used by wxDataViewColumn.
1437 Can be combined together.
1439 enum wxDataViewColumnFlags
1441 wxDATAVIEW_COL_RESIZABLE
= 1,
1442 wxDATAVIEW_COL_SORTABLE
= 2,
1443 wxDATAVIEW_COL_REORDERABLE
= 4,
1444 wxDATAVIEW_COL_HIDDEN
= 8
1448 @class wxDataViewColumn
1450 This class represents a column in a wxDataViewCtrl.
1451 One wxDataViewColumn is bound to one column in the data model to which the
1452 wxDataViewCtrl has been associated.
1454 An instance of wxDataViewRenderer is used by this class to render its data.
1459 class wxDataViewColumn
: public wxHeaderColumn
1463 Constructs a text column.
1466 The title of the column.
1468 The class which will render the contents of this column.
1470 The index of the model's column which is associated with this object.
1472 The width of the column.
1473 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1475 The alignment of the column title.
1477 One or more flags of the ::wxDataViewColumnFlags enumeration.
1479 wxDataViewColumn(const wxString
& title
,
1480 wxDataViewRenderer
* renderer
,
1481 unsigned int model_column
,
1482 int width
= wxDVC_DEFAULT_WIDTH
,
1483 wxAlignment align
= wxALIGN_CENTER
,
1484 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1487 Constructs a bitmap column.
1490 The bitmap of the column.
1492 The class which will render the contents of this column.
1494 The index of the model's column which is associated with this object.
1496 The width of the column.
1497 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1499 The alignment of the column title.
1501 One or more flags of the ::wxDataViewColumnFlags enumeration.
1503 wxDataViewColumn(const wxBitmap
& bitmap
,
1504 wxDataViewRenderer
* renderer
,
1505 unsigned int model_column
,
1506 int width
= wxDVC_DEFAULT_WIDTH
,
1507 wxAlignment align
= wxALIGN_CENTER
,
1508 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1511 Returns the index of the column of the model, which this
1512 wxDataViewColumn is displaying.
1514 unsigned int GetModelColumn() const;
1517 Returns the owning wxDataViewCtrl.
1519 wxDataViewCtrl
* GetOwner() const;
1522 Returns the renderer of this wxDataViewColumn.
1524 @see wxDataViewRenderer.
1526 wxDataViewRenderer
* GetRenderer() const;
1532 @class wxDataViewListCtrl
1534 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1535 and forwards most of its API to that class.
1537 The purpose of this class is to offer a simple way to display and
1538 edit a small table of data without having to write your own wxDataViewModel.
1541 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, -1 );
1543 listctrl->AppendToggleColumn( "Toggle" );
1544 listctrl->AppendTextColumn( "Text" );
1546 wxVector<wxVariant> data;
1547 data.push_back( true );
1548 data.push_back( "row 1" );
1549 listctrl->AppendItem( data );
1552 data.push_back( false );
1553 data.push_back( "row 3" );
1554 listctrl->AppendItem( data );
1561 class wxDataViewListCtrl
: public wxDataViewCtrl
1567 wxDataViewListCtrl();
1570 Constructor. Calls Create().
1572 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1573 const wxPoint
& pos
= wxDefaultPosition
,
1574 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1575 const wxValidator
& validator
= wxDefaultValidator
);
1578 Destructor. Deletes the image list if any.
1580 ~wxDataViewListCtrl();
1583 Creates the control and a wxDataViewListStore as its internal model.
1585 bool Create( wxWindow
*parent
, wxWindowID id
,
1586 const wxPoint
& pos
= wxDefaultPosition
,
1587 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1588 const wxValidator
& validator
= wxDefaultValidator
);
1594 wxDataViewListStore
*GetStore();
1595 const wxDataViewListStore
*GetStore() const;
1599 Appends a column to the control and additonally appends a
1600 column to the store with the type @a varianttype.
1602 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1605 Prepends a column to the control and additonally prepends a
1606 column to the store with the type @a varianttype.
1608 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1611 Inserts a column to the control and additonally inserts a
1612 column to the store with the type @a varianttype.
1614 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1617 Overridden from wxDataViewCtrl
1619 Appends a column to the control and additonally appends a
1620 column to the store with the type string.
1622 virtual void AppendColumn( wxDataViewColumn
*column
);
1625 Overridden from wxDataViewCtrl
1627 Prepends a column to the control and additonally prepends a
1628 column to the store with the type string.
1630 virtual void PrependColumn( wxDataViewColumn
*column
);
1633 Overridden from wxDataViewCtrl
1635 Inserts a column to the control and additonally inserts a
1636 column to the store with the type string.
1638 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
1641 Inserts a text column to the control and the store.
1643 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1644 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1645 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1648 Inserts a toggle column to the control and the store.
1650 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1651 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1652 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1655 Inserts a progress column to the control and the store.
1657 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1658 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1659 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1662 Inserts a icon and text column to the control and the store.
1664 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1665 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1666 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1669 Appends an item (=row) to the control and store.
1671 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1674 Prepends an item (=row) to the control and store.
1676 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1679 Inserts an item (=row) to the control and store.
1681 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1684 Delete the row at position @a row.
1686 void DeleteItem( unsigned row
);
1689 Delete all items (= all rows).
1691 void DeleteAllItems();
1694 Sets the value in the store and update the control.
1696 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
1699 Returns the value from the store.
1701 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
1704 Sets the value in the store and update the control.
1706 This method assumes that the a string is stored in respective
1709 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
1712 Returns the value from the store.
1714 This method assumes that the a string is stored in respective
1717 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
1720 Sets the value in the store and update the control.
1722 This method assumes that the a boolean value is stored in
1725 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
1728 Returns the value from the store.
1730 This method assumes that the a boolean value is stored in
1733 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
1738 @class wxDataViewTreeCtrl
1740 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1741 and forwards most of its API to that class.
1742 Additionally, it uses a wxImageList to store a list of icons.
1744 The main purpose of this class is to look like a wxTreeCtrl to make a transition
1745 from it to the wxDataViewCtrl class simpler.
1749 @appearance{dataviewtreectrl.png}
1751 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1757 wxDataViewTreeCtrl();
1760 Constructor. Calls Create().
1762 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1763 const wxPoint
& pos
= wxDefaultPosition
,
1764 const wxSize
& size
= wxDefaultSize
,
1765 long style
= wxDV_NO_HEADER
,
1766 const wxValidator
& validator
= wxDefaultValidator
);
1769 Destructor. Deletes the image list if any.
1771 virtual ~wxDataViewTreeCtrl();
1774 Appends a container to the given @a parent.
1776 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1777 const wxString
& text
,
1780 wxClientData
* data
= NULL
);
1783 Appends an item to the given @a parent.
1785 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1786 const wxString
& text
,
1788 wxClientData
* data
= NULL
);
1791 Creates the control and a wxDataViewTreeStore as its internal model.
1793 bool Create(wxWindow
* parent
, wxWindowID id
,
1794 const wxPoint
& pos
= wxDefaultPosition
,
1795 const wxSize
& size
= wxDefaultSize
,
1796 long style
= wxDV_NO_HEADER
,
1797 const wxValidator
& validator
= wxDefaultValidator
);
1800 Calls the identical method from wxDataViewTreeStore.
1802 void DeleteAllItems();
1805 Calls the identical method from wxDataViewTreeStore.
1807 void DeleteChildren(const wxDataViewItem
& item
);
1810 Calls the identical method from wxDataViewTreeStore.
1812 void DeleteItem(const wxDataViewItem
& item
);
1815 Calls the identical method from wxDataViewTreeStore.
1817 int GetChildCount(const wxDataViewItem
& parent
) const;
1820 Returns the image list.
1822 wxImageList
* GetImageList();
1825 Calls the identical method from wxDataViewTreeStore.
1827 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1830 Calls the identical method from wxDataViewTreeStore.
1832 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1835 Calls the identical method from wxDataViewTreeStore.
1837 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
1840 Calls the identical method from wxDataViewTreeStore.
1842 wxString
GetItemText(const wxDataViewItem
& item
) const;
1845 Calls the identical method from wxDataViewTreeStore.
1847 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1848 unsigned int pos
) const;
1854 wxDataViewTreeStore
* GetStore();
1855 const wxDataViewTreeStore
* GetStore() const;
1859 Calls the same method from wxDataViewTreeStore but uses
1860 an index position in the image list instead of a wxIcon.
1862 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1863 const wxDataViewItem
& previous
,
1864 const wxString
& text
,
1867 wxClientData
* data
= NULL
);
1870 Calls the same method from wxDataViewTreeStore but uses
1871 an index position in the image list instead of a wxIcon.
1873 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1874 const wxDataViewItem
& previous
,
1875 const wxString
& text
,
1877 wxClientData
* data
= NULL
);
1880 Calls the same method from wxDataViewTreeStore but uses
1881 an index position in the image list instead of a wxIcon.
1883 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1884 const wxString
& text
,
1887 wxClientData
* data
= NULL
);
1890 Calls the same method from wxDataViewTreeStore but uses
1891 an index position in the image list instead of a wxIcon.
1893 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1894 const wxString
& text
,
1896 wxClientData
* data
= NULL
);
1899 Sets the image list.
1901 void SetImageList(wxImageList
* imagelist
);
1904 Calls the identical method from wxDataViewTreeStore.
1906 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1909 Calls the identical method from wxDataViewTreeStore.
1911 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1912 const wxIcon
& icon
);
1915 Calls the identical method from wxDataViewTreeStore.
1917 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1920 Calls the identical method from wxDataViewTreeStore.
1922 void SetItemText(const wxDataViewItem
& item
,
1923 const wxString
& text
);
1928 @class wxDataViewListStore
1930 wxDataViewListStore is a specialised wxDataViewModel for storing
1931 a simple table of data. Since it derives from wxDataViewIndexListModel
1932 its data is be accessed by row (i.e. by index) instead of only
1935 This class actually stores the values (therefore its name)
1936 and implements all virtual methods from the base classes so it can be
1937 used directly without having to derive any class from it, but it is
1938 mostly used from within wxDataViewListCtrl.
1944 class wxDataViewListStore
: public wxDataViewIndexListModel
1950 wxDataViewListStore();
1955 ~wxDataViewListStore();
1958 Prepends a data column.
1960 @a variantype indicates the type of values store in the column.
1962 This does not automatically fill in any (default) values in
1963 rows which exist in the store already.
1965 void PrependColumn( const wxString
&varianttype
);
1968 Inserts a data column before @a pos.
1970 @a variantype indicates the type of values store in the column.
1972 This does not automatically fill in any (default) values in
1973 rows which exist in the store already.
1975 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1978 Appends a data column.
1980 @a variantype indicates the type of values store in the column.
1982 This does not automatically fill in any (default) values in
1983 rows which exist in the store already.
1985 void AppendColumn( const wxString
&varianttype
);
1988 Appends an item (=row) and fills it with @a values.
1990 The values must match the values specifies in the column
1991 in number and type. No (default) values are filled in
1994 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1997 Prepends an item (=row) and fills it with @a values.
1999 The values must match the values specifies in the column
2000 in number and type. No (default) values are filled in
2003 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2006 Inserts an item (=row) and fills it with @a values.
2008 The values must match the values specifies in the column
2009 in number and type. No (default) values are filled in
2012 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2015 Delete the item (=row) at position @a pos.
2017 void DeleteItem( unsigned pos
);
2020 Delete all item (=all rows) in the store.
2022 void DeleteAllItems();
2025 Overriden from wxDataViewModel
2027 virtual unsigned int GetColumnCount() const;
2030 Overriden from wxDataViewModel
2032 virtual wxString
GetColumnType( unsigned int col
) const;
2035 Overriden from wxDataViewIndexListModel
2037 virtual void GetValueByRow( wxVariant
&value
,
2038 unsigned int row
, unsigned int col
) const;
2041 Overriden from wxDataViewIndexListModel
2043 virtual bool SetValueByRow( const wxVariant
&value
,
2044 unsigned int row
, unsigned int col
);
2049 @class wxDataViewTreeStore
2051 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2052 trees very much like wxTreeCtrl does and it offers a similar API.
2054 This class actually stores the entire tree and the values (therefore its name)
2055 and implements all virtual methods from the base class so it can be used directly
2056 without having to derive any class from it, but it is mostly used from within
2062 class wxDataViewTreeStore
: public wxDataViewModel
2066 Constructor. Creates the invisible root node internally.
2068 wxDataViewTreeStore();
2073 virtual ~wxDataViewTreeStore();
2078 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2079 const wxString
& text
,
2080 const wxIcon
& icon
= wxNullIcon
,
2081 const wxIcon
& expanded
= wxNullIcon
,
2082 wxClientData
* data
= NULL
);
2087 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2088 const wxString
& text
,
2089 const wxIcon
& icon
= wxNullIcon
,
2090 wxClientData
* data
= NULL
);
2093 Delete all item in the model.
2095 void DeleteAllItems();
2098 Delete all children of the item, but not the item itself.
2100 void DeleteChildren(const wxDataViewItem
& item
);
2105 void DeleteItem(const wxDataViewItem
& item
);
2108 Return the number of children of item.
2110 int GetChildCount(const wxDataViewItem
& parent
) const;
2113 Returns the client data asoociated with the item.
2115 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2118 Returns the icon to display in expanded containers.
2120 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2123 Returns the icon of the item.
2125 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2128 Returns the text of the item.
2130 wxString
GetItemText(const wxDataViewItem
& item
) const;
2133 Returns the nth child item of item.
2135 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2136 unsigned int pos
) const;
2139 Inserts a container after @a previous.
2141 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2142 const wxDataViewItem
& previous
,
2143 const wxString
& text
,
2144 const wxIcon
& icon
= wxNullIcon
,
2145 const wxIcon
& expanded
= wxNullIcon
,
2146 wxClientData
* data
= NULL
);
2149 Inserts an item after @a previous.
2151 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2152 const wxDataViewItem
& previous
,
2153 const wxString
& text
,
2154 const wxIcon
& icon
= wxNullIcon
,
2155 wxClientData
* data
= NULL
);
2158 Inserts a container before the first child item or @a parent.
2160 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2161 const wxString
& text
,
2162 const wxIcon
& icon
= wxNullIcon
,
2163 const wxIcon
& expanded
= wxNullIcon
,
2164 wxClientData
* data
= NULL
);
2167 Inserts an item before the first child item or @a parent.
2169 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2170 const wxString
& text
,
2171 const wxIcon
& icon
= wxNullIcon
,
2172 wxClientData
* data
= NULL
);
2175 Sets the client data associated with the item.
2177 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2180 Sets the expanded icon for the item.
2182 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2183 const wxIcon
& icon
);
2186 Sets the icon for the item.
2188 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2193 @class wxDataViewIconText
2195 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2196 This class can be converted to and from a wxVariant.
2201 class wxDataViewIconText
: public wxObject
2208 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2209 const wxIcon
& icon
= wxNullIcon
);
2210 wxDataViewIconText(const wxDataViewIconText
& other
);
2216 const wxIcon
& GetIcon() const;
2221 wxString
GetText() const;
2226 void SetIcon(const wxIcon
& icon
);
2231 void SetText(const wxString
& text
);
2237 @class wxDataViewEvent
2239 This is the event class for the wxDataViewCtrl notifications.
2242 @category{events,dvc}
2244 class wxDataViewEvent
: public wxNotifyEvent
2248 Constructor. Typically used by wxWidgets internals only.
2250 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2254 Returns the position of the column in the control or -1
2255 if no column field was set by the event emitter.
2257 int GetColumn() const;
2260 Returns a pointer to the wxDataViewColumn from which
2261 the event was emitted or @NULL.
2263 wxDataViewColumn
* GetDataViewColumn() const;
2266 Returns the wxDataViewModel associated with the event.
2268 wxDataViewModel
* GetModel() const;
2271 Returns a the position of a context menu event in screen coordinates.
2273 wxPoint
GetPosition() const;
2276 Returns a reference to a value.
2278 const wxVariant
& GetValue() const;
2281 Sets the column index associated with this event.
2283 void SetColumn(int col
);
2286 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2288 void SetDataViewColumn(wxDataViewColumn
* col
);
2291 Sets the dataview model associated with this event.
2293 void SetModel(wxDataViewModel
* model
);
2296 Sets the value associated with this event.
2298 void SetValue(const wxVariant
& value
);
2301 Set wxDataObject for data transfer within a drag operation.
2303 void SetDataObject( wxDataObject
*obj
);
2306 Used internally. Gets associated wxDataObject for data transfer
2307 within a drag operation.
2309 wxDataObject
*GetDataObject() const;
2312 Used internally. Sets the wxDataFormat during a drop operation.
2314 void SetDataFormat( const wxDataFormat
&format
);
2317 Gets the wxDataFormat during a drop operation.
2319 wxDataFormat
GetDataFormat() const;
2322 Used internally. Sets the data size for a drop data transfer.
2324 void SetDataSize( size_t size
);
2327 Gets the data size for a drop data transfer.
2329 size_t GetDataSize() const;
2332 Used internally. Sets the data buffer for a drop data transfer.
2334 void SetDataBuffer( void* buf
);
2337 Gets the data buffer for a drop data transfer.
2339 void *GetDataBuffer() const;