Don't lose selection in wxDataViewCtrl::Select() under Mac.
[wxWidgets.git] / interface / wx / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dataview.h
3 // Purpose: interface of wxDataView* classes
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 @class wxDataViewModel
12
13 wxDataViewModel is the base class for all data model to be displayed by a
14 wxDataViewCtrl.
15
16 All other models derive from it and must implement its pure virtual functions
17 in order to define a complete data model. In detail, you need to override
18 wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren,
19 wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and
20 wxDataViewModel::GetValue in order to define the data model which acts as an
21 interface between your actual data and the wxDataViewCtrl.
22
23 Note that wxDataViewModel does not define the position or index of any item
24 in the control because different controls might display the same data differently.
25 wxDataViewModel does provide a wxDataViewModel::Compare method which the
26 wxDataViewCtrl may use to sort the data either in conjunction with a column
27 header or without (see wxDataViewModel::HasDefaultCompare).
28
29 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
30 to store data and its type in a generic way. wxVariant can be extended to contain
31 almost any data without changes to the original class. To a certain extent,
32 you can use (the somewhat more elegant) wxAny instead of wxVariant as there
33 is code to convert between the two, but it is unclear what impact this will
34 have on performance.
35
36 Since you will usually allow the wxDataViewCtrl to change your data
37 through its graphical interface, you will also have to override
38 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
39 to some data has been committed.
40
41 If the data represented by the model is changed by something else than its
42 associated wxDataViewCtrl, the control has to be notified about the change.
43 Depending on what happened you need to call one of the following methods:
44 - wxDataViewModel::ValueChanged,
45 - wxDataViewModel::ItemAdded,
46 - wxDataViewModel::ItemDeleted,
47 - wxDataViewModel::ItemChanged,
48 - wxDataViewModel::Cleared.
49
50 There are plural forms for notification of addition, change or removal of
51 several item at once. See:
52 - wxDataViewModel::ItemsAdded,
53 - wxDataViewModel::ItemsDeleted,
54 - wxDataViewModel::ItemsChanged.
55
56 This class maintains a list of wxDataViewModelNotifier which link this class
57 to the specific implementations on the supported platforms so that e.g. calling
58 wxDataViewModel::ValueChanged on this model will just call
59 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
60 You can also add your own notifier in order to get informed about any changes
61 to the data in the list model.
62
63 Currently wxWidgets provides the following models apart from the base model:
64 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
65 wxDataViewListStore.
66
67 Note that wxDataViewModel is reference counted, derives from wxRefCounter
68 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
69 This implies that you need to decrease the reference count after
70 associating the model with a control like this:
71
72 @code
73 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
74 wxDataViewModel *musicModel = new MyMusicModel;
75 m_musicCtrl->AssociateModel( musicModel );
76 musicModel->DecRef(); // avoid memory leak !!
77
78 // add columns now
79 @endcode
80
81 A potentially better way to avoid memory leaks is to use wxObjectDataPtr
82
83 @code
84 wxObjectDataPtr<MyMusicModel> musicModel;
85
86 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
87 musicModel = new MyMusicModel;
88 m_musicCtrl->AssociateModel( musicModel.get() );
89
90 // add columns now
91 @endcode
92
93
94 @library{wxadv}
95 @category{dvc}
96 */
97 class wxDataViewModel : public wxRefCounter
98 {
99 public:
100 /**
101 Constructor.
102 */
103 wxDataViewModel();
104
105 /**
106 Adds a wxDataViewModelNotifier to the model.
107 */
108 void AddNotifier(wxDataViewModelNotifier* notifier);
109
110 /**
111 Change the value of the given item and update the control to reflect
112 it.
113
114 This function simply calls SetValue() and, if it succeeded,
115 ValueChanged().
116
117 @since 2.9.1
118
119 @param variant
120 The new value.
121 @param item
122 The item (row) to update.
123 @param col
124 The column to update.
125 @return
126 @true if both SetValue() and ValueChanged() returned @true.
127 */
128 bool ChangeValue(const wxVariant& variant,
129 const wxDataViewItem& item,
130 unsigned int col);
131
132 /**
133 Called to inform the model that all data has been cleared.
134 The control will reread the data from the model again.
135 */
136 virtual bool Cleared();
137
138 /**
139 The compare function to be used by control. The default compare function
140 sorts by container and other items separately and in ascending order.
141 Override this for a different sorting behaviour.
142
143 @see HasDefaultCompare().
144 */
145 virtual int Compare(const wxDataViewItem& item1,
146 const wxDataViewItem& item2,
147 unsigned int column,
148 bool ascending) const;
149
150 /**
151 Override this to indicate that the item has special font attributes.
152 This only affects the wxDataViewTextRendererText renderer.
153
154 The base class version always simply returns @false.
155
156 @see wxDataViewItemAttr.
157
158 @param item
159 The item for which the attribute is requested.
160 @param col
161 The column of the item for which the attribute is requested.
162 @param attr
163 The attribute to be filled in if the function returns @true.
164 @return
165 @true if this item has an attribute or @false otherwise.
166 */
167 virtual bool GetAttr(const wxDataViewItem& item, unsigned int col,
168 wxDataViewItemAttr& attr) const;
169
170 /**
171 Override this so the control can query the child items of an item.
172 Returns the number of items.
173 */
174 virtual unsigned int GetChildren(const wxDataViewItem& item,
175 wxDataViewItemArray& children) const = 0;
176
177 /**
178 Override this to indicate the number of columns in the model.
179 */
180 virtual unsigned int GetColumnCount() const = 0;
181
182 /**
183 Override this to indicate what type of data is stored in the
184 column specified by @a col.
185
186 This should return a string indicating the type of data as reported by wxVariant.
187 */
188 virtual wxString GetColumnType(unsigned int col) const = 0;
189
190 /**
191 Override this to indicate which wxDataViewItem representing the parent
192 of @a item or an invalid wxDataViewItem if the the root item is
193 the parent item.
194 */
195 virtual wxDataViewItem GetParent(const wxDataViewItem& item) const = 0;
196
197 /**
198 Override this to indicate the value of @a item.
199 A wxVariant is used to store the data.
200 */
201 virtual void GetValue(wxVariant& variant, const wxDataViewItem& item,
202 unsigned int col) const = 0;
203
204 /**
205 Override this method to indicate if a container item merely acts as a
206 headline (or for categorisation) or if it also acts a normal item with
207 entries for futher columns. By default returns @false.
208 */
209 virtual bool HasContainerColumns(const wxDataViewItem& item) const;
210
211 /**
212 Override this to indicate that the model provides a default compare
213 function that the control should use if no wxDataViewColumn has been
214 chosen for sorting. Usually, the user clicks on a column header for
215 sorting, the data will be sorted alphanumerically.
216
217 If any other order (e.g. by index or order of appearance) is required,
218 then this should be used.
219 See wxDataViewIndexListModel for a model which makes use of this.
220 */
221 virtual bool HasDefaultCompare() const;
222
223 /**
224 Return true if there is a value in the given column of this item.
225
226 All normal items have values in all columns but the container items
227 only show their label in the first column (@a col == 0) by default (but
228 see HasContainerColumns()). So this function always returns true for
229 the first column while for the other ones it returns true only if the
230 item is not a container or HasContainerColumns() was overridden to
231 return true for it.
232
233 @since 2.9.1
234 */
235 bool HasValue(const wxDataViewItem& item, unsigned col) const;
236
237 /**
238 Override this to indicate of @a item is a container, i.e. if
239 it can have child items.
240 */
241 virtual bool IsContainer(const wxDataViewItem& item) const = 0;
242
243 /**
244 Call this to inform the model that an item has been added to the data.
245 */
246 bool ItemAdded(const wxDataViewItem& parent,
247 const wxDataViewItem& item);
248
249 /**
250 Call this to inform the model that an item has changed.
251
252 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
253 event (in which the column fields will not be set) to the user.
254 */
255 bool ItemChanged(const wxDataViewItem& item);
256
257 /**
258 Call this to inform the model that an item has been deleted from the data.
259 */
260 bool ItemDeleted(const wxDataViewItem& parent,
261 const wxDataViewItem& item);
262
263 /**
264 Call this to inform the model that several items have been added to the data.
265 */
266 bool ItemsAdded(const wxDataViewItem& parent,
267 const wxDataViewItemArray& items);
268
269 /**
270 Call this to inform the model that several items have changed.
271
272 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
273 events (in which the column fields will not be set) to the user.
274 */
275 bool ItemsChanged(const wxDataViewItemArray& items);
276
277 /**
278 Call this to inform the model that several items have been deleted.
279 */
280 bool ItemsDeleted(const wxDataViewItem& parent,
281 const wxDataViewItemArray& items);
282
283 /**
284 Remove the @a notifier from the list of notifiers.
285 */
286 void RemoveNotifier(wxDataViewModelNotifier* notifier);
287
288 /**
289 Call this to initiate a resort after the sort function has been changed.
290 */
291 virtual void Resort();
292
293 /**
294 This gets called in order to set a value in the data model.
295
296 The most common scenario is that the wxDataViewCtrl calls this method
297 after the user changed some data in the view.
298
299 This is the function you need to override in your derived class but if
300 you want to call it, ChangeValue() is usually more convenient as
301 otherwise you need to manually call ValueChanged() to update the
302 control itself.
303 */
304 virtual bool SetValue(const wxVariant& variant,
305 const wxDataViewItem& item,
306 unsigned int col) = 0;
307
308 /**
309 Call this to inform this model that a value in the model has been changed.
310 This is also called from wxDataViewCtrl's internal editing code, e.g. when
311 editing a text field in the control.
312
313 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
314 event to the user.
315 */
316 virtual bool ValueChanged(const wxDataViewItem& item,
317 unsigned int col);
318
319 protected:
320
321 /**
322 Destructor. This should not be called directly. Use DecRef() instead.
323 */
324 virtual ~wxDataViewModel();
325 };
326
327
328
329 /**
330 @class wxDataViewIndexListModel
331
332 wxDataViewIndexListModel is a specialized data model which lets you address
333 an item by its position (row) rather than its wxDataViewItem (which you can
334 obtain from this class).
335 This model also provides its own wxDataViewIndexListModel::Compare
336 method which sorts the model's data by the index.
337
338 This model is not a virtual model since the control stores each wxDataViewItem.
339 Use wxDataViewVirtualListModel if you need to display millions of items or
340 have other reason to use a virtual control.
341
342 @library{wxadv}
343 @category{dvc}
344 */
345 class wxDataViewIndexListModel : public wxDataViewModel
346 {
347 public:
348 /**
349 Constructor.
350 */
351 wxDataViewIndexListModel(unsigned int initial_size = 0);
352
353 /**
354 Destructor.
355 */
356 virtual ~wxDataViewIndexListModel();
357
358 /**
359 Compare method that sorts the items by their index.
360 */
361 int Compare(const wxDataViewItem& item1,
362 const wxDataViewItem& item2,
363 unsigned int column, bool ascending);
364
365 /**
366 Override this to indicate that the row has special font attributes.
367 This only affects the wxDataViewTextRendererText() renderer.
368
369 The base class version always simply returns @false.
370
371 @see wxDataViewItemAttr.
372
373 @param row
374 The row for which the attribute is requested.
375 @param col
376 The column for which the attribute is requested.
377 @param attr
378 The attribute to be filled in if the function returns @true.
379 @return
380 @true if this item has an attribute or @false otherwise.
381 */
382 virtual bool GetAttrByRow(unsigned int row, unsigned int col,
383 wxDataViewItemAttr& attr) const;
384
385 /**
386 Returns the number of items (i.e. rows) in the list.
387 */
388 unsigned int GetCount() const;
389
390 /**
391 Returns the wxDataViewItem at the given @e row.
392 */
393 wxDataViewItem GetItem(unsigned int row) const;
394
395 /**
396 Returns the position of given @e item.
397 */
398 unsigned int GetRow(const wxDataViewItem& item) const;
399
400 /**
401 Override this to allow getting values from the model.
402 */
403 virtual void GetValueByRow(wxVariant& variant, unsigned int row,
404 unsigned int col) const = 0;
405
406 /**
407 Call this after if the data has to be read again from the model.
408 This is useful after major changes when calling the methods below
409 (possibly thousands of times) doesn't make sense.
410 */
411 void Reset(unsigned int new_size);
412
413 /**
414 Call this after a row has been appended to the model.
415 */
416 void RowAppended();
417
418 /**
419 Call this after a row has been changed.
420 */
421 void RowChanged(unsigned int row);
422
423 /**
424 Call this after a row has been deleted.
425 */
426 void RowDeleted(unsigned int row);
427
428 /**
429 Call this after a row has been inserted at the given position.
430 */
431 void RowInserted(unsigned int before);
432
433 /**
434 Call this after a row has been prepended to the model.
435 */
436 void RowPrepended();
437
438 /**
439 Call this after a value has been changed.
440 */
441 void RowValueChanged(unsigned int row, unsigned int col);
442
443 /**
444 Call this after rows have been deleted.
445 The array will internally get copied and sorted in descending order so
446 that the rows with the highest position will be deleted first.
447 */
448 void RowsDeleted(const wxArrayInt& rows);
449
450 /**
451 Called in order to set a value in the model.
452 */
453 virtual bool SetValueByRow(const wxVariant& variant, unsigned int row,
454 unsigned int col) = 0;
455 };
456
457
458
459 /**
460 @class wxDataViewVirtualListModel
461
462 wxDataViewVirtualListModel is a specialized data model which lets you address
463 an item by its position (row) rather than its wxDataViewItem and as such offers
464 the exact same interface as wxDataViewIndexListModel.
465 The important difference is that under platforms other than OS X, using this
466 model will result in a truly virtual control able to handle millions of items
467 as the control doesn't store any item (a feature not supported by the
468 Carbon API under OS X).
469
470 @see wxDataViewIndexListModel for the API.
471
472 @library{wxadv}
473 @category{dvc}
474 */
475 class wxDataViewVirtualListModel : public wxDataViewModel
476 {
477 public:
478 /**
479 Constructor.
480 */
481 wxDataViewVirtualListModel(unsigned int initial_size = 0);
482
483 /**
484 Returns the number of virtual items (i.e. rows) in the list.
485 */
486 unsigned int GetCount() const;
487 };
488
489
490
491 /**
492 @class wxDataViewItemAttr
493
494 This class is used to indicate to a wxDataViewCtrl that a certain item
495 (see wxDataViewItem) has extra font attributes for its renderer.
496 For this, it is required to override wxDataViewModel::GetAttr.
497
498 Attributes are currently only supported by wxDataViewTextRendererText.
499
500 @library{wxadv}
501 @category{dvc}
502 */
503 class wxDataViewItemAttr
504 {
505 public:
506 /**
507 Constructor.
508 */
509 wxDataViewItemAttr();
510
511 /**
512 Call this to indicate that the item shall be displayed in bold text.
513 */
514 void SetBold(bool set);
515
516 /**
517 Call this to indicate that the item shall be displayed with that colour.
518 */
519 void SetColour(const wxColour& colour);
520
521 /**
522 Call this to indicate that the item shall be displayed in italic text.
523 */
524 void SetItalic(bool set);
525 };
526
527
528
529 /**
530 @class wxDataViewItem
531
532 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
533 in a persistent way, i.e. independent of the position of the item in the control
534 or changes to its contents.
535
536 It must hold a unique ID of type @e void* in its only field and can be converted
537 to and from it.
538
539 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
540 return @false which used in many places in the API of wxDataViewCtrl to
541 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
542 the invisible root. Examples for this are wxDataViewModel::GetParent and
543 wxDataViewModel::GetChildren.
544
545 @library{wxadv}
546 @category{dvc}
547 */
548 class wxDataViewItem
549 {
550 public:
551 //@{
552 /**
553 Constructor.
554 */
555 wxDataViewItem(void* id = NULL);
556 wxDataViewItem(const wxDataViewItem& item);
557 //@}
558
559 /**
560 Returns the ID.
561 */
562 void* GetID() const;
563
564 /**
565 Returns @true if the ID is not @NULL.
566 */
567 bool IsOk() const;
568 };
569
570
571
572 /**
573 @class wxDataViewCtrl
574
575 wxDataViewCtrl is a control to display data either in a tree like fashion or
576 in a tabular form or both.
577
578 If you only need to display a simple tree structure with an API more like the
579 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
580 Likewise, if you only want to display simple table structure you can use
581 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
582 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
583
584 A wxDataViewItem is used to represent a (visible) item in the control.
585
586 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
587 virtual functions or by setting it directly. Instead you need to write your own
588 wxDataViewModel and associate it with this control.
589 Then you need to add a number of wxDataViewColumn to this control to define
590 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
591 of a wxDataViewRenderer to render its cells.
592
593 A number of standard renderers for rendering text, dates, images, toggle,
594 a progress bar etc. are provided. Additionally, the user can write custom
595 renderers deriving from wxDataViewCustomRenderer for displaying anything.
596
597 All data transfer from the control to the model and the user code is done
598 through wxVariant which can be extended to support more data formats as necessary.
599 Accordingly, all type information uses the strings returned from wxVariant::GetType.
600
601 @beginStyleTable
602 @style{wxDV_SINGLE}
603 Single selection mode. This is the default.
604 @style{wxDV_MULTIPLE}
605 Multiple selection mode.
606 @style{wxDV_ROW_LINES}
607 Use alternating colours for rows if supported by platform and theme.
608 @style{wxDV_HORIZ_RULES}
609 Display fine rules between row if supported.
610 @style{wxDV_VERT_RULES}
611 Display fine rules between columns is supported.
612 @style{wxDV_VARIABLE_LINE_HEIGHT}
613 Allow variable line heights.
614 This can be inefficient when displaying large number of items.
615 @style{wxDV_NO_HEADER}
616 Do not show column headers (which are shown by default).
617 @endStyleTable
618
619 @beginEventEmissionTable{wxDataViewEvent}
620 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
621 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
622 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
623 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
624 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
625 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This
626 event can be vetoed in order to prevent editing on an item by item
627 basis. Still experimental.
628 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
629 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
630 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
631 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
632 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
633 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
634 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
635 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
636 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
637 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
638 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
639 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
640 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
641 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
642 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
643 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
644 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
645 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
646 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
647 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
648 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
649 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
650 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
651 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
652 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
653 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
654 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
655 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
656 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
657 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
658 @endEventTable
659
660 @library{wxadv}
661 @category{ctrl,dvc}
662 @appearance{dataviewctrl.png}
663 */
664 class wxDataViewCtrl : public wxControl
665 {
666 public:
667 /**
668 Default Constructor.
669 */
670 wxDataViewCtrl();
671
672 /**
673 Constructor. Calls Create().
674 */
675 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
676 const wxPoint& pos = wxDefaultPosition,
677 const wxSize& size = wxDefaultSize,
678 long style = 0,
679 const wxValidator& validator = wxDefaultValidator);
680
681 /**
682 Destructor.
683 */
684 virtual ~wxDataViewCtrl();
685
686 /**
687 Appends a wxDataViewColumn to the control. Returns @true on success.
688
689 Note that there is a number of short cut methods which implicitly create
690 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
691 */
692 virtual bool AppendColumn(wxDataViewColumn* col);
693
694 /**
695 Prepends a wxDataViewColumn to the control. Returns @true on success.
696
697 Note that there is a number of short cut methods which implicitly create
698 a wxDataViewColumn and a wxDataViewRenderer for it.
699 */
700 virtual bool PrependColumn(wxDataViewColumn* col);
701
702 /**
703 Inserts a wxDataViewColumn to the control. Returns @true on success.
704 */
705 virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
706
707 //@{
708 /**
709 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
710 created in the function or @NULL on failure.
711 */
712 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
713 unsigned int model_column,
714 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
715 int width = -1,
716 wxAlignment align = wxALIGN_CENTER,
717 int flags = wxDATAVIEW_COL_RESIZABLE);
718 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
719 unsigned int model_column,
720 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
721 int width = -1,
722 wxAlignment align = wxALIGN_CENTER,
723 int flags = wxDATAVIEW_COL_RESIZABLE);
724 //@}
725
726 //@{
727 /**
728 Appends a column for rendering a date. Returns the wxDataViewColumn
729 created in the function or @NULL on failure.
730
731 @note The @a align parameter is applied to both the column header and
732 the column renderer.
733 */
734 wxDataViewColumn* AppendDateColumn(const wxString& label,
735 unsigned int model_column,
736 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
737 int width = -1,
738 wxAlignment align = wxALIGN_NOT,
739 int flags = wxDATAVIEW_COL_RESIZABLE);
740 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
741 unsigned int model_column,
742 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
743 int width = -1,
744 wxAlignment align = wxALIGN_NOT,
745 int flags = wxDATAVIEW_COL_RESIZABLE);
746 //@}
747
748 //@{
749 /**
750 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
751 created in the function or @NULL on failure.
752 This method uses the wxDataViewIconTextRenderer class.
753
754 @note The @a align parameter is applied to both the column header and
755 the column renderer.
756 */
757 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
758 unsigned int model_column,
759 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
760 int width = -1,
761 wxAlignment align = wxALIGN_NOT,
762 int flags = wxDATAVIEW_COL_RESIZABLE);
763 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
764 unsigned int model_column,
765 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
766 int width = -1,
767 wxAlignment align = wxALIGN_NOT,
768 int flags = wxDATAVIEW_COL_RESIZABLE);
769 //@}
770
771 //@{
772 /**
773 Appends a column for rendering a progress indicator. Returns the
774 wxDataViewColumn created in the function or @NULL on failure.
775
776 @note The @a align parameter is applied to both the column header and
777 the column renderer.
778 */
779 wxDataViewColumn* AppendProgressColumn(const wxString& label,
780 unsigned int model_column,
781 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
782 int width = 80,
783 wxAlignment align = wxALIGN_CENTER,
784 int flags = wxDATAVIEW_COL_RESIZABLE);
785 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
786 unsigned int model_column,
787 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
788 int width = 80,
789 wxAlignment align = wxALIGN_CENTER,
790 int flags = wxDATAVIEW_COL_RESIZABLE);
791 //@}
792
793 //@{
794 /**
795 Appends a column for rendering text. Returns the wxDataViewColumn
796 created in the function or @NULL on failure.
797
798 @note The @a align parameter is applied to both the column header and
799 the column renderer.
800 */
801 wxDataViewColumn* AppendTextColumn(const wxString& label,
802 unsigned int model_column,
803 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
804 int width = -1,
805 wxAlignment align = wxALIGN_NOT,
806 int flags = wxDATAVIEW_COL_RESIZABLE);
807 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
808 unsigned int model_column,
809 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
810 int width = -1,
811 wxAlignment align = wxALIGN_NOT,
812 int flags = wxDATAVIEW_COL_RESIZABLE);
813 //@}
814
815 //@{
816 /**
817 Appends a column for rendering a toggle. Returns the wxDataViewColumn
818 created in the function or @NULL on failure.
819
820 @note The @a align parameter is applied to both the column header and
821 the column renderer.
822 */
823 wxDataViewColumn* AppendToggleColumn(const wxString& label,
824 unsigned int model_column,
825 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
826 int width = 30,
827 wxAlignment align = wxALIGN_CENTER,
828 int flags = wxDATAVIEW_COL_RESIZABLE);
829 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
830 unsigned int model_column,
831 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
832 int width = 30,
833 wxAlignment align = wxALIGN_CENTER,
834 int flags = wxDATAVIEW_COL_RESIZABLE);
835 //@}
836
837 /**
838 Associates a wxDataViewModel with the control.
839 This increases the reference count of the model by 1.
840 */
841 virtual bool AssociateModel(wxDataViewModel* model);
842
843 /**
844 Removes all columns.
845 */
846 virtual bool ClearColumns();
847
848 /**
849 Collapses the item.
850 */
851 virtual void Collapse(const wxDataViewItem& item);
852
853 /**
854 Create the control. Useful for two step creation.
855 */
856 bool Create(wxWindow* parent, wxWindowID id,
857 const wxPoint& pos = wxDefaultPosition,
858 const wxSize& size = wxDefaultSize,
859 long style = 0,
860 const wxValidator& validator = wxDefaultValidator);
861
862 /**
863 Deletes given column.
864 */
865 virtual bool DeleteColumn(wxDataViewColumn* column);
866
867 /**
868 Enable drag operations using the given @a format.
869 */
870 virtual bool EnableDragSource( const wxDataFormat &format );
871
872 /**
873 Enable drop operations using the given @a format.
874 */
875 virtual bool EnableDropTarget( const wxDataFormat &format );
876
877 /**
878 Call this to ensure that the given item is visible.
879 */
880 virtual void EnsureVisible(const wxDataViewItem& item,
881 const wxDataViewColumn* column = NULL);
882
883 /**
884 Expands the item.
885 */
886 virtual void Expand(const wxDataViewItem& item);
887
888 /**
889 Expands all ancestors of the @a item. This method also
890 ensures that the item itself as well as all ancestor
891 items have been read from the model by the control.
892 */
893 virtual void ExpandAncestors( const wxDataViewItem & item );
894
895 /**
896 Returns pointer to the column. @a pos refers to the position in the
897 control which may change after reordering columns by the user.
898 */
899 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
900
901 /**
902 Returns the number of columns.
903 */
904 virtual unsigned int GetColumnCount() const;
905
906 /**
907 Returns the position of the column or -1 if not found in the control.
908 */
909 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
910
911 /**
912 Returns column containing the expanders.
913 */
914 wxDataViewColumn* GetExpanderColumn() const;
915
916 /**
917 Returns indentation.
918 */
919 int GetIndent() const;
920
921 /**
922 Returns item rect.
923 */
924 virtual wxRect GetItemRect(const wxDataViewItem& item,
925 const wxDataViewColumn* col = NULL) const;
926
927 /**
928 Returns pointer to the data model associated with the control (if any).
929 */
930 wxDataViewModel* GetModel();
931
932 /**
933 Returns first selected item or an invalid item if none is selected.
934 */
935 virtual wxDataViewItem GetSelection() const;
936
937 /**
938 Fills @a sel with currently selected items and returns their number.
939 */
940 virtual int GetSelections(wxDataViewItemArray& sel) const;
941
942 /**
943 Returns the wxDataViewColumn currently responsible for sorting
944 or @NULL if none has been selected.
945 */
946 virtual wxDataViewColumn* GetSortingColumn() const;
947
948 /**
949 Hittest.
950 */
951 virtual void HitTest(const wxPoint& point, wxDataViewItem& item,
952 wxDataViewColumn*& col) const;
953
954 /**
955 Return @true if the item is expanded.
956 */
957 virtual bool IsExpanded(const wxDataViewItem& item) const;
958
959 /**
960 Return @true if the item is selected.
961 */
962 virtual bool IsSelected(const wxDataViewItem& item) const;
963
964 /**
965 Select the given item.
966
967 In single selection mode this changes the (unique) currently selected
968 item. In multi selection mode, the @a item is selected and the
969 previously selected items remain selected.
970 */
971 virtual void Select(const wxDataViewItem& item);
972
973 /**
974 Select all items.
975 */
976 virtual void SelectAll();
977
978 /**
979 Set which column shall contain the tree-like expanders.
980 */
981 void SetExpanderColumn(wxDataViewColumn* col);
982
983 /**
984 Sets the indendation.
985 */
986 void SetIndent(int indent);
987
988 /**
989 Sets the selection to the array of wxDataViewItems.
990 */
991 virtual void SetSelections(const wxDataViewItemArray& sel);
992
993 /**
994 Unselect the given item.
995 */
996 virtual void Unselect(const wxDataViewItem& item);
997
998 /**
999 Unselect all item.
1000 This method only has effect if multiple selections are allowed.
1001 */
1002 virtual void UnselectAll();
1003 };
1004
1005
1006
1007 /**
1008 @class wxDataViewModelNotifier
1009
1010 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1011 its notification interface.
1012 See the documentation of that class for further information.
1013
1014 @library{wxadv}
1015 @category{dvc}
1016 */
1017 class wxDataViewModelNotifier
1018 {
1019 public:
1020 /**
1021 Constructor.
1022 */
1023 wxDataViewModelNotifier();
1024
1025 /**
1026 Destructor.
1027 */
1028 virtual ~wxDataViewModelNotifier();
1029
1030 /**
1031 Called by owning model.
1032 */
1033 virtual bool Cleared() = 0;
1034
1035 /**
1036 Get owning wxDataViewModel.
1037 */
1038 wxDataViewModel* GetOwner() const;
1039
1040 /**
1041 Called by owning model.
1042 */
1043 virtual bool ItemAdded(const wxDataViewItem& parent,
1044 const wxDataViewItem& item) = 0;
1045
1046 /**
1047 Called by owning model.
1048 */
1049 virtual bool ItemChanged(const wxDataViewItem& item) = 0;
1050
1051 /**
1052 Called by owning model.
1053 */
1054 virtual bool ItemDeleted(const wxDataViewItem& parent,
1055 const wxDataViewItem& item) = 0;
1056
1057 /**
1058 Called by owning model.
1059 */
1060 virtual bool ItemsAdded(const wxDataViewItem& parent,
1061 const wxDataViewItemArray& items);
1062
1063 /**
1064 Called by owning model.
1065 */
1066 virtual bool ItemsChanged(const wxDataViewItemArray& items);
1067
1068 /**
1069 Called by owning model.
1070 */
1071 virtual bool ItemsDeleted(const wxDataViewItem& parent,
1072 const wxDataViewItemArray& items);
1073
1074 /**
1075 Called by owning model.
1076 */
1077 virtual void Resort() = 0;
1078
1079 /**
1080 Set owner of this notifier. Used internally.
1081 */
1082 void SetOwner(wxDataViewModel* owner);
1083
1084 /**
1085 Called by owning model.
1086 */
1087 virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0;
1088 };
1089
1090
1091 /**
1092 The mode of a data-view cell; see wxDataViewRenderer for more info.
1093 */
1094 enum wxDataViewCellMode
1095 {
1096 wxDATAVIEW_CELL_INERT,
1097
1098 /**
1099 Indicates that the user can double click the cell and something will
1100 happen (e.g. a window for editing a date will pop up).
1101 */
1102 wxDATAVIEW_CELL_ACTIVATABLE,
1103
1104 /**
1105 Indicates that the user can edit the data in-place, i.e. an control
1106 will show up after a slow click on the cell. This behaviour is best
1107 known from changing the filename in most file managers etc.
1108 */
1109 wxDATAVIEW_CELL_EDITABLE
1110 };
1111
1112 /**
1113 The values of this enum controls how a wxDataViewRenderer should display
1114 its contents in a cell.
1115 */
1116 enum wxDataViewCellRenderState
1117 {
1118 wxDATAVIEW_CELL_SELECTED = 1,
1119 wxDATAVIEW_CELL_PRELIT = 2,
1120 wxDATAVIEW_CELL_INSENSITIVE = 4,
1121 wxDATAVIEW_CELL_FOCUSED = 8
1122 };
1123
1124 /**
1125 @class wxDataViewRenderer
1126
1127 This class is used by wxDataViewCtrl to render the individual cells.
1128 One instance of a renderer class is owned by a wxDataViewColumn.
1129 There is a number of ready-to-use renderers provided:
1130 - wxDataViewTextRenderer,
1131 - wxDataViewIconTextRenderer,
1132 - wxDataViewToggleRenderer,
1133 - wxDataViewProgressRenderer,
1134 - wxDataViewBitmapRenderer,
1135 - wxDataViewDateRenderer,
1136 - wxDataViewSpinRenderer.
1137 - wxDataViewChoiceRenderer.
1138
1139 Additionally, the user can write own renderers by deriving from
1140 wxDataViewCustomRenderer.
1141
1142 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1143 by the constructors respectively controls what actions the cell data allows
1144 and how the renderer should display its contents in a cell.
1145
1146 @library{wxadv}
1147 @category{dvc}
1148 */
1149 class wxDataViewRenderer : public wxObject
1150 {
1151 public:
1152 /**
1153 Constructor.
1154 */
1155 wxDataViewRenderer(const wxString& varianttype,
1156 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1157 int align = wxDVR_DEFAULT_ALIGNMENT );
1158
1159 /**
1160 Enable or disable replacing parts of the item text with ellipsis to
1161 make it fit the column width.
1162
1163 This method only makes sense for the renderers working with text, such
1164 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1165
1166 By default wxELLIPSIZE_MIDDLE is used.
1167
1168 @param mode
1169 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1170
1171 @since 2.9.1
1172 */
1173 void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
1174
1175 /**
1176 Disable replacing parts of the item text with ellipsis.
1177
1178 If ellipsizing is disabled, the string will be truncated if it doesn't
1179 fit.
1180
1181 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1182
1183 @since 2.9.1
1184 */
1185 void DisableEllipsize();
1186
1187 /**
1188 Returns the alignment. See SetAlignment()
1189 */
1190 virtual int GetAlignment() const;
1191
1192 /**
1193 Returns the ellipsize mode used by the renderer.
1194
1195 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1196 if it doesn't fit.
1197
1198 @see EnableEllipsize()
1199 */
1200 wxEllipsizeMode GetEllipsizeMode() const;
1201
1202 /**
1203 Returns the cell mode.
1204 */
1205 virtual wxDataViewCellMode GetMode() const;
1206
1207 /**
1208 Returns pointer to the owning wxDataViewColumn.
1209 */
1210 wxDataViewColumn* GetOwner() const;
1211
1212 /**
1213 This methods retrieves the value from the renderer in order to
1214 transfer the value back to the data model.
1215
1216 Returns @false on failure.
1217 */
1218 virtual bool GetValue(wxVariant& value) const = 0;
1219
1220 /**
1221 Returns a string with the type of the wxVariant supported by this renderer.
1222 */
1223 wxString GetVariantType() const;
1224
1225 /**
1226 Sets the alignment of the renderer's content.
1227 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1228 should have the same alignment as the column header.
1229
1230 The method is not implemented under OS X and the renderer always aligns
1231 its contents as the column header on that platform. The other platforms
1232 support both vertical and horizontal alignment.
1233 */
1234 virtual void SetAlignment( int align );
1235 /**
1236 Sets the owning wxDataViewColumn.
1237 This is usually called from within wxDataViewColumn.
1238 */
1239 void SetOwner(wxDataViewColumn* owner);
1240
1241 /**
1242 Set the value of the renderer (and thus its cell) to @a value.
1243 The internal code will then render this cell with this data.
1244 */
1245 virtual bool SetValue(const wxVariant& value) = 0;
1246
1247 /**
1248 Before data is committed to the data model, it is passed to this
1249 method where it can be checked for validity. This can also be
1250 used for checking a valid range or limiting the user input in
1251 a certain aspect (e.g. max number of characters or only alphanumeric
1252 input, ASCII only etc.). Return @false if the value is not valid.
1253
1254 Please note that due to implementation limitations, this validation
1255 is done after the editing control already is destroyed and the
1256 editing process finished.
1257 */
1258 virtual bool Validate(wxVariant& value);
1259 };
1260
1261
1262
1263 /**
1264 @class wxDataViewTextRenderer
1265
1266 wxDataViewTextRenderer is used for rendering text.
1267 It supports in-place editing if desired.
1268
1269 @library{wxadv}
1270 @category{dvc}
1271 */
1272 class wxDataViewTextRenderer : public wxDataViewRenderer
1273 {
1274 public:
1275 /**
1276 The ctor.
1277 */
1278 wxDataViewTextRenderer(const wxString& varianttype = "string",
1279 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1280 int align = wxDVR_DEFAULT_ALIGNMENT );
1281 };
1282
1283
1284
1285 /**
1286 @class wxDataViewIconTextRenderer
1287
1288 The wxDataViewIconTextRenderer class is used to display text with
1289 a small icon next to it as it is typically done in a file manager.
1290
1291 This classes uses the wxDataViewIconText helper class to store its data.
1292 wxDataViewIconText can be converted to and from a wxVariant using the left
1293 shift operator.
1294
1295 @library{wxadv}
1296 @category{dvc}
1297 */
1298 class wxDataViewIconTextRenderer : public wxDataViewRenderer
1299 {
1300 public:
1301 /**
1302 The ctor.
1303 */
1304 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
1305 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1306 int align = wxDVR_DEFAULT_ALIGNMENT );
1307 };
1308
1309
1310
1311 /**
1312 @class wxDataViewProgressRenderer
1313
1314 This class is used by wxDataViewCtrl to render progress bars.
1315
1316 @library{wxadv}
1317 @category{dvc}
1318 */
1319 class wxDataViewProgressRenderer : public wxDataViewRenderer
1320 {
1321 public:
1322 /**
1323 The ctor.
1324 */
1325 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1326 const wxString& varianttype = "long",
1327 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1328 int align = wxDVR_DEFAULT_ALIGNMENT );
1329 };
1330
1331
1332
1333 /**
1334 @class wxDataViewSpinRenderer
1335
1336 This is a specialized renderer for rendering integer values.
1337 It supports modifying the values in-place by using a wxSpinCtrl.
1338 The renderer only support variants of type @e long.
1339
1340 @library{wxadv}
1341 @category{dvc}
1342 */
1343 class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1344 {
1345 public:
1346 /**
1347 Constructor.
1348 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
1349 */
1350 wxDataViewSpinRenderer(int min, int max,
1351 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1352 int align = wxDVR_DEFAULT_ALIGNMENT);
1353 };
1354
1355
1356
1357 /**
1358 @class wxDataViewToggleRenderer
1359
1360 This class is used by wxDataViewCtrl to render toggle controls.
1361
1362 @library{wxadv}
1363 @category{dvc}
1364 */
1365 class wxDataViewToggleRenderer : public wxDataViewRenderer
1366 {
1367 public:
1368 /**
1369 The ctor.
1370 */
1371 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
1372 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1373 int align = wxDVR_DEFAULT_ALIGNMENT);
1374 };
1375
1376
1377 /**
1378 @class wxDataViewChoiceRenderer
1379
1380 This class is used by wxDataViewCtrl to render choice controls.
1381 It stores a string so that SetValue() and GetValue() operate
1382 on a variant holding a string.
1383
1384 @library{wxadv}
1385 @category{dvc}
1386 */
1387
1388 class wxDataViewChoiceRenderer: public wxDataViewRenderer
1389 {
1390 public:
1391 /**
1392 The ctor.
1393 */
1394 wxDataViewChoiceRenderer( const wxArrayString &choices,
1395 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1396 int alignment = wxDVR_DEFAULT_ALIGNMENT );
1397
1398 /**
1399 Returns the choice referred to by index.
1400 */
1401 wxString GetChoice(size_t index) const;
1402
1403 /**
1404 Returns all choices.
1405 */
1406 const wxArrayString& GetChoices() const;
1407 };
1408
1409
1410 /**
1411 @class wxDataViewDateRenderer
1412
1413 This class is used by wxDataViewCtrl to render calendar controls.
1414
1415 @library{wxadv}
1416 @category{dvc}
1417 */
1418 class wxDataViewDateRenderer : public wxDataViewRenderer
1419 {
1420 public:
1421 /**
1422 The ctor.
1423 */
1424 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
1425 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1426 int align = wxDVR_DEFAULT_ALIGNMENT);
1427 };
1428
1429
1430
1431 /**
1432 @class wxDataViewCustomRenderer
1433
1434 You need to derive a new class from wxDataViewCustomRenderer in
1435 order to write a new renderer.
1436
1437 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1438 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1439
1440 If you want your renderer to support in-place editing then you also need to override
1441 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
1442 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1443
1444 Note that a special event handler will be pushed onto that editor control
1445 which handles @e \<ENTER\> and focus out events in order to end the editing.
1446
1447 @library{wxadv}
1448 @category{dvc}
1449 */
1450 class wxDataViewCustomRenderer : public wxDataViewRenderer
1451 {
1452 public:
1453 /**
1454 Constructor.
1455 */
1456 wxDataViewCustomRenderer(const wxString& varianttype = "string",
1457 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1458 int align = -1, bool no_init = false);
1459
1460 /**
1461 Destructor.
1462 */
1463 virtual ~wxDataViewCustomRenderer();
1464
1465 /**
1466 Override this to react to double clicks or ENTER.
1467 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1468 */
1469 virtual bool Activate( wxRect cell,
1470 wxDataViewModel* model,
1471 const wxDataViewItem & item,
1472 unsigned int col );
1473
1474 /**
1475 Override this to create the actual editor control once editing
1476 is about to start.
1477
1478 @a parent is the parent of the editor control, @a labelRect indicates the
1479 position and size of the editor control and @a value is its initial value:
1480 @code
1481 {
1482 long l = value;
1483 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1484 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1485 }
1486 @endcode
1487 */
1488 virtual wxControl* CreateEditorCtrl(wxWindow* parent,
1489 wxRect labelRect,
1490 const wxVariant& value);
1491
1492 /**
1493 Return the attribute to be used for rendering.
1494
1495 This function may be called from Render() implementation to use the
1496 attributes defined for the item if the renderer supports them.
1497
1498 Notice that when Render() is called, the wxDC object passed to it is
1499 already set up to use the correct attributes (e.g. its font is set to
1500 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
1501 returns true) so it may not be necessary to call it explicitly if you
1502 only want to render text using the items attributes.
1503
1504 @since 2.9.1
1505 */
1506 const wxDataViewItemAttr& GetAttr() const;
1507
1508 /**
1509 Return size required to show content.
1510 */
1511 virtual wxSize GetSize() const = 0;
1512
1513 /**
1514 Override this so that the renderer can get the value from the editor
1515 control (pointed to by @a editor):
1516 @code
1517 {
1518 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1519 long l = sc->GetValue();
1520 value = l;
1521 return true;
1522 }
1523 @endcode
1524 */
1525 virtual bool GetValueFromEditorCtrl(wxControl* editor,
1526 wxVariant& value);
1527
1528 /**
1529 Override this and make it return @true in order to
1530 indicate that this renderer supports in-place editing.
1531 */
1532 virtual bool HasEditorCtrl() const;
1533
1534 /**
1535 Override this to react to a left click.
1536 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
1537 */
1538 virtual bool LeftClick( wxPoint cursor,
1539 wxRect cell,
1540 wxDataViewModel * model,
1541 const wxDataViewItem & item,
1542 unsigned int col );
1543
1544 /**
1545 Override this to render the cell.
1546 Before this is called, wxDataViewRenderer::SetValue was called
1547 so that this instance knows what to render.
1548 */
1549 virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
1550
1551 /**
1552 This method should be called from within Render() whenever you need to
1553 render simple text.
1554 This will ensure that the correct colour, font and vertical alignment will
1555 be chosen so the text will look the same as text drawn by native renderers.
1556 */
1557 void RenderText(const wxString& text, int xoffset, wxRect cell,
1558 wxDC* dc, int state);
1559
1560 /**
1561 Override this to start a drag operation. Not yet supported.
1562 */
1563 virtual bool StartDrag(wxPoint cursor, wxRect cell,
1564 wxDataViewModel* model,
1565 const wxDataViewItem & item,
1566 unsigned int col);
1567 };
1568
1569
1570
1571 /**
1572 @class wxDataViewBitmapRenderer
1573
1574 This class is used by wxDataViewCtrl to render bitmap controls.
1575
1576 @library{wxadv}
1577 @category{dvc}
1578 */
1579 class wxDataViewBitmapRenderer : public wxDataViewRenderer
1580 {
1581 public:
1582 /**
1583 The ctor.
1584 */
1585 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
1586 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1587 int align = wxDVR_DEFAULT_ALIGNMENT);
1588 };
1589
1590
1591 /**
1592 The flags used by wxDataViewColumn.
1593 Can be combined together.
1594 */
1595 enum wxDataViewColumnFlags
1596 {
1597 wxDATAVIEW_COL_RESIZABLE = 1,
1598 wxDATAVIEW_COL_SORTABLE = 2,
1599 wxDATAVIEW_COL_REORDERABLE = 4,
1600 wxDATAVIEW_COL_HIDDEN = 8
1601 };
1602
1603 /**
1604 @class wxDataViewColumn
1605
1606 This class represents a column in a wxDataViewCtrl.
1607 One wxDataViewColumn is bound to one column in the data model to which the
1608 wxDataViewCtrl has been associated.
1609
1610 An instance of wxDataViewRenderer is used by this class to render its data.
1611
1612 @library{wxadv}
1613 @category{dvc}
1614 */
1615 class wxDataViewColumn : public wxSettableHeaderColumn
1616 {
1617 public:
1618 /**
1619 Constructs a text column.
1620
1621 @param title
1622 The title of the column.
1623 @param renderer
1624 The class which will render the contents of this column.
1625 @param model_column
1626 The index of the model's column which is associated with this object.
1627 @param width
1628 The width of the column.
1629 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1630 @param align
1631 The alignment of the column title.
1632 @param flags
1633 One or more flags of the ::wxDataViewColumnFlags enumeration.
1634 */
1635 wxDataViewColumn(const wxString& title,
1636 wxDataViewRenderer* renderer,
1637 unsigned int model_column,
1638 int width = wxDVC_DEFAULT_WIDTH,
1639 wxAlignment align = wxALIGN_CENTER,
1640 int flags = wxDATAVIEW_COL_RESIZABLE);
1641
1642 /**
1643 Constructs a bitmap column.
1644
1645 @param bitmap
1646 The bitmap of the column.
1647 @param renderer
1648 The class which will render the contents of this column.
1649 @param model_column
1650 The index of the model's column which is associated with this object.
1651 @param width
1652 The width of the column.
1653 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1654 @param align
1655 The alignment of the column title.
1656 @param flags
1657 One or more flags of the ::wxDataViewColumnFlags enumeration.
1658 */
1659 wxDataViewColumn(const wxBitmap& bitmap,
1660 wxDataViewRenderer* renderer,
1661 unsigned int model_column,
1662 int width = wxDVC_DEFAULT_WIDTH,
1663 wxAlignment align = wxALIGN_CENTER,
1664 int flags = wxDATAVIEW_COL_RESIZABLE);
1665
1666 /**
1667 Returns the index of the column of the model, which this
1668 wxDataViewColumn is displaying.
1669 */
1670 unsigned int GetModelColumn() const;
1671
1672 /**
1673 Returns the owning wxDataViewCtrl.
1674 */
1675 wxDataViewCtrl* GetOwner() const;
1676
1677 /**
1678 Returns the renderer of this wxDataViewColumn.
1679
1680 @see wxDataViewRenderer.
1681 */
1682 wxDataViewRenderer* GetRenderer() const;
1683 };
1684
1685
1686
1687 /**
1688 @class wxDataViewListCtrl
1689
1690 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1691 and forwards most of its API to that class.
1692
1693 The purpose of this class is to offer a simple way to display and
1694 edit a small table of data without having to write your own wxDataViewModel.
1695
1696 @code
1697 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
1698
1699 listctrl->AppendToggleColumn( "Toggle" );
1700 listctrl->AppendTextColumn( "Text" );
1701
1702 wxVector<wxVariant> data;
1703 data.push_back( wxVariant(true) );
1704 data.push_back( wxVariant("row 1") );
1705 listctrl->AppendItem( data );
1706
1707 data.clear();
1708 data.push_back( wxVariant(false) );
1709 data.push_back( wxVariant("row 3") );
1710 listctrl->AppendItem( data );
1711 @endcode
1712
1713 @beginStyleTable
1714 See wxDataViewCtrl for the list of supported styles.
1715 @endStyleTable
1716
1717 @beginEventEmissionTable
1718 See wxDataViewCtrl for the list of events emitted by this class.
1719 @endEventTable
1720
1721 @library{wxadv}
1722 @category{ctrl,dvc}
1723 */
1724 class wxDataViewListCtrl: public wxDataViewCtrl
1725 {
1726 public:
1727 /**
1728 Default ctor.
1729 */
1730 wxDataViewListCtrl();
1731
1732 /**
1733 Constructor. Calls Create().
1734 */
1735 wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
1736 const wxPoint& pos = wxDefaultPosition,
1737 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1738 const wxValidator& validator = wxDefaultValidator );
1739
1740 /**
1741 Destructor. Deletes the image list if any.
1742 */
1743 ~wxDataViewListCtrl();
1744
1745 /**
1746 Creates the control and a wxDataViewListStore as its internal model.
1747 */
1748 bool Create( wxWindow *parent, wxWindowID id,
1749 const wxPoint& pos = wxDefaultPosition,
1750 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1751 const wxValidator& validator = wxDefaultValidator );
1752
1753 //@{
1754 /**
1755 Returns the store.
1756 */
1757 wxDataViewListStore *GetStore();
1758 const wxDataViewListStore *GetStore() const;
1759 //@}
1760
1761 /**
1762 Returns the position of given @e item or wxNOT_FOUND if it's
1763 not a valid item.
1764
1765 @since 2.9.2
1766 */
1767 int ItemToRow(const wxDataViewItem &item) const;
1768
1769 /**
1770 Returns the wxDataViewItem at the given @e row.
1771
1772 @since 2.9.2
1773 */
1774 wxDataViewItem RowToItem(int row) const;
1775
1776 //@{
1777 /**
1778 @name Selection handling functions
1779 */
1780
1781 /**
1782 Returns index of the selected row or wxNOT_FOUND.
1783
1784 @see wxDataViewCtrl::GetSelection()
1785
1786 @since 2.9.2
1787 */
1788 int GetSelectedRow() const;
1789
1790 /**
1791 Selects given row.
1792
1793 @see wxDataViewCtrl::Select()
1794
1795 @since 2.9.2
1796 */
1797 void SelectRow(unsigned row);
1798
1799 /**
1800 Unselects given row.
1801
1802 @see wxDataViewCtrl::Unselect()
1803
1804 @since 2.9.2
1805 */
1806 void UnselectRow(unsigned row);
1807
1808 /**
1809 Returns true if @a row is selected.
1810
1811 @see wxDataViewCtrl::IsSelected()
1812
1813 @since 2.9.2
1814 */
1815 bool IsRowSelected(unsigned row) const;
1816
1817 //@}
1818
1819 /**
1820 @name Column management functions
1821 */
1822 //@{
1823
1824 /**
1825 Appends a column to the control and additionally appends a
1826 column to the store with the type string.
1827 */
1828 virtual void AppendColumn( wxDataViewColumn *column );
1829
1830 /**
1831 Appends a column to the control and additionally appends a
1832 column to the list store with the type @a varianttype.
1833 */
1834 void AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
1835
1836 /**
1837 Appends a text column to the control and the store.
1838
1839 See wxDataViewColumn::wxDataViewColumn for more info about
1840 the parameters.
1841 */
1842 wxDataViewColumn *AppendTextColumn( const wxString &label,
1843 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1844 int width = -1, wxAlignment align = wxALIGN_LEFT,
1845 int flags = wxDATAVIEW_COL_RESIZABLE );
1846
1847 /**
1848 Appends a toggle column to the control and the store.
1849
1850 See wxDataViewColumn::wxDataViewColumn for more info about
1851 the parameters.
1852 */
1853 wxDataViewColumn *AppendToggleColumn( const wxString &label,
1854 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1855 int width = -1, wxAlignment align = wxALIGN_LEFT,
1856 int flags = wxDATAVIEW_COL_RESIZABLE );
1857
1858 /**
1859 Appends a progress column to the control and the store.
1860
1861 See wxDataViewColumn::wxDataViewColumn for more info about
1862 the parameters.
1863 */
1864 wxDataViewColumn *AppendProgressColumn( const wxString &label,
1865 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1866 int width = -1, wxAlignment align = wxALIGN_LEFT,
1867 int flags = wxDATAVIEW_COL_RESIZABLE );
1868
1869 /**
1870 Appends an icon-and-text column to the control and the store.
1871
1872 See wxDataViewColumn::wxDataViewColumn for more info about
1873 the parameters.
1874 */
1875 wxDataViewColumn *AppendIconTextColumn( const wxString &label,
1876 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1877 int width = -1, wxAlignment align = wxALIGN_LEFT,
1878 int flags = wxDATAVIEW_COL_RESIZABLE );
1879
1880 /**
1881 Inserts a column to the control and additionally inserts a
1882 column to the store with the type string.
1883 */
1884 virtual void InsertColumn( unsigned int pos, wxDataViewColumn *column );
1885
1886 /**
1887 Inserts a column to the control and additionally inserts a
1888 column to the list store with the type @a varianttype.
1889 */
1890 void InsertColumn( unsigned int pos, wxDataViewColumn *column,
1891 const wxString &varianttype );
1892
1893 /**
1894 Prepends a column to the control and additionally prepends a
1895 column to the store with the type string.
1896 */
1897 virtual void PrependColumn( wxDataViewColumn *column );
1898
1899 /**
1900 Prepends a column to the control and additionally prepends a
1901 column to the list store with the type @a varianttype.
1902 */
1903 void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
1904
1905 //@}
1906
1907
1908 /**
1909 @name Item management functions
1910 */
1911 //@{
1912
1913 /**
1914 Appends an item (=row) to the control and store.
1915 */
1916 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1917
1918 /**
1919 Prepends an item (=row) to the control and store.
1920 */
1921 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1922
1923 /**
1924 Inserts an item (=row) to the control and store.
1925 */
1926 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
1927
1928 /**
1929 Delete the row at position @a row.
1930 */
1931 void DeleteItem( unsigned row );
1932
1933 /**
1934 Delete all items (= all rows).
1935 */
1936 void DeleteAllItems();
1937
1938 /**
1939 Sets the value in the store and update the control.
1940 */
1941 void SetValue( const wxVariant &value, unsigned int row, unsigned int col );
1942
1943 /**
1944 Returns the value from the store.
1945 */
1946 void GetValue( wxVariant &value, unsigned int row, unsigned int col );
1947
1948 /**
1949 Sets the value in the store and update the control.
1950
1951 This method assumes that the a string is stored in respective
1952 column.
1953 */
1954 void SetTextValue( const wxString &value, unsigned int row, unsigned int col );
1955
1956 /**
1957 Returns the value from the store.
1958
1959 This method assumes that the a string is stored in respective
1960 column.
1961 */
1962 wxString GetTextValue( unsigned int row, unsigned int col ) const;
1963
1964 /**
1965 Sets the value in the store and update the control.
1966
1967 This method assumes that the a boolean value is stored in
1968 respective column.
1969 */
1970 void SetToggleValue( bool value, unsigned int row, unsigned int col );
1971
1972 /**
1973 Returns the value from the store.
1974
1975 This method assumes that the a boolean value is stored in
1976 respective column.
1977 */
1978 bool GetToggleValue( unsigned int row, unsigned int col ) const;
1979
1980 //@}
1981 };
1982
1983
1984 /**
1985 @class wxDataViewTreeCtrl
1986
1987 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1988 and forwards most of its API to that class.
1989 Additionally, it uses a wxImageList to store a list of icons.
1990
1991 The main purpose of this class is to provide a simple upgrade path for code
1992 using wxTreeCtrl.
1993
1994 @beginStyleTable
1995 See wxDataViewCtrl for the list of supported styles.
1996 @endStyleTable
1997
1998 @beginEventEmissionTable
1999 See wxDataViewCtrl for the list of events emitted by this class.
2000 @endEventTable
2001
2002 @library{wxadv}
2003 @category{ctrl,dvc}
2004 @appearance{dataviewtreectrl.png}
2005 */
2006 class wxDataViewTreeCtrl : public wxDataViewCtrl
2007 {
2008 public:
2009 /**
2010 Default ctor.
2011 */
2012 wxDataViewTreeCtrl();
2013
2014 /**
2015 Constructor.
2016
2017 Calls Create().
2018 */
2019 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
2020 const wxPoint& pos = wxDefaultPosition,
2021 const wxSize& size = wxDefaultSize,
2022 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
2023 const wxValidator& validator = wxDefaultValidator);
2024
2025 /**
2026 Destructor. Deletes the image list if any.
2027 */
2028 virtual ~wxDataViewTreeCtrl();
2029
2030 /**
2031 Appends a container to the given @a parent.
2032 */
2033 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
2034 const wxString& text,
2035 int icon = -1,
2036 int expanded = -1,
2037 wxClientData* data = NULL);
2038
2039 /**
2040 Appends an item to the given @a parent.
2041 */
2042 wxDataViewItem AppendItem(const wxDataViewItem& parent,
2043 const wxString& text,
2044 int icon = -1,
2045 wxClientData* data = NULL);
2046
2047 /**
2048 Creates the control and a wxDataViewTreeStore as its internal model.
2049
2050 The default tree column created by this method is an editable column
2051 using wxDataViewIconTextRenderer as its renderer.
2052 */
2053 bool Create(wxWindow* parent, wxWindowID id,
2054 const wxPoint& pos = wxDefaultPosition,
2055 const wxSize& size = wxDefaultSize,
2056 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
2057 const wxValidator& validator = wxDefaultValidator);
2058
2059 /**
2060 Calls the identical method from wxDataViewTreeStore.
2061 */
2062 void DeleteAllItems();
2063
2064 /**
2065 Calls the identical method from wxDataViewTreeStore.
2066 */
2067 void DeleteChildren(const wxDataViewItem& item);
2068
2069 /**
2070 Calls the identical method from wxDataViewTreeStore.
2071 */
2072 void DeleteItem(const wxDataViewItem& item);
2073
2074 /**
2075 Calls the identical method from wxDataViewTreeStore.
2076 */
2077 int GetChildCount(const wxDataViewItem& parent) const;
2078
2079 /**
2080 Returns the image list.
2081 */
2082 wxImageList* GetImageList();
2083
2084 /**
2085 Calls the identical method from wxDataViewTreeStore.
2086 */
2087 wxClientData* GetItemData(const wxDataViewItem& item) const;
2088
2089 /**
2090 Calls the identical method from wxDataViewTreeStore.
2091 */
2092 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
2093
2094 /**
2095 Calls the identical method from wxDataViewTreeStore.
2096 */
2097 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
2098
2099 /**
2100 Calls the identical method from wxDataViewTreeStore.
2101 */
2102 wxString GetItemText(const wxDataViewItem& item) const;
2103
2104 /**
2105 Calls the identical method from wxDataViewTreeStore.
2106 */
2107 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
2108 unsigned int pos) const;
2109
2110 //@{
2111 /**
2112 Returns the store.
2113 */
2114 wxDataViewTreeStore* GetStore();
2115 const wxDataViewTreeStore* GetStore() const;
2116 //@}
2117
2118 /**
2119 Calls the same method from wxDataViewTreeStore but uses
2120 an index position in the image list instead of a wxIcon.
2121 */
2122 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
2123 const wxDataViewItem& previous,
2124 const wxString& text,
2125 int icon = -1,
2126 int expanded = -1,
2127 wxClientData* data = NULL);
2128
2129 /**
2130 Calls the same method from wxDataViewTreeStore but uses
2131 an index position in the image list instead of a wxIcon.
2132 */
2133 wxDataViewItem InsertItem(const wxDataViewItem& parent,
2134 const wxDataViewItem& previous,
2135 const wxString& text,
2136 int icon = -1,
2137 wxClientData* data = NULL);
2138
2139 /**
2140 Returns true if item is a container.
2141 */
2142 bool IsContainer( const wxDataViewItem& item );
2143
2144 /**
2145 Calls the same method from wxDataViewTreeStore but uses
2146 an index position in the image list instead of a wxIcon.
2147 */
2148 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
2149 const wxString& text,
2150 int icon = -1,
2151 int expanded = -1,
2152 wxClientData* data = NULL);
2153
2154 /**
2155 Calls the same method from wxDataViewTreeStore but uses
2156 an index position in the image list instead of a wxIcon.
2157 */
2158 wxDataViewItem PrependItem(const wxDataViewItem& parent,
2159 const wxString& text,
2160 int icon = -1,
2161 wxClientData* data = NULL);
2162
2163 /**
2164 Sets the image list.
2165 */
2166 void SetImageList(wxImageList* imagelist);
2167
2168 /**
2169 Calls the identical method from wxDataViewTreeStore.
2170 */
2171 void SetItemData(const wxDataViewItem& item, wxClientData* data);
2172
2173 /**
2174 Calls the identical method from wxDataViewTreeStore.
2175 */
2176 void SetItemExpandedIcon(const wxDataViewItem& item,
2177 const wxIcon& icon);
2178
2179 /**
2180 Calls the identical method from wxDataViewTreeStore.
2181 */
2182 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
2183
2184 /**
2185 Calls the identical method from wxDataViewTreeStore.
2186 */
2187 void SetItemText(const wxDataViewItem& item,
2188 const wxString& text);
2189 };
2190
2191
2192 /**
2193 @class wxDataViewListStore
2194
2195 wxDataViewListStore is a specialised wxDataViewModel for storing
2196 a simple table of data. Since it derives from wxDataViewIndexListModel
2197 its data is be accessed by row (i.e. by index) instead of only
2198 by wxDataViewItem.
2199
2200 This class actually stores the values (therefore its name)
2201 and implements all virtual methods from the base classes so it can be
2202 used directly without having to derive any class from it, but it is
2203 mostly used from within wxDataViewListCtrl.
2204
2205 @library{wxadv}
2206 @category{dvc}
2207 */
2208
2209 class wxDataViewListStore: public wxDataViewIndexListModel
2210 {
2211 public:
2212 /**
2213 Constructor
2214 */
2215 wxDataViewListStore();
2216
2217 /**
2218 Destructor
2219 */
2220 ~wxDataViewListStore();
2221
2222 /**
2223 Prepends a data column.
2224
2225 @a variantype indicates the type of values store in the column.
2226
2227 This does not automatically fill in any (default) values in
2228 rows which exist in the store already.
2229 */
2230 void PrependColumn( const wxString &varianttype );
2231
2232 /**
2233 Inserts a data column before @a pos.
2234
2235 @a variantype indicates the type of values store in the column.
2236
2237 This does not automatically fill in any (default) values in
2238 rows which exist in the store already.
2239 */
2240 void InsertColumn( unsigned int pos, const wxString &varianttype );
2241
2242 /**
2243 Appends a data column.
2244
2245 @a variantype indicates the type of values store in the column.
2246
2247 This does not automatically fill in any (default) values in
2248 rows which exist in the store already.
2249 */
2250 void AppendColumn( const wxString &varianttype );
2251
2252 /**
2253 Appends an item (=row) and fills it with @a values.
2254
2255 The values must match the values specifies in the column
2256 in number and type. No (default) values are filled in
2257 automatically.
2258 */
2259 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
2260
2261 /**
2262 Prepends an item (=row) and fills it with @a values.
2263
2264 The values must match the values specifies in the column
2265 in number and type. No (default) values are filled in
2266 automatically.
2267 */
2268 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
2269
2270 /**
2271 Inserts an item (=row) and fills it with @a values.
2272
2273 The values must match the values specifies in the column
2274 in number and type. No (default) values are filled in
2275 automatically.
2276 */
2277 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
2278
2279 /**
2280 Delete the item (=row) at position @a pos.
2281 */
2282 void DeleteItem( unsigned pos );
2283
2284 /**
2285 Delete all item (=all rows) in the store.
2286 */
2287 void DeleteAllItems();
2288
2289 /**
2290 Overriden from wxDataViewModel
2291 */
2292 virtual unsigned int GetColumnCount() const;
2293
2294 /**
2295 Overriden from wxDataViewModel
2296 */
2297 virtual wxString GetColumnType( unsigned int col ) const;
2298
2299 /**
2300 Overriden from wxDataViewIndexListModel
2301 */
2302 virtual void GetValueByRow( wxVariant &value,
2303 unsigned int row, unsigned int col ) const;
2304
2305 /**
2306 Overriden from wxDataViewIndexListModel
2307 */
2308 virtual bool SetValueByRow( const wxVariant &value,
2309 unsigned int row, unsigned int col );
2310 };
2311
2312
2313 /**
2314 @class wxDataViewTreeStore
2315
2316 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
2317 trees very much like wxTreeCtrl does and it offers a similar API.
2318
2319 This class actually stores the entire tree and the values (therefore its name)
2320 and implements all virtual methods from the base class so it can be used directly
2321 without having to derive any class from it, but it is mostly used from within
2322 wxDataViewTreeCtrl.
2323
2324 @library{wxadv}
2325 @category{dvc}
2326 */
2327 class wxDataViewTreeStore : public wxDataViewModel
2328 {
2329 public:
2330 /**
2331 Constructor. Creates the invisible root node internally.
2332 */
2333 wxDataViewTreeStore();
2334
2335 /**
2336 Destructor.
2337 */
2338 virtual ~wxDataViewTreeStore();
2339
2340 /**
2341 Append a container.
2342 */
2343 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
2344 const wxString& text,
2345 const wxIcon& icon = wxNullIcon,
2346 const wxIcon& expanded = wxNullIcon,
2347 wxClientData* data = NULL);
2348
2349 /**
2350 Append an item.
2351 */
2352 wxDataViewItem AppendItem(const wxDataViewItem& parent,
2353 const wxString& text,
2354 const wxIcon& icon = wxNullIcon,
2355 wxClientData* data = NULL);
2356
2357 /**
2358 Delete all item in the model.
2359 */
2360 void DeleteAllItems();
2361
2362 /**
2363 Delete all children of the item, but not the item itself.
2364 */
2365 void DeleteChildren(const wxDataViewItem& item);
2366
2367 /**
2368 Delete this item.
2369 */
2370 void DeleteItem(const wxDataViewItem& item);
2371
2372 /**
2373 Return the number of children of item.
2374 */
2375 int GetChildCount(const wxDataViewItem& parent) const;
2376
2377 /**
2378 Returns the client data asoociated with the item.
2379 */
2380 wxClientData* GetItemData(const wxDataViewItem& item) const;
2381
2382 /**
2383 Returns the icon to display in expanded containers.
2384 */
2385 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
2386
2387 /**
2388 Returns the icon of the item.
2389 */
2390 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
2391
2392 /**
2393 Returns the text of the item.
2394 */
2395 wxString GetItemText(const wxDataViewItem& item) const;
2396
2397 /**
2398 Returns the nth child item of item.
2399 */
2400 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
2401 unsigned int pos) const;
2402
2403 /**
2404 Inserts a container after @a previous.
2405 */
2406 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
2407 const wxDataViewItem& previous,
2408 const wxString& text,
2409 const wxIcon& icon = wxNullIcon,
2410 const wxIcon& expanded = wxNullIcon,
2411 wxClientData* data = NULL);
2412
2413 /**
2414 Inserts an item after @a previous.
2415 */
2416 wxDataViewItem InsertItem(const wxDataViewItem& parent,
2417 const wxDataViewItem& previous,
2418 const wxString& text,
2419 const wxIcon& icon = wxNullIcon,
2420 wxClientData* data = NULL);
2421
2422 /**
2423 Inserts a container before the first child item or @a parent.
2424 */
2425 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
2426 const wxString& text,
2427 const wxIcon& icon = wxNullIcon,
2428 const wxIcon& expanded = wxNullIcon,
2429 wxClientData* data = NULL);
2430
2431 /**
2432 Inserts an item before the first child item or @a parent.
2433 */
2434 wxDataViewItem PrependItem(const wxDataViewItem& parent,
2435 const wxString& text,
2436 const wxIcon& icon = wxNullIcon,
2437 wxClientData* data = NULL);
2438
2439 /**
2440 Sets the client data associated with the item.
2441 */
2442 void SetItemData(const wxDataViewItem& item, wxClientData* data);
2443
2444 /**
2445 Sets the expanded icon for the item.
2446 */
2447 void SetItemExpandedIcon(const wxDataViewItem& item,
2448 const wxIcon& icon);
2449
2450 /**
2451 Sets the icon for the item.
2452 */
2453 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
2454 };
2455
2456
2457 /**
2458 @class wxDataViewIconText
2459
2460 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2461 This class can be converted to and from a wxVariant.
2462
2463 @library{wxadv}
2464 @category{dvc}
2465 */
2466 class wxDataViewIconText : public wxObject
2467 {
2468 public:
2469 //@{
2470 /**
2471 Constructor.
2472 */
2473 wxDataViewIconText(const wxString& text = wxEmptyString,
2474 const wxIcon& icon = wxNullIcon);
2475 wxDataViewIconText(const wxDataViewIconText& other);
2476 //@}
2477
2478 /**
2479 Gets the icon.
2480 */
2481 const wxIcon& GetIcon() const;
2482
2483 /**
2484 Gets the text.
2485 */
2486 wxString GetText() const;
2487
2488 /**
2489 Set the icon.
2490 */
2491 void SetIcon(const wxIcon& icon);
2492
2493 /**
2494 Set the text.
2495 */
2496 void SetText(const wxString& text);
2497 };
2498
2499
2500
2501 /**
2502 @class wxDataViewEvent
2503
2504 This is the event class for the wxDataViewCtrl notifications.
2505
2506 @beginEventTable{wxDataViewEvent}
2507 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2508 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2509 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2510 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2511 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2512 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2513 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2514 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2515 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2516 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2517 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2518 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2519 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2520 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2521 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2522 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2523 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2524 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2525 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2526 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2527 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2528 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2529 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2530 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2531 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2532 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2533 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2534 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2535 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2536 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2537 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2538 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2539 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2540 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2541 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
2542 Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
2543 @endEventTable
2544
2545 @library{wxadv}
2546 @category{events,dvc}
2547 */
2548 class wxDataViewEvent : public wxNotifyEvent
2549 {
2550 public:
2551 /**
2552 Constructor. Typically used by wxWidgets internals only.
2553 */
2554 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
2555 int winid = 0);
2556
2557 /**
2558 Returns the position of the column in the control or -1
2559 if no column field was set by the event emitter.
2560 */
2561 int GetColumn() const;
2562
2563 /**
2564 Returns a pointer to the wxDataViewColumn from which
2565 the event was emitted or @NULL.
2566 */
2567 wxDataViewColumn* GetDataViewColumn() const;
2568
2569 /**
2570 Returns the wxDataViewModel associated with the event.
2571 */
2572 wxDataViewModel* GetModel() const;
2573
2574 /**
2575 Returns a the position of a context menu event in screen coordinates.
2576 */
2577 wxPoint GetPosition() const;
2578
2579 /**
2580 Returns a reference to a value.
2581 */
2582 const wxVariant& GetValue() const;
2583
2584 /**
2585 Sets the column index associated with this event.
2586 */
2587 void SetColumn(int col);
2588
2589 /**
2590 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2591 */
2592 void SetDataViewColumn(wxDataViewColumn* col);
2593
2594 /**
2595 Sets the dataview model associated with this event.
2596 */
2597 void SetModel(wxDataViewModel* model);
2598
2599 /**
2600 Sets the value associated with this event.
2601 */
2602 void SetValue(const wxVariant& value);
2603
2604 /**
2605 Set wxDataObject for data transfer within a drag operation.
2606 */
2607 void SetDataObject( wxDataObject *obj );
2608
2609 /**
2610 Used internally. Gets associated wxDataObject for data transfer
2611 within a drag operation.
2612 */
2613 wxDataObject *GetDataObject() const;
2614
2615 /**
2616 Used internally. Sets the wxDataFormat during a drop operation.
2617 */
2618 void SetDataFormat( const wxDataFormat &format );
2619
2620 /**
2621 Gets the wxDataFormat during a drop operation.
2622 */
2623 wxDataFormat GetDataFormat() const;
2624
2625 /**
2626 Used internally. Sets the data size for a drop data transfer.
2627 */
2628 void SetDataSize( size_t size );
2629
2630 /**
2631 Gets the data size for a drop data transfer.
2632 */
2633 size_t GetDataSize() const;
2634
2635 /**
2636 Used internally. Sets the data buffer for a drop data transfer.
2637 */
2638 void SetDataBuffer( void* buf );
2639
2640 /**
2641 Gets the data buffer for a drop data transfer.
2642 */
2643 void *GetDataBuffer() const;
2644
2645 /**
2646 Return the first row that will be displayed.
2647 */
2648 int GetCacheFrom() const;
2649
2650 /**
2651 Return the last row that will be displayed.
2652 */
2653 int GetCacheTo() const;
2654 };
2655