]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dataview.h
avoid infinite recursion for richtooltops, (hopefully) fixes #15070
[wxWidgets.git] / interface / wx / dataview.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dataview.h
80932a3e 3// Purpose: interface of wxDataView* classes
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
b321b61c 9
23324ae1
FM
10/**
11 @class wxDataViewModel
7c913512 12
c4e57202
FM
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
a36bceb6
RR
23 Note that wxDataViewModel does not define the position or index of any item
24 in the control because different controls might display the same data differently.
25 wxDataViewModel does provide a wxDataViewModel::Compare method which the
26 wxDataViewCtrl may use to sort the data either in conjunction with a column
27 header or without (see wxDataViewModel::HasDefaultCompare).
7c913512 28
c4e57202
FM
29 wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
30 to store data and its type in a generic way. wxVariant can be extended to contain
a36bceb6
RR
31 almost any data without changes to the original class. To a certain extent,
32 you can use (the somewhat more elegant) wxAny instead of wxVariant as there
33 is code to convert between the two, but it is unclear what impact this will
34 have on performance.
35
36 Since you will usually allow the wxDataViewCtrl to change your data
37 through its graphical interface, you will also have to override
38 wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
39 to some data has been committed.
7c913512 40
a36bceb6
RR
41 If the data represented by the model is changed by something else than its
42 associated wxDataViewCtrl, the control has to be notified about the change.
c4e57202
FM
43 Depending on what happened you need to call one of the following methods:
44 - wxDataViewModel::ValueChanged,
45 - wxDataViewModel::ItemAdded,
46 - wxDataViewModel::ItemDeleted,
47 - wxDataViewModel::ItemChanged,
48 - wxDataViewModel::Cleared.
49
50 There are plural forms for notification of addition, change or removal of
51 several item at once. See:
52 - wxDataViewModel::ItemsAdded,
53 - wxDataViewModel::ItemsDeleted,
54 - wxDataViewModel::ItemsChanged.
55
c4e57202
FM
56 This class maintains a list of wxDataViewModelNotifier which link this class
57 to the specific implementations on the supported platforms so that e.g. calling
58 wxDataViewModel::ValueChanged on this model will just call
59 wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
60 You can also add your own notifier in order to get informed about any changes
23324ae1 61 to the data in the list model.
7c913512 62
c4e57202 63 Currently wxWidgets provides the following models apart from the base model:
bda698ed
RR
64 wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
65 wxDataViewListStore.
7c913512 66
e4e83d3a 67 Note that wxDataViewModel is reference counted, derives from wxRefCounter
c4e57202
FM
68 and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
69 This implies that you need to decrease the reference count after
23324ae1 70 associating the model with a control like this:
7c913512 71
23324ae1 72 @code
14f73cf1 73 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
23324ae1 74 wxDataViewModel *musicModel = new MyMusicModel;
14f73cf1
FM
75 m_musicCtrl->AssociateModel( musicModel );
76 musicModel->DecRef(); // avoid memory leak !!
43c64cc6 77
23324ae1
FM
78 // add columns now
79 @endcode
7c913512 80
a36bceb6
RR
81 A potentially better way to avoid memory leaks is to use wxObjectDataPtr
82
83 @code
84 wxObjectDataPtr<MyMusicModel> musicModel;
85
86 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
87 musicModel = new MyMusicModel;
88 m_musicCtrl->AssociateModel( musicModel.get() );
89
90 // add columns now
91 @endcode
92
93
23324ae1 94 @library{wxadv}
b321b61c 95 @category{dvc}
23324ae1 96*/
e4e83d3a 97class wxDataViewModel : public wxRefCounter
23324ae1
FM
98{
99public:
100 /**
101 Constructor.
102 */
103 wxDataViewModel();
104
23324ae1 105 /**
c4e57202 106 Adds a wxDataViewModelNotifier to the model.
23324ae1
FM
107 */
108 void AddNotifier(wxDataViewModelNotifier* notifier);
109
795dac4c
VZ
110 /**
111 Change the value of the given item and update the control to reflect
112 it.
113
114 This function simply calls SetValue() and, if it succeeded,
115 ValueChanged().
116
117 @since 2.9.1
118
d86f721a 119 @param variant
795dac4c
VZ
120 The new value.
121 @param item
122 The item (row) to update.
123 @param col
124 The column to update.
125 @return
126 @true if both SetValue() and ValueChanged() returned @true.
127 */
128 bool ChangeValue(const wxVariant& variant,
129 const wxDataViewItem& item,
130 unsigned int col);
131
23324ae1 132 /**
c4e57202
FM
133 Called to inform the model that all data has been cleared.
134 The control will reread the data from the model again.
23324ae1
FM
135 */
136 virtual bool Cleared();
137
138 /**
139 The compare function to be used by control. The default compare function
140 sorts by container and other items separately and in ascending order.
141 Override this for a different sorting behaviour.
c4e57202
FM
142
143 @see HasDefaultCompare().
23324ae1
FM
144 */
145 virtual int Compare(const wxDataViewItem& item1,
146 const wxDataViewItem& item2,
147 unsigned int column,
862de7b3 148 bool ascending) const;
23324ae1
FM
149
150 /**
13f184c0 151 Override this to indicate that the item has special font attributes.
c4e57202
FM
152 This only affects the wxDataViewTextRendererText renderer.
153
7fadac88
VZ
154 The base class version always simply returns @false.
155
c4e57202 156 @see wxDataViewItemAttr.
7fadac88
VZ
157
158 @param item
159 The item for which the attribute is requested.
160 @param col
161 The column of the item for which the attribute is requested.
162 @param attr
163 The attribute to be filled in if the function returns @true.
164 @return
165 @true if this item has an attribute or @false otherwise.
23324ae1 166 */
fadc2df6 167 virtual bool GetAttr(const wxDataViewItem& item, unsigned int col,
7fadac88 168 wxDataViewItemAttr& attr) const;
23324ae1 169
98f8e666
VZ
170 /**
171 Override this to indicate that the item should be disabled.
172
173 Disabled items are displayed differently (e.g. grayed out) and cannot
174 be interacted with.
175
176 The base class version always returns @true, thus making all items
177 enabled by default.
178
179 @param item
180 The item whose enabled status is requested.
181 @param col
182 The column of the item whose enabled status is requested.
183 @return
184 @true if this item should be enabled, @false otherwise.
185
cf5d4c76 186 @note Currently disabling items is not supported by the wxOSX/Carbon
e97f9fbd 187 implementation.
98f8e666
VZ
188
189 @since 2.9.2
190 */
191 virtual bool IsEnabled(const wxDataViewItem &item,
192 unsigned int col) const;
193
23324ae1 194 /**
c4e57202
FM
195 Override this so the control can query the child items of an item.
196 Returns the number of items.
23324ae1
FM
197 */
198 virtual unsigned int GetChildren(const wxDataViewItem& item,
fadc2df6 199 wxDataViewItemArray& children) const = 0;
23324ae1
FM
200
201 /**
202 Override this to indicate the number of columns in the model.
203 */
b91c4601 204 virtual unsigned int GetColumnCount() const = 0;
23324ae1
FM
205
206 /**
207 Override this to indicate what type of data is stored in the
c4e57202
FM
208 column specified by @a col.
209
210 This should return a string indicating the type of data as reported by wxVariant.
23324ae1 211 */
b91c4601 212 virtual wxString GetColumnType(unsigned int col) const = 0;
23324ae1
FM
213
214 /**
215 Override this to indicate which wxDataViewItem representing the parent
57ab6f23 216 of @a item or an invalid wxDataViewItem if the root item is
23324ae1
FM
217 the parent item.
218 */
b91c4601 219 virtual wxDataViewItem GetParent(const wxDataViewItem& item) const = 0;
23324ae1
FM
220
221 /**
c4e57202 222 Override this to indicate the value of @a item.
23324ae1
FM
223 A wxVariant is used to store the data.
224 */
b91c4601
FM
225 virtual void GetValue(wxVariant& variant, const wxDataViewItem& item,
226 unsigned int col) const = 0;
23324ae1
FM
227
228 /**
c4e57202
FM
229 Override this method to indicate if a container item merely acts as a
230 headline (or for categorisation) or if it also acts a normal item with
57ab6f23 231 entries for further columns. By default returns @false.
23324ae1 232 */
328f5751 233 virtual bool HasContainerColumns(const wxDataViewItem& item) const;
23324ae1
FM
234
235 /**
236 Override this to indicate that the model provides a default compare
237 function that the control should use if no wxDataViewColumn has been
238 chosen for sorting. Usually, the user clicks on a column header for
c4e57202
FM
239 sorting, the data will be sorted alphanumerically.
240
241 If any other order (e.g. by index or order of appearance) is required,
242 then this should be used.
243 See wxDataViewIndexListModel for a model which makes use of this.
23324ae1 244 */
328f5751 245 virtual bool HasDefaultCompare() const;
23324ae1 246
b372f20e
VZ
247 /**
248 Return true if there is a value in the given column of this item.
249
250 All normal items have values in all columns but the container items
251 only show their label in the first column (@a col == 0) by default (but
252 see HasContainerColumns()). So this function always returns true for
253 the first column while for the other ones it returns true only if the
254 item is not a container or HasContainerColumns() was overridden to
255 return true for it.
256
257 @since 2.9.1
258 */
259 bool HasValue(const wxDataViewItem& item, unsigned col) const;
260
23324ae1 261 /**
0824e369 262 Override this to indicate of @a item is a container, i.e.\ if
23324ae1
FM
263 it can have child items.
264 */
b91c4601 265 virtual bool IsContainer(const wxDataViewItem& item) const = 0;
23324ae1
FM
266
267 /**
c4e57202 268 Call this to inform the model that an item has been added to the data.
23324ae1 269 */
9ca2afd1 270 bool ItemAdded(const wxDataViewItem& parent,
23324ae1
FM
271 const wxDataViewItem& item);
272
273 /**
274 Call this to inform the model that an item has changed.
c4e57202 275
3a194bda 276 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
23324ae1
FM
277 event (in which the column fields will not be set) to the user.
278 */
9ca2afd1 279 bool ItemChanged(const wxDataViewItem& item);
23324ae1
FM
280
281 /**
282 Call this to inform the model that an item has been deleted from the data.
283 */
9ca2afd1 284 bool ItemDeleted(const wxDataViewItem& parent,
23324ae1
FM
285 const wxDataViewItem& item);
286
287 /**
c4e57202 288 Call this to inform the model that several items have been added to the data.
23324ae1 289 */
9ca2afd1 290 bool ItemsAdded(const wxDataViewItem& parent,
23324ae1
FM
291 const wxDataViewItemArray& items);
292
293 /**
294 Call this to inform the model that several items have changed.
c4e57202 295
3a194bda 296 This will eventually emit @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
23324ae1
FM
297 events (in which the column fields will not be set) to the user.
298 */
9ca2afd1 299 bool ItemsChanged(const wxDataViewItemArray& items);
23324ae1
FM
300
301 /**
302 Call this to inform the model that several items have been deleted.
303 */
9ca2afd1 304 bool ItemsDeleted(const wxDataViewItem& parent,
23324ae1
FM
305 const wxDataViewItemArray& items);
306
307 /**
4cc4bfaf 308 Remove the @a notifier from the list of notifiers.
23324ae1
FM
309 */
310 void RemoveNotifier(wxDataViewModelNotifier* notifier);
311
312 /**
c4e57202 313 Call this to initiate a resort after the sort function has been changed.
23324ae1
FM
314 */
315 virtual void Resort();
316
317 /**
318 This gets called in order to set a value in the data model.
795dac4c 319
c4e57202
FM
320 The most common scenario is that the wxDataViewCtrl calls this method
321 after the user changed some data in the view.
322
795dac4c
VZ
323 This is the function you need to override in your derived class but if
324 you want to call it, ChangeValue() is usually more convenient as
325 otherwise you need to manually call ValueChanged() to update the
326 control itself.
23324ae1 327 */
795dac4c
VZ
328 virtual bool SetValue(const wxVariant& variant,
329 const wxDataViewItem& item,
b91c4601 330 unsigned int col) = 0;
23324ae1
FM
331
332 /**
c4e57202
FM
333 Call this to inform this model that a value in the model has been changed.
334 This is also called from wxDataViewCtrl's internal editing code, e.g. when
335 editing a text field in the control.
336
3a194bda 337 This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
23324ae1
FM
338 event to the user.
339 */
340 virtual bool ValueChanged(const wxDataViewItem& item,
341 unsigned int col);
5e6e278d 342
4e15d1ca
RD
343
344 virtual bool IsListModel() const;
345 virtual bool IsVirtualListModel() const;
346
5e6e278d
FM
347protected:
348
349 /**
350 Destructor. This should not be called directly. Use DecRef() instead.
351 */
352 virtual ~wxDataViewModel();
23324ae1
FM
353};
354
355
e54c96f1 356
e39de702 357/**
b955766e 358 @class wxDataViewListModel
e39de702 359
b955766e
RR
360 Base class with abstract API for wxDataViewIndexListModel and
361 wxDataViewVirtualListModel.
e39de702 362
8ed522d9 363 @library{wxadv}
b321b61c 364 @category{dvc}
e39de702 365*/
b955766e 366class wxDataViewListModel : public wxDataViewModel
e39de702
RR
367{
368public:
e39de702
RR
369
370 /**
371 Destructor.
372 */
4e15d1ca 373 virtual ~wxDataViewListModel();
e39de702
RR
374
375 /**
376 Compare method that sorts the items by their index.
377 */
378 int Compare(const wxDataViewItem& item1,
379 const wxDataViewItem& item2,
2ccd2adc 380 unsigned int column, bool ascending) const;
e39de702
RR
381
382 /**
13f184c0 383 Override this to indicate that the row has special font attributes.
c4e57202
FM
384 This only affects the wxDataViewTextRendererText() renderer.
385
7fadac88
VZ
386 The base class version always simply returns @false.
387
c4e57202 388 @see wxDataViewItemAttr.
7fadac88
VZ
389
390 @param row
391 The row for which the attribute is requested.
392 @param col
393 The column for which the attribute is requested.
394 @param attr
395 The attribute to be filled in if the function returns @true.
396 @return
397 @true if this item has an attribute or @false otherwise.
e39de702 398 */
8eff6c56 399 virtual bool GetAttrByRow(unsigned int row, unsigned int col,
7fadac88 400 wxDataViewItemAttr& attr) const;
e39de702 401
98f8e666
VZ
402 /**
403 Override this if you want to disable specific items.
404
405 The base class version always returns @true, thus making all items
406 enabled by default.
407
408 @param row
409 The row of the item whose enabled status is requested.
410 @param col
411 The column of the item whose enabled status is requested.
412 @return
413 @true if the item at this row and column should be enabled,
414 @false otherwise.
415
416 @note See wxDataViewModel::IsEnabled() for the current status of
417 support for disabling the items under different platforms.
418
419 @since 2.9.2
420 */
421 virtual bool IsEnabledByRow(unsigned int row,
422 unsigned int col) const;
423
74d9b8fb 424 /**
47e2f881 425 Returns the number of items (or rows) in the list.
74d9b8fb 426 */
4e15d1ca 427 unsigned int GetCount() const = 0;
e39de702
RR
428
429 /**
430 Returns the position of given @e item.
431 */
4e15d1ca 432 unsigned int GetRow(const wxDataViewItem& item) const = 0;
e39de702
RR
433
434 /**
435 Override this to allow getting values from the model.
436 */
8eff6c56 437 virtual void GetValueByRow(wxVariant& variant, unsigned int row,
4e15d1ca
RD
438 unsigned int col) const = 0;
439
440 /**
441 Called in order to set a value in the model.
442 */
443 virtual bool SetValueByRow(const wxVariant& variant, unsigned int row,
444 unsigned int col) = 0;
445};
446
447
448/**
449 @class wxDataViewIndexListModel
450
451 wxDataViewIndexListModel is a specialized data model which lets you address
452 an item by its position (row) rather than its wxDataViewItem (which you can
453 obtain from this class).
454 This model also provides its own wxDataViewIndexListModel::Compare
455 method which sorts the model's data by the index.
456
457 This model is not a virtual model since the control stores each wxDataViewItem.
458 Use wxDataViewVirtualListModel if you need to display millions of items or
459 have other reason to use a virtual control.
460
461 @see wxDataViewListModel for the API.
462
463 @library{wxadv}
464 @category{dvc}
465*/
466
467class wxDataViewIndexListModel : public wxDataViewListModel
468{
469public:
470 /**
471 Constructor.
472 */
473 wxDataViewIndexListModel(unsigned int initial_size = 0);
474
475 /**
476 Returns the wxDataViewItem at the given @e row.
477 */
478 wxDataViewItem GetItem(unsigned int row) const;
e39de702
RR
479
480 /**
c4e57202
FM
481 Call this after if the data has to be read again from the model.
482 This is useful after major changes when calling the methods below
483 (possibly thousands of times) doesn't make sense.
e39de702
RR
484 */
485 void Reset(unsigned int new_size);
486
487 /**
488 Call this after a row has been appended to the model.
489 */
490 void RowAppended();
491
492 /**
493 Call this after a row has been changed.
494 */
495 void RowChanged(unsigned int row);
496
497 /**
498 Call this after a row has been deleted.
499 */
500 void RowDeleted(unsigned int row);
501
502 /**
503 Call this after a row has been inserted at the given position.
504 */
505 void RowInserted(unsigned int before);
506
507 /**
508 Call this after a row has been prepended to the model.
509 */
510 void RowPrepended();
511
512 /**
513 Call this after a value has been changed.
514 */
515 void RowValueChanged(unsigned int row, unsigned int col);
516
517 /**
c4e57202
FM
518 Call this after rows have been deleted.
519 The array will internally get copied and sorted in descending order so
520 that the rows with the highest position will be deleted first.
e39de702
RR
521 */
522 void RowsDeleted(const wxArrayInt& rows);
523
b955766e 524};
e39de702
RR
525
526/**
527 @class wxDataViewVirtualListModel
e39de702 528
c4e57202
FM
529 wxDataViewVirtualListModel is a specialized data model which lets you address
530 an item by its position (row) rather than its wxDataViewItem and as such offers
531 the exact same interface as wxDataViewIndexListModel.
532 The important difference is that under platforms other than OS X, using this
533 model will result in a truly virtual control able to handle millions of items
b955766e 534 as the control doesn't store any item (a feature not supported by OS X).
e39de702 535
b955766e 536 @see wxDataViewListModel for the API.
e39de702 537
8ed522d9 538 @library{wxadv}
b321b61c 539 @category{dvc}
e39de702 540*/
b955766e
RR
541
542class wxDataViewVirtualListModel : public wxDataViewListModel
e39de702
RR
543{
544public:
545 /**
546 Constructor.
547 */
548 wxDataViewVirtualListModel(unsigned int initial_size = 0);
74d9b8fb 549
4e15d1ca
RD
550 /**
551 Returns the wxDataViewItem at the given @e row.
552 */
553 wxDataViewItem GetItem(unsigned int row) const;
554
555 /**
556 Call this after if the data has to be read again from the model.
557 This is useful after major changes when calling the methods below
558 (possibly thousands of times) doesn't make sense.
559 */
560 void Reset(unsigned int new_size);
561
562 /**
563 Call this after a row has been appended to the model.
564 */
565 void RowAppended();
566
567 /**
568 Call this after a row has been changed.
569 */
570 void RowChanged(unsigned int row);
571
572 /**
573 Call this after a row has been deleted.
574 */
575 void RowDeleted(unsigned int row);
576
577 /**
578 Call this after a row has been inserted at the given position.
579 */
580 void RowInserted(unsigned int before);
581
582 /**
583 Call this after a row has been prepended to the model.
584 */
585 void RowPrepended();
586
587 /**
588 Call this after a value has been changed.
589 */
590 void RowValueChanged(unsigned int row, unsigned int col);
591
592 /**
593 Call this after rows have been deleted.
594 The array will internally get copied and sorted in descending order so
595 that the rows with the highest position will be deleted first.
596 */
597 void RowsDeleted(const wxArrayInt& rows);
598
6da3d196 599};
e39de702
RR
600
601
602
23324ae1
FM
603/**
604 @class wxDataViewItemAttr
7c913512 605
c4e57202
FM
606 This class is used to indicate to a wxDataViewCtrl that a certain item
607 (see wxDataViewItem) has extra font attributes for its renderer.
608 For this, it is required to override wxDataViewModel::GetAttr.
7c913512 609
c4e57202 610 Attributes are currently only supported by wxDataViewTextRendererText.
7c913512 611
23324ae1 612 @library{wxadv}
b321b61c 613 @category{dvc}
23324ae1 614*/
7c913512 615class wxDataViewItemAttr
23324ae1
FM
616{
617public:
618 /**
619 Constructor.
620 */
621 wxDataViewItemAttr();
622
623 /**
624 Call this to indicate that the item shall be displayed in bold text.
625 */
626 void SetBold(bool set);
627
628 /**
c4e57202 629 Call this to indicate that the item shall be displayed with that colour.
23324ae1
FM
630 */
631 void SetColour(const wxColour& colour);
632
1c959a62
VZ
633 /**
634 Call this to set the background colour to use.
635
636 Currently this attribute is only supported in the generic version of
637 wxDataViewCtrl and ignored by the native GTK+ and OS X implementations.
638
639 @since 2.9.4
640 */
641 void SetBackgroundColour(const wxColour& colour);
642
23324ae1
FM
643 /**
644 Call this to indicate that the item shall be displayed in italic text.
645 */
646 void SetItalic(bool set);
4e15d1ca
RD
647
648
649 /**
650 Returns true if the colour property has been set.
651 */
652 bool HasColour() const;
653
654 /**
655 Returns this attribute's colour.
656 */
657 const wxColour& GetColour() const;
658
659 /**
660 Returns true if any property affecting the font has been set.
661 */
662 bool HasFont() const;
663
664 /**
665 Returns value of the bold property.
666 */
667 bool GetBold() const;
668
669 /**
670 Returns value of the italics property.
671 */
672 bool GetItalic() const;
673
674 /**
675 Returns true if the background colour property has been set.
676 */
677 bool HasBackgroundColour() const;
678
679 /**
680 Returns the colour to be used for the background.
681 */
682 const wxColour& GetBackgroundColour() const;
683
684 /**
685 Returns true if none of the properties have been set.
686 */
687 bool IsDefault() const;
688
689 /**
690 Return the font based on the given one with this attribute applied to it.
691 */
692 wxFont GetEffectiveFont(const wxFont& font) const;
23324ae1
FM
693};
694
695
e54c96f1 696
23324ae1
FM
697/**
698 @class wxDataViewItem
7c913512 699
c4e57202 700 wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
fe45d6ff 701 in a persistent way, i.e. independent of the position of the item in the control
c4e57202
FM
702 or changes to its contents.
703
704 It must hold a unique ID of type @e void* in its only field and can be converted
705 to and from it.
706
707 If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
708 return @false which used in many places in the API of wxDataViewCtrl to
709 indicate that e.g. no item was found. An ID of @NULL is also used to indicate
710 the invisible root. Examples for this are wxDataViewModel::GetParent and
23324ae1 711 wxDataViewModel::GetChildren.
7c913512 712
23324ae1 713 @library{wxadv}
b321b61c 714 @category{dvc}
23324ae1 715*/
7c913512 716class wxDataViewItem
23324ae1
FM
717{
718public:
719 //@{
720 /**
c4e57202 721 Constructor.
23324ae1 722 */
d5c4a81f 723 wxDataViewItem();
7c913512 724 wxDataViewItem(const wxDataViewItem& item);
d5c4a81f 725 explicit wxDataViewItem(void* id);
23324ae1
FM
726 //@}
727
728 /**
729 Returns the ID.
730 */
328f5751 731 void* GetID() const;
23324ae1
FM
732
733 /**
c4e57202 734 Returns @true if the ID is not @NULL.
23324ae1 735 */
328f5751 736 bool IsOk() const;
23324ae1
FM
737};
738
739
e9321277
RD
740// ----------------------------------------------------------------------------
741// wxDataViewCtrl flags
742// ----------------------------------------------------------------------------
743
744// size of a wxDataViewRenderer without contents:
745#define wxDVC_DEFAULT_RENDERER_SIZE 20
746
747// the default width of new (text) columns:
748#define wxDVC_DEFAULT_WIDTH 80
749
750// the default width of new toggle columns:
751#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
752
753// the default minimal width of the columns:
754#define wxDVC_DEFAULT_MINWIDTH 30
755
756// The default alignment of wxDataViewRenderers is to take
757// the alignment from the column it owns.
758#define wxDVR_DEFAULT_ALIGNMENT -1
759
760#define wxDV_SINGLE 0x0000 // for convenience
761#define wxDV_MULTIPLE 0x0001 // can select multiple items
762
763#define wxDV_NO_HEADER 0x0002 // column titles not visible
764#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
765#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
766
767#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
768#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
769
ea8fa3c4
RD
770// events
771
772wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED;
773
774wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED;
775wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING;
776wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED;
777wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING;
778wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED;
779wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING;
780wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED;
781wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE;
782wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED;
783
784wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU;
785
786wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK;
787wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
788wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED;
789wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED;
790wxEventType wxEVT_COMMAND_DATAVIEW_CACHE_HINT;
791
792wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG;
793wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE;
794wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP;
e54c96f1 795
23324ae1
FM
796/**
797 @class wxDataViewCtrl
7c913512 798
c4e57202
FM
799 wxDataViewCtrl is a control to display data either in a tree like fashion or
800 in a tabular form or both.
02b51ae5 801
c4e57202
FM
802 If you only need to display a simple tree structure with an API more like the
803 older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
02b51ae5 804 Likewise, if you only want to display simple table structure you can use
832df171
RR
805 the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
806 wxDataViewListCtrl can be used without defining your own wxDataViewModel.
c4e57202
FM
807
808 A wxDataViewItem is used to represent a (visible) item in the control.
809
80932a3e 810 Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
c4e57202
FM
811 virtual functions or by setting it directly. Instead you need to write your own
812 wxDataViewModel and associate it with this control.
813 Then you need to add a number of wxDataViewColumn to this control to define
814 what each column shall display. Each wxDataViewColumn in turn owns 1 instance
815 of a wxDataViewRenderer to render its cells.
816
817 A number of standard renderers for rendering text, dates, images, toggle,
818 a progress bar etc. are provided. Additionally, the user can write custom
80932a3e 819 renderers deriving from wxDataViewCustomRenderer for displaying anything.
c4e57202
FM
820
821 All data transfer from the control to the model and the user code is done
822 through wxVariant which can be extended to support more data formats as necessary.
823 Accordingly, all type information uses the strings returned from wxVariant::GetType.
7c913512 824
23324ae1 825 @beginStyleTable
8c6791e4 826 @style{wxDV_SINGLE}
23324ae1 827 Single selection mode. This is the default.
8c6791e4 828 @style{wxDV_MULTIPLE}
23324ae1 829 Multiple selection mode.
8c6791e4 830 @style{wxDV_ROW_LINES}
23324ae1 831 Use alternating colours for rows if supported by platform and theme.
cc72cde0
VZ
832 Currently only supported by the native GTK and OS X implementations
833 but not by the generic one.
8c6791e4 834 @style{wxDV_HORIZ_RULES}
23324ae1 835 Display fine rules between row if supported.
8c6791e4 836 @style{wxDV_VERT_RULES}
23324ae1 837 Display fine rules between columns is supported.
d7c6d397 838 @style{wxDV_VARIABLE_LINE_HEIGHT}
c4e57202 839 Allow variable line heights.
14f73cf1 840 This can be inefficient when displaying large number of items.
b5123fb6
VZ
841 @style{wxDV_NO_HEADER}
842 Do not show column headers (which are shown by default).
23324ae1 843 @endStyleTable
7c913512 844
3051a44a 845 @beginEventEmissionTable{wxDataViewEvent}
7d01d660 846 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
14f73cf1 847 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
7d01d660 848 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
43868fde
VZ
849 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. This event
850 is triggered by double clicking an item or pressing some special key
851 (usually "Enter") when it is focused.
3e978cf7 852 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
b0c7cd8e 853 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event. This
3e978cf7 854 event can be vetoed in order to prevent editing on an item by item
b0c7cd8e 855 basis.
7d01d660 856 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
14f73cf1 857 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
7d01d660 858 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
14f73cf1 859 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
7d01d660 860 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
14f73cf1 861 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
7d01d660 862 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
14f73cf1 863 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
7d01d660 864 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
14f73cf1 865 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
7d01d660 866 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
14f73cf1 867 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
7d01d660 868 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
14f73cf1 869 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
7d01d660 870 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
7ed24cb6
VZ
871 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event
872 generated when the user right clicks inside the control. Notice that
873 this menu is generated even if the click didn't occur on any valid
874 item, in this case wxDataViewEvent::GetItem() simply returns an
875 invalid item.
7d01d660 876 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2392b8e8 877 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK event.
7d01d660 878 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
14f73cf1 879 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
7d01d660 880 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
14f73cf1 881 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
7d01d660 882 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
14f73cf1 883 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
591cc82d 884 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
14f73cf1 885 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
e4de825e 886 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
14f73cf1 887 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
e4de825e 888 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
14f73cf1 889 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
7d01d660 890 @endEventTable
b91c4601 891
43868fde
VZ
892 Notice that this control doesn't allow to process generic mouse events such
893 as @c wxEVT_LEFT_DOWN in all ports (notably it doesn't work in wxGTK). If
894 you need to handle any mouse events not covered by the ones above, consider
895 using a custom renderer for the cells that must handle them.
896
23324ae1 897 @library{wxadv}
b321b61c 898 @category{ctrl,dvc}
ce154616 899 @appearance{dataviewctrl}
23324ae1
FM
900*/
901class wxDataViewCtrl : public wxControl
902{
903public:
23324ae1 904 /**
19723525 905 Default Constructor.
23324ae1
FM
906 */
907 wxDataViewCtrl();
b91c4601 908
19723525
RR
909 /**
910 Constructor. Calls Create().
911 */
7c913512
FM
912 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
913 const wxPoint& pos = wxDefaultPosition,
914 const wxSize& size = wxDefaultSize,
915 long style = 0,
8eb99915
RR
916 const wxValidator& validator = wxDefaultValidator,
917 const wxString& name = wxDataViewCtrlNameStr);
23324ae1
FM
918
919 /**
920 Destructor.
921 */
adaaa686 922 virtual ~wxDataViewCtrl();
23324ae1 923
4e15d1ca
RD
924 /**
925 Create the control. Useful for two step creation.
926 */
927 bool Create(wxWindow* parent, wxWindowID id,
928 const wxPoint& pos = wxDefaultPosition,
929 const wxSize& size = wxDefaultSize,
930 long style = 0,
931 const wxValidator& validator = wxDefaultValidator,
932 const wxString& name = wxDataViewCtrlNameStr);
933
e39de702 934 /**
19723525 935 Appends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 936
e39de702
RR
937 Note that there is a number of short cut methods which implicitly create
938 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
939 */
940 virtual bool AppendColumn(wxDataViewColumn* col);
941
19723525
RR
942 /**
943 Prepends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 944
19723525
RR
945 Note that there is a number of short cut methods which implicitly create
946 a wxDataViewColumn and a wxDataViewRenderer for it.
947 */
948 virtual bool PrependColumn(wxDataViewColumn* col);
949
950 /**
951 Inserts a wxDataViewColumn to the control. Returns @true on success.
952 */
953 virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
b91c4601 954
23324ae1
FM
955 //@{
956 /**
957 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
958 created in the function or @NULL on failure.
959 */
960 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
961 unsigned int model_column,
962 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
963 int width = -1,
964 wxAlignment align = wxALIGN_CENTER,
965 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
966 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
967 unsigned int model_column,
968 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
969 int width = -1,
970 wxAlignment align = wxALIGN_CENTER,
971 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
972 //@}
973
4e15d1ca
RD
974 //@{
975 /**
976 Prepends a column for rendering a bitmap. Returns the wxDataViewColumn
977 created in the function or @NULL on failure.
978 */
979 wxDataViewColumn* PrependBitmapColumn(const wxString& label,
980 unsigned int model_column,
981 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
982 int width = -1,
983 wxAlignment align = wxALIGN_CENTER,
984 int flags = wxDATAVIEW_COL_RESIZABLE);
985 wxDataViewColumn* PrependBitmapColumn(const wxBitmap& label,
986 unsigned int model_column,
987 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
988 int width = -1,
989 wxAlignment align = wxALIGN_CENTER,
990 int flags = wxDATAVIEW_COL_RESIZABLE);
991 //@}
992
23324ae1
FM
993 //@{
994 /**
995 Appends a column for rendering a date. Returns the wxDataViewColumn
996 created in the function or @NULL on failure.
b91c4601 997
c4e57202
FM
998 @note The @a align parameter is applied to both the column header and
999 the column renderer.
23324ae1
FM
1000 */
1001 wxDataViewColumn* AppendDateColumn(const wxString& label,
1002 unsigned int model_column,
1003 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1004 int width = -1,
882678eb 1005 wxAlignment align = wxALIGN_NOT,
23324ae1 1006 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1007 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
1008 unsigned int model_column,
1009 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1010 int width = -1,
882678eb 1011 wxAlignment align = wxALIGN_NOT,
7c913512 1012 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1013 //@}
1014
4e15d1ca
RD
1015 //@{
1016 /**
1017 Prepends a column for rendering a date. Returns the wxDataViewColumn
1018 created in the function or @NULL on failure.
1019
1020 @note The @a align parameter is applied to both the column header and
1021 the column renderer.
1022 */
1023 wxDataViewColumn* PrependDateColumn(const wxString& label,
1024 unsigned int model_column,
1025 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1026 int width = -1,
1027 wxAlignment align = wxALIGN_NOT,
1028 int flags = wxDATAVIEW_COL_RESIZABLE);
1029 wxDataViewColumn* PrependDateColumn(const wxBitmap& label,
1030 unsigned int model_column,
1031 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1032 int width = -1,
1033 wxAlignment align = wxALIGN_NOT,
1034 int flags = wxDATAVIEW_COL_RESIZABLE);
1035 //@}
1036
23324ae1
FM
1037 //@{
1038 /**
1039 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
c4e57202
FM
1040 created in the function or @NULL on failure.
1041 This method uses the wxDataViewIconTextRenderer class.
b91c4601 1042
c4e57202
FM
1043 @note The @a align parameter is applied to both the column header and
1044 the column renderer.
23324ae1
FM
1045 */
1046 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
1047 unsigned int model_column,
1048 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1049 int width = -1,
882678eb 1050 wxAlignment align = wxALIGN_NOT,
23324ae1 1051 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1052 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
1053 unsigned int model_column,
1054 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1055 int width = -1,
882678eb 1056 wxAlignment align = wxALIGN_NOT,
7c913512 1057 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1058 //@}
1059
4e15d1ca
RD
1060 //@{
1061 /**
1062 Prepends a column for rendering text with an icon. Returns the wxDataViewColumn
1063 created in the function or @NULL on failure.
1064 This method uses the wxDataViewIconTextRenderer class.
1065
1066 @note The @a align parameter is applied to both the column header and
1067 the column renderer.
1068 */
1069 wxDataViewColumn* PrependIconTextColumn(const wxString& label,
1070 unsigned int model_column,
1071 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1072 int width = -1,
1073 wxAlignment align = wxALIGN_NOT,
1074 int flags = wxDATAVIEW_COL_RESIZABLE);
1075 wxDataViewColumn* PrependIconTextColumn(const wxBitmap& label,
1076 unsigned int model_column,
1077 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1078 int width = -1,
1079 wxAlignment align = wxALIGN_NOT,
1080 int flags = wxDATAVIEW_COL_RESIZABLE);
1081 //@}
1082
23324ae1
FM
1083 //@{
1084 /**
1085 Appends a column for rendering a progress indicator. Returns the
e39de702 1086 wxDataViewColumn created in the function or @NULL on failure.
b91c4601 1087
c4e57202
FM
1088 @note The @a align parameter is applied to both the column header and
1089 the column renderer.
23324ae1
FM
1090 */
1091 wxDataViewColumn* AppendProgressColumn(const wxString& label,
1092 unsigned int model_column,
1093 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1094 int width = 80,
1095 wxAlignment align = wxALIGN_CENTER,
1096 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1097 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
1098 unsigned int model_column,
1099 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1100 int width = 80,
1101 wxAlignment align = wxALIGN_CENTER,
1102 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1103 //@}
1104
4e15d1ca
RD
1105 //@{
1106 /**
1107 Prepends a column for rendering a progress indicator. Returns the
1108 wxDataViewColumn created in the function or @NULL on failure.
1109
1110 @note The @a align parameter is applied to both the column header and
1111 the column renderer.
1112 */
1113 wxDataViewColumn* PrependProgressColumn(const wxString& label,
1114 unsigned int model_column,
1115 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1116 int width = 80,
1117 wxAlignment align = wxALIGN_CENTER,
1118 int flags = wxDATAVIEW_COL_RESIZABLE);
1119 wxDataViewColumn* PrependProgressColumn(const wxBitmap& label,
1120 unsigned int model_column,
1121 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1122 int width = 80,
1123 wxAlignment align = wxALIGN_CENTER,
1124 int flags = wxDATAVIEW_COL_RESIZABLE);
1125 //@}
1126
23324ae1
FM
1127 //@{
1128 /**
1129 Appends a column for rendering text. Returns the wxDataViewColumn
1130 created in the function or @NULL on failure.
b91c4601 1131
c4e57202
FM
1132 @note The @a align parameter is applied to both the column header and
1133 the column renderer.
23324ae1
FM
1134 */
1135 wxDataViewColumn* AppendTextColumn(const wxString& label,
1136 unsigned int model_column,
1137 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1138 int width = -1,
882678eb 1139 wxAlignment align = wxALIGN_NOT,
23324ae1 1140 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1141 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
1142 unsigned int model_column,
1143 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1144 int width = -1,
882678eb 1145 wxAlignment align = wxALIGN_NOT,
7c913512 1146 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1147 //@}
1148
4e15d1ca
RD
1149 //@{
1150 /**
1151 Prepends a column for rendering text. Returns the wxDataViewColumn
1152 created in the function or @NULL on failure.
1153
1154 @note The @a align parameter is applied to both the column header and
1155 the column renderer.
1156 */
1157 wxDataViewColumn* PrependTextColumn(const wxString& label,
1158 unsigned int model_column,
1159 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1160 int width = -1,
1161 wxAlignment align = wxALIGN_NOT,
1162 int flags = wxDATAVIEW_COL_RESIZABLE);
1163 wxDataViewColumn* PrependTextColumn(const wxBitmap& label,
1164 unsigned int model_column,
1165 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1166 int width = -1,
1167 wxAlignment align = wxALIGN_NOT,
1168 int flags = wxDATAVIEW_COL_RESIZABLE);
1169 //@}
1170
23324ae1
FM
1171 //@{
1172 /**
1173 Appends a column for rendering a toggle. Returns the wxDataViewColumn
1174 created in the function or @NULL on failure.
b91c4601 1175
c4e57202
FM
1176 @note The @a align parameter is applied to both the column header and
1177 the column renderer.
23324ae1
FM
1178 */
1179 wxDataViewColumn* AppendToggleColumn(const wxString& label,
1180 unsigned int model_column,
1181 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1182 int width = 30,
1183 wxAlignment align = wxALIGN_CENTER,
1184 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1185 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
1186 unsigned int model_column,
1187 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1188 int width = 30,
1189 wxAlignment align = wxALIGN_CENTER,
1190 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1191 //@}
1192
4e15d1ca
RD
1193 //@{
1194 /**
1195 Prepends a column for rendering a toggle. Returns the wxDataViewColumn
1196 created in the function or @NULL on failure.
1197
1198 @note The @a align parameter is applied to both the column header and
1199 the column renderer.
1200 */
1201 wxDataViewColumn* PrependToggleColumn(const wxString& label,
1202 unsigned int model_column,
1203 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1204 int width = 30,
1205 wxAlignment align = wxALIGN_CENTER,
1206 int flags = wxDATAVIEW_COL_RESIZABLE);
1207 wxDataViewColumn* PrependToggleColumn(const wxBitmap& label,
1208 unsigned int model_column,
1209 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1210 int width = 30,
1211 wxAlignment align = wxALIGN_CENTER,
1212 int flags = wxDATAVIEW_COL_RESIZABLE);
1213 //@}
1214
23324ae1 1215 /**
c4e57202
FM
1216 Associates a wxDataViewModel with the control.
1217 This increases the reference count of the model by 1.
23324ae1
FM
1218 */
1219 virtual bool AssociateModel(wxDataViewModel* model);
1220
1221 /**
1222 Removes all columns.
1223 */
1224 virtual bool ClearColumns();
1225
23324ae1
FM
1226 /**
1227 Collapses the item.
1228 */
adaaa686 1229 virtual void Collapse(const wxDataViewItem& item);
23324ae1 1230
23324ae1
FM
1231 /**
1232 Deletes given column.
1233 */
50ec54b6 1234 virtual bool DeleteColumn(wxDataViewColumn* column);
23324ae1 1235
907f09f4
VS
1236 /**
1237 Programmatically starts editing given cell of @a item.
1238
1239 Doesn't do anything if the item or this column is not editable.
1240
1241 @note Currently not implemented in wxOSX/Carbon.
1242
1243 @since 2.9.4
1244 */
1245 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
1246
e4de825e
RR
1247 /**
1248 Enable drag operations using the given @a format.
1249 */
1250 virtual bool EnableDragSource( const wxDataFormat &format );
02b51ae5 1251
e4de825e
RR
1252 /**
1253 Enable drop operations using the given @a format.
1254 */
1255 virtual bool EnableDropTarget( const wxDataFormat &format );
02b51ae5 1256
23324ae1
FM
1257 /**
1258 Call this to ensure that the given item is visible.
1259 */
fadc2df6
FM
1260 virtual void EnsureVisible(const wxDataViewItem& item,
1261 const wxDataViewColumn* column = NULL);
23324ae1
FM
1262
1263 /**
1264 Expands the item.
1265 */
adaaa686 1266 virtual void Expand(const wxDataViewItem& item);
23324ae1 1267
4219d8b0
RR
1268 /**
1269 Expands all ancestors of the @a item. This method also
1270 ensures that the item itself as well as all ancestor
1271 items have been read from the model by the control.
1272 */
1273 virtual void ExpandAncestors( const wxDataViewItem & item );
798c0d87 1274
23324ae1 1275 /**
c4e57202
FM
1276 Returns pointer to the column. @a pos refers to the position in the
1277 control which may change after reordering columns by the user.
23324ae1 1278 */
328f5751 1279 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
23324ae1
FM
1280
1281 /**
1282 Returns the number of columns.
1283 */
328f5751 1284 virtual unsigned int GetColumnCount() const;
23324ae1
FM
1285
1286 /**
1287 Returns the position of the column or -1 if not found in the control.
1288 */
328f5751 1289 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
23324ae1
FM
1290
1291 /**
1292 Returns column containing the expanders.
1293 */
328f5751 1294 wxDataViewColumn* GetExpanderColumn() const;
23324ae1 1295
80ce465c
VZ
1296 /**
1297 Returns the currently focused item.
1298
1299 This is the item that the keyboard commands apply to. It may be invalid
1300 if there is no focus currently.
1301
1302 This method is mostly useful for the controls with @c wxDV_MULTIPLE
1303 style as in the case of single selection it returns the same thing as
1304 GetSelection().
1305
1306 Notice that under all platforms except Mac OS X the currently focused
1307 item may be selected or not but under OS X the current item is always
1308 selected.
1309
ee1377e1 1310 @see SetCurrentItem(), GetCurrentColumn()
80ce465c
VZ
1311
1312 @since 2.9.2
1313 */
1314 wxDataViewItem GetCurrentItem() const;
1315
ee1377e1
VS
1316 /**
1317 Returns the column that currently has focus.
1318
1319 If the focus is set to individual cell within the currently focused
1320 item (as opposed to being on the item as a whole), then this is the
1321 column that the focus is on.
1322
1323 Returns NULL if no column currently has focus.
1324
1325 @see GetCurrentItem()
1326
1327 @since 2.9.4
1328 */
1329 wxDataViewColumn *GetCurrentColumn() const;
1330
23324ae1
FM
1331 /**
1332 Returns indentation.
1333 */
328f5751 1334 int GetIndent() const;
23324ae1
FM
1335
1336 /**
7f15deea
VZ
1337 Returns item rectangle.
1338
1339 This method is currently not implemented at all in wxGTK and only
1340 implemented for non-@NULL @a col argument in wxOSX. It is fully
1341 implemented in the generic version of the control.
1342
1343 @param item
1344 A valid item.
1345 @param col
1346 If non-@NULL, the rectangle returned corresponds to the
1347 intersection of the item with the specified column. If @NULL, the
1348 rectangle spans all the columns.
23324ae1 1349 */
fadc2df6
FM
1350 virtual wxRect GetItemRect(const wxDataViewItem& item,
1351 const wxDataViewColumn* col = NULL) const;
23324ae1
FM
1352
1353 /**
c4e57202 1354 Returns pointer to the data model associated with the control (if any).
23324ae1 1355 */
adaaa686 1356 wxDataViewModel* GetModel();
23324ae1 1357
fa93d732
VZ
1358 /**
1359 Returns the number of currently selected items.
1360
1361 This method may be called for both the controls with single and
1362 multiple selections and returns the number of selected item, possibly
1363 0, in any case.
1364
1365 @since 2.9.3
1366 */
1367 virtual int GetSelectedItemsCount() const;
1368
23324ae1
FM
1369 /**
1370 Returns first selected item or an invalid item if none is selected.
fa93d732
VZ
1371
1372 This method may be called for both the controls with single and
1373 multiple selections but returns an invalid item if more than one item
1374 is selected in the latter case, use HasSelection() to determine if
1375 there are any selected items when using multiple selection.
23324ae1 1376 */
adaaa686 1377 virtual wxDataViewItem GetSelection() const;
23324ae1
FM
1378
1379 /**
c4e57202 1380 Fills @a sel with currently selected items and returns their number.
fa93d732
VZ
1381
1382 This method may be called for both the controls with single and
1383 multiple selections. In the single selection case it returns the array
1384 with at most one element in it.
1385
1386 @see GetSelectedItemsCount()
23324ae1 1387 */
adaaa686 1388 virtual int GetSelections(wxDataViewItemArray& sel) const;
23324ae1
FM
1389
1390 /**
1391 Returns the wxDataViewColumn currently responsible for sorting
1392 or @NULL if none has been selected.
1393 */
328f5751 1394 virtual wxDataViewColumn* GetSortingColumn() const;
23324ae1 1395
fa93d732
VZ
1396 /**
1397 Returns true if any items are currently selected.
1398
1399 This method may be called for both the controls with single and
1400 multiple selections.
1401
1402 Calling this method is equivalent to calling GetSelectedItemsCount()
1403 and comparing its result with 0 but is more clear and might also be
1404 implemented more efficiently in the future.
1405
1406 @since 2.9.3
1407 */
1408 bool HasSelection() const;
1409
23324ae1
FM
1410 /**
1411 Hittest.
1412 */
fadc2df6
FM
1413 virtual void HitTest(const wxPoint& point, wxDataViewItem& item,
1414 wxDataViewColumn*& col) const;
23324ae1 1415
739a8399
RR
1416 /**
1417 Return @true if the item is expanded.
739a8399
RR
1418 */
1419 virtual bool IsExpanded(const wxDataViewItem& item) const;
1420
23324ae1
FM
1421 /**
1422 Return @true if the item is selected.
1423 */
adaaa686 1424 virtual bool IsSelected(const wxDataViewItem& item) const;
23324ae1
FM
1425
1426 /**
1427 Select the given item.
1e184300
VZ
1428
1429 In single selection mode this changes the (unique) currently selected
1430 item. In multi selection mode, the @a item is selected and the
1431 previously selected items remain selected.
23324ae1 1432 */
adaaa686 1433 virtual void Select(const wxDataViewItem& item);
23324ae1
FM
1434
1435 /**
1436 Select all items.
1437 */
adaaa686 1438 virtual void SelectAll();
23324ae1
FM
1439
1440 /**
1441 Set which column shall contain the tree-like expanders.
1442 */
4cc4bfaf 1443 void SetExpanderColumn(wxDataViewColumn* col);
23324ae1 1444
80ce465c
VZ
1445 /**
1446 Changes the currently focused item.
1447
1448 The @a item parameter must be valid, there is no way to remove the
1449 current item from the control.
1450
1451 In single selection mode, calling this method is the same as calling
1452 Select() and is thus not very useful. In multiple selection mode this
1453 method only moves the current item however without changing the
1454 selection except under OS X where the current item is always selected,
1455 so calling SetCurrentItem() selects @a item if it hadn't been selected
1456 before.
1457
1458 @see GetCurrentItem()
1459
1460 @since 2.9.2
1461 */
1462 void SetCurrentItem(const wxDataViewItem& item);
1463
23324ae1 1464 /**
57ab6f23 1465 Sets the indentation.
23324ae1
FM
1466 */
1467 void SetIndent(int indent);
1468
1469 /**
1470 Sets the selection to the array of wxDataViewItems.
1471 */
adaaa686 1472 virtual void SetSelections(const wxDataViewItemArray& sel);
23324ae1
FM
1473
1474 /**
1475 Unselect the given item.
1476 */
adaaa686 1477 virtual void Unselect(const wxDataViewItem& item);
23324ae1
FM
1478
1479 /**
c4e57202
FM
1480 Unselect all item.
1481 This method only has effect if multiple selections are allowed.
23324ae1 1482 */
adaaa686 1483 virtual void UnselectAll();
bbfd4548
VZ
1484
1485 /**
1486 Sets the row height.
1487
1488 This function can only be used when all rows have the same height, i.e.
1489 when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
1490
0f4a54a6
VZ
1491 Currently this is implemented in the generic and native GTK versions
1492 only and nothing is done (and @false returned) when using OS X port.
1493
1494 Also notice that this method can only be used to increase the row
1495 height compared with the default one (as determined by the return value
1496 of wxDataViewRenderer::GetSize()), if it is set to a too small value
1497 then the minimum required by the renderers will be used.
bbfd4548
VZ
1498
1499 @return @true if the line height was changed or @false otherwise.
1500
1501 @since 2.9.2
1502 */
1503 virtual bool SetRowHeight(int rowHeight);
23324ae1
FM
1504};
1505
1506
e54c96f1 1507
23324ae1
FM
1508/**
1509 @class wxDataViewModelNotifier
7c913512 1510
c4e57202
FM
1511 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1512 its notification interface.
1513 See the documentation of that class for further information.
7c913512 1514
8ed522d9 1515 @library{wxadv}
b321b61c 1516 @category{dvc}
23324ae1 1517*/
7c913512 1518class wxDataViewModelNotifier
23324ae1
FM
1519{
1520public:
1521 /**
1522 Constructor.
1523 */
1524 wxDataViewModelNotifier();
1525
1526 /**
1527 Destructor.
1528 */
adaaa686 1529 virtual ~wxDataViewModelNotifier();
23324ae1
FM
1530
1531 /**
1532 Called by owning model.
1533 */
b91c4601 1534 virtual bool Cleared() = 0;
23324ae1
FM
1535
1536 /**
1537 Get owning wxDataViewModel.
1538 */
e51bf699 1539 wxDataViewModel* GetOwner() const;
23324ae1
FM
1540
1541 /**
1542 Called by owning model.
63e55c0a
VS
1543
1544 @return Always return @true from this function in derived classes.
23324ae1 1545 */
fadc2df6
FM
1546 virtual bool ItemAdded(const wxDataViewItem& parent,
1547 const wxDataViewItem& item) = 0;
23324ae1
FM
1548
1549 /**
1550 Called by owning model.
63e55c0a
VS
1551
1552 @return Always return @true from this function in derived classes.
23324ae1 1553 */
b91c4601 1554 virtual bool ItemChanged(const wxDataViewItem& item) = 0;
23324ae1
FM
1555
1556 /**
1557 Called by owning model.
63e55c0a
VS
1558
1559 @return Always return @true from this function in derived classes.
23324ae1 1560 */
fadc2df6
FM
1561 virtual bool ItemDeleted(const wxDataViewItem& parent,
1562 const wxDataViewItem& item) = 0;
23324ae1
FM
1563
1564 /**
1565 Called by owning model.
63e55c0a
VS
1566
1567 @return Always return @true from this function in derived classes.
23324ae1 1568 */
fadc2df6
FM
1569 virtual bool ItemsAdded(const wxDataViewItem& parent,
1570 const wxDataViewItemArray& items);
23324ae1
FM
1571
1572 /**
1573 Called by owning model.
63e55c0a
VS
1574
1575 @return Always return @true from this function in derived classes.
23324ae1 1576 */
adaaa686 1577 virtual bool ItemsChanged(const wxDataViewItemArray& items);
23324ae1
FM
1578
1579 /**
1580 Called by owning model.
63e55c0a
VS
1581
1582 @return Always return @true from this function in derived classes.
23324ae1 1583 */
fadc2df6
FM
1584 virtual bool ItemsDeleted(const wxDataViewItem& parent,
1585 const wxDataViewItemArray& items);
23324ae1
FM
1586
1587 /**
1588 Called by owning model.
1589 */
b91c4601 1590 virtual void Resort() = 0;
23324ae1
FM
1591
1592 /**
1593 Set owner of this notifier. Used internally.
1594 */
1595 void SetOwner(wxDataViewModel* owner);
1596
1597 /**
1598 Called by owning model.
63e55c0a
VS
1599
1600 @return Always return @true from this function in derived classes.
23324ae1 1601 */
b91c4601 1602 virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0;
23324ae1
FM
1603};
1604
1605
c4e57202
FM
1606/**
1607 The mode of a data-view cell; see wxDataViewRenderer for more info.
1608*/
1609enum wxDataViewCellMode
1610{
dc73d7f5
VS
1611 /**
1612 The cell only displays information and cannot be manipulated or
1613 otherwise interacted with in any way.
1614
1615 Note that this doesn't mean that the row being drawn can't be selected,
1616 just that a particular element of it cannot be individually modified.
1617 */
c4e57202
FM
1618 wxDATAVIEW_CELL_INERT,
1619
1620 /**
dc73d7f5
VS
1621 Indicates that the cell can be @em activated by clicking it or using
1622 keyboard.
1623
1624 Activating a cell is an alternative to showing inline editor when the
1625 value can be edited in a simple way that doesn't warrant full editor
1626 control. The most typical use of cell activation is toggling the
1627 checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded
1628 volume slider or a five-star rating column.
1629
1630 The exact means of activating a cell are platform-dependent, but they
1631 are usually similar to those used for inline editing of values.
1632 Typically, a cell would be activated by Space or Enter keys or by left
1633 mouse click.
1634
1635 @note Do not confuse this with item activation in wxDataViewCtrl
1636 and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is
1637 used for activating the item (or, to put it differently, the
1638 entire row) similarly to analogous messages in wxTreeCtrl and
1639 wxListCtrl, and the effect differs (play a song, open a file
1640 etc.). Cell activation, on the other hand, is all about
1641 interacting with the individual cell.
1642
1643 @see wxDataViewCustomRenderer::ActivateCell()
c4e57202
FM
1644 */
1645 wxDATAVIEW_CELL_ACTIVATABLE,
1646
1647 /**
dc73d7f5
VS
1648 Indicates that the user can edit the data in-place in an inline editor
1649 control that will show up when the user wants to edit the cell.
1650
1651 A typical example of this behaviour is changing the filename in a file
1652 managers.
1653
1654 Editing is typically triggered by slowly double-clicking the cell or by
1655 a platform-dependent keyboard shortcut (F2 is typical on Windows, Space
1656 and/or Enter is common elsewhere and supported on Windows too).
1657
1658 @see wxDataViewCustomRenderer::CreateEditorCtrl()
c4e57202
FM
1659 */
1660 wxDATAVIEW_CELL_EDITABLE
1661};
1662
1663/**
1664 The values of this enum controls how a wxDataViewRenderer should display
1665 its contents in a cell.
1666*/
1667enum wxDataViewCellRenderState
1668{
1669 wxDATAVIEW_CELL_SELECTED = 1,
1670 wxDATAVIEW_CELL_PRELIT = 2,
1671 wxDATAVIEW_CELL_INSENSITIVE = 4,
1672 wxDATAVIEW_CELL_FOCUSED = 8
1673};
e54c96f1 1674
23324ae1
FM
1675/**
1676 @class wxDataViewRenderer
7c913512 1677
5b99d5d8 1678 This class is used by wxDataViewCtrl to render the individual cells.
c4e57202
FM
1679 One instance of a renderer class is owned by a wxDataViewColumn.
1680 There is a number of ready-to-use renderers provided:
1681 - wxDataViewTextRenderer,
c4e57202
FM
1682 - wxDataViewIconTextRenderer,
1683 - wxDataViewToggleRenderer,
1684 - wxDataViewProgressRenderer,
1685 - wxDataViewBitmapRenderer,
1686 - wxDataViewDateRenderer,
1687 - wxDataViewSpinRenderer.
f4fcd648 1688 - wxDataViewChoiceRenderer.
7c913512 1689
4e15d1ca 1690 Additionally, the user can write their own renderers by deriving from
23324ae1 1691 wxDataViewCustomRenderer.
7c913512 1692
c4e57202
FM
1693 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1694 by the constructors respectively controls what actions the cell data allows
1695 and how the renderer should display its contents in a cell.
7c913512 1696
23324ae1 1697 @library{wxadv}
b321b61c 1698 @category{dvc}
23324ae1
FM
1699*/
1700class wxDataViewRenderer : public wxObject
1701{
1702public:
1703 /**
b91c4601 1704 Constructor.
23324ae1
FM
1705 */
1706 wxDataViewRenderer(const wxString& varianttype,
1707 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
f2b7492a 1708 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1 1709
c937bcac
VZ
1710 /**
1711 Enable or disable replacing parts of the item text with ellipsis to
1712 make it fit the column width.
1713
1714 This method only makes sense for the renderers working with text, such
1715 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1716
1717 By default wxELLIPSIZE_MIDDLE is used.
1718
1719 @param mode
1720 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1721
1722 @since 2.9.1
1723 */
1724 void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
1725
1726 /**
1727 Disable replacing parts of the item text with ellipsis.
1728
1729 If ellipsizing is disabled, the string will be truncated if it doesn't
1730 fit.
1731
1732 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1733
1734 @since 2.9.1
1735 */
1736 void DisableEllipsize();
1737
20c36737 1738 /**
f2b7492a 1739 Returns the alignment. See SetAlignment()
20c36737
RR
1740 */
1741 virtual int GetAlignment() const;
1742
c937bcac
VZ
1743 /**
1744 Returns the ellipsize mode used by the renderer.
1745
1746 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1747 if it doesn't fit.
1748
1749 @see EnableEllipsize()
1750 */
1751 wxEllipsizeMode GetEllipsizeMode() const;
1752
23324ae1
FM
1753 /**
1754 Returns the cell mode.
1755 */
adaaa686 1756 virtual wxDataViewCellMode GetMode() const;
23324ae1
FM
1757
1758 /**
1759 Returns pointer to the owning wxDataViewColumn.
1760 */
adaaa686 1761 wxDataViewColumn* GetOwner() const;
23324ae1
FM
1762
1763 /**
1764 This methods retrieves the value from the renderer in order to
c4e57202
FM
1765 transfer the value back to the data model.
1766
1767 Returns @false on failure.
23324ae1 1768 */
b91c4601 1769 virtual bool GetValue(wxVariant& value) const = 0;
23324ae1
FM
1770
1771 /**
c4e57202 1772 Returns a string with the type of the wxVariant supported by this renderer.
23324ae1 1773 */
adaaa686 1774 wxString GetVariantType() const;
23324ae1 1775
20c36737 1776 /**
c4e57202
FM
1777 Sets the alignment of the renderer's content.
1778 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1779 should have the same alignment as the column header.
1780
1781 The method is not implemented under OS X and the renderer always aligns
1782 its contents as the column header on that platform. The other platforms
f2b7492a 1783 support both vertical and horizontal alignment.
20c36737
RR
1784 */
1785 virtual void SetAlignment( int align );
23324ae1 1786 /**
c4e57202
FM
1787 Sets the owning wxDataViewColumn.
1788 This is usually called from within wxDataViewColumn.
23324ae1 1789 */
adaaa686 1790 void SetOwner(wxDataViewColumn* owner);
23324ae1
FM
1791
1792 /**
c4e57202 1793 Set the value of the renderer (and thus its cell) to @a value.
23324ae1
FM
1794 The internal code will then render this cell with this data.
1795 */
b91c4601 1796 virtual bool SetValue(const wxVariant& value) = 0;
23324ae1
FM
1797
1798 /**
1799 Before data is committed to the data model, it is passed to this
1800 method where it can be checked for validity. This can also be
1801 used for checking a valid range or limiting the user input in
1802 a certain aspect (e.g. max number of characters or only alphanumeric
c4e57202
FM
1803 input, ASCII only etc.). Return @false if the value is not valid.
1804
23324ae1
FM
1805 Please note that due to implementation limitations, this validation
1806 is done after the editing control already is destroyed and the
1807 editing process finished.
1808 */
1809 virtual bool Validate(wxVariant& value);
4e15d1ca
RD
1810
1811
1812 virtual bool HasEditorCtrl() const;
1813 virtual wxWindow* CreateEditorCtrl(wxWindow * parent,
1814 wxRect labelRect,
1815 const wxVariant& value);
1816 virtual bool GetValueFromEditorCtrl(wxWindow * editor,
1817 wxVariant& value);
1818 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1819 virtual void CancelEditing();
1820 virtual bool FinishEditing();
1821 wxWindow *GetEditorCtrl();
1822
1823protected:
1824 wxDataViewCtrl* GetView() const;
23324ae1
FM
1825};
1826
1827
e54c96f1 1828
23324ae1
FM
1829/**
1830 @class wxDataViewTextRenderer
7c913512 1831
c4e57202
FM
1832 wxDataViewTextRenderer is used for rendering text.
1833 It supports in-place editing if desired.
7c913512 1834
23324ae1 1835 @library{wxadv}
b321b61c 1836 @category{dvc}
23324ae1
FM
1837*/
1838class wxDataViewTextRenderer : public wxDataViewRenderer
1839{
1840public:
1841 /**
c4e57202 1842 The ctor.
23324ae1
FM
1843 */
1844 wxDataViewTextRenderer(const wxString& varianttype = "string",
05303ccd
RR
1845 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1846 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1847};
1848
1849
e54c96f1 1850
f2b7492a
RR
1851/**
1852 @class wxDataViewIconTextRenderer
f2b7492a
RR
1853
1854 The wxDataViewIconTextRenderer class is used to display text with
1855 a small icon next to it as it is typically done in a file manager.
c4e57202
FM
1856
1857 This classes uses the wxDataViewIconText helper class to store its data.
4d68a949
BP
1858 wxDataViewIconText can be converted to and from a wxVariant using the left
1859 shift operator.
f2b7492a
RR
1860
1861 @library{wxadv}
b321b61c 1862 @category{dvc}
f2b7492a
RR
1863*/
1864class wxDataViewIconTextRenderer : public wxDataViewRenderer
1865{
1866public:
1867 /**
c4e57202 1868 The ctor.
f2b7492a
RR
1869 */
1870 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
1871 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1872 int align = wxDVR_DEFAULT_ALIGNMENT );
1873};
1874
1875
1876
23324ae1
FM
1877/**
1878 @class wxDataViewProgressRenderer
7c913512 1879
c4e57202 1880 This class is used by wxDataViewCtrl to render progress bars.
7c913512 1881
23324ae1 1882 @library{wxadv}
b321b61c 1883 @category{dvc}
23324ae1
FM
1884*/
1885class wxDataViewProgressRenderer : public wxDataViewRenderer
1886{
1887public:
1888 /**
c4e57202 1889 The ctor.
23324ae1
FM
1890 */
1891 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1892 const wxString& varianttype = "long",
05303ccd
RR
1893 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1894 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1895};
1896
1897
e54c96f1 1898
23324ae1
FM
1899/**
1900 @class wxDataViewSpinRenderer
7c913512 1901
c4e57202
FM
1902 This is a specialized renderer for rendering integer values.
1903 It supports modifying the values in-place by using a wxSpinCtrl.
23324ae1 1904 The renderer only support variants of type @e long.
7c913512 1905
8ed522d9 1906 @library{wxadv}
b321b61c 1907 @category{dvc}
23324ae1
FM
1908*/
1909class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1910{
1911public:
1912 /**
c4e57202
FM
1913 Constructor.
1914 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
23324ae1
FM
1915 */
1916 wxDataViewSpinRenderer(int min, int max,
1917 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
05303ccd 1918 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1919};
1920
1921
e54c96f1 1922
23324ae1
FM
1923/**
1924 @class wxDataViewToggleRenderer
7c913512 1925
c4e57202 1926 This class is used by wxDataViewCtrl to render toggle controls.
7c913512 1927
23324ae1 1928 @library{wxadv}
b321b61c 1929 @category{dvc}
23324ae1
FM
1930*/
1931class wxDataViewToggleRenderer : public wxDataViewRenderer
1932{
1933public:
1934 /**
c4e57202 1935 The ctor.
23324ae1
FM
1936 */
1937 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
50ec54b6
FM
1938 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1939 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1940};
1941
1942
f4fcd648 1943/**
df8cd0bd
VZ
1944 A wxDataViewCtrl renderer using wxChoice control and values of strings in
1945 it.
f4fcd648
RR
1946
1947 This class is used by wxDataViewCtrl to render choice controls.
1948 It stores a string so that SetValue() and GetValue() operate
1949 on a variant holding a string.
1950
df8cd0bd
VZ
1951 @see wxDataViewChoiceByIndexRenderer
1952
f4fcd648
RR
1953 @library{wxadv}
1954 @category{dvc}
1955*/
1956
1957class wxDataViewChoiceRenderer: public wxDataViewRenderer
1958{
1959public:
1960 /**
1961 The ctor.
1962 */
1963 wxDataViewChoiceRenderer( const wxArrayString &choices,
1964 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1965 int alignment = wxDVR_DEFAULT_ALIGNMENT );
1966
1967 /**
1968 Returns the choice referred to by index.
1969 */
1970 wxString GetChoice(size_t index) const;
df8cd0bd 1971
f4fcd648
RR
1972 /**
1973 Returns all choices.
1974 */
1975 const wxArrayString& GetChoices() const;
1976};
1977
e54c96f1 1978
df8cd0bd
VZ
1979/**
1980 A wxDataViewCtrl renderer using wxChoice control and indexes into it.
1981
1982 Unlike its base wxDataViewChoiceRenderer class, this one stores the choice
1983 index, i.e. an @c int, in the variant used by its SetValue() and
1984 GetValue().
1985
1986 @library{wxadv}
1987 @category{dvc}
1988*/
1989class wxDataViewChoiceByIndexRenderer : public wxDataViewChoiceRenderer
1990{
1991public:
1992 /**
1993 The ctor.
1994 */
1995 wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
1996 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1997 int alignment = wxDVR_DEFAULT_ALIGNMENT );
1998};
1999
2000
23324ae1 2001/**
5b99d5d8 2002 @class wxDataViewDateRenderer
7c913512 2003
c4e57202 2004 This class is used by wxDataViewCtrl to render calendar controls.
7c913512 2005
5b99d5d8 2006 @library{wxadv}
b321b61c 2007 @category{dvc}
23324ae1 2008*/
5b99d5d8 2009class wxDataViewDateRenderer : public wxDataViewRenderer
23324ae1
FM
2010{
2011public:
23324ae1 2012 /**
c4e57202 2013 The ctor.
23324ae1 2014 */
5b99d5d8 2015 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
50ec54b6
FM
2016 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
2017 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8 2018};
23324ae1 2019
3c4f71cc 2020
23324ae1 2021
5b99d5d8
RR
2022/**
2023 @class wxDataViewCustomRenderer
23324ae1 2024
5b99d5d8 2025 You need to derive a new class from wxDataViewCustomRenderer in
c4e57202
FM
2026 order to write a new renderer.
2027
2028 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
2029 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
2030
2031 If you want your renderer to support in-place editing then you also need to override
2032 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
5b99d5d8 2033 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
c4e57202
FM
2034
2035 Note that a special event handler will be pushed onto that editor control
2036 which handles @e \<ENTER\> and focus out events in order to end the editing.
23324ae1 2037
5b99d5d8 2038 @library{wxadv}
b321b61c 2039 @category{dvc}
5b99d5d8
RR
2040*/
2041class wxDataViewCustomRenderer : public wxDataViewRenderer
2042{
2043public:
23324ae1 2044 /**
5b99d5d8 2045 Constructor.
23324ae1 2046 */
5b99d5d8
RR
2047 wxDataViewCustomRenderer(const wxString& varianttype = "string",
2048 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
4e15d1ca 2049 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
2050
2051 /**
5b99d5d8 2052 Destructor.
23324ae1 2053 */
adaaa686 2054 virtual ~wxDataViewCustomRenderer();
23324ae1 2055
23324ae1 2056 /**
dc73d7f5
VS
2057 Override this to react to cell @em activation. Activating a cell is an
2058 alternative to showing inline editor when the value can be edited in a
2059 simple way that doesn't warrant full editor control. The most typical
2060 use of cell activation is toggling the checkbox in
2061 wxDataViewToggleRenderer; others would be e.g. an embedded volume
2062 slider or a five-star rating column.
2063
2064 The exact means of activating a cell are platform-dependent, but they
2065 are usually similar to those used for inline editing of values.
2066 Typically, a cell would be activated by Space or Enter keys or by left
2067 mouse click.
2068
2069 This method will only be called if the cell has the
2070 wxDATAVIEW_CELL_ACTIVATABLE mode.
2071
2072 @param cell
2073 Coordinates of the activated cell's area.
2074 @param model
2075 The model to manipulate in response.
2076 @param item
2077 Activated item.
2078 @param col
2079 Activated column of @a item.
2080 @param mouseEvent
2081 If the activation was triggered by mouse click, contains the
2082 corresponding event. Is @NULL otherwise (for keyboard activation).
2083 Mouse coordinates are adjusted to be relative to the cell.
2084
2085 @since 2.9.3
2086
2087 @note Do not confuse this method with item activation in wxDataViewCtrl
2088 and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is
2089 used for activating the item (or, to put it differently, the
2090 entire row) similarly to analogous messages in wxTreeCtrl and
2091 wxListCtrl, and the effect differs (play a song, open a file
2092 etc.). Cell activation, on the other hand, is all about
2093 interacting with the individual cell.
2094
2095 @see CreateEditorCtrl()
23324ae1 2096 */
dc73d7f5
VS
2097 virtual bool ActivateCell(const wxRect& cell,
2098 wxDataViewModel* model,
2099 const wxDataViewItem & item,
2100 unsigned int col,
2101 const wxMouseEvent *mouseEvent);
23324ae1
FM
2102
2103 /**
5b99d5d8 2104 Override this to create the actual editor control once editing
c4e57202
FM
2105 is about to start.
2106
dc73d7f5
VS
2107 This method will only be called if the cell has the
2108 wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly
2109 double-clicking the cell or by a platform-dependent keyboard shortcut
2110 (F2 is typical on Windows, Space and/or Enter is common elsewhere and
2111 supported on Windows too).
2112
2113 @param parent
2114 The parent of the editor control.
2115 @param labelRect
2116 Indicates the position and size of the editor control. The control
2117 should be created in place of the cell and @a labelRect should be
2118 respected as much as possible.
2119 @param value
2120 Initial value of the editor.
2121
2122 An example:
c4e57202
FM
2123 @code
2124 {
2125 long l = value;
2126 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
2127 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
2128 }
2129 @endcode
dc73d7f5
VS
2130
2131 @see ActivateCell()
23324ae1 2132 */
64c70359
VS
2133 virtual wxWindow* CreateEditorCtrl(wxWindow* parent,
2134 wxRect labelRect,
2135 const wxVariant& value);
23324ae1
FM
2136
2137 /**
62265c2c
VZ
2138 Return the attribute to be used for rendering.
2139
2140 This function may be called from Render() implementation to use the
2141 attributes defined for the item if the renderer supports them.
2142
2143 Notice that when Render() is called, the wxDC object passed to it is
2144 already set up to use the correct attributes (e.g. its font is set to
2145 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
2146 returns true) so it may not be necessary to call it explicitly if you
2147 only want to render text using the items attributes.
2148
2149 @since 2.9.1
2150 */
2151 const wxDataViewItemAttr& GetAttr() const;
23324ae1
FM
2152
2153 /**
5b99d5d8 2154 Return size required to show content.
23324ae1 2155 */
b91c4601 2156 virtual wxSize GetSize() const = 0;
23324ae1
FM
2157
2158 /**
80093617 2159 Override this so that the renderer can get the value from the editor
c4e57202
FM
2160 control (pointed to by @a editor):
2161 @code
2162 {
2163 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
2164 long l = sc->GetValue();
2165 value = l;
2166 return true;
2167 }
2168 @endcode
23324ae1 2169 */
64c70359 2170 virtual bool GetValueFromEditorCtrl(wxWindow* editor,
5b99d5d8 2171 wxVariant& value);
23324ae1
FM
2172
2173 /**
c4e57202 2174 Override this and make it return @true in order to
5b99d5d8 2175 indicate that this renderer supports in-place editing.
23324ae1 2176 */
220bfe15 2177 virtual bool HasEditorCtrl() const;
23324ae1
FM
2178
2179 /**
1c103099
RD
2180 Override this to react to a left click. This method will only be
2181 called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. This method is
2182 deprecated, please use ActivateCell instead.
23324ae1 2183 */
1c103099
RD
2184 virtual bool LeftClick( wxPoint cursor,
2185 wxRect cell,
5b99d5d8
RR
2186 wxDataViewModel * model,
2187 const wxDataViewItem & item,
2188 unsigned int col );
23324ae1 2189
1c103099
RD
2190 /**
2191 Override this to react to the activation of a cell. This method is
2192 deprecated, please use ActivateCell instead.
2193 */
2194 virtual bool Activate(wxRect cell,
2195 wxDataViewModel * model,
2196 const wxDataViewItem & item,
2197 unsigned int col);
2198
2199
23324ae1 2200 /**
c4e57202
FM
2201 Override this to render the cell.
2202 Before this is called, wxDataViewRenderer::SetValue was called
5b99d5d8 2203 so that this instance knows what to render.
23324ae1 2204 */
b91c4601 2205 virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
23324ae1
FM
2206
2207 /**
c4e57202
FM
2208 This method should be called from within Render() whenever you need to
2209 render simple text.
2210 This will ensure that the correct colour, font and vertical alignment will
2211 be chosen so the text will look the same as text drawn by native renderers.
23324ae1 2212 */
50ec54b6 2213 void RenderText(const wxString& text, int xoffset, wxRect cell,
5b99d5d8 2214 wxDC* dc, int state);
23324ae1
FM
2215
2216 /**
80093617 2217 Override this to start a drag operation. Not yet supported.
23324ae1 2218 */
548fa9c1
VS
2219 virtual bool StartDrag(const wxPoint& cursor,
2220 const wxRect& cell,
5b99d5d8
RR
2221 wxDataViewModel* model,
2222 const wxDataViewItem & item,
2223 unsigned int col);
4e15d1ca
RD
2224
2225protected:
2226 /**
2227 Helper for GetSize() implementations, respects attributes.
2228 */
2229 wxSize GetTextExtent(const wxString& str) const;
23324ae1
FM
2230};
2231
2232
e54c96f1 2233
23324ae1 2234/**
5b99d5d8 2235 @class wxDataViewBitmapRenderer
7c913512 2236
c4e57202 2237 This class is used by wxDataViewCtrl to render bitmap controls.
7c913512 2238
23324ae1 2239 @library{wxadv}
b321b61c 2240 @category{dvc}
23324ae1 2241*/
5b99d5d8 2242class wxDataViewBitmapRenderer : public wxDataViewRenderer
23324ae1
FM
2243{
2244public:
2245 /**
c4e57202 2246 The ctor.
23324ae1 2247 */
5b99d5d8
RR
2248 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
2249 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
14d922d1 2250 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8
RR
2251};
2252
23324ae1 2253
c4e57202
FM
2254/**
2255 The flags used by wxDataViewColumn.
02b51ae5 2256 Can be combined together.
c4e57202
FM
2257*/
2258enum wxDataViewColumnFlags
2259{
2260 wxDATAVIEW_COL_RESIZABLE = 1,
2261 wxDATAVIEW_COL_SORTABLE = 2,
2262 wxDATAVIEW_COL_REORDERABLE = 4,
2263 wxDATAVIEW_COL_HIDDEN = 8
2264};
23324ae1 2265
5b99d5d8
RR
2266/**
2267 @class wxDataViewColumn
5b99d5d8
RR
2268
2269 This class represents a column in a wxDataViewCtrl.
739a8399 2270 One wxDataViewColumn is bound to one column in the data model to which the
c4e57202 2271 wxDataViewCtrl has been associated.
5b99d5d8 2272
c4e57202 2273 An instance of wxDataViewRenderer is used by this class to render its data.
5b99d5d8
RR
2274
2275 @library{wxadv}
b321b61c 2276 @category{dvc}
5b99d5d8 2277*/
c9c59db7 2278class wxDataViewColumn : public wxSettableHeaderColumn
5b99d5d8
RR
2279{
2280public:
23324ae1 2281 /**
02b51ae5
FM
2282 Constructs a text column.
2283
2284 @param title
2285 The title of the column.
2286 @param renderer
2287 The class which will render the contents of this column.
2288 @param model_column
2289 The index of the model's column which is associated with this object.
2290 @param width
2291 The width of the column.
2292 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2293 @param align
2294 The alignment of the column title.
2295 @param flags
2296 One or more flags of the ::wxDataViewColumnFlags enumeration.
23324ae1 2297 */
5b99d5d8
RR
2298 wxDataViewColumn(const wxString& title,
2299 wxDataViewRenderer* renderer,
2300 unsigned int model_column,
2301 int width = wxDVC_DEFAULT_WIDTH,
882678eb 2302 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 2303 int flags = wxDATAVIEW_COL_RESIZABLE);
02b51ae5
FM
2304
2305 /**
2306 Constructs a bitmap column.
2307
2308 @param bitmap
2309 The bitmap of the column.
2310 @param renderer
2311 The class which will render the contents of this column.
2312 @param model_column
2313 The index of the model's column which is associated with this object.
2314 @param width
2315 The width of the column.
2316 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2317 @param align
2318 The alignment of the column title.
2319 @param flags
2320 One or more flags of the ::wxDataViewColumnFlags enumeration.
2321 */
5b99d5d8
RR
2322 wxDataViewColumn(const wxBitmap& bitmap,
2323 wxDataViewRenderer* renderer,
2324 unsigned int model_column,
2325 int width = wxDVC_DEFAULT_WIDTH,
882678eb 2326 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 2327 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1 2328
23324ae1 2329 /**
5b99d5d8
RR
2330 Returns the index of the column of the model, which this
2331 wxDataViewColumn is displaying.
23324ae1 2332 */
adaaa686 2333 unsigned int GetModelColumn() const;
23324ae1
FM
2334
2335 /**
5b99d5d8 2336 Returns the owning wxDataViewCtrl.
23324ae1 2337 */
e51bf699 2338 wxDataViewCtrl* GetOwner() const;
23324ae1
FM
2339
2340 /**
5b99d5d8 2341 Returns the renderer of this wxDataViewColumn.
c4e57202
FM
2342
2343 @see wxDataViewRenderer.
23324ae1 2344 */
adaaa686 2345 wxDataViewRenderer* GetRenderer() const;
23324ae1
FM
2346};
2347
2348
e54c96f1 2349
832df171
RR
2350/**
2351 @class wxDataViewListCtrl
2352
2353 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
2354 and forwards most of its API to that class.
2355
2356 The purpose of this class is to offer a simple way to display and
2357 edit a small table of data without having to write your own wxDataViewModel.
2358
23efa4bf 2359 @code
14f73cf1 2360 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
02b51ae5 2361
95b20f41
RR
2362 listctrl->AppendToggleColumn( "Toggle" );
2363 listctrl->AppendTextColumn( "Text" );
02b51ae5 2364
23efa4bf 2365 wxVector<wxVariant> data;
14f73cf1
FM
2366 data.push_back( wxVariant(true) );
2367 data.push_back( wxVariant("row 1") );
23efa4bf 2368 listctrl->AppendItem( data );
02b51ae5 2369
23efa4bf 2370 data.clear();
14f73cf1
FM
2371 data.push_back( wxVariant(false) );
2372 data.push_back( wxVariant("row 3") );
23efa4bf
RR
2373 listctrl->AppendItem( data );
2374 @endcode
43c64cc6 2375
14f73cf1
FM
2376 @beginStyleTable
2377 See wxDataViewCtrl for the list of supported styles.
2378 @endStyleTable
43c64cc6 2379
14f73cf1
FM
2380 @beginEventEmissionTable
2381 See wxDataViewCtrl for the list of events emitted by this class.
2382 @endEventTable
23efa4bf 2383
832df171
RR
2384 @library{wxadv}
2385 @category{ctrl,dvc}
2386*/
832df171
RR
2387class wxDataViewListCtrl: public wxDataViewCtrl
2388{
b75b04d4 2389public:
832df171
RR
2390 /**
2391 Default ctor.
2392 */
2393 wxDataViewListCtrl();
02b51ae5 2394
832df171
RR
2395 /**
2396 Constructor. Calls Create().
2397 */
2398 wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
2399 const wxPoint& pos = wxDefaultPosition,
2400 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
2401 const wxValidator& validator = wxDefaultValidator );
02b51ae5 2402
832df171
RR
2403 /**
2404 Destructor. Deletes the image list if any.
2405 */
2406 ~wxDataViewListCtrl();
2407
2408 /**
2409 Creates the control and a wxDataViewListStore as its internal model.
2410 */
2411 bool Create( wxWindow *parent, wxWindowID id,
2412 const wxPoint& pos = wxDefaultPosition,
2413 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
2414 const wxValidator& validator = wxDefaultValidator );
2415
2416 //@{
2417 /**
2418 Returns the store.
2419 */
2420 wxDataViewListStore *GetStore();
2421 const wxDataViewListStore *GetStore() const;
2422 //@}
2423
17de95e4
VS
2424 /**
2425 Returns the position of given @e item or wxNOT_FOUND if it's
2426 not a valid item.
2427
2428 @since 2.9.2
2429 */
2430 int ItemToRow(const wxDataViewItem &item) const;
2431
2432 /**
2433 Returns the wxDataViewItem at the given @e row.
2434
2435 @since 2.9.2
2436 */
2437 wxDataViewItem RowToItem(int row) const;
2438
fa629ada
VS
2439 //@{
2440 /**
2441 @name Selection handling functions
2442 */
2443
2444 /**
2445 Returns index of the selected row or wxNOT_FOUND.
2446
2447 @see wxDataViewCtrl::GetSelection()
2448
2449 @since 2.9.2
2450 */
2451 int GetSelectedRow() const;
2452
2453 /**
2454 Selects given row.
2455
2456 @see wxDataViewCtrl::Select()
2457
2458 @since 2.9.2
2459 */
2460 void SelectRow(unsigned row);
2461
2462 /**
2463 Unselects given row.
2464
2465 @see wxDataViewCtrl::Unselect()
2466
2467 @since 2.9.2
2468 */
2469 void UnselectRow(unsigned row);
2470
2471 /**
2472 Returns true if @a row is selected.
2473
2474 @see wxDataViewCtrl::IsSelected()
2475
2476 @since 2.9.2
2477 */
2478 bool IsRowSelected(unsigned row) const;
2479
2480 //@}
2481
832df171 2482 /**
14f73cf1
FM
2483 @name Column management functions
2484 */
2485 //@{
43c64cc6 2486
14f73cf1
FM
2487 /**
2488 Appends a column to the control and additionally appends a
2489 column to the store with the type string.
2490 */
2ccd2adc 2491 virtual bool AppendColumn( wxDataViewColumn *column );
14f73cf1
FM
2492
2493 /**
2494 Appends a column to the control and additionally appends a
2495 column to the list store with the type @a varianttype.
832df171 2496 */
95b20f41 2497 void AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 2498
832df171 2499 /**
14f73cf1 2500 Appends a text column to the control and the store.
43c64cc6 2501
14f73cf1
FM
2502 See wxDataViewColumn::wxDataViewColumn for more info about
2503 the parameters.
832df171 2504 */
14f73cf1
FM
2505 wxDataViewColumn *AppendTextColumn( const wxString &label,
2506 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2507 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2508 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2509
832df171 2510 /**
14f73cf1 2511 Appends a toggle column to the control and the store.
43c64cc6 2512
14f73cf1
FM
2513 See wxDataViewColumn::wxDataViewColumn for more info about
2514 the parameters.
832df171 2515 */
14f73cf1
FM
2516 wxDataViewColumn *AppendToggleColumn( const wxString &label,
2517 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
43c64cc6 2518 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2519 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2520
95b20f41 2521 /**
14f73cf1 2522 Appends a progress column to the control and the store.
02b51ae5 2523
14f73cf1
FM
2524 See wxDataViewColumn::wxDataViewColumn for more info about
2525 the parameters.
95b20f41 2526 */
14f73cf1
FM
2527 wxDataViewColumn *AppendProgressColumn( const wxString &label,
2528 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2529 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2530 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2531
95b20f41 2532 /**
14f73cf1 2533 Appends an icon-and-text column to the control and the store.
02b51ae5 2534
14f73cf1
FM
2535 See wxDataViewColumn::wxDataViewColumn for more info about
2536 the parameters.
95b20f41 2537 */
14f73cf1
FM
2538 wxDataViewColumn *AppendIconTextColumn( const wxString &label,
2539 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2540 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2541 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2542
95b20f41 2543 /**
14f73cf1 2544 Inserts a column to the control and additionally inserts a
95b20f41
RR
2545 column to the store with the type string.
2546 */
2ccd2adc 2547 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *column );
02b51ae5 2548
832df171 2549 /**
14f73cf1
FM
2550 Inserts a column to the control and additionally inserts a
2551 column to the list store with the type @a varianttype.
832df171 2552 */
43c64cc6 2553 void InsertColumn( unsigned int pos, wxDataViewColumn *column,
14f73cf1 2554 const wxString &varianttype );
02b51ae5 2555
832df171 2556 /**
14f73cf1
FM
2557 Prepends a column to the control and additionally prepends a
2558 column to the store with the type string.
832df171 2559 */
2ccd2adc 2560 virtual bool PrependColumn( wxDataViewColumn *column );
02b51ae5 2561
832df171 2562 /**
14f73cf1
FM
2563 Prepends a column to the control and additionally prepends a
2564 column to the list store with the type @a varianttype.
832df171 2565 */
14f73cf1 2566 void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 2567
14f73cf1 2568 //@}
43c64cc6
VZ
2569
2570
832df171 2571 /**
14f73cf1 2572 @name Item management functions
832df171 2573 */
14f73cf1 2574 //@{
43c64cc6 2575
832df171
RR
2576 /**
2577 Appends an item (=row) to the control and store.
2578 */
41abc29a 2579 void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
832df171
RR
2580
2581 /**
2582 Prepends an item (=row) to the control and store.
2583 */
41abc29a 2584 void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
832df171
RR
2585
2586 /**
2587 Inserts an item (=row) to the control and store.
2588 */
41abc29a 2589 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2590
832df171
RR
2591 /**
2592 Delete the row at position @a row.
2593 */
2594 void DeleteItem( unsigned row );
02b51ae5 2595
832df171
RR
2596 /**
2597 Delete all items (= all rows).
2598 */
2599 void DeleteAllItems();
02b51ae5 2600
5fb4b6cd
VZ
2601 /**
2602 Returns the number of items (=rows) in the control
2603
2604 @since 2.9.4
2605 */
2606 unsigned int GetItemCount() const;
2607
518cef04
VZ
2608 /**
2609 Returns the client data associated with the item.
2610
2611 @see SetItemData()
2612
2613 @since 2.9.4
2614 */
2615 wxUIntPtr GetItemData(const wxDataViewItem& item) const;
2616
832df171
RR
2617 /**
2618 Sets the value in the store and update the control.
2619 */
2620 void SetValue( const wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 2621
832df171
RR
2622 /**
2623 Returns the value from the store.
2624 */
2625 void GetValue( wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 2626
832df171 2627 /**
02b51ae5
FM
2628 Sets the value in the store and update the control.
2629
57ab6f23 2630 This method assumes that the string is stored in respective
832df171
RR
2631 column.
2632 */
2633 void SetTextValue( const wxString &value, unsigned int row, unsigned int col );
02b51ae5 2634
832df171
RR
2635 /**
2636 Returns the value from the store.
02b51ae5 2637
57ab6f23 2638 This method assumes that the string is stored in respective
832df171
RR
2639 column.
2640 */
2641 wxString GetTextValue( unsigned int row, unsigned int col ) const;
02b51ae5 2642
832df171 2643 /**
02b51ae5
FM
2644 Sets the value in the store and update the control.
2645
57ab6f23 2646 This method assumes that the boolean value is stored in
832df171
RR
2647 respective column.
2648 */
2649 void SetToggleValue( bool value, unsigned int row, unsigned int col );
02b51ae5 2650
832df171
RR
2651 /**
2652 Returns the value from the store.
02b51ae5 2653
57ab6f23 2654 This method assumes that the boolean value is stored in
832df171
RR
2655 respective column.
2656 */
2657 bool GetToggleValue( unsigned int row, unsigned int col ) const;
43c64cc6 2658
518cef04
VZ
2659 /**
2660 Associates a client data pointer with the given item.
2661
2662 Notice that the control does @e not take ownership of the pointer for
2663 compatibility with wxListCtrl. I.e. it will @e not delete the pointer
2664 (if it is a pointer and not a number) itself, it is up to you to do it.
2665
2666 @see GetItemData()
2667
2668 @since 2.9.4
2669 */
2670 void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
2671
14f73cf1 2672 //@}
832df171
RR
2673};
2674
2675
23324ae1 2676/**
5b99d5d8 2677 @class wxDataViewTreeCtrl
7c913512 2678
c4e57202
FM
2679 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
2680 and forwards most of its API to that class.
2681 Additionally, it uses a wxImageList to store a list of icons.
2682
43c64cc6
VZ
2683 The main purpose of this class is to provide a simple upgrade path for code
2684 using wxTreeCtrl.
14f73cf1
FM
2685
2686 @beginStyleTable
2687 See wxDataViewCtrl for the list of supported styles.
2688 @endStyleTable
43c64cc6 2689
14f73cf1
FM
2690 @beginEventEmissionTable
2691 See wxDataViewCtrl for the list of events emitted by this class.
2692 @endEventTable
7c913512 2693
8ed522d9 2694 @library{wxadv}
b321b61c 2695 @category{ctrl,dvc}
ce154616 2696 @appearance{dataviewtreectrl}
23324ae1 2697*/
5b99d5d8 2698class wxDataViewTreeCtrl : public wxDataViewCtrl
23324ae1
FM
2699{
2700public:
2701 /**
c4e57202 2702 Default ctor.
5b99d5d8
RR
2703 */
2704 wxDataViewTreeCtrl();
c4e57202
FM
2705
2706 /**
43c64cc6
VZ
2707 Constructor.
2708
2709 Calls Create().
c4e57202 2710 */
5b99d5d8
RR
2711 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
2712 const wxPoint& pos = wxDefaultPosition,
2713 const wxSize& size = wxDefaultSize,
43c64cc6 2714 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
5b99d5d8 2715 const wxValidator& validator = wxDefaultValidator);
3c4f71cc 2716
5b99d5d8
RR
2717 /**
2718 Destructor. Deletes the image list if any.
23324ae1 2719 */
adaaa686 2720 virtual ~wxDataViewTreeCtrl();
23324ae1 2721
5b99d5d8 2722 /**
b75b04d4 2723 Appends a container to the given @a parent.
5b99d5d8
RR
2724 */
2725 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
2726 const wxString& text,
2727 int icon = -1,
2728 int expanded = -1,
2729 wxClientData* data = NULL);
e54c96f1 2730
5b99d5d8 2731 /**
b75b04d4 2732 Appends an item to the given @a parent.
5b99d5d8
RR
2733 */
2734 wxDataViewItem AppendItem(const wxDataViewItem& parent,
2735 const wxString& text,
2736 int icon = -1,
2737 wxClientData* data = NULL);
7c913512 2738
5b99d5d8 2739 /**
c4e57202 2740 Creates the control and a wxDataViewTreeStore as its internal model.
43c64cc6
VZ
2741
2742 The default tree column created by this method is an editable column
2743 using wxDataViewIconTextRenderer as its renderer.
5b99d5d8
RR
2744 */
2745 bool Create(wxWindow* parent, wxWindowID id,
2746 const wxPoint& pos = wxDefaultPosition,
2747 const wxSize& size = wxDefaultSize,
43c64cc6 2748 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
5b99d5d8
RR
2749 const wxValidator& validator = wxDefaultValidator);
2750
2751 /**
2752 Calls the identical method from wxDataViewTreeStore.
2753 */
2754 void DeleteAllItems();
7c913512 2755
23324ae1 2756 /**
5b99d5d8
RR
2757 Calls the identical method from wxDataViewTreeStore.
2758 */
2759 void DeleteChildren(const wxDataViewItem& item);
3c4f71cc 2760
5b99d5d8
RR
2761 /**
2762 Calls the identical method from wxDataViewTreeStore.
23324ae1 2763 */
5b99d5d8 2764 void DeleteItem(const wxDataViewItem& item);
23324ae1 2765
5b99d5d8
RR
2766 /**
2767 Calls the identical method from wxDataViewTreeStore.
2768 */
2769 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1 2770
5b99d5d8
RR
2771 /**
2772 Returns the image list.
2773 */
2774 wxImageList* GetImageList();
05303ccd 2775
5b99d5d8
RR
2776 /**
2777 Calls the identical method from wxDataViewTreeStore.
2778 */
2779 wxClientData* GetItemData(const wxDataViewItem& item) const;
05303ccd 2780
5b99d5d8
RR
2781 /**
2782 Calls the identical method from wxDataViewTreeStore.
2783 */
b91c4601 2784 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
05303ccd 2785
05303ccd 2786 /**
5b99d5d8 2787 Calls the identical method from wxDataViewTreeStore.
05303ccd 2788 */
b91c4601 2789 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
05303ccd
RR
2790
2791 /**
5b99d5d8 2792 Calls the identical method from wxDataViewTreeStore.
05303ccd 2793 */
5b99d5d8
RR
2794 wxString GetItemText(const wxDataViewItem& item) const;
2795
2796 /**
2797 Calls the identical method from wxDataViewTreeStore.
2798 */
2799 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
2800 unsigned int pos) const;
05303ccd 2801
5b99d5d8 2802 //@{
05303ccd 2803 /**
5b99d5d8 2804 Returns the store.
05303ccd 2805 */
882678eb 2806 wxDataViewTreeStore* GetStore();
5b99d5d8
RR
2807 const wxDataViewTreeStore* GetStore() const;
2808 //@}
05303ccd
RR
2809
2810 /**
c4e57202
FM
2811 Calls the same method from wxDataViewTreeStore but uses
2812 an index position in the image list instead of a wxIcon.
05303ccd 2813 */
5b99d5d8
RR
2814 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
2815 const wxDataViewItem& previous,
2816 const wxString& text,
2817 int icon = -1,
2818 int expanded = -1,
2819 wxClientData* data = NULL);
05303ccd
RR
2820
2821 /**
c4e57202
FM
2822 Calls the same method from wxDataViewTreeStore but uses
2823 an index position in the image list instead of a wxIcon.
05303ccd 2824 */
5b99d5d8
RR
2825 wxDataViewItem InsertItem(const wxDataViewItem& parent,
2826 const wxDataViewItem& previous,
2827 const wxString& text,
2828 int icon = -1,
2829 wxClientData* data = NULL);
05303ccd 2830
8ddda15b
RR
2831 /**
2832 Returns true if item is a container.
2833 */
2834 bool IsContainer( const wxDataViewItem& item );
2835
05303ccd 2836 /**
c4e57202
FM
2837 Calls the same method from wxDataViewTreeStore but uses
2838 an index position in the image list instead of a wxIcon.
05303ccd 2839 */
5b99d5d8
RR
2840 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
2841 const wxString& text,
2842 int icon = -1,
2843 int expanded = -1,
2844 wxClientData* data = NULL);
05303ccd
RR
2845
2846 /**
c4e57202
FM
2847 Calls the same method from wxDataViewTreeStore but uses
2848 an index position in the image list instead of a wxIcon.
05303ccd 2849 */
5b99d5d8
RR
2850 wxDataViewItem PrependItem(const wxDataViewItem& parent,
2851 const wxString& text,
2852 int icon = -1,
2853 wxClientData* data = NULL);
05303ccd
RR
2854
2855 /**
5b99d5d8 2856 Sets the image list.
05303ccd 2857 */
5b99d5d8 2858 void SetImageList(wxImageList* imagelist);
05303ccd
RR
2859
2860 /**
5b99d5d8 2861 Calls the identical method from wxDataViewTreeStore.
05303ccd 2862 */
5b99d5d8 2863 void SetItemData(const wxDataViewItem& item, wxClientData* data);
05303ccd
RR
2864
2865 /**
5b99d5d8 2866 Calls the identical method from wxDataViewTreeStore.
05303ccd 2867 */
5b99d5d8
RR
2868 void SetItemExpandedIcon(const wxDataViewItem& item,
2869 const wxIcon& icon);
05303ccd
RR
2870
2871 /**
5b99d5d8 2872 Calls the identical method from wxDataViewTreeStore.
05303ccd 2873 */
5b99d5d8 2874 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
05303ccd
RR
2875
2876 /**
5b99d5d8 2877 Calls the identical method from wxDataViewTreeStore.
05303ccd 2878 */
5b99d5d8
RR
2879 void SetItemText(const wxDataViewItem& item,
2880 const wxString& text);
05303ccd
RR
2881};
2882
2883
bda698ed
RR
2884/**
2885 @class wxDataViewListStore
2886
2887 wxDataViewListStore is a specialised wxDataViewModel for storing
2888 a simple table of data. Since it derives from wxDataViewIndexListModel
2889 its data is be accessed by row (i.e. by index) instead of only
2890 by wxDataViewItem.
2891
02b51ae5 2892 This class actually stores the values (therefore its name)
bda698ed 2893 and implements all virtual methods from the base classes so it can be
02b51ae5 2894 used directly without having to derive any class from it, but it is
bda698ed
RR
2895 mostly used from within wxDataViewListCtrl.
2896
2897 @library{wxadv}
2898 @category{dvc}
2899*/
2900
2901class wxDataViewListStore: public wxDataViewIndexListModel
2902{
2903public:
2904 /**
02b51ae5 2905 Constructor
bda698ed
RR
2906 */
2907 wxDataViewListStore();
02b51ae5 2908
bda698ed 2909 /**
02b51ae5 2910 Destructor
bda698ed
RR
2911 */
2912 ~wxDataViewListStore();
2913
2914 /**
02b51ae5
FM
2915 Prepends a data column.
2916
2917 @a variantype indicates the type of values store in the column.
2918
2919 This does not automatically fill in any (default) values in
2920 rows which exist in the store already.
bda698ed
RR
2921 */
2922 void PrependColumn( const wxString &varianttype );
2923
2924 /**
02b51ae5
FM
2925 Inserts a data column before @a pos.
2926
2927 @a variantype indicates the type of values store in the column.
2928
2929 This does not automatically fill in any (default) values in
2930 rows which exist in the store already.
bda698ed
RR
2931 */
2932 void InsertColumn( unsigned int pos, const wxString &varianttype );
2933
2934 /**
02b51ae5
FM
2935 Appends a data column.
2936
2937 @a variantype indicates the type of values store in the column.
2938
2939 This does not automatically fill in any (default) values in
2940 rows which exist in the store already.
bda698ed
RR
2941 */
2942 void AppendColumn( const wxString &varianttype );
02b51ae5 2943
bda698ed
RR
2944 /**
2945 Appends an item (=row) and fills it with @a values.
02b51ae5 2946
bda698ed
RR
2947 The values must match the values specifies in the column
2948 in number and type. No (default) values are filled in
2949 automatically.
2950 */
41abc29a 2951 void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2952
bda698ed
RR
2953 /**
2954 Prepends an item (=row) and fills it with @a values.
02b51ae5 2955
bda698ed
RR
2956 The values must match the values specifies in the column
2957 in number and type. No (default) values are filled in
2958 automatically.
2959 */
41abc29a 2960 void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2961
bda698ed
RR
2962 /**
2963 Inserts an item (=row) and fills it with @a values.
02b51ae5 2964
bda698ed
RR
2965 The values must match the values specifies in the column
2966 in number and type. No (default) values are filled in
2967 automatically.
2968 */
41abc29a 2969 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2970
bda698ed
RR
2971 /**
2972 Delete the item (=row) at position @a pos.
2973 */
2974 void DeleteItem( unsigned pos );
02b51ae5 2975
bda698ed
RR
2976 /**
2977 Delete all item (=all rows) in the store.
2978 */
2979 void DeleteAllItems();
2980
5fb4b6cd
VZ
2981 /**
2982 Returns the number of items (=rows) in the control
2983
2984 @since 2.9.4
2985 */
2986 unsigned int GetItemCount() const;
2987
518cef04
VZ
2988 /**
2989 Returns the client data associated with the item.
2990
2991 @see SetItemData()
2992
2993 @since 2.9.4
2994 */
2995 wxUIntPtr GetItemData(const wxDataViewItem& item) const;
2996
bda698ed 2997 /**
57ab6f23 2998 Overridden from wxDataViewModel
bda698ed
RR
2999 */
3000 virtual unsigned int GetColumnCount() const;
3001
3002 /**
57ab6f23 3003 Overridden from wxDataViewModel
bda698ed
RR
3004 */
3005 virtual wxString GetColumnType( unsigned int col ) const;
3006
518cef04
VZ
3007 /**
3008 Sets the client data associated with the item.
3009
3010 Notice that this class does @e not take ownership of the passed in
3011 pointer and will not delete it.
3012
3013 @see GetItemData()
3014
3015 @since 2.9.4
3016 */
3017 void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
3018
bda698ed 3019 /**
57ab6f23 3020 Overridden from wxDataViewIndexListModel
bda698ed
RR
3021 */
3022 virtual void GetValueByRow( wxVariant &value,
3023 unsigned int row, unsigned int col ) const;
3024
3025 /**
57ab6f23 3026 Overridden from wxDataViewIndexListModel
bda698ed
RR
3027 */
3028 virtual bool SetValueByRow( const wxVariant &value,
3029 unsigned int row, unsigned int col );
3030};
3031
05303ccd
RR
3032
3033/**
5b99d5d8 3034 @class wxDataViewTreeStore
05303ccd 3035
57ab6f23 3036 wxDataViewTreeStore is a specialised wxDataViewModel for storing simple
c4e57202
FM
3037 trees very much like wxTreeCtrl does and it offers a similar API.
3038
02b51ae5 3039 This class actually stores the entire tree and the values (therefore its name)
8eff6c56 3040 and implements all virtual methods from the base class so it can be used directly
bda698ed
RR
3041 without having to derive any class from it, but it is mostly used from within
3042 wxDataViewTreeCtrl.
05303ccd
RR
3043
3044 @library{wxadv}
b321b61c 3045 @category{dvc}
05303ccd 3046*/
5b99d5d8 3047class wxDataViewTreeStore : public wxDataViewModel
05303ccd
RR
3048{
3049public:
3050 /**
5b99d5d8 3051 Constructor. Creates the invisible root node internally.
05303ccd 3052 */
5b99d5d8 3053 wxDataViewTreeStore();
e54c96f1 3054
5b99d5d8
RR
3055 /**
3056 Destructor.
3057 */
adaaa686 3058 virtual ~wxDataViewTreeStore();
7c913512 3059
5b99d5d8
RR
3060 /**
3061 Append a container.
3062 */
3063 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
3064 const wxString& text,
3065 const wxIcon& icon = wxNullIcon,
3066 const wxIcon& expanded = wxNullIcon,
3067 wxClientData* data = NULL);
7c913512 3068
5b99d5d8
RR
3069 /**
3070 Append an item.
3071 */
3072 wxDataViewItem AppendItem(const wxDataViewItem& parent,
3073 const wxString& text,
3074 const wxIcon& icon = wxNullIcon,
3075 wxClientData* data = NULL);
7c913512 3076
23324ae1 3077 /**
5b99d5d8 3078 Delete all item in the model.
23324ae1 3079 */
5b99d5d8 3080 void DeleteAllItems();
23324ae1
FM
3081
3082 /**
5b99d5d8 3083 Delete all children of the item, but not the item itself.
23324ae1 3084 */
5b99d5d8 3085 void DeleteChildren(const wxDataViewItem& item);
23324ae1
FM
3086
3087 /**
5b99d5d8 3088 Delete this item.
23324ae1 3089 */
5b99d5d8 3090 void DeleteItem(const wxDataViewItem& item);
23324ae1
FM
3091
3092 /**
5b99d5d8 3093 Return the number of children of item.
23324ae1 3094 */
5b99d5d8 3095 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1
FM
3096
3097 /**
57ab6f23 3098 Returns the client data associated with the item.
23324ae1 3099 */
5b99d5d8 3100 wxClientData* GetItemData(const wxDataViewItem& item) const;
23324ae1
FM
3101
3102 /**
5b99d5d8 3103 Returns the icon to display in expanded containers.
23324ae1 3104 */
b91c4601 3105 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
23324ae1
FM
3106
3107 /**
5b99d5d8 3108 Returns the icon of the item.
23324ae1 3109 */
b91c4601 3110 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
23324ae1
FM
3111
3112 /**
5b99d5d8 3113 Returns the text of the item.
23324ae1 3114 */
5b99d5d8 3115 wxString GetItemText(const wxDataViewItem& item) const;
23324ae1
FM
3116
3117 /**
5b99d5d8 3118 Returns the nth child item of item.
23324ae1 3119 */
5b99d5d8
RR
3120 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
3121 unsigned int pos) const;
23324ae1
FM
3122
3123 /**
c4e57202 3124 Inserts a container after @a previous.
23324ae1 3125 */
5b99d5d8
RR
3126 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
3127 const wxDataViewItem& previous,
3128 const wxString& text,
3129 const wxIcon& icon = wxNullIcon,
3130 const wxIcon& expanded = wxNullIcon,
3131 wxClientData* data = NULL);
23324ae1
FM
3132
3133 /**
c4e57202 3134 Inserts an item after @a previous.
23324ae1 3135 */
5b99d5d8
RR
3136 wxDataViewItem InsertItem(const wxDataViewItem& parent,
3137 const wxDataViewItem& previous,
3138 const wxString& text,
3139 const wxIcon& icon = wxNullIcon,
3140 wxClientData* data = NULL);
23324ae1
FM
3141
3142 /**
c4e57202 3143 Inserts a container before the first child item or @a parent.
23324ae1 3144 */
5b99d5d8
RR
3145 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
3146 const wxString& text,
3147 const wxIcon& icon = wxNullIcon,
3148 const wxIcon& expanded = wxNullIcon,
3149 wxClientData* data = NULL);
23324ae1
FM
3150
3151 /**
c4e57202 3152 Inserts an item before the first child item or @a parent.
23324ae1 3153 */
5b99d5d8
RR
3154 wxDataViewItem PrependItem(const wxDataViewItem& parent,
3155 const wxString& text,
3156 const wxIcon& icon = wxNullIcon,
3157 wxClientData* data = NULL);
23324ae1
FM
3158
3159 /**
5b99d5d8 3160 Sets the client data associated with the item.
23324ae1 3161 */
5b99d5d8 3162 void SetItemData(const wxDataViewItem& item, wxClientData* data);
23324ae1
FM
3163
3164 /**
5b99d5d8 3165 Sets the expanded icon for the item.
23324ae1 3166 */
5b99d5d8
RR
3167 void SetItemExpandedIcon(const wxDataViewItem& item,
3168 const wxIcon& icon);
23324ae1
FM
3169
3170 /**
5b99d5d8 3171 Sets the icon for the item.
23324ae1 3172 */
5b99d5d8 3173 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
23324ae1 3174};
e54c96f1 3175
80932a3e
FM
3176
3177/**
3178 @class wxDataViewIconText
3179
3180 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
3181 This class can be converted to and from a wxVariant.
3182
3183 @library{wxadv}
3184 @category{dvc}
3185*/
3186class wxDataViewIconText : public wxObject
3187{
3188public:
3189 //@{
3190 /**
3191 Constructor.
3192 */
3193 wxDataViewIconText(const wxString& text = wxEmptyString,
3194 const wxIcon& icon = wxNullIcon);
3195 wxDataViewIconText(const wxDataViewIconText& other);
3196 //@}
3197
3198 /**
3199 Gets the icon.
3200 */
3201 const wxIcon& GetIcon() const;
3202
3203 /**
3204 Gets the text.
3205 */
3206 wxString GetText() const;
3207
3208 /**
3209 Set the icon.
3210 */
3211 void SetIcon(const wxIcon& icon);
3212
3213 /**
3214 Set the text.
3215 */
3216 void SetText(const wxString& text);
3217};
3218
3219
3220
3221/**
3222 @class wxDataViewEvent
3223
3224 This is the event class for the wxDataViewCtrl notifications.
3225
14f73cf1
FM
3226 @beginEventTable{wxDataViewEvent}
3227 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
3228 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
3229 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
3230 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
3231 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
3232 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
3233 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
3234 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
3235 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
3236 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
3237 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
3238 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
3239 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
3240 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
3241 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
3242 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
3243 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
3244 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
3245 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
3246 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
3247 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2392b8e8 3248 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK event.
14f73cf1
FM
3249 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
3250 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
3251 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
3252 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
3253 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
3254 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
5e4027e5
VZ
3255 Currently this even is only generated when using the native OSX
3256 version.
14f73cf1
FM
3257 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
3258 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
3259 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
3260 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
3261 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
3262 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
47a8b1e1
VZ
3263 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
3264 Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event.
14f73cf1 3265 @endEventTable
43c64cc6 3266
80932a3e
FM
3267 @library{wxadv}
3268 @category{events,dvc}
3269*/
3270class wxDataViewEvent : public wxNotifyEvent
3271{
3272public:
80932a3e
FM
3273 /**
3274 Constructor. Typically used by wxWidgets internals only.
3275 */
3276 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
3277 int winid = 0);
80932a3e
FM
3278
3279 /**
3280 Returns the position of the column in the control or -1
3281 if no column field was set by the event emitter.
3282 */
3283 int GetColumn() const;
3284
3285 /**
3286 Returns a pointer to the wxDataViewColumn from which
3287 the event was emitted or @NULL.
3288 */
3289 wxDataViewColumn* GetDataViewColumn() const;
3290
3291 /**
3292 Returns the wxDataViewModel associated with the event.
3293 */
3294 wxDataViewModel* GetModel() const;
3295
3296 /**
57ab6f23 3297 Returns the position of a context menu event in screen coordinates.
80932a3e
FM
3298 */
3299 wxPoint GetPosition() const;
3300
3301 /**
3302 Returns a reference to a value.
3303 */
3304 const wxVariant& GetValue() const;
3305
2a648479
VZ
3306 /**
3307 Can be used to determine whether the new value is going to be accepted
3308 in wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE handler.
3309
3310 Returns @true if editing the item was cancelled or if the user tried to
3311 enter an invalid value (refused by wxDataViewRenderer::Validate()). If
3312 this method returns @false, it means that the value in the model is
3313 about to be changed to the new one.
3314
3315 Notice that wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event handler can
3316 call wxNotifyEvent::Veto() to prevent this from happening.
3317
3318 Currently support for setting this field and for vetoing the change is
3319 only available in the generic version of wxDataViewCtrl, i.e. under MSW
3320 but not GTK nor OS X.
3321
3322 @since 2.9.3
3323 */
3324 bool IsEditCancelled() const;
3325
80932a3e
FM
3326 /**
3327 Sets the column index associated with this event.
3328 */
3329 void SetColumn(int col);
3330
3331 /**
2392b8e8 3332 For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK only.
80932a3e
FM
3333 */
3334 void SetDataViewColumn(wxDataViewColumn* col);
3335
3336 /**
3337 Sets the dataview model associated with this event.
3338 */
3339 void SetModel(wxDataViewModel* model);
3340
3341 /**
3342 Sets the value associated with this event.
3343 */
3344 void SetValue(const wxVariant& value);
02b51ae5 3345
591cc82d 3346 /**
e4de825e 3347 Set wxDataObject for data transfer within a drag operation.
591cc82d
RR
3348 */
3349 void SetDataObject( wxDataObject *obj );
02b51ae5 3350
e4de825e
RR
3351 /**
3352 Gets the wxDataFormat during a drop operation.
3353 */
3354 wxDataFormat GetDataFormat() const;
02b51ae5 3355
e4de825e
RR
3356 /**
3357 Gets the data size for a drop data transfer.
3358 */
3359 size_t GetDataSize() const;
02b51ae5 3360
e4de825e
RR
3361 /**
3362 Gets the data buffer for a drop data transfer.
591cc82d 3363 */
e4de825e 3364 void *GetDataBuffer() const;
47a8b1e1 3365
c04be1a2
VZ
3366 /**
3367 Specify the kind of the drag operation to perform.
3368
3369 This method can be used inside a wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
3370 handler in order to configure the drag operation. Valid values are
3371 ::wxDrag_CopyOnly (default), ::wxDrag_AllowMove (allow the data to be
3372 moved) and ::wxDrag_DefaultMove.
3373
3374 Currently it is only honoured by the generic version of wxDataViewCtrl
3375 (used e.g. under MSW) and not supported by the native GTK and OS X
3376 versions.
3377
3378 @see GetDropEffect()
3379
3380 @since 2.9.4
3381 */
3382 void SetDragFlags(int flags);
3383
3384 /**
3385 Returns the effect the user requested to happen to the dropped data.
3386
3387 This function can be used inside
3388 wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE and
3389 wxEVT_COMMAND_DATAVIEW_ITEM_DROP handlers and returns whether the user
3390 is trying to copy (the return value is ::wxDragCopy) or move (if the
3391 return value is ::wxDragMove) the data.
3392
3393 Currently this is only available when using the generic version of
3394 wxDataViewCtrl (used e.g. under MSW) and always returns ::wxDragNone in
3395 the GTK and OS X native versions.
3396
3397 @since 2.9.4
3398 */
3399 wxDragResult GetDropEffect() const;
3400
47a8b1e1
VZ
3401 /**
3402 Return the first row that will be displayed.
3403 */
3404 int GetCacheFrom() const;
3405
3406 /**
3407 Return the last row that will be displayed.
3408 */
3409 int GetCacheTo() const;
4e15d1ca
RD
3410
3411
3412
3413
3414 wxDataViewItem GetItem() const;
3415 void SetItem( const wxDataViewItem &item );
3416 void SetEditCanceled(bool editCancelled);
3417 void SetPosition( int x, int y );
3418 void SetCache(int from, int to);
3419 wxDataObject *GetDataObject() const;
3420 void SetDataFormat( const wxDataFormat &format );
3421 void SetDataSize( size_t size );
3422 void SetDataBuffer( void* buf );
3423 int GetDragFlags() const;
3424 void SetDropEffect( wxDragResult effect );
3425
80932a3e
FM
3426};
3427