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