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