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