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