]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dataview.h
Continue bisecting tests crash in PPC OS X builds.
[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
ce7fe42e
VZ
772wxEventType wxEVT_DATAVIEW_SELECTION_CHANGED;
773
774wxEventType wxEVT_DATAVIEW_ITEM_ACTIVATED;
775wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSING;
776wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSED;
777wxEventType wxEVT_DATAVIEW_ITEM_EXPANDING;
778wxEventType wxEVT_DATAVIEW_ITEM_EXPANDED;
779wxEventType wxEVT_DATAVIEW_ITEM_START_EDITING;
780wxEventType wxEVT_DATAVIEW_ITEM_EDITING_STARTED;
781wxEventType wxEVT_DATAVIEW_ITEM_EDITING_DONE;
782wxEventType wxEVT_DATAVIEW_ITEM_VALUE_CHANGED;
783
784wxEventType wxEVT_DATAVIEW_ITEM_CONTEXT_MENU;
785
786wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_CLICK;
3bc1418b 787wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
ce7fe42e
VZ
788wxEventType wxEVT_DATAVIEW_COLUMN_SORTED;
789wxEventType wxEVT_DATAVIEW_COLUMN_REORDERED;
790wxEventType wxEVT_DATAVIEW_CACHE_HINT;
791
792wxEventType wxEVT_DATAVIEW_ITEM_BEGIN_DRAG;
793wxEventType wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE;
794wxEventType wxEVT_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}
c37975fa 835 Display the separator lines between rows.
8c6791e4 836 @style{wxDV_VERT_RULES}
c37975fa 837 Display the separator lines between columns.
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)}
ce7fe42e 847 Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
7d01d660 848 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
ce7fe42e 849 Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event. This event
43868fde
VZ
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)}
ce7fe42e 853 Process a @c wxEVT_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)}
ce7fe42e 857 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
7d01d660 858 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
ce7fe42e 859 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
7d01d660 860 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
ce7fe42e 861 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
7d01d660 862 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
ce7fe42e 863 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
7d01d660 864 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
ce7fe42e 865 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
7d01d660 866 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
ce7fe42e 867 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
7d01d660 868 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
ce7fe42e 869 Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
7d01d660 870 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
ce7fe42e 871 Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event
7ed24cb6
VZ
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)}
ce7fe42e 877 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
7d01d660 878 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
3bc1418b 879 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
47e175a2
VZ
880 Notice that currently this event is not generated in the native OS X
881 versions of the control.
7d01d660 882 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
ce7fe42e 883 Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
7d01d660 884 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
ce7fe42e 885 Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
591cc82d 886 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
ce7fe42e 887 Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
e4de825e 888 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
ce7fe42e 889 Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
e4de825e 890 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
ce7fe42e 891 Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
7d01d660 892 @endEventTable
b91c4601 893
43868fde
VZ
894 Notice that this control doesn't allow to process generic mouse events such
895 as @c wxEVT_LEFT_DOWN in all ports (notably it doesn't work in wxGTK). If
896 you need to handle any mouse events not covered by the ones above, consider
897 using a custom renderer for the cells that must handle them.
898
23324ae1 899 @library{wxadv}
b321b61c 900 @category{ctrl,dvc}
ce154616 901 @appearance{dataviewctrl}
23324ae1
FM
902*/
903class wxDataViewCtrl : public wxControl
904{
905public:
23324ae1 906 /**
19723525 907 Default Constructor.
23324ae1
FM
908 */
909 wxDataViewCtrl();
b91c4601 910
19723525
RR
911 /**
912 Constructor. Calls Create().
913 */
7c913512
FM
914 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
915 const wxPoint& pos = wxDefaultPosition,
916 const wxSize& size = wxDefaultSize,
917 long style = 0,
8eb99915
RR
918 const wxValidator& validator = wxDefaultValidator,
919 const wxString& name = wxDataViewCtrlNameStr);
23324ae1
FM
920
921 /**
922 Destructor.
923 */
adaaa686 924 virtual ~wxDataViewCtrl();
23324ae1 925
4e15d1ca
RD
926 /**
927 Create the control. Useful for two step creation.
928 */
929 bool Create(wxWindow* parent, wxWindowID id,
930 const wxPoint& pos = wxDefaultPosition,
931 const wxSize& size = wxDefaultSize,
932 long style = 0,
933 const wxValidator& validator = wxDefaultValidator,
934 const wxString& name = wxDataViewCtrlNameStr);
935
e39de702 936 /**
19723525 937 Appends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 938
e39de702
RR
939 Note that there is a number of short cut methods which implicitly create
940 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
941 */
942 virtual bool AppendColumn(wxDataViewColumn* col);
943
19723525
RR
944 /**
945 Prepends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 946
19723525
RR
947 Note that there is a number of short cut methods which implicitly create
948 a wxDataViewColumn and a wxDataViewRenderer for it.
949 */
950 virtual bool PrependColumn(wxDataViewColumn* col);
951
952 /**
953 Inserts a wxDataViewColumn to the control. Returns @true on success.
954 */
955 virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
b91c4601 956
23324ae1
FM
957 //@{
958 /**
959 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
960 created in the function or @NULL on failure.
961 */
962 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
963 unsigned int model_column,
964 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
965 int width = -1,
966 wxAlignment align = wxALIGN_CENTER,
967 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
968 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
969 unsigned int model_column,
970 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
971 int width = -1,
972 wxAlignment align = wxALIGN_CENTER,
973 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
974 //@}
975
4e15d1ca
RD
976 //@{
977 /**
978 Prepends a column for rendering a bitmap. Returns the wxDataViewColumn
979 created in the function or @NULL on failure.
980 */
981 wxDataViewColumn* PrependBitmapColumn(const wxString& label,
982 unsigned int model_column,
983 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
984 int width = -1,
985 wxAlignment align = wxALIGN_CENTER,
986 int flags = wxDATAVIEW_COL_RESIZABLE);
987 wxDataViewColumn* PrependBitmapColumn(const wxBitmap& label,
988 unsigned int model_column,
989 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
990 int width = -1,
991 wxAlignment align = wxALIGN_CENTER,
992 int flags = wxDATAVIEW_COL_RESIZABLE);
993 //@}
994
23324ae1
FM
995 //@{
996 /**
997 Appends a column for rendering a date. Returns the wxDataViewColumn
998 created in the function or @NULL on failure.
b91c4601 999
c4e57202
FM
1000 @note The @a align parameter is applied to both the column header and
1001 the column renderer.
23324ae1
FM
1002 */
1003 wxDataViewColumn* AppendDateColumn(const wxString& label,
1004 unsigned int model_column,
1005 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1006 int width = -1,
882678eb 1007 wxAlignment align = wxALIGN_NOT,
23324ae1 1008 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1009 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
1010 unsigned int model_column,
1011 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1012 int width = -1,
882678eb 1013 wxAlignment align = wxALIGN_NOT,
7c913512 1014 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1015 //@}
1016
4e15d1ca
RD
1017 //@{
1018 /**
1019 Prepends a column for rendering a date. Returns the wxDataViewColumn
1020 created in the function or @NULL on failure.
1021
1022 @note The @a align parameter is applied to both the column header and
1023 the column renderer.
1024 */
1025 wxDataViewColumn* PrependDateColumn(const wxString& label,
1026 unsigned int model_column,
1027 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1028 int width = -1,
1029 wxAlignment align = wxALIGN_NOT,
1030 int flags = wxDATAVIEW_COL_RESIZABLE);
1031 wxDataViewColumn* PrependDateColumn(const wxBitmap& label,
1032 unsigned int model_column,
1033 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1034 int width = -1,
1035 wxAlignment align = wxALIGN_NOT,
1036 int flags = wxDATAVIEW_COL_RESIZABLE);
1037 //@}
1038
23324ae1
FM
1039 //@{
1040 /**
1041 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
c4e57202
FM
1042 created in the function or @NULL on failure.
1043 This method uses the wxDataViewIconTextRenderer class.
b91c4601 1044
c4e57202
FM
1045 @note The @a align parameter is applied to both the column header and
1046 the column renderer.
23324ae1
FM
1047 */
1048 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
1049 unsigned int model_column,
1050 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1051 int width = -1,
882678eb 1052 wxAlignment align = wxALIGN_NOT,
23324ae1 1053 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1054 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
1055 unsigned int model_column,
1056 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1057 int width = -1,
882678eb 1058 wxAlignment align = wxALIGN_NOT,
7c913512 1059 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1060 //@}
1061
4e15d1ca
RD
1062 //@{
1063 /**
1064 Prepends a column for rendering text with an icon. Returns the wxDataViewColumn
1065 created in the function or @NULL on failure.
1066 This method uses the wxDataViewIconTextRenderer class.
1067
1068 @note The @a align parameter is applied to both the column header and
1069 the column renderer.
1070 */
1071 wxDataViewColumn* PrependIconTextColumn(const wxString& label,
1072 unsigned int model_column,
1073 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1074 int width = -1,
1075 wxAlignment align = wxALIGN_NOT,
1076 int flags = wxDATAVIEW_COL_RESIZABLE);
1077 wxDataViewColumn* PrependIconTextColumn(const wxBitmap& label,
1078 unsigned int model_column,
1079 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1080 int width = -1,
1081 wxAlignment align = wxALIGN_NOT,
1082 int flags = wxDATAVIEW_COL_RESIZABLE);
1083 //@}
1084
23324ae1
FM
1085 //@{
1086 /**
1087 Appends a column for rendering a progress indicator. Returns the
e39de702 1088 wxDataViewColumn created in the function or @NULL on failure.
b91c4601 1089
c4e57202
FM
1090 @note The @a align parameter is applied to both the column header and
1091 the column renderer.
23324ae1
FM
1092 */
1093 wxDataViewColumn* AppendProgressColumn(const wxString& label,
1094 unsigned int model_column,
1095 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1096 int width = 80,
1097 wxAlignment align = wxALIGN_CENTER,
1098 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1099 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
1100 unsigned int model_column,
1101 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1102 int width = 80,
1103 wxAlignment align = wxALIGN_CENTER,
1104 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1105 //@}
1106
4e15d1ca
RD
1107 //@{
1108 /**
1109 Prepends a column for rendering a progress indicator. Returns the
1110 wxDataViewColumn created in the function or @NULL on failure.
1111
1112 @note The @a align parameter is applied to both the column header and
1113 the column renderer.
1114 */
1115 wxDataViewColumn* PrependProgressColumn(const wxString& label,
1116 unsigned int model_column,
1117 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1118 int width = 80,
1119 wxAlignment align = wxALIGN_CENTER,
1120 int flags = wxDATAVIEW_COL_RESIZABLE);
1121 wxDataViewColumn* PrependProgressColumn(const wxBitmap& label,
1122 unsigned int model_column,
1123 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1124 int width = 80,
1125 wxAlignment align = wxALIGN_CENTER,
1126 int flags = wxDATAVIEW_COL_RESIZABLE);
1127 //@}
1128
23324ae1
FM
1129 //@{
1130 /**
1131 Appends a column for rendering text. Returns the wxDataViewColumn
1132 created in the function or @NULL on failure.
b91c4601 1133
c4e57202
FM
1134 @note The @a align parameter is applied to both the column header and
1135 the column renderer.
23324ae1
FM
1136 */
1137 wxDataViewColumn* AppendTextColumn(const wxString& label,
1138 unsigned int model_column,
1139 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1140 int width = -1,
882678eb 1141 wxAlignment align = wxALIGN_NOT,
23324ae1 1142 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1143 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
1144 unsigned int model_column,
1145 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1146 int width = -1,
882678eb 1147 wxAlignment align = wxALIGN_NOT,
7c913512 1148 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1149 //@}
1150
4e15d1ca
RD
1151 //@{
1152 /**
1153 Prepends a column for rendering text. Returns the wxDataViewColumn
1154 created in the function or @NULL on failure.
1155
1156 @note The @a align parameter is applied to both the column header and
1157 the column renderer.
1158 */
1159 wxDataViewColumn* PrependTextColumn(const wxString& label,
1160 unsigned int model_column,
1161 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1162 int width = -1,
1163 wxAlignment align = wxALIGN_NOT,
1164 int flags = wxDATAVIEW_COL_RESIZABLE);
1165 wxDataViewColumn* PrependTextColumn(const wxBitmap& label,
1166 unsigned int model_column,
1167 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1168 int width = -1,
1169 wxAlignment align = wxALIGN_NOT,
1170 int flags = wxDATAVIEW_COL_RESIZABLE);
1171 //@}
1172
23324ae1
FM
1173 //@{
1174 /**
1175 Appends a column for rendering a toggle. Returns the wxDataViewColumn
1176 created in the function or @NULL on failure.
b91c4601 1177
c4e57202
FM
1178 @note The @a align parameter is applied to both the column header and
1179 the column renderer.
23324ae1
FM
1180 */
1181 wxDataViewColumn* AppendToggleColumn(const wxString& label,
1182 unsigned int model_column,
1183 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1184 int width = 30,
1185 wxAlignment align = wxALIGN_CENTER,
1186 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
1187 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
1188 unsigned int model_column,
1189 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1190 int width = 30,
1191 wxAlignment align = wxALIGN_CENTER,
1192 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
1193 //@}
1194
4e15d1ca
RD
1195 //@{
1196 /**
1197 Prepends a column for rendering a toggle. Returns the wxDataViewColumn
1198 created in the function or @NULL on failure.
1199
1200 @note The @a align parameter is applied to both the column header and
1201 the column renderer.
1202 */
1203 wxDataViewColumn* PrependToggleColumn(const wxString& label,
1204 unsigned int model_column,
1205 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1206 int width = 30,
1207 wxAlignment align = wxALIGN_CENTER,
1208 int flags = wxDATAVIEW_COL_RESIZABLE);
1209 wxDataViewColumn* PrependToggleColumn(const wxBitmap& label,
1210 unsigned int model_column,
1211 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1212 int width = 30,
1213 wxAlignment align = wxALIGN_CENTER,
1214 int flags = wxDATAVIEW_COL_RESIZABLE);
1215 //@}
1216
23324ae1 1217 /**
c4e57202
FM
1218 Associates a wxDataViewModel with the control.
1219 This increases the reference count of the model by 1.
23324ae1
FM
1220 */
1221 virtual bool AssociateModel(wxDataViewModel* model);
1222
1223 /**
1224 Removes all columns.
1225 */
1226 virtual bool ClearColumns();
1227
23324ae1
FM
1228 /**
1229 Collapses the item.
1230 */
adaaa686 1231 virtual void Collapse(const wxDataViewItem& item);
23324ae1 1232
23324ae1
FM
1233 /**
1234 Deletes given column.
1235 */
50ec54b6 1236 virtual bool DeleteColumn(wxDataViewColumn* column);
23324ae1 1237
907f09f4
VS
1238 /**
1239 Programmatically starts editing given cell of @a item.
1240
1241 Doesn't do anything if the item or this column is not editable.
1242
1243 @note Currently not implemented in wxOSX/Carbon.
1244
1245 @since 2.9.4
1246 */
1247 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
1248
e4de825e
RR
1249 /**
1250 Enable drag operations using the given @a format.
1251 */
1252 virtual bool EnableDragSource( const wxDataFormat &format );
02b51ae5 1253
e4de825e
RR
1254 /**
1255 Enable drop operations using the given @a format.
1256 */
1257 virtual bool EnableDropTarget( const wxDataFormat &format );
02b51ae5 1258
23324ae1
FM
1259 /**
1260 Call this to ensure that the given item is visible.
1261 */
fadc2df6
FM
1262 virtual void EnsureVisible(const wxDataViewItem& item,
1263 const wxDataViewColumn* column = NULL);
23324ae1
FM
1264
1265 /**
1266 Expands the item.
1267 */
adaaa686 1268 virtual void Expand(const wxDataViewItem& item);
23324ae1 1269
4219d8b0
RR
1270 /**
1271 Expands all ancestors of the @a item. This method also
1272 ensures that the item itself as well as all ancestor
1273 items have been read from the model by the control.
1274 */
1275 virtual void ExpandAncestors( const wxDataViewItem & item );
798c0d87 1276
23324ae1 1277 /**
c4e57202
FM
1278 Returns pointer to the column. @a pos refers to the position in the
1279 control which may change after reordering columns by the user.
23324ae1 1280 */
328f5751 1281 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
23324ae1
FM
1282
1283 /**
1284 Returns the number of columns.
1285 */
328f5751 1286 virtual unsigned int GetColumnCount() const;
23324ae1
FM
1287
1288 /**
1289 Returns the position of the column or -1 if not found in the control.
1290 */
328f5751 1291 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
23324ae1
FM
1292
1293 /**
1294 Returns column containing the expanders.
1295 */
328f5751 1296 wxDataViewColumn* GetExpanderColumn() const;
23324ae1 1297
80ce465c
VZ
1298 /**
1299 Returns the currently focused item.
1300
1301 This is the item that the keyboard commands apply to. It may be invalid
1302 if there is no focus currently.
1303
1304 This method is mostly useful for the controls with @c wxDV_MULTIPLE
1305 style as in the case of single selection it returns the same thing as
1306 GetSelection().
1307
1308 Notice that under all platforms except Mac OS X the currently focused
1309 item may be selected or not but under OS X the current item is always
1310 selected.
1311
ee1377e1 1312 @see SetCurrentItem(), GetCurrentColumn()
80ce465c
VZ
1313
1314 @since 2.9.2
1315 */
1316 wxDataViewItem GetCurrentItem() const;
1317
ee1377e1
VS
1318 /**
1319 Returns the column that currently has focus.
1320
1321 If the focus is set to individual cell within the currently focused
1322 item (as opposed to being on the item as a whole), then this is the
1323 column that the focus is on.
1324
1325 Returns NULL if no column currently has focus.
1326
1327 @see GetCurrentItem()
1328
1329 @since 2.9.4
1330 */
1331 wxDataViewColumn *GetCurrentColumn() const;
1332
23324ae1
FM
1333 /**
1334 Returns indentation.
1335 */
328f5751 1336 int GetIndent() const;
23324ae1
FM
1337
1338 /**
7f15deea
VZ
1339 Returns item rectangle.
1340
1341 This method is currently not implemented at all in wxGTK and only
1342 implemented for non-@NULL @a col argument in wxOSX. It is fully
1343 implemented in the generic version of the control.
1344
1345 @param item
1346 A valid item.
1347 @param col
1348 If non-@NULL, the rectangle returned corresponds to the
1349 intersection of the item with the specified column. If @NULL, the
1350 rectangle spans all the columns.
23324ae1 1351 */
fadc2df6
FM
1352 virtual wxRect GetItemRect(const wxDataViewItem& item,
1353 const wxDataViewColumn* col = NULL) const;
23324ae1
FM
1354
1355 /**
c4e57202 1356 Returns pointer to the data model associated with the control (if any).
23324ae1 1357 */
adaaa686 1358 wxDataViewModel* GetModel();
23324ae1 1359
fa93d732
VZ
1360 /**
1361 Returns the number of currently selected items.
1362
1363 This method may be called for both the controls with single and
1364 multiple selections and returns the number of selected item, possibly
1365 0, in any case.
1366
1367 @since 2.9.3
1368 */
1369 virtual int GetSelectedItemsCount() const;
1370
23324ae1
FM
1371 /**
1372 Returns first selected item or an invalid item if none is selected.
fa93d732
VZ
1373
1374 This method may be called for both the controls with single and
1375 multiple selections but returns an invalid item if more than one item
1376 is selected in the latter case, use HasSelection() to determine if
1377 there are any selected items when using multiple selection.
23324ae1 1378 */
adaaa686 1379 virtual wxDataViewItem GetSelection() const;
23324ae1
FM
1380
1381 /**
c4e57202 1382 Fills @a sel with currently selected items and returns their number.
fa93d732
VZ
1383
1384 This method may be called for both the controls with single and
1385 multiple selections. In the single selection case it returns the array
1386 with at most one element in it.
1387
1388 @see GetSelectedItemsCount()
23324ae1 1389 */
adaaa686 1390 virtual int GetSelections(wxDataViewItemArray& sel) const;
23324ae1
FM
1391
1392 /**
1393 Returns the wxDataViewColumn currently responsible for sorting
1394 or @NULL if none has been selected.
1395 */
328f5751 1396 virtual wxDataViewColumn* GetSortingColumn() const;
23324ae1 1397
fa93d732
VZ
1398 /**
1399 Returns true if any items are currently selected.
1400
1401 This method may be called for both the controls with single and
1402 multiple selections.
1403
1404 Calling this method is equivalent to calling GetSelectedItemsCount()
1405 and comparing its result with 0 but is more clear and might also be
1406 implemented more efficiently in the future.
1407
1408 @since 2.9.3
1409 */
1410 bool HasSelection() const;
1411
23324ae1
FM
1412 /**
1413 Hittest.
1414 */
fadc2df6
FM
1415 virtual void HitTest(const wxPoint& point, wxDataViewItem& item,
1416 wxDataViewColumn*& col) const;
23324ae1 1417
739a8399
RR
1418 /**
1419 Return @true if the item is expanded.
739a8399
RR
1420 */
1421 virtual bool IsExpanded(const wxDataViewItem& item) const;
1422
23324ae1
FM
1423 /**
1424 Return @true if the item is selected.
1425 */
adaaa686 1426 virtual bool IsSelected(const wxDataViewItem& item) const;
23324ae1
FM
1427
1428 /**
1429 Select the given item.
1e184300
VZ
1430
1431 In single selection mode this changes the (unique) currently selected
1432 item. In multi selection mode, the @a item is selected and the
1433 previously selected items remain selected.
23324ae1 1434 */
adaaa686 1435 virtual void Select(const wxDataViewItem& item);
23324ae1
FM
1436
1437 /**
1438 Select all items.
1439 */
adaaa686 1440 virtual void SelectAll();
23324ae1
FM
1441
1442 /**
1443 Set which column shall contain the tree-like expanders.
1444 */
4cc4bfaf 1445 void SetExpanderColumn(wxDataViewColumn* col);
23324ae1 1446
80ce465c
VZ
1447 /**
1448 Changes the currently focused item.
1449
1450 The @a item parameter must be valid, there is no way to remove the
1451 current item from the control.
1452
1453 In single selection mode, calling this method is the same as calling
1454 Select() and is thus not very useful. In multiple selection mode this
1455 method only moves the current item however without changing the
1456 selection except under OS X where the current item is always selected,
1457 so calling SetCurrentItem() selects @a item if it hadn't been selected
1458 before.
1459
1460 @see GetCurrentItem()
1461
1462 @since 2.9.2
1463 */
1464 void SetCurrentItem(const wxDataViewItem& item);
1465
23324ae1 1466 /**
57ab6f23 1467 Sets the indentation.
23324ae1
FM
1468 */
1469 void SetIndent(int indent);
1470
1471 /**
1472 Sets the selection to the array of wxDataViewItems.
1473 */
adaaa686 1474 virtual void SetSelections(const wxDataViewItemArray& sel);
23324ae1
FM
1475
1476 /**
1477 Unselect the given item.
1478 */
adaaa686 1479 virtual void Unselect(const wxDataViewItem& item);
23324ae1
FM
1480
1481 /**
c4e57202
FM
1482 Unselect all item.
1483 This method only has effect if multiple selections are allowed.
23324ae1 1484 */
adaaa686 1485 virtual void UnselectAll();
bbfd4548
VZ
1486
1487 /**
1488 Sets the row height.
1489
1490 This function can only be used when all rows have the same height, i.e.
1491 when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
1492
0f4a54a6
VZ
1493 Currently this is implemented in the generic and native GTK versions
1494 only and nothing is done (and @false returned) when using OS X port.
1495
1496 Also notice that this method can only be used to increase the row
1497 height compared with the default one (as determined by the return value
1498 of wxDataViewRenderer::GetSize()), if it is set to a too small value
1499 then the minimum required by the renderers will be used.
bbfd4548
VZ
1500
1501 @return @true if the line height was changed or @false otherwise.
1502
1503 @since 2.9.2
1504 */
1505 virtual bool SetRowHeight(int rowHeight);
23324ae1
FM
1506};
1507
1508
e54c96f1 1509
23324ae1
FM
1510/**
1511 @class wxDataViewModelNotifier
7c913512 1512
c4e57202
FM
1513 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
1514 its notification interface.
1515 See the documentation of that class for further information.
7c913512 1516
8ed522d9 1517 @library{wxadv}
b321b61c 1518 @category{dvc}
23324ae1 1519*/
7c913512 1520class wxDataViewModelNotifier
23324ae1
FM
1521{
1522public:
1523 /**
1524 Constructor.
1525 */
1526 wxDataViewModelNotifier();
1527
1528 /**
1529 Destructor.
1530 */
adaaa686 1531 virtual ~wxDataViewModelNotifier();
23324ae1
FM
1532
1533 /**
1534 Called by owning model.
1535 */
b91c4601 1536 virtual bool Cleared() = 0;
23324ae1
FM
1537
1538 /**
1539 Get owning wxDataViewModel.
1540 */
e51bf699 1541 wxDataViewModel* GetOwner() const;
23324ae1
FM
1542
1543 /**
1544 Called by owning model.
63e55c0a
VS
1545
1546 @return Always return @true from this function in derived classes.
23324ae1 1547 */
fadc2df6
FM
1548 virtual bool ItemAdded(const wxDataViewItem& parent,
1549 const wxDataViewItem& item) = 0;
23324ae1
FM
1550
1551 /**
1552 Called by owning model.
63e55c0a
VS
1553
1554 @return Always return @true from this function in derived classes.
23324ae1 1555 */
b91c4601 1556 virtual bool ItemChanged(const wxDataViewItem& item) = 0;
23324ae1
FM
1557
1558 /**
1559 Called by owning model.
63e55c0a
VS
1560
1561 @return Always return @true from this function in derived classes.
23324ae1 1562 */
fadc2df6
FM
1563 virtual bool ItemDeleted(const wxDataViewItem& parent,
1564 const wxDataViewItem& item) = 0;
23324ae1
FM
1565
1566 /**
1567 Called by owning model.
63e55c0a
VS
1568
1569 @return Always return @true from this function in derived classes.
23324ae1 1570 */
fadc2df6
FM
1571 virtual bool ItemsAdded(const wxDataViewItem& parent,
1572 const wxDataViewItemArray& items);
23324ae1
FM
1573
1574 /**
1575 Called by owning model.
63e55c0a
VS
1576
1577 @return Always return @true from this function in derived classes.
23324ae1 1578 */
adaaa686 1579 virtual bool ItemsChanged(const wxDataViewItemArray& items);
23324ae1
FM
1580
1581 /**
1582 Called by owning model.
63e55c0a
VS
1583
1584 @return Always return @true from this function in derived classes.
23324ae1 1585 */
fadc2df6
FM
1586 virtual bool ItemsDeleted(const wxDataViewItem& parent,
1587 const wxDataViewItemArray& items);
23324ae1
FM
1588
1589 /**
1590 Called by owning model.
1591 */
b91c4601 1592 virtual void Resort() = 0;
23324ae1
FM
1593
1594 /**
1595 Set owner of this notifier. Used internally.
1596 */
1597 void SetOwner(wxDataViewModel* owner);
1598
1599 /**
1600 Called by owning model.
63e55c0a
VS
1601
1602 @return Always return @true from this function in derived classes.
23324ae1 1603 */
b91c4601 1604 virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0;
23324ae1
FM
1605};
1606
1607
c4e57202
FM
1608/**
1609 The mode of a data-view cell; see wxDataViewRenderer for more info.
1610*/
1611enum wxDataViewCellMode
1612{
dc73d7f5
VS
1613 /**
1614 The cell only displays information and cannot be manipulated or
1615 otherwise interacted with in any way.
1616
1617 Note that this doesn't mean that the row being drawn can't be selected,
1618 just that a particular element of it cannot be individually modified.
1619 */
c4e57202
FM
1620 wxDATAVIEW_CELL_INERT,
1621
1622 /**
dc73d7f5
VS
1623 Indicates that the cell can be @em activated by clicking it or using
1624 keyboard.
1625
1626 Activating a cell is an alternative to showing inline editor when the
1627 value can be edited in a simple way that doesn't warrant full editor
1628 control. The most typical use of cell activation is toggling the
1629 checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded
1630 volume slider or a five-star rating column.
1631
1632 The exact means of activating a cell are platform-dependent, but they
1633 are usually similar to those used for inline editing of values.
1634 Typically, a cell would be activated by Space or Enter keys or by left
1635 mouse click.
1636
1637 @note Do not confuse this with item activation in wxDataViewCtrl
ce7fe42e 1638 and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
dc73d7f5
VS
1639 used for activating the item (or, to put it differently, the
1640 entire row) similarly to analogous messages in wxTreeCtrl and
1641 wxListCtrl, and the effect differs (play a song, open a file
1642 etc.). Cell activation, on the other hand, is all about
1643 interacting with the individual cell.
1644
1645 @see wxDataViewCustomRenderer::ActivateCell()
c4e57202
FM
1646 */
1647 wxDATAVIEW_CELL_ACTIVATABLE,
1648
1649 /**
dc73d7f5
VS
1650 Indicates that the user can edit the data in-place in an inline editor
1651 control that will show up when the user wants to edit the cell.
1652
1653 A typical example of this behaviour is changing the filename in a file
1654 managers.
1655
1656 Editing is typically triggered by slowly double-clicking the cell or by
1657 a platform-dependent keyboard shortcut (F2 is typical on Windows, Space
1658 and/or Enter is common elsewhere and supported on Windows too).
1659
1660 @see wxDataViewCustomRenderer::CreateEditorCtrl()
c4e57202
FM
1661 */
1662 wxDATAVIEW_CELL_EDITABLE
1663};
1664
1665/**
1666 The values of this enum controls how a wxDataViewRenderer should display
1667 its contents in a cell.
1668*/
1669enum wxDataViewCellRenderState
1670{
1671 wxDATAVIEW_CELL_SELECTED = 1,
1672 wxDATAVIEW_CELL_PRELIT = 2,
1673 wxDATAVIEW_CELL_INSENSITIVE = 4,
1674 wxDATAVIEW_CELL_FOCUSED = 8
1675};
e54c96f1 1676
23324ae1
FM
1677/**
1678 @class wxDataViewRenderer
7c913512 1679
5b99d5d8 1680 This class is used by wxDataViewCtrl to render the individual cells.
c4e57202
FM
1681 One instance of a renderer class is owned by a wxDataViewColumn.
1682 There is a number of ready-to-use renderers provided:
1683 - wxDataViewTextRenderer,
c4e57202
FM
1684 - wxDataViewIconTextRenderer,
1685 - wxDataViewToggleRenderer,
1686 - wxDataViewProgressRenderer,
1687 - wxDataViewBitmapRenderer,
1688 - wxDataViewDateRenderer,
1689 - wxDataViewSpinRenderer.
f4fcd648 1690 - wxDataViewChoiceRenderer.
7c913512 1691
4e15d1ca 1692 Additionally, the user can write their own renderers by deriving from
23324ae1 1693 wxDataViewCustomRenderer.
7c913512 1694
c4e57202
FM
1695 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1696 by the constructors respectively controls what actions the cell data allows
1697 and how the renderer should display its contents in a cell.
7c913512 1698
23324ae1 1699 @library{wxadv}
b321b61c 1700 @category{dvc}
23324ae1
FM
1701*/
1702class wxDataViewRenderer : public wxObject
1703{
1704public:
1705 /**
b91c4601 1706 Constructor.
23324ae1
FM
1707 */
1708 wxDataViewRenderer(const wxString& varianttype,
1709 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
f2b7492a 1710 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1 1711
c937bcac
VZ
1712 /**
1713 Enable or disable replacing parts of the item text with ellipsis to
1714 make it fit the column width.
1715
1716 This method only makes sense for the renderers working with text, such
1717 as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
1718
1719 By default wxELLIPSIZE_MIDDLE is used.
1720
1721 @param mode
1722 Ellipsization mode, use wxELLIPSIZE_NONE to disable.
1723
1724 @since 2.9.1
1725 */
1726 void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
1727
1728 /**
1729 Disable replacing parts of the item text with ellipsis.
1730
1731 If ellipsizing is disabled, the string will be truncated if it doesn't
1732 fit.
1733
1734 This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
1735
1736 @since 2.9.1
1737 */
1738 void DisableEllipsize();
1739
20c36737 1740 /**
f2b7492a 1741 Returns the alignment. See SetAlignment()
20c36737
RR
1742 */
1743 virtual int GetAlignment() const;
1744
c937bcac
VZ
1745 /**
1746 Returns the ellipsize mode used by the renderer.
1747
1748 If the return value is wxELLIPSIZE_NONE, the text is simply truncated
1749 if it doesn't fit.
1750
1751 @see EnableEllipsize()
1752 */
1753 wxEllipsizeMode GetEllipsizeMode() const;
1754
23324ae1
FM
1755 /**
1756 Returns the cell mode.
1757 */
adaaa686 1758 virtual wxDataViewCellMode GetMode() const;
23324ae1
FM
1759
1760 /**
1761 Returns pointer to the owning wxDataViewColumn.
1762 */
adaaa686 1763 wxDataViewColumn* GetOwner() const;
23324ae1
FM
1764
1765 /**
1766 This methods retrieves the value from the renderer in order to
c4e57202
FM
1767 transfer the value back to the data model.
1768
1769 Returns @false on failure.
23324ae1 1770 */
b91c4601 1771 virtual bool GetValue(wxVariant& value) const = 0;
23324ae1
FM
1772
1773 /**
c4e57202 1774 Returns a string with the type of the wxVariant supported by this renderer.
23324ae1 1775 */
adaaa686 1776 wxString GetVariantType() const;
23324ae1 1777
20c36737 1778 /**
c4e57202
FM
1779 Sets the alignment of the renderer's content.
1780 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1781 should have the same alignment as the column header.
1782
1783 The method is not implemented under OS X and the renderer always aligns
1784 its contents as the column header on that platform. The other platforms
f2b7492a 1785 support both vertical and horizontal alignment.
20c36737
RR
1786 */
1787 virtual void SetAlignment( int align );
23324ae1 1788 /**
c4e57202
FM
1789 Sets the owning wxDataViewColumn.
1790 This is usually called from within wxDataViewColumn.
23324ae1 1791 */
adaaa686 1792 void SetOwner(wxDataViewColumn* owner);
23324ae1
FM
1793
1794 /**
c4e57202 1795 Set the value of the renderer (and thus its cell) to @a value.
23324ae1
FM
1796 The internal code will then render this cell with this data.
1797 */
b91c4601 1798 virtual bool SetValue(const wxVariant& value) = 0;
23324ae1
FM
1799
1800 /**
1801 Before data is committed to the data model, it is passed to this
1802 method where it can be checked for validity. This can also be
1803 used for checking a valid range or limiting the user input in
1804 a certain aspect (e.g. max number of characters or only alphanumeric
c4e57202
FM
1805 input, ASCII only etc.). Return @false if the value is not valid.
1806
23324ae1
FM
1807 Please note that due to implementation limitations, this validation
1808 is done after the editing control already is destroyed and the
1809 editing process finished.
1810 */
1811 virtual bool Validate(wxVariant& value);
4e15d1ca
RD
1812
1813
1814 virtual bool HasEditorCtrl() const;
1815 virtual wxWindow* CreateEditorCtrl(wxWindow * parent,
1816 wxRect labelRect,
1817 const wxVariant& value);
1818 virtual bool GetValueFromEditorCtrl(wxWindow * editor,
1819 wxVariant& value);
1820 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1821 virtual void CancelEditing();
1822 virtual bool FinishEditing();
1823 wxWindow *GetEditorCtrl();
1824
1825protected:
1826 wxDataViewCtrl* GetView() const;
23324ae1
FM
1827};
1828
1829
e54c96f1 1830
23324ae1
FM
1831/**
1832 @class wxDataViewTextRenderer
7c913512 1833
c4e57202
FM
1834 wxDataViewTextRenderer is used for rendering text.
1835 It supports in-place editing if desired.
7c913512 1836
23324ae1 1837 @library{wxadv}
b321b61c 1838 @category{dvc}
23324ae1
FM
1839*/
1840class wxDataViewTextRenderer : public wxDataViewRenderer
1841{
1842public:
1843 /**
c4e57202 1844 The ctor.
23324ae1
FM
1845 */
1846 wxDataViewTextRenderer(const wxString& varianttype = "string",
05303ccd
RR
1847 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1848 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1849};
1850
1851
e54c96f1 1852
f2b7492a
RR
1853/**
1854 @class wxDataViewIconTextRenderer
f2b7492a
RR
1855
1856 The wxDataViewIconTextRenderer class is used to display text with
1857 a small icon next to it as it is typically done in a file manager.
c4e57202
FM
1858
1859 This classes uses the wxDataViewIconText helper class to store its data.
4d68a949
BP
1860 wxDataViewIconText can be converted to and from a wxVariant using the left
1861 shift operator.
f2b7492a
RR
1862
1863 @library{wxadv}
b321b61c 1864 @category{dvc}
f2b7492a
RR
1865*/
1866class wxDataViewIconTextRenderer : public wxDataViewRenderer
1867{
1868public:
1869 /**
c4e57202 1870 The ctor.
f2b7492a
RR
1871 */
1872 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
1873 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1874 int align = wxDVR_DEFAULT_ALIGNMENT );
1875};
1876
1877
1878
23324ae1
FM
1879/**
1880 @class wxDataViewProgressRenderer
7c913512 1881
c4e57202 1882 This class is used by wxDataViewCtrl to render progress bars.
7c913512 1883
23324ae1 1884 @library{wxadv}
b321b61c 1885 @category{dvc}
23324ae1
FM
1886*/
1887class wxDataViewProgressRenderer : public wxDataViewRenderer
1888{
1889public:
1890 /**
c4e57202 1891 The ctor.
23324ae1
FM
1892 */
1893 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1894 const wxString& varianttype = "long",
05303ccd
RR
1895 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1896 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1897};
1898
1899
e54c96f1 1900
23324ae1
FM
1901/**
1902 @class wxDataViewSpinRenderer
7c913512 1903
c4e57202
FM
1904 This is a specialized renderer for rendering integer values.
1905 It supports modifying the values in-place by using a wxSpinCtrl.
23324ae1 1906 The renderer only support variants of type @e long.
7c913512 1907
8ed522d9 1908 @library{wxadv}
b321b61c 1909 @category{dvc}
23324ae1
FM
1910*/
1911class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1912{
1913public:
1914 /**
c4e57202
FM
1915 Constructor.
1916 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
23324ae1
FM
1917 */
1918 wxDataViewSpinRenderer(int min, int max,
1919 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
05303ccd 1920 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1921};
1922
1923
e54c96f1 1924
23324ae1
FM
1925/**
1926 @class wxDataViewToggleRenderer
7c913512 1927
c4e57202 1928 This class is used by wxDataViewCtrl to render toggle controls.
7c913512 1929
23324ae1 1930 @library{wxadv}
b321b61c 1931 @category{dvc}
23324ae1
FM
1932*/
1933class wxDataViewToggleRenderer : public wxDataViewRenderer
1934{
1935public:
1936 /**
c4e57202 1937 The ctor.
23324ae1
FM
1938 */
1939 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
50ec54b6
FM
1940 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1941 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1942};
1943
1944
f4fcd648 1945/**
df8cd0bd
VZ
1946 A wxDataViewCtrl renderer using wxChoice control and values of strings in
1947 it.
f4fcd648
RR
1948
1949 This class is used by wxDataViewCtrl to render choice controls.
1950 It stores a string so that SetValue() and GetValue() operate
1951 on a variant holding a string.
1952
df8cd0bd
VZ
1953 @see wxDataViewChoiceByIndexRenderer
1954
f4fcd648
RR
1955 @library{wxadv}
1956 @category{dvc}
1957*/
1958
1959class wxDataViewChoiceRenderer: public wxDataViewRenderer
1960{
1961public:
1962 /**
1963 The ctor.
1964 */
1965 wxDataViewChoiceRenderer( const wxArrayString &choices,
1966 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1967 int alignment = wxDVR_DEFAULT_ALIGNMENT );
1968
1969 /**
1970 Returns the choice referred to by index.
1971 */
1972 wxString GetChoice(size_t index) const;
df8cd0bd 1973
f4fcd648
RR
1974 /**
1975 Returns all choices.
1976 */
1977 const wxArrayString& GetChoices() const;
1978};
1979
e54c96f1 1980
df8cd0bd
VZ
1981/**
1982 A wxDataViewCtrl renderer using wxChoice control and indexes into it.
1983
1984 Unlike its base wxDataViewChoiceRenderer class, this one stores the choice
1985 index, i.e. an @c int, in the variant used by its SetValue() and
1986 GetValue().
1987
1988 @library{wxadv}
1989 @category{dvc}
1990*/
1991class wxDataViewChoiceByIndexRenderer : public wxDataViewChoiceRenderer
1992{
1993public:
1994 /**
1995 The ctor.
1996 */
1997 wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
1998 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1999 int alignment = wxDVR_DEFAULT_ALIGNMENT );
2000};
2001
2002
23324ae1 2003/**
5b99d5d8 2004 @class wxDataViewDateRenderer
7c913512 2005
c4e57202 2006 This class is used by wxDataViewCtrl to render calendar controls.
7c913512 2007
5b99d5d8 2008 @library{wxadv}
b321b61c 2009 @category{dvc}
23324ae1 2010*/
5b99d5d8 2011class wxDataViewDateRenderer : public wxDataViewRenderer
23324ae1
FM
2012{
2013public:
23324ae1 2014 /**
c4e57202 2015 The ctor.
23324ae1 2016 */
5b99d5d8 2017 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
50ec54b6
FM
2018 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
2019 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8 2020};
23324ae1 2021
3c4f71cc 2022
23324ae1 2023
5b99d5d8
RR
2024/**
2025 @class wxDataViewCustomRenderer
23324ae1 2026
5b99d5d8 2027 You need to derive a new class from wxDataViewCustomRenderer in
c4e57202
FM
2028 order to write a new renderer.
2029
2030 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
2031 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
2032
2033 If you want your renderer to support in-place editing then you also need to override
2034 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
5b99d5d8 2035 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
c4e57202
FM
2036
2037 Note that a special event handler will be pushed onto that editor control
2038 which handles @e \<ENTER\> and focus out events in order to end the editing.
23324ae1 2039
5b99d5d8 2040 @library{wxadv}
b321b61c 2041 @category{dvc}
5b99d5d8
RR
2042*/
2043class wxDataViewCustomRenderer : public wxDataViewRenderer
2044{
2045public:
23324ae1 2046 /**
5b99d5d8 2047 Constructor.
23324ae1 2048 */
5b99d5d8
RR
2049 wxDataViewCustomRenderer(const wxString& varianttype = "string",
2050 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
4e15d1ca 2051 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
2052
2053 /**
5b99d5d8 2054 Destructor.
23324ae1 2055 */
adaaa686 2056 virtual ~wxDataViewCustomRenderer();
23324ae1 2057
23324ae1 2058 /**
dc73d7f5
VS
2059 Override this to react to cell @em activation. Activating a cell is an
2060 alternative to showing inline editor when the value can be edited in a
2061 simple way that doesn't warrant full editor control. The most typical
2062 use of cell activation is toggling the checkbox in
2063 wxDataViewToggleRenderer; others would be e.g. an embedded volume
2064 slider or a five-star rating column.
2065
2066 The exact means of activating a cell are platform-dependent, but they
2067 are usually similar to those used for inline editing of values.
2068 Typically, a cell would be activated by Space or Enter keys or by left
2069 mouse click.
2070
2071 This method will only be called if the cell has the
2072 wxDATAVIEW_CELL_ACTIVATABLE mode.
2073
2074 @param cell
2075 Coordinates of the activated cell's area.
2076 @param model
2077 The model to manipulate in response.
2078 @param item
2079 Activated item.
2080 @param col
2081 Activated column of @a item.
2082 @param mouseEvent
2083 If the activation was triggered by mouse click, contains the
2084 corresponding event. Is @NULL otherwise (for keyboard activation).
2085 Mouse coordinates are adjusted to be relative to the cell.
2086
2087 @since 2.9.3
2088
2089 @note Do not confuse this method with item activation in wxDataViewCtrl
ce7fe42e 2090 and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
dc73d7f5
VS
2091 used for activating the item (or, to put it differently, the
2092 entire row) similarly to analogous messages in wxTreeCtrl and
2093 wxListCtrl, and the effect differs (play a song, open a file
2094 etc.). Cell activation, on the other hand, is all about
2095 interacting with the individual cell.
2096
2097 @see CreateEditorCtrl()
23324ae1 2098 */
dc73d7f5
VS
2099 virtual bool ActivateCell(const wxRect& cell,
2100 wxDataViewModel* model,
2101 const wxDataViewItem & item,
2102 unsigned int col,
2103 const wxMouseEvent *mouseEvent);
23324ae1
FM
2104
2105 /**
5b99d5d8 2106 Override this to create the actual editor control once editing
c4e57202
FM
2107 is about to start.
2108
dc73d7f5
VS
2109 This method will only be called if the cell has the
2110 wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly
2111 double-clicking the cell or by a platform-dependent keyboard shortcut
2112 (F2 is typical on Windows, Space and/or Enter is common elsewhere and
2113 supported on Windows too).
2114
2115 @param parent
2116 The parent of the editor control.
2117 @param labelRect
2118 Indicates the position and size of the editor control. The control
2119 should be created in place of the cell and @a labelRect should be
2120 respected as much as possible.
2121 @param value
2122 Initial value of the editor.
2123
2124 An example:
c4e57202
FM
2125 @code
2126 {
2127 long l = value;
2128 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
2129 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
2130 }
2131 @endcode
dc73d7f5
VS
2132
2133 @see ActivateCell()
23324ae1 2134 */
64c70359
VS
2135 virtual wxWindow* CreateEditorCtrl(wxWindow* parent,
2136 wxRect labelRect,
2137 const wxVariant& value);
23324ae1
FM
2138
2139 /**
62265c2c
VZ
2140 Return the attribute to be used for rendering.
2141
2142 This function may be called from Render() implementation to use the
2143 attributes defined for the item if the renderer supports them.
2144
2145 Notice that when Render() is called, the wxDC object passed to it is
2146 already set up to use the correct attributes (e.g. its font is set to
2147 bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
2148 returns true) so it may not be necessary to call it explicitly if you
2149 only want to render text using the items attributes.
2150
2151 @since 2.9.1
2152 */
2153 const wxDataViewItemAttr& GetAttr() const;
23324ae1
FM
2154
2155 /**
5b99d5d8 2156 Return size required to show content.
23324ae1 2157 */
b91c4601 2158 virtual wxSize GetSize() const = 0;
23324ae1
FM
2159
2160 /**
80093617 2161 Override this so that the renderer can get the value from the editor
c4e57202
FM
2162 control (pointed to by @a editor):
2163 @code
2164 {
2165 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
2166 long l = sc->GetValue();
2167 value = l;
2168 return true;
2169 }
2170 @endcode
23324ae1 2171 */
64c70359 2172 virtual bool GetValueFromEditorCtrl(wxWindow* editor,
5b99d5d8 2173 wxVariant& value);
23324ae1
FM
2174
2175 /**
c4e57202 2176 Override this and make it return @true in order to
5b99d5d8 2177 indicate that this renderer supports in-place editing.
23324ae1 2178 */
220bfe15 2179 virtual bool HasEditorCtrl() const;
23324ae1
FM
2180
2181 /**
1c103099
RD
2182 Override this to react to a left click. This method will only be
2183 called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. This method is
2184 deprecated, please use ActivateCell instead.
23324ae1 2185 */
1c103099
RD
2186 virtual bool LeftClick( wxPoint cursor,
2187 wxRect cell,
5b99d5d8
RR
2188 wxDataViewModel * model,
2189 const wxDataViewItem & item,
2190 unsigned int col );
23324ae1 2191
1c103099
RD
2192 /**
2193 Override this to react to the activation of a cell. This method is
2194 deprecated, please use ActivateCell instead.
2195 */
2196 virtual bool Activate(wxRect cell,
2197 wxDataViewModel * model,
2198 const wxDataViewItem & item,
2199 unsigned int col);
2200
2201
23324ae1 2202 /**
c4e57202
FM
2203 Override this to render the cell.
2204 Before this is called, wxDataViewRenderer::SetValue was called
5b99d5d8 2205 so that this instance knows what to render.
23324ae1 2206 */
b91c4601 2207 virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
23324ae1
FM
2208
2209 /**
c4e57202
FM
2210 This method should be called from within Render() whenever you need to
2211 render simple text.
2212 This will ensure that the correct colour, font and vertical alignment will
2213 be chosen so the text will look the same as text drawn by native renderers.
23324ae1 2214 */
50ec54b6 2215 void RenderText(const wxString& text, int xoffset, wxRect cell,
5b99d5d8 2216 wxDC* dc, int state);
23324ae1
FM
2217
2218 /**
80093617 2219 Override this to start a drag operation. Not yet supported.
23324ae1 2220 */
548fa9c1
VS
2221 virtual bool StartDrag(const wxPoint& cursor,
2222 const wxRect& cell,
5b99d5d8
RR
2223 wxDataViewModel* model,
2224 const wxDataViewItem & item,
2225 unsigned int col);
4e15d1ca
RD
2226
2227protected:
2228 /**
2229 Helper for GetSize() implementations, respects attributes.
2230 */
2231 wxSize GetTextExtent(const wxString& str) const;
23324ae1
FM
2232};
2233
2234
e54c96f1 2235
23324ae1 2236/**
5b99d5d8 2237 @class wxDataViewBitmapRenderer
7c913512 2238
c4e57202 2239 This class is used by wxDataViewCtrl to render bitmap controls.
7c913512 2240
23324ae1 2241 @library{wxadv}
b321b61c 2242 @category{dvc}
23324ae1 2243*/
5b99d5d8 2244class wxDataViewBitmapRenderer : public wxDataViewRenderer
23324ae1
FM
2245{
2246public:
2247 /**
c4e57202 2248 The ctor.
23324ae1 2249 */
5b99d5d8
RR
2250 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
2251 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
14d922d1 2252 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8
RR
2253};
2254
23324ae1 2255
c4e57202
FM
2256/**
2257 The flags used by wxDataViewColumn.
02b51ae5 2258 Can be combined together.
c4e57202
FM
2259*/
2260enum wxDataViewColumnFlags
2261{
2262 wxDATAVIEW_COL_RESIZABLE = 1,
2263 wxDATAVIEW_COL_SORTABLE = 2,
2264 wxDATAVIEW_COL_REORDERABLE = 4,
2265 wxDATAVIEW_COL_HIDDEN = 8
2266};
23324ae1 2267
5b99d5d8
RR
2268/**
2269 @class wxDataViewColumn
5b99d5d8
RR
2270
2271 This class represents a column in a wxDataViewCtrl.
739a8399 2272 One wxDataViewColumn is bound to one column in the data model to which the
c4e57202 2273 wxDataViewCtrl has been associated.
5b99d5d8 2274
c4e57202 2275 An instance of wxDataViewRenderer is used by this class to render its data.
5b99d5d8
RR
2276
2277 @library{wxadv}
b321b61c 2278 @category{dvc}
5b99d5d8 2279*/
c9c59db7 2280class wxDataViewColumn : public wxSettableHeaderColumn
5b99d5d8
RR
2281{
2282public:
23324ae1 2283 /**
02b51ae5
FM
2284 Constructs a text column.
2285
2286 @param title
2287 The title of the column.
2288 @param renderer
2289 The class which will render the contents of this column.
2290 @param model_column
2291 The index of the model's column which is associated with this object.
2292 @param width
2293 The width of the column.
2294 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2295 @param align
2296 The alignment of the column title.
2297 @param flags
2298 One or more flags of the ::wxDataViewColumnFlags enumeration.
23324ae1 2299 */
5b99d5d8
RR
2300 wxDataViewColumn(const wxString& title,
2301 wxDataViewRenderer* renderer,
2302 unsigned int model_column,
2303 int width = wxDVC_DEFAULT_WIDTH,
882678eb 2304 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 2305 int flags = wxDATAVIEW_COL_RESIZABLE);
02b51ae5
FM
2306
2307 /**
2308 Constructs a bitmap column.
2309
2310 @param bitmap
2311 The bitmap of the column.
2312 @param renderer
2313 The class which will render the contents of this column.
2314 @param model_column
2315 The index of the model's column which is associated with this object.
2316 @param width
2317 The width of the column.
2318 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
2319 @param align
2320 The alignment of the column title.
2321 @param flags
2322 One or more flags of the ::wxDataViewColumnFlags enumeration.
2323 */
5b99d5d8
RR
2324 wxDataViewColumn(const wxBitmap& bitmap,
2325 wxDataViewRenderer* renderer,
2326 unsigned int model_column,
2327 int width = wxDVC_DEFAULT_WIDTH,
882678eb 2328 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 2329 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1 2330
23324ae1 2331 /**
5b99d5d8
RR
2332 Returns the index of the column of the model, which this
2333 wxDataViewColumn is displaying.
23324ae1 2334 */
adaaa686 2335 unsigned int GetModelColumn() const;
23324ae1
FM
2336
2337 /**
5b99d5d8 2338 Returns the owning wxDataViewCtrl.
23324ae1 2339 */
e51bf699 2340 wxDataViewCtrl* GetOwner() const;
23324ae1
FM
2341
2342 /**
5b99d5d8 2343 Returns the renderer of this wxDataViewColumn.
c4e57202
FM
2344
2345 @see wxDataViewRenderer.
23324ae1 2346 */
adaaa686 2347 wxDataViewRenderer* GetRenderer() const;
23324ae1
FM
2348};
2349
2350
e54c96f1 2351
832df171
RR
2352/**
2353 @class wxDataViewListCtrl
2354
2355 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
2356 and forwards most of its API to that class.
2357
2358 The purpose of this class is to offer a simple way to display and
2359 edit a small table of data without having to write your own wxDataViewModel.
2360
23efa4bf 2361 @code
14f73cf1 2362 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
02b51ae5 2363
95b20f41
RR
2364 listctrl->AppendToggleColumn( "Toggle" );
2365 listctrl->AppendTextColumn( "Text" );
02b51ae5 2366
23efa4bf 2367 wxVector<wxVariant> data;
14f73cf1
FM
2368 data.push_back( wxVariant(true) );
2369 data.push_back( wxVariant("row 1") );
23efa4bf 2370 listctrl->AppendItem( data );
02b51ae5 2371
23efa4bf 2372 data.clear();
14f73cf1
FM
2373 data.push_back( wxVariant(false) );
2374 data.push_back( wxVariant("row 3") );
23efa4bf
RR
2375 listctrl->AppendItem( data );
2376 @endcode
43c64cc6 2377
14f73cf1
FM
2378 @beginStyleTable
2379 See wxDataViewCtrl for the list of supported styles.
2380 @endStyleTable
43c64cc6 2381
14f73cf1
FM
2382 @beginEventEmissionTable
2383 See wxDataViewCtrl for the list of events emitted by this class.
2384 @endEventTable
23efa4bf 2385
832df171
RR
2386 @library{wxadv}
2387 @category{ctrl,dvc}
430b5963
VZ
2388
2389 @since 2.9.0
832df171 2390*/
832df171
RR
2391class wxDataViewListCtrl: public wxDataViewCtrl
2392{
b75b04d4 2393public:
832df171
RR
2394 /**
2395 Default ctor.
2396 */
2397 wxDataViewListCtrl();
02b51ae5 2398
832df171
RR
2399 /**
2400 Constructor. Calls Create().
2401 */
2402 wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
2403 const wxPoint& pos = wxDefaultPosition,
2404 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
2405 const wxValidator& validator = wxDefaultValidator );
02b51ae5 2406
832df171
RR
2407 /**
2408 Destructor. Deletes the image list if any.
2409 */
2410 ~wxDataViewListCtrl();
2411
2412 /**
2413 Creates the control and a wxDataViewListStore as its internal model.
2414 */
2415 bool Create( wxWindow *parent, wxWindowID id,
2416 const wxPoint& pos = wxDefaultPosition,
2417 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
2418 const wxValidator& validator = wxDefaultValidator );
2419
2420 //@{
2421 /**
2422 Returns the store.
2423 */
2424 wxDataViewListStore *GetStore();
2425 const wxDataViewListStore *GetStore() const;
2426 //@}
2427
17de95e4
VS
2428 /**
2429 Returns the position of given @e item or wxNOT_FOUND if it's
2430 not a valid item.
2431
2432 @since 2.9.2
2433 */
2434 int ItemToRow(const wxDataViewItem &item) const;
2435
2436 /**
2437 Returns the wxDataViewItem at the given @e row.
2438
2439 @since 2.9.2
2440 */
2441 wxDataViewItem RowToItem(int row) const;
2442
fa629ada
VS
2443 //@{
2444 /**
2445 @name Selection handling functions
2446 */
2447
2448 /**
2449 Returns index of the selected row or wxNOT_FOUND.
2450
2451 @see wxDataViewCtrl::GetSelection()
2452
2453 @since 2.9.2
2454 */
2455 int GetSelectedRow() const;
2456
2457 /**
2458 Selects given row.
2459
2460 @see wxDataViewCtrl::Select()
2461
2462 @since 2.9.2
2463 */
2464 void SelectRow(unsigned row);
2465
2466 /**
2467 Unselects given row.
2468
2469 @see wxDataViewCtrl::Unselect()
2470
2471 @since 2.9.2
2472 */
2473 void UnselectRow(unsigned row);
2474
2475 /**
2476 Returns true if @a row is selected.
2477
2478 @see wxDataViewCtrl::IsSelected()
2479
2480 @since 2.9.2
2481 */
2482 bool IsRowSelected(unsigned row) const;
2483
2484 //@}
2485
832df171 2486 /**
14f73cf1
FM
2487 @name Column management functions
2488 */
2489 //@{
43c64cc6 2490
14f73cf1
FM
2491 /**
2492 Appends a column to the control and additionally appends a
2493 column to the store with the type string.
2494 */
2ccd2adc 2495 virtual bool AppendColumn( wxDataViewColumn *column );
14f73cf1
FM
2496
2497 /**
2498 Appends a column to the control and additionally appends a
2499 column to the list store with the type @a varianttype.
832df171 2500 */
95b20f41 2501 void AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 2502
832df171 2503 /**
14f73cf1 2504 Appends a text column to the control and the store.
43c64cc6 2505
14f73cf1
FM
2506 See wxDataViewColumn::wxDataViewColumn for more info about
2507 the parameters.
832df171 2508 */
14f73cf1
FM
2509 wxDataViewColumn *AppendTextColumn( const wxString &label,
2510 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2511 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2512 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2513
832df171 2514 /**
14f73cf1 2515 Appends a toggle column to the control and the store.
43c64cc6 2516
14f73cf1
FM
2517 See wxDataViewColumn::wxDataViewColumn for more info about
2518 the parameters.
832df171 2519 */
14f73cf1
FM
2520 wxDataViewColumn *AppendToggleColumn( const wxString &label,
2521 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
43c64cc6 2522 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2523 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2524
95b20f41 2525 /**
14f73cf1 2526 Appends a progress column to the control and the store.
02b51ae5 2527
14f73cf1
FM
2528 See wxDataViewColumn::wxDataViewColumn for more info about
2529 the parameters.
95b20f41 2530 */
14f73cf1
FM
2531 wxDataViewColumn *AppendProgressColumn( const wxString &label,
2532 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2533 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2534 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2535
95b20f41 2536 /**
14f73cf1 2537 Appends an icon-and-text column to the control and the store.
02b51ae5 2538
14f73cf1
FM
2539 See wxDataViewColumn::wxDataViewColumn for more info about
2540 the parameters.
95b20f41 2541 */
14f73cf1
FM
2542 wxDataViewColumn *AppendIconTextColumn( const wxString &label,
2543 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
43c64cc6 2544 int width = -1, wxAlignment align = wxALIGN_LEFT,
14f73cf1 2545 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 2546
95b20f41 2547 /**
14f73cf1 2548 Inserts a column to the control and additionally inserts a
95b20f41
RR
2549 column to the store with the type string.
2550 */
2ccd2adc 2551 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *column );
02b51ae5 2552
832df171 2553 /**
14f73cf1
FM
2554 Inserts a column to the control and additionally inserts a
2555 column to the list store with the type @a varianttype.
832df171 2556 */
43c64cc6 2557 void InsertColumn( unsigned int pos, wxDataViewColumn *column,
14f73cf1 2558 const wxString &varianttype );
02b51ae5 2559
832df171 2560 /**
14f73cf1
FM
2561 Prepends a column to the control and additionally prepends a
2562 column to the store with the type string.
832df171 2563 */
2ccd2adc 2564 virtual bool PrependColumn( wxDataViewColumn *column );
02b51ae5 2565
832df171 2566 /**
14f73cf1
FM
2567 Prepends a column to the control and additionally prepends a
2568 column to the list store with the type @a varianttype.
832df171 2569 */
14f73cf1 2570 void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 2571
14f73cf1 2572 //@}
43c64cc6
VZ
2573
2574
832df171 2575 /**
14f73cf1 2576 @name Item management functions
832df171 2577 */
14f73cf1 2578 //@{
43c64cc6 2579
832df171
RR
2580 /**
2581 Appends an item (=row) to the control and store.
2582 */
41abc29a 2583 void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
832df171
RR
2584
2585 /**
2586 Prepends an item (=row) to the control and store.
2587 */
41abc29a 2588 void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
832df171
RR
2589
2590 /**
2591 Inserts an item (=row) to the control and store.
2592 */
41abc29a 2593 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2594
832df171
RR
2595 /**
2596 Delete the row at position @a row.
2597 */
2598 void DeleteItem( unsigned row );
02b51ae5 2599
832df171
RR
2600 /**
2601 Delete all items (= all rows).
2602 */
2603 void DeleteAllItems();
02b51ae5 2604
5fb4b6cd
VZ
2605 /**
2606 Returns the number of items (=rows) in the control
2607
2608 @since 2.9.4
2609 */
2610 unsigned int GetItemCount() const;
2611
518cef04
VZ
2612 /**
2613 Returns the client data associated with the item.
2614
2615 @see SetItemData()
2616
2617 @since 2.9.4
2618 */
2619 wxUIntPtr GetItemData(const wxDataViewItem& item) const;
2620
832df171
RR
2621 /**
2622 Sets the value in the store and update the control.
2623 */
2624 void SetValue( const wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 2625
832df171
RR
2626 /**
2627 Returns the value from the store.
2628 */
2629 void GetValue( wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 2630
832df171 2631 /**
02b51ae5
FM
2632 Sets the value in the store and update the control.
2633
57ab6f23 2634 This method assumes that the string is stored in respective
832df171
RR
2635 column.
2636 */
2637 void SetTextValue( const wxString &value, unsigned int row, unsigned int col );
02b51ae5 2638
832df171
RR
2639 /**
2640 Returns the value from the store.
02b51ae5 2641
57ab6f23 2642 This method assumes that the string is stored in respective
832df171
RR
2643 column.
2644 */
2645 wxString GetTextValue( unsigned int row, unsigned int col ) const;
02b51ae5 2646
832df171 2647 /**
02b51ae5
FM
2648 Sets the value in the store and update the control.
2649
57ab6f23 2650 This method assumes that the boolean value is stored in
832df171
RR
2651 respective column.
2652 */
2653 void SetToggleValue( bool value, unsigned int row, unsigned int col );
02b51ae5 2654
832df171
RR
2655 /**
2656 Returns the value from the store.
02b51ae5 2657
57ab6f23 2658 This method assumes that the boolean value is stored in
832df171
RR
2659 respective column.
2660 */
2661 bool GetToggleValue( unsigned int row, unsigned int col ) const;
43c64cc6 2662
518cef04
VZ
2663 /**
2664 Associates a client data pointer with the given item.
2665
2666 Notice that the control does @e not take ownership of the pointer for
2667 compatibility with wxListCtrl. I.e. it will @e not delete the pointer
2668 (if it is a pointer and not a number) itself, it is up to you to do it.
2669
2670 @see GetItemData()
2671
2672 @since 2.9.4
2673 */
2674 void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
2675
14f73cf1 2676 //@}
832df171
RR
2677};
2678
2679
23324ae1 2680/**
5b99d5d8 2681 @class wxDataViewTreeCtrl
7c913512 2682
c4e57202
FM
2683 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
2684 and forwards most of its API to that class.
2685 Additionally, it uses a wxImageList to store a list of icons.
2686
43c64cc6
VZ
2687 The main purpose of this class is to provide a simple upgrade path for code
2688 using wxTreeCtrl.
14f73cf1
FM
2689
2690 @beginStyleTable
2691 See wxDataViewCtrl for the list of supported styles.
2692 @endStyleTable
43c64cc6 2693
14f73cf1
FM
2694 @beginEventEmissionTable
2695 See wxDataViewCtrl for the list of events emitted by this class.
2696 @endEventTable
7c913512 2697
8ed522d9 2698 @library{wxadv}
b321b61c 2699 @category{ctrl,dvc}
430b5963
VZ
2700
2701 @since 2.9.0
2702
ce154616 2703 @appearance{dataviewtreectrl}
23324ae1 2704*/
5b99d5d8 2705class wxDataViewTreeCtrl : public wxDataViewCtrl
23324ae1
FM
2706{
2707public:
2708 /**
c4e57202 2709 Default ctor.
5b99d5d8
RR
2710 */
2711 wxDataViewTreeCtrl();
c4e57202
FM
2712
2713 /**
43c64cc6
VZ
2714 Constructor.
2715
2716 Calls Create().
c4e57202 2717 */
5b99d5d8
RR
2718 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
2719 const wxPoint& pos = wxDefaultPosition,
2720 const wxSize& size = wxDefaultSize,
43c64cc6 2721 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
5b99d5d8 2722 const wxValidator& validator = wxDefaultValidator);
3c4f71cc 2723
5b99d5d8
RR
2724 /**
2725 Destructor. Deletes the image list if any.
23324ae1 2726 */
adaaa686 2727 virtual ~wxDataViewTreeCtrl();
23324ae1 2728
5b99d5d8 2729 /**
b75b04d4 2730 Appends a container to the given @a parent.
5b99d5d8
RR
2731 */
2732 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
2733 const wxString& text,
2734 int icon = -1,
2735 int expanded = -1,
2736 wxClientData* data = NULL);
e54c96f1 2737
5b99d5d8 2738 /**
b75b04d4 2739 Appends an item to the given @a parent.
5b99d5d8
RR
2740 */
2741 wxDataViewItem AppendItem(const wxDataViewItem& parent,
2742 const wxString& text,
2743 int icon = -1,
2744 wxClientData* data = NULL);
7c913512 2745
5b99d5d8 2746 /**
c4e57202 2747 Creates the control and a wxDataViewTreeStore as its internal model.
43c64cc6
VZ
2748
2749 The default tree column created by this method is an editable column
2750 using wxDataViewIconTextRenderer as its renderer.
5b99d5d8
RR
2751 */
2752 bool Create(wxWindow* parent, wxWindowID id,
2753 const wxPoint& pos = wxDefaultPosition,
2754 const wxSize& size = wxDefaultSize,
43c64cc6 2755 long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
5b99d5d8
RR
2756 const wxValidator& validator = wxDefaultValidator);
2757
2758 /**
2759 Calls the identical method from wxDataViewTreeStore.
2760 */
2761 void DeleteAllItems();
7c913512 2762
23324ae1 2763 /**
5b99d5d8
RR
2764 Calls the identical method from wxDataViewTreeStore.
2765 */
2766 void DeleteChildren(const wxDataViewItem& item);
3c4f71cc 2767
5b99d5d8
RR
2768 /**
2769 Calls the identical method from wxDataViewTreeStore.
23324ae1 2770 */
5b99d5d8 2771 void DeleteItem(const wxDataViewItem& item);
23324ae1 2772
5b99d5d8
RR
2773 /**
2774 Calls the identical method from wxDataViewTreeStore.
2775 */
2776 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1 2777
5b99d5d8
RR
2778 /**
2779 Returns the image list.
2780 */
2781 wxImageList* GetImageList();
05303ccd 2782
5b99d5d8
RR
2783 /**
2784 Calls the identical method from wxDataViewTreeStore.
2785 */
2786 wxClientData* GetItemData(const wxDataViewItem& item) const;
05303ccd 2787
5b99d5d8
RR
2788 /**
2789 Calls the identical method from wxDataViewTreeStore.
2790 */
b91c4601 2791 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
05303ccd 2792
05303ccd 2793 /**
5b99d5d8 2794 Calls the identical method from wxDataViewTreeStore.
05303ccd 2795 */
b91c4601 2796 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
05303ccd
RR
2797
2798 /**
5b99d5d8 2799 Calls the identical method from wxDataViewTreeStore.
05303ccd 2800 */
5b99d5d8
RR
2801 wxString GetItemText(const wxDataViewItem& item) const;
2802
2803 /**
2804 Calls the identical method from wxDataViewTreeStore.
2805 */
2806 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
2807 unsigned int pos) const;
05303ccd 2808
5b99d5d8 2809 //@{
05303ccd 2810 /**
5b99d5d8 2811 Returns the store.
05303ccd 2812 */
882678eb 2813 wxDataViewTreeStore* GetStore();
5b99d5d8
RR
2814 const wxDataViewTreeStore* GetStore() const;
2815 //@}
05303ccd
RR
2816
2817 /**
c4e57202
FM
2818 Calls the same method from wxDataViewTreeStore but uses
2819 an index position in the image list instead of a wxIcon.
05303ccd 2820 */
5b99d5d8
RR
2821 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
2822 const wxDataViewItem& previous,
2823 const wxString& text,
2824 int icon = -1,
2825 int expanded = -1,
2826 wxClientData* data = NULL);
05303ccd
RR
2827
2828 /**
c4e57202
FM
2829 Calls the same method from wxDataViewTreeStore but uses
2830 an index position in the image list instead of a wxIcon.
05303ccd 2831 */
5b99d5d8
RR
2832 wxDataViewItem InsertItem(const wxDataViewItem& parent,
2833 const wxDataViewItem& previous,
2834 const wxString& text,
2835 int icon = -1,
2836 wxClientData* data = NULL);
05303ccd 2837
8ddda15b
RR
2838 /**
2839 Returns true if item is a container.
2840 */
2841 bool IsContainer( const wxDataViewItem& item );
2842
05303ccd 2843 /**
c4e57202
FM
2844 Calls the same method from wxDataViewTreeStore but uses
2845 an index position in the image list instead of a wxIcon.
05303ccd 2846 */
5b99d5d8
RR
2847 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
2848 const wxString& text,
2849 int icon = -1,
2850 int expanded = -1,
2851 wxClientData* data = NULL);
05303ccd
RR
2852
2853 /**
c4e57202
FM
2854 Calls the same method from wxDataViewTreeStore but uses
2855 an index position in the image list instead of a wxIcon.
05303ccd 2856 */
5b99d5d8
RR
2857 wxDataViewItem PrependItem(const wxDataViewItem& parent,
2858 const wxString& text,
2859 int icon = -1,
2860 wxClientData* data = NULL);
05303ccd
RR
2861
2862 /**
5b99d5d8 2863 Sets the image list.
05303ccd 2864 */
5b99d5d8 2865 void SetImageList(wxImageList* imagelist);
05303ccd
RR
2866
2867 /**
5b99d5d8 2868 Calls the identical method from wxDataViewTreeStore.
05303ccd 2869 */
5b99d5d8 2870 void SetItemData(const wxDataViewItem& item, wxClientData* data);
05303ccd
RR
2871
2872 /**
5b99d5d8 2873 Calls the identical method from wxDataViewTreeStore.
05303ccd 2874 */
5b99d5d8
RR
2875 void SetItemExpandedIcon(const wxDataViewItem& item,
2876 const wxIcon& icon);
05303ccd
RR
2877
2878 /**
5b99d5d8 2879 Calls the identical method from wxDataViewTreeStore.
05303ccd 2880 */
5b99d5d8 2881 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
05303ccd
RR
2882
2883 /**
5b99d5d8 2884 Calls the identical method from wxDataViewTreeStore.
05303ccd 2885 */
5b99d5d8
RR
2886 void SetItemText(const wxDataViewItem& item,
2887 const wxString& text);
05303ccd
RR
2888};
2889
2890
bda698ed
RR
2891/**
2892 @class wxDataViewListStore
2893
2894 wxDataViewListStore is a specialised wxDataViewModel for storing
2895 a simple table of data. Since it derives from wxDataViewIndexListModel
2896 its data is be accessed by row (i.e. by index) instead of only
2897 by wxDataViewItem.
2898
02b51ae5 2899 This class actually stores the values (therefore its name)
bda698ed 2900 and implements all virtual methods from the base classes so it can be
02b51ae5 2901 used directly without having to derive any class from it, but it is
bda698ed
RR
2902 mostly used from within wxDataViewListCtrl.
2903
2904 @library{wxadv}
2905 @category{dvc}
2906*/
2907
2908class wxDataViewListStore: public wxDataViewIndexListModel
2909{
2910public:
2911 /**
02b51ae5 2912 Constructor
bda698ed
RR
2913 */
2914 wxDataViewListStore();
02b51ae5 2915
bda698ed 2916 /**
02b51ae5 2917 Destructor
bda698ed
RR
2918 */
2919 ~wxDataViewListStore();
2920
2921 /**
02b51ae5
FM
2922 Prepends a data column.
2923
2924 @a variantype indicates the type of values store in the column.
2925
2926 This does not automatically fill in any (default) values in
2927 rows which exist in the store already.
bda698ed
RR
2928 */
2929 void PrependColumn( const wxString &varianttype );
2930
2931 /**
02b51ae5
FM
2932 Inserts a data column before @a pos.
2933
2934 @a variantype indicates the type of values store in the column.
2935
2936 This does not automatically fill in any (default) values in
2937 rows which exist in the store already.
bda698ed
RR
2938 */
2939 void InsertColumn( unsigned int pos, const wxString &varianttype );
2940
2941 /**
02b51ae5
FM
2942 Appends a data column.
2943
2944 @a variantype indicates the type of values store in the column.
2945
2946 This does not automatically fill in any (default) values in
2947 rows which exist in the store already.
bda698ed
RR
2948 */
2949 void AppendColumn( const wxString &varianttype );
02b51ae5 2950
bda698ed
RR
2951 /**
2952 Appends an item (=row) and fills it with @a values.
02b51ae5 2953
bda698ed
RR
2954 The values must match the values specifies in the column
2955 in number and type. No (default) values are filled in
2956 automatically.
2957 */
41abc29a 2958 void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2959
bda698ed
RR
2960 /**
2961 Prepends an item (=row) and fills it with @a values.
02b51ae5 2962
bda698ed
RR
2963 The values must match the values specifies in the column
2964 in number and type. No (default) values are filled in
2965 automatically.
2966 */
41abc29a 2967 void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2968
bda698ed
RR
2969 /**
2970 Inserts an item (=row) and fills it with @a values.
02b51ae5 2971
bda698ed
RR
2972 The values must match the values specifies in the column
2973 in number and type. No (default) values are filled in
2974 automatically.
2975 */
41abc29a 2976 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
02b51ae5 2977
bda698ed
RR
2978 /**
2979 Delete the item (=row) at position @a pos.
2980 */
2981 void DeleteItem( unsigned pos );
02b51ae5 2982
bda698ed
RR
2983 /**
2984 Delete all item (=all rows) in the store.
2985 */
2986 void DeleteAllItems();
2987
5fb4b6cd
VZ
2988 /**
2989 Returns the number of items (=rows) in the control
2990
2991 @since 2.9.4
2992 */
2993 unsigned int GetItemCount() const;
2994
518cef04
VZ
2995 /**
2996 Returns the client data associated with the item.
2997
2998 @see SetItemData()
2999
3000 @since 2.9.4
3001 */
3002 wxUIntPtr GetItemData(const wxDataViewItem& item) const;
3003
bda698ed 3004 /**
57ab6f23 3005 Overridden from wxDataViewModel
bda698ed
RR
3006 */
3007 virtual unsigned int GetColumnCount() const;
3008
3009 /**
57ab6f23 3010 Overridden from wxDataViewModel
bda698ed
RR
3011 */
3012 virtual wxString GetColumnType( unsigned int col ) const;
3013
518cef04
VZ
3014 /**
3015 Sets the client data associated with the item.
3016
3017 Notice that this class does @e not take ownership of the passed in
3018 pointer and will not delete it.
3019
3020 @see GetItemData()
3021
3022 @since 2.9.4
3023 */
3024 void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
3025
bda698ed 3026 /**
57ab6f23 3027 Overridden from wxDataViewIndexListModel
bda698ed
RR
3028 */
3029 virtual void GetValueByRow( wxVariant &value,
3030 unsigned int row, unsigned int col ) const;
3031
3032 /**
57ab6f23 3033 Overridden from wxDataViewIndexListModel
bda698ed
RR
3034 */
3035 virtual bool SetValueByRow( const wxVariant &value,
3036 unsigned int row, unsigned int col );
3037};
3038
05303ccd
RR
3039
3040/**
5b99d5d8 3041 @class wxDataViewTreeStore
05303ccd 3042
57ab6f23 3043 wxDataViewTreeStore is a specialised wxDataViewModel for storing simple
c4e57202
FM
3044 trees very much like wxTreeCtrl does and it offers a similar API.
3045
02b51ae5 3046 This class actually stores the entire tree and the values (therefore its name)
8eff6c56 3047 and implements all virtual methods from the base class so it can be used directly
bda698ed
RR
3048 without having to derive any class from it, but it is mostly used from within
3049 wxDataViewTreeCtrl.
05303ccd
RR
3050
3051 @library{wxadv}
b321b61c 3052 @category{dvc}
05303ccd 3053*/
5b99d5d8 3054class wxDataViewTreeStore : public wxDataViewModel
05303ccd
RR
3055{
3056public:
3057 /**
5b99d5d8 3058 Constructor. Creates the invisible root node internally.
05303ccd 3059 */
5b99d5d8 3060 wxDataViewTreeStore();
e54c96f1 3061
5b99d5d8
RR
3062 /**
3063 Destructor.
3064 */
adaaa686 3065 virtual ~wxDataViewTreeStore();
7c913512 3066
5b99d5d8
RR
3067 /**
3068 Append a container.
3069 */
3070 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
3071 const wxString& text,
3072 const wxIcon& icon = wxNullIcon,
3073 const wxIcon& expanded = wxNullIcon,
3074 wxClientData* data = NULL);
7c913512 3075
5b99d5d8
RR
3076 /**
3077 Append an item.
3078 */
3079 wxDataViewItem AppendItem(const wxDataViewItem& parent,
3080 const wxString& text,
3081 const wxIcon& icon = wxNullIcon,
3082 wxClientData* data = NULL);
7c913512 3083
23324ae1 3084 /**
5b99d5d8 3085 Delete all item in the model.
23324ae1 3086 */
5b99d5d8 3087 void DeleteAllItems();
23324ae1
FM
3088
3089 /**
5b99d5d8 3090 Delete all children of the item, but not the item itself.
23324ae1 3091 */
5b99d5d8 3092 void DeleteChildren(const wxDataViewItem& item);
23324ae1
FM
3093
3094 /**
5b99d5d8 3095 Delete this item.
23324ae1 3096 */
5b99d5d8 3097 void DeleteItem(const wxDataViewItem& item);
23324ae1
FM
3098
3099 /**
5b99d5d8 3100 Return the number of children of item.
23324ae1 3101 */
5b99d5d8 3102 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1
FM
3103
3104 /**
57ab6f23 3105 Returns the client data associated with the item.
23324ae1 3106 */
5b99d5d8 3107 wxClientData* GetItemData(const wxDataViewItem& item) const;
23324ae1
FM
3108
3109 /**
5b99d5d8 3110 Returns the icon to display in expanded containers.
23324ae1 3111 */
b91c4601 3112 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
23324ae1
FM
3113
3114 /**
5b99d5d8 3115 Returns the icon of the item.
23324ae1 3116 */
b91c4601 3117 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
23324ae1
FM
3118
3119 /**
5b99d5d8 3120 Returns the text of the item.
23324ae1 3121 */
5b99d5d8 3122 wxString GetItemText(const wxDataViewItem& item) const;
23324ae1
FM
3123
3124 /**
5b99d5d8 3125 Returns the nth child item of item.
23324ae1 3126 */
5b99d5d8
RR
3127 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
3128 unsigned int pos) const;
23324ae1
FM
3129
3130 /**
c4e57202 3131 Inserts a container after @a previous.
23324ae1 3132 */
5b99d5d8
RR
3133 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
3134 const wxDataViewItem& previous,
3135 const wxString& text,
3136 const wxIcon& icon = wxNullIcon,
3137 const wxIcon& expanded = wxNullIcon,
3138 wxClientData* data = NULL);
23324ae1
FM
3139
3140 /**
c4e57202 3141 Inserts an item after @a previous.
23324ae1 3142 */
5b99d5d8
RR
3143 wxDataViewItem InsertItem(const wxDataViewItem& parent,
3144 const wxDataViewItem& previous,
3145 const wxString& text,
3146 const wxIcon& icon = wxNullIcon,
3147 wxClientData* data = NULL);
23324ae1
FM
3148
3149 /**
c4e57202 3150 Inserts a container before the first child item or @a parent.
23324ae1 3151 */
5b99d5d8
RR
3152 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
3153 const wxString& text,
3154 const wxIcon& icon = wxNullIcon,
3155 const wxIcon& expanded = wxNullIcon,
3156 wxClientData* data = NULL);
23324ae1
FM
3157
3158 /**
c4e57202 3159 Inserts an item before the first child item or @a parent.
23324ae1 3160 */
5b99d5d8
RR
3161 wxDataViewItem PrependItem(const wxDataViewItem& parent,
3162 const wxString& text,
3163 const wxIcon& icon = wxNullIcon,
3164 wxClientData* data = NULL);
23324ae1
FM
3165
3166 /**
5b99d5d8 3167 Sets the client data associated with the item.
23324ae1 3168 */
5b99d5d8 3169 void SetItemData(const wxDataViewItem& item, wxClientData* data);
23324ae1
FM
3170
3171 /**
5b99d5d8 3172 Sets the expanded icon for the item.
23324ae1 3173 */
5b99d5d8
RR
3174 void SetItemExpandedIcon(const wxDataViewItem& item,
3175 const wxIcon& icon);
23324ae1
FM
3176
3177 /**
5b99d5d8 3178 Sets the icon for the item.
23324ae1 3179 */
5b99d5d8 3180 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
23324ae1 3181};
e54c96f1 3182
80932a3e
FM
3183
3184/**
3185 @class wxDataViewIconText
3186
3187 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
3188 This class can be converted to and from a wxVariant.
3189
3190 @library{wxadv}
3191 @category{dvc}
3192*/
3193class wxDataViewIconText : public wxObject
3194{
3195public:
3196 //@{
3197 /**
3198 Constructor.
3199 */
3200 wxDataViewIconText(const wxString& text = wxEmptyString,
3201 const wxIcon& icon = wxNullIcon);
3202 wxDataViewIconText(const wxDataViewIconText& other);
3203 //@}
3204
3205 /**
3206 Gets the icon.
3207 */
3208 const wxIcon& GetIcon() const;
3209
3210 /**
3211 Gets the text.
3212 */
3213 wxString GetText() const;
3214
3215 /**
3216 Set the icon.
3217 */
3218 void SetIcon(const wxIcon& icon);
3219
3220 /**
3221 Set the text.
3222 */
3223 void SetText(const wxString& text);
3224};
3225
3226
3227
3228/**
3229 @class wxDataViewEvent
3230
3231 This is the event class for the wxDataViewCtrl notifications.
3232
14f73cf1
FM
3233 @beginEventTable{wxDataViewEvent}
3234 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
ce7fe42e 3235 Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
14f73cf1 3236 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
ce7fe42e 3237 Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event.
14f73cf1 3238 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
ce7fe42e 3239 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
14f73cf1 3240 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
ce7fe42e 3241 Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
14f73cf1 3242 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
ce7fe42e 3243 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
14f73cf1 3244 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
ce7fe42e 3245 Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
14f73cf1 3246 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
ce7fe42e 3247 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
14f73cf1 3248 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
ce7fe42e 3249 Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
14f73cf1 3250 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
ce7fe42e 3251 Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
14f73cf1 3252 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
ce7fe42e 3253 Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event.
14f73cf1 3254 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
ce7fe42e 3255 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
14f73cf1 3256 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
3bc1418b 3257 Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
14f73cf1 3258 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
ce7fe42e 3259 Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
14f73cf1 3260 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
ce7fe42e 3261 Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
5e4027e5
VZ
3262 Currently this even is only generated when using the native OSX
3263 version.
14f73cf1 3264 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
ce7fe42e 3265 Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
14f73cf1 3266 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
ce7fe42e 3267 Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
14f73cf1 3268 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
ce7fe42e 3269 Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
47a8b1e1 3270 @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
ce7fe42e 3271 Process a @c wxEVT_DATAVIEW_CACHE_HINT event.
14f73cf1 3272 @endEventTable
43c64cc6 3273
80932a3e
FM
3274 @library{wxadv}
3275 @category{events,dvc}
3276*/
3277class wxDataViewEvent : public wxNotifyEvent
3278{
3279public:
80932a3e
FM
3280 /**
3281 Constructor. Typically used by wxWidgets internals only.
3282 */
3283 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
3284 int winid = 0);
80932a3e
FM
3285
3286 /**
3287 Returns the position of the column in the control or -1
3288 if no column field was set by the event emitter.
3289 */
3290 int GetColumn() const;
3291
3292 /**
3293 Returns a pointer to the wxDataViewColumn from which
3294 the event was emitted or @NULL.
3295 */
3296 wxDataViewColumn* GetDataViewColumn() const;
3297
3298 /**
3299 Returns the wxDataViewModel associated with the event.
3300 */
3301 wxDataViewModel* GetModel() const;
3302
3303 /**
57ab6f23 3304 Returns the position of a context menu event in screen coordinates.
80932a3e
FM
3305 */
3306 wxPoint GetPosition() const;
3307
3308 /**
3309 Returns a reference to a value.
3310 */
3311 const wxVariant& GetValue() const;
3312
2a648479
VZ
3313 /**
3314 Can be used to determine whether the new value is going to be accepted
ce7fe42e 3315 in wxEVT_DATAVIEW_ITEM_EDITING_DONE handler.
2a648479
VZ
3316
3317 Returns @true if editing the item was cancelled or if the user tried to
3318 enter an invalid value (refused by wxDataViewRenderer::Validate()). If
3319 this method returns @false, it means that the value in the model is
3320 about to be changed to the new one.
3321
ce7fe42e 3322 Notice that wxEVT_DATAVIEW_ITEM_EDITING_DONE event handler can
2a648479
VZ
3323 call wxNotifyEvent::Veto() to prevent this from happening.
3324
3325 Currently support for setting this field and for vetoing the change is
3326 only available in the generic version of wxDataViewCtrl, i.e. under MSW
3327 but not GTK nor OS X.
3328
3329 @since 2.9.3
3330 */
3331 bool IsEditCancelled() const;
3332
80932a3e
FM
3333 /**
3334 Sets the column index associated with this event.
3335 */
3336 void SetColumn(int col);
3337
3338 /**
2392b8e8 3339 For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK only.
80932a3e
FM
3340 */
3341 void SetDataViewColumn(wxDataViewColumn* col);
3342
3343 /**
3344 Sets the dataview model associated with this event.
3345 */
3346 void SetModel(wxDataViewModel* model);
3347
3348 /**
3349 Sets the value associated with this event.
3350 */
3351 void SetValue(const wxVariant& value);
02b51ae5 3352
591cc82d 3353 /**
e4de825e 3354 Set wxDataObject for data transfer within a drag operation.
591cc82d
RR
3355 */
3356 void SetDataObject( wxDataObject *obj );
02b51ae5 3357
e4de825e
RR
3358 /**
3359 Gets the wxDataFormat during a drop operation.
3360 */
3361 wxDataFormat GetDataFormat() const;
02b51ae5 3362
e4de825e
RR
3363 /**
3364 Gets the data size for a drop data transfer.
3365 */
3366 size_t GetDataSize() const;
02b51ae5 3367
e4de825e
RR
3368 /**
3369 Gets the data buffer for a drop data transfer.
591cc82d 3370 */
e4de825e 3371 void *GetDataBuffer() const;
47a8b1e1 3372
c04be1a2
VZ
3373 /**
3374 Specify the kind of the drag operation to perform.
3375
ce7fe42e 3376 This method can be used inside a wxEVT_DATAVIEW_ITEM_BEGIN_DRAG
c04be1a2
VZ
3377 handler in order to configure the drag operation. Valid values are
3378 ::wxDrag_CopyOnly (default), ::wxDrag_AllowMove (allow the data to be
3379 moved) and ::wxDrag_DefaultMove.
3380
3381 Currently it is only honoured by the generic version of wxDataViewCtrl
3382 (used e.g. under MSW) and not supported by the native GTK and OS X
3383 versions.
3384
3385 @see GetDropEffect()
3386
3387 @since 2.9.4
3388 */
3389 void SetDragFlags(int flags);
3390
3391 /**
3392 Returns the effect the user requested to happen to the dropped data.
3393
3394 This function can be used inside
ce7fe42e
VZ
3395 wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE and
3396 wxEVT_DATAVIEW_ITEM_DROP handlers and returns whether the user
c04be1a2
VZ
3397 is trying to copy (the return value is ::wxDragCopy) or move (if the
3398 return value is ::wxDragMove) the data.
3399
3400 Currently this is only available when using the generic version of
3401 wxDataViewCtrl (used e.g. under MSW) and always returns ::wxDragNone in
3402 the GTK and OS X native versions.
3403
3404 @since 2.9.4
3405 */
3406 wxDragResult GetDropEffect() const;
3407
47a8b1e1
VZ
3408 /**
3409 Return the first row that will be displayed.
3410 */
3411 int GetCacheFrom() const;
3412
3413 /**
3414 Return the last row that will be displayed.
3415 */
3416 int GetCacheTo() const;
4e15d1ca
RD
3417
3418
3419
3420
3421 wxDataViewItem GetItem() const;
3422 void SetItem( const wxDataViewItem &item );
3423 void SetEditCanceled(bool editCancelled);
3424 void SetPosition( int x, int y );
3425 void SetCache(int from, int to);
3426 wxDataObject *GetDataObject() const;
3427 void SetDataFormat( const wxDataFormat &format );
3428 void SetDataSize( size_t size );
3429 void SetDataBuffer( void* buf );
3430 int GetDragFlags() const;
3431 void SetDropEffect( wxDragResult effect );
3432
80932a3e
FM
3433};
3434