]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dataview.h
undo the last change as it results in buildbot configuration error
[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
14f73cf1 70 wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
23324ae1 71 wxDataViewModel *musicModel = new MyMusicModel;
14f73cf1
FM
72 m_musicCtrl->AssociateModel( musicModel );
73 musicModel->DecRef(); // avoid memory leak !!
74
23324ae1
FM
75 // add columns now
76 @endcode
7c913512 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,
862de7b3 110 bool ascending) const;
23324ae1
FM
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.
02b51ae5 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.
02b51ae5 491 Likewise, if you only want to display simple table structure you can use
832df171
RR
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 524 Allow variable line heights.
14f73cf1 525 This can be inefficient when displaying large number of items.
23324ae1 526 @endStyleTable
7c913512 527
3051a44a 528 @beginEventEmissionTable{wxDataViewEvent}
7d01d660 529 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
14f73cf1 530 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
7d01d660 531 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
14f73cf1 532 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
3e978cf7
RR
533 @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
534 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This
535 event can be vetoed in order to prevent editing on an item by item
536 basis. Still experimental.
7d01d660 537 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
14f73cf1 538 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
7d01d660 539 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
14f73cf1 540 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
7d01d660 541 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
14f73cf1 542 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
7d01d660 543 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
14f73cf1 544 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
7d01d660 545 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
14f73cf1 546 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
7d01d660 547 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
14f73cf1 548 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
7d01d660 549 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
14f73cf1 550 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
7d01d660 551 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
14f73cf1 552 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
7d01d660 553 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
14f73cf1 554 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
7d01d660 555 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
14f73cf1 556 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
7d01d660 557 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
14f73cf1 558 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
7d01d660 559 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
14f73cf1 560 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
591cc82d 561 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
14f73cf1 562 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
e4de825e 563 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
14f73cf1 564 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
e4de825e 565 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
14f73cf1 566 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
7d01d660 567 @endEventTable
b91c4601 568
23324ae1 569 @library{wxadv}
b321b61c 570 @category{ctrl,dvc}
7e59b885 571 @appearance{dataviewctrl.png}
23324ae1
FM
572*/
573class wxDataViewCtrl : public wxControl
574{
575public:
23324ae1 576 /**
19723525 577 Default Constructor.
23324ae1
FM
578 */
579 wxDataViewCtrl();
b91c4601 580
19723525
RR
581 /**
582 Constructor. Calls Create().
583 */
7c913512
FM
584 wxDataViewCtrl(wxWindow* parent, wxWindowID id,
585 const wxPoint& pos = wxDefaultPosition,
586 const wxSize& size = wxDefaultSize,
587 long style = 0,
588 const wxValidator& validator = wxDefaultValidator);
23324ae1
FM
589
590 /**
591 Destructor.
592 */
adaaa686 593 virtual ~wxDataViewCtrl();
23324ae1 594
e39de702 595 /**
19723525 596 Appends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 597
e39de702
RR
598 Note that there is a number of short cut methods which implicitly create
599 a wxDataViewColumn and a wxDataViewRenderer for it (see below).
600 */
601 virtual bool AppendColumn(wxDataViewColumn* col);
602
19723525
RR
603 /**
604 Prepends a wxDataViewColumn to the control. Returns @true on success.
c4e57202 605
19723525
RR
606 Note that there is a number of short cut methods which implicitly create
607 a wxDataViewColumn and a wxDataViewRenderer for it.
608 */
609 virtual bool PrependColumn(wxDataViewColumn* col);
610
611 /**
612 Inserts a wxDataViewColumn to the control. Returns @true on success.
613 */
614 virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
b91c4601 615
23324ae1
FM
616 //@{
617 /**
618 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
619 created in the function or @NULL on failure.
620 */
621 wxDataViewColumn* AppendBitmapColumn(const wxString& label,
622 unsigned int model_column,
623 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
624 int width = -1,
625 wxAlignment align = wxALIGN_CENTER,
626 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
627 wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
628 unsigned int model_column,
629 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
630 int width = -1,
631 wxAlignment align = wxALIGN_CENTER,
632 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
633 //@}
634
23324ae1
FM
635 //@{
636 /**
637 Appends a column for rendering a date. Returns the wxDataViewColumn
638 created in the function or @NULL on failure.
b91c4601 639
c4e57202
FM
640 @note The @a align parameter is applied to both the column header and
641 the column renderer.
23324ae1
FM
642 */
643 wxDataViewColumn* AppendDateColumn(const wxString& label,
644 unsigned int model_column,
645 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
646 int width = -1,
882678eb 647 wxAlignment align = wxALIGN_NOT,
23324ae1 648 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
649 wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
650 unsigned int model_column,
651 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
652 int width = -1,
882678eb 653 wxAlignment align = wxALIGN_NOT,
7c913512 654 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
655 //@}
656
657 //@{
658 /**
659 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
c4e57202
FM
660 created in the function or @NULL on failure.
661 This method uses the wxDataViewIconTextRenderer class.
b91c4601 662
c4e57202
FM
663 @note The @a align parameter is applied to both the column header and
664 the column renderer.
23324ae1
FM
665 */
666 wxDataViewColumn* AppendIconTextColumn(const wxString& label,
667 unsigned int model_column,
668 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
669 int width = -1,
882678eb 670 wxAlignment align = wxALIGN_NOT,
23324ae1 671 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
672 wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
673 unsigned int model_column,
674 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
675 int width = -1,
882678eb 676 wxAlignment align = wxALIGN_NOT,
7c913512 677 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
678 //@}
679
680 //@{
681 /**
682 Appends a column for rendering a progress indicator. Returns the
e39de702 683 wxDataViewColumn created in the function or @NULL on failure.
b91c4601 684
c4e57202
FM
685 @note The @a align parameter is applied to both the column header and
686 the column renderer.
23324ae1
FM
687 */
688 wxDataViewColumn* AppendProgressColumn(const wxString& label,
689 unsigned int model_column,
690 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
691 int width = 80,
692 wxAlignment align = wxALIGN_CENTER,
693 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
694 wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
695 unsigned int model_column,
696 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
697 int width = 80,
698 wxAlignment align = wxALIGN_CENTER,
699 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
700 //@}
701
702 //@{
703 /**
704 Appends a column for rendering text. Returns the wxDataViewColumn
705 created in the function or @NULL on failure.
b91c4601 706
c4e57202
FM
707 @note The @a align parameter is applied to both the column header and
708 the column renderer.
23324ae1
FM
709 */
710 wxDataViewColumn* AppendTextColumn(const wxString& label,
711 unsigned int model_column,
712 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
713 int width = -1,
882678eb 714 wxAlignment align = wxALIGN_NOT,
23324ae1 715 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
716 wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
717 unsigned int model_column,
718 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
719 int width = -1,
882678eb 720 wxAlignment align = wxALIGN_NOT,
7c913512 721 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
722 //@}
723
724 //@{
725 /**
726 Appends a column for rendering a toggle. Returns the wxDataViewColumn
727 created in the function or @NULL on failure.
b91c4601 728
c4e57202
FM
729 @note The @a align parameter is applied to both the column header and
730 the column renderer.
23324ae1
FM
731 */
732 wxDataViewColumn* AppendToggleColumn(const wxString& label,
733 unsigned int model_column,
734 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
735 int width = 30,
736 wxAlignment align = wxALIGN_CENTER,
737 int flags = wxDATAVIEW_COL_RESIZABLE);
7c913512
FM
738 wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
739 unsigned int model_column,
740 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
741 int width = 30,
742 wxAlignment align = wxALIGN_CENTER,
743 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1
FM
744 //@}
745
746 /**
c4e57202
FM
747 Associates a wxDataViewModel with the control.
748 This increases the reference count of the model by 1.
23324ae1
FM
749 */
750 virtual bool AssociateModel(wxDataViewModel* model);
751
752 /**
753 Removes all columns.
754 */
755 virtual bool ClearColumns();
756
23324ae1
FM
757 /**
758 Collapses the item.
759 */
adaaa686 760 virtual void Collapse(const wxDataViewItem& item);
23324ae1
FM
761
762 /**
763 Create the control. Useful for two step creation.
764 */
765 bool Create(wxWindow* parent, wxWindowID id,
766 const wxPoint& pos = wxDefaultPosition,
767 const wxSize& size = wxDefaultSize,
768 long style = 0,
769 const wxValidator& validator = wxDefaultValidator);
770
771 /**
772 Deletes given column.
773 */
50ec54b6 774 virtual bool DeleteColumn(wxDataViewColumn* column);
23324ae1 775
e4de825e
RR
776 /**
777 Enable drag operations using the given @a format.
778 */
779 virtual bool EnableDragSource( const wxDataFormat &format );
02b51ae5 780
e4de825e
RR
781 /**
782 Enable drop operations using the given @a format.
783 */
784 virtual bool EnableDropTarget( const wxDataFormat &format );
02b51ae5 785
23324ae1
FM
786 /**
787 Call this to ensure that the given item is visible.
788 */
fadc2df6
FM
789 virtual void EnsureVisible(const wxDataViewItem& item,
790 const wxDataViewColumn* column = NULL);
23324ae1
FM
791
792 /**
793 Expands the item.
794 */
adaaa686 795 virtual void Expand(const wxDataViewItem& item);
23324ae1 796
4219d8b0
RR
797 /**
798 Expands all ancestors of the @a item. This method also
799 ensures that the item itself as well as all ancestor
800 items have been read from the model by the control.
801 */
802 virtual void ExpandAncestors( const wxDataViewItem & item );
798c0d87 803
23324ae1 804 /**
c4e57202
FM
805 Returns pointer to the column. @a pos refers to the position in the
806 control which may change after reordering columns by the user.
23324ae1 807 */
328f5751 808 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
23324ae1
FM
809
810 /**
811 Returns the number of columns.
812 */
328f5751 813 virtual unsigned int GetColumnCount() const;
23324ae1
FM
814
815 /**
816 Returns the position of the column or -1 if not found in the control.
817 */
328f5751 818 virtual int GetColumnPosition(const wxDataViewColumn* column) const;
23324ae1
FM
819
820 /**
821 Returns column containing the expanders.
822 */
328f5751 823 wxDataViewColumn* GetExpanderColumn() const;
23324ae1
FM
824
825 /**
826 Returns indentation.
827 */
328f5751 828 int GetIndent() const;
23324ae1
FM
829
830 /**
831 Returns item rect.
832 */
fadc2df6
FM
833 virtual wxRect GetItemRect(const wxDataViewItem& item,
834 const wxDataViewColumn* col = NULL) const;
23324ae1
FM
835
836 /**
c4e57202 837 Returns pointer to the data model associated with the control (if any).
23324ae1 838 */
adaaa686 839 wxDataViewModel* GetModel();
23324ae1
FM
840
841 /**
842 Returns first selected item or an invalid item if none is selected.
843 */
adaaa686 844 virtual wxDataViewItem GetSelection() const;
23324ae1
FM
845
846 /**
c4e57202 847 Fills @a sel with currently selected items and returns their number.
23324ae1 848 */
adaaa686 849 virtual int GetSelections(wxDataViewItemArray& sel) const;
23324ae1
FM
850
851 /**
852 Returns the wxDataViewColumn currently responsible for sorting
853 or @NULL if none has been selected.
854 */
328f5751 855 virtual wxDataViewColumn* GetSortingColumn() const;
23324ae1
FM
856
857 /**
858 Hittest.
859 */
fadc2df6
FM
860 virtual void HitTest(const wxPoint& point, wxDataViewItem& item,
861 wxDataViewColumn*& col) const;
23324ae1 862
739a8399
RR
863 /**
864 Return @true if the item is expanded.
739a8399
RR
865 */
866 virtual bool IsExpanded(const wxDataViewItem& item) const;
867
23324ae1
FM
868 /**
869 Return @true if the item is selected.
870 */
adaaa686 871 virtual bool IsSelected(const wxDataViewItem& item) const;
23324ae1
FM
872
873 /**
874 Select the given item.
875 */
adaaa686 876 virtual void Select(const wxDataViewItem& item);
23324ae1
FM
877
878 /**
879 Select all items.
880 */
adaaa686 881 virtual void SelectAll();
23324ae1
FM
882
883 /**
884 Set which column shall contain the tree-like expanders.
885 */
4cc4bfaf 886 void SetExpanderColumn(wxDataViewColumn* col);
23324ae1
FM
887
888 /**
889 Sets the indendation.
890 */
891 void SetIndent(int indent);
892
893 /**
894 Sets the selection to the array of wxDataViewItems.
895 */
adaaa686 896 virtual void SetSelections(const wxDataViewItemArray& sel);
23324ae1
FM
897
898 /**
899 Unselect the given item.
900 */
adaaa686 901 virtual void Unselect(const wxDataViewItem& item);
23324ae1
FM
902
903 /**
c4e57202
FM
904 Unselect all item.
905 This method only has effect if multiple selections are allowed.
23324ae1 906 */
adaaa686 907 virtual void UnselectAll();
23324ae1
FM
908};
909
910
e54c96f1 911
23324ae1
FM
912/**
913 @class wxDataViewModelNotifier
7c913512 914
c4e57202
FM
915 A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
916 its notification interface.
917 See the documentation of that class for further information.
7c913512 918
8ed522d9 919 @library{wxadv}
b321b61c 920 @category{dvc}
23324ae1 921*/
7c913512 922class wxDataViewModelNotifier
23324ae1
FM
923{
924public:
925 /**
926 Constructor.
927 */
928 wxDataViewModelNotifier();
929
930 /**
931 Destructor.
932 */
adaaa686 933 virtual ~wxDataViewModelNotifier();
23324ae1
FM
934
935 /**
936 Called by owning model.
937 */
b91c4601 938 virtual bool Cleared() = 0;
23324ae1
FM
939
940 /**
941 Get owning wxDataViewModel.
942 */
e51bf699 943 wxDataViewModel* GetOwner() const;
23324ae1
FM
944
945 /**
946 Called by owning model.
947 */
fadc2df6
FM
948 virtual bool ItemAdded(const wxDataViewItem& parent,
949 const wxDataViewItem& item) = 0;
23324ae1
FM
950
951 /**
952 Called by owning model.
953 */
b91c4601 954 virtual bool ItemChanged(const wxDataViewItem& item) = 0;
23324ae1
FM
955
956 /**
957 Called by owning model.
958 */
fadc2df6
FM
959 virtual bool ItemDeleted(const wxDataViewItem& parent,
960 const wxDataViewItem& item) = 0;
23324ae1
FM
961
962 /**
963 Called by owning model.
964 */
fadc2df6
FM
965 virtual bool ItemsAdded(const wxDataViewItem& parent,
966 const wxDataViewItemArray& items);
23324ae1
FM
967
968 /**
969 Called by owning model.
970 */
adaaa686 971 virtual bool ItemsChanged(const wxDataViewItemArray& items);
23324ae1
FM
972
973 /**
974 Called by owning model.
975 */
fadc2df6
FM
976 virtual bool ItemsDeleted(const wxDataViewItem& parent,
977 const wxDataViewItemArray& items);
23324ae1
FM
978
979 /**
980 Called by owning model.
981 */
b91c4601 982 virtual void Resort() = 0;
23324ae1
FM
983
984 /**
985 Set owner of this notifier. Used internally.
986 */
987 void SetOwner(wxDataViewModel* owner);
988
989 /**
990 Called by owning model.
991 */
b91c4601 992 virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0;
23324ae1
FM
993};
994
995
c4e57202
FM
996/**
997 The mode of a data-view cell; see wxDataViewRenderer for more info.
998*/
999enum wxDataViewCellMode
1000{
1001 wxDATAVIEW_CELL_INERT,
1002
1003 /**
1004 Indicates that the user can double click the cell and something will
1005 happen (e.g. a window for editing a date will pop up).
1006 */
1007 wxDATAVIEW_CELL_ACTIVATABLE,
1008
1009 /**
1010 Indicates that the user can edit the data in-place, i.e. an control
1011 will show up after a slow click on the cell. This behaviour is best
1012 known from changing the filename in most file managers etc.
1013 */
1014 wxDATAVIEW_CELL_EDITABLE
1015};
1016
1017/**
1018 The values of this enum controls how a wxDataViewRenderer should display
1019 its contents in a cell.
1020*/
1021enum wxDataViewCellRenderState
1022{
1023 wxDATAVIEW_CELL_SELECTED = 1,
1024 wxDATAVIEW_CELL_PRELIT = 2,
1025 wxDATAVIEW_CELL_INSENSITIVE = 4,
1026 wxDATAVIEW_CELL_FOCUSED = 8
1027};
e54c96f1 1028
23324ae1
FM
1029/**
1030 @class wxDataViewRenderer
7c913512 1031
5b99d5d8 1032 This class is used by wxDataViewCtrl to render the individual cells.
c4e57202
FM
1033 One instance of a renderer class is owned by a wxDataViewColumn.
1034 There is a number of ready-to-use renderers provided:
1035 - wxDataViewTextRenderer,
1036 - wxDataViewTextRendererAttr,
1037 - wxDataViewIconTextRenderer,
1038 - wxDataViewToggleRenderer,
1039 - wxDataViewProgressRenderer,
1040 - wxDataViewBitmapRenderer,
1041 - wxDataViewDateRenderer,
1042 - wxDataViewSpinRenderer.
7c913512 1043
23324ae1
FM
1044 Additionally, the user can write own renderers by deriving from
1045 wxDataViewCustomRenderer.
7c913512 1046
c4e57202
FM
1047 The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
1048 by the constructors respectively controls what actions the cell data allows
1049 and how the renderer should display its contents in a cell.
7c913512 1050
23324ae1 1051 @library{wxadv}
b321b61c 1052 @category{dvc}
23324ae1
FM
1053*/
1054class wxDataViewRenderer : public wxObject
1055{
1056public:
1057 /**
b91c4601 1058 Constructor.
23324ae1
FM
1059 */
1060 wxDataViewRenderer(const wxString& varianttype,
1061 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
f2b7492a 1062 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1 1063
20c36737 1064 /**
f2b7492a 1065 Returns the alignment. See SetAlignment()
20c36737
RR
1066 */
1067 virtual int GetAlignment() const;
1068
23324ae1
FM
1069 /**
1070 Returns the cell mode.
1071 */
adaaa686 1072 virtual wxDataViewCellMode GetMode() const;
23324ae1
FM
1073
1074 /**
1075 Returns pointer to the owning wxDataViewColumn.
1076 */
adaaa686 1077 wxDataViewColumn* GetOwner() const;
23324ae1
FM
1078
1079 /**
1080 This methods retrieves the value from the renderer in order to
c4e57202
FM
1081 transfer the value back to the data model.
1082
1083 Returns @false on failure.
23324ae1 1084 */
b91c4601 1085 virtual bool GetValue(wxVariant& value) const = 0;
23324ae1
FM
1086
1087 /**
c4e57202 1088 Returns a string with the type of the wxVariant supported by this renderer.
23324ae1 1089 */
adaaa686 1090 wxString GetVariantType() const;
23324ae1 1091
20c36737 1092 /**
c4e57202
FM
1093 Sets the alignment of the renderer's content.
1094 The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
1095 should have the same alignment as the column header.
1096
1097 The method is not implemented under OS X and the renderer always aligns
1098 its contents as the column header on that platform. The other platforms
f2b7492a 1099 support both vertical and horizontal alignment.
20c36737
RR
1100 */
1101 virtual void SetAlignment( int align );
23324ae1 1102 /**
c4e57202
FM
1103 Sets the owning wxDataViewColumn.
1104 This is usually called from within wxDataViewColumn.
23324ae1 1105 */
adaaa686 1106 void SetOwner(wxDataViewColumn* owner);
23324ae1
FM
1107
1108 /**
c4e57202 1109 Set the value of the renderer (and thus its cell) to @a value.
23324ae1
FM
1110 The internal code will then render this cell with this data.
1111 */
b91c4601 1112 virtual bool SetValue(const wxVariant& value) = 0;
23324ae1
FM
1113
1114 /**
1115 Before data is committed to the data model, it is passed to this
1116 method where it can be checked for validity. This can also be
1117 used for checking a valid range or limiting the user input in
1118 a certain aspect (e.g. max number of characters or only alphanumeric
c4e57202
FM
1119 input, ASCII only etc.). Return @false if the value is not valid.
1120
23324ae1
FM
1121 Please note that due to implementation limitations, this validation
1122 is done after the editing control already is destroyed and the
1123 editing process finished.
1124 */
1125 virtual bool Validate(wxVariant& value);
1126};
1127
1128
e54c96f1 1129
23324ae1
FM
1130/**
1131 @class wxDataViewTextRenderer
7c913512 1132
c4e57202
FM
1133 wxDataViewTextRenderer is used for rendering text.
1134 It supports in-place editing if desired.
7c913512 1135
23324ae1 1136 @library{wxadv}
b321b61c 1137 @category{dvc}
23324ae1
FM
1138*/
1139class wxDataViewTextRenderer : public wxDataViewRenderer
1140{
1141public:
1142 /**
c4e57202 1143 The ctor.
23324ae1
FM
1144 */
1145 wxDataViewTextRenderer(const wxString& varianttype = "string",
05303ccd
RR
1146 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1147 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1148};
1149
1150
e54c96f1 1151
f2b7492a
RR
1152/**
1153 @class wxDataViewIconTextRenderer
f2b7492a
RR
1154
1155 The wxDataViewIconTextRenderer class is used to display text with
1156 a small icon next to it as it is typically done in a file manager.
c4e57202
FM
1157
1158 This classes uses the wxDataViewIconText helper class to store its data.
1159 wxDataViewIonText can be converted to and from a wxVariant using the left shift
f2b7492a
RR
1160 operator.
1161
1162 @library{wxadv}
b321b61c 1163 @category{dvc}
f2b7492a
RR
1164*/
1165class wxDataViewIconTextRenderer : public wxDataViewRenderer
1166{
1167public:
1168 /**
c4e57202 1169 The ctor.
f2b7492a
RR
1170 */
1171 wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
1172 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1173 int align = wxDVR_DEFAULT_ALIGNMENT );
1174};
1175
1176
1177
23324ae1
FM
1178/**
1179 @class wxDataViewProgressRenderer
7c913512 1180
c4e57202 1181 This class is used by wxDataViewCtrl to render progress bars.
7c913512 1182
23324ae1 1183 @library{wxadv}
b321b61c 1184 @category{dvc}
23324ae1
FM
1185*/
1186class wxDataViewProgressRenderer : public wxDataViewRenderer
1187{
1188public:
1189 /**
c4e57202 1190 The ctor.
23324ae1
FM
1191 */
1192 wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
1193 const wxString& varianttype = "long",
05303ccd
RR
1194 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1195 int align = wxDVR_DEFAULT_ALIGNMENT );
23324ae1
FM
1196};
1197
1198
e54c96f1 1199
23324ae1
FM
1200/**
1201 @class wxDataViewSpinRenderer
7c913512 1202
c4e57202
FM
1203 This is a specialized renderer for rendering integer values.
1204 It supports modifying the values in-place by using a wxSpinCtrl.
23324ae1 1205 The renderer only support variants of type @e long.
7c913512 1206
8ed522d9 1207 @library{wxadv}
b321b61c 1208 @category{dvc}
23324ae1
FM
1209*/
1210class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
1211{
1212public:
1213 /**
c4e57202
FM
1214 Constructor.
1215 @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
23324ae1
FM
1216 */
1217 wxDataViewSpinRenderer(int min, int max,
1218 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
05303ccd 1219 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1220};
1221
1222
e54c96f1 1223
23324ae1
FM
1224/**
1225 @class wxDataViewToggleRenderer
7c913512 1226
c4e57202 1227 This class is used by wxDataViewCtrl to render toggle controls.
7c913512 1228
23324ae1 1229 @library{wxadv}
b321b61c 1230 @category{dvc}
23324ae1
FM
1231*/
1232class wxDataViewToggleRenderer : public wxDataViewRenderer
1233{
1234public:
1235 /**
c4e57202 1236 The ctor.
23324ae1
FM
1237 */
1238 wxDataViewToggleRenderer(const wxString& varianttype = "bool",
50ec54b6
FM
1239 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1240 int align = wxDVR_DEFAULT_ALIGNMENT);
23324ae1
FM
1241};
1242
1243
e54c96f1 1244
23324ae1 1245/**
5b99d5d8 1246 @class wxDataViewDateRenderer
7c913512 1247
c4e57202 1248 This class is used by wxDataViewCtrl to render calendar controls.
7c913512 1249
5b99d5d8 1250 @library{wxadv}
b321b61c 1251 @category{dvc}
23324ae1 1252*/
5b99d5d8 1253class wxDataViewDateRenderer : public wxDataViewRenderer
23324ae1
FM
1254{
1255public:
23324ae1 1256 /**
c4e57202 1257 The ctor.
23324ae1 1258 */
5b99d5d8 1259 wxDataViewDateRenderer(const wxString& varianttype = "datetime",
50ec54b6
FM
1260 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1261 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8 1262};
23324ae1 1263
3c4f71cc 1264
23324ae1 1265
5b99d5d8
RR
1266/**
1267 @class wxDataViewTextRendererAttr
23324ae1 1268
c4e57202
FM
1269 The same as wxDataViewTextRenderer but with support for font attributes.
1270 Font attributes are currently only supported under GTK+ and MSW.
23324ae1 1271
c4e57202 1272 @see wxDataViewModel::GetAttr and wxDataViewItemAttr.
23324ae1 1273
5b99d5d8 1274 @library{wxadv}
b321b61c 1275 @category{dvc}
5b99d5d8
RR
1276*/
1277class wxDataViewTextRendererAttr : public wxDataViewTextRenderer
1278{
1279public:
23324ae1 1280 /**
c4e57202 1281 The ctor.
23324ae1 1282 */
5b99d5d8
RR
1283 wxDataViewTextRendererAttr(const wxString& varianttype = "string",
1284 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1285 int align = wxDVR_DEFAULT_ALIGNMENT);
1286};
23324ae1 1287
23324ae1 1288
b321b61c 1289
5b99d5d8
RR
1290/**
1291 @class wxDataViewCustomRenderer
23324ae1 1292
5b99d5d8 1293 You need to derive a new class from wxDataViewCustomRenderer in
c4e57202
FM
1294 order to write a new renderer.
1295
1296 You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
1297 wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
1298
1299 If you want your renderer to support in-place editing then you also need to override
1300 wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
5b99d5d8 1301 and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
c4e57202
FM
1302
1303 Note that a special event handler will be pushed onto that editor control
1304 which handles @e \<ENTER\> and focus out events in order to end the editing.
23324ae1 1305
5b99d5d8 1306 @library{wxadv}
b321b61c 1307 @category{dvc}
5b99d5d8
RR
1308*/
1309class wxDataViewCustomRenderer : public wxDataViewRenderer
1310{
1311public:
23324ae1 1312 /**
5b99d5d8 1313 Constructor.
23324ae1 1314 */
5b99d5d8
RR
1315 wxDataViewCustomRenderer(const wxString& varianttype = "string",
1316 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
b91c4601 1317 int align = -1, bool no_init = false);
23324ae1
FM
1318
1319 /**
5b99d5d8 1320 Destructor.
23324ae1 1321 */
adaaa686 1322 virtual ~wxDataViewCustomRenderer();
23324ae1 1323
23324ae1 1324 /**
c4e57202
FM
1325 Override this to react to double clicks or ENTER.
1326 This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode.
23324ae1 1327 */
5b99d5d8
RR
1328 virtual bool Activate( wxRect cell,
1329 wxDataViewModel* model,
1330 const wxDataViewItem & item,
1331 unsigned int col );
23324ae1
FM
1332
1333 /**
5b99d5d8 1334 Override this to create the actual editor control once editing
c4e57202
FM
1335 is about to start.
1336
1337 @a parent is the parent of the editor control, @a labelRect indicates the
1338 position and size of the editor control and @a value is its initial value:
1339 @code
1340 {
1341 long l = value;
1342 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
1343 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
1344 }
1345 @endcode
23324ae1 1346 */
5b99d5d8
RR
1347 virtual wxControl* CreateEditorCtrl(wxWindow* parent,
1348 wxRect labelRect,
1349 const wxVariant& value);
23324ae1
FM
1350
1351 /**
5b99d5d8 1352 Create DC on request. Internal.
23324ae1 1353 */
5b99d5d8 1354 virtual wxDC* GetDC();
23324ae1
FM
1355
1356 /**
5b99d5d8 1357 Return size required to show content.
23324ae1 1358 */
b91c4601 1359 virtual wxSize GetSize() const = 0;
23324ae1
FM
1360
1361 /**
c4e57202
FM
1362 Overrride this so that the renderer can get the value from the editor
1363 control (pointed to by @a editor):
1364 @code
1365 {
1366 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
1367 long l = sc->GetValue();
1368 value = l;
1369 return true;
1370 }
1371 @endcode
23324ae1 1372 */
5b99d5d8
RR
1373 virtual bool GetValueFromEditorCtrl(wxControl* editor,
1374 wxVariant& value);
23324ae1
FM
1375
1376 /**
c4e57202 1377 Override this and make it return @true in order to
5b99d5d8 1378 indicate that this renderer supports in-place editing.
23324ae1 1379 */
220bfe15 1380 virtual bool HasEditorCtrl() const;
23324ae1
FM
1381
1382 /**
c4e57202
FM
1383 Overrride this to react to a left click.
1384 This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode.
23324ae1 1385 */
5b99d5d8
RR
1386 virtual bool LeftClick( wxPoint cursor,
1387 wxRect cell,
1388 wxDataViewModel * model,
1389 const wxDataViewItem & item,
1390 unsigned int col );
23324ae1
FM
1391
1392 /**
c4e57202
FM
1393 Override this to render the cell.
1394 Before this is called, wxDataViewRenderer::SetValue was called
5b99d5d8 1395 so that this instance knows what to render.
23324ae1 1396 */
b91c4601 1397 virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
23324ae1
FM
1398
1399 /**
c4e57202
FM
1400 This method should be called from within Render() whenever you need to
1401 render simple text.
1402 This will ensure that the correct colour, font and vertical alignment will
1403 be chosen so the text will look the same as text drawn by native renderers.
23324ae1 1404 */
50ec54b6 1405 void RenderText(const wxString& text, int xoffset, wxRect cell,
5b99d5d8 1406 wxDC* dc, int state);
23324ae1
FM
1407
1408 /**
c4e57202 1409 Overrride this to start a drag operation. Not yet supported.
23324ae1 1410 */
5b99d5d8
RR
1411 virtual bool StartDrag(wxPoint cursor, wxRect cell,
1412 wxDataViewModel* model,
1413 const wxDataViewItem & item,
1414 unsigned int col);
23324ae1
FM
1415};
1416
1417
e54c96f1 1418
23324ae1 1419/**
5b99d5d8 1420 @class wxDataViewBitmapRenderer
7c913512 1421
c4e57202 1422 This class is used by wxDataViewCtrl to render bitmap controls.
7c913512 1423
23324ae1 1424 @library{wxadv}
b321b61c 1425 @category{dvc}
23324ae1 1426*/
5b99d5d8 1427class wxDataViewBitmapRenderer : public wxDataViewRenderer
23324ae1
FM
1428{
1429public:
1430 /**
c4e57202 1431 The ctor.
23324ae1 1432 */
5b99d5d8
RR
1433 wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
1434 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
14d922d1 1435 int align = wxDVR_DEFAULT_ALIGNMENT);
5b99d5d8
RR
1436};
1437
23324ae1 1438
c4e57202
FM
1439/**
1440 The flags used by wxDataViewColumn.
02b51ae5 1441 Can be combined together.
c4e57202
FM
1442*/
1443enum wxDataViewColumnFlags
1444{
1445 wxDATAVIEW_COL_RESIZABLE = 1,
1446 wxDATAVIEW_COL_SORTABLE = 2,
1447 wxDATAVIEW_COL_REORDERABLE = 4,
1448 wxDATAVIEW_COL_HIDDEN = 8
1449};
23324ae1 1450
5b99d5d8
RR
1451/**
1452 @class wxDataViewColumn
5b99d5d8
RR
1453
1454 This class represents a column in a wxDataViewCtrl.
739a8399 1455 One wxDataViewColumn is bound to one column in the data model to which the
c4e57202 1456 wxDataViewCtrl has been associated.
5b99d5d8 1457
c4e57202 1458 An instance of wxDataViewRenderer is used by this class to render its data.
5b99d5d8
RR
1459
1460 @library{wxadv}
b321b61c 1461 @category{dvc}
5b99d5d8 1462*/
c9c59db7 1463class wxDataViewColumn : public wxSettableHeaderColumn
5b99d5d8
RR
1464{
1465public:
23324ae1 1466 /**
02b51ae5
FM
1467 Constructs a text column.
1468
1469 @param title
1470 The title of the column.
1471 @param renderer
1472 The class which will render the contents of this column.
1473 @param model_column
1474 The index of the model's column which is associated with this object.
1475 @param width
1476 The width of the column.
1477 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1478 @param align
1479 The alignment of the column title.
1480 @param flags
1481 One or more flags of the ::wxDataViewColumnFlags enumeration.
23324ae1 1482 */
5b99d5d8
RR
1483 wxDataViewColumn(const wxString& title,
1484 wxDataViewRenderer* renderer,
1485 unsigned int model_column,
1486 int width = wxDVC_DEFAULT_WIDTH,
882678eb 1487 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 1488 int flags = wxDATAVIEW_COL_RESIZABLE);
02b51ae5
FM
1489
1490 /**
1491 Constructs a bitmap column.
1492
1493 @param bitmap
1494 The bitmap of the column.
1495 @param renderer
1496 The class which will render the contents of this column.
1497 @param model_column
1498 The index of the model's column which is associated with this object.
1499 @param width
1500 The width of the column.
1501 The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
1502 @param align
1503 The alignment of the column title.
1504 @param flags
1505 One or more flags of the ::wxDataViewColumnFlags enumeration.
1506 */
5b99d5d8
RR
1507 wxDataViewColumn(const wxBitmap& bitmap,
1508 wxDataViewRenderer* renderer,
1509 unsigned int model_column,
1510 int width = wxDVC_DEFAULT_WIDTH,
882678eb 1511 wxAlignment align = wxALIGN_CENTER,
5b99d5d8 1512 int flags = wxDATAVIEW_COL_RESIZABLE);
23324ae1 1513
23324ae1 1514 /**
5b99d5d8
RR
1515 Returns the index of the column of the model, which this
1516 wxDataViewColumn is displaying.
23324ae1 1517 */
adaaa686 1518 unsigned int GetModelColumn() const;
23324ae1
FM
1519
1520 /**
5b99d5d8 1521 Returns the owning wxDataViewCtrl.
23324ae1 1522 */
e51bf699 1523 wxDataViewCtrl* GetOwner() const;
23324ae1
FM
1524
1525 /**
5b99d5d8 1526 Returns the renderer of this wxDataViewColumn.
c4e57202
FM
1527
1528 @see wxDataViewRenderer.
23324ae1 1529 */
adaaa686 1530 wxDataViewRenderer* GetRenderer() const;
23324ae1
FM
1531};
1532
1533
e54c96f1 1534
832df171
RR
1535/**
1536 @class wxDataViewListCtrl
1537
1538 This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
1539 and forwards most of its API to that class.
1540
1541 The purpose of this class is to offer a simple way to display and
1542 edit a small table of data without having to write your own wxDataViewModel.
1543
23efa4bf 1544 @code
14f73cf1 1545 wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
02b51ae5 1546
95b20f41
RR
1547 listctrl->AppendToggleColumn( "Toggle" );
1548 listctrl->AppendTextColumn( "Text" );
02b51ae5 1549
23efa4bf 1550 wxVector<wxVariant> data;
14f73cf1
FM
1551 data.push_back( wxVariant(true) );
1552 data.push_back( wxVariant("row 1") );
23efa4bf 1553 listctrl->AppendItem( data );
02b51ae5 1554
23efa4bf 1555 data.clear();
14f73cf1
FM
1556 data.push_back( wxVariant(false) );
1557 data.push_back( wxVariant("row 3") );
23efa4bf
RR
1558 listctrl->AppendItem( data );
1559 @endcode
14f73cf1
FM
1560
1561 @beginStyleTable
1562 See wxDataViewCtrl for the list of supported styles.
1563 @endStyleTable
1564
1565 @beginEventEmissionTable
1566 See wxDataViewCtrl for the list of events emitted by this class.
1567 @endEventTable
23efa4bf 1568
832df171
RR
1569 @library{wxadv}
1570 @category{ctrl,dvc}
1571*/
832df171
RR
1572class wxDataViewListCtrl: public wxDataViewCtrl
1573{
b75b04d4 1574public:
832df171
RR
1575 /**
1576 Default ctor.
1577 */
1578 wxDataViewListCtrl();
02b51ae5 1579
832df171
RR
1580 /**
1581 Constructor. Calls Create().
1582 */
1583 wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
1584 const wxPoint& pos = wxDefaultPosition,
1585 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1586 const wxValidator& validator = wxDefaultValidator );
02b51ae5 1587
832df171
RR
1588 /**
1589 Destructor. Deletes the image list if any.
1590 */
1591 ~wxDataViewListCtrl();
1592
1593 /**
1594 Creates the control and a wxDataViewListStore as its internal model.
1595 */
1596 bool Create( wxWindow *parent, wxWindowID id,
1597 const wxPoint& pos = wxDefaultPosition,
1598 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1599 const wxValidator& validator = wxDefaultValidator );
1600
1601 //@{
1602 /**
1603 Returns the store.
1604 */
1605 wxDataViewListStore *GetStore();
1606 const wxDataViewListStore *GetStore() const;
1607 //@}
1608
1609 /**
14f73cf1
FM
1610 @name Column management functions
1611 */
1612 //@{
1613
1614 /**
1615 Appends a column to the control and additionally appends a
1616 column to the store with the type string.
1617 */
1618 virtual void AppendColumn( wxDataViewColumn *column );
1619
1620 /**
1621 Appends a column to the control and additionally appends a
1622 column to the list store with the type @a varianttype.
832df171 1623 */
95b20f41 1624 void AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 1625
832df171 1626 /**
14f73cf1
FM
1627 Appends a text column to the control and the store.
1628
1629 See wxDataViewColumn::wxDataViewColumn for more info about
1630 the parameters.
832df171 1631 */
14f73cf1
FM
1632 wxDataViewColumn *AppendTextColumn( const wxString &label,
1633 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1634 int width = -1, wxAlignment align = wxALIGN_LEFT,
1635 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 1636
832df171 1637 /**
14f73cf1
FM
1638 Appends a toggle column to the control and the store.
1639
1640 See wxDataViewColumn::wxDataViewColumn for more info about
1641 the parameters.
832df171 1642 */
14f73cf1
FM
1643 wxDataViewColumn *AppendToggleColumn( const wxString &label,
1644 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
1645 int width = -1, wxAlignment align = wxALIGN_LEFT,
1646 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 1647
95b20f41 1648 /**
14f73cf1 1649 Appends a progress column to the control and the store.
02b51ae5 1650
14f73cf1
FM
1651 See wxDataViewColumn::wxDataViewColumn for more info about
1652 the parameters.
95b20f41 1653 */
14f73cf1
FM
1654 wxDataViewColumn *AppendProgressColumn( const wxString &label,
1655 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1656 int width = -1, wxAlignment align = wxALIGN_LEFT,
1657 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 1658
95b20f41 1659 /**
14f73cf1 1660 Appends an icon-and-text column to the control and the store.
02b51ae5 1661
14f73cf1
FM
1662 See wxDataViewColumn::wxDataViewColumn for more info about
1663 the parameters.
95b20f41 1664 */
14f73cf1
FM
1665 wxDataViewColumn *AppendIconTextColumn( const wxString &label,
1666 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
1667 int width = -1, wxAlignment align = wxALIGN_LEFT,
1668 int flags = wxDATAVIEW_COL_RESIZABLE );
02b51ae5 1669
95b20f41 1670 /**
14f73cf1 1671 Inserts a column to the control and additionally inserts a
95b20f41
RR
1672 column to the store with the type string.
1673 */
1674 virtual void InsertColumn( unsigned int pos, wxDataViewColumn *column );
02b51ae5 1675
832df171 1676 /**
14f73cf1
FM
1677 Inserts a column to the control and additionally inserts a
1678 column to the list store with the type @a varianttype.
832df171 1679 */
14f73cf1
FM
1680 void InsertColumn( unsigned int pos, wxDataViewColumn *column,
1681 const wxString &varianttype );
02b51ae5 1682
832df171 1683 /**
14f73cf1
FM
1684 Prepends a column to the control and additionally prepends a
1685 column to the store with the type string.
832df171 1686 */
14f73cf1 1687 virtual void PrependColumn( wxDataViewColumn *column );
02b51ae5 1688
832df171 1689 /**
14f73cf1
FM
1690 Prepends a column to the control and additionally prepends a
1691 column to the list store with the type @a varianttype.
832df171 1692 */
14f73cf1 1693 void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
02b51ae5 1694
14f73cf1
FM
1695 //@}
1696
1697
832df171 1698 /**
14f73cf1 1699 @name Item management functions
832df171 1700 */
14f73cf1
FM
1701 //@{
1702
832df171
RR
1703 /**
1704 Appends an item (=row) to the control and store.
1705 */
1706 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1707
1708 /**
1709 Prepends an item (=row) to the control and store.
1710 */
1711 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1712
1713 /**
1714 Inserts an item (=row) to the control and store.
1715 */
14f73cf1 1716 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
02b51ae5 1717
832df171
RR
1718 /**
1719 Delete the row at position @a row.
1720 */
1721 void DeleteItem( unsigned row );
02b51ae5 1722
832df171
RR
1723 /**
1724 Delete all items (= all rows).
1725 */
1726 void DeleteAllItems();
02b51ae5 1727
832df171
RR
1728 /**
1729 Sets the value in the store and update the control.
1730 */
1731 void SetValue( const wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 1732
832df171
RR
1733 /**
1734 Returns the value from the store.
1735 */
1736 void GetValue( wxVariant &value, unsigned int row, unsigned int col );
02b51ae5 1737
832df171 1738 /**
02b51ae5
FM
1739 Sets the value in the store and update the control.
1740
832df171
RR
1741 This method assumes that the a string is stored in respective
1742 column.
1743 */
1744 void SetTextValue( const wxString &value, unsigned int row, unsigned int col );
02b51ae5 1745
832df171
RR
1746 /**
1747 Returns the value from the store.
02b51ae5 1748
832df171
RR
1749 This method assumes that the a string is stored in respective
1750 column.
1751 */
1752 wxString GetTextValue( unsigned int row, unsigned int col ) const;
02b51ae5 1753
832df171 1754 /**
02b51ae5
FM
1755 Sets the value in the store and update the control.
1756
832df171
RR
1757 This method assumes that the a boolean value is stored in
1758 respective column.
1759 */
1760 void SetToggleValue( bool value, unsigned int row, unsigned int col );
02b51ae5 1761
832df171
RR
1762 /**
1763 Returns the value from the store.
02b51ae5 1764
832df171
RR
1765 This method assumes that the a boolean value is stored in
1766 respective column.
1767 */
1768 bool GetToggleValue( unsigned int row, unsigned int col ) const;
14f73cf1
FM
1769
1770 //@}
832df171
RR
1771};
1772
1773
23324ae1 1774/**
5b99d5d8 1775 @class wxDataViewTreeCtrl
7c913512 1776
c4e57202
FM
1777 This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
1778 and forwards most of its API to that class.
1779 Additionally, it uses a wxImageList to store a list of icons.
1780
14f73cf1
FM
1781 The main purpose of this class is to represent a possible replacement for
1782 wxTreeCtrl.
1783
1784 @beginStyleTable
1785 See wxDataViewCtrl for the list of supported styles.
1786 @endStyleTable
1787
1788 @beginEventEmissionTable
1789 See wxDataViewCtrl for the list of events emitted by this class.
1790 @endEventTable
7c913512 1791
8ed522d9 1792 @library{wxadv}
b321b61c 1793 @category{ctrl,dvc}
7e59b885 1794 @appearance{dataviewtreectrl.png}
23324ae1 1795*/
5b99d5d8 1796class wxDataViewTreeCtrl : public wxDataViewCtrl
23324ae1
FM
1797{
1798public:
1799 /**
c4e57202 1800 Default ctor.
5b99d5d8
RR
1801 */
1802 wxDataViewTreeCtrl();
c4e57202
FM
1803
1804 /**
1805 Constructor. Calls Create().
1806 */
5b99d5d8
RR
1807 wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
1808 const wxPoint& pos = wxDefaultPosition,
1809 const wxSize& size = wxDefaultSize,
1810 long style = wxDV_NO_HEADER,
1811 const wxValidator& validator = wxDefaultValidator);
3c4f71cc 1812
5b99d5d8
RR
1813 /**
1814 Destructor. Deletes the image list if any.
23324ae1 1815 */
adaaa686 1816 virtual ~wxDataViewTreeCtrl();
23324ae1 1817
5b99d5d8 1818 /**
b75b04d4 1819 Appends a container to the given @a parent.
5b99d5d8
RR
1820 */
1821 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
1822 const wxString& text,
1823 int icon = -1,
1824 int expanded = -1,
1825 wxClientData* data = NULL);
e54c96f1 1826
5b99d5d8 1827 /**
b75b04d4 1828 Appends an item to the given @a parent.
5b99d5d8
RR
1829 */
1830 wxDataViewItem AppendItem(const wxDataViewItem& parent,
1831 const wxString& text,
1832 int icon = -1,
1833 wxClientData* data = NULL);
7c913512 1834
5b99d5d8 1835 /**
c4e57202 1836 Creates the control and a wxDataViewTreeStore as its internal model.
5b99d5d8
RR
1837 */
1838 bool Create(wxWindow* parent, wxWindowID id,
1839 const wxPoint& pos = wxDefaultPosition,
1840 const wxSize& size = wxDefaultSize,
1841 long style = wxDV_NO_HEADER,
1842 const wxValidator& validator = wxDefaultValidator);
1843
1844 /**
1845 Calls the identical method from wxDataViewTreeStore.
1846 */
1847 void DeleteAllItems();
7c913512 1848
23324ae1 1849 /**
5b99d5d8
RR
1850 Calls the identical method from wxDataViewTreeStore.
1851 */
1852 void DeleteChildren(const wxDataViewItem& item);
3c4f71cc 1853
5b99d5d8
RR
1854 /**
1855 Calls the identical method from wxDataViewTreeStore.
23324ae1 1856 */
5b99d5d8 1857 void DeleteItem(const wxDataViewItem& item);
23324ae1 1858
5b99d5d8
RR
1859 /**
1860 Calls the identical method from wxDataViewTreeStore.
1861 */
1862 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1 1863
5b99d5d8
RR
1864 /**
1865 Returns the image list.
1866 */
1867 wxImageList* GetImageList();
05303ccd 1868
5b99d5d8
RR
1869 /**
1870 Calls the identical method from wxDataViewTreeStore.
1871 */
1872 wxClientData* GetItemData(const wxDataViewItem& item) const;
05303ccd 1873
5b99d5d8
RR
1874 /**
1875 Calls the identical method from wxDataViewTreeStore.
1876 */
b91c4601 1877 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
05303ccd 1878
05303ccd 1879 /**
5b99d5d8 1880 Calls the identical method from wxDataViewTreeStore.
05303ccd 1881 */
b91c4601 1882 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
05303ccd
RR
1883
1884 /**
5b99d5d8 1885 Calls the identical method from wxDataViewTreeStore.
05303ccd 1886 */
5b99d5d8
RR
1887 wxString GetItemText(const wxDataViewItem& item) const;
1888
1889 /**
1890 Calls the identical method from wxDataViewTreeStore.
1891 */
1892 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
1893 unsigned int pos) const;
05303ccd 1894
5b99d5d8 1895 //@{
05303ccd 1896 /**
5b99d5d8 1897 Returns the store.
05303ccd 1898 */
882678eb 1899 wxDataViewTreeStore* GetStore();
5b99d5d8
RR
1900 const wxDataViewTreeStore* GetStore() const;
1901 //@}
05303ccd
RR
1902
1903 /**
c4e57202
FM
1904 Calls the same method from wxDataViewTreeStore but uses
1905 an index position in the image list instead of a wxIcon.
05303ccd 1906 */
5b99d5d8
RR
1907 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
1908 const wxDataViewItem& previous,
1909 const wxString& text,
1910 int icon = -1,
1911 int expanded = -1,
1912 wxClientData* data = NULL);
05303ccd
RR
1913
1914 /**
c4e57202
FM
1915 Calls the same method from wxDataViewTreeStore but uses
1916 an index position in the image list instead of a wxIcon.
05303ccd 1917 */
5b99d5d8
RR
1918 wxDataViewItem InsertItem(const wxDataViewItem& parent,
1919 const wxDataViewItem& previous,
1920 const wxString& text,
1921 int icon = -1,
1922 wxClientData* data = NULL);
05303ccd
RR
1923
1924 /**
c4e57202
FM
1925 Calls the same method from wxDataViewTreeStore but uses
1926 an index position in the image list instead of a wxIcon.
05303ccd 1927 */
5b99d5d8
RR
1928 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
1929 const wxString& text,
1930 int icon = -1,
1931 int expanded = -1,
1932 wxClientData* data = NULL);
05303ccd
RR
1933
1934 /**
c4e57202
FM
1935 Calls the same method from wxDataViewTreeStore but uses
1936 an index position in the image list instead of a wxIcon.
05303ccd 1937 */
5b99d5d8
RR
1938 wxDataViewItem PrependItem(const wxDataViewItem& parent,
1939 const wxString& text,
1940 int icon = -1,
1941 wxClientData* data = NULL);
05303ccd
RR
1942
1943 /**
5b99d5d8 1944 Sets the image list.
05303ccd 1945 */
5b99d5d8 1946 void SetImageList(wxImageList* imagelist);
05303ccd
RR
1947
1948 /**
5b99d5d8 1949 Calls the identical method from wxDataViewTreeStore.
05303ccd 1950 */
5b99d5d8 1951 void SetItemData(const wxDataViewItem& item, wxClientData* data);
05303ccd
RR
1952
1953 /**
5b99d5d8 1954 Calls the identical method from wxDataViewTreeStore.
05303ccd 1955 */
5b99d5d8
RR
1956 void SetItemExpandedIcon(const wxDataViewItem& item,
1957 const wxIcon& icon);
05303ccd
RR
1958
1959 /**
5b99d5d8 1960 Calls the identical method from wxDataViewTreeStore.
05303ccd 1961 */
5b99d5d8 1962 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
05303ccd
RR
1963
1964 /**
5b99d5d8 1965 Calls the identical method from wxDataViewTreeStore.
05303ccd 1966 */
5b99d5d8
RR
1967 void SetItemText(const wxDataViewItem& item,
1968 const wxString& text);
05303ccd
RR
1969};
1970
1971
bda698ed
RR
1972/**
1973 @class wxDataViewListStore
1974
1975 wxDataViewListStore is a specialised wxDataViewModel for storing
1976 a simple table of data. Since it derives from wxDataViewIndexListModel
1977 its data is be accessed by row (i.e. by index) instead of only
1978 by wxDataViewItem.
1979
02b51ae5 1980 This class actually stores the values (therefore its name)
bda698ed 1981 and implements all virtual methods from the base classes so it can be
02b51ae5 1982 used directly without having to derive any class from it, but it is
bda698ed
RR
1983 mostly used from within wxDataViewListCtrl.
1984
1985 @library{wxadv}
1986 @category{dvc}
1987*/
1988
1989class wxDataViewListStore: public wxDataViewIndexListModel
1990{
1991public:
1992 /**
02b51ae5 1993 Constructor
bda698ed
RR
1994 */
1995 wxDataViewListStore();
02b51ae5 1996
bda698ed 1997 /**
02b51ae5 1998 Destructor
bda698ed
RR
1999 */
2000 ~wxDataViewListStore();
2001
2002 /**
02b51ae5
FM
2003 Prepends a data column.
2004
2005 @a variantype indicates the type of values store in the column.
2006
2007 This does not automatically fill in any (default) values in
2008 rows which exist in the store already.
bda698ed
RR
2009 */
2010 void PrependColumn( const wxString &varianttype );
2011
2012 /**
02b51ae5
FM
2013 Inserts a data column before @a pos.
2014
2015 @a variantype indicates the type of values store in the column.
2016
2017 This does not automatically fill in any (default) values in
2018 rows which exist in the store already.
bda698ed
RR
2019 */
2020 void InsertColumn( unsigned int pos, const wxString &varianttype );
2021
2022 /**
02b51ae5
FM
2023 Appends a data column.
2024
2025 @a variantype indicates the type of values store in the column.
2026
2027 This does not automatically fill in any (default) values in
2028 rows which exist in the store already.
bda698ed
RR
2029 */
2030 void AppendColumn( const wxString &varianttype );
02b51ae5 2031
bda698ed
RR
2032 /**
2033 Appends an item (=row) and fills it with @a values.
02b51ae5 2034
bda698ed
RR
2035 The values must match the values specifies in the column
2036 in number and type. No (default) values are filled in
2037 automatically.
2038 */
2039 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
02b51ae5 2040
bda698ed
RR
2041 /**
2042 Prepends an item (=row) and fills it with @a values.
02b51ae5 2043
bda698ed
RR
2044 The values must match the values specifies in the column
2045 in number and type. No (default) values are filled in
2046 automatically.
2047 */
2048 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
02b51ae5 2049
bda698ed
RR
2050 /**
2051 Inserts an item (=row) and fills it with @a values.
02b51ae5 2052
bda698ed
RR
2053 The values must match the values specifies in the column
2054 in number and type. No (default) values are filled in
2055 automatically.
2056 */
2057 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
02b51ae5 2058
bda698ed
RR
2059 /**
2060 Delete the item (=row) at position @a pos.
2061 */
2062 void DeleteItem( unsigned pos );
02b51ae5 2063
bda698ed
RR
2064 /**
2065 Delete all item (=all rows) in the store.
2066 */
2067 void DeleteAllItems();
2068
2069 /**
2070 Overriden from wxDataViewModel
2071 */
2072 virtual unsigned int GetColumnCount() const;
2073
2074 /**
2075 Overriden from wxDataViewModel
2076 */
2077 virtual wxString GetColumnType( unsigned int col ) const;
2078
2079 /**
2080 Overriden from wxDataViewIndexListModel
2081 */
2082 virtual void GetValueByRow( wxVariant &value,
2083 unsigned int row, unsigned int col ) const;
2084
2085 /**
2086 Overriden from wxDataViewIndexListModel
2087 */
2088 virtual bool SetValueByRow( const wxVariant &value,
2089 unsigned int row, unsigned int col );
2090};
2091
05303ccd
RR
2092
2093/**
5b99d5d8 2094 @class wxDataViewTreeStore
05303ccd 2095
bda698ed 2096 wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple
c4e57202
FM
2097 trees very much like wxTreeCtrl does and it offers a similar API.
2098
02b51ae5 2099 This class actually stores the entire tree and the values (therefore its name)
8eff6c56 2100 and implements all virtual methods from the base class so it can be used directly
bda698ed
RR
2101 without having to derive any class from it, but it is mostly used from within
2102 wxDataViewTreeCtrl.
05303ccd
RR
2103
2104 @library{wxadv}
b321b61c 2105 @category{dvc}
05303ccd 2106*/
5b99d5d8 2107class wxDataViewTreeStore : public wxDataViewModel
05303ccd
RR
2108{
2109public:
2110 /**
5b99d5d8 2111 Constructor. Creates the invisible root node internally.
05303ccd 2112 */
5b99d5d8 2113 wxDataViewTreeStore();
e54c96f1 2114
5b99d5d8
RR
2115 /**
2116 Destructor.
2117 */
adaaa686 2118 virtual ~wxDataViewTreeStore();
7c913512 2119
5b99d5d8
RR
2120 /**
2121 Append a container.
2122 */
2123 wxDataViewItem AppendContainer(const wxDataViewItem& parent,
2124 const wxString& text,
2125 const wxIcon& icon = wxNullIcon,
2126 const wxIcon& expanded = wxNullIcon,
2127 wxClientData* data = NULL);
7c913512 2128
5b99d5d8
RR
2129 /**
2130 Append an item.
2131 */
2132 wxDataViewItem AppendItem(const wxDataViewItem& parent,
2133 const wxString& text,
2134 const wxIcon& icon = wxNullIcon,
2135 wxClientData* data = NULL);
7c913512 2136
23324ae1 2137 /**
5b99d5d8 2138 Delete all item in the model.
23324ae1 2139 */
5b99d5d8 2140 void DeleteAllItems();
23324ae1
FM
2141
2142 /**
5b99d5d8 2143 Delete all children of the item, but not the item itself.
23324ae1 2144 */
5b99d5d8 2145 void DeleteChildren(const wxDataViewItem& item);
23324ae1
FM
2146
2147 /**
5b99d5d8 2148 Delete this item.
23324ae1 2149 */
5b99d5d8 2150 void DeleteItem(const wxDataViewItem& item);
23324ae1
FM
2151
2152 /**
5b99d5d8 2153 Return the number of children of item.
23324ae1 2154 */
5b99d5d8 2155 int GetChildCount(const wxDataViewItem& parent) const;
23324ae1
FM
2156
2157 /**
5b99d5d8 2158 Returns the client data asoociated with the item.
23324ae1 2159 */
5b99d5d8 2160 wxClientData* GetItemData(const wxDataViewItem& item) const;
23324ae1
FM
2161
2162 /**
5b99d5d8 2163 Returns the icon to display in expanded containers.
23324ae1 2164 */
b91c4601 2165 const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
23324ae1
FM
2166
2167 /**
5b99d5d8 2168 Returns the icon of the item.
23324ae1 2169 */
b91c4601 2170 const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
23324ae1
FM
2171
2172 /**
5b99d5d8 2173 Returns the text of the item.
23324ae1 2174 */
5b99d5d8 2175 wxString GetItemText(const wxDataViewItem& item) const;
23324ae1
FM
2176
2177 /**
5b99d5d8 2178 Returns the nth child item of item.
23324ae1 2179 */
5b99d5d8
RR
2180 wxDataViewItem GetNthChild(const wxDataViewItem& parent,
2181 unsigned int pos) const;
23324ae1
FM
2182
2183 /**
c4e57202 2184 Inserts a container after @a previous.
23324ae1 2185 */
5b99d5d8
RR
2186 wxDataViewItem InsertContainer(const wxDataViewItem& parent,
2187 const wxDataViewItem& previous,
2188 const wxString& text,
2189 const wxIcon& icon = wxNullIcon,
2190 const wxIcon& expanded = wxNullIcon,
2191 wxClientData* data = NULL);
23324ae1
FM
2192
2193 /**
c4e57202 2194 Inserts an item after @a previous.
23324ae1 2195 */
5b99d5d8
RR
2196 wxDataViewItem InsertItem(const wxDataViewItem& parent,
2197 const wxDataViewItem& previous,
2198 const wxString& text,
2199 const wxIcon& icon = wxNullIcon,
2200 wxClientData* data = NULL);
23324ae1
FM
2201
2202 /**
c4e57202 2203 Inserts a container before the first child item or @a parent.
23324ae1 2204 */
5b99d5d8
RR
2205 wxDataViewItem PrependContainer(const wxDataViewItem& parent,
2206 const wxString& text,
2207 const wxIcon& icon = wxNullIcon,
2208 const wxIcon& expanded = wxNullIcon,
2209 wxClientData* data = NULL);
23324ae1
FM
2210
2211 /**
c4e57202 2212 Inserts an item before the first child item or @a parent.
23324ae1 2213 */
5b99d5d8
RR
2214 wxDataViewItem PrependItem(const wxDataViewItem& parent,
2215 const wxString& text,
2216 const wxIcon& icon = wxNullIcon,
2217 wxClientData* data = NULL);
23324ae1
FM
2218
2219 /**
5b99d5d8 2220 Sets the client data associated with the item.
23324ae1 2221 */
5b99d5d8 2222 void SetItemData(const wxDataViewItem& item, wxClientData* data);
23324ae1
FM
2223
2224 /**
5b99d5d8 2225 Sets the expanded icon for the item.
23324ae1 2226 */
5b99d5d8
RR
2227 void SetItemExpandedIcon(const wxDataViewItem& item,
2228 const wxIcon& icon);
23324ae1
FM
2229
2230 /**
5b99d5d8 2231 Sets the icon for the item.
23324ae1 2232 */
5b99d5d8 2233 void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
23324ae1 2234};
e54c96f1 2235
80932a3e
FM
2236
2237/**
2238 @class wxDataViewIconText
2239
2240 wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
2241 This class can be converted to and from a wxVariant.
2242
2243 @library{wxadv}
2244 @category{dvc}
2245*/
2246class wxDataViewIconText : public wxObject
2247{
2248public:
2249 //@{
2250 /**
2251 Constructor.
2252 */
2253 wxDataViewIconText(const wxString& text = wxEmptyString,
2254 const wxIcon& icon = wxNullIcon);
2255 wxDataViewIconText(const wxDataViewIconText& other);
2256 //@}
2257
2258 /**
2259 Gets the icon.
2260 */
2261 const wxIcon& GetIcon() const;
2262
2263 /**
2264 Gets the text.
2265 */
2266 wxString GetText() const;
2267
2268 /**
2269 Set the icon.
2270 */
2271 void SetIcon(const wxIcon& icon);
2272
2273 /**
2274 Set the text.
2275 */
2276 void SetText(const wxString& text);
2277};
2278
2279
2280
2281/**
2282 @class wxDataViewEvent
2283
2284 This is the event class for the wxDataViewCtrl notifications.
2285
14f73cf1
FM
2286 @beginEventTable{wxDataViewEvent}
2287 @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
2288 Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event.
2289 @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
2290 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.
2291 @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
2292 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event.
2293 @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
2294 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event.
2295 @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
2296 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event.
2297 @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
2298 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event.
2299 @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
2300 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event.
2301 @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
2302 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event.
2303 @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
2304 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event.
2305 @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
2306 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event.
2307 @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
2308 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event.
2309 @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
2310 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event.
2311 @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
2312 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event.
2313 @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
2314 Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event.
2315 @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
2316 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event.
2317 @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
2318 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event.
2319 @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
2320 Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event.
2321 @endEventTable
2322
80932a3e
FM
2323 @library{wxadv}
2324 @category{events,dvc}
2325*/
2326class wxDataViewEvent : public wxNotifyEvent
2327{
2328public:
80932a3e
FM
2329 /**
2330 Constructor. Typically used by wxWidgets internals only.
2331 */
2332 wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
2333 int winid = 0);
80932a3e
FM
2334
2335 /**
2336 Returns the position of the column in the control or -1
2337 if no column field was set by the event emitter.
2338 */
2339 int GetColumn() const;
2340
2341 /**
2342 Returns a pointer to the wxDataViewColumn from which
2343 the event was emitted or @NULL.
2344 */
2345 wxDataViewColumn* GetDataViewColumn() const;
2346
2347 /**
2348 Returns the wxDataViewModel associated with the event.
2349 */
2350 wxDataViewModel* GetModel() const;
2351
2352 /**
2353 Returns a the position of a context menu event in screen coordinates.
2354 */
2355 wxPoint GetPosition() const;
2356
2357 /**
2358 Returns a reference to a value.
2359 */
2360 const wxVariant& GetValue() const;
2361
2362 /**
2363 Sets the column index associated with this event.
2364 */
2365 void SetColumn(int col);
2366
2367 /**
2368 For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only.
2369 */
2370 void SetDataViewColumn(wxDataViewColumn* col);
2371
2372 /**
2373 Sets the dataview model associated with this event.
2374 */
2375 void SetModel(wxDataViewModel* model);
2376
2377 /**
2378 Sets the value associated with this event.
2379 */
2380 void SetValue(const wxVariant& value);
02b51ae5 2381
591cc82d 2382 /**
e4de825e 2383 Set wxDataObject for data transfer within a drag operation.
591cc82d
RR
2384 */
2385 void SetDataObject( wxDataObject *obj );
02b51ae5 2386
591cc82d 2387 /**
e4de825e
RR
2388 Used internally. Gets associated wxDataObject for data transfer
2389 within a drag operation.
2390 */
2391 wxDataObject *GetDataObject() const;
02b51ae5 2392
e4de825e
RR
2393 /**
2394 Used internally. Sets the wxDataFormat during a drop operation.
2395 */
2396 void SetDataFormat( const wxDataFormat &format );
02b51ae5 2397
e4de825e
RR
2398 /**
2399 Gets the wxDataFormat during a drop operation.
2400 */
2401 wxDataFormat GetDataFormat() const;
02b51ae5 2402
e4de825e
RR
2403 /**
2404 Used internally. Sets the data size for a drop data transfer.
2405 */
2406 void SetDataSize( size_t size );
02b51ae5 2407
e4de825e
RR
2408 /**
2409 Gets the data size for a drop data transfer.
2410 */
2411 size_t GetDataSize() const;
02b51ae5 2412
e4de825e
RR
2413 /**
2414 Used internally. Sets the data buffer for a drop data transfer.
2415 */
2416 void SetDataBuffer( void* buf );
02b51ae5 2417
e4de825e
RR
2418 /**
2419 Gets the data buffer for a drop data transfer.
591cc82d 2420 */
e4de825e 2421 void *GetDataBuffer() const;
80932a3e
FM
2422};
2423