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