1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
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 Note that wxDataViewModel does not define the position or index of any item
24 in the control because different controls might display the same data differently.
25 wxDataViewModel does provide a wxDataViewModel::Compare method which the
26 wxDataViewCtrl may use to sort the data either in conjunction with a column
27 header or without (see wxDataViewModel::HasDefaultCompare).
29 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
30 to store data and its type in a generic way. wxVariant can be extended to contain
31 almost any data without changes to the original class. To a certain extent,
32 you can use (the somewhat more elegant) wxAny instead of wxVariant as there
33 is code to convert between the two, but it is unclear what impact this will
36 Since you will usually allow the wxDataViewCtrl to change your data
37 through its graphical interface, you will also have to override
38 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
39 to some data has been committed.
41 If the data represented by the model is changed by something else than its
42 associated wxDataViewCtrl, the control has to be notified about the change.
43 Depending on what happened you need to call one of the following methods:
44 - wxDataViewModel::ValueChanged,
45 - wxDataViewModel::ItemAdded,
46 - wxDataViewModel::ItemDeleted,
47 - wxDataViewModel::ItemChanged,
48 - wxDataViewModel::Cleared.
50 There are plural forms for notification of addition, change or removal of
51 several item at once. See:
52 - wxDataViewModel::ItemsAdded,
53 - wxDataViewModel::ItemsDeleted,
54 - wxDataViewModel::ItemsChanged.
56 This class maintains a list of wxDataViewModelNotifier which link this class
57 to the specific implementations on the supported platforms so that e.g. calling
58 wxDataViewModel::ValueChanged on this model will just call
59 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
60 You can also add your own notifier in order to get informed about any changes
61 to the data in the list model.
63 Currently wxWidgets provides the following models apart from the base model:
64 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
67 Note that wxDataViewModel is reference counted, derives from wxRefCounter
68 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
69 This implies that you need to decrease the reference count after
70 associating the model with a control like this:
73 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
74 wxDataViewModel *musicModel = new MyMusicModel;
75 m_musicCtrl->AssociateModel( musicModel );
76 musicModel->DecRef(); // avoid memory leak !!
81 A potentially better way to avoid memory leaks is to use wxObjectDataPtr
84 wxObjectDataPtr<MyMusicModel> musicModel;
86 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
87 musicModel = new MyMusicModel;
88 m_musicCtrl->AssociateModel( musicModel.get() );
97 class wxDataViewModel
: public wxRefCounter
106 Adds a wxDataViewModelNotifier to the model.
108 void AddNotifier(wxDataViewModelNotifier
* notifier
);
111 Change the value of the given item and update the control to reflect
114 This function simply calls SetValue() and, if it succeeded,
122 The item (row) to update.
124 The column to update.
126 @true if both SetValue() and ValueChanged() returned @true.
128 bool ChangeValue(const wxVariant
& variant
,
129 const wxDataViewItem
& item
,
133 Called to inform the model that all data has been cleared.
134 The control will reread the data from the model again.
136 virtual bool Cleared();
139 The compare function to be used by control. The default compare function
140 sorts by container and other items separately and in ascending order.
141 Override this for a different sorting behaviour.
143 @see HasDefaultCompare().
145 virtual int Compare(const wxDataViewItem
& item1
,
146 const wxDataViewItem
& item2
,
148 bool ascending
) const;
151 Override this to indicate that the item has special font attributes.
152 This only affects the wxDataViewTextRendererText renderer.
154 The base class version always simply returns @false.
156 @see wxDataViewItemAttr.
159 The item for which the attribute is requested.
161 The column of the item for which the attribute is requested.
163 The attribute to be filled in if the function returns @true.
165 @true if this item has an attribute or @false otherwise.
167 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
168 wxDataViewItemAttr
& attr
) const;
171 Override this to indicate that the item should be disabled.
173 Disabled items are displayed differently (e.g. grayed out) and cannot
176 The base class version always returns @true, thus making all items
180 The item whose enabled status is requested.
182 The column of the item whose enabled status is requested.
184 @true if this item should be enabled, @false otherwise.
186 @note Currently disabling items is not supported by the wxOSX/Carbon
191 virtual bool IsEnabled(const wxDataViewItem
&item
,
192 unsigned int col
) const;
195 Override this so the control can query the child items of an item.
196 Returns the number of items.
198 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
199 wxDataViewItemArray
& children
) const = 0;
202 Override this to indicate the number of columns in the model.
204 virtual unsigned int GetColumnCount() const = 0;
207 Override this to indicate what type of data is stored in the
208 column specified by @a col.
210 This should return a string indicating the type of data as reported by wxVariant.
212 virtual wxString
GetColumnType(unsigned int col
) const = 0;
215 Override this to indicate which wxDataViewItem representing the parent
216 of @a item or an invalid wxDataViewItem if the root item is
219 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
222 Override this to indicate the value of @a item.
223 A wxVariant is used to store the data.
225 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
226 unsigned int col
) const = 0;
229 Override this method to indicate if a container item merely acts as a
230 headline (or for categorisation) or if it also acts a normal item with
231 entries for further columns. By default returns @false.
233 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
236 Override this to indicate that the model provides a default compare
237 function that the control should use if no wxDataViewColumn has been
238 chosen for sorting. Usually, the user clicks on a column header for
239 sorting, the data will be sorted alphanumerically.
241 If any other order (e.g. by index or order of appearance) is required,
242 then this should be used.
243 See wxDataViewIndexListModel for a model which makes use of this.
245 virtual bool HasDefaultCompare() const;
248 Return true if there is a value in the given column of this item.
250 All normal items have values in all columns but the container items
251 only show their label in the first column (@a col == 0) by default (but
252 see HasContainerColumns()). So this function always returns true for
253 the first column while for the other ones it returns true only if the
254 item is not a container or HasContainerColumns() was overridden to
259 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const;
262 Override this to indicate of @a item is a container, i.e. if
263 it can have child items.
265 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
268 Call this to inform the model that an item has been added to the data.
270 bool ItemAdded(const wxDataViewItem
& parent
,
271 const wxDataViewItem
& item
);
274 Call this to inform the model that an item has changed.
276 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
277 event (in which the column fields will not be set) to the user.
279 bool ItemChanged(const wxDataViewItem
& item
);
282 Call this to inform the model that an item has been deleted from the data.
284 bool ItemDeleted(const wxDataViewItem
& parent
,
285 const wxDataViewItem
& item
);
288 Call this to inform the model that several items have been added to the data.
290 bool ItemsAdded(const wxDataViewItem
& parent
,
291 const wxDataViewItemArray
& items
);
294 Call this to inform the model that several items have changed.
296 This will eventually emit @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
297 events (in which the column fields will not be set) to the user.
299 bool ItemsChanged(const wxDataViewItemArray
& items
);
302 Call this to inform the model that several items have been deleted.
304 bool ItemsDeleted(const wxDataViewItem
& parent
,
305 const wxDataViewItemArray
& items
);
308 Remove the @a notifier from the list of notifiers.
310 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
313 Call this to initiate a resort after the sort function has been changed.
315 virtual void Resort();
318 This gets called in order to set a value in the data model.
320 The most common scenario is that the wxDataViewCtrl calls this method
321 after the user changed some data in the view.
323 This is the function you need to override in your derived class but if
324 you want to call it, ChangeValue() is usually more convenient as
325 otherwise you need to manually call ValueChanged() to update the
328 virtual bool SetValue(const wxVariant
& variant
,
329 const wxDataViewItem
& item
,
330 unsigned int col
) = 0;
333 Call this to inform this model that a value in the model has been changed.
334 This is also called from wxDataViewCtrl's internal editing code, e.g. when
335 editing a text field in the control.
337 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
340 virtual bool ValueChanged(const wxDataViewItem
& item
,
346 Destructor. This should not be called directly. Use DecRef() instead.
348 virtual ~wxDataViewModel();
354 @class wxDataViewListModel
356 Base class with abstract API for wxDataViewIndexListModel and
357 wxDataViewVirtualListModel.
362 class wxDataViewListModel
: public wxDataViewModel
369 virtual ~wxDataViewIndexListModel();
372 Compare method that sorts the items by their index.
374 int Compare(const wxDataViewItem
& item1
,
375 const wxDataViewItem
& item2
,
376 unsigned int column
, bool ascending
);
379 Override this to indicate that the row has special font attributes.
380 This only affects the wxDataViewTextRendererText() renderer.
382 The base class version always simply returns @false.
384 @see wxDataViewItemAttr.
387 The row for which the attribute is requested.
389 The column for which the attribute is requested.
391 The attribute to be filled in if the function returns @true.
393 @true if this item has an attribute or @false otherwise.
395 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
396 wxDataViewItemAttr
& attr
) const;
399 Override this if you want to disable specific items.
401 The base class version always returns @true, thus making all items
405 The row of the item whose enabled status is requested.
407 The column of the item whose enabled status is requested.
409 @true if the item at this row and column should be enabled,
412 @note See wxDataViewModel::IsEnabled() for the current status of
413 support for disabling the items under different platforms.
417 virtual bool IsEnabledByRow(unsigned int row
,
418 unsigned int col
) const;
421 Returns the number of items (or rows) in the list.
423 unsigned int GetCount() const;
426 Returns the wxDataViewItem at the given @e row.
428 wxDataViewItem
GetItem(unsigned int row
) const;
431 Returns the position of given @e item.
433 unsigned int GetRow(const wxDataViewItem
& item
) const;
436 Override this to allow getting values from the model.
438 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
439 unsigned int col
) const = 0;
442 Call this after if the data has to be read again from the model.
443 This is useful after major changes when calling the methods below
444 (possibly thousands of times) doesn't make sense.
446 void Reset(unsigned int new_size
);
449 Call this after a row has been appended to the model.
454 Call this after a row has been changed.
456 void RowChanged(unsigned int row
);
459 Call this after a row has been deleted.
461 void RowDeleted(unsigned int row
);
464 Call this after a row has been inserted at the given position.
466 void RowInserted(unsigned int before
);
469 Call this after a row has been prepended to the model.
474 Call this after a value has been changed.
476 void RowValueChanged(unsigned int row
, unsigned int col
);
479 Call this after rows have been deleted.
480 The array will internally get copied and sorted in descending order so
481 that the rows with the highest position will be deleted first.
483 void RowsDeleted(const wxArrayInt
& rows
);
486 Called in order to set a value in the model.
488 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
489 unsigned int col
) = 0;
494 @class wxDataViewIndexListModel
496 wxDataViewIndexListModel is a specialized data model which lets you address
497 an item by its position (row) rather than its wxDataViewItem (which you can
498 obtain from this class).
499 This model also provides its own wxDataViewIndexListModel::Compare
500 method which sorts the model's data by the index.
502 This model is not a virtual model since the control stores each wxDataViewItem.
503 Use wxDataViewVirtualListModel if you need to display millions of items or
504 have other reason to use a virtual control.
506 @see wxDataViewListModel for the API.
512 class wxDataViewIndexListModel
: public wxDataViewListModel
518 wxDataViewIndexListModel(unsigned int initial_size
= 0);
523 @class wxDataViewVirtualListModel
525 wxDataViewVirtualListModel is a specialized data model which lets you address
526 an item by its position (row) rather than its wxDataViewItem and as such offers
527 the exact same interface as wxDataViewIndexListModel.
528 The important difference is that under platforms other than OS X, using this
529 model will result in a truly virtual control able to handle millions of items
530 as the control doesn't store any item (a feature not supported by OS X).
532 @see wxDataViewListModel for the API.
538 class wxDataViewVirtualListModel
: public wxDataViewListModel
544 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
551 @class wxDataViewItemAttr
553 This class is used to indicate to a wxDataViewCtrl that a certain item
554 (see wxDataViewItem) has extra font attributes for its renderer.
555 For this, it is required to override wxDataViewModel::GetAttr.
557 Attributes are currently only supported by wxDataViewTextRendererText.
562 class wxDataViewItemAttr
568 wxDataViewItemAttr();
571 Call this to indicate that the item shall be displayed in bold text.
573 void SetBold(bool set
);
576 Call this to indicate that the item shall be displayed with that colour.
578 void SetColour(const wxColour
& colour
);
581 Call this to set the background colour to use.
583 Currently this attribute is only supported in the generic version of
584 wxDataViewCtrl and ignored by the native GTK+ and OS X implementations.
588 void SetBackgroundColour(const wxColour
& colour
);
591 Call this to indicate that the item shall be displayed in italic text.
593 void SetItalic(bool set
);
599 @class wxDataViewItem
601 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
602 in a persistent way, i.e. independent of the position of the item in the control
603 or changes to its contents.
605 It must hold a unique ID of type @e void* in its only field and can be converted
608 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
609 return @false which used in many places in the API of wxDataViewCtrl to
610 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
611 the invisible root. Examples for this are wxDataViewModel::GetParent and
612 wxDataViewModel::GetChildren.
625 wxDataViewItem(const wxDataViewItem
& item
);
626 explicit wxDataViewItem(void* id
);
635 Returns @true if the ID is not @NULL.
641 // ----------------------------------------------------------------------------
642 // wxDataViewCtrl flags
643 // ----------------------------------------------------------------------------
645 // size of a wxDataViewRenderer without contents:
646 #define wxDVC_DEFAULT_RENDERER_SIZE 20
648 // the default width of new (text) columns:
649 #define wxDVC_DEFAULT_WIDTH 80
651 // the default width of new toggle columns:
652 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
654 // the default minimal width of the columns:
655 #define wxDVC_DEFAULT_MINWIDTH 30
657 // The default alignment of wxDataViewRenderers is to take
658 // the alignment from the column it owns.
659 #define wxDVR_DEFAULT_ALIGNMENT -1
661 #define wxDV_SINGLE 0x0000 // for convenience
662 #define wxDV_MULTIPLE 0x0001 // can select multiple items
664 #define wxDV_NO_HEADER 0x0002 // column titles not visible
665 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
666 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
668 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
669 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
673 wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
;
675 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
;
676 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
;
677 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
;
678 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
;
679 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
;
680 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
;
681 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
;
682 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
;
683 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
;
685 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
;
687 wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
;
688 wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
689 wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
;
690 wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
;
691 wxEventType wxEVT_COMMAND_DATAVIEW_CACHE_HINT
;
693 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
;
694 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
;
695 wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP
;
698 @class wxDataViewCtrl
700 wxDataViewCtrl is a control to display data either in a tree like fashion or
701 in a tabular form or both.
703 If you only need to display a simple tree structure with an API more like the
704 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
705 Likewise, if you only want to display simple table structure you can use
706 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
707 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
709 A wxDataViewItem is used to represent a (visible) item in the control.
711 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
712 virtual functions or by setting it directly. Instead you need to write your own
713 wxDataViewModel and associate it with this control.
714 Then you need to add a number of wxDataViewColumn to this control to define
715 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
716 of a wxDataViewRenderer to render its cells.
718 A number of standard renderers for rendering text, dates, images, toggle,
719 a progress bar etc. are provided. Additionally, the user can write custom
720 renderers deriving from wxDataViewCustomRenderer for displaying anything.
722 All data transfer from the control to the model and the user code is done
723 through wxVariant which can be extended to support more data formats as necessary.
724 Accordingly, all type information uses the strings returned from wxVariant::GetType.
728 Single selection mode. This is the default.
729 @style{wxDV_MULTIPLE}
730 Multiple selection mode.
731 @style{wxDV_ROW_LINES}
732 Use alternating colours for rows if supported by platform and theme.
733 Currently only supported by the native GTK and OS X implementations
734 but not by the generic one.
735 @style{wxDV_HORIZ_RULES}
736 Display fine rules between row if supported.
737 @style{wxDV_VERT_RULES}
738 Display fine rules between columns is supported.
739 @style{wxDV_VARIABLE_LINE_HEIGHT}
740 Allow variable line heights.
741 This can be inefficient when displaying large number of items.
742 @style{wxDV_NO_HEADER}
743 Do not show column headers (which are shown by default).
746 @beginEventEmissionTable{wxDataViewEvent}
747 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
748 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
749 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
750 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
751 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
752 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event. This
753 event can be vetoed in order to prevent editing on an item by item
755 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
756 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
757 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
758 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
759 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
760 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
761 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
762 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
763 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
764 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
765 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
766 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
767 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
768 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
769 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
770 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event
771 generated when the user right clicks inside the control. Notice that
772 this menu is generated even if the click didn't occur on any valid
773 item, in this case wxDataViewEvent::GetItem() simply returns an
775 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
776 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
777 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
778 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
779 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
780 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
781 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
782 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
783 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
784 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
785 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
786 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
787 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
788 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
793 @appearance{dataviewctrl.png}
795 class wxDataViewCtrl
: public wxControl
804 Constructor. Calls Create().
806 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
807 const wxPoint
& pos
= wxDefaultPosition
,
808 const wxSize
& size
= wxDefaultSize
,
810 const wxValidator
& validator
= wxDefaultValidator
,
811 const wxString
& name
= wxDataViewCtrlNameStr
);
816 virtual ~wxDataViewCtrl();
819 Appends a wxDataViewColumn to the control. Returns @true on success.
821 Note that there is a number of short cut methods which implicitly create
822 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
824 virtual bool AppendColumn(wxDataViewColumn
* col
);
827 Prepends a wxDataViewColumn to the control. Returns @true on success.
829 Note that there is a number of short cut methods which implicitly create
830 a wxDataViewColumn and a wxDataViewRenderer for it.
832 virtual bool PrependColumn(wxDataViewColumn
* col
);
835 Inserts a wxDataViewColumn to the control. Returns @true on success.
837 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
841 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
842 created in the function or @NULL on failure.
844 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
845 unsigned int model_column
,
846 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
848 wxAlignment align
= wxALIGN_CENTER
,
849 int flags
= wxDATAVIEW_COL_RESIZABLE
);
850 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
851 unsigned int model_column
,
852 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
854 wxAlignment align
= wxALIGN_CENTER
,
855 int flags
= wxDATAVIEW_COL_RESIZABLE
);
860 Appends a column for rendering a date. Returns the wxDataViewColumn
861 created in the function or @NULL on failure.
863 @note The @a align parameter is applied to both the column header and
866 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
867 unsigned int model_column
,
868 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
870 wxAlignment align
= wxALIGN_NOT
,
871 int flags
= wxDATAVIEW_COL_RESIZABLE
);
872 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
873 unsigned int model_column
,
874 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
876 wxAlignment align
= wxALIGN_NOT
,
877 int flags
= wxDATAVIEW_COL_RESIZABLE
);
882 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
883 created in the function or @NULL on failure.
884 This method uses the wxDataViewIconTextRenderer class.
886 @note The @a align parameter is applied to both the column header and
889 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
890 unsigned int model_column
,
891 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
893 wxAlignment align
= wxALIGN_NOT
,
894 int flags
= wxDATAVIEW_COL_RESIZABLE
);
895 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
896 unsigned int model_column
,
897 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
899 wxAlignment align
= wxALIGN_NOT
,
900 int flags
= wxDATAVIEW_COL_RESIZABLE
);
905 Appends a column for rendering a progress indicator. Returns the
906 wxDataViewColumn created in the function or @NULL on failure.
908 @note The @a align parameter is applied to both the column header and
911 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
912 unsigned int model_column
,
913 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
915 wxAlignment align
= wxALIGN_CENTER
,
916 int flags
= wxDATAVIEW_COL_RESIZABLE
);
917 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
918 unsigned int model_column
,
919 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
921 wxAlignment align
= wxALIGN_CENTER
,
922 int flags
= wxDATAVIEW_COL_RESIZABLE
);
927 Appends a column for rendering text. Returns the wxDataViewColumn
928 created in the function or @NULL on failure.
930 @note The @a align parameter is applied to both the column header and
933 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
934 unsigned int model_column
,
935 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
937 wxAlignment align
= wxALIGN_NOT
,
938 int flags
= wxDATAVIEW_COL_RESIZABLE
);
939 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
940 unsigned int model_column
,
941 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
943 wxAlignment align
= wxALIGN_NOT
,
944 int flags
= wxDATAVIEW_COL_RESIZABLE
);
949 Appends a column for rendering a toggle. Returns the wxDataViewColumn
950 created in the function or @NULL on failure.
952 @note The @a align parameter is applied to both the column header and
955 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
956 unsigned int model_column
,
957 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
959 wxAlignment align
= wxALIGN_CENTER
,
960 int flags
= wxDATAVIEW_COL_RESIZABLE
);
961 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
962 unsigned int model_column
,
963 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
965 wxAlignment align
= wxALIGN_CENTER
,
966 int flags
= wxDATAVIEW_COL_RESIZABLE
);
970 Associates a wxDataViewModel with the control.
971 This increases the reference count of the model by 1.
973 virtual bool AssociateModel(wxDataViewModel
* model
);
978 virtual bool ClearColumns();
983 virtual void Collapse(const wxDataViewItem
& item
);
986 Create the control. Useful for two step creation.
988 bool Create(wxWindow
* parent
, wxWindowID id
,
989 const wxPoint
& pos
= wxDefaultPosition
,
990 const wxSize
& size
= wxDefaultSize
,
992 const wxValidator
& validator
= wxDefaultValidator
,
993 const wxString
& name
= wxDataViewCtrlNameStr
);
996 Deletes given column.
998 virtual bool DeleteColumn(wxDataViewColumn
* column
);
1001 Enable drag operations using the given @a format.
1003 virtual bool EnableDragSource( const wxDataFormat
&format
);
1006 Enable drop operations using the given @a format.
1008 virtual bool EnableDropTarget( const wxDataFormat
&format
);
1011 Call this to ensure that the given item is visible.
1013 virtual void EnsureVisible(const wxDataViewItem
& item
,
1014 const wxDataViewColumn
* column
= NULL
);
1019 virtual void Expand(const wxDataViewItem
& item
);
1022 Expands all ancestors of the @a item. This method also
1023 ensures that the item itself as well as all ancestor
1024 items have been read from the model by the control.
1026 virtual void ExpandAncestors( const wxDataViewItem
& item
);
1029 Returns pointer to the column. @a pos refers to the position in the
1030 control which may change after reordering columns by the user.
1032 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
1035 Returns the number of columns.
1037 virtual unsigned int GetColumnCount() const;
1040 Returns the position of the column or -1 if not found in the control.
1042 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
1045 Returns column containing the expanders.
1047 wxDataViewColumn
* GetExpanderColumn() const;
1050 Returns the currently focused item.
1052 This is the item that the keyboard commands apply to. It may be invalid
1053 if there is no focus currently.
1055 This method is mostly useful for the controls with @c wxDV_MULTIPLE
1056 style as in the case of single selection it returns the same thing as
1059 Notice that under all platforms except Mac OS X the currently focused
1060 item may be selected or not but under OS X the current item is always
1063 @see SetCurrentItem()
1067 wxDataViewItem
GetCurrentItem() const;
1070 Returns indentation.
1072 int GetIndent() const;
1077 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
1078 const wxDataViewColumn
* col
= NULL
) const;
1081 Returns pointer to the data model associated with the control (if any).
1083 wxDataViewModel
* GetModel();
1086 Returns the number of currently selected items.
1088 This method may be called for both the controls with single and
1089 multiple selections and returns the number of selected item, possibly
1094 virtual int GetSelectedItemsCount() const;
1097 Returns first selected item or an invalid item if none is selected.
1099 This method may be called for both the controls with single and
1100 multiple selections but returns an invalid item if more than one item
1101 is selected in the latter case, use HasSelection() to determine if
1102 there are any selected items when using multiple selection.
1104 virtual wxDataViewItem
GetSelection() const;
1107 Fills @a sel with currently selected items and returns their number.
1109 This method may be called for both the controls with single and
1110 multiple selections. In the single selection case it returns the array
1111 with at most one element in it.
1113 @see GetSelectedItemsCount()
1115 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
1118 Returns the wxDataViewColumn currently responsible for sorting
1119 or @NULL if none has been selected.
1121 virtual wxDataViewColumn
* GetSortingColumn() const;
1124 Returns true if any items are currently selected.
1126 This method may be called for both the controls with single and
1127 multiple selections.
1129 Calling this method is equivalent to calling GetSelectedItemsCount()
1130 and comparing its result with 0 but is more clear and might also be
1131 implemented more efficiently in the future.
1135 bool HasSelection() const;
1140 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
1141 wxDataViewColumn
*& col
) const;
1144 Return @true if the item is expanded.
1146 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
1149 Return @true if the item is selected.
1151 virtual bool IsSelected(const wxDataViewItem
& item
) const;
1154 Select the given item.
1156 In single selection mode this changes the (unique) currently selected
1157 item. In multi selection mode, the @a item is selected and the
1158 previously selected items remain selected.
1160 virtual void Select(const wxDataViewItem
& item
);
1165 virtual void SelectAll();
1168 Set which column shall contain the tree-like expanders.
1170 void SetExpanderColumn(wxDataViewColumn
* col
);
1173 Changes the currently focused item.
1175 The @a item parameter must be valid, there is no way to remove the
1176 current item from the control.
1178 In single selection mode, calling this method is the same as calling
1179 Select() and is thus not very useful. In multiple selection mode this
1180 method only moves the current item however without changing the
1181 selection except under OS X where the current item is always selected,
1182 so calling SetCurrentItem() selects @a item if it hadn't been selected
1185 @see GetCurrentItem()
1189 void SetCurrentItem(const wxDataViewItem
& item
);
1192 Sets the indentation.
1194 void SetIndent(int indent
);
1197 Sets the selection to the array of wxDataViewItems.
1199 virtual void SetSelections(const wxDataViewItemArray
& sel
);
1202 Programmatically starts editing the given item on the given column.
1203 Currently not implemented on wxOSX Carbon.
1207 virtual void StartEditor(const wxDataViewItem
& item
, unsigned int column
);
1210 Unselect the given item.
1212 virtual void Unselect(const wxDataViewItem
& item
);
1216 This method only has effect if multiple selections are allowed.
1218 virtual void UnselectAll();
1221 Sets the row height.
1223 This function can only be used when all rows have the same height, i.e.
1224 when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
1226 Currently this is implemented in the generic and native GTK versions
1227 only and nothing is done (and @false returned) when using OS X port.
1229 Also notice that this method can only be used to increase the row
1230 height compared with the default one (as determined by the return value
1231 of wxDataViewRenderer::GetSize()), if it is set to a too small value
1232 then the minimum required by the renderers will be used.
1234 @return @true if the line height was changed or @false otherwise.
1238 virtual bool SetRowHeight(int rowHeight
);
1244 @class wxDataViewModelNotifier
1246 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1247 its notification interface.
1248 See the documentation of that class for further information.
1253 class wxDataViewModelNotifier
1259 wxDataViewModelNotifier();
1264 virtual ~wxDataViewModelNotifier();
1267 Called by owning model.
1269 virtual bool Cleared() = 0;
1272 Get owning wxDataViewModel.
1274 wxDataViewModel
* GetOwner() const;
1277 Called by owning model.
1279 @return Always return @true from this function in derived classes.
1281 virtual bool ItemAdded(const wxDataViewItem
& parent
,
1282 const wxDataViewItem
& item
) = 0;
1285 Called by owning model.
1287 @return Always return @true from this function in derived classes.
1289 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
1292 Called by owning model.
1294 @return Always return @true from this function in derived classes.
1296 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
1297 const wxDataViewItem
& item
) = 0;
1300 Called by owning model.
1302 @return Always return @true from this function in derived classes.
1304 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
1305 const wxDataViewItemArray
& items
);
1308 Called by owning model.
1310 @return Always return @true from this function in derived classes.
1312 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
1315 Called by owning model.
1317 @return Always return @true from this function in derived classes.
1319 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
1320 const wxDataViewItemArray
& items
);
1323 Called by owning model.
1325 virtual void Resort() = 0;
1328 Set owner of this notifier. Used internally.
1330 void SetOwner(wxDataViewModel
* owner
);
1333 Called by owning model.
1335 @return Always return @true from this function in derived classes.
1337 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
1342 The mode of a data-view cell; see wxDataViewRenderer for more info.
1344 enum wxDataViewCellMode
1347 The cell only displays information and cannot be manipulated or
1348 otherwise interacted with in any way.
1350 Note that this doesn't mean that the row being drawn can't be selected,
1351 just that a particular element of it cannot be individually modified.
1353 wxDATAVIEW_CELL_INERT
,
1356 Indicates that the cell can be @em activated by clicking it or using
1359 Activating a cell is an alternative to showing inline editor when the
1360 value can be edited in a simple way that doesn't warrant full editor
1361 control. The most typical use of cell activation is toggling the
1362 checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded
1363 volume slider or a five-star rating column.
1365 The exact means of activating a cell are platform-dependent, but they
1366 are usually similar to those used for inline editing of values.
1367 Typically, a cell would be activated by Space or Enter keys or by left
1370 @note Do not confuse this with item activation in wxDataViewCtrl
1371 and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is
1372 used for activating the item (or, to put it differently, the
1373 entire row) similarly to analogous messages in wxTreeCtrl and
1374 wxListCtrl, and the effect differs (play a song, open a file
1375 etc.). Cell activation, on the other hand, is all about
1376 interacting with the individual cell.
1378 @see wxDataViewCustomRenderer::ActivateCell()
1380 wxDATAVIEW_CELL_ACTIVATABLE
,
1383 Indicates that the user can edit the data in-place in an inline editor
1384 control that will show up when the user wants to edit the cell.
1386 A typical example of this behaviour is changing the filename in a file
1389 Editing is typically triggered by slowly double-clicking the cell or by
1390 a platform-dependent keyboard shortcut (F2 is typical on Windows, Space
1391 and/or Enter is common elsewhere and supported on Windows too).
1393 @see wxDataViewCustomRenderer::CreateEditorCtrl()
1395 wxDATAVIEW_CELL_EDITABLE
1399 The values of this enum controls how a wxDataViewRenderer should display
1400 its contents in a cell.
1402 enum wxDataViewCellRenderState
1404 wxDATAVIEW_CELL_SELECTED
= 1,
1405 wxDATAVIEW_CELL_PRELIT
= 2,
1406 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1407 wxDATAVIEW_CELL_FOCUSED
= 8
1411 @class wxDataViewRenderer
1413 This class is used by wxDataViewCtrl to render the individual cells.
1414 One instance of a renderer class is owned by a wxDataViewColumn.
1415 There is a number of ready-to-use renderers provided:
1416 - wxDataViewTextRenderer,
1417 - wxDataViewIconTextRenderer,
1418 - wxDataViewToggleRenderer,
1419 - wxDataViewProgressRenderer,
1420 - wxDataViewBitmapRenderer,
1421 - wxDataViewDateRenderer,
1422 - wxDataViewSpinRenderer.
1423 - wxDataViewChoiceRenderer.
1425 Additionally, the user can write own renderers by deriving from
1426 wxDataViewCustomRenderer.
1428 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1429 by the constructors respectively controls what actions the cell data allows
1430 and how the renderer should display its contents in a cell.
1435 class wxDataViewRenderer
: public wxObject
1441 wxDataViewRenderer(const wxString
& varianttype
,
1442 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1443 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1446 Enable or disable replacing parts of the item text with ellipsis to
1447 make it fit the column width.
1449 This method only makes sense for the renderers working with text, such
1450 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1452 By default wxELLIPSIZE_MIDDLE is used.
1455 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1459 void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
);
1462 Disable replacing parts of the item text with ellipsis.
1464 If ellipsizing is disabled, the string will be truncated if it doesn't
1467 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1471 void DisableEllipsize();
1474 Returns the alignment. See SetAlignment()
1476 virtual int GetAlignment() const;
1479 Returns the ellipsize mode used by the renderer.
1481 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1484 @see EnableEllipsize()
1486 wxEllipsizeMode
GetEllipsizeMode() const;
1489 Returns the cell mode.
1491 virtual wxDataViewCellMode
GetMode() const;
1494 Returns pointer to the owning wxDataViewColumn.
1496 wxDataViewColumn
* GetOwner() const;
1499 This methods retrieves the value from the renderer in order to
1500 transfer the value back to the data model.
1502 Returns @false on failure.
1504 virtual bool GetValue(wxVariant
& value
) const = 0;
1507 Returns a string with the type of the wxVariant supported by this renderer.
1509 wxString
GetVariantType() const;
1512 Sets the alignment of the renderer's content.
1513 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1514 should have the same alignment as the column header.
1516 The method is not implemented under OS X and the renderer always aligns
1517 its contents as the column header on that platform. The other platforms
1518 support both vertical and horizontal alignment.
1520 virtual void SetAlignment( int align
);
1522 Sets the owning wxDataViewColumn.
1523 This is usually called from within wxDataViewColumn.
1525 void SetOwner(wxDataViewColumn
* owner
);
1528 Set the value of the renderer (and thus its cell) to @a value.
1529 The internal code will then render this cell with this data.
1531 virtual bool SetValue(const wxVariant
& value
) = 0;
1534 Before data is committed to the data model, it is passed to this
1535 method where it can be checked for validity. This can also be
1536 used for checking a valid range or limiting the user input in
1537 a certain aspect (e.g. max number of characters or only alphanumeric
1538 input, ASCII only etc.). Return @false if the value is not valid.
1540 Please note that due to implementation limitations, this validation
1541 is done after the editing control already is destroyed and the
1542 editing process finished.
1544 virtual bool Validate(wxVariant
& value
);
1550 @class wxDataViewTextRenderer
1552 wxDataViewTextRenderer is used for rendering text.
1553 It supports in-place editing if desired.
1558 class wxDataViewTextRenderer
: public wxDataViewRenderer
1564 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1565 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1566 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1572 @class wxDataViewIconTextRenderer
1574 The wxDataViewIconTextRenderer class is used to display text with
1575 a small icon next to it as it is typically done in a file manager.
1577 This classes uses the wxDataViewIconText helper class to store its data.
1578 wxDataViewIconText can be converted to and from a wxVariant using the left
1584 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1590 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1591 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1592 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1598 @class wxDataViewProgressRenderer
1600 This class is used by wxDataViewCtrl to render progress bars.
1605 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1611 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1612 const wxString
& varianttype
= "long",
1613 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1614 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1620 @class wxDataViewSpinRenderer
1622 This is a specialized renderer for rendering integer values.
1623 It supports modifying the values in-place by using a wxSpinCtrl.
1624 The renderer only support variants of type @e long.
1629 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1634 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1636 wxDataViewSpinRenderer(int min
, int max
,
1637 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1638 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1644 @class wxDataViewToggleRenderer
1646 This class is used by wxDataViewCtrl to render toggle controls.
1651 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1657 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1658 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1659 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1664 @class wxDataViewChoiceRenderer
1666 This class is used by wxDataViewCtrl to render choice controls.
1667 It stores a string so that SetValue() and GetValue() operate
1668 on a variant holding a string.
1674 class wxDataViewChoiceRenderer
: public wxDataViewRenderer
1680 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1681 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1682 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1685 Returns the choice referred to by index.
1687 wxString
GetChoice(size_t index
) const;
1690 Returns all choices.
1692 const wxArrayString
& GetChoices() const;
1697 @class wxDataViewDateRenderer
1699 This class is used by wxDataViewCtrl to render calendar controls.
1704 class wxDataViewDateRenderer
: public wxDataViewRenderer
1710 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1711 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1712 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1718 @class wxDataViewCustomRenderer
1720 You need to derive a new class from wxDataViewCustomRenderer in
1721 order to write a new renderer.
1723 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1724 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1726 If you want your renderer to support in-place editing then you also need to override
1727 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1728 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1730 Note that a special event handler will be pushed onto that editor control
1731 which handles @e \<ENTER\> and focus out events in order to end the editing.
1736 class wxDataViewCustomRenderer
: public wxDataViewRenderer
1742 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
1743 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1744 int align
= -1, bool no_init
= false);
1749 virtual ~wxDataViewCustomRenderer();
1752 Override this to react to cell @em activation. Activating a cell is an
1753 alternative to showing inline editor when the value can be edited in a
1754 simple way that doesn't warrant full editor control. The most typical
1755 use of cell activation is toggling the checkbox in
1756 wxDataViewToggleRenderer; others would be e.g. an embedded volume
1757 slider or a five-star rating column.
1759 The exact means of activating a cell are platform-dependent, but they
1760 are usually similar to those used for inline editing of values.
1761 Typically, a cell would be activated by Space or Enter keys or by left
1764 This method will only be called if the cell has the
1765 wxDATAVIEW_CELL_ACTIVATABLE mode.
1768 Coordinates of the activated cell's area.
1770 The model to manipulate in response.
1774 Activated column of @a item.
1776 If the activation was triggered by mouse click, contains the
1777 corresponding event. Is @NULL otherwise (for keyboard activation).
1778 Mouse coordinates are adjusted to be relative to the cell.
1782 @note Do not confuse this method with item activation in wxDataViewCtrl
1783 and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is
1784 used for activating the item (or, to put it differently, the
1785 entire row) similarly to analogous messages in wxTreeCtrl and
1786 wxListCtrl, and the effect differs (play a song, open a file
1787 etc.). Cell activation, on the other hand, is all about
1788 interacting with the individual cell.
1790 @see CreateEditorCtrl()
1792 virtual bool ActivateCell(const wxRect
& cell
,
1793 wxDataViewModel
* model
,
1794 const wxDataViewItem
& item
,
1796 const wxMouseEvent
*mouseEvent
);
1799 Override this to create the actual editor control once editing
1802 This method will only be called if the cell has the
1803 wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly
1804 double-clicking the cell or by a platform-dependent keyboard shortcut
1805 (F2 is typical on Windows, Space and/or Enter is common elsewhere and
1806 supported on Windows too).
1809 The parent of the editor control.
1811 Indicates the position and size of the editor control. The control
1812 should be created in place of the cell and @a labelRect should be
1813 respected as much as possible.
1815 Initial value of the editor.
1821 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1822 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1828 virtual wxWindow
* CreateEditorCtrl(wxWindow
* parent
,
1830 const wxVariant
& value
);
1833 Return the attribute to be used for rendering.
1835 This function may be called from Render() implementation to use the
1836 attributes defined for the item if the renderer supports them.
1838 Notice that when Render() is called, the wxDC object passed to it is
1839 already set up to use the correct attributes (e.g. its font is set to
1840 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
1841 returns true) so it may not be necessary to call it explicitly if you
1842 only want to render text using the items attributes.
1846 const wxDataViewItemAttr
& GetAttr() const;
1849 Return size required to show content.
1851 virtual wxSize
GetSize() const = 0;
1854 Override this so that the renderer can get the value from the editor
1855 control (pointed to by @a editor):
1858 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1859 long l = sc->GetValue();
1865 virtual bool GetValueFromEditorCtrl(wxWindow
* editor
,
1869 Override this and make it return @true in order to
1870 indicate that this renderer supports in-place editing.
1872 virtual bool HasEditorCtrl() const;
1875 Override this to react to a left click.
1876 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1878 virtual bool LeftClick( const wxPoint
& cursor
,
1880 wxDataViewModel
* model
,
1881 const wxDataViewItem
& item
,
1885 Override this to render the cell.
1886 Before this is called, wxDataViewRenderer::SetValue was called
1887 so that this instance knows what to render.
1889 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
1892 This method should be called from within Render() whenever you need to
1894 This will ensure that the correct colour, font and vertical alignment will
1895 be chosen so the text will look the same as text drawn by native renderers.
1897 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
1898 wxDC
* dc
, int state
);
1901 Override this to start a drag operation. Not yet supported.
1903 virtual bool StartDrag(const wxPoint
& cursor
,
1905 wxDataViewModel
* model
,
1906 const wxDataViewItem
& item
,
1913 @class wxDataViewBitmapRenderer
1915 This class is used by wxDataViewCtrl to render bitmap controls.
1920 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
1926 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
1927 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1928 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1933 The flags used by wxDataViewColumn.
1934 Can be combined together.
1936 enum wxDataViewColumnFlags
1938 wxDATAVIEW_COL_RESIZABLE
= 1,
1939 wxDATAVIEW_COL_SORTABLE
= 2,
1940 wxDATAVIEW_COL_REORDERABLE
= 4,
1941 wxDATAVIEW_COL_HIDDEN
= 8
1945 @class wxDataViewColumn
1947 This class represents a column in a wxDataViewCtrl.
1948 One wxDataViewColumn is bound to one column in the data model to which the
1949 wxDataViewCtrl has been associated.
1951 An instance of wxDataViewRenderer is used by this class to render its data.
1956 class wxDataViewColumn
: public wxSettableHeaderColumn
1960 Constructs a text column.
1963 The title of the column.
1965 The class which will render the contents of this column.
1967 The index of the model's column which is associated with this object.
1969 The width of the column.
1970 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1972 The alignment of the column title.
1974 One or more flags of the ::wxDataViewColumnFlags enumeration.
1976 wxDataViewColumn(const wxString
& title
,
1977 wxDataViewRenderer
* renderer
,
1978 unsigned int model_column
,
1979 int width
= wxDVC_DEFAULT_WIDTH
,
1980 wxAlignment align
= wxALIGN_CENTER
,
1981 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1984 Constructs a bitmap column.
1987 The bitmap of the column.
1989 The class which will render the contents of this column.
1991 The index of the model's column which is associated with this object.
1993 The width of the column.
1994 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1996 The alignment of the column title.
1998 One or more flags of the ::wxDataViewColumnFlags enumeration.
2000 wxDataViewColumn(const wxBitmap
& bitmap
,
2001 wxDataViewRenderer
* renderer
,
2002 unsigned int model_column
,
2003 int width
= wxDVC_DEFAULT_WIDTH
,
2004 wxAlignment align
= wxALIGN_CENTER
,
2005 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2008 Returns the index of the column of the model, which this
2009 wxDataViewColumn is displaying.
2011 unsigned int GetModelColumn() const;
2014 Returns the owning wxDataViewCtrl.
2016 wxDataViewCtrl
* GetOwner() const;
2019 Returns the renderer of this wxDataViewColumn.
2021 @see wxDataViewRenderer.
2023 wxDataViewRenderer
* GetRenderer() const;
2029 @class wxDataViewListCtrl
2031 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
2032 and forwards most of its API to that class.
2034 The purpose of this class is to offer a simple way to display and
2035 edit a small table of data without having to write your own wxDataViewModel.
2038 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
2040 listctrl->AppendToggleColumn( "Toggle" );
2041 listctrl->AppendTextColumn( "Text" );
2043 wxVector<wxVariant> data;
2044 data.push_back( wxVariant(true) );
2045 data.push_back( wxVariant("row 1") );
2046 listctrl->AppendItem( data );
2049 data.push_back( wxVariant(false) );
2050 data.push_back( wxVariant("row 3") );
2051 listctrl->AppendItem( data );
2055 See wxDataViewCtrl for the list of supported styles.
2058 @beginEventEmissionTable
2059 See wxDataViewCtrl for the list of events emitted by this class.
2065 class wxDataViewListCtrl
: public wxDataViewCtrl
2071 wxDataViewListCtrl();
2074 Constructor. Calls Create().
2076 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
2077 const wxPoint
& pos
= wxDefaultPosition
,
2078 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
2079 const wxValidator
& validator
= wxDefaultValidator
);
2082 Destructor. Deletes the image list if any.
2084 ~wxDataViewListCtrl();
2087 Creates the control and a wxDataViewListStore as its internal model.
2089 bool Create( wxWindow
*parent
, wxWindowID id
,
2090 const wxPoint
& pos
= wxDefaultPosition
,
2091 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
2092 const wxValidator
& validator
= wxDefaultValidator
);
2098 wxDataViewListStore
*GetStore();
2099 const wxDataViewListStore
*GetStore() const;
2103 Returns the position of given @e item or wxNOT_FOUND if it's
2108 int ItemToRow(const wxDataViewItem
&item
) const;
2111 Returns the wxDataViewItem at the given @e row.
2115 wxDataViewItem
RowToItem(int row
) const;
2119 @name Selection handling functions
2123 Returns index of the selected row or wxNOT_FOUND.
2125 @see wxDataViewCtrl::GetSelection()
2129 int GetSelectedRow() const;
2134 @see wxDataViewCtrl::Select()
2138 void SelectRow(unsigned row
);
2141 Unselects given row.
2143 @see wxDataViewCtrl::Unselect()
2147 void UnselectRow(unsigned row
);
2150 Returns true if @a row is selected.
2152 @see wxDataViewCtrl::IsSelected()
2156 bool IsRowSelected(unsigned row
) const;
2161 @name Column management functions
2166 Appends a column to the control and additionally appends a
2167 column to the store with the type string.
2169 virtual void AppendColumn( wxDataViewColumn
*column
);
2172 Appends a column to the control and additionally appends a
2173 column to the list store with the type @a varianttype.
2175 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
2178 Appends a text column to the control and the store.
2180 See wxDataViewColumn::wxDataViewColumn for more info about
2183 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
2184 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2185 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2186 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2189 Appends a toggle column to the control and the store.
2191 See wxDataViewColumn::wxDataViewColumn for more info about
2194 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
2195 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
2196 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2197 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2200 Appends a progress column to the control and the store.
2202 See wxDataViewColumn::wxDataViewColumn for more info about
2205 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
2206 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2207 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2208 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2211 Appends an icon-and-text column to the control and the store.
2213 See wxDataViewColumn::wxDataViewColumn for more info about
2216 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
2217 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2218 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2219 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2222 Inserts a column to the control and additionally inserts a
2223 column to the store with the type string.
2225 virtual void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
2228 Inserts a column to the control and additionally inserts a
2229 column to the list store with the type @a varianttype.
2231 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
,
2232 const wxString
&varianttype
);
2235 Prepends a column to the control and additionally prepends a
2236 column to the store with the type string.
2238 virtual void PrependColumn( wxDataViewColumn
*column
);
2241 Prepends a column to the control and additionally prepends a
2242 column to the list store with the type @a varianttype.
2244 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
2250 @name Item management functions
2255 Appends an item (=row) to the control and store.
2257 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2260 Prepends an item (=row) to the control and store.
2262 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2265 Inserts an item (=row) to the control and store.
2267 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2270 Delete the row at position @a row.
2272 void DeleteItem( unsigned row
);
2275 Delete all items (= all rows).
2277 void DeleteAllItems();
2280 Sets the value in the store and update the control.
2282 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
2285 Returns the value from the store.
2287 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
2290 Sets the value in the store and update the control.
2292 This method assumes that the string is stored in respective
2295 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
2298 Returns the value from the store.
2300 This method assumes that the string is stored in respective
2303 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
2306 Sets the value in the store and update the control.
2308 This method assumes that the boolean value is stored in
2311 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
2314 Returns the value from the store.
2316 This method assumes that the boolean value is stored in
2319 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
2326 @class wxDataViewTreeCtrl
2328 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
2329 and forwards most of its API to that class.
2330 Additionally, it uses a wxImageList to store a list of icons.
2332 The main purpose of this class is to provide a simple upgrade path for code
2336 See wxDataViewCtrl for the list of supported styles.
2339 @beginEventEmissionTable
2340 See wxDataViewCtrl for the list of events emitted by this class.
2345 @appearance{dataviewtreectrl.png}
2347 class wxDataViewTreeCtrl
: public wxDataViewCtrl
2353 wxDataViewTreeCtrl();
2360 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
2361 const wxPoint
& pos
= wxDefaultPosition
,
2362 const wxSize
& size
= wxDefaultSize
,
2363 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2364 const wxValidator
& validator
= wxDefaultValidator
);
2367 Destructor. Deletes the image list if any.
2369 virtual ~wxDataViewTreeCtrl();
2372 Appends a container to the given @a parent.
2374 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2375 const wxString
& text
,
2378 wxClientData
* data
= NULL
);
2381 Appends an item to the given @a parent.
2383 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2384 const wxString
& text
,
2386 wxClientData
* data
= NULL
);
2389 Creates the control and a wxDataViewTreeStore as its internal model.
2391 The default tree column created by this method is an editable column
2392 using wxDataViewIconTextRenderer as its renderer.
2394 bool Create(wxWindow
* parent
, wxWindowID id
,
2395 const wxPoint
& pos
= wxDefaultPosition
,
2396 const wxSize
& size
= wxDefaultSize
,
2397 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2398 const wxValidator
& validator
= wxDefaultValidator
);
2401 Calls the identical method from wxDataViewTreeStore.
2403 void DeleteAllItems();
2406 Calls the identical method from wxDataViewTreeStore.
2408 void DeleteChildren(const wxDataViewItem
& item
);
2411 Calls the identical method from wxDataViewTreeStore.
2413 void DeleteItem(const wxDataViewItem
& item
);
2416 Calls the identical method from wxDataViewTreeStore.
2418 int GetChildCount(const wxDataViewItem
& parent
) const;
2421 Returns the image list.
2423 wxImageList
* GetImageList();
2426 Calls the identical method from wxDataViewTreeStore.
2428 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2431 Calls the identical method from wxDataViewTreeStore.
2433 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2436 Calls the identical method from wxDataViewTreeStore.
2438 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2441 Calls the identical method from wxDataViewTreeStore.
2443 wxString
GetItemText(const wxDataViewItem
& item
) const;
2446 Calls the identical method from wxDataViewTreeStore.
2448 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2449 unsigned int pos
) const;
2455 wxDataViewTreeStore
* GetStore();
2456 const wxDataViewTreeStore
* GetStore() const;
2460 Calls the same method from wxDataViewTreeStore but uses
2461 an index position in the image list instead of a wxIcon.
2463 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2464 const wxDataViewItem
& previous
,
2465 const wxString
& text
,
2468 wxClientData
* data
= NULL
);
2471 Calls the same method from wxDataViewTreeStore but uses
2472 an index position in the image list instead of a wxIcon.
2474 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2475 const wxDataViewItem
& previous
,
2476 const wxString
& text
,
2478 wxClientData
* data
= NULL
);
2481 Returns true if item is a container.
2483 bool IsContainer( const wxDataViewItem
& item
);
2486 Calls the same method from wxDataViewTreeStore but uses
2487 an index position in the image list instead of a wxIcon.
2489 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2490 const wxString
& text
,
2493 wxClientData
* data
= NULL
);
2496 Calls the same method from wxDataViewTreeStore but uses
2497 an index position in the image list instead of a wxIcon.
2499 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2500 const wxString
& text
,
2502 wxClientData
* data
= NULL
);
2505 Sets the image list.
2507 void SetImageList(wxImageList
* imagelist
);
2510 Calls the identical method from wxDataViewTreeStore.
2512 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2515 Calls the identical method from wxDataViewTreeStore.
2517 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2518 const wxIcon
& icon
);
2521 Calls the identical method from wxDataViewTreeStore.
2523 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2526 Calls the identical method from wxDataViewTreeStore.
2528 void SetItemText(const wxDataViewItem
& item
,
2529 const wxString
& text
);
2534 @class wxDataViewListStore
2536 wxDataViewListStore is a specialised wxDataViewModel for storing
2537 a simple table of data. Since it derives from wxDataViewIndexListModel
2538 its data is be accessed by row (i.e. by index) instead of only
2541 This class actually stores the values (therefore its name)
2542 and implements all virtual methods from the base classes so it can be
2543 used directly without having to derive any class from it, but it is
2544 mostly used from within wxDataViewListCtrl.
2550 class wxDataViewListStore
: public wxDataViewIndexListModel
2556 wxDataViewListStore();
2561 ~wxDataViewListStore();
2564 Prepends a data column.
2566 @a variantype indicates the type of values store in the column.
2568 This does not automatically fill in any (default) values in
2569 rows which exist in the store already.
2571 void PrependColumn( const wxString
&varianttype
);
2574 Inserts a data column before @a pos.
2576 @a variantype indicates the type of values store in the column.
2578 This does not automatically fill in any (default) values in
2579 rows which exist in the store already.
2581 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
2584 Appends a data column.
2586 @a variantype indicates the type of values store in the column.
2588 This does not automatically fill in any (default) values in
2589 rows which exist in the store already.
2591 void AppendColumn( const wxString
&varianttype
);
2594 Appends an item (=row) and fills it with @a values.
2596 The values must match the values specifies in the column
2597 in number and type. No (default) values are filled in
2600 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2603 Prepends an item (=row) and fills it with @a values.
2605 The values must match the values specifies in the column
2606 in number and type. No (default) values are filled in
2609 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2612 Inserts an item (=row) and fills it with @a values.
2614 The values must match the values specifies in the column
2615 in number and type. No (default) values are filled in
2618 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
2621 Delete the item (=row) at position @a pos.
2623 void DeleteItem( unsigned pos
);
2626 Delete all item (=all rows) in the store.
2628 void DeleteAllItems();
2631 Overridden from wxDataViewModel
2633 virtual unsigned int GetColumnCount() const;
2636 Overridden from wxDataViewModel
2638 virtual wxString
GetColumnType( unsigned int col
) const;
2641 Overridden from wxDataViewIndexListModel
2643 virtual void GetValueByRow( wxVariant
&value
,
2644 unsigned int row
, unsigned int col
) const;
2647 Overridden from wxDataViewIndexListModel
2649 virtual bool SetValueByRow( const wxVariant
&value
,
2650 unsigned int row
, unsigned int col
);
2655 @class wxDataViewTreeStore
2657 wxDataViewTreeStore is a specialised wxDataViewModel for storing simple
2658 trees very much like wxTreeCtrl does and it offers a similar API.
2660 This class actually stores the entire tree and the values (therefore its name)
2661 and implements all virtual methods from the base class so it can be used directly
2662 without having to derive any class from it, but it is mostly used from within
2668 class wxDataViewTreeStore
: public wxDataViewModel
2672 Constructor. Creates the invisible root node internally.
2674 wxDataViewTreeStore();
2679 virtual ~wxDataViewTreeStore();
2684 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2685 const wxString
& text
,
2686 const wxIcon
& icon
= wxNullIcon
,
2687 const wxIcon
& expanded
= wxNullIcon
,
2688 wxClientData
* data
= NULL
);
2693 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2694 const wxString
& text
,
2695 const wxIcon
& icon
= wxNullIcon
,
2696 wxClientData
* data
= NULL
);
2699 Delete all item in the model.
2701 void DeleteAllItems();
2704 Delete all children of the item, but not the item itself.
2706 void DeleteChildren(const wxDataViewItem
& item
);
2711 void DeleteItem(const wxDataViewItem
& item
);
2714 Return the number of children of item.
2716 int GetChildCount(const wxDataViewItem
& parent
) const;
2719 Returns the client data associated with the item.
2721 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2724 Returns the icon to display in expanded containers.
2726 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2729 Returns the icon of the item.
2731 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2734 Returns the text of the item.
2736 wxString
GetItemText(const wxDataViewItem
& item
) const;
2739 Returns the nth child item of item.
2741 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2742 unsigned int pos
) const;
2745 Inserts a container after @a previous.
2747 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2748 const wxDataViewItem
& previous
,
2749 const wxString
& text
,
2750 const wxIcon
& icon
= wxNullIcon
,
2751 const wxIcon
& expanded
= wxNullIcon
,
2752 wxClientData
* data
= NULL
);
2755 Inserts an item after @a previous.
2757 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2758 const wxDataViewItem
& previous
,
2759 const wxString
& text
,
2760 const wxIcon
& icon
= wxNullIcon
,
2761 wxClientData
* data
= NULL
);
2764 Inserts a container before the first child item or @a parent.
2766 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2767 const wxString
& text
,
2768 const wxIcon
& icon
= wxNullIcon
,
2769 const wxIcon
& expanded
= wxNullIcon
,
2770 wxClientData
* data
= NULL
);
2773 Inserts an item before the first child item or @a parent.
2775 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2776 const wxString
& text
,
2777 const wxIcon
& icon
= wxNullIcon
,
2778 wxClientData
* data
= NULL
);
2781 Sets the client data associated with the item.
2783 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2786 Sets the expanded icon for the item.
2788 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2789 const wxIcon
& icon
);
2792 Sets the icon for the item.
2794 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2799 @class wxDataViewIconText
2801 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2802 This class can be converted to and from a wxVariant.
2807 class wxDataViewIconText
: public wxObject
2814 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
2815 const wxIcon
& icon
= wxNullIcon
);
2816 wxDataViewIconText(const wxDataViewIconText
& other
);
2822 const wxIcon
& GetIcon() const;
2827 wxString
GetText() const;
2832 void SetIcon(const wxIcon
& icon
);
2837 void SetText(const wxString
& text
);
2843 @class wxDataViewEvent
2845 This is the event class for the wxDataViewCtrl notifications.
2847 @beginEventTable{wxDataViewEvent}
2848 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2849 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2850 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2851 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2852 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2853 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2854 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2855 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2856 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2857 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2858 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2859 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2860 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2861 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2862 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2863 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2864 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2865 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2866 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2867 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2868 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2869 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2870 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2871 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2872 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2873 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2874 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2875 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2876 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2877 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2878 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2879 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2880 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2881 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2882 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
2883 Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
2887 @category{events,dvc}
2889 class wxDataViewEvent
: public wxNotifyEvent
2893 Constructor. Typically used by wxWidgets internals only.
2895 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
2899 Returns the position of the column in the control or -1
2900 if no column field was set by the event emitter.
2902 int GetColumn() const;
2905 Returns a pointer to the wxDataViewColumn from which
2906 the event was emitted or @NULL.
2908 wxDataViewColumn
* GetDataViewColumn() const;
2911 Returns the wxDataViewModel associated with the event.
2913 wxDataViewModel
* GetModel() const;
2916 Returns the position of a context menu event in screen coordinates.
2918 wxPoint
GetPosition() const;
2921 Returns a reference to a value.
2923 const wxVariant
& GetValue() const;
2926 Can be used to determine whether the new value is going to be accepted
2927 in wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE handler.
2929 Returns @true if editing the item was cancelled or if the user tried to
2930 enter an invalid value (refused by wxDataViewRenderer::Validate()). If
2931 this method returns @false, it means that the value in the model is
2932 about to be changed to the new one.
2934 Notice that wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event handler can
2935 call wxNotifyEvent::Veto() to prevent this from happening.
2937 Currently support for setting this field and for vetoing the change is
2938 only available in the generic version of wxDataViewCtrl, i.e. under MSW
2939 but not GTK nor OS X.
2943 bool IsEditCancelled() const;
2946 Sets the column index associated with this event.
2948 void SetColumn(int col
);
2951 For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2953 void SetDataViewColumn(wxDataViewColumn
* col
);
2956 Sets the dataview model associated with this event.
2958 void SetModel(wxDataViewModel
* model
);
2961 Sets the value associated with this event.
2963 void SetValue(const wxVariant
& value
);
2966 Set wxDataObject for data transfer within a drag operation.
2968 void SetDataObject( wxDataObject
*obj
);
2971 Used internally. Gets associated wxDataObject for data transfer
2972 within a drag operation.
2974 wxDataObject
*GetDataObject() const;
2977 Used internally. Sets the wxDataFormat during a drop operation.
2979 void SetDataFormat( const wxDataFormat
&format
);
2982 Gets the wxDataFormat during a drop operation.
2984 wxDataFormat
GetDataFormat() const;
2987 Used internally. Sets the data size for a drop data transfer.
2989 void SetDataSize( size_t size
);
2992 Gets the data size for a drop data transfer.
2994 size_t GetDataSize() const;
2997 Used internally. Sets the data buffer for a drop data transfer.
2999 void SetDataBuffer( void* buf
);
3002 Gets the data buffer for a drop data transfer.
3004 void *GetDataBuffer() const;
3007 Return the first row that will be displayed.
3009 int GetCacheFrom() const;
3012 Return the last row that will be displayed.
3014 int GetCacheTo() const;