1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxDataViewIconText class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDataViewIconText
13 wxDataViewIconText is used by
14 wxDataViewIconTextRenderer
15 for data transfer. This class can be converted to a from
21 class wxDataViewIconText
: public wxObject
28 wxDataViewIconText(const wxString
& text
= wxEmptyString
,
29 const wxIcon
& icon
= wxNullIcon
);
30 wxDataViewIconText(const wxDataViewIconText
& other
);
36 const wxIcon
GetIcon() const;
41 wxString
GetText() const;
46 void SetIcon(const wxIcon
& icon
);
51 void SetText(const wxString
& text
);
56 @class wxDataViewEvent
59 wxDataViewEvent - the event class for the wxDataViewCtrl notifications
64 class wxDataViewEvent
: public wxNotifyEvent
71 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
,
73 wxDataViewEvent(const wxDataViewEvent
& event
);
77 Used to clone the event.
79 wxEvent
* Clone() const;
82 Returns the position of the column in the control or -1
83 if no column field was set by the event emitter.
85 int GetColumn() const;
88 Returns a pointer to the wxDataViewColumn from which
89 the event was emitted or @NULL.
91 wxDataViewColumn
* GetDataViewColumn();
94 Returns the wxDataViewModel associated with the event.
96 wxDataViewModel
* GetModel() const;
99 Returns a the position of a context menu event in screen coordinates.
101 wxPoint
GetPosition() const;
104 Returns a reference to a value.
106 const wxVariant
GetValue() const;
111 void SetColumn(int col
);
114 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
116 void SetDataViewColumn(wxDataViewColumn
* col
);
121 void SetModel(wxDataViewModel
* model
);
126 void SetValue(const wxVariant
& value
);
131 @class wxDataViewIconTextRenderer
132 @wxheader{dataview.h}
134 The wxDataViewIconTextRenderer class is used to display text with
135 a small icon next to it as it is typically done in a file manager.
136 This classes uses the wxDataViewIconText
137 helper class to store its data. wxDataViewIonText can be converted
138 to a from a wxVariant using the left shift
144 class wxDataViewIconTextRenderer
: public wxDataViewRenderer
150 wxDataViewIconTextRenderer(const wxString
& varianttype
= "wxDataViewIconText",
151 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
156 @class wxDataViewIndexListModel
157 @wxheader{dataview.h}
159 wxDataViewIndexListModel is a specialized data model which lets
160 you address an item by its position (row) rather than its
161 wxDataViewItem (which you can obtain from this class).
162 This model also provides its own
163 wxDataViewIndexListModel::Compare method
164 which sorts the model's data by the index.
166 This model is special in the it is implemented differently under OS X
167 and other platforms. Under OS X a wxDataViewItem is always persistent
168 and this is also the case for this class. Under other platforms, the
169 meaning of a wxDataViewItem is changed to reflect a row number for
170 wxDataViewIndexListModel. The consequence of this is that
171 wxDataViewIndexListModel can be used as a virtual model with an
172 almost infinate number of items on platforms other than OS X.
177 class wxDataViewIndexListModel
: public wxDataViewModel
183 wxDataViewIndexListModel(unsigned int initial_size
= 0);
188 ~wxDataViewIndexListModel();
191 Compare method that sorts the items by their index.
193 int Compare(const wxDataViewItem
& item1
,
194 const wxDataViewItem
& item2
,
195 unsigned int column
, bool ascending
);
198 Oberride this to indicate that the row has special font attributes.
199 This only affects the
200 wxDataViewTextRendererText renderer.
201 See also wxDataViewItemAttr.
203 bool GetAttr(unsigned int row
, unsigned int col
,
204 wxDataViewItemAttr
& attr
);
207 Returns the wxDataViewItem at the given @e row.
209 wxDataViewItem
GetItem(unsigned int row
) const;
212 Returns the position of given @e item.
214 unsigned int GetRow(const wxDataViewItem
& item
) const;
217 Override this to allow getting values from the model.
219 void GetValue(wxVariant
& variant
, unsigned int row
,
220 unsigned int col
) const;
223 Call this after if the data has to be read again from
224 the model. This is useful after major changes when
225 calling the methods below (possibly thousands of times)
228 void Reset(unsigned int new_size
);
231 Call this after a row has been appended to the model.
236 Call this after a row has been changed.
238 void RowChanged(unsigned int row
);
241 Call this after a row has been deleted.
243 void RowDeleted(unsigned int row
);
246 Call this after a row has been inserted at the given position.
248 void RowInserted(unsigned int before
);
251 Call this after a row has been prepended to the model.
256 Call this after a value has been changed.
258 void RowValueChanged(unsigned int row
, unsigned int col
);
261 Call this after rows have been deleted. The array will internally
262 get copied and sorted in descending order so that the rows with
263 the highest position will be deleted first.
265 void RowsDeleted(const wxArrayInt
& rows
);
268 Called in order to set a value in the model.
270 bool SetValue(const wxVariant
& variant
, unsigned int row
,
276 @class wxDataViewModel
277 @wxheader{dataview.h}
279 wxDataViewModel is the base class for all data model to be
280 displayed by a wxDataViewCtrl.
281 All other models derive from it and must implement its
282 pure virtual functions in order to define a complete
283 data model. In detail, you need to override
284 wxDataViewModel::IsContainer,
285 wxDataViewModel::GetParent,
286 wxDataViewModel::GetChildren,
287 wxDataViewModel::GetColumnCount,
288 wxDataViewModel::GetColumnType and
289 wxDataViewModel::GetValue in order to
290 define the data model which acts as an interface between
291 your actual data and the wxDataViewCtrl. Since you will
292 usually also allow the wxDataViewCtrl to change your data
293 through its graphical interface, you will also have to override
294 wxDataViewModel::SetValue which the
295 wxDataViewCtrl will call when a change to some data has been
298 wxDataViewModel (as indeed the entire wxDataViewCtrl
299 code) is using wxVariant to store data and
300 its type in a generic way. wxVariant can be extended to contain
301 almost any data without changes to the original class.
303 The data that is presented through this data model is expected
304 to change at run-time. You need to inform the data model when
305 a change happened. Depending on what happened you need to call
306 one of the following methods:
307 wxDataViewModel::ValueChanged,
308 wxDataViewModel::ItemAdded,
309 wxDataViewModel::ItemDeleted,
310 wxDataViewModel::ItemChanged,
311 wxDataViewModel::Cleared. There are
312 plural forms for notification of addition, change
313 or removal of several item at once. See
314 wxDataViewModel::ItemsAdded,
315 wxDataViewModel::ItemsDeleted,
316 wxDataViewModel::ItemsChanged.
318 Note that wxDataViewModel does not define the position or
319 index of any item in the control because different controls
320 might display the same data differently. wxDataViewModel does
321 provide a wxDataViewModel::Compare method
322 which the wxDataViewCtrl may use to sort the data either
323 in conjunction with a column header or without (see
324 wxDataViewModel::HasDefaultCompare).
326 This class maintains a list of
327 wxDataViewModelNotifier
328 which link this class to the specific implementations on the
329 supported platforms so that e.g. calling
330 wxDataViewModel::ValueChanged
331 on this model will just call
332 wxDataViewModelNotifier::ValueChanged
333 for each notifier that has been added. You can also add
334 your own notifier in order to get informed about any changes
335 to the data in the list model.
337 Currently wxWidgets provides the following models apart
339 wxDataViewIndexListModel,
342 Note that wxDataViewModel is reference counted, derives from
343 wxObjectRefData and cannot be deleted
344 directly as it can be shared by several wxDataViewCtrls. This
345 implies that you need to decrease the reference count after
346 associating the model with a control like this:
349 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
350 wxDataViewModel *musicModel = new MyMusicModel;
351 m_musicCtrl-AssociateModel( musicModel );
352 musicModel-DecRef(); // avoid memory leak !!
360 class wxDataViewModel
: public wxObjectRefData
369 Destructor. This should not be called directly. Use DecRef() instead.
374 Adds a wxDataViewModelNotifier
377 void AddNotifier(wxDataViewModelNotifier
* notifier
);
380 Called to inform the model that all data has been cleared. The
381 control will reread the data from the model again.
383 virtual bool Cleared();
386 The compare function to be used by control. The default compare function
387 sorts by container and other items separately and in ascending order.
388 Override this for a different sorting behaviour.
389 See also HasDefaultCompare().
391 virtual int Compare(const wxDataViewItem
& item1
,
392 const wxDataViewItem
& item2
,
397 Oberride this to indicate that the item has special font attributes.
398 This only affects the
399 wxDataViewTextRendererText renderer.
400 See also wxDataViewItemAttr.
402 bool GetAttr(const wxDataViewItem
& item
, unsigned int col
,
403 wxDataViewItemAttr
& attr
);
406 Override this so the control can query the child items of
407 an item. Returns the number of items.
409 virtual unsigned int GetChildren(const wxDataViewItem
& item
,
410 wxDataViewItemArray
& children
) const;
413 Override this to indicate the number of columns in the model.
415 virtual unsigned int GetColumnCount() const;
418 Override this to indicate what type of data is stored in the
419 column specified by @e col. This should return a string
420 indicating the type of data as reported by wxVariant.
422 virtual wxString
GetColumnType(unsigned int col
) const;
425 Override this to indicate which wxDataViewItem representing the parent
426 of @a item or an invalid wxDataViewItem if the the root item is
429 virtual wxDataViewItem
GetParent(const wxDataViewItem
& item
) const;
432 Override this to indicate the value of @e item
433 A wxVariant is used to store the data.
435 virtual void GetValue(wxVariant
& variant
,
436 const wxDataViewItem
& item
,
437 unsigned int col
) const;
440 Override this method to indicate if a container item merely
441 acts as a headline (or for categorisation) or if it also
442 acts a normal item with entries for futher columns. By
443 default returns @e @false.
445 virtual bool HasContainerColumns(const wxDataViewItem
& item
) const;
448 Override this to indicate that the model provides a default compare
449 function that the control should use if no wxDataViewColumn has been
450 chosen for sorting. Usually, the user clicks on a column header for
451 sorting, the data will be sorted alphanumerically. If any other
452 order (e.g. by index or order of appearance) is required, then this
453 should be used. See also wxDataViewIndexListModel
454 for a model which makes use of this.
456 virtual bool HasDefaultCompare() const;
459 Override this to indicate of @a item is a container, i.e. if
460 it can have child items.
462 virtual bool IsContainer(const wxDataViewItem
& item
) const;
465 Call this to inform the model that an item has been added
468 virtual bool ItemAdded(const wxDataViewItem
& parent
,
469 const wxDataViewItem
& item
);
472 Call this to inform the model that an item has changed.
473 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
474 event (in which the column fields will not be set) to the user.
476 virtual bool ItemChanged(const wxDataViewItem
& item
);
479 Call this to inform the model that an item has been deleted from the data.
481 virtual bool ItemDeleted(const wxDataViewItem
& parent
,
482 const wxDataViewItem
& item
);
485 Call this to inform the model that several items have been added
488 virtual bool ItemsAdded(const wxDataViewItem
& parent
,
489 const wxDataViewItemArray
& items
);
492 Call this to inform the model that several items have changed.
493 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
494 events (in which the column fields will not be set) to the user.
496 virtual bool ItemsChanged(const wxDataViewItemArray
& items
);
499 Call this to inform the model that several items have been deleted.
501 virtual bool ItemsDeleted(const wxDataViewItem
& parent
,
502 const wxDataViewItemArray
& items
);
505 Remove the @a notifier from the list of notifiers.
507 void RemoveNotifier(wxDataViewModelNotifier
* notifier
);
510 Call this to initiate a resort after the sort function has
513 virtual void Resort();
516 This gets called in order to set a value in the data model.
517 The most common scenario is that the wxDataViewCtrl calls
518 this method after the user changed some data in the view.
519 Afterwards ValueChanged()
522 virtual bool SetValue(const wxVariant
& variant
,
523 const wxDataViewItem
& item
,
527 Call this to inform this model that a value in the model has
528 been changed. This is also called from wxDataViewCtrl's
529 internal editing code, e.g. when editing a text field
531 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
534 virtual bool ValueChanged(const wxDataViewItem
& item
,
540 @class wxDataViewCustomRenderer
541 @wxheader{dataview.h}
543 You need to derive a new class from wxDataViewCustomRenderer in
544 order to write a new renderer. You need to override at least
545 wxDataViewRenderer::SetValue,
546 wxDataViewRenderer::GetValue,
547 wxDataViewCustomRenderer::GetSize
548 and wxDataViewCustomRenderer::Render.
550 If you want your renderer to support in-place editing then you
551 also need to override
552 wxDataViewCustomRenderer::HasEditorCtrl,
553 wxDataViewCustomRenderer::CreateEditorCtrl
554 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
555 Note that a special event handler will be pushed onto that
556 editor control which handles ENTER and focus out events
557 in order to end the editing.
562 class wxDataViewCustomRenderer
: public wxDataViewRenderer
568 wxDataViewCustomRenderer(const wxString
& varianttype
= "string",
569 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
570 bool no_init
= false);
575 ~wxDataViewCustomRenderer();
578 Override this to react to double clicks or ENTER.
580 virtual bool Activate(wxRect cell
, wxDataViewModel
* model
,
585 Override this to create the actual editor control once editing
586 is about to start. @a parent is the parent of the editor
587 control, @a labelRect indicates the position and
588 size of the editor control and @a value is its initial value:
590 virtual wxControl
* CreateEditorCtrl(wxWindow
* parent
,
592 const wxVariant
& value
);
595 Create DC on request. Internal.
597 virtual wxDC
* GetDC();
600 Return size required to show content.
602 virtual wxSize
GetSize();
605 Overrride this so that the renderer can get the value
606 from the editor control (pointed to by @e editor):
608 virtual bool GetValueFromEditorCtrl(wxControl
* editor
,
612 Override this and make it return @e @true in order to
613 indicate that this renderer supports in-place editing.
615 virtual bool HasEditorCtrl();
618 Overrride this to react to a left click.
620 virtual bool LeftClick(wxPoint cursor
, wxRect cell
,
621 wxDataViewModel
* model
,
626 Override this to render the cell. Before this is called,
627 wxDataViewRenderer::SetValue was called
628 so that this instance knows what to render.
630 virtual bool Render(wxRect cell
, wxDC
* dc
, int state
);
633 This method should be called from within Render()
634 whenever you need to render simple text. This will ensure that the
635 correct colour, font and vertical alignment will be chosen so the
636 text will look the same as text drawn by native renderers.
638 bool RenderText(const wxString
& text
, int xoffset
, wxRect cell
,
639 wxDC
* dc
, int state
);
642 Overrride this to react to a right click.
644 virtual bool RightClick(wxPoint cursor
, wxRect cell
,
645 wxDataViewModel
* model
,
650 Overrride this to start a drag operation.
652 virtual bool StartDrag(wxPoint cursor
, wxRect cell
,
653 wxDataViewModel
* model
,
660 @class wxDataViewBitmapRenderer
661 @wxheader{dataview.h}
663 wxDataViewBitmapRenderer
668 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
674 wxDataViewBitmapRenderer(const wxString
& varianttype
= "wxBitmap",
675 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
680 @class wxDataViewItemAttr
681 @wxheader{dataview.h}
683 This class is used to indicate to a wxDataViewCtrl
684 that a certain Item has extra font attributes
685 for its renderer. For this, it is required to override
686 wxDataViewModel::GetAttr.
688 Attributes are currently only supported by
689 wxDataViewTextRendererText.
694 class wxDataViewItemAttr
700 wxDataViewItemAttr();
703 Call this to indicate that the item shall be displayed in bold text.
705 void SetBold(bool set
);
708 Call this to indicate that the item shall be displayed with
711 void SetColour(const wxColour
& colour
);
714 Call this to indicate that the item shall be displayed in italic text.
716 void SetItalic(bool set
);
721 @class wxDataViewItem
722 @wxheader{dataview.h}
724 wxDataViewItem is a small opaque class that represents an
725 item in a wxDataViewCtrl in a
726 persistent way, i.e. indepent of the position of the
727 item in the control or changes to its contents. It must
728 hold a unique ID of type @e void* in its only field
729 and can be converted to a from it.
731 If the ID is @e @NULL the wxDataViewItem is invalid and
732 wxDataViewItem::IsOk will return @e @false
733 which used in many places in the API of wxDataViewCtrl
734 to indicate that e.g. no item was found. An ID of @NULL
735 is also used to indicate the invisible root. Examples
737 wxDataViewModel::GetParent and
738 wxDataViewModel::GetChildren.
750 wxDataViewItem(void* id
= NULL
);
751 wxDataViewItem(const wxDataViewItem
& item
);
760 Returns @true if the ID is not @e @NULL.
767 @class wxDataViewCtrl
768 @wxheader{dataview.h}
770 wxDataViewCtrl is a control to display data either
771 in a tree like fashion or in a tabular form or both.
772 If you only need to display a simple tree structure
773 with an API more like the older wxTreeCtrl class,
774 then the specialized wxDataViewTreeCtrl
777 A wxDataViewItem is used
778 to represent a (visible) item in the control.
780 Unlike wxListCtrl wxDataViewCtrl doesn't
781 get its data from the user through virtual functions or by
782 setting it directly. Instead you need to write your own
783 wxDataViewModel and associate
784 it with this control. Then you need to add a number of
785 wxDataViewColumn to this control to
786 define what each column shall display. Each wxDataViewColumn
787 in turn owns 1 instance of a
788 wxDataViewRenderer to render its
789 cells. A number of standard renderers for rendering text, dates,
790 images, toggle, a progress bar etc. are provided. Additionally,
791 the user can write custom renderes deriving from
792 wxDataViewCustomRenderer
793 for displaying anything.
795 All data transfer from the control to the model and the user
796 code is done through wxVariant which can
797 be extended to support more data formats as necessary.
798 Accordingly, all type information uses the strings returned
799 from wxVariant::GetType.
803 Single selection mode. This is the default.
804 @style{wxDV_MULTIPLE}:
805 Multiple selection mode.
806 @style{wxDV_ROW_LINES}:
807 Use alternating colours for rows if supported by platform and theme.
808 @style{wxDV_HORIZ_RULES}:
809 Display fine rules between row if supported.
810 @style{wxDV_VERT_RULES}:
811 Display fine rules between columns is supported.
816 @appearance{dataviewctrl.png}
818 class wxDataViewCtrl
: public wxControl
823 Constructor. Calls Create().
826 wxDataViewCtrl(wxWindow
* parent
, wxWindowID id
,
827 const wxPoint
& pos
= wxDefaultPosition
,
828 const wxSize
& size
= wxDefaultSize
,
830 const wxValidator
& validator
= wxDefaultValidator
);
840 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
841 created in the function or @NULL on failure.
843 wxDataViewColumn
* AppendBitmapColumn(const wxString
& label
,
844 unsigned int model_column
,
845 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
847 wxAlignment align
= wxALIGN_CENTER
,
848 int flags
= wxDATAVIEW_COL_RESIZABLE
);
849 wxDataViewColumn
* AppendBitmapColumn(const wxBitmap
& label
,
850 unsigned int model_column
,
851 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
853 wxAlignment align
= wxALIGN_CENTER
,
854 int flags
= wxDATAVIEW_COL_RESIZABLE
);
858 Add a wxDataViewColumn to the control. Returns
860 Note that there is a number of short cut methods which implicitly create
861 a wxDataViewColumn and a
862 wxDataViewRenderer for it (see below).
864 virtual bool AppendColumn(wxDataViewColumn
* col
);
868 Appends a column for rendering a date. Returns the wxDataViewColumn
869 created in the function or @NULL on failure.
871 wxDataViewColumn
* AppendDateColumn(const wxString
& label
,
872 unsigned int model_column
,
873 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
875 wxAlignment align
= wxALIGN_CENTER
,
876 int flags
= wxDATAVIEW_COL_RESIZABLE
);
877 wxDataViewColumn
* AppendDateColumn(const wxBitmap
& label
,
878 unsigned int model_column
,
879 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
881 wxAlignment align
= wxALIGN_CENTER
,
882 int flags
= wxDATAVIEW_COL_RESIZABLE
);
887 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
888 created in the function or @NULL on failure. This uses the
889 wxDataViewIconTextRenderer.
891 wxDataViewColumn
* AppendIconTextColumn(const wxString
& label
,
892 unsigned int model_column
,
893 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
895 wxAlignment align
= wxALIGN_LEFT
,
896 int flags
= wxDATAVIEW_COL_RESIZABLE
);
897 wxDataViewColumn
* AppendIconTextColumn(const wxBitmap
& label
,
898 unsigned int model_column
,
899 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
901 wxAlignment align
= wxALIGN_LEFT
,
902 int flags
= wxDATAVIEW_COL_RESIZABLE
);
907 Appends a column for rendering a progress indicator. Returns the
909 created in the function or @NULL on failure.
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 wxDataViewColumn
* AppendTextColumn(const wxString
& label
,
931 unsigned int model_column
,
932 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
934 wxAlignment align
= wxALIGN_LEFT
,
935 int flags
= wxDATAVIEW_COL_RESIZABLE
);
936 wxDataViewColumn
* AppendTextColumn(const wxBitmap
& label
,
937 unsigned int model_column
,
938 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
940 wxAlignment align
= wxALIGN_LEFT
,
941 int flags
= wxDATAVIEW_COL_RESIZABLE
);
946 Appends a column for rendering a toggle. Returns the wxDataViewColumn
947 created in the function or @NULL on failure.
949 wxDataViewColumn
* AppendToggleColumn(const wxString
& label
,
950 unsigned int model_column
,
951 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
953 wxAlignment align
= wxALIGN_CENTER
,
954 int flags
= wxDATAVIEW_COL_RESIZABLE
);
955 wxDataViewColumn
* AppendToggleColumn(const wxBitmap
& label
,
956 unsigned int model_column
,
957 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
959 wxAlignment align
= wxALIGN_CENTER
,
960 int flags
= wxDATAVIEW_COL_RESIZABLE
);
964 Associates a wxDataViewModel with the
965 control. This increases the reference count of the model by 1.
967 virtual bool AssociateModel(wxDataViewModel
* model
);
972 virtual bool ClearColumns();
977 void ClearSelection();
982 void Collapse(const wxDataViewItem
& item
);
985 Create the control. Useful for two step creation.
987 bool Create(wxWindow
* parent
, wxWindowID id
,
988 const wxPoint
& pos
= wxDefaultPosition
,
989 const wxSize
& size
= wxDefaultSize
,
991 const wxValidator
& validator
= wxDefaultValidator
);
994 Deletes given column.
996 virtual bool DeleteColumn(const wxDataViewColumn
* column
);
999 Call this to ensure that the given item is visible.
1001 void EnsureVisible(const wxDataViewItem
& item
,
1002 const wxDataViewColumn
* column
= NULL
);
1007 void Expand(const wxDataViewItem
& item
);
1010 Returns pointer to the column. @a pos refers to the
1011 position in the control which may change after reordering
1012 columns by the user.
1014 virtual wxDataViewColumn
* GetColumn(unsigned int pos
) const;
1017 Returns the number of columns.
1019 virtual unsigned int GetColumnCount() const;
1022 Returns the position of the column or -1 if not found in the control.
1024 virtual int GetColumnPosition(const wxDataViewColumn
* column
) const;
1027 Returns column containing the expanders.
1029 wxDataViewColumn
* GetExpanderColumn() const;
1032 Returns indentation.
1034 int GetIndent() const;
1039 wxRect
GetItemRect(const wxDataViewItem
& item
,
1040 const wxDataViewColumn
* col
= NULL
) const;
1043 Returns pointer to the data model associated with the
1046 virtual wxDataViewModel
* GetModel() const;
1049 Returns first selected item or an invalid item if none is selected.
1051 wxDataViewItem
GetSelection() const;
1054 Fills @a sel with currently selected items and returns
1057 int GetSelections(wxDataViewItemArray
& sel
) const;
1060 Returns the wxDataViewColumn currently responsible for sorting
1061 or @NULL if none has been selected.
1063 virtual wxDataViewColumn
* GetSortingColumn() const;
1068 void HitTest(const wxPoint
& point
, wxDataViewItem
& item
,
1069 wxDataViewColumn
*& col
) const;
1072 Return @true if the item is selected.
1074 bool IsSelected(const wxDataViewItem
& item
) const;
1077 Select the given item.
1079 void Select(const wxDataViewItem
& item
);
1087 Set which column shall contain the tree-like expanders.
1089 void SetExpanderColumn(wxDataViewColumn
* col
);
1092 Sets the indendation.
1094 void SetIndent(int indent
);
1097 Sets the selection to the array of wxDataViewItems.
1099 void SetSelections(const wxDataViewItemArray
& sel
);
1102 Unselect the given item.
1104 void Unselect(const wxDataViewItem
& item
);
1107 Unselect all item. This method only has effect if multiple
1108 selections are allowed.
1115 @class wxDataViewModelNotifier
1116 @wxheader{dataview.h}
1118 A wxDataViewModelNotifier instance is owned by a
1120 and mirrors its notification interface. See
1121 the documentation of that class for further
1127 class wxDataViewModelNotifier
1133 wxDataViewModelNotifier();
1138 ~wxDataViewModelNotifier();
1141 Called by owning model.
1146 Get owning wxDataViewModel.
1148 wxDataViewModel
* GetOwner();
1151 Called by owning model.
1153 bool ItemAdded(const wxDataViewItem
& parent
,
1154 const wxDataViewItem
& item
);
1157 Called by owning model.
1159 bool ItemChanged(const wxDataViewItem
& item
);
1162 Called by owning model.
1164 bool ItemDeleted(const wxDataViewItem
& parent
,
1165 const wxDataViewItem
& item
);
1168 Called by owning model.
1170 bool ItemsAdded(const wxDataViewItem
& parent
,
1171 const wxDataViewItemArray
& items
);
1174 Called by owning model.
1176 bool ItemsChanged(const wxDataViewItemArray
& items
);
1179 Called by owning model.
1181 bool ItemsDeleted(const wxDataViewItem
& parent
,
1182 const wxDataViewItemArray
& items
);
1185 Called by owning model.
1190 Set owner of this notifier. Used internally.
1192 void SetOwner(wxDataViewModel
* owner
);
1195 Called by owning model.
1197 bool ValueChanged(const wxDataViewItem
& item
, unsigned int col
);
1202 @class wxDataViewRenderer
1203 @wxheader{dataview.h}
1205 This class is used by wxDataViewCtrl to
1206 render the individual cells. One instance of a renderer class is
1207 owned by wxDataViewColumn. There is
1208 a number of ready-to-use renderers provided:
1209 wxDataViewTextRenderer,
1210 wxDataViewTextRendererAttr,
1211 wxDataViewIconTextRenderer,
1212 wxDataViewToggleRenderer,
1213 wxDataViewProgressRenderer,
1214 wxDataViewBitmapRenderer,
1215 wxDataViewDateRenderer.
1216 wxDataViewSpinRenderer.
1218 Additionally, the user can write own renderers by deriving from
1219 wxDataViewCustomRenderer.
1221 The @e wxDataViewCellMode flag controls, what actions
1222 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1223 indicates that the user can double click the cell and
1224 something will happen (e.g. a window for editing a date
1225 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1226 that the user can edit the data in-place, i.e. an control
1227 will show up after a slow click on the cell. This behaviour
1228 is best known from changing the filename in most file
1233 enum wxDataViewCellMode
1235 wxDATAVIEW_CELL_INERT,
1236 wxDATAVIEW_CELL_ACTIVATABLE,
1237 wxDATAVIEW_CELL_EDITABLE
1241 The @e wxDataViewCellRenderState flag controls how the
1242 the renderer should display its contents in a cell:
1245 enum wxDataViewCellRenderState
1247 wxDATAVIEW_CELL_SELECTED = 1,
1248 wxDATAVIEW_CELL_PRELIT = 2,
1249 wxDATAVIEW_CELL_INSENSITIVE = 4,
1250 wxDATAVIEW_CELL_FOCUSED = 8
1258 class wxDataViewRenderer
: public wxObject
1264 wxDataViewRenderer(const wxString
& varianttype
,
1265 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1266 int alignment
= wxALIGN_LEFT
|wxALIGN_CENTRE_VERTICAL
);
1269 Returns the cell mode.
1271 virtual wxDataViewCellMode
GetMode();
1274 Returns pointer to the owning wxDataViewColumn.
1276 virtual wxDataViewColumn
* GetOwner();
1279 This methods retrieves the value from the renderer in order to
1280 transfer the value back to the data model. Returns @e @false
1283 virtual bool GetValue(wxVariant
& value
);
1286 Returns a string with the type of the wxVariant
1287 supported by this renderer.
1289 virtual wxString
GetVariantType();
1292 Sets the owning wxDataViewColumn. This
1293 is usually called from within wxDataViewColumn.
1295 virtual void SetOwner(wxDataViewColumn
* owner
);
1298 Set the value of the renderer (and thus its cell) to @e value.
1299 The internal code will then render this cell with this data.
1301 virtual bool SetValue(const wxVariant
& value
);
1304 Before data is committed to the data model, it is passed to this
1305 method where it can be checked for validity. This can also be
1306 used for checking a valid range or limiting the user input in
1307 a certain aspect (e.g. max number of characters or only alphanumeric
1308 input, ASCII only etc.). Return @e @false if the value is
1310 Please note that due to implementation limitations, this validation
1311 is done after the editing control already is destroyed and the
1312 editing process finished.
1314 virtual bool Validate(wxVariant
& value
);
1319 @class wxDataViewTextRenderer
1320 @wxheader{dataview.h}
1322 wxDataViewTextRenderer is used for rendering text. It supports
1323 in-place editing if desired.
1328 class wxDataViewTextRenderer
: public wxDataViewRenderer
1334 wxDataViewTextRenderer(const wxString
& varianttype
= "string",
1335 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1340 @class wxDataViewProgressRenderer
1341 @wxheader{dataview.h}
1343 wxDataViewProgressRenderer
1348 class wxDataViewProgressRenderer
: public wxDataViewRenderer
1354 wxDataViewProgressRenderer(const wxString
& label
= wxEmptyString
,
1355 const wxString
& varianttype
= "long",
1356 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1361 @class wxDataViewSpinRenderer
1362 @wxheader{dataview.h}
1364 This is a specialized renderer for rendering integer values. It
1365 supports modifying the values in-place by using a wxSpinCtrl.
1366 The renderer only support variants of type @e long.
1371 class wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1375 Constructor. @a min and @a max indicate the minimum und
1376 maximum values of for the wxSpinCtrl.
1378 wxDataViewSpinRenderer(int min
, int max
,
1379 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1380 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1385 @class wxDataViewToggleRenderer
1386 @wxheader{dataview.h}
1388 wxDataViewToggleRenderer
1393 class wxDataViewToggleRenderer
: public wxDataViewRenderer
1399 wxDataViewToggleRenderer(const wxString
& varianttype
= "bool",
1400 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
1405 @class wxDataViewTreeCtrl
1406 @wxheader{dataview.h}
1408 This class is a wxDataViewCtrl which internally
1409 uses a wxDataViewTreeStore and forwards
1410 most of its API to that class. Additionally, it uses a wxImageList
1411 to store a list of icons. The main purpose of this class is to look
1412 like a wxTreeCtrl to make a transition from it
1413 to the wxDataViewCtrl class simpler.
1417 @appearance{dataviewtreectrl.png}
1419 class wxDataViewTreeCtrl
: public wxDataViewCtrl
1424 Constructor. Calls Create().
1426 wxDataViewTreeCtrl();
1427 wxDataViewTreeCtrl(wxWindow
* parent
, wxWindowID id
,
1428 const wxPoint
& pos
= wxDefaultPosition
,
1429 const wxSize
& size
= wxDefaultSize
,
1430 long style
= wxDV_NO_HEADER
,
1431 const wxValidator
& validator
= wxDefaultValidator
);
1435 Destructor. Deletes the image list if any.
1437 ~wxDataViewTreeCtrl();
1442 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1443 const wxString
& text
,
1446 wxClientData
* data
= NULL
);
1451 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1452 const wxString
& text
,
1454 wxClientData
* data
= NULL
);
1457 Creates the control and a wxDataViewTreeStore as
1460 bool Create(wxWindow
* parent
, wxWindowID id
,
1461 const wxPoint
& pos
= wxDefaultPosition
,
1462 const wxSize
& size
= wxDefaultSize
,
1463 long style
= wxDV_NO_HEADER
,
1464 const wxValidator
& validator
= wxDefaultValidator
);
1467 Calls the identical method from wxDataViewTreeStore.
1469 void DeleteAllItems();
1472 Calls the identical method from wxDataViewTreeStore.
1474 void DeleteChildren(const wxDataViewItem
& item
);
1477 Calls the identical method from wxDataViewTreeStore.
1479 void DeleteItem(const wxDataViewItem
& item
);
1482 Calls the identical method from wxDataViewTreeStore.
1484 int GetChildCount(const wxDataViewItem
& parent
) const;
1487 Returns the image list.
1489 wxImageList
* GetImageList();
1492 Calls the identical method from wxDataViewTreeStore.
1494 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1497 Calls the identical method from wxDataViewTreeStore.
1499 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1502 Calls the identical method from wxDataViewTreeStore.
1504 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1507 Calls the identical method from wxDataViewTreeStore.
1509 wxString
GetItemText(const wxDataViewItem
& item
) const;
1512 Calls the identical method from wxDataViewTreeStore.
1514 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1515 unsigned int pos
) const;
1521 wxDataViewTreeStore
* GetStore() const;
1522 const wxDataViewTreeStore
* GetStore() const;
1526 Calls the same method from wxDataViewTreeStore but uess
1527 and index position in the image list instead of a wxIcon.
1529 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1530 const wxDataViewItem
& previous
,
1531 const wxString
& text
,
1534 wxClientData
* data
= NULL
);
1537 Calls the same method from wxDataViewTreeStore but uess
1538 and index position in the image list instead of a wxIcon.
1540 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1541 const wxDataViewItem
& previous
,
1542 const wxString
& text
,
1544 wxClientData
* data
= NULL
);
1547 Calls the same method from wxDataViewTreeStore but uess
1548 and index position in the image list instead of a wxIcon.
1550 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1551 const wxString
& text
,
1554 wxClientData
* data
= NULL
);
1557 Calls the same method from wxDataViewTreeStore but uess
1558 and index position in the image list instead of a wxIcon.
1560 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1561 const wxString
& text
,
1563 wxClientData
* data
= NULL
);
1566 Sets the image list.
1568 void SetImageList(wxImageList
* imagelist
);
1571 Calls the identical method from wxDataViewTreeStore.
1573 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1576 Calls the identical method from wxDataViewTreeStore.
1578 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1579 const wxIcon
& icon
);
1582 Calls the identical method from wxDataViewTreeStore.
1584 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1587 Calls the identical method from wxDataViewTreeStore.
1589 void SetItemText(const wxDataViewItem
& item
,
1590 const wxString
& text
);
1595 @class wxDataViewTreeStore
1596 @wxheader{dataview.h}
1598 wxDataViewTreeStore is a specialised wxDataViewModel
1599 for displaying simple trees very much like wxTreeCtrl
1600 does and it offers a similar API. This class actually stores the entire
1601 tree (therefore its name) and implements all virtual methods from the base
1602 class so it can be used directly without having to derive any class from it.
1603 This comes at the price of much reduced flexibility.
1608 class wxDataViewTreeStore
: public wxDataViewModel
1612 Constructor. Creates the invisible root node internally.
1614 wxDataViewTreeStore();
1619 ~wxDataViewTreeStore();
1624 wxDataViewItem
AppendContainer(const wxDataViewItem
& parent
,
1625 const wxString
& text
,
1626 const wxIcon
& icon
= wxNullIcon
,
1627 const wxIcon
& expanded
= wxNullIcon
,
1628 wxClientData
* data
= NULL
);
1633 wxDataViewItem
AppendItem(const wxDataViewItem
& parent
,
1634 const wxString
& text
,
1635 const wxIcon
& icon
= wxNullIcon
,
1636 wxClientData
* data
= NULL
);
1639 Delete all item in the model.
1641 void DeleteAllItems();
1644 Delete all children of the item, but not the item itself.
1646 void DeleteChildren(const wxDataViewItem
& item
);
1651 void DeleteItem(const wxDataViewItem
& item
);
1654 Return the number of children of item.
1656 int GetChildCount(const wxDataViewItem
& parent
) const;
1659 Returns the client data asoociated with the item.
1661 wxClientData
* GetItemData(const wxDataViewItem
& item
) const;
1664 Returns the icon to display in expanded containers.
1666 const wxIcon
GetItemExpandedIcon(const wxDataViewItem
& item
) const;
1669 Returns the icon of the item.
1671 const wxIcon
GetItemIcon(const wxDataViewItem
& item
) const;
1674 Returns the text of the item.
1676 wxString
GetItemText(const wxDataViewItem
& item
) const;
1679 Returns the nth child item of item.
1681 wxDataViewItem
GetNthChild(const wxDataViewItem
& parent
,
1682 unsigned int pos
) const;
1685 Inserts a container after @e previous.
1687 wxDataViewItem
InsertContainer(const wxDataViewItem
& parent
,
1688 const wxDataViewItem
& previous
,
1689 const wxString
& text
,
1690 const wxIcon
& icon
= wxNullIcon
,
1691 const wxIcon
& expanded
= wxNullIcon
,
1692 wxClientData
* data
= NULL
);
1695 Inserts an item after @e previous.
1697 wxDataViewItem
InsertItem(const wxDataViewItem
& parent
,
1698 const wxDataViewItem
& previous
,
1699 const wxString
& text
,
1700 const wxIcon
& icon
= wxNullIcon
,
1701 wxClientData
* data
= NULL
);
1704 Inserts a container before the first child item or @e parent.
1706 wxDataViewItem
PrependContainer(const wxDataViewItem
& parent
,
1707 const wxString
& text
,
1708 const wxIcon
& icon
= wxNullIcon
,
1709 const wxIcon
& expanded
= wxNullIcon
,
1710 wxClientData
* data
= NULL
);
1713 Inserts an item before the first child item or @e parent.
1715 wxDataViewItem
PrependItem(const wxDataViewItem
& parent
,
1716 const wxString
& text
,
1717 const wxIcon
& icon
= wxNullIcon
,
1718 wxClientData
* data
= NULL
);
1721 Sets the client data associated with the item.
1723 void SetItemData(const wxDataViewItem
& item
, wxClientData
* data
);
1726 Sets the expanded icon for the item.
1728 void SetItemExpandedIcon(const wxDataViewItem
& item
,
1729 const wxIcon
& icon
);
1732 Sets the icon for the item.
1734 void SetItemIcon(const wxDataViewItem
& item
, const wxIcon
& icon
);
1739 @class wxDataViewDateRenderer
1740 @wxheader{dataview.h}
1742 wxDataViewDateRenderer
1747 class wxDataViewDateRenderer
: public wxDataViewRenderer
1753 wxDataViewDateRenderer(const wxString
& varianttype
= "datetime",
1754 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
1759 @class wxDataViewTextRendererAttr
1760 @wxheader{dataview.h}
1762 The same as wxDataViewTextRenderer but with
1763 support for font attributes. Font attributes are currently only supported
1766 See also wxDataViewModel::GetAttr and
1772 class wxDataViewTextRendererAttr
: public wxDataViewTextRenderer
1778 wxDataViewTextRendererAttr(const wxString
& varianttype
= "string",
1779 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1780 int align
= wxDVR_DEFAULT_ALIGNMENT
);
1785 @class wxDataViewColumn
1786 @wxheader{dataview.h}
1788 This class represents a column in a wxDataViewCtrl.
1789 One wxDataViewColumn is bound to one column in the data model,
1790 to which the wxDataViewCtrl has been associated.
1792 An instance of wxDataViewRenderer is used by
1793 this class to render its data.
1798 class wxDataViewColumn
: public wxObject
1805 wxDataViewColumn(const wxString
& title
,
1806 wxDataViewRenderer
* renderer
,
1807 unsigned int model_column
,
1808 int width
= wxDVC_DEFAULT_WIDTH
,
1809 wxAlignment align
= wxALIGN_CENTRE
,
1810 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1811 wxDataViewColumn(const wxBitmap
& bitmap
,
1812 wxDataViewRenderer
* renderer
,
1813 unsigned int model_column
,
1814 int width
= wxDVC_DEFAULT_WIDTH
,
1815 wxAlignment align
= wxALIGN_CENTRE
,
1816 int flags
= wxDATAVIEW_COL_RESIZABLE
);
1822 ~wxDataViewColumn();
1825 Returns the bitmap in the header of the column, if any.
1827 const wxBitmap
GetBitmap();
1830 Returns the index of the column of the model, which this
1831 wxDataViewColumn is displaying.
1833 unsigned int GetModelColumn();
1836 Returns the owning wxDataViewCtrl.
1838 wxDataViewCtrl
* GetOwner();
1841 Returns the renderer of this wxDataViewColumn.
1842 See also wxDataViewRenderer.
1844 wxDataViewRenderer
* GetRenderer();
1847 Returns @true if the column is reorderable.
1849 bool GetReorderable();
1852 Returns @true if the column is sortable.
1858 Returns the width of the column.
1863 Returns @true, if the sort order is ascending.
1864 See also SetSortOrder()
1866 bool IsSortOrderAscending();
1869 Set the alignment of the column header.
1871 void SetAlignment(wxAlignment align
);
1874 Set the bitmap of the column header.
1876 void SetBitmap(const wxBitmap
& bitmap
);
1879 Indicate wether the column can be reordered by the
1880 user using the mouse. This is typically implemented
1881 visually by dragging the header button around.
1883 void SetReorderable(bool reorderable
);
1886 Indicate the sort order if the implementation of the
1887 wxDataViewCtrl supports it, most commonly by showing
1890 void SetSortOrder(bool ascending
);
1893 Indicate that the column is sortable. This does
1894 not show any sorting indicate yet, but it does
1895 make the column header clickable. Call
1897 afterwards to actually make the sort indicator appear.
1898 If @a sortable is @false, the column header is
1899 no longer clickable and the sort indicator (little
1900 arrow) will disappear.
1902 void SetSortable(bool sortable
);
1905 Set the title of the column header to @e title.
1907 void SetTitle(const wxString
& title
);