]> git.saurik.com Git - wxWidgets.git/blob - interface/dataview.h
compilo
[wxWidgets.git] / interface / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dataview.h
3 // Purpose: interface of wxDataViewIconText
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxDataViewIconText
11 @wxheader{dataview.h}
12
13 wxDataViewIconText is used by
14 wxDataViewIconTextRenderer
15 for data transfer. This class can be converted to a from
16 a wxVariant.
17
18 @library{wxbase}
19 @category{FIXME}
20 */
21 class wxDataViewIconText : public wxObject
22 {
23 public:
24 //@{
25 /**
26 Constructor.
27 */
28 wxDataViewIconText(const wxString& text = wxEmptyString,
29 const wxIcon& icon = wxNullIcon);
30 wxDataViewIconText(const wxDataViewIconText& other);
31 //@}
32
33 /**
34 Gets the icon.
35 */
36 const wxIcon GetIcon() const;
37
38 /**
39 Gets the text.
40 */
41 wxString GetText() const;
42
43 /**
44 Set the icon.
45 */
46 void SetIcon(const wxIcon& icon);
47
48 /**
49 Set the text.
50 */
51 void SetText(const wxString& text);
52 };
53
54
55
56 /**
57 @class wxDataViewEvent
58 @wxheader{dataview.h}
59
60 wxDataViewEvent - the event class for the wxDataViewCtrl notifications
61
62 @library{wxadv}
63 @category{FIXME}
64 */
65 class wxDataViewEvent : public wxNotifyEvent
66 {
67 public:
68 //@{
69 /**
70
71 */
72 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
73 int winid = 0);
74 wxDataViewEvent(const wxDataViewEvent& event);
75 //@}
76
77 /**
78 Used to clone the event.
79 */
80 wxEvent* Clone() const;
81
82 /**
83 Returns the position of the column in the control or -1
84 if no column field was set by the event emitter.
85 */
86 int GetColumn() const;
87
88 /**
89 Returns a pointer to the wxDataViewColumn from which
90 the event was emitted or @NULL.
91 */
92 wxDataViewColumn* GetDataViewColumn();
93
94 /**
95 Returns the wxDataViewModel associated with the event.
96 */
97 wxDataViewModel* GetModel() const;
98
99 /**
100 Returns a the position of a context menu event in screen coordinates.
101 */
102 wxPoint GetPosition() const;
103
104 /**
105 Returns a reference to a value.
106 */
107 const wxVariant GetValue() const;
108
109 /**
110
111 */
112 void SetColumn(int col);
113
114 /**
115 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
116 */
117 void SetDataViewColumn(wxDataViewColumn* col);
118
119 /**
120
121 */
122 void SetModel(wxDataViewModel* model);
123
124 /**
125
126 */
127 void SetValue(const wxVariant& value);
128 };
129
130
131
132 /**
133 @class wxDataViewIconTextRenderer
134 @wxheader{dataview.h}
135
136 The wxDataViewIconTextRenderer class is used to display text with
137 a small icon next to it as it is typically done in a file manager.
138 This classes uses the wxDataViewIconText
139 helper class to store its data. wxDataViewIonText can be converted
140 to a from a wxVariant using the left shift
141 operator.
142
143 @library{wxadv}
144 @category{FIXME}
145 */
146 class wxDataViewIconTextRenderer : public wxDataViewRenderer
147 {
148 public:
149 /**
150
151 */
152 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
153 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT);
154 };
155
156
157
158 /**
159 @class wxDataViewIndexListModel
160 @wxheader{dataview.h}
161
162 wxDataViewIndexListModel is a specialized data model which lets
163 you address an item by its position (row) rather than its
164 wxDataViewItem (which you can obtain from this class).
165 This model also provides its own
166 wxDataViewIndexListModel::Compare method
167 which sorts the model's data by the index.
168
169 This model is special in the it is implemented differently under OS X
170 and other platforms. Under OS X a wxDataViewItem is always persistent
171 and this is also the case for this class. Under other platforms, the
172 meaning of a wxDataViewItem is changed to reflect a row number for
173 wxDataViewIndexListModel. The consequence of this is that
174 wxDataViewIndexListModel can be used as a virtual model with an
175 almost infinate number of items on platforms other than OS X.
176
177 @library{wxbase}
178 @category{FIXME}
179 */
180 class wxDataViewIndexListModel : public wxDataViewModel
181 {
182 public:
183 /**
184 Constructor.
185 */
186 wxDataViewIndexListModel(unsigned int initial_size = 0);
187
188 /**
189 Destructor.
190 */
191 ~wxDataViewIndexListModel();
192
193 /**
194 Compare method that sorts the items by their index.
195 */
196 int Compare(const wxDataViewItem& item1,
197 const wxDataViewItem& item2,
198 unsigned int column, bool ascending);
199
200 /**
201 Oberride this to indicate that the row has special font attributes.
202 This only affects the
203 wxDataViewTextRendererText() renderer.
204 See also wxDataViewItemAttr.
205 */
206 bool GetAttr(unsigned int row, unsigned int col,
207 wxDataViewItemAttr& attr);
208
209 /**
210 Returns the wxDataViewItem at the given @e row.
211 */
212 wxDataViewItem GetItem(unsigned int row) const;
213
214 /**
215 Returns the position of given @e item.
216 */
217 unsigned int GetRow(const wxDataViewItem& item) const;
218
219 /**
220 Override this to allow getting values from the model.
221 */
222 void GetValue(wxVariant& variant, unsigned int row,
223 unsigned int col) const;
224
225 /**
226 Call this after if the data has to be read again from
227 the model. This is useful after major changes when
228 calling the methods below (possibly thousands of times)
229 doesn't make sense.
230 */
231 void Reset(unsigned int new_size);
232
233 /**
234 Call this after a row has been appended to the model.
235 */
236 void RowAppended();
237
238 /**
239 Call this after a row has been changed.
240 */
241 void RowChanged(unsigned int row);
242
243 /**
244 Call this after a row has been deleted.
245 */
246 void RowDeleted(unsigned int row);
247
248 /**
249 Call this after a row has been inserted at the given position.
250 */
251 void RowInserted(unsigned int before);
252
253 /**
254 Call this after a row has been prepended to the model.
255 */
256 void RowPrepended();
257
258 /**
259 Call this after a value has been changed.
260 */
261 void RowValueChanged(unsigned int row, unsigned int col);
262
263 /**
264 Call this after rows have been deleted. The array will internally
265 get copied and sorted in descending order so that the rows with
266 the highest position will be deleted first.
267 */
268 void RowsDeleted(const wxArrayInt& rows);
269
270 /**
271 Called in order to set a value in the model.
272 */
273 bool SetValue(const wxVariant& variant, unsigned int row,
274 unsigned int col);
275 };
276
277
278
279 /**
280 @class wxDataViewModel
281 @wxheader{dataview.h}
282
283 wxDataViewModel is the base class for all data model to be
284 displayed by a wxDataViewCtrl.
285 All other models derive from it and must implement its
286 pure virtual functions in order to define a complete
287 data model. In detail, you need to override
288 wxDataViewModel::IsContainer,
289 wxDataViewModel::GetParent,
290 wxDataViewModel::GetChildren,
291 wxDataViewModel::GetColumnCount,
292 wxDataViewModel::GetColumnType and
293 wxDataViewModel::GetValue in order to
294 define the data model which acts as an interface between
295 your actual data and the wxDataViewCtrl. Since you will
296 usually also allow the wxDataViewCtrl to change your data
297 through its graphical interface, you will also have to override
298 wxDataViewModel::SetValue which the
299 wxDataViewCtrl will call when a change to some data has been
300 commited.
301
302 wxDataViewModel (as indeed the entire wxDataViewCtrl
303 code) is using wxVariant to store data and
304 its type in a generic way. wxVariant can be extended to contain
305 almost any data without changes to the original class.
306
307 The data that is presented through this data model is expected
308 to change at run-time. You need to inform the data model when
309 a change happened. Depending on what happened you need to call
310 one of the following methods:
311 wxDataViewModel::ValueChanged,
312 wxDataViewModel::ItemAdded,
313 wxDataViewModel::ItemDeleted,
314 wxDataViewModel::ItemChanged,
315 wxDataViewModel::Cleared. There are
316 plural forms for notification of addition, change
317 or removal of several item at once. See
318 wxDataViewModel::ItemsAdded,
319 wxDataViewModel::ItemsDeleted,
320 wxDataViewModel::ItemsChanged.
321
322 Note that wxDataViewModel does not define the position or
323 index of any item in the control because different controls
324 might display the same data differently. wxDataViewModel does
325 provide a wxDataViewModel::Compare method
326 which the wxDataViewCtrl may use to sort the data either
327 in conjunction with a column header or without (see
328 wxDataViewModel::HasDefaultCompare).
329
330 This class maintains a list of
331 wxDataViewModelNotifier
332 which link this class to the specific implementations on the
333 supported platforms so that e.g. calling
334 wxDataViewModel::ValueChanged
335 on this model will just call
336 wxDataViewModelNotifier::ValueChanged
337 for each notifier that has been added. You can also add
338 your own notifier in order to get informed about any changes
339 to the data in the list model.
340
341 Currently wxWidgets provides the following models apart
342 from the base model:
343 wxDataViewIndexListModel,
344 wxDataViewTreeStore.
345
346 Note that wxDataViewModel is reference counted, derives from
347 wxObjectRefData and cannot be deleted
348 directly as it can be shared by several wxDataViewCtrls. This
349 implies that you need to decrease the reference count after
350 associating the model with a control like this:
351
352 @code
353 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL );
354 wxDataViewModel *musicModel = new MyMusicModel;
355 m_musicCtrl-AssociateModel( musicModel );
356 musicModel-DecRef(); // avoid memory leak !!
357 // add columns now
358 @endcode
359
360
361 @library{wxadv}
362 @category{FIXME}
363 */
364 class wxDataViewModel : public wxObjectRefData
365 {
366 public:
367 /**
368 Constructor.
369 */
370 wxDataViewModel();
371
372 /**
373 Destructor. This should not be called directly. Use DecRef() instead.
374 */
375 ~wxDataViewModel();
376
377 /**
378 Adds a wxDataViewModelNotifier
379 to the model.
380 */
381 void AddNotifier(wxDataViewModelNotifier* notifier);
382
383 /**
384 Called to inform the model that all data has been cleared. The
385 control will reread the data from the model again.
386 */
387 virtual bool Cleared();
388
389 /**
390 The compare function to be used by control. The default compare function
391 sorts by container and other items separately and in ascending order.
392 Override this for a different sorting behaviour.
393 See also HasDefaultCompare().
394 */
395 virtual int Compare(const wxDataViewItem& item1,
396 const wxDataViewItem& item2,
397 unsigned int column,
398 bool ascending);
399
400 /**
401 Oberride this to indicate that the item has special font attributes.
402 This only affects the
403 wxDataViewTextRendererText() renderer.
404 See also wxDataViewItemAttr.
405 */
406 bool GetAttr(const wxDataViewItem& item, unsigned int col,
407 wxDataViewItemAttr& attr);
408
409 /**
410 Override this so the control can query the child items of
411 an item. Returns the number of items.
412 */
413 virtual unsigned int GetChildren(const wxDataViewItem& item,
414 wxDataViewItemArray& children) const;
415
416 /**
417 Override this to indicate the number of columns in the model.
418 */
419 virtual unsigned int GetColumnCount() const;
420
421 /**
422 Override this to indicate what type of data is stored in the
423 column specified by @e col. This should return a string
424 indicating the type of data as reported by wxVariant.
425 */
426 virtual wxString GetColumnType(unsigned int col) const;
427
428 /**
429 Override this to indicate which wxDataViewItem representing the parent
430 of @a item or an invalid wxDataViewItem if the the root item is
431 the parent item.
432 */
433 virtual wxDataViewItem GetParent(const wxDataViewItem& item) const;
434
435 /**
436 Override this to indicate the value of @e item
437 A wxVariant is used to store the data.
438 */
439 virtual void GetValue(wxVariant& variant,
440 const wxDataViewItem& item,
441 unsigned int col) const;
442
443 /**
444 Override this method to indicate if a container item merely
445 acts as a headline (or for categorisation) or if it also
446 acts a normal item with entries for futher columns. By
447 default returns @e @false.
448 */
449 virtual bool HasContainerColumns(const wxDataViewItem& item) const;
450
451 /**
452 Override this to indicate that the model provides a default compare
453 function that the control should use if no wxDataViewColumn has been
454 chosen for sorting. Usually, the user clicks on a column header for
455 sorting, the data will be sorted alphanumerically. If any other
456 order (e.g. by index or order of appearance) is required, then this
457 should be used. See also wxDataViewIndexListModel
458 for a model which makes use of this.
459 */
460 virtual bool HasDefaultCompare() const;
461
462 /**
463 Override this to indicate of @a item is a container, i.e. if
464 it can have child items.
465 */
466 virtual bool IsContainer(const wxDataViewItem& item) const;
467
468 /**
469 Call this to inform the model that an item has been added
470 to the data.
471 */
472 virtual bool ItemAdded(const wxDataViewItem& parent,
473 const wxDataViewItem& item);
474
475 /**
476 Call this to inform the model that an item has changed.
477 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
478 event (in which the column fields will not be set) to the user.
479 */
480 virtual bool ItemChanged(const wxDataViewItem& item);
481
482 /**
483 Call this to inform the model that an item has been deleted from the data.
484 */
485 virtual bool ItemDeleted(const wxDataViewItem& parent,
486 const wxDataViewItem& item);
487
488 /**
489 Call this to inform the model that several items have been added
490 to the data.
491 */
492 virtual bool ItemsAdded(const wxDataViewItem& parent,
493 const wxDataViewItemArray& items);
494
495 /**
496 Call this to inform the model that several items have changed.
497 This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
498 events (in which the column fields will not be set) to the user.
499 */
500 virtual bool ItemsChanged(const wxDataViewItemArray& items);
501
502 /**
503 Call this to inform the model that several items have been deleted.
504 */
505 virtual bool ItemsDeleted(const wxDataViewItem& parent,
506 const wxDataViewItemArray& items);
507
508 /**
509 Remove the @a notifier from the list of notifiers.
510 */
511 void RemoveNotifier(wxDataViewModelNotifier* notifier);
512
513 /**
514 Call this to initiate a resort after the sort function has
515 been changed.
516 */
517 virtual void Resort();
518
519 /**
520 This gets called in order to set a value in the data model.
521 The most common scenario is that the wxDataViewCtrl calls
522 this method after the user changed some data in the view.
523 Afterwards ValueChanged()
524 has to be called!
525 */
526 virtual bool SetValue(const wxVariant& variant,
527 const wxDataViewItem& item,
528 unsigned int col);
529
530 /**
531 Call this to inform this model that a value in the model has
532 been changed. This is also called from wxDataViewCtrl's
533 internal editing code, e.g. when editing a text field
534 in the control.
535 This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
536 event to the user.
537 */
538 virtual bool ValueChanged(const wxDataViewItem& item,
539 unsigned int col);
540 };
541
542
543
544
545 /**
546 @class wxDataViewItemAttr
547 @wxheader{dataview.h}
548
549 This class is used to indicate to a wxDataViewCtrl
550 that a certain Item() has extra font attributes
551 for its renderer. For this, it is required to override
552 wxDataViewModel::GetAttr.
553
554 Attributes are currently only supported by
555 wxDataViewTextRendererText().
556
557 @library{wxadv}
558 @category{FIXME}
559 */
560 class wxDataViewItemAttr
561 {
562 public:
563 /**
564 Constructor.
565 */
566 wxDataViewItemAttr();
567
568 /**
569 Call this to indicate that the item shall be displayed in bold text.
570 */
571 void SetBold(bool set);
572
573 /**
574 Call this to indicate that the item shall be displayed with
575 that colour.
576 */
577 void SetColour(const wxColour& colour);
578
579 /**
580 Call this to indicate that the item shall be displayed in italic text.
581 */
582 void SetItalic(bool set);
583 };
584
585
586
587 /**
588 @class wxDataViewItem
589 @wxheader{dataview.h}
590
591 wxDataViewItem is a small opaque class that represents an
592 item in a wxDataViewCtrl in a
593 persistent way, i.e. indepent of the position of the
594 item in the control or changes to its contents. It must
595 hold a unique ID of type @e void* in its only field
596 and can be converted to a from it.
597
598 If the ID is @e @NULL the wxDataViewItem is invalid and
599 wxDataViewItem::IsOk will return @e @false
600 which used in many places in the API of wxDataViewCtrl
601 to indicate that e.g. no item was found. An ID of @NULL
602 is also used to indicate the invisible root. Examples
603 for this are
604 wxDataViewModel::GetParent and
605 wxDataViewModel::GetChildren.
606
607 @library{wxadv}
608 @category{FIXME}
609 */
610 class wxDataViewItem
611 {
612 public:
613 //@{
614 /**
615
616 */
617 wxDataViewItem(void* id = NULL);
618 wxDataViewItem(const wxDataViewItem& item);
619 //@}
620
621 /**
622 Returns the ID.
623 */
624 void* GetID() const;
625
626 /**
627 Returns @true if the ID is not @e @NULL.
628 */
629 bool IsOk() const;
630 };
631
632
633
634 /**
635 @class wxDataViewCtrl
636 @wxheader{dataview.h}
637
638 wxDataViewCtrl is a control to display data either
639 in a tree like fashion or in a tabular form or both.
640 If you only need to display a simple tree structure
641 with an API more like the older wxTreeCtrl class,
642 then the specialized wxDataViewTreeCtrl
643 can be used.
644
645 A wxDataViewItem is used
646 to represent a (visible) item in the control.
647
648 Unlike wxListCtrl wxDataViewCtrl doesn't
649 get its data from the user through virtual functions or by
650 setting it directly. Instead you need to write your own
651 wxDataViewModel and associate
652 it with this control. Then you need to add a number of
653 wxDataViewColumn to this control to
654 define what each column shall display. Each wxDataViewColumn
655 in turn owns 1 instance of a
656 wxDataViewRenderer to render its
657 cells. A number of standard renderers for rendering text, dates,
658 images, toggle, a progress bar etc. are provided. Additionally,
659 the user can write custom renderes deriving from
660 wxDataViewCustomRenderer
661 for displaying anything.
662
663 All data transfer from the control to the model and the user
664 code is done through wxVariant which can
665 be extended to support more data formats as necessary.
666 Accordingly, all type information uses the strings returned
667 from wxVariant::GetType.
668
669 @beginStyleTable
670 @style{wxDV_SINGLE}
671 Single selection mode. This is the default.
672 @style{wxDV_MULTIPLE}
673 Multiple selection mode.
674 @style{wxDV_ROW_LINES}
675 Use alternating colours for rows if supported by platform and theme.
676 @style{wxDV_HORIZ_RULES}
677 Display fine rules between row if supported.
678 @style{wxDV_VERT_RULES}
679 Display fine rules between columns is supported.
680 @endStyleTable
681
682 @library{wxadv}
683 @category{ctrl}
684 @appearance{dataviewctrl.png}
685 */
686 class wxDataViewCtrl : public wxControl
687 {
688 public:
689 //@{
690 /**
691 Constructor. Calls Create().
692 */
693 wxDataViewCtrl();
694 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
695 const wxPoint& pos = wxDefaultPosition,
696 const wxSize& size = wxDefaultSize,
697 long style = 0,
698 const wxValidator& validator = wxDefaultValidator);
699 //@}
700
701 /**
702 Destructor.
703 */
704 ~wxDataViewCtrl();
705
706 //@{
707 /**
708 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
709 created in the function or @NULL on failure.
710 */
711 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
712 unsigned int model_column,
713 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
714 int width = -1,
715 wxAlignment align = wxALIGN_CENTER,
716 int flags = wxDATAVIEW_COL_RESIZABLE);
717 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
718 unsigned int model_column,
719 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
720 int width = -1,
721 wxAlignment align = wxALIGN_CENTER,
722 int flags = wxDATAVIEW_COL_RESIZABLE);
723 //@}
724
725 /**
726 Add a wxDataViewColumn to the control. Returns
727 @e @true on success.
728 Note that there is a number of short cut methods which implicitly create
729 a wxDataViewColumn and a
730 wxDataViewRenderer for it (see below).
731 */
732 virtual bool AppendColumn(wxDataViewColumn* col);
733
734 //@{
735 /**
736 Appends a column for rendering a date. Returns the wxDataViewColumn
737 created in the function or @NULL on failure.
738 */
739 wxDataViewColumn* AppendDateColumn(const wxString& label,
740 unsigned int model_column,
741 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
742 int width = -1,
743 wxAlignment align = wxALIGN_CENTER,
744 int flags = wxDATAVIEW_COL_RESIZABLE);
745 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
746 unsigned int model_column,
747 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
748 int width = -1,
749 wxAlignment align = wxALIGN_CENTER,
750 int flags = wxDATAVIEW_COL_RESIZABLE);
751 //@}
752
753 //@{
754 /**
755 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
756 created in the function or @NULL on failure. This uses the
757 wxDataViewIconTextRenderer.
758 */
759 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
760 unsigned int model_column,
761 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
762 int width = -1,
763 wxAlignment align = wxALIGN_LEFT,
764 int flags = wxDATAVIEW_COL_RESIZABLE);
765 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
766 unsigned int model_column,
767 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
768 int width = -1,
769 wxAlignment align = wxALIGN_LEFT,
770 int flags = wxDATAVIEW_COL_RESIZABLE);
771 //@}
772
773 //@{
774 /**
775 Appends a column for rendering a progress indicator. Returns the
776 wxDataViewColumn
777 created in the function or @NULL on failure.
778 */
779 wxDataViewColumn* AppendProgressColumn(const wxString& label,
780 unsigned int model_column,
781 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
782 int width = 80,
783 wxAlignment align = wxALIGN_CENTER,
784 int flags = wxDATAVIEW_COL_RESIZABLE);
785 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
786 unsigned int model_column,
787 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
788 int width = 80,
789 wxAlignment align = wxALIGN_CENTER,
790 int flags = wxDATAVIEW_COL_RESIZABLE);
791 //@}
792
793 //@{
794 /**
795 Appends a column for rendering text. Returns the wxDataViewColumn
796 created in the function or @NULL on failure.
797 */
798 wxDataViewColumn* AppendTextColumn(const wxString& label,
799 unsigned int model_column,
800 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
801 int width = -1,
802 wxAlignment align = wxALIGN_LEFT,
803 int flags = wxDATAVIEW_COL_RESIZABLE);
804 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
805 unsigned int model_column,
806 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
807 int width = -1,
808 wxAlignment align = wxALIGN_LEFT,
809 int flags = wxDATAVIEW_COL_RESIZABLE);
810 //@}
811
812 //@{
813 /**
814 Appends a column for rendering a toggle. Returns the wxDataViewColumn
815 created in the function or @NULL on failure.
816 */
817 wxDataViewColumn* AppendToggleColumn(const wxString& label,
818 unsigned int model_column,
819 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
820 int width = 30,
821 wxAlignment align = wxALIGN_CENTER,
822 int flags = wxDATAVIEW_COL_RESIZABLE);
823 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
824 unsigned int model_column,
825 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
826 int width = 30,
827 wxAlignment align = wxALIGN_CENTER,
828 int flags = wxDATAVIEW_COL_RESIZABLE);
829 //@}
830
831 /**
832 Associates a wxDataViewModel with the
833 control. This increases the reference count of the model by 1.
834 */
835 virtual bool AssociateModel(wxDataViewModel* model);
836
837 /**
838 Removes all columns.
839 */
840 virtual bool ClearColumns();
841
842 /**
843 Unselects all rows.
844 */
845 void ClearSelection();
846
847 /**
848 Collapses the item.
849 */
850 void Collapse(const wxDataViewItem& item);
851
852 /**
853 Create the control. Useful for two step creation.
854 */
855 bool Create(wxWindow* parent, wxWindowID id,
856 const wxPoint& pos = wxDefaultPosition,
857 const wxSize& size = wxDefaultSize,
858 long style = 0,
859 const wxValidator& validator = wxDefaultValidator);
860
861 /**
862 Deletes given column.
863 */
864 virtual bool DeleteColumn(const wxDataViewColumn* column);
865
866 /**
867 Call this to ensure that the given item is visible.
868 */
869 void EnsureVisible(const wxDataViewItem& item,
870 const wxDataViewColumn* column = NULL);
871
872 /**
873 Expands the item.
874 */
875 void Expand(const wxDataViewItem& item);
876
877 /**
878 Returns pointer to the column. @a pos refers to the
879 position in the control which may change after reordering
880 columns by the user.
881 */
882 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
883
884 /**
885 Returns the number of columns.
886 */
887 virtual unsigned int GetColumnCount() const;
888
889 /**
890 Returns the position of the column or -1 if not found in the control.
891 */
892 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
893
894 /**
895 Returns column containing the expanders.
896 */
897 wxDataViewColumn* GetExpanderColumn() const;
898
899 /**
900 Returns indentation.
901 */
902 int GetIndent() const;
903
904 /**
905 Returns item rect.
906 */
907 wxRect GetItemRect(const wxDataViewItem& item,
908 const wxDataViewColumn* col = NULL) const;
909
910 /**
911 Returns pointer to the data model associated with the
912 control (if any).
913 */
914 virtual wxDataViewModel* GetModel() const;
915
916 /**
917 Returns first selected item or an invalid item if none is selected.
918 */
919 wxDataViewItem GetSelection() const;
920
921 /**
922 Fills @a sel with currently selected items and returns
923 their number.
924 */
925 int GetSelections(wxDataViewItemArray& sel) const;
926
927 /**
928 Returns the wxDataViewColumn currently responsible for sorting
929 or @NULL if none has been selected.
930 */
931 virtual wxDataViewColumn* GetSortingColumn() const;
932
933 /**
934 Hittest.
935 */
936 void HitTest(const wxPoint& point, wxDataViewItem& item,
937 wxDataViewColumn*& col) const;
938
939 /**
940 Return @true if the item is selected.
941 */
942 bool IsSelected(const wxDataViewItem& item) const;
943
944 /**
945 Select the given item.
946 */
947 void Select(const wxDataViewItem& item);
948
949 /**
950 Select all items.
951 */
952 void SelectAll();
953
954 /**
955 Set which column shall contain the tree-like expanders.
956 */
957 void SetExpanderColumn(wxDataViewColumn* col);
958
959 /**
960 Sets the indendation.
961 */
962 void SetIndent(int indent);
963
964 /**
965 Sets the selection to the array of wxDataViewItems.
966 */
967 void SetSelections(const wxDataViewItemArray& sel);
968
969 /**
970 Unselect the given item.
971 */
972 void Unselect(const wxDataViewItem& item);
973
974 /**
975 Unselect all item. This method only has effect if multiple
976 selections are allowed.
977 */
978 void UnselectAll();
979 };
980
981
982
983 /**
984 @class wxDataViewModelNotifier
985 @wxheader{dataview.h}
986
987 A wxDataViewModelNotifier instance is owned by a
988 wxDataViewModel
989 and mirrors its notification interface. See
990 the documentation of that class for further
991 information.
992
993 @library{wxbase}
994 @category{FIXME}
995 */
996 class wxDataViewModelNotifier
997 {
998 public:
999 /**
1000 Constructor.
1001 */
1002 wxDataViewModelNotifier();
1003
1004 /**
1005 Destructor.
1006 */
1007 ~wxDataViewModelNotifier();
1008
1009 /**
1010 Called by owning model.
1011 */
1012 bool Cleared();
1013
1014 /**
1015 Get owning wxDataViewModel.
1016 */
1017 wxDataViewModel* GetOwner();
1018
1019 /**
1020 Called by owning model.
1021 */
1022 bool ItemAdded(const wxDataViewItem& parent,
1023 const wxDataViewItem& item);
1024
1025 /**
1026 Called by owning model.
1027 */
1028 bool ItemChanged(const wxDataViewItem& item);
1029
1030 /**
1031 Called by owning model.
1032 */
1033 bool ItemDeleted(const wxDataViewItem& parent,
1034 const wxDataViewItem& item);
1035
1036 /**
1037 Called by owning model.
1038 */
1039 bool ItemsAdded(const wxDataViewItem& parent,
1040 const wxDataViewItemArray& items);
1041
1042 /**
1043 Called by owning model.
1044 */
1045 bool ItemsChanged(const wxDataViewItemArray& items);
1046
1047 /**
1048 Called by owning model.
1049 */
1050 bool ItemsDeleted(const wxDataViewItem& parent,
1051 const wxDataViewItemArray& items);
1052
1053 /**
1054 Called by owning model.
1055 */
1056 void Resort();
1057
1058 /**
1059 Set owner of this notifier. Used internally.
1060 */
1061 void SetOwner(wxDataViewModel* owner);
1062
1063 /**
1064 Called by owning model.
1065 */
1066 bool ValueChanged(const wxDataViewItem& item, unsigned int col);
1067 };
1068
1069
1070
1071 /**
1072 @class wxDataViewRenderer
1073 @wxheader{dataview.h}
1074
1075 This class is used by wxDataViewCtrl to
1076 render the individual cells. One instance of a renderer class is
1077 owned by wxDataViewColumn. There is
1078 a number of ready-to-use renderers provided:
1079 wxDataViewTextRenderer,
1080 wxDataViewTextRendererAttr,
1081 wxDataViewIconTextRenderer,
1082 wxDataViewToggleRenderer,
1083 wxDataViewProgressRenderer,
1084 wxDataViewBitmapRenderer,
1085 wxDataViewDateRenderer.
1086 wxDataViewSpinRenderer.
1087
1088 Additionally, the user can write own renderers by deriving from
1089 wxDataViewCustomRenderer.
1090
1091 The @e wxDataViewCellMode flag controls, what actions
1092 the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE
1093 indicates that the user can double click the cell and
1094 something will happen (e.g. a window for editing a date
1095 will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates
1096 that the user can edit the data in-place, i.e. an control
1097 will show up after a slow click on the cell. This behaviour
1098 is best known from changing the filename in most file
1099 managers etc.
1100
1101
1102 @code
1103 enum wxDataViewCellMode
1104 {
1105 wxDATAVIEW_CELL_INERT,
1106 wxDATAVIEW_CELL_ACTIVATABLE,
1107 wxDATAVIEW_CELL_EDITABLE
1108 };
1109 @endcode
1110
1111 The @e wxDataViewCellRenderState flag controls how the
1112 the renderer should display its contents in a cell:
1113
1114 @code
1115 enum wxDataViewCellRenderState
1116 {
1117 wxDATAVIEW_CELL_SELECTED = 1,
1118 wxDATAVIEW_CELL_PRELIT = 2,
1119 wxDATAVIEW_CELL_INSENSITIVE = 4,
1120 wxDATAVIEW_CELL_FOCUSED = 8
1121 };
1122 @endcode
1123
1124
1125 @library{wxadv}
1126 @category{FIXME}
1127 */
1128 class wxDataViewRenderer : public wxObject
1129 {
1130 public:
1131 /**
1132 Constructor.
1133 */
1134 wxDataViewRenderer(const wxString& varianttype,
1135 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1136 int align = wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL);
1137
1138 /**
1139 Returns the alignment.
1140 */
1141 virtual int GetAlignment() const;
1142
1143 /**
1144 Returns the cell mode.
1145 */
1146 virtual wxDataViewCellMode GetMode();
1147
1148 /**
1149 Returns pointer to the owning wxDataViewColumn.
1150 */
1151 virtual wxDataViewColumn* GetOwner();
1152
1153 /**
1154 This methods retrieves the value from the renderer in order to
1155 transfer the value back to the data model. Returns @e @false
1156 on failure.
1157 */
1158 virtual bool GetValue(wxVariant& value);
1159
1160 /**
1161 Returns a string with the type of the wxVariant
1162 supported by this renderer.
1163 */
1164 virtual wxString GetVariantType();
1165
1166 /**
1167 Sets the alignment.
1168 */
1169 virtual void SetAlignment( int align );
1170 /**
1171 Sets the owning wxDataViewColumn. This
1172 is usually called from within wxDataViewColumn.
1173 */
1174 virtual void SetOwner(wxDataViewColumn* owner);
1175
1176 /**
1177 Set the value of the renderer (and thus its cell) to @e value.
1178 The internal code will then render this cell with this data.
1179 */
1180 virtual bool SetValue(const wxVariant& value);
1181
1182 /**
1183 Before data is committed to the data model, it is passed to this
1184 method where it can be checked for validity. This can also be
1185 used for checking a valid range or limiting the user input in
1186 a certain aspect (e.g. max number of characters or only alphanumeric
1187 input, ASCII only etc.). Return @e @false if the value is
1188 not valid.
1189 Please note that due to implementation limitations, this validation
1190 is done after the editing control already is destroyed and the
1191 editing process finished.
1192 */
1193 virtual bool Validate(wxVariant& value);
1194 };
1195
1196
1197
1198 /**
1199 @class wxDataViewTextRenderer
1200 @wxheader{dataview.h}
1201
1202 wxDataViewTextRenderer is used for rendering text. It supports
1203 in-place editing if desired.
1204
1205 @library{wxadv}
1206 @category{FIXME}
1207 */
1208 class wxDataViewTextRenderer : public wxDataViewRenderer
1209 {
1210 public:
1211 /**
1212
1213 */
1214 wxDataViewTextRenderer(const wxString& varianttype = "string",
1215 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1216 int align = wxDVR_DEFAULT_ALIGNMENT );
1217 };
1218
1219
1220
1221 /**
1222 @class wxDataViewProgressRenderer
1223 @wxheader{dataview.h}
1224
1225 wxDataViewProgressRenderer
1226
1227 @library{wxadv}
1228 @category{FIXME}
1229 */
1230 class wxDataViewProgressRenderer : public wxDataViewRenderer
1231 {
1232 public:
1233 /**
1234
1235 */
1236 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1237 const wxString& varianttype = "long",
1238 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1239 int align = wxDVR_DEFAULT_ALIGNMENT );
1240 };
1241
1242
1243
1244 /**
1245 @class wxDataViewSpinRenderer
1246 @wxheader{dataview.h}
1247
1248 This is a specialized renderer for rendering integer values. It
1249 supports modifying the values in-place by using a wxSpinCtrl.
1250 The renderer only support variants of type @e long.
1251
1252 @library{wxbase}
1253 @category{FIXME}
1254 */
1255 class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1256 {
1257 public:
1258 /**
1259 Constructor. @a min and @a max indicate the minimum und
1260 maximum values of for the wxSpinCtrl.
1261 */
1262 wxDataViewSpinRenderer(int min, int max,
1263 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1264 int align = wxDVR_DEFAULT_ALIGNMENT);
1265 };
1266
1267
1268
1269 /**
1270 @class wxDataViewToggleRenderer
1271 @wxheader{dataview.h}
1272
1273 wxDataViewToggleRenderer
1274
1275 @library{wxadv}
1276 @category{FIXME}
1277 */
1278 class wxDataViewToggleRenderer : public wxDataViewRenderer
1279 {
1280 public:
1281 /**
1282
1283 */
1284 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
1285 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT);
1286 };
1287
1288
1289
1290 /**
1291 @class wxDataViewTreeCtrl
1292 @wxheader{dataview.h}
1293
1294 This class is a wxDataViewCtrl which internally
1295 uses a wxDataViewTreeStore and forwards
1296 most of its API to that class. Additionally, it uses a wxImageList
1297 to store a list of icons. The main purpose of this class is to look
1298 like a wxTreeCtrl to make a transition from it
1299 to the wxDataViewCtrl class simpler.
1300
1301 @library{wxbase}
1302 @category{ctrl}
1303 @appearance{dataviewtreectrl.png}
1304 */
1305 class wxDataViewTreeCtrl : public wxDataViewCtrl
1306 {
1307 public:
1308 //@{
1309 /**
1310 Constructor. Calls Create().
1311 */
1312 wxDataViewTreeCtrl();
1313 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
1314 const wxPoint& pos = wxDefaultPosition,
1315 const wxSize& size = wxDefaultSize,
1316 long style = wxDV_NO_HEADER,
1317 const wxValidator& validator = wxDefaultValidator);
1318 //@}
1319
1320 /**
1321 Destructor. Deletes the image list if any.
1322 */
1323 ~wxDataViewTreeCtrl();
1324
1325 /**
1326
1327 */
1328 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
1329 const wxString& text,
1330 int icon = -1,
1331 int expanded = -1,
1332 wxClientData* data = NULL);
1333
1334 /**
1335
1336 */
1337 wxDataViewItem AppendItem(const wxDataViewItem& parent,
1338 const wxString& text,
1339 int icon = -1,
1340 wxClientData* data = NULL);
1341
1342 /**
1343 Creates the control and a wxDataViewTreeStore as
1344 its internal model.
1345 */
1346 bool Create(wxWindow* parent, wxWindowID id,
1347 const wxPoint& pos = wxDefaultPosition,
1348 const wxSize& size = wxDefaultSize,
1349 long style = wxDV_NO_HEADER,
1350 const wxValidator& validator = wxDefaultValidator);
1351
1352 /**
1353 Calls the identical method from wxDataViewTreeStore.
1354 */
1355 void DeleteAllItems();
1356
1357 /**
1358 Calls the identical method from wxDataViewTreeStore.
1359 */
1360 void DeleteChildren(const wxDataViewItem& item);
1361
1362 /**
1363 Calls the identical method from wxDataViewTreeStore.
1364 */
1365 void DeleteItem(const wxDataViewItem& item);
1366
1367 /**
1368 Calls the identical method from wxDataViewTreeStore.
1369 */
1370 int GetChildCount(const wxDataViewItem& parent) const;
1371
1372 /**
1373 Returns the image list.
1374 */
1375 wxImageList* GetImageList();
1376
1377 /**
1378 Calls the identical method from wxDataViewTreeStore.
1379 */
1380 wxClientData* GetItemData(const wxDataViewItem& item) const;
1381
1382 /**
1383 Calls the identical method from wxDataViewTreeStore.
1384 */
1385 const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
1386
1387 /**
1388 Calls the identical method from wxDataViewTreeStore.
1389 */
1390 const wxIcon GetItemIcon(const wxDataViewItem& item) const;
1391
1392 /**
1393 Calls the identical method from wxDataViewTreeStore.
1394 */
1395 wxString GetItemText(const wxDataViewItem& item) const;
1396
1397 /**
1398 Calls the identical method from wxDataViewTreeStore.
1399 */
1400 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
1401 unsigned int pos) const;
1402
1403 //@{
1404 /**
1405 Returns the store.
1406 */
1407 wxDataViewTreeStore* GetStore() const;
1408 const wxDataViewTreeStore* GetStore() const;
1409 //@}
1410
1411 /**
1412 Calls the same method from wxDataViewTreeStore but uess
1413 and index position in the image list instead of a wxIcon.
1414 */
1415 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
1416 const wxDataViewItem& previous,
1417 const wxString& text,
1418 int icon = -1,
1419 int expanded = -1,
1420 wxClientData* data = NULL);
1421
1422 /**
1423 Calls the same method from wxDataViewTreeStore but uess
1424 and index position in the image list instead of a wxIcon.
1425 */
1426 wxDataViewItem InsertItem(const wxDataViewItem& parent,
1427 const wxDataViewItem& previous,
1428 const wxString& text,
1429 int icon = -1,
1430 wxClientData* data = NULL);
1431
1432 /**
1433 Calls the same method from wxDataViewTreeStore but uess
1434 and index position in the image list instead of a wxIcon.
1435 */
1436 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
1437 const wxString& text,
1438 int icon = -1,
1439 int expanded = -1,
1440 wxClientData* data = NULL);
1441
1442 /**
1443 Calls the same method from wxDataViewTreeStore but uess
1444 and index position in the image list instead of a wxIcon.
1445 */
1446 wxDataViewItem PrependItem(const wxDataViewItem& parent,
1447 const wxString& text,
1448 int icon = -1,
1449 wxClientData* data = NULL);
1450
1451 /**
1452 Sets the image list.
1453 */
1454 void SetImageList(wxImageList* imagelist);
1455
1456 /**
1457 Calls the identical method from wxDataViewTreeStore.
1458 */
1459 void SetItemData(const wxDataViewItem& item, wxClientData* data);
1460
1461 /**
1462 Calls the identical method from wxDataViewTreeStore.
1463 */
1464 void SetItemExpandedIcon(const wxDataViewItem& item,
1465 const wxIcon& icon);
1466
1467 /**
1468 Calls the identical method from wxDataViewTreeStore.
1469 */
1470 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
1471
1472 /**
1473 Calls the identical method from wxDataViewTreeStore.
1474 */
1475 void SetItemText(const wxDataViewItem& item,
1476 const wxString& text);
1477 };
1478
1479
1480
1481 /**
1482 @class wxDataViewTreeStore
1483 @wxheader{dataview.h}
1484
1485 wxDataViewTreeStore is a specialised wxDataViewModel
1486 for displaying simple trees very much like wxTreeCtrl
1487 does and it offers a similar API. This class actually stores the entire
1488 tree (therefore its name) and implements all virtual methods from the base
1489 class so it can be used directly without having to derive any class from it.
1490 This comes at the price of much reduced flexibility.
1491
1492 @library{wxadv}
1493 @category{FIXME}
1494 */
1495 class wxDataViewTreeStore : public wxDataViewModel
1496 {
1497 public:
1498 /**
1499 Constructor. Creates the invisible root node internally.
1500 */
1501 wxDataViewTreeStore();
1502
1503 /**
1504 Destructor.
1505 */
1506 ~wxDataViewTreeStore();
1507
1508 /**
1509 Append a container.
1510 */
1511 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
1512 const wxString& text,
1513 const wxIcon& icon = wxNullIcon,
1514 const wxIcon& expanded = wxNullIcon,
1515 wxClientData* data = NULL);
1516
1517 /**
1518 Append an item.
1519 */
1520 wxDataViewItem AppendItem(const wxDataViewItem& parent,
1521 const wxString& text,
1522 const wxIcon& icon = wxNullIcon,
1523 wxClientData* data = NULL);
1524
1525 /**
1526 Delete all item in the model.
1527 */
1528 void DeleteAllItems();
1529
1530 /**
1531 Delete all children of the item, but not the item itself.
1532 */
1533 void DeleteChildren(const wxDataViewItem& item);
1534
1535 /**
1536 Delete this item.
1537 */
1538 void DeleteItem(const wxDataViewItem& item);
1539
1540 /**
1541 Return the number of children of item.
1542 */
1543 int GetChildCount(const wxDataViewItem& parent) const;
1544
1545 /**
1546 Returns the client data asoociated with the item.
1547 */
1548 wxClientData* GetItemData(const wxDataViewItem& item) const;
1549
1550 /**
1551 Returns the icon to display in expanded containers.
1552 */
1553 const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
1554
1555 /**
1556 Returns the icon of the item.
1557 */
1558 const wxIcon GetItemIcon(const wxDataViewItem& item) const;
1559
1560 /**
1561 Returns the text of the item.
1562 */
1563 wxString GetItemText(const wxDataViewItem& item) const;
1564
1565 /**
1566 Returns the nth child item of item.
1567 */
1568 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
1569 unsigned int pos) const;
1570
1571 /**
1572 Inserts a container after @e previous.
1573 */
1574 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
1575 const wxDataViewItem& previous,
1576 const wxString& text,
1577 const wxIcon& icon = wxNullIcon,
1578 const wxIcon& expanded = wxNullIcon,
1579 wxClientData* data = NULL);
1580
1581 /**
1582 Inserts an item after @e previous.
1583 */
1584 wxDataViewItem InsertItem(const wxDataViewItem& parent,
1585 const wxDataViewItem& previous,
1586 const wxString& text,
1587 const wxIcon& icon = wxNullIcon,
1588 wxClientData* data = NULL);
1589
1590 /**
1591 Inserts a container before the first child item or @e parent.
1592 */
1593 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
1594 const wxString& text,
1595 const wxIcon& icon = wxNullIcon,
1596 const wxIcon& expanded = wxNullIcon,
1597 wxClientData* data = NULL);
1598
1599 /**
1600 Inserts an item before the first child item or @e parent.
1601 */
1602 wxDataViewItem PrependItem(const wxDataViewItem& parent,
1603 const wxString& text,
1604 const wxIcon& icon = wxNullIcon,
1605 wxClientData* data = NULL);
1606
1607 /**
1608 Sets the client data associated with the item.
1609 */
1610 void SetItemData(const wxDataViewItem& item, wxClientData* data);
1611
1612 /**
1613 Sets the expanded icon for the item.
1614 */
1615 void SetItemExpandedIcon(const wxDataViewItem& item,
1616 const wxIcon& icon);
1617
1618 /**
1619 Sets the icon for the item.
1620 */
1621 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
1622 };
1623
1624
1625
1626 /**
1627 @class wxDataViewDateRenderer
1628 @wxheader{dataview.h}
1629
1630 wxDataViewDateRenderer
1631
1632 @library{wxadv}
1633 @category{FIXME}
1634 */
1635 class wxDataViewDateRenderer : public wxDataViewRenderer
1636 {
1637 public:
1638 /**
1639
1640 */
1641 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
1642 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE);
1643 };
1644
1645
1646
1647 /**
1648 @class wxDataViewTextRendererAttr
1649 @wxheader{dataview.h}
1650
1651 The same as wxDataViewTextRenderer but with
1652 support for font attributes. Font attributes are currently only supported
1653 under GTK+ and MSW.
1654
1655 See also wxDataViewModel::GetAttr and
1656 wxDataViewItemAttr.
1657
1658 @library{wxadv}
1659 @category{FIXME}
1660 */
1661 class wxDataViewTextRendererAttr : public wxDataViewTextRenderer
1662 {
1663 public:
1664 /**
1665
1666 */
1667 wxDataViewTextRendererAttr(const wxString& varianttype = "string",
1668 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1669 int align = wxDVR_DEFAULT_ALIGNMENT);
1670 };
1671
1672
1673 /**
1674 @class wxDataViewCustomRenderer
1675 @wxheader{dataview.h}
1676
1677 You need to derive a new class from wxDataViewCustomRenderer in
1678 order to write a new renderer. You need to override at least
1679 wxDataViewRenderer::SetValue,
1680 wxDataViewRenderer::GetValue,
1681 wxDataViewCustomRenderer::GetSize
1682 and wxDataViewCustomRenderer::Render.
1683
1684 If you want your renderer to support in-place editing then you
1685 also need to override
1686 wxDataViewCustomRenderer::HasEditorCtrl,
1687 wxDataViewCustomRenderer::CreateEditorCtrl
1688 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
1689 Note that a special event handler will be pushed onto that
1690 editor control which handles ENTER and focus out events
1691 in order to end the editing.
1692
1693 @library{wxadv}
1694 @category{FIXME}
1695 */
1696 class wxDataViewCustomRenderer : public wxDataViewRenderer
1697 {
1698 public:
1699 /**
1700 Constructor.
1701 */
1702 wxDataViewCustomRenderer(const wxString& varianttype = "string",
1703 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1704 int align = wxDVR_DEFAULT_ALIGNMENT );
1705
1706 /**
1707 Destructor.
1708 */
1709 ~wxDataViewCustomRenderer();
1710
1711 /**
1712 Override this to react to double clicks or ENTER. This method will
1713 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1714 */
1715 virtual bool Activate( wxRect cell,
1716 wxDataViewModel* model,
1717 const wxDataViewItem & item,
1718 unsigned int col );
1719
1720 /**
1721 Override this to create the actual editor control once editing
1722 is about to start. @a parent is the parent of the editor
1723 control, @a labelRect indicates the position and
1724 size of the editor control and @a value is its initial value:
1725 */
1726 virtual wxControl* CreateEditorCtrl(wxWindow* parent,
1727 wxRect labelRect,
1728 const wxVariant& value);
1729
1730 /**
1731 Create DC on request. Internal.
1732 */
1733 virtual wxDC* GetDC();
1734
1735 /**
1736 Return size required to show content.
1737 */
1738 virtual wxSize GetSize();
1739
1740 /**
1741 Overrride this so that the renderer can get the value
1742 from the editor control (pointed to by @e editor):
1743 */
1744 virtual bool GetValueFromEditorCtrl(wxControl* editor,
1745 wxVariant& value);
1746
1747 /**
1748 Override this and make it return @e @true in order to
1749 indicate that this renderer supports in-place editing.
1750 */
1751 virtual bool HasEditorCtrl();
1752
1753 /**
1754 Overrride this to react to a left click. This method will
1755 only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
1756 */
1757 virtual bool LeftClick( wxPoint cursor,
1758 wxRect cell,
1759 wxDataViewModel * model,
1760 const wxDataViewItem & item,
1761 unsigned int col );
1762
1763 /**
1764 Override this to render the cell. Before this is called,
1765 wxDataViewRenderer::SetValue was called
1766 so that this instance knows what to render.
1767 */
1768 virtual bool Render(wxRect cell, wxDC* dc, int state);
1769
1770 /**
1771 This method should be called from within Render()
1772 whenever you need to render simple text. This will ensure that the
1773 correct colour, font and vertical alignment will be chosen so the
1774 text will look the same as text drawn by native renderers.
1775 */
1776 bool RenderText(const wxString& text, int xoffset, wxRect cell,
1777 wxDC* dc, int state);
1778
1779 /**
1780 Overrride this to start a drag operation. Not yet
1781 supported
1782 */
1783 virtual bool StartDrag(wxPoint cursor, wxRect cell,
1784 wxDataViewModel* model,
1785 const wxDataViewItem & item,
1786 unsigned int col);
1787 };
1788
1789
1790
1791 /**
1792 @class wxDataViewBitmapRenderer
1793 @wxheader{dataview.h}
1794
1795 wxDataViewBitmapRenderer
1796
1797 @library{wxadv}
1798 @category{FIXME}
1799 */
1800 class wxDataViewBitmapRenderer : public wxDataViewRenderer
1801 {
1802 public:
1803 /**
1804
1805 */
1806 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
1807 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1808 int align = wxDVR_DEFAULT_ALIGNMENT,
1809 };
1810
1811
1812 /**
1813 @class wxDataViewColumn
1814 @wxheader{dataview.h}
1815
1816 This class represents a column in a wxDataViewCtrl.
1817 One wxDataViewColumn is bound to one column in the data model,
1818 to which the wxDataViewCtrl has been associated.
1819
1820 An instance of wxDataViewRenderer is used by
1821 this class to render its data.
1822
1823 @library{wxadv}
1824 @category{FIXME}
1825 */
1826 class wxDataViewColumn : public wxObject
1827 {
1828 public:
1829 //@{
1830 /**
1831 Constructors.
1832 */
1833 wxDataViewColumn(const wxString& title,
1834 wxDataViewRenderer* renderer,
1835 unsigned int model_column,
1836 int width = wxDVC_DEFAULT_WIDTH,
1837 wxAlignment align = wxALIGN_CENTRE,
1838 int flags = wxDATAVIEW_COL_RESIZABLE);
1839 wxDataViewColumn(const wxBitmap& bitmap,
1840 wxDataViewRenderer* renderer,
1841 unsigned int model_column,
1842 int width = wxDVC_DEFAULT_WIDTH,
1843 wxAlignment align = wxALIGN_CENTRE,
1844 int flags = wxDATAVIEW_COL_RESIZABLE);
1845 //@}
1846
1847 /**
1848 Destructor.
1849 */
1850 ~wxDataViewColumn();
1851
1852 /**
1853 Returns the bitmap in the header of the column, if any.
1854 */
1855 const wxBitmap GetBitmap();
1856
1857 /**
1858 Returns the index of the column of the model, which this
1859 wxDataViewColumn is displaying.
1860 */
1861 unsigned int GetModelColumn();
1862
1863 /**
1864 Returns the owning wxDataViewCtrl.
1865 */
1866 wxDataViewCtrl* GetOwner();
1867
1868 /**
1869 Returns the renderer of this wxDataViewColumn.
1870 See also wxDataViewRenderer.
1871 */
1872 wxDataViewRenderer* GetRenderer();
1873
1874 /**
1875 Returns @true if the column is reorderable.
1876 */
1877 bool GetReorderable();
1878
1879 /**
1880 Returns @true if the column is sortable.
1881 See SetSortable()
1882 */
1883 bool GetSortable();
1884
1885 /**
1886 Returns the width of the column.
1887 */
1888 int GetWidth();
1889
1890 /**
1891 Returns @true, if the sort order is ascending.
1892 See also SetSortOrder()
1893 */
1894 bool IsSortOrderAscending();
1895
1896 /**
1897 Set the alignment of the column header.
1898 */
1899 void SetAlignment(wxAlignment align);
1900
1901 /**
1902 Set the bitmap of the column header.
1903 */
1904 void SetBitmap(const wxBitmap& bitmap);
1905
1906 /**
1907 Indicate wether the column can be reordered by the
1908 user using the mouse. This is typically implemented
1909 visually by dragging the header button around.
1910 */
1911 void SetReorderable(bool reorderable);
1912
1913 /**
1914 Indicate the sort order if the implementation of the
1915 wxDataViewCtrl supports it, most commonly by showing
1916 a little arrow.
1917 */
1918 void SetSortOrder(bool ascending);
1919
1920 /**
1921 Indicate that the column is sortable. This does
1922 not show any sorting indicate yet, but it does
1923 make the column header clickable. Call
1924 SetSortOrder()
1925 afterwards to actually make the sort indicator appear.
1926 If @a sortable is @false, the column header is
1927 no longer clickable and the sort indicator (little
1928 arrow) will disappear.
1929 */
1930 void SetSortable(bool sortable);
1931
1932 /**
1933 Set the title of the column header to @e title.
1934 */
1935 void SetTitle(const wxString& title);
1936 };
1937