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