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