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 committed.
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 wxRefCounter
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 wxRefCounter
90 Adds a wxDataViewModelNotifier to the model.
92 void AddNotifier(wxDataViewModelNotifier
* notifier
);
95 Change the value of the given item and update the control to reflect
98 This function simply calls SetValue() and, if it succeeded,
106 The item (row) to update.
108 The column to update.
110 @true if both SetValue() and ValueChanged() returned @true.
112 bool ChangeValue(const wxVariant
& variant
,
113 const wxDataViewItem
& item
,
117 Called to inform the model that all data has been cleared.
118 The control will reread the data from the model again.
120 virtual bool Cleared();
123 The compare function to be used by control. The default compare function
124 sorts by container and other items separately and in ascending order.
125 Override this for a different sorting behaviour.
127 @see HasDefaultCompare().
129 virtual int Compare(const wxDataViewItem
& item1
,
130 const wxDataViewItem
& item2
,
132 bool ascending
) const;
135 Override this to indicate that the item has special font attributes.
136 This only affects the wxDataViewTextRendererText renderer.
138 @see wxDataViewItemAttr.
140 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
141 wxDataViewItemAttr
& attr
);
144 Override this so the control can query the child items of an item.
145 Returns the number of items.
147 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
148 wxDataViewItemArray
& children
) const = 0;
151 Override this to indicate the number of columns in the model.
153 virtual unsigned int GetColumnCount() const = 0;
156 Override this to indicate what type of data is stored in the
157 column specified by @a col.
159 This should return a string indicating the type of data as reported by wxVariant.
161 virtual wxString
GetColumnType(unsigned int col
) const = 0;
164 Override this to indicate which wxDataViewItem representing the parent
165 of @a item or an invalid wxDataViewItem if the the root item is
168 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
171 Override this to indicate the value of @a item.
172 A wxVariant is used to store the data.
174 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
175 unsigned int col
) const = 0;
178 Override this method to indicate if a container item merely acts as a
179 headline (or for categorisation) or if it also acts a normal item with
180 entries for futher columns. By default returns @false.
182 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
185 Override this to indicate that the model provides a default compare
186 function that the control should use if no wxDataViewColumn has been
187 chosen for sorting. Usually, the user clicks on a column header for
188 sorting, the data will be sorted alphanumerically.
190 If any other order (e.g. by index or order of appearance) is required,
191 then this should be used.
192 See wxDataViewIndexListModel for a model which makes use of this.
194 virtual bool HasDefaultCompare() const;
197 Override this to indicate of @a item is a container, i.e. if
198 it can have child items.
200 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
203 Call this to inform the model that an item has been added to the data.
205 virtual bool ItemAdded(const wxDataViewItem
& parent
,
206 const wxDataViewItem
& item
);
209 Call this to inform the model that an item has changed.
211 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
212 event (in which the column fields will not be set) to the user.
214 virtual bool ItemChanged(const wxDataViewItem
& item
);
217 Call this to inform the model that an item has been deleted from the data.
219 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
220 const wxDataViewItem
& item
);
223 Call this to inform the model that several items have been added to the data.
225 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
226 const wxDataViewItemArray
& items
);
229 Call this to inform the model that several items have changed.
231 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
232 events (in which the column fields will not be set) to the user.
234 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
237 Call this to inform the model that several items have been deleted.
239 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
240 const wxDataViewItemArray
& items
);
243 Remove the @a notifier from the list of notifiers.
245 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
248 Call this to initiate a resort after the sort function has been changed.
250 virtual void Resort();
253 This gets called in order to set a value in the data model.
255 The most common scenario is that the wxDataViewCtrl calls this method
256 after the user changed some data in the view.
258 This is the function you need to override in your derived class but if
259 you want to call it, ChangeValue() is usually more convenient as
260 otherwise you need to manually call ValueChanged() to update the
263 virtual bool SetValue(const wxVariant
& variant
,
264 const wxDataViewItem
& item
,
265 unsigned int col
) = 0;
268 Call this to inform this model that a value in the model has been changed.
269 This is also called from wxDataViewCtrl's internal editing code, e.g. when
270 editing a text field in the control.
272 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
275 virtual bool ValueChanged(const wxDataViewItem
& item
,
281 Destructor. This should not be called directly. Use DecRef() instead.
283 virtual ~wxDataViewModel();
289 @class wxDataViewIndexListModel
291 wxDataViewIndexListModel is a specialized data model which lets you address
292 an item by its position (row) rather than its wxDataViewItem (which you can
293 obtain from this class).
294 This model also provides its own wxDataViewIndexListModel::Compare
295 method which sorts the model's data by the index.
297 This model is not a virtual model since the control stores each wxDataViewItem.
298 Use wxDataViewVirtualListModel if you need to display millions of items or
299 have other reason to use a virtual control.
304 class wxDataViewIndexListModel
: public wxDataViewModel
310 wxDataViewIndexListModel(unsigned int initial_size
= 0);
315 virtual ~wxDataViewIndexListModel();
318 Compare method that sorts the items by their index.
320 int Compare(const wxDataViewItem
& item1
,
321 const wxDataViewItem
& item2
,
322 unsigned int column
, bool ascending
);
325 Override this to indicate that the row has special font attributes.
326 This only affects the wxDataViewTextRendererText() renderer.
328 @see wxDataViewItemAttr.
330 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
331 wxDataViewItemAttr
& attr
);
334 Returns the wxDataViewItem at the given @e row.
336 wxDataViewItem
GetItem(unsigned int row
) const;
339 Returns the position of given @e item.
341 unsigned int GetRow(const wxDataViewItem
& item
) const;
344 Override this to allow getting values from the model.
346 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
347 unsigned int col
) const = 0;
350 Call this after if the data has to be read again from the model.
351 This is useful after major changes when calling the methods below
352 (possibly thousands of times) doesn't make sense.
354 void Reset(unsigned int new_size
);
357 Call this after a row has been appended to the model.
362 Call this after a row has been changed.
364 void RowChanged(unsigned int row
);
367 Call this after a row has been deleted.
369 void RowDeleted(unsigned int row
);
372 Call this after a row has been inserted at the given position.
374 void RowInserted(unsigned int before
);
377 Call this after a row has been prepended to the model.
382 Call this after a value has been changed.
384 void RowValueChanged(unsigned int row
, unsigned int col
);
387 Call this after rows have been deleted.
388 The array will internally get copied and sorted in descending order so
389 that the rows with the highest position will be deleted first.
391 void RowsDeleted(const wxArrayInt
& rows
);
394 Called in order to set a value in the model.
396 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
397 unsigned int col
) = 0;
403 @class wxDataViewVirtualListModel
405 wxDataViewVirtualListModel is a specialized data model which lets you address
406 an item by its position (row) rather than its wxDataViewItem and as such offers
407 the exact same interface as wxDataViewIndexListModel.
408 The important difference is that under platforms other than OS X, using this
409 model will result in a truly virtual control able to handle millions of items
410 as the control doesn't store any item (a feature not supported by the
411 Carbon API under OS X).
413 @see wxDataViewIndexListModel for the API.
418 class wxDataViewVirtualListModel
: public wxDataViewModel
424 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
430 @class wxDataViewItemAttr
432 This class is used to indicate to a wxDataViewCtrl that a certain item
433 (see wxDataViewItem) has extra font attributes for its renderer.
434 For this, it is required to override wxDataViewModel::GetAttr.
436 Attributes are currently only supported by wxDataViewTextRendererText.
441 class wxDataViewItemAttr
447 wxDataViewItemAttr();
450 Call this to indicate that the item shall be displayed in bold text.
452 void SetBold(bool set
);
455 Call this to indicate that the item shall be displayed with that colour.
457 void SetColour(const wxColour
& colour
);
460 Call this to indicate that the item shall be displayed in italic text.
462 void SetItalic(bool set
);
468 @class wxDataViewItem
470 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
471 in a persistent way, i.e. indepent of the position of the item in the control
472 or changes to its contents.
474 It must hold a unique ID of type @e void* in its only field and can be converted
477 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
478 return @false which used in many places in the API of wxDataViewCtrl to
479 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
480 the invisible root. Examples for this are wxDataViewModel::GetParent and
481 wxDataViewModel::GetChildren.
493 wxDataViewItem(void* id
= NULL
);
494 wxDataViewItem(const wxDataViewItem
& item
);
503 Returns @true if the ID is not @NULL.
511 @class wxDataViewCtrl
513 wxDataViewCtrl is a control to display data either in a tree like fashion or
514 in a tabular form or both.
516 If you only need to display a simple tree structure with an API more like the
517 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
518 Likewise, if you only want to display simple table structure you can use
519 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
520 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
522 A wxDataViewItem is used to represent a (visible) item in the control.
524 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
525 virtual functions or by setting it directly. Instead you need to write your own
526 wxDataViewModel and associate it with this control.
527 Then you need to add a number of wxDataViewColumn to this control to define
528 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
529 of a wxDataViewRenderer to render its cells.
531 A number of standard renderers for rendering text, dates, images, toggle,
532 a progress bar etc. are provided. Additionally, the user can write custom
533 renderers deriving from wxDataViewCustomRenderer for displaying anything.
535 All data transfer from the control to the model and the user code is done
536 through wxVariant which can be extended to support more data formats as necessary.
537 Accordingly, all type information uses the strings returned from wxVariant::GetType.
541 Single selection mode. This is the default.
542 @style{wxDV_MULTIPLE}
543 Multiple selection mode.
544 @style{wxDV_ROW_LINES}
545 Use alternating colours for rows if supported by platform and theme.
546 @style{wxDV_HORIZ_RULES}
547 Display fine rules between row if supported.
548 @style{wxDV_VERT_RULES}
549 Display fine rules between columns is supported.
550 @style{wxDV_VARIABLE_LINE_HEIGHT}
551 Allow variable line heights.
552 This can be inefficient when displaying large number of items.
555 @beginEventEmissionTable{wxDataViewEvent}
556 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
557 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
558 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
559 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
560 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
561 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This
562 event can be vetoed in order to prevent editing on an item by item
563 basis. Still experimental.
564 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
565 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
566 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
567 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
568 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
569 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
570 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
571 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
572 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
573 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
574 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
575 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
576 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
577 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
578 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
579 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
580 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
581 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
582 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
583 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
584 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
585 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
586 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
587 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
588 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
589 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
590 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
591 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
592 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
593 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
598 @appearance{dataviewctrl.png}
600 class wxDataViewCtrl
: public wxControl
609 Constructor. Calls Create().
611 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
612 const wxPoint
& pos
= wxDefaultPosition
,
613 const wxSize
& size
= wxDefaultSize
,
615 const wxValidator
& validator
= wxDefaultValidator
);
620 virtual ~wxDataViewCtrl();
623 Appends a wxDataViewColumn to the control. Returns @true on success.
625 Note that there is a number of short cut methods which implicitly create
626 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
628 virtual bool AppendColumn(wxDataViewColumn
* col
);
631 Prepends a wxDataViewColumn to the control. Returns @true on success.
633 Note that there is a number of short cut methods which implicitly create
634 a wxDataViewColumn and a wxDataViewRenderer for it.
636 virtual bool PrependColumn(wxDataViewColumn
* col
);
639 Inserts a wxDataViewColumn to the control. Returns @true on success.
641 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
645 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
646 created in the function or @NULL on failure.
648 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
649 unsigned int model_column
,
650 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
652 wxAlignment align
= wxALIGN_CENTER
,
653 int flags
= wxDATAVIEW_COL_RESIZABLE
);
654 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
655 unsigned int model_column
,
656 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
658 wxAlignment align
= wxALIGN_CENTER
,
659 int flags
= wxDATAVIEW_COL_RESIZABLE
);
664 Appends a column for rendering a date. Returns the wxDataViewColumn
665 created in the function or @NULL on failure.
667 @note The @a align parameter is applied to both the column header and
670 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
671 unsigned int model_column
,
672 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
674 wxAlignment align
= wxALIGN_NOT
,
675 int flags
= wxDATAVIEW_COL_RESIZABLE
);
676 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
677 unsigned int model_column
,
678 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
680 wxAlignment align
= wxALIGN_NOT
,
681 int flags
= wxDATAVIEW_COL_RESIZABLE
);
686 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
687 created in the function or @NULL on failure.
688 This method uses the wxDataViewIconTextRenderer class.
690 @note The @a align parameter is applied to both the column header and
693 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
694 unsigned int model_column
,
695 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
697 wxAlignment align
= wxALIGN_NOT
,
698 int flags
= wxDATAVIEW_COL_RESIZABLE
);
699 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
700 unsigned int model_column
,
701 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
703 wxAlignment align
= wxALIGN_NOT
,
704 int flags
= wxDATAVIEW_COL_RESIZABLE
);
709 Appends a column for rendering a progress indicator. Returns the
710 wxDataViewColumn created in the function or @NULL on failure.
712 @note The @a align parameter is applied to both the column header and
715 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
716 unsigned int model_column
,
717 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
719 wxAlignment align
= wxALIGN_CENTER
,
720 int flags
= wxDATAVIEW_COL_RESIZABLE
);
721 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
722 unsigned int model_column
,
723 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
725 wxAlignment align
= wxALIGN_CENTER
,
726 int flags
= wxDATAVIEW_COL_RESIZABLE
);
731 Appends a column for rendering text. Returns the wxDataViewColumn
732 created in the function or @NULL on failure.
734 @note The @a align parameter is applied to both the column header and
737 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
738 unsigned int model_column
,
739 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
741 wxAlignment align
= wxALIGN_NOT
,
742 int flags
= wxDATAVIEW_COL_RESIZABLE
);
743 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
744 unsigned int model_column
,
745 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
747 wxAlignment align
= wxALIGN_NOT
,
748 int flags
= wxDATAVIEW_COL_RESIZABLE
);
753 Appends a column for rendering a toggle. Returns the wxDataViewColumn
754 created in the function or @NULL on failure.
756 @note The @a align parameter is applied to both the column header and
759 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
760 unsigned int model_column
,
761 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
763 wxAlignment align
= wxALIGN_CENTER
,
764 int flags
= wxDATAVIEW_COL_RESIZABLE
);
765 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
766 unsigned int model_column
,
767 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
769 wxAlignment align
= wxALIGN_CENTER
,
770 int flags
= wxDATAVIEW_COL_RESIZABLE
);
774 Associates a wxDataViewModel with the control.
775 This increases the reference count of the model by 1.
777 virtual bool AssociateModel(wxDataViewModel
* model
);
782 virtual bool ClearColumns();
787 virtual void Collapse(const wxDataViewItem
& item
);
790 Create the control. Useful for two step creation.
792 bool Create(wxWindow
* parent
, wxWindowID id
,
793 const wxPoint
& pos
= wxDefaultPosition
,
794 const wxSize
& size
= wxDefaultSize
,
796 const wxValidator
& validator
= wxDefaultValidator
);
799 Deletes given column.
801 virtual bool DeleteColumn(wxDataViewColumn
* column
);
804 Enable drag operations using the given @a format.
806 virtual bool EnableDragSource( const wxDataFormat
&format
);
809 Enable drop operations using the given @a format.
811 virtual bool EnableDropTarget( const wxDataFormat
&format
);
814 Call this to ensure that the given item is visible.
816 virtual void EnsureVisible(const wxDataViewItem
& item
,
817 const wxDataViewColumn
* column
= NULL
);
822 virtual void Expand(const wxDataViewItem
& item
);
825 Expands all ancestors of the @a item. This method also
826 ensures that the item itself as well as all ancestor
827 items have been read from the model by the control.
829 virtual void ExpandAncestors( const wxDataViewItem
& item
);
832 Returns pointer to the column. @a pos refers to the position in the
833 control which may change after reordering columns by the user.
835 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
838 Returns the number of columns.
840 virtual unsigned int GetColumnCount() const;
843 Returns the position of the column or -1 if not found in the control.
845 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
848 Returns column containing the expanders.
850 wxDataViewColumn
* GetExpanderColumn() const;
855 int GetIndent() const;
860 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
861 const wxDataViewColumn
* col
= NULL
) const;
864 Returns pointer to the data model associated with the control (if any).
866 wxDataViewModel
* GetModel();
869 Returns first selected item or an invalid item if none is selected.
871 virtual wxDataViewItem
GetSelection() const;
874 Fills @a sel with currently selected items and returns their number.
876 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
879 Returns the wxDataViewColumn currently responsible for sorting
880 or @NULL if none has been selected.
882 virtual wxDataViewColumn
* GetSortingColumn() const;
887 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
888 wxDataViewColumn
*& col
) const;
891 Return @true if the item is expanded.
893 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
896 Return @true if the item is selected.
898 virtual bool IsSelected(const wxDataViewItem
& item
) const;
901 Select the given item.
903 virtual void Select(const wxDataViewItem
& item
);
908 virtual void SelectAll();
911 Set which column shall contain the tree-like expanders.
913 void SetExpanderColumn(wxDataViewColumn
* col
);
916 Sets the indendation.
918 void SetIndent(int indent
);
921 Sets the selection to the array of wxDataViewItems.
923 virtual void SetSelections(const wxDataViewItemArray
& sel
);
926 Unselect the given item.
928 virtual void Unselect(const wxDataViewItem
& item
);
932 This method only has effect if multiple selections are allowed.
934 virtual void UnselectAll();
940 @class wxDataViewModelNotifier
942 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
943 its notification interface.
944 See the documentation of that class for further information.
949 class wxDataViewModelNotifier
955 wxDataViewModelNotifier();
960 virtual ~wxDataViewModelNotifier();
963 Called by owning model.
965 virtual bool Cleared() = 0;
968 Get owning wxDataViewModel.
970 wxDataViewModel
* GetOwner() const;
973 Called by owning model.
975 virtual bool ItemAdded(const wxDataViewItem
& parent
,
976 const wxDataViewItem
& item
) = 0;
979 Called by owning model.
981 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
984 Called by owning model.
986 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
987 const wxDataViewItem
& item
) = 0;
990 Called by owning model.
992 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
993 const wxDataViewItemArray
& items
);
996 Called by owning model.
998 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
1001 Called by owning model.
1003 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
1004 const wxDataViewItemArray
& items
);
1007 Called by owning model.
1009 virtual void Resort() = 0;
1012 Set owner of this notifier. Used internally.
1014 void SetOwner(wxDataViewModel
* owner
);
1017 Called by owning model.
1019 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
1024 The mode of a data-view cell; see wxDataViewRenderer for more info.
1026 enum wxDataViewCellMode
1028 wxDATAVIEW_CELL_INERT
,
1031 Indicates that the user can double click the cell and something will
1032 happen (e.g. a window for editing a date will pop up).
1034 wxDATAVIEW_CELL_ACTIVATABLE
,
1037 Indicates that the user can edit the data in-place, i.e. an control
1038 will show up after a slow click on the cell. This behaviour is best
1039 known from changing the filename in most file managers etc.
1041 wxDATAVIEW_CELL_EDITABLE
1045 The values of this enum controls how a wxDataViewRenderer should display
1046 its contents in a cell.
1048 enum wxDataViewCellRenderState
1050 wxDATAVIEW_CELL_SELECTED
= 1,
1051 wxDATAVIEW_CELL_PRELIT
= 2,
1052 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1053 wxDATAVIEW_CELL_FOCUSED
= 8
1057 @class wxDataViewRenderer
1059 This class is used by wxDataViewCtrl to render the individual cells.
1060 One instance of a renderer class is owned by a wxDataViewColumn.
1061 There is a number of ready-to-use renderers provided:
1062 - wxDataViewTextRenderer,
1063 - wxDataViewIconTextRenderer,
1064 - wxDataViewToggleRenderer,
1065 - wxDataViewProgressRenderer,
1066 - wxDataViewBitmapRenderer,
1067 - wxDataViewDateRenderer,
1068 - wxDataViewSpinRenderer.
1070 Additionally, the user can write own renderers by deriving from
1071 wxDataViewCustomRenderer.
1073 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1074 by the constructors respectively controls what actions the cell data allows
1075 and how the renderer should display its contents in a cell.
1080 class wxDataViewRenderer
: public wxObject
1086 wxDataViewRenderer(const wxString
& varianttype
,
1087 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1088 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1091 Enable or disable replacing parts of the item text with ellipsis to
1092 make it fit the column width.
1094 This method only makes sense for the renderers working with text, such
1095 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1097 By default wxELLIPSIZE_MIDDLE is used.
1100 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1104 void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
);
1107 Disable replacing parts of the item text with ellipsis.
1109 If ellipsizing is disabled, the string will be truncated if it doesn't
1112 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1116 void DisableEllipsize();
1119 Returns the alignment. See SetAlignment()
1121 virtual int GetAlignment() const;
1124 Returns the ellipsize mode used by the renderer.
1126 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1129 @see EnableEllipsize()
1131 wxEllipsizeMode
GetEllipsizeMode() const;
1134 Returns the cell mode.
1136 virtual wxDataViewCellMode
GetMode() const;
1139 Returns pointer to the owning wxDataViewColumn.
1141 wxDataViewColumn
* GetOwner() const;
1144 This methods retrieves the value from the renderer in order to
1145 transfer the value back to the data model.
1147 Returns @false on failure.
1149 virtual bool GetValue(wxVariant
& value
) const = 0;
1152 Returns a string with the type of the wxVariant supported by this renderer.
1154 wxString
GetVariantType() const;
1157 Sets the alignment of the renderer's content.
1158 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1159 should have the same alignment as the column header.
1161 The method is not implemented under OS X and the renderer always aligns
1162 its contents as the column header on that platform. The other platforms
1163 support both vertical and horizontal alignment.
1165 virtual void SetAlignment( int align
);
1167 Sets the owning wxDataViewColumn.
1168 This is usually called from within wxDataViewColumn.
1170 void SetOwner(wxDataViewColumn
* owner
);
1173 Set the value of the renderer (and thus its cell) to @a value.
1174 The internal code will then render this cell with this data.
1176 virtual bool SetValue(const wxVariant
& value
) = 0;
1179 Before data is committed to the data model, it is passed to this
1180 method where it can be checked for validity. This can also be
1181 used for checking a valid range or limiting the user input in
1182 a certain aspect (e.g. max number of characters or only alphanumeric
1183 input, ASCII only etc.). Return @false if the value is not valid.
1185 Please note that due to implementation limitations, this validation
1186 is done after the editing control already is destroyed and the
1187 editing process finished.
1189 virtual bool Validate(wxVariant
& value
);
1195 @class wxDataViewTextRenderer
1197 wxDataViewTextRenderer is used for rendering text.
1198 It supports in-place editing if desired.
1203 class wxDataViewTextRenderer
: public wxDataViewRenderer
1209 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1210 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1211 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1217 @class wxDataViewIconTextRenderer
1219 The wxDataViewIconTextRenderer class is used to display text with
1220 a small icon next to it as it is typically done in a file manager.
1222 This classes uses the wxDataViewIconText helper class to store its data.
1223 wxDataViewIonText can be converted to and from a wxVariant using the left shift
1229 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1235 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1236 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1237 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1243 @class wxDataViewProgressRenderer
1245 This class is used by wxDataViewCtrl to render progress bars.
1250 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1256 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1257 const wxString
& varianttype
= "long",
1258 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1259 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1265 @class wxDataViewSpinRenderer
1267 This is a specialized renderer for rendering integer values.
1268 It supports modifying the values in-place by using a wxSpinCtrl.
1269 The renderer only support variants of type @e long.
1274 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1279 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1281 wxDataViewSpinRenderer(int min
, int max
,
1282 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1283 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1289 @class wxDataViewToggleRenderer
1291 This class is used by wxDataViewCtrl to render toggle controls.
1296 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1302 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1303 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1304 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1310 @class wxDataViewDateRenderer
1312 This class is used by wxDataViewCtrl to render calendar controls.
1317 class wxDataViewDateRenderer
: public wxDataViewRenderer
1323 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1324 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1325 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1331 @class wxDataViewCustomRenderer
1333 You need to derive a new class from wxDataViewCustomRenderer in
1334 order to write a new renderer.
1336 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1337 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1339 If you want your renderer to support in-place editing then you also need to override
1340 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1341 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1343 Note that a special event handler will be pushed onto that editor control
1344 which handles @e \<ENTER\> and focus out events in order to end the editing.
1349 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1355 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1356 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1357 int align
= -1, bool no_init
= false);
1362 virtual ~wxDataViewCustomRenderer();
1365 Override this to react to double clicks or ENTER.
1366 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1368 virtual bool Activate( wxRect cell
,
1369 wxDataViewModel
* model
,
1370 const wxDataViewItem
& item
,
1374 Override this to create the actual editor control once editing
1377 @a parent is the parent of the editor control, @a labelRect indicates the
1378 position and size of the editor control and @a value is its initial value:
1382 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1383 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1387 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
1389 const wxVariant
& value
);
1392 Create DC on request. Internal.
1394 virtual wxDC
* GetDC();
1397 Return size required to show content.
1399 virtual wxSize
GetSize() const = 0;
1402 Overrride this so that the renderer can get the value from the editor
1403 control (pointed to by @a editor):
1406 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1407 long l = sc->GetValue();
1413 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
1417 Override this and make it return @true in order to
1418 indicate that this renderer supports in-place editing.
1420 virtual bool HasEditorCtrl() const;
1423 Overrride this to react to a left click.
1424 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1426 virtual bool LeftClick( wxPoint cursor
,
1428 wxDataViewModel
* model
,
1429 const wxDataViewItem
& item
,
1433 Override this to render the cell.
1434 Before this is called, wxDataViewRenderer::SetValue was called
1435 so that this instance knows what to render.
1437 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1440 This method should be called from within Render() whenever you need to
1442 This will ensure that the correct colour, font and vertical alignment will
1443 be chosen so the text will look the same as text drawn by native renderers.
1445 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1446 wxDC
* dc
, int state
);
1449 Overrride this to start a drag operation. Not yet supported.
1451 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
1452 wxDataViewModel
* model
,
1453 const wxDataViewItem
& item
,
1460 @class wxDataViewBitmapRenderer
1462 This class is used by wxDataViewCtrl to render bitmap controls.
1467 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1473 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1474 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1475 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1480 The flags used by wxDataViewColumn.
1481 Can be combined together.
1483 enum wxDataViewColumnFlags
1485 wxDATAVIEW_COL_RESIZABLE
= 1,
1486 wxDATAVIEW_COL_SORTABLE
= 2,
1487 wxDATAVIEW_COL_REORDERABLE
= 4,
1488 wxDATAVIEW_COL_HIDDEN
= 8
1492 @class wxDataViewColumn
1494 This class represents a column in a wxDataViewCtrl.
1495 One wxDataViewColumn is bound to one column in the data model to which the
1496 wxDataViewCtrl has been associated.
1498 An instance of wxDataViewRenderer is used by this class to render its data.
1503 class wxDataViewColumn
: public wxSettableHeaderColumn
1507 Constructs a text column.
1510 The title of the column.
1512 The class which will render the contents of this column.
1514 The index of the model's column which is associated with this object.
1516 The width of the column.
1517 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1519 The alignment of the column title.
1521 One or more flags of the ::wxDataViewColumnFlags enumeration.
1523 wxDataViewColumn(const wxString
& title
,
1524 wxDataViewRenderer
* renderer
,
1525 unsigned int model_column
,
1526 int width
= wxDVC_DEFAULT_WIDTH
,
1527 wxAlignment align
= wxALIGN_CENTER
,
1528 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1531 Constructs a bitmap column.
1534 The bitmap of the column.
1536 The class which will render the contents of this column.
1538 The index of the model's column which is associated with this object.
1540 The width of the column.
1541 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1543 The alignment of the column title.
1545 One or more flags of the ::wxDataViewColumnFlags enumeration.
1547 wxDataViewColumn(const wxBitmap
& bitmap
,
1548 wxDataViewRenderer
* renderer
,
1549 unsigned int model_column
,
1550 int width
= wxDVC_DEFAULT_WIDTH
,
1551 wxAlignment align
= wxALIGN_CENTER
,
1552 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1555 Returns the index of the column of the model, which this
1556 wxDataViewColumn is displaying.
1558 unsigned int GetModelColumn() const;
1561 Returns the owning wxDataViewCtrl.
1563 wxDataViewCtrl
* GetOwner() const;
1566 Returns the renderer of this wxDataViewColumn.
1568 @see wxDataViewRenderer.
1570 wxDataViewRenderer
* GetRenderer() const;
1576 @class wxDataViewListCtrl
1578 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1579 and forwards most of its API to that class.
1581 The purpose of this class is to offer a simple way to display and
1582 edit a small table of data without having to write your own wxDataViewModel.
1585 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
1587 listctrl->AppendToggleColumn( "Toggle" );
1588 listctrl->AppendTextColumn( "Text" );
1590 wxVector<wxVariant> data;
1591 data.push_back( wxVariant(true) );
1592 data.push_back( wxVariant("row 1") );
1593 listctrl->AppendItem( data );
1596 data.push_back( wxVariant(false) );
1597 data.push_back( wxVariant("row 3") );
1598 listctrl->AppendItem( data );
1602 See wxDataViewCtrl for the list of supported styles.
1605 @beginEventEmissionTable
1606 See wxDataViewCtrl for the list of events emitted by this class.
1612 class wxDataViewListCtrl
: public wxDataViewCtrl
1618 wxDataViewListCtrl();
1621 Constructor. Calls Create().
1623 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1624 const wxPoint
& pos
= wxDefaultPosition
,
1625 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1626 const wxValidator
& validator
= wxDefaultValidator
);
1629 Destructor. Deletes the image list if any.
1631 ~wxDataViewListCtrl();
1634 Creates the control and a wxDataViewListStore as its internal model.
1636 bool Create( wxWindow
*parent
, wxWindowID id
,
1637 const wxPoint
& pos
= wxDefaultPosition
,
1638 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1639 const wxValidator
& validator
= wxDefaultValidator
);
1645 wxDataViewListStore
*GetStore();
1646 const wxDataViewListStore
*GetStore() const;
1650 @name Column management functions
1655 Appends a column to the control and additionally appends a
1656 column to the store with the type string.
1658 virtual void AppendColumn( wxDataViewColumn
*column
);
1661 Appends a column to the control and additionally appends a
1662 column to the list store with the type @a varianttype.
1664 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1667 Appends a text column to the control and the store.
1669 See wxDataViewColumn::wxDataViewColumn for more info about
1672 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1673 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1674 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1675 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1678 Appends a toggle column to the control and the store.
1680 See wxDataViewColumn::wxDataViewColumn for more info about
1683 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1684 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1685 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1686 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1689 Appends a progress column to the control and the store.
1691 See wxDataViewColumn::wxDataViewColumn for more info about
1694 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1695 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1696 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1697 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1700 Appends an icon-and-text column to the control and the store.
1702 See wxDataViewColumn::wxDataViewColumn for more info about
1705 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1706 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1707 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
1708 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1711 Inserts a column to the control and additionally inserts a
1712 column to the store with the type string.
1714 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
1717 Inserts a column to the control and additionally inserts a
1718 column to the list store with the type @a varianttype.
1720 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
,
1721 const wxString
&varianttype
);
1724 Prepends a column to the control and additionally prepends a
1725 column to the store with the type string.
1727 virtual void PrependColumn( wxDataViewColumn
*column
);
1730 Prepends a column to the control and additionally prepends a
1731 column to the list store with the type @a varianttype.
1733 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1739 @name Item management functions
1744 Appends an item (=row) to the control and store.
1746 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1749 Prepends an item (=row) to the control and store.
1751 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1754 Inserts an item (=row) to the control and store.
1756 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1759 Delete the row at position @a row.
1761 void DeleteItem( unsigned row
);
1764 Delete all items (= all rows).
1766 void DeleteAllItems();
1769 Sets the value in the store and update the control.
1771 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
1774 Returns the value from the store.
1776 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
1779 Sets the value in the store and update the control.
1781 This method assumes that the a string is stored in respective
1784 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
1787 Returns the value from the store.
1789 This method assumes that the a string is stored in respective
1792 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
1795 Sets the value in the store and update the control.
1797 This method assumes that the a boolean value is stored in
1800 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
1803 Returns the value from the store.
1805 This method assumes that the a boolean value is stored in
1808 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
1815 @class wxDataViewTreeCtrl
1817 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1818 and forwards most of its API to that class.
1819 Additionally, it uses a wxImageList to store a list of icons.
1821 The main purpose of this class is to represent a possible replacement for
1825 See wxDataViewCtrl for the list of supported styles.
1828 @beginEventEmissionTable
1829 See wxDataViewCtrl for the list of events emitted by this class.
1834 @appearance{dataviewtreectrl.png}
1836 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1842 wxDataViewTreeCtrl();
1845 Constructor. Calls Create().
1847 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1848 const wxPoint
& pos
= wxDefaultPosition
,
1849 const wxSize
& size
= wxDefaultSize
,
1850 long style
= wxDV_NO_HEADER
,
1851 const wxValidator
& validator
= wxDefaultValidator
);
1854 Destructor. Deletes the image list if any.
1856 virtual ~wxDataViewTreeCtrl();
1859 Appends a container to the given @a parent.
1861 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1862 const wxString
& text
,
1865 wxClientData
* data
= NULL
);
1868 Appends an item to the given @a parent.
1870 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1871 const wxString
& text
,
1873 wxClientData
* data
= NULL
);
1876 Creates the control and a wxDataViewTreeStore as its internal model.
1878 bool Create(wxWindow
* parent
, wxWindowID id
,
1879 const wxPoint
& pos
= wxDefaultPosition
,
1880 const wxSize
& size
= wxDefaultSize
,
1881 long style
= wxDV_NO_HEADER
,
1882 const wxValidator
& validator
= wxDefaultValidator
);
1885 Calls the identical method from wxDataViewTreeStore.
1887 void DeleteAllItems();
1890 Calls the identical method from wxDataViewTreeStore.
1892 void DeleteChildren(const wxDataViewItem
& item
);
1895 Calls the identical method from wxDataViewTreeStore.
1897 void DeleteItem(const wxDataViewItem
& item
);
1900 Calls the identical method from wxDataViewTreeStore.
1902 int GetChildCount(const wxDataViewItem
& parent
) const;
1905 Returns the image list.
1907 wxImageList
* GetImageList();
1910 Calls the identical method from wxDataViewTreeStore.
1912 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1915 Calls the identical method from wxDataViewTreeStore.
1917 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1920 Calls the identical method from wxDataViewTreeStore.
1922 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
1925 Calls the identical method from wxDataViewTreeStore.
1927 wxString
GetItemText(const wxDataViewItem
& item
) const;
1930 Calls the identical method from wxDataViewTreeStore.
1932 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1933 unsigned int pos
) const;
1939 wxDataViewTreeStore
* GetStore();
1940 const wxDataViewTreeStore
* GetStore() const;
1944 Calls the same method from wxDataViewTreeStore but uses
1945 an index position in the image list instead of a wxIcon.
1947 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1948 const wxDataViewItem
& previous
,
1949 const wxString
& text
,
1952 wxClientData
* data
= NULL
);
1955 Calls the same method from wxDataViewTreeStore but uses
1956 an index position in the image list instead of a wxIcon.
1958 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1959 const wxDataViewItem
& previous
,
1960 const wxString
& text
,
1962 wxClientData
* data
= NULL
);
1965 Calls the same method from wxDataViewTreeStore but uses
1966 an index position in the image list instead of a wxIcon.
1968 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1969 const wxString
& text
,
1972 wxClientData
* data
= NULL
);
1975 Calls the same method from wxDataViewTreeStore but uses
1976 an index position in the image list instead of a wxIcon.
1978 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1979 const wxString
& text
,
1981 wxClientData
* data
= NULL
);
1984 Sets the image list.
1986 void SetImageList(wxImageList
* imagelist
);
1989 Calls the identical method from wxDataViewTreeStore.
1991 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1994 Calls the identical method from wxDataViewTreeStore.
1996 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1997 const wxIcon
& icon
);
2000 Calls the identical method from wxDataViewTreeStore.
2002 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2005 Calls the identical method from wxDataViewTreeStore.
2007 void SetItemText(const wxDataViewItem
& item
,
2008 const wxString
& text
);
2013 @class wxDataViewListStore
2015 wxDataViewListStore is a specialised wxDataViewModel for storing
2016 a simple table of data. Since it derives from wxDataViewIndexListModel
2017 its data is be accessed by row (i.e. by index) instead of only
2020 This class actually stores the values (therefore its name)
2021 and implements all virtual methods from the base classes so it can be
2022 used directly without having to derive any class from it, but it is
2023 mostly used from within wxDataViewListCtrl.
2029 class wxDataViewListStore
: public wxDataViewIndexListModel
2035 wxDataViewListStore();
2040 ~wxDataViewListStore();
2043 Prepends a data column.
2045 @a variantype indicates the type of values store in the column.
2047 This does not automatically fill in any (default) values in
2048 rows which exist in the store already.
2050 void PrependColumn( const wxString
&varianttype
);
2053 Inserts a data column before @a pos.
2055 @a variantype indicates the type of values store in the column.
2057 This does not automatically fill in any (default) values in
2058 rows which exist in the store already.
2060 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
2063 Appends a data column.
2065 @a variantype indicates the type of values store in the column.
2067 This does not automatically fill in any (default) values in
2068 rows which exist in the store already.
2070 void AppendColumn( const wxString
&varianttype
);
2073 Appends an item (=row) and fills it with @a values.
2075 The values must match the values specifies in the column
2076 in number and type. No (default) values are filled in
2079 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2082 Prepends an item (=row) and fills it with @a values.
2084 The values must match the values specifies in the column
2085 in number and type. No (default) values are filled in
2088 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2091 Inserts an item (=row) and fills it with @a values.
2093 The values must match the values specifies in the column
2094 in number and type. No (default) values are filled in
2097 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2100 Delete the item (=row) at position @a pos.
2102 void DeleteItem( unsigned pos
);
2105 Delete all item (=all rows) in the store.
2107 void DeleteAllItems();
2110 Overriden from wxDataViewModel
2112 virtual unsigned int GetColumnCount() const;
2115 Overriden from wxDataViewModel
2117 virtual wxString
GetColumnType( unsigned int col
) const;
2120 Overriden from wxDataViewIndexListModel
2122 virtual void GetValueByRow( wxVariant
&value
,
2123 unsigned int row
, unsigned int col
) const;
2126 Overriden from wxDataViewIndexListModel
2128 virtual bool SetValueByRow( const wxVariant
&value
,
2129 unsigned int row
, unsigned int col
);
2134 @class wxDataViewTreeStore
2136 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2137 trees very much like wxTreeCtrl does and it offers a similar API.
2139 This class actually stores the entire tree and the values (therefore its name)
2140 and implements all virtual methods from the base class so it can be used directly
2141 without having to derive any class from it, but it is mostly used from within
2147 class wxDataViewTreeStore
: public wxDataViewModel
2151 Constructor. Creates the invisible root node internally.
2153 wxDataViewTreeStore();
2158 virtual ~wxDataViewTreeStore();
2163 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2164 const wxString
& text
,
2165 const wxIcon
& icon
= wxNullIcon
,
2166 const wxIcon
& expanded
= wxNullIcon
,
2167 wxClientData
* data
= NULL
);
2172 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2173 const wxString
& text
,
2174 const wxIcon
& icon
= wxNullIcon
,
2175 wxClientData
* data
= NULL
);
2178 Delete all item in the model.
2180 void DeleteAllItems();
2183 Delete all children of the item, but not the item itself.
2185 void DeleteChildren(const wxDataViewItem
& item
);
2190 void DeleteItem(const wxDataViewItem
& item
);
2193 Return the number of children of item.
2195 int GetChildCount(const wxDataViewItem
& parent
) const;
2198 Returns the client data asoociated with the item.
2200 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2203 Returns the icon to display in expanded containers.
2205 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2208 Returns the icon of the item.
2210 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2213 Returns the text of the item.
2215 wxString
GetItemText(const wxDataViewItem
& item
) const;
2218 Returns the nth child item of item.
2220 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2221 unsigned int pos
) const;
2224 Inserts a container after @a previous.
2226 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2227 const wxDataViewItem
& previous
,
2228 const wxString
& text
,
2229 const wxIcon
& icon
= wxNullIcon
,
2230 const wxIcon
& expanded
= wxNullIcon
,
2231 wxClientData
* data
= NULL
);
2234 Inserts an item after @a previous.
2236 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2237 const wxDataViewItem
& previous
,
2238 const wxString
& text
,
2239 const wxIcon
& icon
= wxNullIcon
,
2240 wxClientData
* data
= NULL
);
2243 Inserts a container before the first child item or @a parent.
2245 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2246 const wxString
& text
,
2247 const wxIcon
& icon
= wxNullIcon
,
2248 const wxIcon
& expanded
= wxNullIcon
,
2249 wxClientData
* data
= NULL
);
2252 Inserts an item before the first child item or @a parent.
2254 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2255 const wxString
& text
,
2256 const wxIcon
& icon
= wxNullIcon
,
2257 wxClientData
* data
= NULL
);
2260 Sets the client data associated with the item.
2262 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2265 Sets the expanded icon for the item.
2267 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2268 const wxIcon
& icon
);
2271 Sets the icon for the item.
2273 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2278 @class wxDataViewIconText
2280 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2281 This class can be converted to and from a wxVariant.
2286 class wxDataViewIconText
: public wxObject
2293 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2294 const wxIcon
& icon
= wxNullIcon
);
2295 wxDataViewIconText(const wxDataViewIconText
& other
);
2301 const wxIcon
& GetIcon() const;
2306 wxString
GetText() const;
2311 void SetIcon(const wxIcon
& icon
);
2316 void SetText(const wxString
& text
);
2322 @class wxDataViewEvent
2324 This is the event class for the wxDataViewCtrl notifications.
2326 @beginEventTable{wxDataViewEvent}
2327 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2328 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2329 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2330 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2331 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2332 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2333 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2334 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2335 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2336 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2337 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2338 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2339 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2340 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2341 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2342 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2343 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2344 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2345 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2346 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2347 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2348 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2349 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2350 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2351 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2352 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2353 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2354 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2355 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2356 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2357 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2358 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2359 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2360 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2361 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
2362 Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
2366 @category{events,dvc}
2368 class wxDataViewEvent
: public wxNotifyEvent
2372 Constructor. Typically used by wxWidgets internals only.
2374 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2378 Returns the position of the column in the control or -1
2379 if no column field was set by the event emitter.
2381 int GetColumn() const;
2384 Returns a pointer to the wxDataViewColumn from which
2385 the event was emitted or @NULL.
2387 wxDataViewColumn
* GetDataViewColumn() const;
2390 Returns the wxDataViewModel associated with the event.
2392 wxDataViewModel
* GetModel() const;
2395 Returns a the position of a context menu event in screen coordinates.
2397 wxPoint
GetPosition() const;
2400 Returns a reference to a value.
2402 const wxVariant
& GetValue() const;
2405 Sets the column index associated with this event.
2407 void SetColumn(int col
);
2410 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2412 void SetDataViewColumn(wxDataViewColumn
* col
);
2415 Sets the dataview model associated with this event.
2417 void SetModel(wxDataViewModel
* model
);
2420 Sets the value associated with this event.
2422 void SetValue(const wxVariant
& value
);
2425 Set wxDataObject for data transfer within a drag operation.
2427 void SetDataObject( wxDataObject
*obj
);
2430 Used internally. Gets associated wxDataObject for data transfer
2431 within a drag operation.
2433 wxDataObject
*GetDataObject() const;
2436 Used internally. Sets the wxDataFormat during a drop operation.
2438 void SetDataFormat( const wxDataFormat
&format
);
2441 Gets the wxDataFormat during a drop operation.
2443 wxDataFormat
GetDataFormat() const;
2446 Used internally. Sets the data size for a drop data transfer.
2448 void SetDataSize( size_t size
);
2451 Gets the data size for a drop data transfer.
2453 size_t GetDataSize() const;
2456 Used internally. Sets the data buffer for a drop data transfer.
2458 void SetDataBuffer( void* buf
);
2461 Gets the data buffer for a drop data transfer.
2463 void *GetDataBuffer() const;
2466 Return the first row that will be displayed.
2468 int GetCacheFrom() const;
2471 Return the last row that will be displayed.
2473 int GetCacheTo() const;