]>
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: | |
23324ae1 | 690 | /** |
19723525 | 691 | Default Constructor. |
23324ae1 FM |
692 | */ |
693 | wxDataViewCtrl(); | |
19723525 RR |
694 | |
695 | /** | |
696 | Constructor. Calls Create(). | |
697 | */ | |
7c913512 FM |
698 | wxDataViewCtrl(wxWindow* parent, wxWindowID id, |
699 | const wxPoint& pos = wxDefaultPosition, | |
700 | const wxSize& size = wxDefaultSize, | |
701 | long style = 0, | |
702 | const wxValidator& validator = wxDefaultValidator); | |
23324ae1 FM |
703 | |
704 | /** | |
705 | Destructor. | |
706 | */ | |
707 | ~wxDataViewCtrl(); | |
708 | ||
e39de702 | 709 | /** |
19723525 | 710 | Appends a wxDataViewColumn to the control. Returns @true on success. |
e39de702 RR |
711 | Note that there is a number of short cut methods which implicitly create |
712 | a wxDataViewColumn and a wxDataViewRenderer for it (see below). | |
713 | */ | |
714 | virtual bool AppendColumn(wxDataViewColumn* col); | |
715 | ||
19723525 RR |
716 | /** |
717 | Prepends a wxDataViewColumn to the control. Returns @true on success. | |
718 | Note that there is a number of short cut methods which implicitly create | |
719 | a wxDataViewColumn and a wxDataViewRenderer for it. | |
720 | */ | |
721 | virtual bool PrependColumn(wxDataViewColumn* col); | |
722 | ||
723 | /** | |
724 | Inserts a wxDataViewColumn to the control. Returns @true on success. | |
725 | */ | |
726 | virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col); | |
727 | ||
23324ae1 FM |
728 | //@{ |
729 | /** | |
730 | Appends a column for rendering a bitmap. Returns the wxDataViewColumn | |
731 | created in the function or @NULL on failure. | |
732 | */ | |
733 | wxDataViewColumn* AppendBitmapColumn(const wxString& label, | |
734 | unsigned int model_column, | |
735 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
736 | int width = -1, | |
737 | wxAlignment align = wxALIGN_CENTER, | |
738 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
739 | wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label, |
740 | unsigned int model_column, | |
741 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
742 | int width = -1, | |
743 | wxAlignment align = wxALIGN_CENTER, | |
744 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
745 | //@} |
746 | ||
23324ae1 FM |
747 | //@{ |
748 | /** | |
749 | Appends a column for rendering a date. Returns the wxDataViewColumn | |
750 | created in the function or @NULL on failure. | |
e39de702 RR |
751 | |
752 | NB: The @e align parameter is applied to both the column header and | |
753 | the column renderer. | |
23324ae1 FM |
754 | */ |
755 | wxDataViewColumn* AppendDateColumn(const wxString& label, | |
756 | unsigned int model_column, | |
757 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
758 | int width = -1, | |
759 | wxAlignment align = wxALIGN_CENTER, | |
760 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
761 | wxDataViewColumn* AppendDateColumn(const wxBitmap& label, |
762 | unsigned int model_column, | |
763 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
764 | int width = -1, | |
765 | wxAlignment align = wxALIGN_CENTER, | |
766 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
767 | //@} |
768 | ||
769 | //@{ | |
770 | /** | |
771 | Appends a column for rendering text with an icon. Returns the wxDataViewColumn | |
e39de702 RR |
772 | created in the function or @NULL on failure. This method uses the |
773 | wxDataViewIconTextRenderer class. | |
774 | ||
775 | NB: The @e align parameter is applied to both the column header and | |
776 | the column renderer. | |
23324ae1 FM |
777 | */ |
778 | wxDataViewColumn* AppendIconTextColumn(const wxString& label, | |
779 | unsigned int model_column, | |
780 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
781 | int width = -1, | |
782 | wxAlignment align = wxALIGN_LEFT, | |
783 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
784 | wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label, |
785 | unsigned int model_column, | |
786 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
787 | int width = -1, | |
788 | wxAlignment align = wxALIGN_LEFT, | |
789 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
790 | //@} |
791 | ||
792 | //@{ | |
793 | /** | |
794 | Appends a column for rendering a progress indicator. Returns the | |
e39de702 RR |
795 | wxDataViewColumn created in the function or @NULL on failure. |
796 | ||
797 | NB: The @e align parameter is applied to both the column header and | |
798 | the column renderer. | |
23324ae1 FM |
799 | */ |
800 | wxDataViewColumn* AppendProgressColumn(const wxString& label, | |
801 | unsigned int model_column, | |
802 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
803 | int width = 80, | |
804 | wxAlignment align = wxALIGN_CENTER, | |
805 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
806 | wxDataViewColumn* AppendProgressColumn(const wxBitmap& label, |
807 | unsigned int model_column, | |
808 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
809 | int width = 80, | |
810 | wxAlignment align = wxALIGN_CENTER, | |
811 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
812 | //@} |
813 | ||
814 | //@{ | |
815 | /** | |
816 | Appends a column for rendering text. Returns the wxDataViewColumn | |
817 | created in the function or @NULL on failure. | |
e39de702 RR |
818 | |
819 | NB: The @e align parameter is applied to both the column header and | |
820 | the column renderer. | |
23324ae1 FM |
821 | */ |
822 | wxDataViewColumn* AppendTextColumn(const wxString& label, | |
823 | unsigned int model_column, | |
824 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
825 | int width = -1, | |
826 | wxAlignment align = wxALIGN_LEFT, | |
827 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
828 | wxDataViewColumn* AppendTextColumn(const wxBitmap& label, |
829 | unsigned int model_column, | |
830 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
831 | int width = -1, | |
832 | wxAlignment align = wxALIGN_LEFT, | |
833 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
834 | //@} |
835 | ||
836 | //@{ | |
837 | /** | |
838 | Appends a column for rendering a toggle. Returns the wxDataViewColumn | |
839 | created in the function or @NULL on failure. | |
e39de702 RR |
840 | |
841 | NB: The @e align parameter is applied to both the column header and | |
842 | the column renderer. | |
23324ae1 FM |
843 | */ |
844 | wxDataViewColumn* AppendToggleColumn(const wxString& label, | |
845 | unsigned int model_column, | |
846 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
847 | int width = 30, | |
848 | wxAlignment align = wxALIGN_CENTER, | |
849 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
850 | wxDataViewColumn* AppendToggleColumn(const wxBitmap& label, |
851 | unsigned int model_column, | |
852 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
853 | int width = 30, | |
854 | wxAlignment align = wxALIGN_CENTER, | |
855 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
856 | //@} |
857 | ||
858 | /** | |
e39de702 RR |
859 | Associates a wxDataViewModel with the control. This increases the reference |
860 | count of the model by 1. | |
23324ae1 FM |
861 | */ |
862 | virtual bool AssociateModel(wxDataViewModel* model); | |
863 | ||
864 | /** | |
865 | Removes all columns. | |
866 | */ | |
867 | virtual bool ClearColumns(); | |
868 | ||
869 | /** | |
870 | Unselects all rows. | |
871 | */ | |
872 | void ClearSelection(); | |
873 | ||
874 | /** | |
875 | Collapses the item. | |
876 | */ | |
4cc4bfaf | 877 | void Collapse(const wxDataViewItem& item); |
23324ae1 FM |
878 | |
879 | /** | |
880 | Create the control. Useful for two step creation. | |
881 | */ | |
882 | bool Create(wxWindow* parent, wxWindowID id, | |
883 | const wxPoint& pos = wxDefaultPosition, | |
884 | const wxSize& size = wxDefaultSize, | |
885 | long style = 0, | |
886 | const wxValidator& validator = wxDefaultValidator); | |
887 | ||
888 | /** | |
889 | Deletes given column. | |
890 | */ | |
891 | virtual bool DeleteColumn(const wxDataViewColumn* column); | |
892 | ||
893 | /** | |
894 | Call this to ensure that the given item is visible. | |
895 | */ | |
4cc4bfaf FM |
896 | void EnsureVisible(const wxDataViewItem& item, |
897 | const wxDataViewColumn* column = NULL); | |
23324ae1 FM |
898 | |
899 | /** | |
900 | Expands the item. | |
901 | */ | |
4cc4bfaf | 902 | void Expand(const wxDataViewItem& item); |
23324ae1 FM |
903 | |
904 | /** | |
4cc4bfaf | 905 | Returns pointer to the column. @a pos refers to the |
23324ae1 FM |
906 | position in the control which may change after reordering |
907 | columns by the user. | |
908 | */ | |
328f5751 | 909 | virtual wxDataViewColumn* GetColumn(unsigned int pos) const; |
23324ae1 FM |
910 | |
911 | /** | |
912 | Returns the number of columns. | |
913 | */ | |
328f5751 | 914 | virtual unsigned int GetColumnCount() const; |
23324ae1 FM |
915 | |
916 | /** | |
917 | Returns the position of the column or -1 if not found in the control. | |
918 | */ | |
328f5751 | 919 | virtual int GetColumnPosition(const wxDataViewColumn* column) const; |
23324ae1 FM |
920 | |
921 | /** | |
922 | Returns column containing the expanders. | |
923 | */ | |
328f5751 | 924 | wxDataViewColumn* GetExpanderColumn() const; |
23324ae1 FM |
925 | |
926 | /** | |
927 | Returns indentation. | |
928 | */ | |
328f5751 | 929 | int GetIndent() const; |
23324ae1 FM |
930 | |
931 | /** | |
932 | Returns item rect. | |
933 | */ | |
934 | wxRect GetItemRect(const wxDataViewItem& item, | |
328f5751 | 935 | const wxDataViewColumn* col = NULL) const; |
23324ae1 FM |
936 | |
937 | /** | |
938 | Returns pointer to the data model associated with the | |
939 | control (if any). | |
940 | */ | |
328f5751 | 941 | virtual wxDataViewModel* GetModel() const; |
23324ae1 FM |
942 | |
943 | /** | |
944 | Returns first selected item or an invalid item if none is selected. | |
945 | */ | |
328f5751 | 946 | wxDataViewItem GetSelection() const; |
23324ae1 FM |
947 | |
948 | /** | |
4cc4bfaf | 949 | Fills @a sel with currently selected items and returns |
23324ae1 FM |
950 | their number. |
951 | */ | |
328f5751 | 952 | int GetSelections(wxDataViewItemArray& sel) const; |
23324ae1 FM |
953 | |
954 | /** | |
955 | Returns the wxDataViewColumn currently responsible for sorting | |
956 | or @NULL if none has been selected. | |
957 | */ | |
328f5751 | 958 | virtual wxDataViewColumn* GetSortingColumn() const; |
23324ae1 FM |
959 | |
960 | /** | |
961 | Hittest. | |
962 | */ | |
963 | void HitTest(const wxPoint& point, wxDataViewItem& item, | |
328f5751 | 964 | wxDataViewColumn*& col) const; |
23324ae1 FM |
965 | |
966 | /** | |
967 | Return @true if the item is selected. | |
968 | */ | |
328f5751 | 969 | bool IsSelected(const wxDataViewItem& item) const; |
23324ae1 FM |
970 | |
971 | /** | |
972 | Select the given item. | |
973 | */ | |
4cc4bfaf | 974 | void Select(const wxDataViewItem& item); |
23324ae1 FM |
975 | |
976 | /** | |
977 | Select all items. | |
978 | */ | |
979 | void SelectAll(); | |
980 | ||
981 | /** | |
982 | Set which column shall contain the tree-like expanders. | |
983 | */ | |
4cc4bfaf | 984 | void SetExpanderColumn(wxDataViewColumn* col); |
23324ae1 FM |
985 | |
986 | /** | |
987 | Sets the indendation. | |
988 | */ | |
989 | void SetIndent(int indent); | |
990 | ||
991 | /** | |
992 | Sets the selection to the array of wxDataViewItems. | |
993 | */ | |
4cc4bfaf | 994 | void SetSelections(const wxDataViewItemArray& sel); |
23324ae1 FM |
995 | |
996 | /** | |
997 | Unselect the given item. | |
998 | */ | |
4cc4bfaf | 999 | void Unselect(const wxDataViewItem& item); |
23324ae1 FM |
1000 | |
1001 | /** | |
1002 | Unselect all item. This method only has effect if multiple | |
1003 | selections are allowed. | |
1004 | */ | |
1005 | void UnselectAll(); | |
1006 | }; | |
1007 | ||
1008 | ||
e54c96f1 | 1009 | |
23324ae1 FM |
1010 | /** |
1011 | @class wxDataViewModelNotifier | |
1012 | @wxheader{dataview.h} | |
7c913512 | 1013 | |
23324ae1 FM |
1014 | A wxDataViewModelNotifier instance is owned by a |
1015 | wxDataViewModel | |
7c913512 | 1016 | and mirrors its notification interface. See |
23324ae1 FM |
1017 | the documentation of that class for further |
1018 | information. | |
7c913512 | 1019 | |
23324ae1 | 1020 | @library{wxbase} |
b321b61c | 1021 | @category{dvc} |
23324ae1 | 1022 | */ |
7c913512 | 1023 | class wxDataViewModelNotifier |
23324ae1 FM |
1024 | { |
1025 | public: | |
1026 | /** | |
1027 | Constructor. | |
1028 | */ | |
1029 | wxDataViewModelNotifier(); | |
1030 | ||
1031 | /** | |
1032 | Destructor. | |
1033 | */ | |
1034 | ~wxDataViewModelNotifier(); | |
1035 | ||
1036 | /** | |
1037 | Called by owning model. | |
1038 | */ | |
1039 | bool Cleared(); | |
1040 | ||
1041 | /** | |
1042 | Get owning wxDataViewModel. | |
1043 | */ | |
e51bf699 | 1044 | wxDataViewModel* GetOwner() const; |
23324ae1 FM |
1045 | |
1046 | /** | |
1047 | Called by owning model. | |
1048 | */ | |
1049 | bool ItemAdded(const wxDataViewItem& parent, | |
1050 | const wxDataViewItem& item); | |
1051 | ||
1052 | /** | |
1053 | Called by owning model. | |
1054 | */ | |
1055 | bool ItemChanged(const wxDataViewItem& item); | |
1056 | ||
1057 | /** | |
1058 | Called by owning model. | |
1059 | */ | |
1060 | bool ItemDeleted(const wxDataViewItem& parent, | |
1061 | const wxDataViewItem& item); | |
1062 | ||
1063 | /** | |
1064 | Called by owning model. | |
1065 | */ | |
1066 | bool ItemsAdded(const wxDataViewItem& parent, | |
1067 | const wxDataViewItemArray& items); | |
1068 | ||
1069 | /** | |
1070 | Called by owning model. | |
1071 | */ | |
1072 | bool ItemsChanged(const wxDataViewItemArray& items); | |
1073 | ||
1074 | /** | |
1075 | Called by owning model. | |
1076 | */ | |
1077 | bool ItemsDeleted(const wxDataViewItem& parent, | |
1078 | const wxDataViewItemArray& items); | |
1079 | ||
1080 | /** | |
1081 | Called by owning model. | |
1082 | */ | |
1083 | void Resort(); | |
1084 | ||
1085 | /** | |
1086 | Set owner of this notifier. Used internally. | |
1087 | */ | |
1088 | void SetOwner(wxDataViewModel* owner); | |
1089 | ||
1090 | /** | |
1091 | Called by owning model. | |
1092 | */ | |
1093 | bool ValueChanged(const wxDataViewItem& item, unsigned int col); | |
1094 | }; | |
1095 | ||
1096 | ||
e54c96f1 | 1097 | |
23324ae1 FM |
1098 | /** |
1099 | @class wxDataViewRenderer | |
1100 | @wxheader{dataview.h} | |
7c913512 | 1101 | |
5b99d5d8 RR |
1102 | This class is used by wxDataViewCtrl to render the individual cells. |
1103 | One instance of a renderer class is owned by a wxDataViewColumn. There | |
1104 | is a number of ready-to-use renderers provided: | |
23324ae1 FM |
1105 | wxDataViewTextRenderer, |
1106 | wxDataViewTextRendererAttr, | |
1107 | wxDataViewIconTextRenderer, | |
1108 | wxDataViewToggleRenderer, | |
1109 | wxDataViewProgressRenderer, | |
1110 | wxDataViewBitmapRenderer, | |
1111 | wxDataViewDateRenderer. | |
1112 | wxDataViewSpinRenderer. | |
7c913512 | 1113 | |
23324ae1 FM |
1114 | Additionally, the user can write own renderers by deriving from |
1115 | wxDataViewCustomRenderer. | |
7c913512 | 1116 | |
23324ae1 FM |
1117 | The @e wxDataViewCellMode flag controls, what actions |
1118 | the cell data allows. @e wxDATAVIEW_CELL_ACTIVATABLE | |
1119 | indicates that the user can double click the cell and | |
1120 | something will happen (e.g. a window for editing a date | |
1121 | will pop up). @e wxDATAVIEW_CELL_EDITABLE indicates | |
1122 | that the user can edit the data in-place, i.e. an control | |
1123 | will show up after a slow click on the cell. This behaviour | |
7c913512 | 1124 | is best known from changing the filename in most file |
23324ae1 | 1125 | managers etc. |
7c913512 FM |
1126 | |
1127 | ||
23324ae1 FM |
1128 | @code |
1129 | enum wxDataViewCellMode | |
1130 | { | |
1131 | wxDATAVIEW_CELL_INERT, | |
1132 | wxDATAVIEW_CELL_ACTIVATABLE, | |
1133 | wxDATAVIEW_CELL_EDITABLE | |
1134 | }; | |
1135 | @endcode | |
7c913512 | 1136 | |
23324ae1 FM |
1137 | The @e wxDataViewCellRenderState flag controls how the |
1138 | the renderer should display its contents in a cell: | |
7c913512 | 1139 | |
23324ae1 FM |
1140 | @code |
1141 | enum wxDataViewCellRenderState | |
1142 | { | |
1143 | wxDATAVIEW_CELL_SELECTED = 1, | |
1144 | wxDATAVIEW_CELL_PRELIT = 2, | |
1145 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
1146 | wxDATAVIEW_CELL_FOCUSED = 8 | |
1147 | }; | |
1148 | @endcode | |
7c913512 FM |
1149 | |
1150 | ||
23324ae1 | 1151 | @library{wxadv} |
b321b61c | 1152 | @category{dvc} |
23324ae1 FM |
1153 | */ |
1154 | class wxDataViewRenderer : public wxObject | |
1155 | { | |
1156 | public: | |
1157 | /** | |
5b99d5d8 | 1158 | Constructor. |
23324ae1 FM |
1159 | */ |
1160 | wxDataViewRenderer(const wxString& varianttype, | |
1161 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
f2b7492a | 1162 | int align = wxDVR_DEFAULT_ALIGNMENT ); |
23324ae1 | 1163 | |
20c36737 | 1164 | /** |
f2b7492a | 1165 | Returns the alignment. See SetAlignment() |
20c36737 RR |
1166 | */ |
1167 | virtual int GetAlignment() const; | |
1168 | ||
23324ae1 FM |
1169 | /** |
1170 | Returns the cell mode. | |
1171 | */ | |
1172 | virtual wxDataViewCellMode GetMode(); | |
1173 | ||
1174 | /** | |
1175 | Returns pointer to the owning wxDataViewColumn. | |
1176 | */ | |
e51bf699 | 1177 | virtual wxDataViewColumn* GetOwner() const; |
23324ae1 FM |
1178 | |
1179 | /** | |
1180 | This methods retrieves the value from the renderer in order to | |
1181 | transfer the value back to the data model. Returns @e @false | |
1182 | on failure. | |
1183 | */ | |
1184 | virtual bool GetValue(wxVariant& value); | |
1185 | ||
1186 | /** | |
1187 | Returns a string with the type of the wxVariant | |
1188 | supported by this renderer. | |
1189 | */ | |
1190 | virtual wxString GetVariantType(); | |
1191 | ||
20c36737 | 1192 | /** |
f2b7492a RR |
1193 | Sets the alignment of the renderer's content. The default value |
1194 | of wxDVR_DEFAULT_ALIGMENT indicates that the content should | |
1195 | have the same alignment as the column header. The method is | |
1196 | not implemented under OS X and the renderer always aligns its | |
1197 | contents as the column header on that platform. The other platforms | |
1198 | support both vertical and horizontal alignment. | |
20c36737 RR |
1199 | */ |
1200 | virtual void SetAlignment( int align ); | |
23324ae1 FM |
1201 | /** |
1202 | Sets the owning wxDataViewColumn. This | |
1203 | is usually called from within wxDataViewColumn. | |
1204 | */ | |
1205 | virtual void SetOwner(wxDataViewColumn* owner); | |
1206 | ||
1207 | /** | |
1208 | Set the value of the renderer (and thus its cell) to @e value. | |
1209 | The internal code will then render this cell with this data. | |
1210 | */ | |
1211 | virtual bool SetValue(const wxVariant& value); | |
1212 | ||
1213 | /** | |
1214 | Before data is committed to the data model, it is passed to this | |
1215 | method where it can be checked for validity. This can also be | |
1216 | used for checking a valid range or limiting the user input in | |
1217 | a certain aspect (e.g. max number of characters or only alphanumeric | |
1218 | input, ASCII only etc.). Return @e @false if the value is | |
1219 | not valid. | |
23324ae1 FM |
1220 | Please note that due to implementation limitations, this validation |
1221 | is done after the editing control already is destroyed and the | |
1222 | editing process finished. | |
1223 | */ | |
1224 | virtual bool Validate(wxVariant& value); | |
1225 | }; | |
1226 | ||
1227 | ||
e54c96f1 | 1228 | |
23324ae1 FM |
1229 | /** |
1230 | @class wxDataViewTextRenderer | |
1231 | @wxheader{dataview.h} | |
7c913512 | 1232 | |
23324ae1 FM |
1233 | wxDataViewTextRenderer is used for rendering text. It supports |
1234 | in-place editing if desired. | |
7c913512 | 1235 | |
23324ae1 | 1236 | @library{wxadv} |
b321b61c | 1237 | @category{dvc} |
23324ae1 FM |
1238 | */ |
1239 | class wxDataViewTextRenderer : public wxDataViewRenderer | |
1240 | { | |
1241 | public: | |
1242 | /** | |
3c4f71cc | 1243 | |
23324ae1 FM |
1244 | */ |
1245 | wxDataViewTextRenderer(const wxString& varianttype = "string", | |
05303ccd RR |
1246 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1247 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1248 | }; |
1249 | ||
1250 | ||
e54c96f1 | 1251 | |
f2b7492a RR |
1252 | /** |
1253 | @class wxDataViewIconTextRenderer | |
1254 | @wxheader{dataview.h} | |
1255 | ||
1256 | The wxDataViewIconTextRenderer class is used to display text with | |
1257 | a small icon next to it as it is typically done in a file manager. | |
1258 | This classes uses the wxDataViewIconText | |
1259 | helper class to store its data. wxDataViewIonText can be converted | |
1260 | to a from a wxVariant using the left shift | |
1261 | operator. | |
1262 | ||
1263 | @library{wxadv} | |
b321b61c | 1264 | @category{dvc} |
f2b7492a RR |
1265 | */ |
1266 | class wxDataViewIconTextRenderer : public wxDataViewRenderer | |
1267 | { | |
1268 | public: | |
1269 | /** | |
1270 | ||
1271 | */ | |
1272 | wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText", | |
1273 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1274 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
1275 | }; | |
1276 | ||
1277 | ||
1278 | ||
23324ae1 FM |
1279 | /** |
1280 | @class wxDataViewProgressRenderer | |
1281 | @wxheader{dataview.h} | |
7c913512 | 1282 | |
23324ae1 | 1283 | wxDataViewProgressRenderer |
7c913512 | 1284 | |
23324ae1 | 1285 | @library{wxadv} |
b321b61c | 1286 | @category{dvc} |
23324ae1 FM |
1287 | */ |
1288 | class wxDataViewProgressRenderer : public wxDataViewRenderer | |
1289 | { | |
1290 | public: | |
1291 | /** | |
3c4f71cc | 1292 | |
23324ae1 FM |
1293 | */ |
1294 | wxDataViewProgressRenderer(const wxString& label = wxEmptyString, | |
1295 | const wxString& varianttype = "long", | |
05303ccd RR |
1296 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1297 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1298 | }; |
1299 | ||
1300 | ||
e54c96f1 | 1301 | |
23324ae1 FM |
1302 | /** |
1303 | @class wxDataViewSpinRenderer | |
1304 | @wxheader{dataview.h} | |
7c913512 | 1305 | |
23324ae1 FM |
1306 | This is a specialized renderer for rendering integer values. It |
1307 | supports modifying the values in-place by using a wxSpinCtrl. | |
1308 | The renderer only support variants of type @e long. | |
7c913512 | 1309 | |
23324ae1 | 1310 | @library{wxbase} |
b321b61c | 1311 | @category{dvc} |
23324ae1 FM |
1312 | */ |
1313 | class wxDataViewSpinRenderer : public wxDataViewCustomRenderer | |
1314 | { | |
1315 | public: | |
1316 | /** | |
4cc4bfaf | 1317 | Constructor. @a min and @a max indicate the minimum und |
23324ae1 FM |
1318 | maximum values of for the wxSpinCtrl. |
1319 | */ | |
1320 | wxDataViewSpinRenderer(int min, int max, | |
1321 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
05303ccd | 1322 | int align = wxDVR_DEFAULT_ALIGNMENT); |
23324ae1 FM |
1323 | }; |
1324 | ||
1325 | ||
e54c96f1 | 1326 | |
23324ae1 FM |
1327 | /** |
1328 | @class wxDataViewToggleRenderer | |
1329 | @wxheader{dataview.h} | |
7c913512 | 1330 | |
23324ae1 | 1331 | wxDataViewToggleRenderer |
7c913512 | 1332 | |
23324ae1 | 1333 | @library{wxadv} |
b321b61c | 1334 | @category{dvc} |
23324ae1 FM |
1335 | */ |
1336 | class wxDataViewToggleRenderer : public wxDataViewRenderer | |
1337 | { | |
1338 | public: | |
1339 | /** | |
3c4f71cc | 1340 | |
23324ae1 FM |
1341 | */ |
1342 | wxDataViewToggleRenderer(const wxString& varianttype = "bool", | |
1343 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT); | |
1344 | }; | |
1345 | ||
1346 | ||
e54c96f1 | 1347 | |
23324ae1 | 1348 | /** |
5b99d5d8 | 1349 | @class wxDataViewDateRenderer |
23324ae1 | 1350 | @wxheader{dataview.h} |
7c913512 | 1351 | |
5b99d5d8 | 1352 | wxDataViewDateRenderer |
7c913512 | 1353 | |
5b99d5d8 | 1354 | @library{wxadv} |
b321b61c | 1355 | @category{dvc} |
23324ae1 | 1356 | */ |
5b99d5d8 | 1357 | class wxDataViewDateRenderer : public wxDataViewRenderer |
23324ae1 FM |
1358 | { |
1359 | public: | |
23324ae1 | 1360 | /** |
3c4f71cc | 1361 | |
23324ae1 | 1362 | */ |
5b99d5d8 RR |
1363 | wxDataViewDateRenderer(const wxString& varianttype = "datetime", |
1364 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE); | |
1365 | }; | |
23324ae1 | 1366 | |
3c4f71cc | 1367 | |
23324ae1 | 1368 | |
5b99d5d8 RR |
1369 | /** |
1370 | @class wxDataViewTextRendererAttr | |
1371 | @wxheader{dataview.h} | |
23324ae1 | 1372 | |
5b99d5d8 RR |
1373 | The same as wxDataViewTextRenderer but with |
1374 | support for font attributes. Font attributes are currently only supported | |
1375 | under GTK+ and MSW. | |
23324ae1 | 1376 | |
5b99d5d8 RR |
1377 | See also wxDataViewModel::GetAttr and |
1378 | wxDataViewItemAttr. | |
23324ae1 | 1379 | |
5b99d5d8 | 1380 | @library{wxadv} |
b321b61c | 1381 | @category{dvc} |
5b99d5d8 RR |
1382 | */ |
1383 | class wxDataViewTextRendererAttr : public wxDataViewTextRenderer | |
1384 | { | |
1385 | public: | |
23324ae1 | 1386 | /** |
23324ae1 | 1387 | |
23324ae1 | 1388 | */ |
5b99d5d8 RR |
1389 | wxDataViewTextRendererAttr(const wxString& varianttype = "string", |
1390 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1391 | int align = wxDVR_DEFAULT_ALIGNMENT); | |
1392 | }; | |
23324ae1 | 1393 | |
23324ae1 | 1394 | |
b321b61c | 1395 | |
5b99d5d8 RR |
1396 | /** |
1397 | @class wxDataViewCustomRenderer | |
1398 | @wxheader{dataview.h} | |
23324ae1 | 1399 | |
5b99d5d8 RR |
1400 | You need to derive a new class from wxDataViewCustomRenderer in |
1401 | order to write a new renderer. You need to override at least | |
1402 | wxDataViewRenderer::SetValue, | |
1403 | wxDataViewRenderer::GetValue, | |
1404 | wxDataViewCustomRenderer::GetSize | |
1405 | and wxDataViewCustomRenderer::Render. | |
23324ae1 | 1406 | |
5b99d5d8 RR |
1407 | If you want your renderer to support in-place editing then you |
1408 | also need to override | |
1409 | wxDataViewCustomRenderer::HasEditorCtrl, | |
1410 | wxDataViewCustomRenderer::CreateEditorCtrl | |
1411 | and wxDataViewCustomRenderer::GetValueFromEditorCtrl. | |
1412 | Note that a special event handler will be pushed onto that | |
1413 | editor control which handles ENTER and focus out events | |
1414 | in order to end the editing. | |
23324ae1 | 1415 | |
5b99d5d8 | 1416 | @library{wxadv} |
b321b61c | 1417 | @category{dvc} |
5b99d5d8 RR |
1418 | */ |
1419 | class wxDataViewCustomRenderer : public wxDataViewRenderer | |
1420 | { | |
1421 | public: | |
23324ae1 | 1422 | /** |
5b99d5d8 | 1423 | Constructor. |
23324ae1 | 1424 | */ |
5b99d5d8 RR |
1425 | wxDataViewCustomRenderer(const wxString& varianttype = "string", |
1426 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1427 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1428 | |
1429 | /** | |
5b99d5d8 | 1430 | Destructor. |
23324ae1 | 1431 | */ |
5b99d5d8 | 1432 | ~wxDataViewCustomRenderer(); |
23324ae1 | 1433 | |
23324ae1 | 1434 | /** |
5b99d5d8 RR |
1435 | Override this to react to double clicks or ENTER. This method will |
1436 | only be called in wxDATAVIEW_CELL_ACTIVATABLE mode. | |
23324ae1 | 1437 | */ |
5b99d5d8 RR |
1438 | virtual bool Activate( wxRect cell, |
1439 | wxDataViewModel* model, | |
1440 | const wxDataViewItem & item, | |
1441 | unsigned int col ); | |
23324ae1 FM |
1442 | |
1443 | /** | |
5b99d5d8 RR |
1444 | Override this to create the actual editor control once editing |
1445 | is about to start. @a parent is the parent of the editor | |
1446 | control, @a labelRect indicates the position and | |
1447 | size of the editor control and @a value is its initial value: | |
23324ae1 | 1448 | */ |
5b99d5d8 RR |
1449 | virtual wxControl* CreateEditorCtrl(wxWindow* parent, |
1450 | wxRect labelRect, | |
1451 | const wxVariant& value); | |
23324ae1 FM |
1452 | |
1453 | /** | |
5b99d5d8 | 1454 | Create DC on request. Internal. |
23324ae1 | 1455 | */ |
5b99d5d8 | 1456 | virtual wxDC* GetDC(); |
23324ae1 FM |
1457 | |
1458 | /** | |
5b99d5d8 | 1459 | Return size required to show content. |
23324ae1 | 1460 | */ |
5b99d5d8 | 1461 | virtual wxSize GetSize(); |
23324ae1 FM |
1462 | |
1463 | /** | |
5b99d5d8 RR |
1464 | Overrride this so that the renderer can get the value |
1465 | from the editor control (pointed to by @e editor): | |
23324ae1 | 1466 | */ |
5b99d5d8 RR |
1467 | virtual bool GetValueFromEditorCtrl(wxControl* editor, |
1468 | wxVariant& value); | |
23324ae1 FM |
1469 | |
1470 | /** | |
5b99d5d8 RR |
1471 | Override this and make it return @e @true in order to |
1472 | indicate that this renderer supports in-place editing. | |
23324ae1 | 1473 | */ |
5b99d5d8 | 1474 | virtual bool HasEditorCtrl(); |
23324ae1 FM |
1475 | |
1476 | /** | |
5b99d5d8 RR |
1477 | Overrride this to react to a left click. This method will |
1478 | only be called in wxDATAVIEW_CELL_ACTIVATABLE mode. | |
23324ae1 | 1479 | */ |
5b99d5d8 RR |
1480 | virtual bool LeftClick( wxPoint cursor, |
1481 | wxRect cell, | |
1482 | wxDataViewModel * model, | |
1483 | const wxDataViewItem & item, | |
1484 | unsigned int col ); | |
23324ae1 FM |
1485 | |
1486 | /** | |
5b99d5d8 RR |
1487 | Override this to render the cell. Before this is called, |
1488 | wxDataViewRenderer::SetValue was called | |
1489 | so that this instance knows what to render. | |
23324ae1 | 1490 | */ |
5b99d5d8 | 1491 | virtual bool Render(wxRect cell, wxDC* dc, int state); |
23324ae1 FM |
1492 | |
1493 | /** | |
5b99d5d8 RR |
1494 | This method should be called from within Render() |
1495 | whenever you need to render simple text. This will ensure that the | |
1496 | correct colour, font and vertical alignment will be chosen so the | |
1497 | text will look the same as text drawn by native renderers. | |
23324ae1 | 1498 | */ |
5b99d5d8 RR |
1499 | bool RenderText(const wxString& text, int xoffset, wxRect cell, |
1500 | wxDC* dc, int state); | |
23324ae1 FM |
1501 | |
1502 | /** | |
5b99d5d8 RR |
1503 | Overrride this to start a drag operation. Not yet |
1504 | supported | |
23324ae1 | 1505 | */ |
5b99d5d8 RR |
1506 | virtual bool StartDrag(wxPoint cursor, wxRect cell, |
1507 | wxDataViewModel* model, | |
1508 | const wxDataViewItem & item, | |
1509 | unsigned int col); | |
23324ae1 FM |
1510 | }; |
1511 | ||
1512 | ||
e54c96f1 | 1513 | |
23324ae1 | 1514 | /** |
5b99d5d8 | 1515 | @class wxDataViewBitmapRenderer |
23324ae1 | 1516 | @wxheader{dataview.h} |
7c913512 | 1517 | |
5b99d5d8 | 1518 | wxDataViewBitmapRenderer |
7c913512 | 1519 | |
23324ae1 | 1520 | @library{wxadv} |
b321b61c | 1521 | @category{dvc} |
23324ae1 | 1522 | */ |
5b99d5d8 | 1523 | class wxDataViewBitmapRenderer : public wxDataViewRenderer |
23324ae1 FM |
1524 | { |
1525 | public: | |
1526 | /** | |
23324ae1 | 1527 | |
23324ae1 | 1528 | */ |
5b99d5d8 RR |
1529 | wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap", |
1530 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1531 | int align = wxDVR_DEFAULT_ALIGNMENT, | |
1532 | }; | |
1533 | ||
23324ae1 | 1534 | |
23324ae1 | 1535 | |
5b99d5d8 RR |
1536 | /** |
1537 | @class wxDataViewColumn | |
1538 | @wxheader{dataview.h} | |
1539 | ||
1540 | This class represents a column in a wxDataViewCtrl. | |
1541 | One wxDataViewColumn is bound to one column in the data model, | |
1542 | to which the wxDataViewCtrl has been associated. | |
1543 | ||
1544 | An instance of wxDataViewRenderer is used by | |
1545 | this class to render its data. | |
1546 | ||
1547 | @library{wxadv} | |
b321b61c | 1548 | @category{dvc} |
5b99d5d8 RR |
1549 | */ |
1550 | class wxDataViewColumn : public wxObject | |
1551 | { | |
1552 | public: | |
1553 | //@{ | |
23324ae1 | 1554 | /** |
5b99d5d8 | 1555 | Constructors. |
23324ae1 | 1556 | */ |
5b99d5d8 RR |
1557 | wxDataViewColumn(const wxString& title, |
1558 | wxDataViewRenderer* renderer, | |
1559 | unsigned int model_column, | |
1560 | int width = wxDVC_DEFAULT_WIDTH, | |
1561 | wxAlignment align = wxALIGN_CENTRE, | |
1562 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
1563 | wxDataViewColumn(const wxBitmap& bitmap, | |
1564 | wxDataViewRenderer* renderer, | |
1565 | unsigned int model_column, | |
1566 | int width = wxDVC_DEFAULT_WIDTH, | |
1567 | wxAlignment align = wxALIGN_CENTRE, | |
1568 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
1569 | //@} | |
23324ae1 FM |
1570 | |
1571 | /** | |
5b99d5d8 | 1572 | Destructor. |
23324ae1 | 1573 | */ |
5b99d5d8 | 1574 | ~wxDataViewColumn(); |
23324ae1 FM |
1575 | |
1576 | /** | |
5b99d5d8 | 1577 | Returns the bitmap in the header of the column, if any. |
23324ae1 | 1578 | */ |
5b99d5d8 | 1579 | const wxBitmap GetBitmap(); |
23324ae1 FM |
1580 | |
1581 | /** | |
5b99d5d8 RR |
1582 | Returns the index of the column of the model, which this |
1583 | wxDataViewColumn is displaying. | |
23324ae1 | 1584 | */ |
5b99d5d8 | 1585 | unsigned int GetModelColumn(); |
23324ae1 FM |
1586 | |
1587 | /** | |
5b99d5d8 | 1588 | Returns the owning wxDataViewCtrl. |
23324ae1 | 1589 | */ |
e51bf699 | 1590 | wxDataViewCtrl* GetOwner() const; |
23324ae1 FM |
1591 | |
1592 | /** | |
5b99d5d8 RR |
1593 | Returns the renderer of this wxDataViewColumn. |
1594 | See also wxDataViewRenderer. | |
23324ae1 | 1595 | */ |
5b99d5d8 | 1596 | wxDataViewRenderer* GetRenderer(); |
23324ae1 FM |
1597 | |
1598 | /** | |
5b99d5d8 | 1599 | Returns @true if the column is reorderable. |
23324ae1 | 1600 | */ |
5b99d5d8 | 1601 | bool GetReorderable(); |
23324ae1 FM |
1602 | |
1603 | /** | |
5b99d5d8 RR |
1604 | Returns @true if the column is sortable. |
1605 | See SetSortable() | |
23324ae1 | 1606 | */ |
5b99d5d8 | 1607 | bool GetSortable(); |
23324ae1 FM |
1608 | |
1609 | /** | |
5b99d5d8 | 1610 | Returns the width of the column. |
23324ae1 | 1611 | */ |
5b99d5d8 | 1612 | int GetWidth(); |
23324ae1 FM |
1613 | |
1614 | /** | |
5b99d5d8 RR |
1615 | Returns @true, if the sort order is ascending. |
1616 | See also SetSortOrder() | |
23324ae1 | 1617 | */ |
5b99d5d8 | 1618 | bool IsSortOrderAscending(); |
23324ae1 FM |
1619 | |
1620 | /** | |
5b99d5d8 | 1621 | Set the alignment of the column header. |
23324ae1 | 1622 | */ |
5b99d5d8 | 1623 | void SetAlignment(wxAlignment align); |
23324ae1 FM |
1624 | |
1625 | /** | |
5b99d5d8 | 1626 | Set the bitmap of the column header. |
23324ae1 | 1627 | */ |
5b99d5d8 | 1628 | void SetBitmap(const wxBitmap& bitmap); |
23324ae1 FM |
1629 | |
1630 | /** | |
5b99d5d8 RR |
1631 | Indicate wether the column can be reordered by the |
1632 | user using the mouse. This is typically implemented | |
1633 | visually by dragging the header button around. | |
23324ae1 | 1634 | */ |
5b99d5d8 | 1635 | void SetReorderable(bool reorderable); |
23324ae1 FM |
1636 | |
1637 | /** | |
5b99d5d8 RR |
1638 | Indicate the sort order if the implementation of the |
1639 | wxDataViewCtrl supports it, most commonly by showing | |
1640 | a little arrow. | |
23324ae1 | 1641 | */ |
5b99d5d8 | 1642 | void SetSortOrder(bool ascending); |
23324ae1 FM |
1643 | |
1644 | /** | |
5b99d5d8 RR |
1645 | Indicate that the column is sortable. This does |
1646 | not show any sorting indicate yet, but it does | |
1647 | make the column header clickable. Call | |
1648 | SetSortOrder() | |
1649 | afterwards to actually make the sort indicator appear. | |
1650 | If @a sortable is @false, the column header is | |
1651 | no longer clickable and the sort indicator (little | |
1652 | arrow) will disappear. | |
23324ae1 | 1653 | */ |
5b99d5d8 | 1654 | void SetSortable(bool sortable); |
23324ae1 FM |
1655 | |
1656 | /** | |
5b99d5d8 | 1657 | Set the title of the column header to @e title. |
23324ae1 | 1658 | */ |
5b99d5d8 | 1659 | void SetTitle(const wxString& title); |
23324ae1 FM |
1660 | }; |
1661 | ||
1662 | ||
e54c96f1 | 1663 | |
23324ae1 | 1664 | /** |
5b99d5d8 | 1665 | @class wxDataViewTreeCtrl |
23324ae1 | 1666 | @wxheader{dataview.h} |
7c913512 | 1667 | |
5b99d5d8 RR |
1668 | This class is a wxDataViewCtrl which internally |
1669 | uses a wxDataViewTreeStore and forwards | |
1670 | most of its API to that class. Additionally, it uses a wxImageList | |
1671 | to store a list of icons. The main purpose of this class is to look | |
1672 | like a wxTreeCtrl to make a transition from it | |
1673 | to the wxDataViewCtrl class simpler. | |
7c913512 | 1674 | |
5b99d5d8 | 1675 | @library{wxbase} |
b321b61c BP |
1676 | @category{ctrl,dvc} |
1677 | <!-- @appearance{dataviewtreectrl.png} --> | |
23324ae1 | 1678 | */ |
5b99d5d8 | 1679 | class wxDataViewTreeCtrl : public wxDataViewCtrl |
23324ae1 FM |
1680 | { |
1681 | public: | |
5b99d5d8 | 1682 | //@{ |
23324ae1 | 1683 | /** |
5b99d5d8 RR |
1684 | Constructor. Calls Create(). |
1685 | */ | |
1686 | wxDataViewTreeCtrl(); | |
1687 | wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id, | |
1688 | const wxPoint& pos = wxDefaultPosition, | |
1689 | const wxSize& size = wxDefaultSize, | |
1690 | long style = wxDV_NO_HEADER, | |
1691 | const wxValidator& validator = wxDefaultValidator); | |
1692 | //@} | |
3c4f71cc | 1693 | |
5b99d5d8 RR |
1694 | /** |
1695 | Destructor. Deletes the image list if any. | |
23324ae1 | 1696 | */ |
5b99d5d8 | 1697 | ~wxDataViewTreeCtrl(); |
23324ae1 | 1698 | |
5b99d5d8 | 1699 | /** |
23324ae1 | 1700 | |
5b99d5d8 RR |
1701 | */ |
1702 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
1703 | const wxString& text, | |
1704 | int icon = -1, | |
1705 | int expanded = -1, | |
1706 | wxClientData* data = NULL); | |
e54c96f1 | 1707 | |
5b99d5d8 | 1708 | /** |
7c913512 | 1709 | |
5b99d5d8 RR |
1710 | */ |
1711 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
1712 | const wxString& text, | |
1713 | int icon = -1, | |
1714 | wxClientData* data = NULL); | |
7c913512 | 1715 | |
5b99d5d8 RR |
1716 | /** |
1717 | Creates the control and a wxDataViewTreeStore as | |
1718 | its internal model. | |
1719 | */ | |
1720 | bool Create(wxWindow* parent, wxWindowID id, | |
1721 | const wxPoint& pos = wxDefaultPosition, | |
1722 | const wxSize& size = wxDefaultSize, | |
1723 | long style = wxDV_NO_HEADER, | |
1724 | const wxValidator& validator = wxDefaultValidator); | |
1725 | ||
1726 | /** | |
1727 | Calls the identical method from wxDataViewTreeStore. | |
1728 | */ | |
1729 | void DeleteAllItems(); | |
7c913512 | 1730 | |
23324ae1 | 1731 | /** |
5b99d5d8 RR |
1732 | Calls the identical method from wxDataViewTreeStore. |
1733 | */ | |
1734 | void DeleteChildren(const wxDataViewItem& item); | |
3c4f71cc | 1735 | |
5b99d5d8 RR |
1736 | /** |
1737 | Calls the identical method from wxDataViewTreeStore. | |
23324ae1 | 1738 | */ |
5b99d5d8 | 1739 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 | 1740 | |
5b99d5d8 RR |
1741 | /** |
1742 | Calls the identical method from wxDataViewTreeStore. | |
1743 | */ | |
1744 | int GetChildCount(const wxDataViewItem& parent) const; | |
23324ae1 | 1745 | |
5b99d5d8 RR |
1746 | /** |
1747 | Returns the image list. | |
1748 | */ | |
1749 | wxImageList* GetImageList(); | |
05303ccd | 1750 | |
5b99d5d8 RR |
1751 | /** |
1752 | Calls the identical method from wxDataViewTreeStore. | |
1753 | */ | |
1754 | wxClientData* GetItemData(const wxDataViewItem& item) const; | |
05303ccd | 1755 | |
5b99d5d8 RR |
1756 | /** |
1757 | Calls the identical method from wxDataViewTreeStore. | |
1758 | */ | |
1759 | const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const; | |
05303ccd | 1760 | |
05303ccd | 1761 | /** |
5b99d5d8 | 1762 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1763 | */ |
5b99d5d8 | 1764 | const wxIcon GetItemIcon(const wxDataViewItem& item) const; |
05303ccd RR |
1765 | |
1766 | /** | |
5b99d5d8 | 1767 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1768 | */ |
5b99d5d8 RR |
1769 | wxString GetItemText(const wxDataViewItem& item) const; |
1770 | ||
1771 | /** | |
1772 | Calls the identical method from wxDataViewTreeStore. | |
1773 | */ | |
1774 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, | |
1775 | unsigned int pos) const; | |
05303ccd | 1776 | |
5b99d5d8 | 1777 | //@{ |
05303ccd | 1778 | /** |
5b99d5d8 | 1779 | Returns the store. |
05303ccd | 1780 | */ |
5b99d5d8 RR |
1781 | wxDataViewTreeStore* GetStore() const; |
1782 | const wxDataViewTreeStore* GetStore() const; | |
1783 | //@} | |
05303ccd RR |
1784 | |
1785 | /** | |
5b99d5d8 RR |
1786 | Calls the same method from wxDataViewTreeStore but uess |
1787 | and index position in the image list instead of a wxIcon. | |
05303ccd | 1788 | */ |
5b99d5d8 RR |
1789 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
1790 | const wxDataViewItem& previous, | |
1791 | const wxString& text, | |
1792 | int icon = -1, | |
1793 | int expanded = -1, | |
1794 | wxClientData* data = NULL); | |
05303ccd RR |
1795 | |
1796 | /** | |
5b99d5d8 RR |
1797 | Calls the same method from wxDataViewTreeStore but uess |
1798 | and index position in the image list instead of a wxIcon. | |
05303ccd | 1799 | */ |
5b99d5d8 RR |
1800 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
1801 | const wxDataViewItem& previous, | |
1802 | const wxString& text, | |
1803 | int icon = -1, | |
1804 | wxClientData* data = NULL); | |
05303ccd RR |
1805 | |
1806 | /** | |
5b99d5d8 RR |
1807 | Calls the same method from wxDataViewTreeStore but uess |
1808 | and index position in the image list instead of a wxIcon. | |
05303ccd | 1809 | */ |
5b99d5d8 RR |
1810 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
1811 | const wxString& text, | |
1812 | int icon = -1, | |
1813 | int expanded = -1, | |
1814 | wxClientData* data = NULL); | |
05303ccd RR |
1815 | |
1816 | /** | |
5b99d5d8 RR |
1817 | Calls the same method from wxDataViewTreeStore but uess |
1818 | and index position in the image list instead of a wxIcon. | |
05303ccd | 1819 | */ |
5b99d5d8 RR |
1820 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
1821 | const wxString& text, | |
1822 | int icon = -1, | |
1823 | wxClientData* data = NULL); | |
05303ccd RR |
1824 | |
1825 | /** | |
5b99d5d8 | 1826 | Sets the image list. |
05303ccd | 1827 | */ |
5b99d5d8 | 1828 | void SetImageList(wxImageList* imagelist); |
05303ccd RR |
1829 | |
1830 | /** | |
5b99d5d8 | 1831 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1832 | */ |
5b99d5d8 | 1833 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
05303ccd RR |
1834 | |
1835 | /** | |
5b99d5d8 | 1836 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1837 | */ |
5b99d5d8 RR |
1838 | void SetItemExpandedIcon(const wxDataViewItem& item, |
1839 | const wxIcon& icon); | |
05303ccd RR |
1840 | |
1841 | /** | |
5b99d5d8 | 1842 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1843 | */ |
5b99d5d8 | 1844 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
05303ccd RR |
1845 | |
1846 | /** | |
5b99d5d8 | 1847 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 1848 | */ |
5b99d5d8 RR |
1849 | void SetItemText(const wxDataViewItem& item, |
1850 | const wxString& text); | |
05303ccd RR |
1851 | }; |
1852 | ||
1853 | ||
1854 | ||
1855 | /** | |
5b99d5d8 | 1856 | @class wxDataViewTreeStore |
05303ccd RR |
1857 | @wxheader{dataview.h} |
1858 | ||
5b99d5d8 RR |
1859 | wxDataViewTreeStore is a specialised wxDataViewModel |
1860 | for displaying simple trees very much like wxTreeCtrl | |
1861 | does and it offers a similar API. This class actually stores the entire | |
1862 | tree (therefore its name) and implements all virtual methods from the base | |
1863 | class so it can be used directly without having to derive any class from it. | |
1864 | This comes at the price of much reduced flexibility. | |
05303ccd RR |
1865 | |
1866 | @library{wxadv} | |
b321b61c | 1867 | @category{dvc} |
05303ccd | 1868 | */ |
5b99d5d8 | 1869 | class wxDataViewTreeStore : public wxDataViewModel |
05303ccd RR |
1870 | { |
1871 | public: | |
1872 | /** | |
5b99d5d8 | 1873 | Constructor. Creates the invisible root node internally. |
05303ccd | 1874 | */ |
5b99d5d8 | 1875 | wxDataViewTreeStore(); |
e54c96f1 | 1876 | |
5b99d5d8 RR |
1877 | /** |
1878 | Destructor. | |
1879 | */ | |
1880 | ~wxDataViewTreeStore(); | |
7c913512 | 1881 | |
5b99d5d8 RR |
1882 | /** |
1883 | Append a container. | |
1884 | */ | |
1885 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
1886 | const wxString& text, | |
1887 | const wxIcon& icon = wxNullIcon, | |
1888 | const wxIcon& expanded = wxNullIcon, | |
1889 | wxClientData* data = NULL); | |
7c913512 | 1890 | |
5b99d5d8 RR |
1891 | /** |
1892 | Append an item. | |
1893 | */ | |
1894 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
1895 | const wxString& text, | |
1896 | const wxIcon& icon = wxNullIcon, | |
1897 | wxClientData* data = NULL); | |
7c913512 | 1898 | |
23324ae1 | 1899 | /** |
5b99d5d8 | 1900 | Delete all item in the model. |
23324ae1 | 1901 | */ |
5b99d5d8 | 1902 | void DeleteAllItems(); |
23324ae1 FM |
1903 | |
1904 | /** | |
5b99d5d8 | 1905 | Delete all children of the item, but not the item itself. |
23324ae1 | 1906 | */ |
5b99d5d8 | 1907 | void DeleteChildren(const wxDataViewItem& item); |
23324ae1 FM |
1908 | |
1909 | /** | |
5b99d5d8 | 1910 | Delete this item. |
23324ae1 | 1911 | */ |
5b99d5d8 | 1912 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 FM |
1913 | |
1914 | /** | |
5b99d5d8 | 1915 | Return the number of children of item. |
23324ae1 | 1916 | */ |
5b99d5d8 | 1917 | int GetChildCount(const wxDataViewItem& parent) const; |
23324ae1 FM |
1918 | |
1919 | /** | |
5b99d5d8 | 1920 | Returns the client data asoociated with the item. |
23324ae1 | 1921 | */ |
5b99d5d8 | 1922 | wxClientData* GetItemData(const wxDataViewItem& item) const; |
23324ae1 FM |
1923 | |
1924 | /** | |
5b99d5d8 | 1925 | Returns the icon to display in expanded containers. |
23324ae1 | 1926 | */ |
5b99d5d8 | 1927 | const wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
1928 | |
1929 | /** | |
5b99d5d8 | 1930 | Returns the icon of the item. |
23324ae1 | 1931 | */ |
5b99d5d8 | 1932 | const wxIcon GetItemIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
1933 | |
1934 | /** | |
5b99d5d8 | 1935 | Returns the text of the item. |
23324ae1 | 1936 | */ |
5b99d5d8 | 1937 | wxString GetItemText(const wxDataViewItem& item) const; |
23324ae1 FM |
1938 | |
1939 | /** | |
5b99d5d8 | 1940 | Returns the nth child item of item. |
23324ae1 | 1941 | */ |
5b99d5d8 RR |
1942 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, |
1943 | unsigned int pos) const; | |
23324ae1 FM |
1944 | |
1945 | /** | |
5b99d5d8 | 1946 | Inserts a container after @e previous. |
23324ae1 | 1947 | */ |
5b99d5d8 RR |
1948 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
1949 | const wxDataViewItem& previous, | |
1950 | const wxString& text, | |
1951 | const wxIcon& icon = wxNullIcon, | |
1952 | const wxIcon& expanded = wxNullIcon, | |
1953 | wxClientData* data = NULL); | |
23324ae1 FM |
1954 | |
1955 | /** | |
5b99d5d8 | 1956 | Inserts an item after @e previous. |
23324ae1 | 1957 | */ |
5b99d5d8 RR |
1958 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
1959 | const wxDataViewItem& previous, | |
1960 | const wxString& text, | |
1961 | const wxIcon& icon = wxNullIcon, | |
1962 | wxClientData* data = NULL); | |
23324ae1 FM |
1963 | |
1964 | /** | |
5b99d5d8 | 1965 | Inserts a container before the first child item or @e parent. |
23324ae1 | 1966 | */ |
5b99d5d8 RR |
1967 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
1968 | const wxString& text, | |
1969 | const wxIcon& icon = wxNullIcon, | |
1970 | const wxIcon& expanded = wxNullIcon, | |
1971 | wxClientData* data = NULL); | |
23324ae1 FM |
1972 | |
1973 | /** | |
5b99d5d8 | 1974 | Inserts an item before the first child item or @e parent. |
23324ae1 | 1975 | */ |
5b99d5d8 RR |
1976 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
1977 | const wxString& text, | |
1978 | const wxIcon& icon = wxNullIcon, | |
1979 | wxClientData* data = NULL); | |
23324ae1 FM |
1980 | |
1981 | /** | |
5b99d5d8 | 1982 | Sets the client data associated with the item. |
23324ae1 | 1983 | */ |
5b99d5d8 | 1984 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
23324ae1 FM |
1985 | |
1986 | /** | |
5b99d5d8 | 1987 | Sets the expanded icon for the item. |
23324ae1 | 1988 | */ |
5b99d5d8 RR |
1989 | void SetItemExpandedIcon(const wxDataViewItem& item, |
1990 | const wxIcon& icon); | |
23324ae1 FM |
1991 | |
1992 | /** | |
5b99d5d8 | 1993 | Sets the icon for the item. |
23324ae1 | 1994 | */ |
5b99d5d8 | 1995 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
23324ae1 | 1996 | }; |
e54c96f1 | 1997 |