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