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