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