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