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