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