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