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