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