1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
10 @class wxDataViewModel
12 wxDataViewModel is the base class for all data model to be displayed by a
15 All other models derive from it and must implement its pure virtual functions
16 in order to define a complete data model. In detail, you need to override
17 wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren,
18 wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and
19 wxDataViewModel::GetValue in order to define the data model which acts as an
20 interface between your actual data and the wxDataViewCtrl.
22 Note that wxDataViewModel does not define the position or index of any item
23 in the control because different controls might display the same data differently.
24 wxDataViewModel does provide a wxDataViewModel::Compare method which the
25 wxDataViewCtrl may use to sort the data either in conjunction with a column
26 header or without (see wxDataViewModel::HasDefaultCompare).
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. To a certain extent,
31 you can use (the somewhat more elegant) wxAny instead of wxVariant as there
32 is code to convert between the two, but it is unclear what impact this will
35 Since you will usually allow the wxDataViewCtrl to change your data
36 through its graphical interface, you will also have to override
37 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
38 to some data has been committed.
40 If the data represented by the model is changed by something else than its
41 associated wxDataViewCtrl, the control has to be notified about the change.
42 Depending on what happened you need to call one of the following methods:
43 - wxDataViewModel::ValueChanged,
44 - wxDataViewModel::ItemAdded,
45 - wxDataViewModel::ItemDeleted,
46 - wxDataViewModel::ItemChanged,
47 - wxDataViewModel::Cleared.
49 There are plural forms for notification of addition, change or removal of
50 several item at once. See:
51 - wxDataViewModel::ItemsAdded,
52 - wxDataViewModel::ItemsDeleted,
53 - wxDataViewModel::ItemsChanged.
55 This class maintains a list of wxDataViewModelNotifier which link this class
56 to the specific implementations on the supported platforms so that e.g. calling
57 wxDataViewModel::ValueChanged on this model will just call
58 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
59 You can also add your own notifier in order to get informed about any changes
60 to the data in the list model.
62 Currently wxWidgets provides the following models apart from the base model:
63 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
66 Note that wxDataViewModel is reference counted, derives from wxRefCounter
67 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
68 This implies that you need to decrease the reference count after
69 associating the model with a control like this:
72 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
73 wxDataViewModel *musicModel = new MyMusicModel;
74 m_musicCtrl->AssociateModel( musicModel );
75 musicModel->DecRef(); // avoid memory leak !!
80 A potentially better way to avoid memory leaks is to use wxObjectDataPtr
83 wxObjectDataPtr<MyMusicModel> musicModel;
85 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
86 musicModel = new MyMusicModel;
87 m_musicCtrl->AssociateModel( musicModel.get() );
96 class wxDataViewModel
: public wxRefCounter
105 Adds a wxDataViewModelNotifier to the model.
107 void AddNotifier(wxDataViewModelNotifier
* notifier
);
110 Change the value of the given item and update the control to reflect
113 This function simply calls SetValue() and, if it succeeded,
121 The item (row) to update.
123 The column to update.
125 @true if both SetValue() and ValueChanged() returned @true.
127 bool ChangeValue(const wxVariant
& variant
,
128 const wxDataViewItem
& item
,
132 Called to inform the model that all data has been cleared.
133 The control will reread the data from the model again.
135 virtual bool Cleared();
138 The compare function to be used by control. The default compare function
139 sorts by container and other items separately and in ascending order.
140 Override this for a different sorting behaviour.
142 @see HasDefaultCompare().
144 virtual int Compare(const wxDataViewItem
& item1
,
145 const wxDataViewItem
& item2
,
147 bool ascending
) const;
150 Override this to indicate that the item has special font attributes.
151 This only affects the wxDataViewTextRendererText renderer.
153 The base class version always simply returns @false.
155 @see wxDataViewItemAttr.
158 The item for which the attribute is requested.
160 The column of the item for which the attribute is requested.
162 The attribute to be filled in if the function returns @true.
164 @true if this item has an attribute or @false otherwise.
166 virtual bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
167 wxDataViewItemAttr
& attr
) const;
170 Override this to indicate that the item should be disabled.
172 Disabled items are displayed differently (e.g. grayed out) and cannot
175 The base class version always returns @true, thus making all items
179 The item whose enabled status is requested.
181 The column of the item whose enabled status is requested.
183 @true if this item should be enabled, @false otherwise.
185 @note Currently disabling items is not supported by the wxOSX/Carbon
190 virtual bool IsEnabled(const wxDataViewItem
&item
,
191 unsigned int col
) const;
194 Override this so the control can query the child items of an item.
195 Returns the number of items.
197 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
198 wxDataViewItemArray
& children
) const = 0;
201 Override this to indicate the number of columns in the model.
203 virtual unsigned int GetColumnCount() const = 0;
206 Override this to indicate what type of data is stored in the
207 column specified by @a col.
209 This should return a string indicating the type of data as reported by wxVariant.
211 virtual wxString
GetColumnType(unsigned int col
) const = 0;
214 Override this to indicate which wxDataViewItem representing the parent
215 of @a item or an invalid wxDataViewItem if the root item is
218 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const = 0;
221 Override this to indicate the value of @a item.
222 A wxVariant is used to store the data.
224 virtual void GetValue(wxVariant
& variant
, const wxDataViewItem
& item
,
225 unsigned int col
) const = 0;
228 Override this method to indicate if a container item merely acts as a
229 headline (or for categorisation) or if it also acts a normal item with
230 entries for further columns. By default returns @false.
232 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
235 Override this to indicate that the model provides a default compare
236 function that the control should use if no wxDataViewColumn has been
237 chosen for sorting. Usually, the user clicks on a column header for
238 sorting, the data will be sorted alphanumerically.
240 If any other order (e.g. by index or order of appearance) is required,
241 then this should be used.
242 See wxDataViewIndexListModel for a model which makes use of this.
244 virtual bool HasDefaultCompare() const;
247 Return true if there is a value in the given column of this item.
249 All normal items have values in all columns but the container items
250 only show their label in the first column (@a col == 0) by default (but
251 see HasContainerColumns()). So this function always returns true for
252 the first column while for the other ones it returns true only if the
253 item is not a container or HasContainerColumns() was overridden to
258 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const;
261 Override this to indicate of @a item is a container, i.e.\ if
262 it can have child items.
264 virtual bool IsContainer(const wxDataViewItem
& item
) const = 0;
267 Call this to inform the model that an item has been added to the data.
269 bool ItemAdded(const wxDataViewItem
& parent
,
270 const wxDataViewItem
& item
);
273 Call this to inform the model that an item has changed.
275 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
276 event (in which the column fields will not be set) to the user.
278 bool ItemChanged(const wxDataViewItem
& item
);
281 Call this to inform the model that an item has been deleted from the data.
283 bool ItemDeleted(const wxDataViewItem
& parent
,
284 const wxDataViewItem
& item
);
287 Call this to inform the model that several items have been added to the data.
289 bool ItemsAdded(const wxDataViewItem
& parent
,
290 const wxDataViewItemArray
& items
);
293 Call this to inform the model that several items have changed.
295 This will eventually emit @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
296 events (in which the column fields will not be set) to the user.
298 bool ItemsChanged(const wxDataViewItemArray
& items
);
301 Call this to inform the model that several items have been deleted.
303 bool ItemsDeleted(const wxDataViewItem
& parent
,
304 const wxDataViewItemArray
& items
);
307 Remove the @a notifier from the list of notifiers.
309 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
312 Call this to initiate a resort after the sort function has been changed.
314 virtual void Resort();
317 This gets called in order to set a value in the data model.
319 The most common scenario is that the wxDataViewCtrl calls this method
320 after the user changed some data in the view.
322 This is the function you need to override in your derived class but if
323 you want to call it, ChangeValue() is usually more convenient as
324 otherwise you need to manually call ValueChanged() to update the
327 virtual bool SetValue(const wxVariant
& variant
,
328 const wxDataViewItem
& item
,
329 unsigned int col
) = 0;
332 Call this to inform this model that a value in the model has been changed.
333 This is also called from wxDataViewCtrl's internal editing code, e.g. when
334 editing a text field in the control.
336 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
339 virtual bool ValueChanged(const wxDataViewItem
& item
,
343 virtual bool IsListModel() const;
344 virtual bool IsVirtualListModel() const;
349 Destructor. This should not be called directly. Use DecRef() instead.
351 virtual ~wxDataViewModel();
357 @class wxDataViewListModel
359 Base class with abstract API for wxDataViewIndexListModel and
360 wxDataViewVirtualListModel.
365 class wxDataViewListModel
: public wxDataViewModel
372 virtual ~wxDataViewListModel();
375 Compare method that sorts the items by their index.
377 int Compare(const wxDataViewItem
& item1
,
378 const wxDataViewItem
& item2
,
379 unsigned int column
, bool ascending
) const;
382 Override this to indicate that the row has special font attributes.
383 This only affects the wxDataViewTextRendererText() renderer.
385 The base class version always simply returns @false.
387 @see wxDataViewItemAttr.
390 The row for which the attribute is requested.
392 The column for which the attribute is requested.
394 The attribute to be filled in if the function returns @true.
396 @true if this item has an attribute or @false otherwise.
398 virtual bool GetAttrByRow(unsigned int row
, unsigned int col
,
399 wxDataViewItemAttr
& attr
) const;
402 Override this if you want to disable specific items.
404 The base class version always returns @true, thus making all items
408 The row of the item whose enabled status is requested.
410 The column of the item whose enabled status is requested.
412 @true if the item at this row and column should be enabled,
415 @note See wxDataViewModel::IsEnabled() for the current status of
416 support for disabling the items under different platforms.
420 virtual bool IsEnabledByRow(unsigned int row
,
421 unsigned int col
) const;
424 Returns the number of items (or rows) in the list.
426 unsigned int GetCount() const = 0;
429 Returns the position of given @e item.
431 unsigned int GetRow(const wxDataViewItem
& item
) const = 0;
434 Override this to allow getting values from the model.
436 virtual void GetValueByRow(wxVariant
& variant
, unsigned int row
,
437 unsigned int col
) const = 0;
440 Called in order to set a value in the model.
442 virtual bool SetValueByRow(const wxVariant
& variant
, unsigned int row
,
443 unsigned int col
) = 0;
448 @class wxDataViewIndexListModel
450 wxDataViewIndexListModel is a specialized data model which lets you address
451 an item by its position (row) rather than its wxDataViewItem (which you can
452 obtain from this class).
453 This model also provides its own wxDataViewIndexListModel::Compare
454 method which sorts the model's data by the index.
456 This model is not a virtual model since the control stores each wxDataViewItem.
457 Use wxDataViewVirtualListModel if you need to display millions of items or
458 have other reason to use a virtual control.
460 @see wxDataViewListModel for the API.
466 class wxDataViewIndexListModel
: public wxDataViewListModel
472 wxDataViewIndexListModel(unsigned int initial_size
= 0);
475 Returns the wxDataViewItem at the given @e row.
477 wxDataViewItem
GetItem(unsigned int row
) const;
480 Call this after if the data has to be read again from the model.
481 This is useful after major changes when calling the methods below
482 (possibly thousands of times) doesn't make sense.
484 void Reset(unsigned int new_size
);
487 Call this after a row has been appended to the model.
492 Call this after a row has been changed.
494 void RowChanged(unsigned int row
);
497 Call this after a row has been deleted.
499 void RowDeleted(unsigned int row
);
502 Call this after a row has been inserted at the given position.
504 void RowInserted(unsigned int before
);
507 Call this after a row has been prepended to the model.
512 Call this after a value has been changed.
514 void RowValueChanged(unsigned int row
, unsigned int col
);
517 Call this after rows have been deleted.
518 The array will internally get copied and sorted in descending order so
519 that the rows with the highest position will be deleted first.
521 void RowsDeleted(const wxArrayInt
& rows
);
526 @class wxDataViewVirtualListModel
528 wxDataViewVirtualListModel is a specialized data model which lets you address
529 an item by its position (row) rather than its wxDataViewItem and as such offers
530 the exact same interface as wxDataViewIndexListModel.
531 The important difference is that under platforms other than OS X, using this
532 model will result in a truly virtual control able to handle millions of items
533 as the control doesn't store any item (a feature not supported by OS X).
535 @see wxDataViewListModel for the API.
541 class wxDataViewVirtualListModel
: public wxDataViewListModel
547 wxDataViewVirtualListModel(unsigned int initial_size
= 0);
550 Returns the wxDataViewItem at the given @e row.
552 wxDataViewItem
GetItem(unsigned int row
) const;
555 Call this after if the data has to be read again from the model.
556 This is useful after major changes when calling the methods below
557 (possibly thousands of times) doesn't make sense.
559 void Reset(unsigned int new_size
);
562 Call this after a row has been appended to the model.
567 Call this after a row has been changed.
569 void RowChanged(unsigned int row
);
572 Call this after a row has been deleted.
574 void RowDeleted(unsigned int row
);
577 Call this after a row has been inserted at the given position.
579 void RowInserted(unsigned int before
);
582 Call this after a row has been prepended to the model.
587 Call this after a value has been changed.
589 void RowValueChanged(unsigned int row
, unsigned int col
);
592 Call this after rows have been deleted.
593 The array will internally get copied and sorted in descending order so
594 that the rows with the highest position will be deleted first.
596 void RowsDeleted(const wxArrayInt
& rows
);
603 @class wxDataViewItemAttr
605 This class is used to indicate to a wxDataViewCtrl that a certain item
606 (see wxDataViewItem) has extra font attributes for its renderer.
607 For this, it is required to override wxDataViewModel::GetAttr.
609 Attributes are currently only supported by wxDataViewTextRendererText.
614 class wxDataViewItemAttr
620 wxDataViewItemAttr();
623 Call this to indicate that the item shall be displayed in bold text.
625 void SetBold(bool set
);
628 Call this to indicate that the item shall be displayed with that colour.
630 void SetColour(const wxColour
& colour
);
633 Call this to set the background colour to use.
635 Currently this attribute is only supported in the generic version of
636 wxDataViewCtrl and ignored by the native GTK+ and OS X implementations.
640 void SetBackgroundColour(const wxColour
& colour
);
643 Call this to indicate that the item shall be displayed in italic text.
645 void SetItalic(bool set
);
649 Returns true if the colour property has been set.
651 bool HasColour() const;
654 Returns this attribute's colour.
656 const wxColour
& GetColour() const;
659 Returns true if any property affecting the font has been set.
661 bool HasFont() const;
664 Returns value of the bold property.
666 bool GetBold() const;
669 Returns value of the italics property.
671 bool GetItalic() const;
674 Returns true if the background colour property has been set.
676 bool HasBackgroundColour() const;
679 Returns the colour to be used for the background.
681 const wxColour
& GetBackgroundColour() const;
684 Returns true if none of the properties have been set.
686 bool IsDefault() const;
689 Return the font based on the given one with this attribute applied to it.
691 wxFont
GetEffectiveFont(const wxFont
& font
) const;
697 @class wxDataViewItem
699 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
700 in a persistent way, i.e. independent of the position of the item in the control
701 or changes to its contents.
703 It must hold a unique ID of type @e void* in its only field and can be converted
706 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
707 return @false which used in many places in the API of wxDataViewCtrl to
708 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
709 the invisible root. Examples for this are wxDataViewModel::GetParent and
710 wxDataViewModel::GetChildren.
723 wxDataViewItem(const wxDataViewItem
& item
);
724 explicit wxDataViewItem(void* id
);
733 Returns @true if the ID is not @NULL.
739 // ----------------------------------------------------------------------------
740 // wxDataViewCtrl flags
741 // ----------------------------------------------------------------------------
743 // size of a wxDataViewRenderer without contents:
744 #define wxDVC_DEFAULT_RENDERER_SIZE 20
746 // the default width of new (text) columns:
747 #define wxDVC_DEFAULT_WIDTH 80
749 // the default width of new toggle columns:
750 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
752 // the default minimal width of the columns:
753 #define wxDVC_DEFAULT_MINWIDTH 30
755 // The default alignment of wxDataViewRenderers is to take
756 // the alignment from the column it owns.
757 #define wxDVR_DEFAULT_ALIGNMENT -1
759 #define wxDV_SINGLE 0x0000 // for convenience
760 #define wxDV_MULTIPLE 0x0001 // can select multiple items
762 #define wxDV_NO_HEADER 0x0002 // column titles not visible
763 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
764 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
766 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
767 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
771 wxEventType wxEVT_DATAVIEW_SELECTION_CHANGED
;
773 wxEventType wxEVT_DATAVIEW_ITEM_ACTIVATED
;
774 wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSING
;
775 wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSED
;
776 wxEventType wxEVT_DATAVIEW_ITEM_EXPANDING
;
777 wxEventType wxEVT_DATAVIEW_ITEM_EXPANDED
;
778 wxEventType wxEVT_DATAVIEW_ITEM_START_EDITING
;
779 wxEventType wxEVT_DATAVIEW_ITEM_EDITING_STARTED
;
780 wxEventType wxEVT_DATAVIEW_ITEM_EDITING_DONE
;
781 wxEventType wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
;
783 wxEventType wxEVT_DATAVIEW_ITEM_CONTEXT_MENU
;
785 wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_CLICK
;
786 wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
787 wxEventType wxEVT_DATAVIEW_COLUMN_SORTED
;
788 wxEventType wxEVT_DATAVIEW_COLUMN_REORDERED
;
789 wxEventType wxEVT_DATAVIEW_CACHE_HINT
;
791 wxEventType wxEVT_DATAVIEW_ITEM_BEGIN_DRAG
;
792 wxEventType wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE
;
793 wxEventType wxEVT_DATAVIEW_ITEM_DROP
;
796 @class wxDataViewCtrl
798 wxDataViewCtrl is a control to display data either in a tree like fashion or
799 in a tabular form or both.
801 If you only need to display a simple tree structure with an API more like the
802 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
803 Likewise, if you only want to display simple table structure you can use
804 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
805 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
807 A wxDataViewItem is used to represent a (visible) item in the control.
809 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
810 virtual functions or by setting it directly. Instead you need to write your own
811 wxDataViewModel and associate it with this control.
812 Then you need to add a number of wxDataViewColumn to this control to define
813 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
814 of a wxDataViewRenderer to render its cells.
816 A number of standard renderers for rendering text, dates, images, toggle,
817 a progress bar etc. are provided. Additionally, the user can write custom
818 renderers deriving from wxDataViewCustomRenderer for displaying anything.
820 All data transfer from the control to the model and the user code is done
821 through wxVariant which can be extended to support more data formats as necessary.
822 Accordingly, all type information uses the strings returned from wxVariant::GetType.
826 Single selection mode. This is the default.
827 @style{wxDV_MULTIPLE}
828 Multiple selection mode.
829 @style{wxDV_ROW_LINES}
830 Use alternating colours for rows if supported by platform and theme.
831 Currently only supported by the native GTK and OS X implementations
832 but not by the generic one.
833 @style{wxDV_HORIZ_RULES}
834 Display the separator lines between rows.
835 @style{wxDV_VERT_RULES}
836 Display the separator lines between columns.
837 @style{wxDV_VARIABLE_LINE_HEIGHT}
838 Allow variable line heights.
839 This can be inefficient when displaying large number of items.
840 @style{wxDV_NO_HEADER}
841 Do not show column headers (which are shown by default).
844 @beginEventEmissionTable{wxDataViewEvent}
845 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
846 Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
847 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
848 Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event. This event
849 is triggered by double clicking an item or pressing some special key
850 (usually "Enter") when it is focused.
851 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
852 Process a @c wxEVT_DATAVIEW_ITEM_START_EDITING event. This
853 event can be vetoed in order to prevent editing on an item by item
855 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
856 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
857 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
858 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
859 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
860 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
861 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
862 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
863 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
864 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
865 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
866 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
867 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
868 Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
869 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
870 Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event
871 generated when the user right clicks inside the control. Notice that
872 this menu is generated even if the click didn't occur on any valid
873 item, in this case wxDataViewEvent::GetItem() simply returns an
875 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
876 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
877 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
878 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
879 Notice that currently this event is not generated in the native OS X
880 versions of the control.
881 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
882 Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
883 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
884 Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
885 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
886 Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
887 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
888 Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
889 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
890 Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
893 Notice that this control doesn't allow to process generic mouse events such
894 as @c wxEVT_LEFT_DOWN in all ports (notably it doesn't work in wxGTK). If
895 you need to handle any mouse events not covered by the ones above, consider
896 using a custom renderer for the cells that must handle them.
900 @appearance{dataviewctrl}
902 class wxDataViewCtrl
: public wxControl
911 Constructor. Calls Create().
913 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
914 const wxPoint
& pos
= wxDefaultPosition
,
915 const wxSize
& size
= wxDefaultSize
,
917 const wxValidator
& validator
= wxDefaultValidator
,
918 const wxString
& name
= wxDataViewCtrlNameStr
);
923 virtual ~wxDataViewCtrl();
926 Create the control. Useful for two step creation.
928 bool Create(wxWindow
* parent
, wxWindowID id
,
929 const wxPoint
& pos
= wxDefaultPosition
,
930 const wxSize
& size
= wxDefaultSize
,
932 const wxValidator
& validator
= wxDefaultValidator
,
933 const wxString
& name
= wxDataViewCtrlNameStr
);
936 Appends a wxDataViewColumn to the control. Returns @true on success.
938 Note that there is a number of short cut methods which implicitly create
939 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
941 virtual bool AppendColumn(wxDataViewColumn
* col
);
944 Prepends a wxDataViewColumn to the control. Returns @true on success.
946 Note that there is a number of short cut methods which implicitly create
947 a wxDataViewColumn and a wxDataViewRenderer for it.
949 virtual bool PrependColumn(wxDataViewColumn
* col
);
952 Inserts a wxDataViewColumn to the control. Returns @true on success.
954 virtual bool InsertColumn(unsigned int pos
, wxDataViewColumn
* col
);
958 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
959 created in the function or @NULL on failure.
961 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
962 unsigned int model_column
,
963 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
965 wxAlignment align
= wxALIGN_CENTER
,
966 int flags
= wxDATAVIEW_COL_RESIZABLE
);
967 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
968 unsigned int model_column
,
969 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
971 wxAlignment align
= wxALIGN_CENTER
,
972 int flags
= wxDATAVIEW_COL_RESIZABLE
);
977 Prepends a column for rendering a bitmap. Returns the wxDataViewColumn
978 created in the function or @NULL on failure.
980 wxDataViewColumn
* PrependBitmapColumn(const wxString
& label
,
981 unsigned int model_column
,
982 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
984 wxAlignment align
= wxALIGN_CENTER
,
985 int flags
= wxDATAVIEW_COL_RESIZABLE
);
986 wxDataViewColumn
* PrependBitmapColumn(const wxBitmap
& label
,
987 unsigned int model_column
,
988 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
990 wxAlignment align
= wxALIGN_CENTER
,
991 int flags
= wxDATAVIEW_COL_RESIZABLE
);
996 Appends a column for rendering a date. Returns the wxDataViewColumn
997 created in the function or @NULL on failure.
999 @note The @a align parameter is applied to both the column header and
1000 the column renderer.
1002 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
1003 unsigned int model_column
,
1004 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1006 wxAlignment align
= wxALIGN_NOT
,
1007 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1008 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
1009 unsigned int model_column
,
1010 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1012 wxAlignment align
= wxALIGN_NOT
,
1013 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1018 Prepends a column for rendering a date. Returns the wxDataViewColumn
1019 created in the function or @NULL on failure.
1021 @note The @a align parameter is applied to both the column header and
1022 the column renderer.
1024 wxDataViewColumn
* PrependDateColumn(const wxString
& label
,
1025 unsigned int model_column
,
1026 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1028 wxAlignment align
= wxALIGN_NOT
,
1029 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1030 wxDataViewColumn
* PrependDateColumn(const wxBitmap
& label
,
1031 unsigned int model_column
,
1032 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1034 wxAlignment align
= wxALIGN_NOT
,
1035 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1040 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
1041 created in the function or @NULL on failure.
1042 This method uses the wxDataViewIconTextRenderer class.
1044 @note The @a align parameter is applied to both the column header and
1045 the column renderer.
1047 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
1048 unsigned int model_column
,
1049 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1051 wxAlignment align
= wxALIGN_NOT
,
1052 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1053 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
1054 unsigned int model_column
,
1055 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1057 wxAlignment align
= wxALIGN_NOT
,
1058 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1063 Prepends a column for rendering text with an icon. Returns the wxDataViewColumn
1064 created in the function or @NULL on failure.
1065 This method uses the wxDataViewIconTextRenderer class.
1067 @note The @a align parameter is applied to both the column header and
1068 the column renderer.
1070 wxDataViewColumn
* PrependIconTextColumn(const wxString
& label
,
1071 unsigned int model_column
,
1072 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1074 wxAlignment align
= wxALIGN_NOT
,
1075 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1076 wxDataViewColumn
* PrependIconTextColumn(const wxBitmap
& label
,
1077 unsigned int model_column
,
1078 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1080 wxAlignment align
= wxALIGN_NOT
,
1081 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1086 Appends a column for rendering a progress indicator. Returns the
1087 wxDataViewColumn created in the function or @NULL on failure.
1089 @note The @a align parameter is applied to both the column header and
1090 the column renderer.
1092 wxDataViewColumn
* AppendProgressColumn(const wxString
& label
,
1093 unsigned int model_column
,
1094 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1096 wxAlignment align
= wxALIGN_CENTER
,
1097 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1098 wxDataViewColumn
* AppendProgressColumn(const wxBitmap
& label
,
1099 unsigned int model_column
,
1100 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1102 wxAlignment align
= wxALIGN_CENTER
,
1103 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1108 Prepends a column for rendering a progress indicator. Returns the
1109 wxDataViewColumn created in the function or @NULL on failure.
1111 @note The @a align parameter is applied to both the column header and
1112 the column renderer.
1114 wxDataViewColumn
* PrependProgressColumn(const wxString
& label
,
1115 unsigned int model_column
,
1116 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1118 wxAlignment align
= wxALIGN_CENTER
,
1119 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1120 wxDataViewColumn
* PrependProgressColumn(const wxBitmap
& label
,
1121 unsigned int model_column
,
1122 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1124 wxAlignment align
= wxALIGN_CENTER
,
1125 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1130 Appends a column for rendering text. Returns the wxDataViewColumn
1131 created in the function or @NULL on failure.
1133 @note The @a align parameter is applied to both the column header and
1134 the column renderer.
1136 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
1137 unsigned int model_column
,
1138 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1140 wxAlignment align
= wxALIGN_NOT
,
1141 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1142 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
1143 unsigned int model_column
,
1144 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1146 wxAlignment align
= wxALIGN_NOT
,
1147 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1152 Prepends a column for rendering text. Returns the wxDataViewColumn
1153 created in the function or @NULL on failure.
1155 @note The @a align parameter is applied to both the column header and
1156 the column renderer.
1158 wxDataViewColumn
* PrependTextColumn(const wxString
& label
,
1159 unsigned int model_column
,
1160 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1162 wxAlignment align
= wxALIGN_NOT
,
1163 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1164 wxDataViewColumn
* PrependTextColumn(const wxBitmap
& label
,
1165 unsigned int model_column
,
1166 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1168 wxAlignment align
= wxALIGN_NOT
,
1169 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1174 Appends a column for rendering a toggle. Returns the wxDataViewColumn
1175 created in the function or @NULL on failure.
1177 @note The @a align parameter is applied to both the column header and
1178 the column renderer.
1180 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
1181 unsigned int model_column
,
1182 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1184 wxAlignment align
= wxALIGN_CENTER
,
1185 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1186 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
1187 unsigned int model_column
,
1188 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1190 wxAlignment align
= wxALIGN_CENTER
,
1191 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1196 Prepends a column for rendering a toggle. Returns the wxDataViewColumn
1197 created in the function or @NULL on failure.
1199 @note The @a align parameter is applied to both the column header and
1200 the column renderer.
1202 wxDataViewColumn
* PrependToggleColumn(const wxString
& label
,
1203 unsigned int model_column
,
1204 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1206 wxAlignment align
= wxALIGN_CENTER
,
1207 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1208 wxDataViewColumn
* PrependToggleColumn(const wxBitmap
& label
,
1209 unsigned int model_column
,
1210 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1212 wxAlignment align
= wxALIGN_CENTER
,
1213 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1217 Associates a wxDataViewModel with the control.
1218 This increases the reference count of the model by 1.
1220 virtual bool AssociateModel(wxDataViewModel
* model
);
1223 Removes all columns.
1225 virtual bool ClearColumns();
1230 virtual void Collapse(const wxDataViewItem
& item
);
1233 Deletes given column.
1235 virtual bool DeleteColumn(wxDataViewColumn
* column
);
1238 Programmatically starts editing given cell of @a item.
1240 Doesn't do anything if the item or this column is not editable.
1242 @note Currently not implemented in wxOSX/Carbon.
1246 virtual void EditItem(const wxDataViewItem
& item
, const wxDataViewColumn
*column
);
1249 Enable drag operations using the given @a format.
1251 virtual bool EnableDragSource( const wxDataFormat
&format
);
1254 Enable drop operations using the given @a format.
1256 virtual bool EnableDropTarget( const wxDataFormat
&format
);
1259 Call this to ensure that the given item is visible.
1261 virtual void EnsureVisible(const wxDataViewItem
& item
,
1262 const wxDataViewColumn
* column
= NULL
);
1267 virtual void Expand(const wxDataViewItem
& item
);
1270 Expands all ancestors of the @a item. This method also
1271 ensures that the item itself as well as all ancestor
1272 items have been read from the model by the control.
1274 virtual void ExpandAncestors( const wxDataViewItem
& item
);
1277 Returns pointer to the column. @a pos refers to the position in the
1278 control which may change after reordering columns by the user.
1280 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
1283 Returns the number of columns.
1285 virtual unsigned int GetColumnCount() const;
1288 Returns the position of the column or -1 if not found in the control.
1290 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
1293 Returns column containing the expanders.
1295 wxDataViewColumn
* GetExpanderColumn() const;
1298 Returns the currently focused item.
1300 This is the item that the keyboard commands apply to. It may be invalid
1301 if there is no focus currently.
1303 This method is mostly useful for the controls with @c wxDV_MULTIPLE
1304 style as in the case of single selection it returns the same thing as
1307 Notice that under all platforms except Mac OS X the currently focused
1308 item may be selected or not but under OS X the current item is always
1311 @see SetCurrentItem(), GetCurrentColumn()
1315 wxDataViewItem
GetCurrentItem() const;
1318 Returns the column that currently has focus.
1320 If the focus is set to individual cell within the currently focused
1321 item (as opposed to being on the item as a whole), then this is the
1322 column that the focus is on.
1324 Returns NULL if no column currently has focus.
1326 @see GetCurrentItem()
1330 wxDataViewColumn
*GetCurrentColumn() const;
1333 Returns indentation.
1335 int GetIndent() const;
1338 Returns item rectangle.
1340 This method is currently not implemented at all in wxGTK and only
1341 implemented for non-@NULL @a col argument in wxOSX. It is fully
1342 implemented in the generic version of the control.
1347 If non-@NULL, the rectangle returned corresponds to the
1348 intersection of the item with the specified column. If @NULL, the
1349 rectangle spans all the columns.
1351 virtual wxRect
GetItemRect(const wxDataViewItem
& item
,
1352 const wxDataViewColumn
* col
= NULL
) const;
1355 Returns pointer to the data model associated with the control (if any).
1357 wxDataViewModel
* GetModel();
1360 Returns the number of currently selected items.
1362 This method may be called for both the controls with single and
1363 multiple selections and returns the number of selected item, possibly
1368 virtual int GetSelectedItemsCount() const;
1371 Returns first selected item or an invalid item if none is selected.
1373 This method may be called for both the controls with single and
1374 multiple selections but returns an invalid item if more than one item
1375 is selected in the latter case, use HasSelection() to determine if
1376 there are any selected items when using multiple selection.
1378 virtual wxDataViewItem
GetSelection() const;
1381 Fills @a sel with currently selected items and returns their number.
1383 This method may be called for both the controls with single and
1384 multiple selections. In the single selection case it returns the array
1385 with at most one element in it.
1387 @see GetSelectedItemsCount()
1389 virtual int GetSelections(wxDataViewItemArray
& sel
) const;
1392 Returns the wxDataViewColumn currently responsible for sorting
1393 or @NULL if none has been selected.
1395 virtual wxDataViewColumn
* GetSortingColumn() const;
1398 Returns true if any items are currently selected.
1400 This method may be called for both the controls with single and
1401 multiple selections.
1403 Calling this method is equivalent to calling GetSelectedItemsCount()
1404 and comparing its result with 0 but is more clear and might also be
1405 implemented more efficiently in the future.
1409 bool HasSelection() const;
1414 virtual void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
1415 wxDataViewColumn
*& col
) const;
1418 Return @true if the item is expanded.
1420 virtual bool IsExpanded(const wxDataViewItem
& item
) const;
1423 Return @true if the item is selected.
1425 virtual bool IsSelected(const wxDataViewItem
& item
) const;
1428 Select the given item.
1430 In single selection mode this changes the (unique) currently selected
1431 item. In multi selection mode, the @a item is selected and the
1432 previously selected items remain selected.
1434 virtual void Select(const wxDataViewItem
& item
);
1439 virtual void SelectAll();
1442 Set which column shall contain the tree-like expanders.
1444 void SetExpanderColumn(wxDataViewColumn
* col
);
1447 Changes the currently focused item.
1449 The @a item parameter must be valid, there is no way to remove the
1450 current item from the control.
1452 In single selection mode, calling this method is the same as calling
1453 Select() and is thus not very useful. In multiple selection mode this
1454 method only moves the current item however without changing the
1455 selection except under OS X where the current item is always selected,
1456 so calling SetCurrentItem() selects @a item if it hadn't been selected
1459 @see GetCurrentItem()
1463 void SetCurrentItem(const wxDataViewItem
& item
);
1466 Sets the indentation.
1468 void SetIndent(int indent
);
1471 Sets the selection to the array of wxDataViewItems.
1473 virtual void SetSelections(const wxDataViewItemArray
& sel
);
1476 Unselect the given item.
1478 virtual void Unselect(const wxDataViewItem
& item
);
1482 This method only has effect if multiple selections are allowed.
1484 virtual void UnselectAll();
1487 Sets the row height.
1489 This function can only be used when all rows have the same height, i.e.
1490 when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
1492 Currently this is implemented in the generic and native GTK versions
1493 only and nothing is done (and @false returned) when using OS X port.
1495 Also notice that this method can only be used to increase the row
1496 height compared with the default one (as determined by the return value
1497 of wxDataViewRenderer::GetSize()), if it is set to a too small value
1498 then the minimum required by the renderers will be used.
1500 @return @true if the line height was changed or @false otherwise.
1504 virtual bool SetRowHeight(int rowHeight
);
1510 @class wxDataViewModelNotifier
1512 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1513 its notification interface.
1514 See the documentation of that class for further information.
1519 class wxDataViewModelNotifier
1525 wxDataViewModelNotifier();
1530 virtual ~wxDataViewModelNotifier();
1533 Called by owning model.
1535 virtual bool Cleared() = 0;
1538 Get owning wxDataViewModel.
1540 wxDataViewModel
* GetOwner() const;
1543 Called by owning model.
1545 @return Always return @true from this function in derived classes.
1547 virtual bool ItemAdded(const wxDataViewItem
& parent
,
1548 const wxDataViewItem
& item
) = 0;
1551 Called by owning model.
1553 @return Always return @true from this function in derived classes.
1555 virtual bool ItemChanged(const wxDataViewItem
& item
) = 0;
1558 Called by owning model.
1560 @return Always return @true from this function in derived classes.
1562 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
1563 const wxDataViewItem
& item
) = 0;
1566 Called by owning model.
1568 @return Always return @true from this function in derived classes.
1570 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
1571 const wxDataViewItemArray
& items
);
1574 Called by owning model.
1576 @return Always return @true from this function in derived classes.
1578 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
1581 Called by owning model.
1583 @return Always return @true from this function in derived classes.
1585 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
1586 const wxDataViewItemArray
& items
);
1589 Called by owning model.
1591 virtual void Resort() = 0;
1594 Set owner of this notifier. Used internally.
1596 void SetOwner(wxDataViewModel
* owner
);
1599 Called by owning model.
1601 @return Always return @true from this function in derived classes.
1603 virtual bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
) = 0;
1608 The mode of a data-view cell; see wxDataViewRenderer for more info.
1610 enum wxDataViewCellMode
1613 The cell only displays information and cannot be manipulated or
1614 otherwise interacted with in any way.
1616 Note that this doesn't mean that the row being drawn can't be selected,
1617 just that a particular element of it cannot be individually modified.
1619 wxDATAVIEW_CELL_INERT
,
1622 Indicates that the cell can be @em activated by clicking it or using
1625 Activating a cell is an alternative to showing inline editor when the
1626 value can be edited in a simple way that doesn't warrant full editor
1627 control. The most typical use of cell activation is toggling the
1628 checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded
1629 volume slider or a five-star rating column.
1631 The exact means of activating a cell are platform-dependent, but they
1632 are usually similar to those used for inline editing of values.
1633 Typically, a cell would be activated by Space or Enter keys or by left
1636 @note Do not confuse this with item activation in wxDataViewCtrl
1637 and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
1638 used for activating the item (or, to put it differently, the
1639 entire row) similarly to analogous messages in wxTreeCtrl and
1640 wxListCtrl, and the effect differs (play a song, open a file
1641 etc.). Cell activation, on the other hand, is all about
1642 interacting with the individual cell.
1644 @see wxDataViewCustomRenderer::ActivateCell()
1646 wxDATAVIEW_CELL_ACTIVATABLE
,
1649 Indicates that the user can edit the data in-place in an inline editor
1650 control that will show up when the user wants to edit the cell.
1652 A typical example of this behaviour is changing the filename in a file
1655 Editing is typically triggered by slowly double-clicking the cell or by
1656 a platform-dependent keyboard shortcut (F2 is typical on Windows, Space
1657 and/or Enter is common elsewhere and supported on Windows too).
1659 @see wxDataViewCustomRenderer::CreateEditorCtrl()
1661 wxDATAVIEW_CELL_EDITABLE
1665 The values of this enum controls how a wxDataViewRenderer should display
1666 its contents in a cell.
1668 enum wxDataViewCellRenderState
1670 wxDATAVIEW_CELL_SELECTED
= 1,
1671 wxDATAVIEW_CELL_PRELIT
= 2,
1672 wxDATAVIEW_CELL_INSENSITIVE
= 4,
1673 wxDATAVIEW_CELL_FOCUSED
= 8
1677 @class wxDataViewRenderer
1679 This class is used by wxDataViewCtrl to render the individual cells.
1680 One instance of a renderer class is owned by a wxDataViewColumn.
1681 There is a number of ready-to-use renderers provided:
1682 - wxDataViewTextRenderer,
1683 - wxDataViewIconTextRenderer,
1684 - wxDataViewToggleRenderer,
1685 - wxDataViewProgressRenderer,
1686 - wxDataViewBitmapRenderer,
1687 - wxDataViewDateRenderer,
1688 - wxDataViewSpinRenderer.
1689 - wxDataViewChoiceRenderer.
1691 Additionally, the user can write their own renderers by deriving from
1692 wxDataViewCustomRenderer.
1694 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1695 by the constructors respectively controls what actions the cell data allows
1696 and how the renderer should display its contents in a cell.
1701 class wxDataViewRenderer
: public wxObject
1707 wxDataViewRenderer(const wxString
& varianttype
,
1708 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1709 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1712 Enable or disable replacing parts of the item text with ellipsis to
1713 make it fit the column width.
1715 This method only makes sense for the renderers working with text, such
1716 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1718 By default wxELLIPSIZE_MIDDLE is used.
1721 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1725 void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
);
1728 Disable replacing parts of the item text with ellipsis.
1730 If ellipsizing is disabled, the string will be truncated if it doesn't
1733 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1737 void DisableEllipsize();
1740 Returns the alignment. See SetAlignment()
1742 virtual int GetAlignment() const;
1745 Returns the ellipsize mode used by the renderer.
1747 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1750 @see EnableEllipsize()
1752 wxEllipsizeMode
GetEllipsizeMode() const;
1755 Returns the cell mode.
1757 virtual wxDataViewCellMode
GetMode() const;
1760 Returns pointer to the owning wxDataViewColumn.
1762 wxDataViewColumn
* GetOwner() const;
1765 This methods retrieves the value from the renderer in order to
1766 transfer the value back to the data model.
1768 Returns @false on failure.
1770 virtual bool GetValue(wxVariant
& value
) const = 0;
1773 Returns a string with the type of the wxVariant supported by this renderer.
1775 wxString
GetVariantType() const;
1778 Sets the alignment of the renderer's content.
1779 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1780 should have the same alignment as the column header.
1782 The method is not implemented under OS X and the renderer always aligns
1783 its contents as the column header on that platform. The other platforms
1784 support both vertical and horizontal alignment.
1786 virtual void SetAlignment( int align
);
1788 Sets the owning wxDataViewColumn.
1789 This is usually called from within wxDataViewColumn.
1791 void SetOwner(wxDataViewColumn
* owner
);
1794 Set the value of the renderer (and thus its cell) to @a value.
1795 The internal code will then render this cell with this data.
1797 virtual bool SetValue(const wxVariant
& value
) = 0;
1800 Before data is committed to the data model, it is passed to this
1801 method where it can be checked for validity. This can also be
1802 used for checking a valid range or limiting the user input in
1803 a certain aspect (e.g. max number of characters or only alphanumeric
1804 input, ASCII only etc.). Return @false if the value is not valid.
1806 Please note that due to implementation limitations, this validation
1807 is done after the editing control already is destroyed and the
1808 editing process finished.
1810 virtual bool Validate(wxVariant
& value
);
1813 virtual bool HasEditorCtrl() const;
1814 virtual wxWindow
* CreateEditorCtrl(wxWindow
* parent
,
1816 const wxVariant
& value
);
1817 virtual bool GetValueFromEditorCtrl(wxWindow
* editor
,
1819 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
1820 virtual void CancelEditing();
1821 virtual bool FinishEditing();
1822 wxWindow
*GetEditorCtrl();
1825 wxDataViewCtrl
* GetView() const;
1831 @class wxDataViewTextRenderer
1833 wxDataViewTextRenderer is used for rendering text.
1834 It supports in-place editing if desired.
1839 class wxDataViewTextRenderer
: public wxDataViewRenderer
1845 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1846 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1847 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1853 @class wxDataViewIconTextRenderer
1855 The wxDataViewIconTextRenderer class is used to display text with
1856 a small icon next to it as it is typically done in a file manager.
1858 This classes uses the wxDataViewIconText helper class to store its data.
1859 wxDataViewIconText can be converted to and from a wxVariant using the left
1865 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
1871 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
1872 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1873 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1879 @class wxDataViewProgressRenderer
1881 This class is used by wxDataViewCtrl to render progress bars.
1886 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1892 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1893 const wxString
& varianttype
= "long",
1894 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1895 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1901 @class wxDataViewSpinRenderer
1903 This is a specialized renderer for rendering integer values.
1904 It supports modifying the values in-place by using a wxSpinCtrl.
1905 The renderer only support variants of type @e long.
1910 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1915 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1917 wxDataViewSpinRenderer(int min
, int max
,
1918 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1919 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1925 @class wxDataViewToggleRenderer
1927 This class is used by wxDataViewCtrl to render toggle controls.
1932 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1938 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1939 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1940 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1945 A wxDataViewCtrl renderer using wxChoice control and values of strings in
1948 This class is used by wxDataViewCtrl to render choice controls.
1949 It stores a string so that SetValue() and GetValue() operate
1950 on a variant holding a string.
1952 @see wxDataViewChoiceByIndexRenderer
1958 class wxDataViewChoiceRenderer
: public wxDataViewRenderer
1964 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1965 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1966 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1969 Returns the choice referred to by index.
1971 wxString
GetChoice(size_t index
) const;
1974 Returns all choices.
1976 const wxArrayString
& GetChoices() const;
1981 A wxDataViewCtrl renderer using wxChoice control and indexes into it.
1983 Unlike its base wxDataViewChoiceRenderer class, this one stores the choice
1984 index, i.e. an @c int, in the variant used by its SetValue() and
1990 class wxDataViewChoiceByIndexRenderer
: public wxDataViewChoiceRenderer
1996 wxDataViewChoiceByIndexRenderer( const wxArrayString
&choices
,
1997 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1998 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
2003 @class wxDataViewDateRenderer
2005 This class is used by wxDataViewCtrl to render calendar controls.
2010 class wxDataViewDateRenderer
: public wxDataViewRenderer
2016 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
2017 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
2018 int align
= wxDVR_DEFAULT_ALIGNMENT
);
2024 @class wxDataViewCustomRenderer
2026 You need to derive a new class from wxDataViewCustomRenderer in
2027 order to write a new renderer.
2029 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
2030 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
2032 If you want your renderer to support in-place editing then you also need to override
2033 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
2034 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
2036 Note that a special event handler will be pushed onto that editor control
2037 which handles @e \<ENTER\> and focus out events in order to end the editing.
2042 class wxDataViewCustomRenderer
: public wxDataViewRenderer
2048 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
2049 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2050 int align
= wxDVR_DEFAULT_ALIGNMENT
);
2055 virtual ~wxDataViewCustomRenderer();
2058 Override this to react to cell @em activation. Activating a cell is an
2059 alternative to showing inline editor when the value can be edited in a
2060 simple way that doesn't warrant full editor control. The most typical
2061 use of cell activation is toggling the checkbox in
2062 wxDataViewToggleRenderer; others would be e.g. an embedded volume
2063 slider or a five-star rating column.
2065 The exact means of activating a cell are platform-dependent, but they
2066 are usually similar to those used for inline editing of values.
2067 Typically, a cell would be activated by Space or Enter keys or by left
2070 This method will only be called if the cell has the
2071 wxDATAVIEW_CELL_ACTIVATABLE mode.
2074 Coordinates of the activated cell's area.
2076 The model to manipulate in response.
2080 Activated column of @a item.
2082 If the activation was triggered by mouse click, contains the
2083 corresponding event. Is @NULL otherwise (for keyboard activation).
2084 Mouse coordinates are adjusted to be relative to the cell.
2088 @note Do not confuse this method with item activation in wxDataViewCtrl
2089 and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
2090 used for activating the item (or, to put it differently, the
2091 entire row) similarly to analogous messages in wxTreeCtrl and
2092 wxListCtrl, and the effect differs (play a song, open a file
2093 etc.). Cell activation, on the other hand, is all about
2094 interacting with the individual cell.
2096 @see CreateEditorCtrl()
2098 virtual bool ActivateCell(const wxRect
& cell
,
2099 wxDataViewModel
* model
,
2100 const wxDataViewItem
& item
,
2102 const wxMouseEvent
*mouseEvent
);
2105 Override this to create the actual editor control once editing
2108 This method will only be called if the cell has the
2109 wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly
2110 double-clicking the cell or by a platform-dependent keyboard shortcut
2111 (F2 is typical on Windows, Space and/or Enter is common elsewhere and
2112 supported on Windows too).
2115 The parent of the editor control.
2117 Indicates the position and size of the editor control. The control
2118 should be created in place of the cell and @a labelRect should be
2119 respected as much as possible.
2121 Initial value of the editor.
2127 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
2128 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
2134 virtual wxWindow
* CreateEditorCtrl(wxWindow
* parent
,
2136 const wxVariant
& value
);
2139 Return the attribute to be used for rendering.
2141 This function may be called from Render() implementation to use the
2142 attributes defined for the item if the renderer supports them.
2144 Notice that when Render() is called, the wxDC object passed to it is
2145 already set up to use the correct attributes (e.g. its font is set to
2146 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
2147 returns true) so it may not be necessary to call it explicitly if you
2148 only want to render text using the items attributes.
2152 const wxDataViewItemAttr
& GetAttr() const;
2155 Return size required to show content.
2157 virtual wxSize
GetSize() const = 0;
2160 Override this so that the renderer can get the value from the editor
2161 control (pointed to by @a editor):
2164 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
2165 long l = sc->GetValue();
2171 virtual bool GetValueFromEditorCtrl(wxWindow
* editor
,
2175 Override this and make it return @true in order to
2176 indicate that this renderer supports in-place editing.
2178 virtual bool HasEditorCtrl() const;
2181 Override this to react to a left click. This method will only be
2182 called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. This method is
2183 deprecated, please use ActivateCell instead.
2185 virtual bool LeftClick( wxPoint cursor
,
2187 wxDataViewModel
* model
,
2188 const wxDataViewItem
& item
,
2192 Override this to react to the activation of a cell. This method is
2193 deprecated, please use ActivateCell instead.
2195 virtual bool Activate(wxRect cell
,
2196 wxDataViewModel
* model
,
2197 const wxDataViewItem
& item
,
2202 Override this to render the cell.
2203 Before this is called, wxDataViewRenderer::SetValue was called
2204 so that this instance knows what to render.
2206 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
) = 0;
2209 This method should be called from within Render() whenever you need to
2211 This will ensure that the correct colour, font and vertical alignment will
2212 be chosen so the text will look the same as text drawn by native renderers.
2214 void RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
2215 wxDC
* dc
, int state
);
2218 Override this to start a drag operation. Not yet supported.
2220 virtual bool StartDrag(const wxPoint
& cursor
,
2222 wxDataViewModel
* model
,
2223 const wxDataViewItem
& item
,
2228 Helper for GetSize() implementations, respects attributes.
2230 wxSize
GetTextExtent(const wxString
& str
) const;
2236 @class wxDataViewBitmapRenderer
2238 This class is used by wxDataViewCtrl to render bitmap controls.
2243 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
2249 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
2250 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2251 int align
= wxDVR_DEFAULT_ALIGNMENT
);
2256 The flags used by wxDataViewColumn.
2257 Can be combined together.
2259 enum wxDataViewColumnFlags
2261 wxDATAVIEW_COL_RESIZABLE
= 1,
2262 wxDATAVIEW_COL_SORTABLE
= 2,
2263 wxDATAVIEW_COL_REORDERABLE
= 4,
2264 wxDATAVIEW_COL_HIDDEN
= 8
2268 @class wxDataViewColumn
2270 This class represents a column in a wxDataViewCtrl.
2271 One wxDataViewColumn is bound to one column in the data model to which the
2272 wxDataViewCtrl has been associated.
2274 An instance of wxDataViewRenderer is used by this class to render its data.
2279 class wxDataViewColumn
: public wxSettableHeaderColumn
2283 Constructs a text column.
2286 The title of the column.
2288 The class which will render the contents of this column.
2290 The index of the model's column which is associated with this object.
2292 The width of the column.
2293 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2295 The alignment of the column title.
2297 One or more flags of the ::wxDataViewColumnFlags enumeration.
2299 wxDataViewColumn(const wxString
& title
,
2300 wxDataViewRenderer
* renderer
,
2301 unsigned int model_column
,
2302 int width
= wxDVC_DEFAULT_WIDTH
,
2303 wxAlignment align
= wxALIGN_CENTER
,
2304 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2307 Constructs a bitmap column.
2310 The bitmap of the column.
2312 The class which will render the contents of this column.
2314 The index of the model's column which is associated with this object.
2316 The width of the column.
2317 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2319 The alignment of the column title.
2321 One or more flags of the ::wxDataViewColumnFlags enumeration.
2323 wxDataViewColumn(const wxBitmap
& bitmap
,
2324 wxDataViewRenderer
* renderer
,
2325 unsigned int model_column
,
2326 int width
= wxDVC_DEFAULT_WIDTH
,
2327 wxAlignment align
= wxALIGN_CENTER
,
2328 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2331 Returns the index of the column of the model, which this
2332 wxDataViewColumn is displaying.
2334 unsigned int GetModelColumn() const;
2337 Returns the owning wxDataViewCtrl.
2339 wxDataViewCtrl
* GetOwner() const;
2342 Returns the renderer of this wxDataViewColumn.
2344 @see wxDataViewRenderer.
2346 wxDataViewRenderer
* GetRenderer() const;
2352 @class wxDataViewListCtrl
2354 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
2355 and forwards most of its API to that class.
2357 The purpose of this class is to offer a simple way to display and
2358 edit a small table of data without having to write your own wxDataViewModel.
2361 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
2363 listctrl->AppendToggleColumn( "Toggle" );
2364 listctrl->AppendTextColumn( "Text" );
2366 wxVector<wxVariant> data;
2367 data.push_back( wxVariant(true) );
2368 data.push_back( wxVariant("row 1") );
2369 listctrl->AppendItem( data );
2372 data.push_back( wxVariant(false) );
2373 data.push_back( wxVariant("row 3") );
2374 listctrl->AppendItem( data );
2378 See wxDataViewCtrl for the list of supported styles.
2381 @beginEventEmissionTable
2382 See wxDataViewCtrl for the list of events emitted by this class.
2390 class wxDataViewListCtrl
: public wxDataViewCtrl
2396 wxDataViewListCtrl();
2399 Constructor. Calls Create().
2401 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
2402 const wxPoint
& pos
= wxDefaultPosition
,
2403 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
2404 const wxValidator
& validator
= wxDefaultValidator
);
2407 Destructor. Deletes the image list if any.
2409 ~wxDataViewListCtrl();
2412 Creates the control and a wxDataViewListStore as its internal model.
2414 bool Create( wxWindow
*parent
, wxWindowID id
,
2415 const wxPoint
& pos
= wxDefaultPosition
,
2416 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
2417 const wxValidator
& validator
= wxDefaultValidator
);
2423 wxDataViewListStore
*GetStore();
2424 const wxDataViewListStore
*GetStore() const;
2428 Returns the position of given @e item or wxNOT_FOUND if it's
2433 int ItemToRow(const wxDataViewItem
&item
) const;
2436 Returns the wxDataViewItem at the given @e row.
2440 wxDataViewItem
RowToItem(int row
) const;
2444 @name Selection handling functions
2448 Returns index of the selected row or wxNOT_FOUND.
2450 @see wxDataViewCtrl::GetSelection()
2454 int GetSelectedRow() const;
2459 @see wxDataViewCtrl::Select()
2463 void SelectRow(unsigned row
);
2466 Unselects given row.
2468 @see wxDataViewCtrl::Unselect()
2472 void UnselectRow(unsigned row
);
2475 Returns true if @a row is selected.
2477 @see wxDataViewCtrl::IsSelected()
2481 bool IsRowSelected(unsigned row
) const;
2486 @name Column management functions
2491 Appends a column to the control and additionally appends a
2492 column to the store with the type string.
2494 virtual bool AppendColumn( wxDataViewColumn
*column
);
2497 Appends a column to the control and additionally appends a
2498 column to the list store with the type @a varianttype.
2500 void AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
2503 Appends a text column to the control and the store.
2505 See wxDataViewColumn::wxDataViewColumn for more info about
2508 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
2509 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2510 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2511 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2514 Appends a toggle column to the control and the store.
2516 See wxDataViewColumn::wxDataViewColumn for more info about
2519 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
2520 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
2521 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2522 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2525 Appends a progress column to the control and the store.
2527 See wxDataViewColumn::wxDataViewColumn for more info about
2530 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
2531 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2532 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2533 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2536 Appends an icon-and-text column to the control and the store.
2538 See wxDataViewColumn::wxDataViewColumn for more info about
2541 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
2542 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
2543 int width
= -1, wxAlignment align
= wxALIGN_LEFT
,
2544 int flags
= wxDATAVIEW_COL_RESIZABLE
);
2547 Inserts a column to the control and additionally inserts a
2548 column to the store with the type string.
2550 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
);
2553 Inserts a column to the control and additionally inserts a
2554 column to the list store with the type @a varianttype.
2556 void InsertColumn( unsigned int pos
, wxDataViewColumn
*column
,
2557 const wxString
&varianttype
);
2560 Prepends a column to the control and additionally prepends a
2561 column to the store with the type string.
2563 virtual bool PrependColumn( wxDataViewColumn
*column
);
2566 Prepends a column to the control and additionally prepends a
2567 column to the list store with the type @a varianttype.
2569 void PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
2575 @name Item management functions
2580 Appends an item (=row) to the control and store.
2582 void AppendItem( const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2585 Prepends an item (=row) to the control and store.
2587 void PrependItem( const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2590 Inserts an item (=row) to the control and store.
2592 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2595 Delete the row at position @a row.
2597 void DeleteItem( unsigned row
);
2600 Delete all items (= all rows).
2602 void DeleteAllItems();
2605 Returns the number of items (=rows) in the control
2609 unsigned int GetItemCount() const;
2612 Returns the client data associated with the item.
2618 wxUIntPtr
GetItemData(const wxDataViewItem
& item
) const;
2621 Sets the value in the store and update the control.
2623 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
);
2626 Returns the value from the store.
2628 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
);
2631 Sets the value in the store and update the control.
2633 This method assumes that the string is stored in respective
2636 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
);
2639 Returns the value from the store.
2641 This method assumes that the string is stored in respective
2644 wxString
GetTextValue( unsigned int row
, unsigned int col
) const;
2647 Sets the value in the store and update the control.
2649 This method assumes that the boolean value is stored in
2652 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
);
2655 Returns the value from the store.
2657 This method assumes that the boolean value is stored in
2660 bool GetToggleValue( unsigned int row
, unsigned int col
) const;
2663 Associates a client data pointer with the given item.
2665 Notice that the control does @e not take ownership of the pointer for
2666 compatibility with wxListCtrl. I.e. it will @e not delete the pointer
2667 (if it is a pointer and not a number) itself, it is up to you to do it.
2673 void SetItemData(const wxDataViewItem
& item
, wxUIntPtr data
);
2680 @class wxDataViewTreeCtrl
2682 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
2683 and forwards most of its API to that class.
2684 Additionally, it uses a wxImageList to store a list of icons.
2686 The main purpose of this class is to provide a simple upgrade path for code
2690 See wxDataViewCtrl for the list of supported styles.
2693 @beginEventEmissionTable
2694 See wxDataViewCtrl for the list of events emitted by this class.
2702 @appearance{dataviewtreectrl}
2704 class wxDataViewTreeCtrl
: public wxDataViewCtrl
2710 wxDataViewTreeCtrl();
2717 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
2718 const wxPoint
& pos
= wxDefaultPosition
,
2719 const wxSize
& size
= wxDefaultSize
,
2720 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2721 const wxValidator
& validator
= wxDefaultValidator
);
2724 Destructor. Deletes the image list if any.
2726 virtual ~wxDataViewTreeCtrl();
2729 Appends a container to the given @a parent.
2731 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
2732 const wxString
& text
,
2735 wxClientData
* data
= NULL
);
2738 Appends an item to the given @a parent.
2740 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
2741 const wxString
& text
,
2743 wxClientData
* data
= NULL
);
2746 Creates the control and a wxDataViewTreeStore as its internal model.
2748 The default tree column created by this method is an editable column
2749 using wxDataViewIconTextRenderer as its renderer.
2751 bool Create(wxWindow
* parent
, wxWindowID id
,
2752 const wxPoint
& pos
= wxDefaultPosition
,
2753 const wxSize
& size
= wxDefaultSize
,
2754 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
2755 const wxValidator
& validator
= wxDefaultValidator
);
2758 Calls the identical method from wxDataViewTreeStore.
2760 void DeleteAllItems();
2763 Calls the identical method from wxDataViewTreeStore.
2765 void DeleteChildren(const wxDataViewItem
& item
);
2768 Calls the identical method from wxDataViewTreeStore.
2770 void DeleteItem(const wxDataViewItem
& item
);
2773 Calls the identical method from wxDataViewTreeStore.
2775 int GetChildCount(const wxDataViewItem
& parent
) const;
2778 Returns the image list.
2780 wxImageList
* GetImageList();
2783 Calls the identical method from wxDataViewTreeStore.
2785 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
2788 Calls the identical method from wxDataViewTreeStore.
2790 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
2793 Calls the identical method from wxDataViewTreeStore.
2795 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
2798 Calls the identical method from wxDataViewTreeStore.
2800 wxString
GetItemText(const wxDataViewItem
& item
) const;
2803 Calls the identical method from wxDataViewTreeStore.
2805 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
2806 unsigned int pos
) const;
2812 wxDataViewTreeStore
* GetStore();
2813 const wxDataViewTreeStore
* GetStore() const;
2817 Calls the same method from wxDataViewTreeStore but uses
2818 an index position in the image list instead of a wxIcon.
2820 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
2821 const wxDataViewItem
& previous
,
2822 const wxString
& text
,
2825 wxClientData
* data
= NULL
);
2828 Calls the same method from wxDataViewTreeStore but uses
2829 an index position in the image list instead of a wxIcon.
2831 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
2832 const wxDataViewItem
& previous
,
2833 const wxString
& text
,
2835 wxClientData
* data
= NULL
);
2838 Returns true if item is a container.
2840 bool IsContainer( const wxDataViewItem
& item
);
2843 Calls the same method from wxDataViewTreeStore but uses
2844 an index position in the image list instead of a wxIcon.
2846 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
2847 const wxString
& text
,
2850 wxClientData
* data
= NULL
);
2853 Calls the same method from wxDataViewTreeStore but uses
2854 an index position in the image list instead of a wxIcon.
2856 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
2857 const wxString
& text
,
2859 wxClientData
* data
= NULL
);
2862 Sets the image list.
2864 void SetImageList(wxImageList
* imagelist
);
2867 Calls the identical method from wxDataViewTreeStore.
2869 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
2872 Calls the identical method from wxDataViewTreeStore.
2874 void SetItemExpandedIcon(const wxDataViewItem
& item
,
2875 const wxIcon
& icon
);
2878 Calls the identical method from wxDataViewTreeStore.
2880 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
2883 Calls the identical method from wxDataViewTreeStore.
2885 void SetItemText(const wxDataViewItem
& item
,
2886 const wxString
& text
);
2891 @class wxDataViewListStore
2893 wxDataViewListStore is a specialised wxDataViewModel for storing
2894 a simple table of data. Since it derives from wxDataViewIndexListModel
2895 its data is be accessed by row (i.e. by index) instead of only
2898 This class actually stores the values (therefore its name)
2899 and implements all virtual methods from the base classes so it can be
2900 used directly without having to derive any class from it, but it is
2901 mostly used from within wxDataViewListCtrl.
2907 class wxDataViewListStore
: public wxDataViewIndexListModel
2913 wxDataViewListStore();
2918 ~wxDataViewListStore();
2921 Prepends a data column.
2923 @a variantype indicates the type of values store in the column.
2925 This does not automatically fill in any (default) values in
2926 rows which exist in the store already.
2928 void PrependColumn( const wxString
&varianttype
);
2931 Inserts a data column before @a pos.
2933 @a variantype indicates the type of values store in the column.
2935 This does not automatically fill in any (default) values in
2936 rows which exist in the store already.
2938 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
2941 Appends a data column.
2943 @a variantype indicates the type of values store in the column.
2945 This does not automatically fill in any (default) values in
2946 rows which exist in the store already.
2948 void AppendColumn( const wxString
&varianttype
);
2951 Appends an item (=row) and fills it with @a values.
2953 The values must match the values specifies in the column
2954 in number and type. No (default) values are filled in
2957 void AppendItem( const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2960 Prepends an item (=row) and fills it with @a values.
2962 The values must match the values specifies in the column
2963 in number and type. No (default) values are filled in
2966 void PrependItem( const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2969 Inserts an item (=row) and fills it with @a values.
2971 The values must match the values specifies in the column
2972 in number and type. No (default) values are filled in
2975 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxUIntPtr data
= NULL
);
2978 Delete the item (=row) at position @a pos.
2980 void DeleteItem( unsigned pos
);
2983 Delete all item (=all rows) in the store.
2985 void DeleteAllItems();
2988 Returns the number of items (=rows) in the control
2992 unsigned int GetItemCount() const;
2995 Returns the client data associated with the item.
3001 wxUIntPtr
GetItemData(const wxDataViewItem
& item
) const;
3004 Overridden from wxDataViewModel
3006 virtual unsigned int GetColumnCount() const;
3009 Overridden from wxDataViewModel
3011 virtual wxString
GetColumnType( unsigned int col
) const;
3014 Sets the client data associated with the item.
3016 Notice that this class does @e not take ownership of the passed in
3017 pointer and will not delete it.
3023 void SetItemData(const wxDataViewItem
& item
, wxUIntPtr data
);
3026 Overridden from wxDataViewIndexListModel
3028 virtual void GetValueByRow( wxVariant
&value
,
3029 unsigned int row
, unsigned int col
) const;
3032 Overridden from wxDataViewIndexListModel
3034 virtual bool SetValueByRow( const wxVariant
&value
,
3035 unsigned int row
, unsigned int col
);
3040 @class wxDataViewTreeStore
3042 wxDataViewTreeStore is a specialised wxDataViewModel for storing simple
3043 trees very much like wxTreeCtrl does and it offers a similar API.
3045 This class actually stores the entire tree and the values (therefore its name)
3046 and implements all virtual methods from the base class so it can be used directly
3047 without having to derive any class from it, but it is mostly used from within
3053 class wxDataViewTreeStore
: public wxDataViewModel
3057 Constructor. Creates the invisible root node internally.
3059 wxDataViewTreeStore();
3064 virtual ~wxDataViewTreeStore();
3069 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
3070 const wxString
& text
,
3071 const wxIcon
& icon
= wxNullIcon
,
3072 const wxIcon
& expanded
= wxNullIcon
,
3073 wxClientData
* data
= NULL
);
3078 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
3079 const wxString
& text
,
3080 const wxIcon
& icon
= wxNullIcon
,
3081 wxClientData
* data
= NULL
);
3084 Delete all item in the model.
3086 void DeleteAllItems();
3089 Delete all children of the item, but not the item itself.
3091 void DeleteChildren(const wxDataViewItem
& item
);
3096 void DeleteItem(const wxDataViewItem
& item
);
3099 Return the number of children of item.
3101 int GetChildCount(const wxDataViewItem
& parent
) const;
3104 Returns the client data associated with the item.
3106 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
3109 Returns the icon to display in expanded containers.
3111 const wxIcon
& GetItemExpandedIcon(const wxDataViewItem
& item
) const;
3114 Returns the icon of the item.
3116 const wxIcon
& GetItemIcon(const wxDataViewItem
& item
) const;
3119 Returns the text of the item.
3121 wxString
GetItemText(const wxDataViewItem
& item
) const;
3124 Returns the nth child item of item.
3126 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
3127 unsigned int pos
) const;
3130 Inserts a container after @a previous.
3132 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
3133 const wxDataViewItem
& previous
,
3134 const wxString
& text
,
3135 const wxIcon
& icon
= wxNullIcon
,
3136 const wxIcon
& expanded
= wxNullIcon
,
3137 wxClientData
* data
= NULL
);
3140 Inserts an item after @a previous.
3142 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
3143 const wxDataViewItem
& previous
,
3144 const wxString
& text
,
3145 const wxIcon
& icon
= wxNullIcon
,
3146 wxClientData
* data
= NULL
);
3149 Inserts a container before the first child item or @a parent.
3151 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
3152 const wxString
& text
,
3153 const wxIcon
& icon
= wxNullIcon
,
3154 const wxIcon
& expanded
= wxNullIcon
,
3155 wxClientData
* data
= NULL
);
3158 Inserts an item before the first child item or @a parent.
3160 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
3161 const wxString
& text
,
3162 const wxIcon
& icon
= wxNullIcon
,
3163 wxClientData
* data
= NULL
);
3166 Sets the client data associated with the item.
3168 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
3171 Sets the expanded icon for the item.
3173 void SetItemExpandedIcon(const wxDataViewItem
& item
,
3174 const wxIcon
& icon
);
3177 Sets the icon for the item.
3179 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
3184 @class wxDataViewIconText
3186 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
3187 This class can be converted to and from a wxVariant.
3192 class wxDataViewIconText
: public wxObject
3199 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
3200 const wxIcon
& icon
= wxNullIcon
);
3201 wxDataViewIconText(const wxDataViewIconText
& other
);
3207 const wxIcon
& GetIcon() const;
3212 wxString
GetText() const;
3217 void SetIcon(const wxIcon
& icon
);
3222 void SetText(const wxString
& text
);
3228 @class wxDataViewEvent
3230 This is the event class for the wxDataViewCtrl notifications.
3232 @beginEventTable{wxDataViewEvent}
3233 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
3234 Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
3235 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
3236 Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event.
3237 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
3238 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
3239 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
3240 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
3241 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
3242 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
3243 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
3244 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
3245 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
3246 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
3247 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
3248 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
3249 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
3250 Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
3251 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
3252 Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event.
3253 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
3254 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
3255 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
3256 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
3257 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
3258 Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
3259 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
3260 Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
3261 Currently this even is only generated when using the native OSX
3263 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
3264 Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
3265 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
3266 Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
3267 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
3268 Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
3269 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
3270 Process a @c wxEVT_DATAVIEW_CACHE_HINT event.
3274 @category{events,dvc}
3276 class wxDataViewEvent
: public wxNotifyEvent
3280 Constructor. Typically used by wxWidgets internals only.
3282 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
3286 Returns the position of the column in the control or -1
3287 if no column field was set by the event emitter.
3289 int GetColumn() const;
3292 Returns a pointer to the wxDataViewColumn from which
3293 the event was emitted or @NULL.
3295 wxDataViewColumn
* GetDataViewColumn() const;
3298 Returns the wxDataViewModel associated with the event.
3300 wxDataViewModel
* GetModel() const;
3303 Returns the position of a context menu event in screen coordinates.
3305 wxPoint
GetPosition() const;
3308 Returns a reference to a value.
3310 const wxVariant
& GetValue() const;
3313 Can be used to determine whether the new value is going to be accepted
3314 in wxEVT_DATAVIEW_ITEM_EDITING_DONE handler.
3316 Returns @true if editing the item was cancelled or if the user tried to
3317 enter an invalid value (refused by wxDataViewRenderer::Validate()). If
3318 this method returns @false, it means that the value in the model is
3319 about to be changed to the new one.
3321 Notice that wxEVT_DATAVIEW_ITEM_EDITING_DONE event handler can
3322 call wxNotifyEvent::Veto() to prevent this from happening.
3324 Currently support for setting this field and for vetoing the change is
3325 only available in the generic version of wxDataViewCtrl, i.e. under MSW
3326 but not GTK nor OS X.
3330 bool IsEditCancelled() const;
3333 Sets the column index associated with this event.
3335 void SetColumn(int col
);
3338 For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK only.
3340 void SetDataViewColumn(wxDataViewColumn
* col
);
3343 Sets the dataview model associated with this event.
3345 void SetModel(wxDataViewModel
* model
);
3348 Sets the value associated with this event.
3350 void SetValue(const wxVariant
& value
);
3353 Set wxDataObject for data transfer within a drag operation.
3355 void SetDataObject( wxDataObject
*obj
);
3358 Gets the wxDataFormat during a drop operation.
3360 wxDataFormat
GetDataFormat() const;
3363 Gets the data size for a drop data transfer.
3365 size_t GetDataSize() const;
3368 Gets the data buffer for a drop data transfer.
3370 void *GetDataBuffer() const;
3373 Specify the kind of the drag operation to perform.
3375 This method can be used inside a wxEVT_DATAVIEW_ITEM_BEGIN_DRAG
3376 handler in order to configure the drag operation. Valid values are
3377 ::wxDrag_CopyOnly (default), ::wxDrag_AllowMove (allow the data to be
3378 moved) and ::wxDrag_DefaultMove.
3380 Currently it is only honoured by the generic version of wxDataViewCtrl
3381 (used e.g. under MSW) and not supported by the native GTK and OS X
3384 @see GetDropEffect()
3388 void SetDragFlags(int flags
);
3391 Returns the effect the user requested to happen to the dropped data.
3393 This function can be used inside
3394 wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE and
3395 wxEVT_DATAVIEW_ITEM_DROP handlers and returns whether the user
3396 is trying to copy (the return value is ::wxDragCopy) or move (if the
3397 return value is ::wxDragMove) the data.
3399 Currently this is only available when using the generic version of
3400 wxDataViewCtrl (used e.g. under MSW) and always returns ::wxDragNone in
3401 the GTK and OS X native versions.
3405 wxDragResult
GetDropEffect() const;
3408 Return the first row that will be displayed.
3410 int GetCacheFrom() const;
3413 Return the last row that will be displayed.
3415 int GetCacheTo() const;
3420 wxDataViewItem
GetItem() const;
3421 void SetItem( const wxDataViewItem
&item
);
3422 void SetEditCanceled(bool editCancelled
);
3423 void SetPosition( int x
, int y
);
3424 void SetCache(int from
, int to
);
3425 wxDataObject
*GetDataObject() const;
3426 void SetDataFormat( const wxDataFormat
&format
);
3427 void SetDataSize( size_t size
);
3428 void SetDataBuffer( void* buf
);
3429 int GetDragFlags() const;
3430 void SetDropEffect( wxDragResult effect
);