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