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