]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dataview.h | |
80932a3e | 3 | // Purpose: interface of wxDataView* classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
b321b61c | 9 | |
23324ae1 FM |
10 | /** |
11 | @class wxDataViewModel | |
7c913512 | 12 | |
c4e57202 FM |
13 | wxDataViewModel is the base class for all data model to be displayed by a |
14 | wxDataViewCtrl. | |
15 | ||
16 | All other models derive from it and must implement its pure virtual functions | |
17 | in order to define a complete data model. In detail, you need to override | |
18 | wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren, | |
19 | wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and | |
20 | wxDataViewModel::GetValue in order to define the data model which acts as an | |
21 | interface between your actual data and the wxDataViewCtrl. | |
22 | ||
a36bceb6 RR |
23 | Note that wxDataViewModel does not define the position or index of any item |
24 | in the control because different controls might display the same data differently. | |
25 | wxDataViewModel does provide a wxDataViewModel::Compare method which the | |
26 | wxDataViewCtrl may use to sort the data either in conjunction with a column | |
27 | header or without (see wxDataViewModel::HasDefaultCompare). | |
7c913512 | 28 | |
c4e57202 FM |
29 | wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant |
30 | to store data and its type in a generic way. wxVariant can be extended to contain | |
a36bceb6 RR |
31 | almost any data without changes to the original class. To a certain extent, |
32 | you can use (the somewhat more elegant) wxAny instead of wxVariant as there | |
33 | is code to convert between the two, but it is unclear what impact this will | |
34 | have on performance. | |
35 | ||
36 | Since you will usually allow the wxDataViewCtrl to change your data | |
37 | through its graphical interface, you will also have to override | |
38 | wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change | |
39 | to some data has been committed. | |
7c913512 | 40 | |
a36bceb6 RR |
41 | If the data represented by the model is changed by something else than its |
42 | associated wxDataViewCtrl, the control has to be notified about the change. | |
c4e57202 FM |
43 | Depending on what happened you need to call one of the following methods: |
44 | - wxDataViewModel::ValueChanged, | |
45 | - wxDataViewModel::ItemAdded, | |
46 | - wxDataViewModel::ItemDeleted, | |
47 | - wxDataViewModel::ItemChanged, | |
48 | - wxDataViewModel::Cleared. | |
49 | ||
50 | There are plural forms for notification of addition, change or removal of | |
51 | several item at once. See: | |
52 | - wxDataViewModel::ItemsAdded, | |
53 | - wxDataViewModel::ItemsDeleted, | |
54 | - wxDataViewModel::ItemsChanged. | |
55 | ||
c4e57202 FM |
56 | This class maintains a list of wxDataViewModelNotifier which link this class |
57 | to the specific implementations on the supported platforms so that e.g. calling | |
58 | wxDataViewModel::ValueChanged on this model will just call | |
59 | wxDataViewModelNotifier::ValueChanged for each notifier that has been added. | |
60 | You can also add your own notifier in order to get informed about any changes | |
23324ae1 | 61 | to the data in the list model. |
7c913512 | 62 | |
c4e57202 | 63 | Currently wxWidgets provides the following models apart from the base model: |
bda698ed RR |
64 | wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore, |
65 | wxDataViewListStore. | |
7c913512 | 66 | |
e4e83d3a | 67 | Note that wxDataViewModel is reference counted, derives from wxRefCounter |
c4e57202 FM |
68 | and cannot be deleted directly as it can be shared by several wxDataViewCtrls. |
69 | This implies that you need to decrease the reference count after | |
23324ae1 | 70 | associating the model with a control like this: |
7c913512 | 71 | |
23324ae1 | 72 | @code |
14f73cf1 | 73 | wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY ); |
23324ae1 | 74 | wxDataViewModel *musicModel = new MyMusicModel; |
14f73cf1 FM |
75 | m_musicCtrl->AssociateModel( musicModel ); |
76 | musicModel->DecRef(); // avoid memory leak !! | |
43c64cc6 | 77 | |
23324ae1 FM |
78 | // add columns now |
79 | @endcode | |
7c913512 | 80 | |
a36bceb6 RR |
81 | A potentially better way to avoid memory leaks is to use wxObjectDataPtr |
82 | ||
83 | @code | |
84 | wxObjectDataPtr<MyMusicModel> musicModel; | |
85 | ||
86 | wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY ); | |
87 | musicModel = new MyMusicModel; | |
88 | m_musicCtrl->AssociateModel( musicModel.get() ); | |
89 | ||
90 | // add columns now | |
91 | @endcode | |
92 | ||
93 | ||
23324ae1 | 94 | @library{wxadv} |
b321b61c | 95 | @category{dvc} |
23324ae1 | 96 | */ |
e4e83d3a | 97 | class wxDataViewModel : public wxRefCounter |
23324ae1 FM |
98 | { |
99 | public: | |
100 | /** | |
101 | Constructor. | |
102 | */ | |
103 | wxDataViewModel(); | |
104 | ||
23324ae1 | 105 | /** |
c4e57202 | 106 | Adds a wxDataViewModelNotifier to the model. |
23324ae1 FM |
107 | */ |
108 | void AddNotifier(wxDataViewModelNotifier* notifier); | |
109 | ||
795dac4c VZ |
110 | /** |
111 | Change the value of the given item and update the control to reflect | |
112 | it. | |
113 | ||
114 | This function simply calls SetValue() and, if it succeeded, | |
115 | ValueChanged(). | |
116 | ||
117 | @since 2.9.1 | |
118 | ||
d86f721a | 119 | @param variant |
795dac4c VZ |
120 | The new value. |
121 | @param item | |
122 | The item (row) to update. | |
123 | @param col | |
124 | The column to update. | |
125 | @return | |
126 | @true if both SetValue() and ValueChanged() returned @true. | |
127 | */ | |
128 | bool ChangeValue(const wxVariant& variant, | |
129 | const wxDataViewItem& item, | |
130 | unsigned int col); | |
131 | ||
23324ae1 | 132 | /** |
c4e57202 FM |
133 | Called to inform the model that all data has been cleared. |
134 | The control will reread the data from the model again. | |
23324ae1 FM |
135 | */ |
136 | virtual bool Cleared(); | |
137 | ||
138 | /** | |
139 | The compare function to be used by control. The default compare function | |
140 | sorts by container and other items separately and in ascending order. | |
141 | Override this for a different sorting behaviour. | |
c4e57202 FM |
142 | |
143 | @see HasDefaultCompare(). | |
23324ae1 FM |
144 | */ |
145 | virtual int Compare(const wxDataViewItem& item1, | |
146 | const wxDataViewItem& item2, | |
147 | unsigned int column, | |
862de7b3 | 148 | bool ascending) const; |
23324ae1 FM |
149 | |
150 | /** | |
13f184c0 | 151 | Override this to indicate that the item has special font attributes. |
c4e57202 FM |
152 | This only affects the wxDataViewTextRendererText renderer. |
153 | ||
7fadac88 VZ |
154 | The base class version always simply returns @false. |
155 | ||
c4e57202 | 156 | @see wxDataViewItemAttr. |
7fadac88 VZ |
157 | |
158 | @param item | |
159 | The item for which the attribute is requested. | |
160 | @param col | |
161 | The column of the item for which the attribute is requested. | |
162 | @param attr | |
163 | The attribute to be filled in if the function returns @true. | |
164 | @return | |
165 | @true if this item has an attribute or @false otherwise. | |
23324ae1 | 166 | */ |
fadc2df6 | 167 | virtual bool GetAttr(const wxDataViewItem& item, unsigned int col, |
7fadac88 | 168 | wxDataViewItemAttr& attr) const; |
23324ae1 | 169 | |
98f8e666 VZ |
170 | /** |
171 | Override this to indicate that the item should be disabled. | |
172 | ||
173 | Disabled items are displayed differently (e.g. grayed out) and cannot | |
174 | be interacted with. | |
175 | ||
176 | The base class version always returns @true, thus making all items | |
177 | enabled by default. | |
178 | ||
179 | @param item | |
180 | The item whose enabled status is requested. | |
181 | @param col | |
182 | The column of the item whose enabled status is requested. | |
183 | @return | |
184 | @true if this item should be enabled, @false otherwise. | |
185 | ||
186 | @note Currently disabling items is fully implemented only for the | |
e97f9fbd RR |
187 | native control implementation in wxOSX/Cocoa and wxGTK. |
188 | This feature is only partially supported in the generic | |
189 | version (used by wxMSW) and not supported by the wxOSX/Carbon | |
190 | implementation. | |
98f8e666 VZ |
191 | |
192 | @since 2.9.2 | |
193 | */ | |
194 | virtual bool IsEnabled(const wxDataViewItem &item, | |
195 | unsigned int col) const; | |
196 | ||
23324ae1 | 197 | /** |
c4e57202 FM |
198 | Override this so the control can query the child items of an item. |
199 | Returns the number of items. | |
23324ae1 FM |
200 | */ |
201 | virtual unsigned int GetChildren(const wxDataViewItem& item, | |
fadc2df6 | 202 | wxDataViewItemArray& children) const = 0; |
23324ae1 FM |
203 | |
204 | /** | |
205 | Override this to indicate the number of columns in the model. | |
206 | */ | |
b91c4601 | 207 | virtual unsigned int GetColumnCount() const = 0; |
23324ae1 FM |
208 | |
209 | /** | |
210 | Override this to indicate what type of data is stored in the | |
c4e57202 FM |
211 | column specified by @a col. |
212 | ||
213 | This should return a string indicating the type of data as reported by wxVariant. | |
23324ae1 | 214 | */ |
b91c4601 | 215 | virtual wxString GetColumnType(unsigned int col) const = 0; |
23324ae1 FM |
216 | |
217 | /** | |
218 | Override this to indicate which wxDataViewItem representing the parent | |
57ab6f23 | 219 | of @a item or an invalid wxDataViewItem if the root item is |
23324ae1 FM |
220 | the parent item. |
221 | */ | |
b91c4601 | 222 | virtual wxDataViewItem GetParent(const wxDataViewItem& item) const = 0; |
23324ae1 FM |
223 | |
224 | /** | |
c4e57202 | 225 | Override this to indicate the value of @a item. |
23324ae1 FM |
226 | A wxVariant is used to store the data. |
227 | */ | |
b91c4601 FM |
228 | virtual void GetValue(wxVariant& variant, const wxDataViewItem& item, |
229 | unsigned int col) const = 0; | |
23324ae1 FM |
230 | |
231 | /** | |
c4e57202 FM |
232 | Override this method to indicate if a container item merely acts as a |
233 | headline (or for categorisation) or if it also acts a normal item with | |
57ab6f23 | 234 | entries for further columns. By default returns @false. |
23324ae1 | 235 | */ |
328f5751 | 236 | virtual bool HasContainerColumns(const wxDataViewItem& item) const; |
23324ae1 FM |
237 | |
238 | /** | |
239 | Override this to indicate that the model provides a default compare | |
240 | function that the control should use if no wxDataViewColumn has been | |
241 | chosen for sorting. Usually, the user clicks on a column header for | |
c4e57202 FM |
242 | sorting, the data will be sorted alphanumerically. |
243 | ||
244 | If any other order (e.g. by index or order of appearance) is required, | |
245 | then this should be used. | |
246 | See wxDataViewIndexListModel for a model which makes use of this. | |
23324ae1 | 247 | */ |
328f5751 | 248 | virtual bool HasDefaultCompare() const; |
23324ae1 | 249 | |
b372f20e VZ |
250 | /** |
251 | Return true if there is a value in the given column of this item. | |
252 | ||
253 | All normal items have values in all columns but the container items | |
254 | only show their label in the first column (@a col == 0) by default (but | |
255 | see HasContainerColumns()). So this function always returns true for | |
256 | the first column while for the other ones it returns true only if the | |
257 | item is not a container or HasContainerColumns() was overridden to | |
258 | return true for it. | |
259 | ||
260 | @since 2.9.1 | |
261 | */ | |
262 | bool HasValue(const wxDataViewItem& item, unsigned col) const; | |
263 | ||
23324ae1 | 264 | /** |
4cc4bfaf | 265 | Override this to indicate of @a item is a container, i.e. if |
23324ae1 FM |
266 | it can have child items. |
267 | */ | |
b91c4601 | 268 | virtual bool IsContainer(const wxDataViewItem& item) const = 0; |
23324ae1 FM |
269 | |
270 | /** | |
c4e57202 | 271 | Call this to inform the model that an item has been added to the data. |
23324ae1 | 272 | */ |
9ca2afd1 | 273 | bool ItemAdded(const wxDataViewItem& parent, |
23324ae1 FM |
274 | const wxDataViewItem& item); |
275 | ||
276 | /** | |
277 | Call this to inform the model that an item has changed. | |
c4e57202 | 278 | |
3a194bda | 279 | This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
23324ae1 FM |
280 | event (in which the column fields will not be set) to the user. |
281 | */ | |
9ca2afd1 | 282 | bool ItemChanged(const wxDataViewItem& item); |
23324ae1 FM |
283 | |
284 | /** | |
285 | Call this to inform the model that an item has been deleted from the data. | |
286 | */ | |
9ca2afd1 | 287 | bool ItemDeleted(const wxDataViewItem& parent, |
23324ae1 FM |
288 | const wxDataViewItem& item); |
289 | ||
290 | /** | |
c4e57202 | 291 | Call this to inform the model that several items have been added to the data. |
23324ae1 | 292 | */ |
9ca2afd1 | 293 | bool ItemsAdded(const wxDataViewItem& parent, |
23324ae1 FM |
294 | const wxDataViewItemArray& items); |
295 | ||
296 | /** | |
297 | Call this to inform the model that several items have changed. | |
c4e57202 | 298 | |
3a194bda | 299 | This will eventually emit @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
23324ae1 FM |
300 | events (in which the column fields will not be set) to the user. |
301 | */ | |
9ca2afd1 | 302 | bool ItemsChanged(const wxDataViewItemArray& items); |
23324ae1 FM |
303 | |
304 | /** | |
305 | Call this to inform the model that several items have been deleted. | |
306 | */ | |
9ca2afd1 | 307 | bool ItemsDeleted(const wxDataViewItem& parent, |
23324ae1 FM |
308 | const wxDataViewItemArray& items); |
309 | ||
310 | /** | |
4cc4bfaf | 311 | Remove the @a notifier from the list of notifiers. |
23324ae1 FM |
312 | */ |
313 | void RemoveNotifier(wxDataViewModelNotifier* notifier); | |
314 | ||
315 | /** | |
c4e57202 | 316 | Call this to initiate a resort after the sort function has been changed. |
23324ae1 FM |
317 | */ |
318 | virtual void Resort(); | |
319 | ||
320 | /** | |
321 | This gets called in order to set a value in the data model. | |
795dac4c | 322 | |
c4e57202 FM |
323 | The most common scenario is that the wxDataViewCtrl calls this method |
324 | after the user changed some data in the view. | |
325 | ||
795dac4c VZ |
326 | This is the function you need to override in your derived class but if |
327 | you want to call it, ChangeValue() is usually more convenient as | |
328 | otherwise you need to manually call ValueChanged() to update the | |
329 | control itself. | |
23324ae1 | 330 | */ |
795dac4c VZ |
331 | virtual bool SetValue(const wxVariant& variant, |
332 | const wxDataViewItem& item, | |
b91c4601 | 333 | unsigned int col) = 0; |
23324ae1 FM |
334 | |
335 | /** | |
c4e57202 FM |
336 | Call this to inform this model that a value in the model has been changed. |
337 | This is also called from wxDataViewCtrl's internal editing code, e.g. when | |
338 | editing a text field in the control. | |
339 | ||
3a194bda | 340 | This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
23324ae1 FM |
341 | event to the user. |
342 | */ | |
343 | virtual bool ValueChanged(const wxDataViewItem& item, | |
344 | unsigned int col); | |
5e6e278d FM |
345 | |
346 | protected: | |
347 | ||
348 | /** | |
349 | Destructor. This should not be called directly. Use DecRef() instead. | |
350 | */ | |
351 | virtual ~wxDataViewModel(); | |
23324ae1 FM |
352 | }; |
353 | ||
354 | ||
e54c96f1 | 355 | |
e39de702 | 356 | /** |
b955766e | 357 | @class wxDataViewListModel |
e39de702 | 358 | |
b955766e RR |
359 | Base class with abstract API for wxDataViewIndexListModel and |
360 | wxDataViewVirtualListModel. | |
e39de702 | 361 | |
8ed522d9 | 362 | @library{wxadv} |
b321b61c | 363 | @category{dvc} |
e39de702 | 364 | */ |
b955766e | 365 | class wxDataViewListModel : public wxDataViewModel |
e39de702 RR |
366 | { |
367 | public: | |
e39de702 RR |
368 | |
369 | /** | |
370 | Destructor. | |
371 | */ | |
adaaa686 | 372 | virtual ~wxDataViewIndexListModel(); |
e39de702 RR |
373 | |
374 | /** | |
375 | Compare method that sorts the items by their index. | |
376 | */ | |
377 | int Compare(const wxDataViewItem& item1, | |
378 | const wxDataViewItem& item2, | |
379 | unsigned int column, bool ascending); | |
380 | ||
381 | /** | |
13f184c0 | 382 | Override this to indicate that the row has special font attributes. |
c4e57202 FM |
383 | This only affects the wxDataViewTextRendererText() renderer. |
384 | ||
7fadac88 VZ |
385 | The base class version always simply returns @false. |
386 | ||
c4e57202 | 387 | @see wxDataViewItemAttr. |
7fadac88 VZ |
388 | |
389 | @param row | |
390 | The row for which the attribute is requested. | |
391 | @param col | |
392 | The column for which the attribute is requested. | |
393 | @param attr | |
394 | The attribute to be filled in if the function returns @true. | |
395 | @return | |
396 | @true if this item has an attribute or @false otherwise. | |
e39de702 | 397 | */ |
8eff6c56 | 398 | virtual bool GetAttrByRow(unsigned int row, unsigned int col, |
7fadac88 | 399 | wxDataViewItemAttr& attr) const; |
e39de702 | 400 | |
98f8e666 VZ |
401 | /** |
402 | Override this if you want to disable specific items. | |
403 | ||
404 | The base class version always returns @true, thus making all items | |
405 | enabled by default. | |
406 | ||
407 | @param row | |
408 | The row of the item whose enabled status is requested. | |
409 | @param col | |
410 | The column of the item whose enabled status is requested. | |
411 | @return | |
412 | @true if the item at this row and column should be enabled, | |
413 | @false otherwise. | |
414 | ||
415 | @note See wxDataViewModel::IsEnabled() for the current status of | |
416 | support for disabling the items under different platforms. | |
417 | ||
418 | @since 2.9.2 | |
419 | */ | |
420 | virtual bool IsEnabledByRow(unsigned int row, | |
421 | unsigned int col) const; | |
422 | ||
74d9b8fb | 423 | /** |
47e2f881 | 424 | Returns the number of items (or rows) in the list. |
74d9b8fb VZ |
425 | */ |
426 | unsigned int GetCount() const; | |
427 | ||
e39de702 RR |
428 | /** |
429 | Returns the wxDataViewItem at the given @e row. | |
430 | */ | |
431 | wxDataViewItem GetItem(unsigned int row) const; | |
432 | ||
433 | /** | |
434 | Returns the position of given @e item. | |
435 | */ | |
436 | unsigned int GetRow(const wxDataViewItem& item) const; | |
437 | ||
438 | /** | |
439 | Override this to allow getting values from the model. | |
440 | */ | |
8eff6c56 | 441 | virtual void GetValueByRow(wxVariant& variant, unsigned int row, |
fadc2df6 | 442 | unsigned int col) const = 0; |
e39de702 RR |
443 | |
444 | /** | |
c4e57202 FM |
445 | Call this after if the data has to be read again from the model. |
446 | This is useful after major changes when calling the methods below | |
447 | (possibly thousands of times) doesn't make sense. | |
e39de702 RR |
448 | */ |
449 | void Reset(unsigned int new_size); | |
450 | ||
451 | /** | |
452 | Call this after a row has been appended to the model. | |
453 | */ | |
454 | void RowAppended(); | |
455 | ||
456 | /** | |
457 | Call this after a row has been changed. | |
458 | */ | |
459 | void RowChanged(unsigned int row); | |
460 | ||
461 | /** | |
462 | Call this after a row has been deleted. | |
463 | */ | |
464 | void RowDeleted(unsigned int row); | |
465 | ||
466 | /** | |
467 | Call this after a row has been inserted at the given position. | |
468 | */ | |
469 | void RowInserted(unsigned int before); | |
470 | ||
471 | /** | |
472 | Call this after a row has been prepended to the model. | |
473 | */ | |
474 | void RowPrepended(); | |
475 | ||
476 | /** | |
477 | Call this after a value has been changed. | |
478 | */ | |
479 | void RowValueChanged(unsigned int row, unsigned int col); | |
480 | ||
481 | /** | |
c4e57202 FM |
482 | Call this after rows have been deleted. |
483 | The array will internally get copied and sorted in descending order so | |
484 | that the rows with the highest position will be deleted first. | |
e39de702 RR |
485 | */ |
486 | void RowsDeleted(const wxArrayInt& rows); | |
487 | ||
488 | /** | |
489 | Called in order to set a value in the model. | |
490 | */ | |
8eff6c56 | 491 | virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, |
fadc2df6 | 492 | unsigned int col) = 0; |
e39de702 RR |
493 | }; |
494 | ||
495 | ||
b955766e RR |
496 | /** |
497 | @class wxDataViewIndexListModel | |
498 | ||
499 | wxDataViewIndexListModel is a specialized data model which lets you address | |
500 | an item by its position (row) rather than its wxDataViewItem (which you can | |
501 | obtain from this class). | |
502 | This model also provides its own wxDataViewIndexListModel::Compare | |
503 | method which sorts the model's data by the index. | |
504 | ||
505 | This model is not a virtual model since the control stores each wxDataViewItem. | |
506 | Use wxDataViewVirtualListModel if you need to display millions of items or | |
507 | have other reason to use a virtual control. | |
508 | ||
509 | @see wxDataViewListModel for the API. | |
510 | ||
511 | @library{wxadv} | |
512 | @category{dvc} | |
513 | */ | |
514 | ||
515 | class wxDataViewIndexListModel : public wxDataViewListModel | |
516 | { | |
517 | public: | |
518 | /** | |
519 | Constructor. | |
520 | */ | |
521 | wxDataViewIndexListModel(unsigned int initial_size = 0); | |
522 | ||
523 | }; | |
e39de702 RR |
524 | |
525 | /** | |
526 | @class wxDataViewVirtualListModel | |
e39de702 | 527 | |
c4e57202 FM |
528 | wxDataViewVirtualListModel is a specialized data model which lets you address |
529 | an item by its position (row) rather than its wxDataViewItem and as such offers | |
530 | the exact same interface as wxDataViewIndexListModel. | |
531 | The important difference is that under platforms other than OS X, using this | |
532 | model will result in a truly virtual control able to handle millions of items | |
b955766e | 533 | as the control doesn't store any item (a feature not supported by OS X). |
e39de702 | 534 | |
b955766e | 535 | @see wxDataViewListModel for the API. |
e39de702 | 536 | |
8ed522d9 | 537 | @library{wxadv} |
b321b61c | 538 | @category{dvc} |
e39de702 | 539 | */ |
b955766e RR |
540 | |
541 | class wxDataViewVirtualListModel : public wxDataViewListModel | |
e39de702 RR |
542 | { |
543 | public: | |
544 | /** | |
545 | Constructor. | |
546 | */ | |
547 | wxDataViewVirtualListModel(unsigned int initial_size = 0); | |
74d9b8fb | 548 | |
6da3d196 | 549 | }; |
e39de702 RR |
550 | |
551 | ||
552 | ||
23324ae1 FM |
553 | /** |
554 | @class wxDataViewItemAttr | |
7c913512 | 555 | |
c4e57202 FM |
556 | This class is used to indicate to a wxDataViewCtrl that a certain item |
557 | (see wxDataViewItem) has extra font attributes for its renderer. | |
558 | For this, it is required to override wxDataViewModel::GetAttr. | |
7c913512 | 559 | |
c4e57202 | 560 | Attributes are currently only supported by wxDataViewTextRendererText. |
7c913512 | 561 | |
23324ae1 | 562 | @library{wxadv} |
b321b61c | 563 | @category{dvc} |
23324ae1 | 564 | */ |
7c913512 | 565 | class wxDataViewItemAttr |
23324ae1 FM |
566 | { |
567 | public: | |
568 | /** | |
569 | Constructor. | |
570 | */ | |
571 | wxDataViewItemAttr(); | |
572 | ||
573 | /** | |
574 | Call this to indicate that the item shall be displayed in bold text. | |
575 | */ | |
576 | void SetBold(bool set); | |
577 | ||
578 | /** | |
c4e57202 | 579 | Call this to indicate that the item shall be displayed with that colour. |
23324ae1 FM |
580 | */ |
581 | void SetColour(const wxColour& colour); | |
582 | ||
583 | /** | |
584 | Call this to indicate that the item shall be displayed in italic text. | |
585 | */ | |
586 | void SetItalic(bool set); | |
587 | }; | |
588 | ||
589 | ||
e54c96f1 | 590 | |
23324ae1 FM |
591 | /** |
592 | @class wxDataViewItem | |
7c913512 | 593 | |
c4e57202 | 594 | wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl |
fe45d6ff | 595 | in a persistent way, i.e. independent of the position of the item in the control |
c4e57202 FM |
596 | or changes to its contents. |
597 | ||
598 | It must hold a unique ID of type @e void* in its only field and can be converted | |
599 | to and from it. | |
600 | ||
601 | If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will | |
602 | return @false which used in many places in the API of wxDataViewCtrl to | |
603 | indicate that e.g. no item was found. An ID of @NULL is also used to indicate | |
604 | the invisible root. Examples for this are wxDataViewModel::GetParent and | |
23324ae1 | 605 | wxDataViewModel::GetChildren. |
7c913512 | 606 | |
23324ae1 | 607 | @library{wxadv} |
b321b61c | 608 | @category{dvc} |
23324ae1 | 609 | */ |
7c913512 | 610 | class wxDataViewItem |
23324ae1 FM |
611 | { |
612 | public: | |
613 | //@{ | |
614 | /** | |
c4e57202 | 615 | Constructor. |
23324ae1 | 616 | */ |
d5c4a81f | 617 | wxDataViewItem(); |
7c913512 | 618 | wxDataViewItem(const wxDataViewItem& item); |
d5c4a81f | 619 | explicit wxDataViewItem(void* id); |
23324ae1 FM |
620 | //@} |
621 | ||
622 | /** | |
623 | Returns the ID. | |
624 | */ | |
328f5751 | 625 | void* GetID() const; |
23324ae1 FM |
626 | |
627 | /** | |
c4e57202 | 628 | Returns @true if the ID is not @NULL. |
23324ae1 | 629 | */ |
328f5751 | 630 | bool IsOk() const; |
23324ae1 FM |
631 | }; |
632 | ||
633 | ||
e9321277 RD |
634 | // ---------------------------------------------------------------------------- |
635 | // wxDataViewCtrl flags | |
636 | // ---------------------------------------------------------------------------- | |
637 | ||
638 | // size of a wxDataViewRenderer without contents: | |
639 | #define wxDVC_DEFAULT_RENDERER_SIZE 20 | |
640 | ||
641 | // the default width of new (text) columns: | |
642 | #define wxDVC_DEFAULT_WIDTH 80 | |
643 | ||
644 | // the default width of new toggle columns: | |
645 | #define wxDVC_TOGGLE_DEFAULT_WIDTH 30 | |
646 | ||
647 | // the default minimal width of the columns: | |
648 | #define wxDVC_DEFAULT_MINWIDTH 30 | |
649 | ||
650 | // The default alignment of wxDataViewRenderers is to take | |
651 | // the alignment from the column it owns. | |
652 | #define wxDVR_DEFAULT_ALIGNMENT -1 | |
653 | ||
654 | #define wxDV_SINGLE 0x0000 // for convenience | |
655 | #define wxDV_MULTIPLE 0x0001 // can select multiple items | |
656 | ||
657 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
658 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
659 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
660 | ||
661 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows | |
662 | #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height | |
663 | ||
ea8fa3c4 RD |
664 | // events |
665 | ||
666 | wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED; | |
667 | ||
668 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED; | |
669 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING; | |
670 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED; | |
671 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING; | |
672 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED; | |
673 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING; | |
674 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED; | |
675 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE; | |
676 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED; | |
677 | ||
678 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU; | |
679 | ||
680 | wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK; | |
681 | wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK; | |
682 | wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED; | |
683 | wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED; | |
684 | wxEventType wxEVT_COMMAND_DATAVIEW_CACHE_HINT; | |
685 | ||
686 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG; | |
687 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE; | |
688 | wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_DROP; | |
e54c96f1 | 689 | |
23324ae1 FM |
690 | /** |
691 | @class wxDataViewCtrl | |
7c913512 | 692 | |
c4e57202 FM |
693 | wxDataViewCtrl is a control to display data either in a tree like fashion or |
694 | in a tabular form or both. | |
02b51ae5 | 695 | |
c4e57202 FM |
696 | If you only need to display a simple tree structure with an API more like the |
697 | older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used. | |
02b51ae5 | 698 | Likewise, if you only want to display simple table structure you can use |
832df171 RR |
699 | the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and |
700 | wxDataViewListCtrl can be used without defining your own wxDataViewModel. | |
c4e57202 FM |
701 | |
702 | A wxDataViewItem is used to represent a (visible) item in the control. | |
703 | ||
80932a3e | 704 | Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through |
c4e57202 FM |
705 | virtual functions or by setting it directly. Instead you need to write your own |
706 | wxDataViewModel and associate it with this control. | |
707 | Then you need to add a number of wxDataViewColumn to this control to define | |
708 | what each column shall display. Each wxDataViewColumn in turn owns 1 instance | |
709 | of a wxDataViewRenderer to render its cells. | |
710 | ||
711 | A number of standard renderers for rendering text, dates, images, toggle, | |
712 | a progress bar etc. are provided. Additionally, the user can write custom | |
80932a3e | 713 | renderers deriving from wxDataViewCustomRenderer for displaying anything. |
c4e57202 FM |
714 | |
715 | All data transfer from the control to the model and the user code is done | |
716 | through wxVariant which can be extended to support more data formats as necessary. | |
717 | Accordingly, all type information uses the strings returned from wxVariant::GetType. | |
7c913512 | 718 | |
23324ae1 | 719 | @beginStyleTable |
8c6791e4 | 720 | @style{wxDV_SINGLE} |
23324ae1 | 721 | Single selection mode. This is the default. |
8c6791e4 | 722 | @style{wxDV_MULTIPLE} |
23324ae1 | 723 | Multiple selection mode. |
8c6791e4 | 724 | @style{wxDV_ROW_LINES} |
23324ae1 | 725 | Use alternating colours for rows if supported by platform and theme. |
cc72cde0 VZ |
726 | Currently only supported by the native GTK and OS X implementations |
727 | but not by the generic one. | |
8c6791e4 | 728 | @style{wxDV_HORIZ_RULES} |
23324ae1 | 729 | Display fine rules between row if supported. |
8c6791e4 | 730 | @style{wxDV_VERT_RULES} |
23324ae1 | 731 | Display fine rules between columns is supported. |
d7c6d397 | 732 | @style{wxDV_VARIABLE_LINE_HEIGHT} |
c4e57202 | 733 | Allow variable line heights. |
14f73cf1 | 734 | This can be inefficient when displaying large number of items. |
b5123fb6 VZ |
735 | @style{wxDV_NO_HEADER} |
736 | Do not show column headers (which are shown by default). | |
23324ae1 | 737 | @endStyleTable |
7c913512 | 738 | |
3051a44a | 739 | @beginEventEmissionTable{wxDataViewEvent} |
7d01d660 | 740 | @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)} |
14f73cf1 | 741 | Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event. |
7d01d660 | 742 | @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)} |
14f73cf1 | 743 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. |
3e978cf7 | 744 | @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)} |
b0c7cd8e | 745 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event. This |
3e978cf7 | 746 | event can be vetoed in order to prevent editing on an item by item |
b0c7cd8e | 747 | basis. |
7d01d660 | 748 | @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)} |
14f73cf1 | 749 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. |
7d01d660 | 750 | @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)} |
14f73cf1 | 751 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event. |
7d01d660 | 752 | @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)} |
14f73cf1 | 753 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event. |
7d01d660 | 754 | @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)} |
14f73cf1 | 755 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event. |
7d01d660 | 756 | @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)} |
14f73cf1 | 757 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event. |
7d01d660 | 758 | @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)} |
14f73cf1 | 759 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event. |
7d01d660 | 760 | @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)} |
14f73cf1 | 761 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event. |
7d01d660 | 762 | @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)} |
7ed24cb6 VZ |
763 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event |
764 | generated when the user right clicks inside the control. Notice that | |
765 | this menu is generated even if the click didn't occur on any valid | |
766 | item, in this case wxDataViewEvent::GetItem() simply returns an | |
767 | invalid item. | |
7d01d660 | 768 | @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)} |
14f73cf1 | 769 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event. |
7d01d660 | 770 | @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)} |
14f73cf1 | 771 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event. |
7d01d660 | 772 | @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)} |
14f73cf1 | 773 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event. |
7d01d660 | 774 | @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)} |
14f73cf1 | 775 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event. |
591cc82d | 776 | @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)} |
14f73cf1 | 777 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event. |
e4de825e | 778 | @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)} |
14f73cf1 | 779 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event. |
e4de825e | 780 | @event{EVT_DATAVIEW_ITEM_DROP(id, func)} |
14f73cf1 | 781 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event. |
7d01d660 | 782 | @endEventTable |
b91c4601 | 783 | |
23324ae1 | 784 | @library{wxadv} |
b321b61c | 785 | @category{ctrl,dvc} |
7e59b885 | 786 | @appearance{dataviewctrl.png} |
23324ae1 FM |
787 | */ |
788 | class wxDataViewCtrl : public wxControl | |
789 | { | |
790 | public: | |
23324ae1 | 791 | /** |
19723525 | 792 | Default Constructor. |
23324ae1 FM |
793 | */ |
794 | wxDataViewCtrl(); | |
b91c4601 | 795 | |
19723525 RR |
796 | /** |
797 | Constructor. Calls Create(). | |
798 | */ | |
7c913512 FM |
799 | wxDataViewCtrl(wxWindow* parent, wxWindowID id, |
800 | const wxPoint& pos = wxDefaultPosition, | |
801 | const wxSize& size = wxDefaultSize, | |
802 | long style = 0, | |
8eb99915 RR |
803 | const wxValidator& validator = wxDefaultValidator, |
804 | const wxString& name = wxDataViewCtrlNameStr); | |
23324ae1 FM |
805 | |
806 | /** | |
807 | Destructor. | |
808 | */ | |
adaaa686 | 809 | virtual ~wxDataViewCtrl(); |
23324ae1 | 810 | |
e39de702 | 811 | /** |
19723525 | 812 | Appends a wxDataViewColumn to the control. Returns @true on success. |
c4e57202 | 813 | |
e39de702 RR |
814 | Note that there is a number of short cut methods which implicitly create |
815 | a wxDataViewColumn and a wxDataViewRenderer for it (see below). | |
816 | */ | |
817 | virtual bool AppendColumn(wxDataViewColumn* col); | |
818 | ||
19723525 RR |
819 | /** |
820 | Prepends a wxDataViewColumn to the control. Returns @true on success. | |
c4e57202 | 821 | |
19723525 RR |
822 | Note that there is a number of short cut methods which implicitly create |
823 | a wxDataViewColumn and a wxDataViewRenderer for it. | |
824 | */ | |
825 | virtual bool PrependColumn(wxDataViewColumn* col); | |
826 | ||
827 | /** | |
828 | Inserts a wxDataViewColumn to the control. Returns @true on success. | |
829 | */ | |
830 | virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col); | |
b91c4601 | 831 | |
23324ae1 FM |
832 | //@{ |
833 | /** | |
834 | Appends a column for rendering a bitmap. Returns the wxDataViewColumn | |
835 | created in the function or @NULL on failure. | |
836 | */ | |
837 | wxDataViewColumn* AppendBitmapColumn(const wxString& label, | |
838 | unsigned int model_column, | |
839 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
840 | int width = -1, | |
841 | wxAlignment align = wxALIGN_CENTER, | |
842 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
843 | wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label, |
844 | unsigned int model_column, | |
845 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
846 | int width = -1, | |
847 | wxAlignment align = wxALIGN_CENTER, | |
848 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
849 | //@} |
850 | ||
23324ae1 FM |
851 | //@{ |
852 | /** | |
853 | Appends a column for rendering a date. Returns the wxDataViewColumn | |
854 | created in the function or @NULL on failure. | |
b91c4601 | 855 | |
c4e57202 FM |
856 | @note The @a align parameter is applied to both the column header and |
857 | the column renderer. | |
23324ae1 FM |
858 | */ |
859 | wxDataViewColumn* AppendDateColumn(const wxString& label, | |
860 | unsigned int model_column, | |
861 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
862 | int width = -1, | |
882678eb | 863 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 864 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
865 | wxDataViewColumn* AppendDateColumn(const wxBitmap& label, |
866 | unsigned int model_column, | |
867 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
868 | int width = -1, | |
882678eb | 869 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 870 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
871 | //@} |
872 | ||
873 | //@{ | |
874 | /** | |
875 | Appends a column for rendering text with an icon. Returns the wxDataViewColumn | |
c4e57202 FM |
876 | created in the function or @NULL on failure. |
877 | This method uses the wxDataViewIconTextRenderer class. | |
b91c4601 | 878 | |
c4e57202 FM |
879 | @note The @a align parameter is applied to both the column header and |
880 | the column renderer. | |
23324ae1 FM |
881 | */ |
882 | wxDataViewColumn* AppendIconTextColumn(const wxString& label, | |
883 | unsigned int model_column, | |
884 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
885 | int width = -1, | |
882678eb | 886 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 887 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
888 | wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label, |
889 | unsigned int model_column, | |
890 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
891 | int width = -1, | |
882678eb | 892 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 893 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
894 | //@} |
895 | ||
896 | //@{ | |
897 | /** | |
898 | Appends a column for rendering a progress indicator. Returns the | |
e39de702 | 899 | wxDataViewColumn created in the function or @NULL on failure. |
b91c4601 | 900 | |
c4e57202 FM |
901 | @note The @a align parameter is applied to both the column header and |
902 | the column renderer. | |
23324ae1 FM |
903 | */ |
904 | wxDataViewColumn* AppendProgressColumn(const wxString& label, | |
905 | unsigned int model_column, | |
906 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
907 | int width = 80, | |
908 | wxAlignment align = wxALIGN_CENTER, | |
909 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
910 | wxDataViewColumn* AppendProgressColumn(const wxBitmap& label, |
911 | unsigned int model_column, | |
912 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
913 | int width = 80, | |
914 | wxAlignment align = wxALIGN_CENTER, | |
915 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
916 | //@} |
917 | ||
918 | //@{ | |
919 | /** | |
920 | Appends a column for rendering text. Returns the wxDataViewColumn | |
921 | created in the function or @NULL on failure. | |
b91c4601 | 922 | |
c4e57202 FM |
923 | @note The @a align parameter is applied to both the column header and |
924 | the column renderer. | |
23324ae1 FM |
925 | */ |
926 | wxDataViewColumn* AppendTextColumn(const wxString& label, | |
927 | unsigned int model_column, | |
928 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
929 | int width = -1, | |
882678eb | 930 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 931 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
932 | wxDataViewColumn* AppendTextColumn(const wxBitmap& label, |
933 | unsigned int model_column, | |
934 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
935 | int width = -1, | |
882678eb | 936 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 937 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
938 | //@} |
939 | ||
940 | //@{ | |
941 | /** | |
942 | Appends a column for rendering a toggle. Returns the wxDataViewColumn | |
943 | created in the function or @NULL on failure. | |
b91c4601 | 944 | |
c4e57202 FM |
945 | @note The @a align parameter is applied to both the column header and |
946 | the column renderer. | |
23324ae1 FM |
947 | */ |
948 | wxDataViewColumn* AppendToggleColumn(const wxString& label, | |
949 | unsigned int model_column, | |
950 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
951 | int width = 30, | |
952 | wxAlignment align = wxALIGN_CENTER, | |
953 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
954 | wxDataViewColumn* AppendToggleColumn(const wxBitmap& label, |
955 | unsigned int model_column, | |
956 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
957 | int width = 30, | |
958 | wxAlignment align = wxALIGN_CENTER, | |
959 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
960 | //@} |
961 | ||
962 | /** | |
c4e57202 FM |
963 | Associates a wxDataViewModel with the control. |
964 | This increases the reference count of the model by 1. | |
23324ae1 FM |
965 | */ |
966 | virtual bool AssociateModel(wxDataViewModel* model); | |
967 | ||
968 | /** | |
969 | Removes all columns. | |
970 | */ | |
971 | virtual bool ClearColumns(); | |
972 | ||
23324ae1 FM |
973 | /** |
974 | Collapses the item. | |
975 | */ | |
adaaa686 | 976 | virtual void Collapse(const wxDataViewItem& item); |
23324ae1 FM |
977 | |
978 | /** | |
979 | Create the control. Useful for two step creation. | |
980 | */ | |
981 | bool Create(wxWindow* parent, wxWindowID id, | |
982 | const wxPoint& pos = wxDefaultPosition, | |
983 | const wxSize& size = wxDefaultSize, | |
984 | long style = 0, | |
8eb99915 RR |
985 | const wxValidator& validator = wxDefaultValidator, |
986 | const wxString& name = wxDataViewCtrlNameStr); | |
23324ae1 FM |
987 | |
988 | /** | |
989 | Deletes given column. | |
990 | */ | |
50ec54b6 | 991 | virtual bool DeleteColumn(wxDataViewColumn* column); |
23324ae1 | 992 | |
e4de825e RR |
993 | /** |
994 | Enable drag operations using the given @a format. | |
995 | */ | |
996 | virtual bool EnableDragSource( const wxDataFormat &format ); | |
02b51ae5 | 997 | |
e4de825e RR |
998 | /** |
999 | Enable drop operations using the given @a format. | |
1000 | */ | |
1001 | virtual bool EnableDropTarget( const wxDataFormat &format ); | |
02b51ae5 | 1002 | |
23324ae1 FM |
1003 | /** |
1004 | Call this to ensure that the given item is visible. | |
1005 | */ | |
fadc2df6 FM |
1006 | virtual void EnsureVisible(const wxDataViewItem& item, |
1007 | const wxDataViewColumn* column = NULL); | |
23324ae1 FM |
1008 | |
1009 | /** | |
1010 | Expands the item. | |
1011 | */ | |
adaaa686 | 1012 | virtual void Expand(const wxDataViewItem& item); |
23324ae1 | 1013 | |
4219d8b0 RR |
1014 | /** |
1015 | Expands all ancestors of the @a item. This method also | |
1016 | ensures that the item itself as well as all ancestor | |
1017 | items have been read from the model by the control. | |
1018 | */ | |
1019 | virtual void ExpandAncestors( const wxDataViewItem & item ); | |
798c0d87 | 1020 | |
23324ae1 | 1021 | /** |
c4e57202 FM |
1022 | Returns pointer to the column. @a pos refers to the position in the |
1023 | control which may change after reordering columns by the user. | |
23324ae1 | 1024 | */ |
328f5751 | 1025 | virtual wxDataViewColumn* GetColumn(unsigned int pos) const; |
23324ae1 FM |
1026 | |
1027 | /** | |
1028 | Returns the number of columns. | |
1029 | */ | |
328f5751 | 1030 | virtual unsigned int GetColumnCount() const; |
23324ae1 FM |
1031 | |
1032 | /** | |
1033 | Returns the position of the column or -1 if not found in the control. | |
1034 | */ | |
328f5751 | 1035 | virtual int GetColumnPosition(const wxDataViewColumn* column) const; |
23324ae1 FM |
1036 | |
1037 | /** | |
1038 | Returns column containing the expanders. | |
1039 | */ | |
328f5751 | 1040 | wxDataViewColumn* GetExpanderColumn() const; |
23324ae1 | 1041 | |
80ce465c VZ |
1042 | /** |
1043 | Returns the currently focused item. | |
1044 | ||
1045 | This is the item that the keyboard commands apply to. It may be invalid | |
1046 | if there is no focus currently. | |
1047 | ||
1048 | This method is mostly useful for the controls with @c wxDV_MULTIPLE | |
1049 | style as in the case of single selection it returns the same thing as | |
1050 | GetSelection(). | |
1051 | ||
1052 | Notice that under all platforms except Mac OS X the currently focused | |
1053 | item may be selected or not but under OS X the current item is always | |
1054 | selected. | |
1055 | ||
1056 | @see SetCurrentItem() | |
1057 | ||
1058 | @since 2.9.2 | |
1059 | */ | |
1060 | wxDataViewItem GetCurrentItem() const; | |
1061 | ||
23324ae1 FM |
1062 | /** |
1063 | Returns indentation. | |
1064 | */ | |
328f5751 | 1065 | int GetIndent() const; |
23324ae1 FM |
1066 | |
1067 | /** | |
1068 | Returns item rect. | |
1069 | */ | |
fadc2df6 FM |
1070 | virtual wxRect GetItemRect(const wxDataViewItem& item, |
1071 | const wxDataViewColumn* col = NULL) const; | |
23324ae1 FM |
1072 | |
1073 | /** | |
c4e57202 | 1074 | Returns pointer to the data model associated with the control (if any). |
23324ae1 | 1075 | */ |
adaaa686 | 1076 | wxDataViewModel* GetModel(); |
23324ae1 | 1077 | |
fa93d732 VZ |
1078 | /** |
1079 | Returns the number of currently selected items. | |
1080 | ||
1081 | This method may be called for both the controls with single and | |
1082 | multiple selections and returns the number of selected item, possibly | |
1083 | 0, in any case. | |
1084 | ||
1085 | @since 2.9.3 | |
1086 | */ | |
1087 | virtual int GetSelectedItemsCount() const; | |
1088 | ||
23324ae1 FM |
1089 | /** |
1090 | Returns first selected item or an invalid item if none is selected. | |
fa93d732 VZ |
1091 | |
1092 | This method may be called for both the controls with single and | |
1093 | multiple selections but returns an invalid item if more than one item | |
1094 | is selected in the latter case, use HasSelection() to determine if | |
1095 | there are any selected items when using multiple selection. | |
23324ae1 | 1096 | */ |
adaaa686 | 1097 | virtual wxDataViewItem GetSelection() const; |
23324ae1 FM |
1098 | |
1099 | /** | |
c4e57202 | 1100 | Fills @a sel with currently selected items and returns their number. |
fa93d732 VZ |
1101 | |
1102 | This method may be called for both the controls with single and | |
1103 | multiple selections. In the single selection case it returns the array | |
1104 | with at most one element in it. | |
1105 | ||
1106 | @see GetSelectedItemsCount() | |
23324ae1 | 1107 | */ |
adaaa686 | 1108 | virtual int GetSelections(wxDataViewItemArray& sel) const; |
23324ae1 FM |
1109 | |
1110 | /** | |
1111 | Returns the wxDataViewColumn currently responsible for sorting | |
1112 | or @NULL if none has been selected. | |
1113 | */ | |
328f5751 | 1114 | virtual wxDataViewColumn* GetSortingColumn() const; |
23324ae1 | 1115 | |
fa93d732 VZ |
1116 | /** |
1117 | Returns true if any items are currently selected. | |
1118 | ||
1119 | This method may be called for both the controls with single and | |
1120 | multiple selections. | |
1121 | ||
1122 | Calling this method is equivalent to calling GetSelectedItemsCount() | |
1123 | and comparing its result with 0 but is more clear and might also be | |
1124 | implemented more efficiently in the future. | |
1125 | ||
1126 | @since 2.9.3 | |
1127 | */ | |
1128 | bool HasSelection() const; | |
1129 | ||
23324ae1 FM |
1130 | /** |
1131 | Hittest. | |
1132 | */ | |
fadc2df6 FM |
1133 | virtual void HitTest(const wxPoint& point, wxDataViewItem& item, |
1134 | wxDataViewColumn*& col) const; | |
23324ae1 | 1135 | |
739a8399 RR |
1136 | /** |
1137 | Return @true if the item is expanded. | |
739a8399 RR |
1138 | */ |
1139 | virtual bool IsExpanded(const wxDataViewItem& item) const; | |
1140 | ||
23324ae1 FM |
1141 | /** |
1142 | Return @true if the item is selected. | |
1143 | */ | |
adaaa686 | 1144 | virtual bool IsSelected(const wxDataViewItem& item) const; |
23324ae1 FM |
1145 | |
1146 | /** | |
1147 | Select the given item. | |
1e184300 VZ |
1148 | |
1149 | In single selection mode this changes the (unique) currently selected | |
1150 | item. In multi selection mode, the @a item is selected and the | |
1151 | previously selected items remain selected. | |
23324ae1 | 1152 | */ |
adaaa686 | 1153 | virtual void Select(const wxDataViewItem& item); |
23324ae1 FM |
1154 | |
1155 | /** | |
1156 | Select all items. | |
1157 | */ | |
adaaa686 | 1158 | virtual void SelectAll(); |
23324ae1 FM |
1159 | |
1160 | /** | |
1161 | Set which column shall contain the tree-like expanders. | |
1162 | */ | |
4cc4bfaf | 1163 | void SetExpanderColumn(wxDataViewColumn* col); |
23324ae1 | 1164 | |
80ce465c VZ |
1165 | /** |
1166 | Changes the currently focused item. | |
1167 | ||
1168 | The @a item parameter must be valid, there is no way to remove the | |
1169 | current item from the control. | |
1170 | ||
1171 | In single selection mode, calling this method is the same as calling | |
1172 | Select() and is thus not very useful. In multiple selection mode this | |
1173 | method only moves the current item however without changing the | |
1174 | selection except under OS X where the current item is always selected, | |
1175 | so calling SetCurrentItem() selects @a item if it hadn't been selected | |
1176 | before. | |
1177 | ||
1178 | @see GetCurrentItem() | |
1179 | ||
1180 | @since 2.9.2 | |
1181 | */ | |
1182 | void SetCurrentItem(const wxDataViewItem& item); | |
1183 | ||
23324ae1 | 1184 | /** |
57ab6f23 | 1185 | Sets the indentation. |
23324ae1 FM |
1186 | */ |
1187 | void SetIndent(int indent); | |
1188 | ||
1189 | /** | |
1190 | Sets the selection to the array of wxDataViewItems. | |
1191 | */ | |
adaaa686 | 1192 | virtual void SetSelections(const wxDataViewItemArray& sel); |
23324ae1 | 1193 | |
eeea3b03 RD |
1194 | /** |
1195 | Programmatically starts editing the given item on the given column. | |
1196 | Currently not implemented on wxOSX Carbon. | |
1197 | @since 2.9.2 | |
1198 | */ | |
1199 | ||
1200 | virtual void StartEditor(const wxDataViewItem & item, unsigned int column); | |
1201 | ||
23324ae1 FM |
1202 | /** |
1203 | Unselect the given item. | |
1204 | */ | |
adaaa686 | 1205 | virtual void Unselect(const wxDataViewItem& item); |
23324ae1 FM |
1206 | |
1207 | /** | |
c4e57202 FM |
1208 | Unselect all item. |
1209 | This method only has effect if multiple selections are allowed. | |
23324ae1 | 1210 | */ |
adaaa686 | 1211 | virtual void UnselectAll(); |
bbfd4548 VZ |
1212 | |
1213 | /** | |
1214 | Sets the row height. | |
1215 | ||
1216 | This function can only be used when all rows have the same height, i.e. | |
1217 | when wxDV_VARIABLE_LINE_HEIGHT flag is not used. | |
1218 | ||
0f4a54a6 VZ |
1219 | Currently this is implemented in the generic and native GTK versions |
1220 | only and nothing is done (and @false returned) when using OS X port. | |
1221 | ||
1222 | Also notice that this method can only be used to increase the row | |
1223 | height compared with the default one (as determined by the return value | |
1224 | of wxDataViewRenderer::GetSize()), if it is set to a too small value | |
1225 | then the minimum required by the renderers will be used. | |
bbfd4548 VZ |
1226 | |
1227 | @return @true if the line height was changed or @false otherwise. | |
1228 | ||
1229 | @since 2.9.2 | |
1230 | */ | |
1231 | virtual bool SetRowHeight(int rowHeight); | |
23324ae1 FM |
1232 | }; |
1233 | ||
1234 | ||
e54c96f1 | 1235 | |
23324ae1 FM |
1236 | /** |
1237 | @class wxDataViewModelNotifier | |
7c913512 | 1238 | |
c4e57202 FM |
1239 | A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors |
1240 | its notification interface. | |
1241 | See the documentation of that class for further information. | |
7c913512 | 1242 | |
8ed522d9 | 1243 | @library{wxadv} |
b321b61c | 1244 | @category{dvc} |
23324ae1 | 1245 | */ |
7c913512 | 1246 | class wxDataViewModelNotifier |
23324ae1 FM |
1247 | { |
1248 | public: | |
1249 | /** | |
1250 | Constructor. | |
1251 | */ | |
1252 | wxDataViewModelNotifier(); | |
1253 | ||
1254 | /** | |
1255 | Destructor. | |
1256 | */ | |
adaaa686 | 1257 | virtual ~wxDataViewModelNotifier(); |
23324ae1 FM |
1258 | |
1259 | /** | |
1260 | Called by owning model. | |
1261 | */ | |
b91c4601 | 1262 | virtual bool Cleared() = 0; |
23324ae1 FM |
1263 | |
1264 | /** | |
1265 | Get owning wxDataViewModel. | |
1266 | */ | |
e51bf699 | 1267 | wxDataViewModel* GetOwner() const; |
23324ae1 FM |
1268 | |
1269 | /** | |
1270 | Called by owning model. | |
63e55c0a VS |
1271 | |
1272 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1273 | */ |
fadc2df6 FM |
1274 | virtual bool ItemAdded(const wxDataViewItem& parent, |
1275 | const wxDataViewItem& item) = 0; | |
23324ae1 FM |
1276 | |
1277 | /** | |
1278 | Called by owning model. | |
63e55c0a VS |
1279 | |
1280 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1281 | */ |
b91c4601 | 1282 | virtual bool ItemChanged(const wxDataViewItem& item) = 0; |
23324ae1 FM |
1283 | |
1284 | /** | |
1285 | Called by owning model. | |
63e55c0a VS |
1286 | |
1287 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1288 | */ |
fadc2df6 FM |
1289 | virtual bool ItemDeleted(const wxDataViewItem& parent, |
1290 | const wxDataViewItem& item) = 0; | |
23324ae1 FM |
1291 | |
1292 | /** | |
1293 | Called by owning model. | |
63e55c0a VS |
1294 | |
1295 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1296 | */ |
fadc2df6 FM |
1297 | virtual bool ItemsAdded(const wxDataViewItem& parent, |
1298 | const wxDataViewItemArray& items); | |
23324ae1 FM |
1299 | |
1300 | /** | |
1301 | Called by owning model. | |
63e55c0a VS |
1302 | |
1303 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1304 | */ |
adaaa686 | 1305 | virtual bool ItemsChanged(const wxDataViewItemArray& items); |
23324ae1 FM |
1306 | |
1307 | /** | |
1308 | Called by owning model. | |
63e55c0a VS |
1309 | |
1310 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1311 | */ |
fadc2df6 FM |
1312 | virtual bool ItemsDeleted(const wxDataViewItem& parent, |
1313 | const wxDataViewItemArray& items); | |
23324ae1 FM |
1314 | |
1315 | /** | |
1316 | Called by owning model. | |
1317 | */ | |
b91c4601 | 1318 | virtual void Resort() = 0; |
23324ae1 FM |
1319 | |
1320 | /** | |
1321 | Set owner of this notifier. Used internally. | |
1322 | */ | |
1323 | void SetOwner(wxDataViewModel* owner); | |
1324 | ||
1325 | /** | |
1326 | Called by owning model. | |
63e55c0a VS |
1327 | |
1328 | @return Always return @true from this function in derived classes. | |
23324ae1 | 1329 | */ |
b91c4601 | 1330 | virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0; |
23324ae1 FM |
1331 | }; |
1332 | ||
1333 | ||
c4e57202 FM |
1334 | /** |
1335 | The mode of a data-view cell; see wxDataViewRenderer for more info. | |
1336 | */ | |
1337 | enum wxDataViewCellMode | |
1338 | { | |
dc73d7f5 VS |
1339 | /** |
1340 | The cell only displays information and cannot be manipulated or | |
1341 | otherwise interacted with in any way. | |
1342 | ||
1343 | Note that this doesn't mean that the row being drawn can't be selected, | |
1344 | just that a particular element of it cannot be individually modified. | |
1345 | */ | |
c4e57202 FM |
1346 | wxDATAVIEW_CELL_INERT, |
1347 | ||
1348 | /** | |
dc73d7f5 VS |
1349 | Indicates that the cell can be @em activated by clicking it or using |
1350 | keyboard. | |
1351 | ||
1352 | Activating a cell is an alternative to showing inline editor when the | |
1353 | value can be edited in a simple way that doesn't warrant full editor | |
1354 | control. The most typical use of cell activation is toggling the | |
1355 | checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded | |
1356 | volume slider or a five-star rating column. | |
1357 | ||
1358 | The exact means of activating a cell are platform-dependent, but they | |
1359 | are usually similar to those used for inline editing of values. | |
1360 | Typically, a cell would be activated by Space or Enter keys or by left | |
1361 | mouse click. | |
1362 | ||
1363 | @note Do not confuse this with item activation in wxDataViewCtrl | |
1364 | and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is | |
1365 | used for activating the item (or, to put it differently, the | |
1366 | entire row) similarly to analogous messages in wxTreeCtrl and | |
1367 | wxListCtrl, and the effect differs (play a song, open a file | |
1368 | etc.). Cell activation, on the other hand, is all about | |
1369 | interacting with the individual cell. | |
1370 | ||
1371 | @see wxDataViewCustomRenderer::ActivateCell() | |
c4e57202 FM |
1372 | */ |
1373 | wxDATAVIEW_CELL_ACTIVATABLE, | |
1374 | ||
1375 | /** | |
dc73d7f5 VS |
1376 | Indicates that the user can edit the data in-place in an inline editor |
1377 | control that will show up when the user wants to edit the cell. | |
1378 | ||
1379 | A typical example of this behaviour is changing the filename in a file | |
1380 | managers. | |
1381 | ||
1382 | Editing is typically triggered by slowly double-clicking the cell or by | |
1383 | a platform-dependent keyboard shortcut (F2 is typical on Windows, Space | |
1384 | and/or Enter is common elsewhere and supported on Windows too). | |
1385 | ||
1386 | @see wxDataViewCustomRenderer::CreateEditorCtrl() | |
c4e57202 FM |
1387 | */ |
1388 | wxDATAVIEW_CELL_EDITABLE | |
1389 | }; | |
1390 | ||
1391 | /** | |
1392 | The values of this enum controls how a wxDataViewRenderer should display | |
1393 | its contents in a cell. | |
1394 | */ | |
1395 | enum wxDataViewCellRenderState | |
1396 | { | |
1397 | wxDATAVIEW_CELL_SELECTED = 1, | |
1398 | wxDATAVIEW_CELL_PRELIT = 2, | |
1399 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
1400 | wxDATAVIEW_CELL_FOCUSED = 8 | |
1401 | }; | |
e54c96f1 | 1402 | |
23324ae1 FM |
1403 | /** |
1404 | @class wxDataViewRenderer | |
7c913512 | 1405 | |
5b99d5d8 | 1406 | This class is used by wxDataViewCtrl to render the individual cells. |
c4e57202 FM |
1407 | One instance of a renderer class is owned by a wxDataViewColumn. |
1408 | There is a number of ready-to-use renderers provided: | |
1409 | - wxDataViewTextRenderer, | |
c4e57202 FM |
1410 | - wxDataViewIconTextRenderer, |
1411 | - wxDataViewToggleRenderer, | |
1412 | - wxDataViewProgressRenderer, | |
1413 | - wxDataViewBitmapRenderer, | |
1414 | - wxDataViewDateRenderer, | |
1415 | - wxDataViewSpinRenderer. | |
f4fcd648 | 1416 | - wxDataViewChoiceRenderer. |
7c913512 | 1417 | |
23324ae1 FM |
1418 | Additionally, the user can write own renderers by deriving from |
1419 | wxDataViewCustomRenderer. | |
7c913512 | 1420 | |
c4e57202 FM |
1421 | The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted |
1422 | by the constructors respectively controls what actions the cell data allows | |
1423 | and how the renderer should display its contents in a cell. | |
7c913512 | 1424 | |
23324ae1 | 1425 | @library{wxadv} |
b321b61c | 1426 | @category{dvc} |
23324ae1 FM |
1427 | */ |
1428 | class wxDataViewRenderer : public wxObject | |
1429 | { | |
1430 | public: | |
1431 | /** | |
b91c4601 | 1432 | Constructor. |
23324ae1 FM |
1433 | */ |
1434 | wxDataViewRenderer(const wxString& varianttype, | |
1435 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
f2b7492a | 1436 | int align = wxDVR_DEFAULT_ALIGNMENT ); |
23324ae1 | 1437 | |
c937bcac VZ |
1438 | /** |
1439 | Enable or disable replacing parts of the item text with ellipsis to | |
1440 | make it fit the column width. | |
1441 | ||
1442 | This method only makes sense for the renderers working with text, such | |
1443 | as wxDataViewTextRenderer or wxDataViewIconTextRenderer. | |
1444 | ||
1445 | By default wxELLIPSIZE_MIDDLE is used. | |
1446 | ||
1447 | @param mode | |
1448 | Ellipsization mode, use wxELLIPSIZE_NONE to disable. | |
1449 | ||
1450 | @since 2.9.1 | |
1451 | */ | |
1452 | void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE); | |
1453 | ||
1454 | /** | |
1455 | Disable replacing parts of the item text with ellipsis. | |
1456 | ||
1457 | If ellipsizing is disabled, the string will be truncated if it doesn't | |
1458 | fit. | |
1459 | ||
1460 | This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode. | |
1461 | ||
1462 | @since 2.9.1 | |
1463 | */ | |
1464 | void DisableEllipsize(); | |
1465 | ||
20c36737 | 1466 | /** |
f2b7492a | 1467 | Returns the alignment. See SetAlignment() |
20c36737 RR |
1468 | */ |
1469 | virtual int GetAlignment() const; | |
1470 | ||
c937bcac VZ |
1471 | /** |
1472 | Returns the ellipsize mode used by the renderer. | |
1473 | ||
1474 | If the return value is wxELLIPSIZE_NONE, the text is simply truncated | |
1475 | if it doesn't fit. | |
1476 | ||
1477 | @see EnableEllipsize() | |
1478 | */ | |
1479 | wxEllipsizeMode GetEllipsizeMode() const; | |
1480 | ||
23324ae1 FM |
1481 | /** |
1482 | Returns the cell mode. | |
1483 | */ | |
adaaa686 | 1484 | virtual wxDataViewCellMode GetMode() const; |
23324ae1 FM |
1485 | |
1486 | /** | |
1487 | Returns pointer to the owning wxDataViewColumn. | |
1488 | */ | |
adaaa686 | 1489 | wxDataViewColumn* GetOwner() const; |
23324ae1 FM |
1490 | |
1491 | /** | |
1492 | This methods retrieves the value from the renderer in order to | |
c4e57202 FM |
1493 | transfer the value back to the data model. |
1494 | ||
1495 | Returns @false on failure. | |
23324ae1 | 1496 | */ |
b91c4601 | 1497 | virtual bool GetValue(wxVariant& value) const = 0; |
23324ae1 FM |
1498 | |
1499 | /** | |
c4e57202 | 1500 | Returns a string with the type of the wxVariant supported by this renderer. |
23324ae1 | 1501 | */ |
adaaa686 | 1502 | wxString GetVariantType() const; |
23324ae1 | 1503 | |
20c36737 | 1504 | /** |
c4e57202 FM |
1505 | Sets the alignment of the renderer's content. |
1506 | The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content | |
1507 | should have the same alignment as the column header. | |
1508 | ||
1509 | The method is not implemented under OS X and the renderer always aligns | |
1510 | its contents as the column header on that platform. The other platforms | |
f2b7492a | 1511 | support both vertical and horizontal alignment. |
20c36737 RR |
1512 | */ |
1513 | virtual void SetAlignment( int align ); | |
23324ae1 | 1514 | /** |
c4e57202 FM |
1515 | Sets the owning wxDataViewColumn. |
1516 | This is usually called from within wxDataViewColumn. | |
23324ae1 | 1517 | */ |
adaaa686 | 1518 | void SetOwner(wxDataViewColumn* owner); |
23324ae1 FM |
1519 | |
1520 | /** | |
c4e57202 | 1521 | Set the value of the renderer (and thus its cell) to @a value. |
23324ae1 FM |
1522 | The internal code will then render this cell with this data. |
1523 | */ | |
b91c4601 | 1524 | virtual bool SetValue(const wxVariant& value) = 0; |
23324ae1 FM |
1525 | |
1526 | /** | |
1527 | Before data is committed to the data model, it is passed to this | |
1528 | method where it can be checked for validity. This can also be | |
1529 | used for checking a valid range or limiting the user input in | |
1530 | a certain aspect (e.g. max number of characters or only alphanumeric | |
c4e57202 FM |
1531 | input, ASCII only etc.). Return @false if the value is not valid. |
1532 | ||
23324ae1 FM |
1533 | Please note that due to implementation limitations, this validation |
1534 | is done after the editing control already is destroyed and the | |
1535 | editing process finished. | |
1536 | */ | |
1537 | virtual bool Validate(wxVariant& value); | |
1538 | }; | |
1539 | ||
1540 | ||
e54c96f1 | 1541 | |
23324ae1 FM |
1542 | /** |
1543 | @class wxDataViewTextRenderer | |
7c913512 | 1544 | |
c4e57202 FM |
1545 | wxDataViewTextRenderer is used for rendering text. |
1546 | It supports in-place editing if desired. | |
7c913512 | 1547 | |
23324ae1 | 1548 | @library{wxadv} |
b321b61c | 1549 | @category{dvc} |
23324ae1 FM |
1550 | */ |
1551 | class wxDataViewTextRenderer : public wxDataViewRenderer | |
1552 | { | |
1553 | public: | |
1554 | /** | |
c4e57202 | 1555 | The ctor. |
23324ae1 FM |
1556 | */ |
1557 | wxDataViewTextRenderer(const wxString& varianttype = "string", | |
05303ccd RR |
1558 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1559 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1560 | }; |
1561 | ||
1562 | ||
e54c96f1 | 1563 | |
f2b7492a RR |
1564 | /** |
1565 | @class wxDataViewIconTextRenderer | |
f2b7492a RR |
1566 | |
1567 | The wxDataViewIconTextRenderer class is used to display text with | |
1568 | a small icon next to it as it is typically done in a file manager. | |
c4e57202 FM |
1569 | |
1570 | This classes uses the wxDataViewIconText helper class to store its data. | |
4d68a949 BP |
1571 | wxDataViewIconText can be converted to and from a wxVariant using the left |
1572 | shift operator. | |
f2b7492a RR |
1573 | |
1574 | @library{wxadv} | |
b321b61c | 1575 | @category{dvc} |
f2b7492a RR |
1576 | */ |
1577 | class wxDataViewIconTextRenderer : public wxDataViewRenderer | |
1578 | { | |
1579 | public: | |
1580 | /** | |
c4e57202 | 1581 | The ctor. |
f2b7492a RR |
1582 | */ |
1583 | wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText", | |
1584 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1585 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
1586 | }; | |
1587 | ||
1588 | ||
1589 | ||
23324ae1 FM |
1590 | /** |
1591 | @class wxDataViewProgressRenderer | |
7c913512 | 1592 | |
c4e57202 | 1593 | This class is used by wxDataViewCtrl to render progress bars. |
7c913512 | 1594 | |
23324ae1 | 1595 | @library{wxadv} |
b321b61c | 1596 | @category{dvc} |
23324ae1 FM |
1597 | */ |
1598 | class wxDataViewProgressRenderer : public wxDataViewRenderer | |
1599 | { | |
1600 | public: | |
1601 | /** | |
c4e57202 | 1602 | The ctor. |
23324ae1 FM |
1603 | */ |
1604 | wxDataViewProgressRenderer(const wxString& label = wxEmptyString, | |
1605 | const wxString& varianttype = "long", | |
05303ccd RR |
1606 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1607 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1608 | }; |
1609 | ||
1610 | ||
e54c96f1 | 1611 | |
23324ae1 FM |
1612 | /** |
1613 | @class wxDataViewSpinRenderer | |
7c913512 | 1614 | |
c4e57202 FM |
1615 | This is a specialized renderer for rendering integer values. |
1616 | It supports modifying the values in-place by using a wxSpinCtrl. | |
23324ae1 | 1617 | The renderer only support variants of type @e long. |
7c913512 | 1618 | |
8ed522d9 | 1619 | @library{wxadv} |
b321b61c | 1620 | @category{dvc} |
23324ae1 FM |
1621 | */ |
1622 | class wxDataViewSpinRenderer : public wxDataViewCustomRenderer | |
1623 | { | |
1624 | public: | |
1625 | /** | |
c4e57202 FM |
1626 | Constructor. |
1627 | @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl. | |
23324ae1 FM |
1628 | */ |
1629 | wxDataViewSpinRenderer(int min, int max, | |
1630 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
05303ccd | 1631 | int align = wxDVR_DEFAULT_ALIGNMENT); |
23324ae1 FM |
1632 | }; |
1633 | ||
1634 | ||
e54c96f1 | 1635 | |
23324ae1 FM |
1636 | /** |
1637 | @class wxDataViewToggleRenderer | |
7c913512 | 1638 | |
c4e57202 | 1639 | This class is used by wxDataViewCtrl to render toggle controls. |
7c913512 | 1640 | |
23324ae1 | 1641 | @library{wxadv} |
b321b61c | 1642 | @category{dvc} |
23324ae1 FM |
1643 | */ |
1644 | class wxDataViewToggleRenderer : public wxDataViewRenderer | |
1645 | { | |
1646 | public: | |
1647 | /** | |
c4e57202 | 1648 | The ctor. |
23324ae1 FM |
1649 | */ |
1650 | wxDataViewToggleRenderer(const wxString& varianttype = "bool", | |
50ec54b6 FM |
1651 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1652 | int align = wxDVR_DEFAULT_ALIGNMENT); | |
23324ae1 FM |
1653 | }; |
1654 | ||
1655 | ||
f4fcd648 RR |
1656 | /** |
1657 | @class wxDataViewChoiceRenderer | |
1658 | ||
1659 | This class is used by wxDataViewCtrl to render choice controls. | |
1660 | It stores a string so that SetValue() and GetValue() operate | |
1661 | on a variant holding a string. | |
1662 | ||
1663 | @library{wxadv} | |
1664 | @category{dvc} | |
1665 | */ | |
1666 | ||
1667 | class wxDataViewChoiceRenderer: public wxDataViewRenderer | |
1668 | { | |
1669 | public: | |
1670 | /** | |
1671 | The ctor. | |
1672 | */ | |
1673 | wxDataViewChoiceRenderer( const wxArrayString &choices, | |
1674 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
1675 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
1676 | ||
1677 | /** | |
1678 | Returns the choice referred to by index. | |
1679 | */ | |
1680 | wxString GetChoice(size_t index) const; | |
1681 | ||
1682 | /** | |
1683 | Returns all choices. | |
1684 | */ | |
1685 | const wxArrayString& GetChoices() const; | |
1686 | }; | |
1687 | ||
e54c96f1 | 1688 | |
23324ae1 | 1689 | /** |
5b99d5d8 | 1690 | @class wxDataViewDateRenderer |
7c913512 | 1691 | |
c4e57202 | 1692 | This class is used by wxDataViewCtrl to render calendar controls. |
7c913512 | 1693 | |
5b99d5d8 | 1694 | @library{wxadv} |
b321b61c | 1695 | @category{dvc} |
23324ae1 | 1696 | */ |
5b99d5d8 | 1697 | class wxDataViewDateRenderer : public wxDataViewRenderer |
23324ae1 FM |
1698 | { |
1699 | public: | |
23324ae1 | 1700 | /** |
c4e57202 | 1701 | The ctor. |
23324ae1 | 1702 | */ |
5b99d5d8 | 1703 | wxDataViewDateRenderer(const wxString& varianttype = "datetime", |
50ec54b6 FM |
1704 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
1705 | int align = wxDVR_DEFAULT_ALIGNMENT); | |
5b99d5d8 | 1706 | }; |
23324ae1 | 1707 | |
3c4f71cc | 1708 | |
23324ae1 | 1709 | |
5b99d5d8 RR |
1710 | /** |
1711 | @class wxDataViewCustomRenderer | |
23324ae1 | 1712 | |
5b99d5d8 | 1713 | You need to derive a new class from wxDataViewCustomRenderer in |
c4e57202 FM |
1714 | order to write a new renderer. |
1715 | ||
1716 | You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue, | |
1717 | wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render. | |
1718 | ||
1719 | If you want your renderer to support in-place editing then you also need to override | |
1720 | wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl | |
5b99d5d8 | 1721 | and wxDataViewCustomRenderer::GetValueFromEditorCtrl. |
c4e57202 FM |
1722 | |
1723 | Note that a special event handler will be pushed onto that editor control | |
1724 | which handles @e \<ENTER\> and focus out events in order to end the editing. | |
23324ae1 | 1725 | |
5b99d5d8 | 1726 | @library{wxadv} |
b321b61c | 1727 | @category{dvc} |
5b99d5d8 RR |
1728 | */ |
1729 | class wxDataViewCustomRenderer : public wxDataViewRenderer | |
1730 | { | |
1731 | public: | |
23324ae1 | 1732 | /** |
5b99d5d8 | 1733 | Constructor. |
23324ae1 | 1734 | */ |
5b99d5d8 RR |
1735 | wxDataViewCustomRenderer(const wxString& varianttype = "string", |
1736 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
b91c4601 | 1737 | int align = -1, bool no_init = false); |
23324ae1 FM |
1738 | |
1739 | /** | |
5b99d5d8 | 1740 | Destructor. |
23324ae1 | 1741 | */ |
adaaa686 | 1742 | virtual ~wxDataViewCustomRenderer(); |
23324ae1 | 1743 | |
23324ae1 | 1744 | /** |
dc73d7f5 VS |
1745 | Override this to react to cell @em activation. Activating a cell is an |
1746 | alternative to showing inline editor when the value can be edited in a | |
1747 | simple way that doesn't warrant full editor control. The most typical | |
1748 | use of cell activation is toggling the checkbox in | |
1749 | wxDataViewToggleRenderer; others would be e.g. an embedded volume | |
1750 | slider or a five-star rating column. | |
1751 | ||
1752 | The exact means of activating a cell are platform-dependent, but they | |
1753 | are usually similar to those used for inline editing of values. | |
1754 | Typically, a cell would be activated by Space or Enter keys or by left | |
1755 | mouse click. | |
1756 | ||
1757 | This method will only be called if the cell has the | |
1758 | wxDATAVIEW_CELL_ACTIVATABLE mode. | |
1759 | ||
1760 | @param cell | |
1761 | Coordinates of the activated cell's area. | |
1762 | @param model | |
1763 | The model to manipulate in response. | |
1764 | @param item | |
1765 | Activated item. | |
1766 | @param col | |
1767 | Activated column of @a item. | |
1768 | @param mouseEvent | |
1769 | If the activation was triggered by mouse click, contains the | |
1770 | corresponding event. Is @NULL otherwise (for keyboard activation). | |
1771 | Mouse coordinates are adjusted to be relative to the cell. | |
1772 | ||
1773 | @since 2.9.3 | |
1774 | ||
1775 | @note Do not confuse this method with item activation in wxDataViewCtrl | |
1776 | and the wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. That one is | |
1777 | used for activating the item (or, to put it differently, the | |
1778 | entire row) similarly to analogous messages in wxTreeCtrl and | |
1779 | wxListCtrl, and the effect differs (play a song, open a file | |
1780 | etc.). Cell activation, on the other hand, is all about | |
1781 | interacting with the individual cell. | |
1782 | ||
1783 | @see CreateEditorCtrl() | |
23324ae1 | 1784 | */ |
dc73d7f5 VS |
1785 | virtual bool ActivateCell(const wxRect& cell, |
1786 | wxDataViewModel* model, | |
1787 | const wxDataViewItem & item, | |
1788 | unsigned int col, | |
1789 | const wxMouseEvent *mouseEvent); | |
23324ae1 FM |
1790 | |
1791 | /** | |
5b99d5d8 | 1792 | Override this to create the actual editor control once editing |
c4e57202 FM |
1793 | is about to start. |
1794 | ||
dc73d7f5 VS |
1795 | This method will only be called if the cell has the |
1796 | wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly | |
1797 | double-clicking the cell or by a platform-dependent keyboard shortcut | |
1798 | (F2 is typical on Windows, Space and/or Enter is common elsewhere and | |
1799 | supported on Windows too). | |
1800 | ||
1801 | @param parent | |
1802 | The parent of the editor control. | |
1803 | @param labelRect | |
1804 | Indicates the position and size of the editor control. The control | |
1805 | should be created in place of the cell and @a labelRect should be | |
1806 | respected as much as possible. | |
1807 | @param value | |
1808 | Initial value of the editor. | |
1809 | ||
1810 | An example: | |
c4e57202 FM |
1811 | @code |
1812 | { | |
1813 | long l = value; | |
1814 | return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString, | |
1815 | labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l ); | |
1816 | } | |
1817 | @endcode | |
dc73d7f5 VS |
1818 | |
1819 | @see ActivateCell() | |
23324ae1 | 1820 | */ |
64c70359 VS |
1821 | virtual wxWindow* CreateEditorCtrl(wxWindow* parent, |
1822 | wxRect labelRect, | |
1823 | const wxVariant& value); | |
23324ae1 FM |
1824 | |
1825 | /** | |
62265c2c VZ |
1826 | Return the attribute to be used for rendering. |
1827 | ||
1828 | This function may be called from Render() implementation to use the | |
1829 | attributes defined for the item if the renderer supports them. | |
1830 | ||
1831 | Notice that when Render() is called, the wxDC object passed to it is | |
1832 | already set up to use the correct attributes (e.g. its font is set to | |
1833 | bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic() | |
1834 | returns true) so it may not be necessary to call it explicitly if you | |
1835 | only want to render text using the items attributes. | |
1836 | ||
1837 | @since 2.9.1 | |
1838 | */ | |
1839 | const wxDataViewItemAttr& GetAttr() const; | |
23324ae1 FM |
1840 | |
1841 | /** | |
5b99d5d8 | 1842 | Return size required to show content. |
23324ae1 | 1843 | */ |
b91c4601 | 1844 | virtual wxSize GetSize() const = 0; |
23324ae1 FM |
1845 | |
1846 | /** | |
80093617 | 1847 | Override this so that the renderer can get the value from the editor |
c4e57202 FM |
1848 | control (pointed to by @a editor): |
1849 | @code | |
1850 | { | |
1851 | wxSpinCtrl *sc = (wxSpinCtrl*) editor; | |
1852 | long l = sc->GetValue(); | |
1853 | value = l; | |
1854 | return true; | |
1855 | } | |
1856 | @endcode | |
23324ae1 | 1857 | */ |
64c70359 | 1858 | virtual bool GetValueFromEditorCtrl(wxWindow* editor, |
5b99d5d8 | 1859 | wxVariant& value); |
23324ae1 FM |
1860 | |
1861 | /** | |
c4e57202 | 1862 | Override this and make it return @true in order to |
5b99d5d8 | 1863 | indicate that this renderer supports in-place editing. |
23324ae1 | 1864 | */ |
220bfe15 | 1865 | virtual bool HasEditorCtrl() const; |
23324ae1 FM |
1866 | |
1867 | /** | |
80093617 | 1868 | Override this to react to a left click. |
c4e57202 | 1869 | This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. |
23324ae1 | 1870 | */ |
548fa9c1 VS |
1871 | virtual bool LeftClick( const wxPoint& cursor, |
1872 | const wxRect& cell, | |
5b99d5d8 RR |
1873 | wxDataViewModel * model, |
1874 | const wxDataViewItem & item, | |
1875 | unsigned int col ); | |
23324ae1 FM |
1876 | |
1877 | /** | |
c4e57202 FM |
1878 | Override this to render the cell. |
1879 | Before this is called, wxDataViewRenderer::SetValue was called | |
5b99d5d8 | 1880 | so that this instance knows what to render. |
23324ae1 | 1881 | */ |
b91c4601 | 1882 | virtual bool Render(wxRect cell, wxDC* dc, int state) = 0; |
23324ae1 FM |
1883 | |
1884 | /** | |
c4e57202 FM |
1885 | This method should be called from within Render() whenever you need to |
1886 | render simple text. | |
1887 | This will ensure that the correct colour, font and vertical alignment will | |
1888 | be chosen so the text will look the same as text drawn by native renderers. | |
23324ae1 | 1889 | */ |
50ec54b6 | 1890 | void RenderText(const wxString& text, int xoffset, wxRect cell, |
5b99d5d8 | 1891 | wxDC* dc, int state); |
23324ae1 FM |
1892 | |
1893 | /** | |
80093617 | 1894 | Override this to start a drag operation. Not yet supported. |
23324ae1 | 1895 | */ |
548fa9c1 VS |
1896 | virtual bool StartDrag(const wxPoint& cursor, |
1897 | const wxRect& cell, | |
5b99d5d8 RR |
1898 | wxDataViewModel* model, |
1899 | const wxDataViewItem & item, | |
1900 | unsigned int col); | |
23324ae1 FM |
1901 | }; |
1902 | ||
1903 | ||
e54c96f1 | 1904 | |
23324ae1 | 1905 | /** |
5b99d5d8 | 1906 | @class wxDataViewBitmapRenderer |
7c913512 | 1907 | |
c4e57202 | 1908 | This class is used by wxDataViewCtrl to render bitmap controls. |
7c913512 | 1909 | |
23324ae1 | 1910 | @library{wxadv} |
b321b61c | 1911 | @category{dvc} |
23324ae1 | 1912 | */ |
5b99d5d8 | 1913 | class wxDataViewBitmapRenderer : public wxDataViewRenderer |
23324ae1 FM |
1914 | { |
1915 | public: | |
1916 | /** | |
c4e57202 | 1917 | The ctor. |
23324ae1 | 1918 | */ |
5b99d5d8 RR |
1919 | wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap", |
1920 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
14d922d1 | 1921 | int align = wxDVR_DEFAULT_ALIGNMENT); |
5b99d5d8 RR |
1922 | }; |
1923 | ||
23324ae1 | 1924 | |
c4e57202 FM |
1925 | /** |
1926 | The flags used by wxDataViewColumn. | |
02b51ae5 | 1927 | Can be combined together. |
c4e57202 FM |
1928 | */ |
1929 | enum wxDataViewColumnFlags | |
1930 | { | |
1931 | wxDATAVIEW_COL_RESIZABLE = 1, | |
1932 | wxDATAVIEW_COL_SORTABLE = 2, | |
1933 | wxDATAVIEW_COL_REORDERABLE = 4, | |
1934 | wxDATAVIEW_COL_HIDDEN = 8 | |
1935 | }; | |
23324ae1 | 1936 | |
5b99d5d8 RR |
1937 | /** |
1938 | @class wxDataViewColumn | |
5b99d5d8 RR |
1939 | |
1940 | This class represents a column in a wxDataViewCtrl. | |
739a8399 | 1941 | One wxDataViewColumn is bound to one column in the data model to which the |
c4e57202 | 1942 | wxDataViewCtrl has been associated. |
5b99d5d8 | 1943 | |
c4e57202 | 1944 | An instance of wxDataViewRenderer is used by this class to render its data. |
5b99d5d8 RR |
1945 | |
1946 | @library{wxadv} | |
b321b61c | 1947 | @category{dvc} |
5b99d5d8 | 1948 | */ |
c9c59db7 | 1949 | class wxDataViewColumn : public wxSettableHeaderColumn |
5b99d5d8 RR |
1950 | { |
1951 | public: | |
23324ae1 | 1952 | /** |
02b51ae5 FM |
1953 | Constructs a text column. |
1954 | ||
1955 | @param title | |
1956 | The title of the column. | |
1957 | @param renderer | |
1958 | The class which will render the contents of this column. | |
1959 | @param model_column | |
1960 | The index of the model's column which is associated with this object. | |
1961 | @param width | |
1962 | The width of the column. | |
1963 | The @c wxDVC_DEFAULT_WIDTH value is the fixed default value. | |
1964 | @param align | |
1965 | The alignment of the column title. | |
1966 | @param flags | |
1967 | One or more flags of the ::wxDataViewColumnFlags enumeration. | |
23324ae1 | 1968 | */ |
5b99d5d8 RR |
1969 | wxDataViewColumn(const wxString& title, |
1970 | wxDataViewRenderer* renderer, | |
1971 | unsigned int model_column, | |
1972 | int width = wxDVC_DEFAULT_WIDTH, | |
882678eb | 1973 | wxAlignment align = wxALIGN_CENTER, |
5b99d5d8 | 1974 | int flags = wxDATAVIEW_COL_RESIZABLE); |
02b51ae5 FM |
1975 | |
1976 | /** | |
1977 | Constructs a bitmap column. | |
1978 | ||
1979 | @param bitmap | |
1980 | The bitmap of the column. | |
1981 | @param renderer | |
1982 | The class which will render the contents of this column. | |
1983 | @param model_column | |
1984 | The index of the model's column which is associated with this object. | |
1985 | @param width | |
1986 | The width of the column. | |
1987 | The @c wxDVC_DEFAULT_WIDTH value is the fixed default value. | |
1988 | @param align | |
1989 | The alignment of the column title. | |
1990 | @param flags | |
1991 | One or more flags of the ::wxDataViewColumnFlags enumeration. | |
1992 | */ | |
5b99d5d8 RR |
1993 | wxDataViewColumn(const wxBitmap& bitmap, |
1994 | wxDataViewRenderer* renderer, | |
1995 | unsigned int model_column, | |
1996 | int width = wxDVC_DEFAULT_WIDTH, | |
882678eb | 1997 | wxAlignment align = wxALIGN_CENTER, |
5b99d5d8 | 1998 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 | 1999 | |
23324ae1 | 2000 | /** |
5b99d5d8 RR |
2001 | Returns the index of the column of the model, which this |
2002 | wxDataViewColumn is displaying. | |
23324ae1 | 2003 | */ |
adaaa686 | 2004 | unsigned int GetModelColumn() const; |
23324ae1 FM |
2005 | |
2006 | /** | |
5b99d5d8 | 2007 | Returns the owning wxDataViewCtrl. |
23324ae1 | 2008 | */ |
e51bf699 | 2009 | wxDataViewCtrl* GetOwner() const; |
23324ae1 FM |
2010 | |
2011 | /** | |
5b99d5d8 | 2012 | Returns the renderer of this wxDataViewColumn. |
c4e57202 FM |
2013 | |
2014 | @see wxDataViewRenderer. | |
23324ae1 | 2015 | */ |
adaaa686 | 2016 | wxDataViewRenderer* GetRenderer() const; |
23324ae1 FM |
2017 | }; |
2018 | ||
2019 | ||
e54c96f1 | 2020 | |
832df171 RR |
2021 | /** |
2022 | @class wxDataViewListCtrl | |
2023 | ||
2024 | This class is a wxDataViewCtrl which internally uses a wxDataViewListStore | |
2025 | and forwards most of its API to that class. | |
2026 | ||
2027 | The purpose of this class is to offer a simple way to display and | |
2028 | edit a small table of data without having to write your own wxDataViewModel. | |
2029 | ||
23efa4bf | 2030 | @code |
14f73cf1 | 2031 | wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY ); |
02b51ae5 | 2032 | |
95b20f41 RR |
2033 | listctrl->AppendToggleColumn( "Toggle" ); |
2034 | listctrl->AppendTextColumn( "Text" ); | |
02b51ae5 | 2035 | |
23efa4bf | 2036 | wxVector<wxVariant> data; |
14f73cf1 FM |
2037 | data.push_back( wxVariant(true) ); |
2038 | data.push_back( wxVariant("row 1") ); | |
23efa4bf | 2039 | listctrl->AppendItem( data ); |
02b51ae5 | 2040 | |
23efa4bf | 2041 | data.clear(); |
14f73cf1 FM |
2042 | data.push_back( wxVariant(false) ); |
2043 | data.push_back( wxVariant("row 3") ); | |
23efa4bf RR |
2044 | listctrl->AppendItem( data ); |
2045 | @endcode | |
43c64cc6 | 2046 | |
14f73cf1 FM |
2047 | @beginStyleTable |
2048 | See wxDataViewCtrl for the list of supported styles. | |
2049 | @endStyleTable | |
43c64cc6 | 2050 | |
14f73cf1 FM |
2051 | @beginEventEmissionTable |
2052 | See wxDataViewCtrl for the list of events emitted by this class. | |
2053 | @endEventTable | |
23efa4bf | 2054 | |
832df171 RR |
2055 | @library{wxadv} |
2056 | @category{ctrl,dvc} | |
2057 | */ | |
832df171 RR |
2058 | class wxDataViewListCtrl: public wxDataViewCtrl |
2059 | { | |
b75b04d4 | 2060 | public: |
832df171 RR |
2061 | /** |
2062 | Default ctor. | |
2063 | */ | |
2064 | wxDataViewListCtrl(); | |
02b51ae5 | 2065 | |
832df171 RR |
2066 | /** |
2067 | Constructor. Calls Create(). | |
2068 | */ | |
2069 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
2070 | const wxPoint& pos = wxDefaultPosition, | |
2071 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
2072 | const wxValidator& validator = wxDefaultValidator ); | |
02b51ae5 | 2073 | |
832df171 RR |
2074 | /** |
2075 | Destructor. Deletes the image list if any. | |
2076 | */ | |
2077 | ~wxDataViewListCtrl(); | |
2078 | ||
2079 | /** | |
2080 | Creates the control and a wxDataViewListStore as its internal model. | |
2081 | */ | |
2082 | bool Create( wxWindow *parent, wxWindowID id, | |
2083 | const wxPoint& pos = wxDefaultPosition, | |
2084 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
2085 | const wxValidator& validator = wxDefaultValidator ); | |
2086 | ||
2087 | //@{ | |
2088 | /** | |
2089 | Returns the store. | |
2090 | */ | |
2091 | wxDataViewListStore *GetStore(); | |
2092 | const wxDataViewListStore *GetStore() const; | |
2093 | //@} | |
2094 | ||
17de95e4 VS |
2095 | /** |
2096 | Returns the position of given @e item or wxNOT_FOUND if it's | |
2097 | not a valid item. | |
2098 | ||
2099 | @since 2.9.2 | |
2100 | */ | |
2101 | int ItemToRow(const wxDataViewItem &item) const; | |
2102 | ||
2103 | /** | |
2104 | Returns the wxDataViewItem at the given @e row. | |
2105 | ||
2106 | @since 2.9.2 | |
2107 | */ | |
2108 | wxDataViewItem RowToItem(int row) const; | |
2109 | ||
fa629ada VS |
2110 | //@{ |
2111 | /** | |
2112 | @name Selection handling functions | |
2113 | */ | |
2114 | ||
2115 | /** | |
2116 | Returns index of the selected row or wxNOT_FOUND. | |
2117 | ||
2118 | @see wxDataViewCtrl::GetSelection() | |
2119 | ||
2120 | @since 2.9.2 | |
2121 | */ | |
2122 | int GetSelectedRow() const; | |
2123 | ||
2124 | /** | |
2125 | Selects given row. | |
2126 | ||
2127 | @see wxDataViewCtrl::Select() | |
2128 | ||
2129 | @since 2.9.2 | |
2130 | */ | |
2131 | void SelectRow(unsigned row); | |
2132 | ||
2133 | /** | |
2134 | Unselects given row. | |
2135 | ||
2136 | @see wxDataViewCtrl::Unselect() | |
2137 | ||
2138 | @since 2.9.2 | |
2139 | */ | |
2140 | void UnselectRow(unsigned row); | |
2141 | ||
2142 | /** | |
2143 | Returns true if @a row is selected. | |
2144 | ||
2145 | @see wxDataViewCtrl::IsSelected() | |
2146 | ||
2147 | @since 2.9.2 | |
2148 | */ | |
2149 | bool IsRowSelected(unsigned row) const; | |
2150 | ||
2151 | //@} | |
2152 | ||
832df171 | 2153 | /** |
14f73cf1 FM |
2154 | @name Column management functions |
2155 | */ | |
2156 | //@{ | |
43c64cc6 | 2157 | |
14f73cf1 FM |
2158 | /** |
2159 | Appends a column to the control and additionally appends a | |
2160 | column to the store with the type string. | |
2161 | */ | |
2162 | virtual void AppendColumn( wxDataViewColumn *column ); | |
2163 | ||
2164 | /** | |
2165 | Appends a column to the control and additionally appends a | |
2166 | column to the list store with the type @a varianttype. | |
832df171 | 2167 | */ |
95b20f41 | 2168 | void AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
02b51ae5 | 2169 | |
832df171 | 2170 | /** |
14f73cf1 | 2171 | Appends a text column to the control and the store. |
43c64cc6 | 2172 | |
14f73cf1 FM |
2173 | See wxDataViewColumn::wxDataViewColumn for more info about |
2174 | the parameters. | |
832df171 | 2175 | */ |
14f73cf1 FM |
2176 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
2177 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 2178 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 2179 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 2180 | |
832df171 | 2181 | /** |
14f73cf1 | 2182 | Appends a toggle column to the control and the store. |
43c64cc6 | 2183 | |
14f73cf1 FM |
2184 | See wxDataViewColumn::wxDataViewColumn for more info about |
2185 | the parameters. | |
832df171 | 2186 | */ |
14f73cf1 FM |
2187 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
2188 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
43c64cc6 | 2189 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 2190 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 2191 | |
95b20f41 | 2192 | /** |
14f73cf1 | 2193 | Appends a progress column to the control and the store. |
02b51ae5 | 2194 | |
14f73cf1 FM |
2195 | See wxDataViewColumn::wxDataViewColumn for more info about |
2196 | the parameters. | |
95b20f41 | 2197 | */ |
14f73cf1 FM |
2198 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
2199 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 2200 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 2201 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 2202 | |
95b20f41 | 2203 | /** |
14f73cf1 | 2204 | Appends an icon-and-text column to the control and the store. |
02b51ae5 | 2205 | |
14f73cf1 FM |
2206 | See wxDataViewColumn::wxDataViewColumn for more info about |
2207 | the parameters. | |
95b20f41 | 2208 | */ |
14f73cf1 FM |
2209 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
2210 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 2211 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 2212 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 2213 | |
95b20f41 | 2214 | /** |
14f73cf1 | 2215 | Inserts a column to the control and additionally inserts a |
95b20f41 RR |
2216 | column to the store with the type string. |
2217 | */ | |
2218 | virtual void InsertColumn( unsigned int pos, wxDataViewColumn *column ); | |
02b51ae5 | 2219 | |
832df171 | 2220 | /** |
14f73cf1 FM |
2221 | Inserts a column to the control and additionally inserts a |
2222 | column to the list store with the type @a varianttype. | |
832df171 | 2223 | */ |
43c64cc6 | 2224 | void InsertColumn( unsigned int pos, wxDataViewColumn *column, |
14f73cf1 | 2225 | const wxString &varianttype ); |
02b51ae5 | 2226 | |
832df171 | 2227 | /** |
14f73cf1 FM |
2228 | Prepends a column to the control and additionally prepends a |
2229 | column to the store with the type string. | |
832df171 | 2230 | */ |
14f73cf1 | 2231 | virtual void PrependColumn( wxDataViewColumn *column ); |
02b51ae5 | 2232 | |
832df171 | 2233 | /** |
14f73cf1 FM |
2234 | Prepends a column to the control and additionally prepends a |
2235 | column to the list store with the type @a varianttype. | |
832df171 | 2236 | */ |
14f73cf1 | 2237 | void PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); |
02b51ae5 | 2238 | |
14f73cf1 | 2239 | //@} |
43c64cc6 VZ |
2240 | |
2241 | ||
832df171 | 2242 | /** |
14f73cf1 | 2243 | @name Item management functions |
832df171 | 2244 | */ |
14f73cf1 | 2245 | //@{ |
43c64cc6 | 2246 | |
832df171 RR |
2247 | /** |
2248 | Appends an item (=row) to the control and store. | |
2249 | */ | |
2250 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
2251 | ||
2252 | /** | |
2253 | Prepends an item (=row) to the control and store. | |
2254 | */ | |
2255 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
2256 | ||
2257 | /** | |
2258 | Inserts an item (=row) to the control and store. | |
2259 | */ | |
14f73cf1 | 2260 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); |
02b51ae5 | 2261 | |
832df171 RR |
2262 | /** |
2263 | Delete the row at position @a row. | |
2264 | */ | |
2265 | void DeleteItem( unsigned row ); | |
02b51ae5 | 2266 | |
832df171 RR |
2267 | /** |
2268 | Delete all items (= all rows). | |
2269 | */ | |
2270 | void DeleteAllItems(); | |
02b51ae5 | 2271 | |
832df171 RR |
2272 | /** |
2273 | Sets the value in the store and update the control. | |
2274 | */ | |
2275 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 2276 | |
832df171 RR |
2277 | /** |
2278 | Returns the value from the store. | |
2279 | */ | |
2280 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 2281 | |
832df171 | 2282 | /** |
02b51ae5 FM |
2283 | Sets the value in the store and update the control. |
2284 | ||
57ab6f23 | 2285 | This method assumes that the string is stored in respective |
832df171 RR |
2286 | column. |
2287 | */ | |
2288 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 2289 | |
832df171 RR |
2290 | /** |
2291 | Returns the value from the store. | |
02b51ae5 | 2292 | |
57ab6f23 | 2293 | This method assumes that the string is stored in respective |
832df171 RR |
2294 | column. |
2295 | */ | |
2296 | wxString GetTextValue( unsigned int row, unsigned int col ) const; | |
02b51ae5 | 2297 | |
832df171 | 2298 | /** |
02b51ae5 FM |
2299 | Sets the value in the store and update the control. |
2300 | ||
57ab6f23 | 2301 | This method assumes that the boolean value is stored in |
832df171 RR |
2302 | respective column. |
2303 | */ | |
2304 | void SetToggleValue( bool value, unsigned int row, unsigned int col ); | |
02b51ae5 | 2305 | |
832df171 RR |
2306 | /** |
2307 | Returns the value from the store. | |
02b51ae5 | 2308 | |
57ab6f23 | 2309 | This method assumes that the boolean value is stored in |
832df171 RR |
2310 | respective column. |
2311 | */ | |
2312 | bool GetToggleValue( unsigned int row, unsigned int col ) const; | |
43c64cc6 | 2313 | |
14f73cf1 | 2314 | //@} |
832df171 RR |
2315 | }; |
2316 | ||
2317 | ||
23324ae1 | 2318 | /** |
5b99d5d8 | 2319 | @class wxDataViewTreeCtrl |
7c913512 | 2320 | |
c4e57202 FM |
2321 | This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore |
2322 | and forwards most of its API to that class. | |
2323 | Additionally, it uses a wxImageList to store a list of icons. | |
2324 | ||
43c64cc6 VZ |
2325 | The main purpose of this class is to provide a simple upgrade path for code |
2326 | using wxTreeCtrl. | |
14f73cf1 FM |
2327 | |
2328 | @beginStyleTable | |
2329 | See wxDataViewCtrl for the list of supported styles. | |
2330 | @endStyleTable | |
43c64cc6 | 2331 | |
14f73cf1 FM |
2332 | @beginEventEmissionTable |
2333 | See wxDataViewCtrl for the list of events emitted by this class. | |
2334 | @endEventTable | |
7c913512 | 2335 | |
8ed522d9 | 2336 | @library{wxadv} |
b321b61c | 2337 | @category{ctrl,dvc} |
7e59b885 | 2338 | @appearance{dataviewtreectrl.png} |
23324ae1 | 2339 | */ |
5b99d5d8 | 2340 | class wxDataViewTreeCtrl : public wxDataViewCtrl |
23324ae1 FM |
2341 | { |
2342 | public: | |
2343 | /** | |
c4e57202 | 2344 | Default ctor. |
5b99d5d8 RR |
2345 | */ |
2346 | wxDataViewTreeCtrl(); | |
c4e57202 FM |
2347 | |
2348 | /** | |
43c64cc6 VZ |
2349 | Constructor. |
2350 | ||
2351 | Calls Create(). | |
c4e57202 | 2352 | */ |
5b99d5d8 RR |
2353 | wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id, |
2354 | const wxPoint& pos = wxDefaultPosition, | |
2355 | const wxSize& size = wxDefaultSize, | |
43c64cc6 | 2356 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
5b99d5d8 | 2357 | const wxValidator& validator = wxDefaultValidator); |
3c4f71cc | 2358 | |
5b99d5d8 RR |
2359 | /** |
2360 | Destructor. Deletes the image list if any. | |
23324ae1 | 2361 | */ |
adaaa686 | 2362 | virtual ~wxDataViewTreeCtrl(); |
23324ae1 | 2363 | |
5b99d5d8 | 2364 | /** |
b75b04d4 | 2365 | Appends a container to the given @a parent. |
5b99d5d8 RR |
2366 | */ |
2367 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
2368 | const wxString& text, | |
2369 | int icon = -1, | |
2370 | int expanded = -1, | |
2371 | wxClientData* data = NULL); | |
e54c96f1 | 2372 | |
5b99d5d8 | 2373 | /** |
b75b04d4 | 2374 | Appends an item to the given @a parent. |
5b99d5d8 RR |
2375 | */ |
2376 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
2377 | const wxString& text, | |
2378 | int icon = -1, | |
2379 | wxClientData* data = NULL); | |
7c913512 | 2380 | |
5b99d5d8 | 2381 | /** |
c4e57202 | 2382 | Creates the control and a wxDataViewTreeStore as its internal model. |
43c64cc6 VZ |
2383 | |
2384 | The default tree column created by this method is an editable column | |
2385 | using wxDataViewIconTextRenderer as its renderer. | |
5b99d5d8 RR |
2386 | */ |
2387 | bool Create(wxWindow* parent, wxWindowID id, | |
2388 | const wxPoint& pos = wxDefaultPosition, | |
2389 | const wxSize& size = wxDefaultSize, | |
43c64cc6 | 2390 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
5b99d5d8 RR |
2391 | const wxValidator& validator = wxDefaultValidator); |
2392 | ||
2393 | /** | |
2394 | Calls the identical method from wxDataViewTreeStore. | |
2395 | */ | |
2396 | void DeleteAllItems(); | |
7c913512 | 2397 | |
23324ae1 | 2398 | /** |
5b99d5d8 RR |
2399 | Calls the identical method from wxDataViewTreeStore. |
2400 | */ | |
2401 | void DeleteChildren(const wxDataViewItem& item); | |
3c4f71cc | 2402 | |
5b99d5d8 RR |
2403 | /** |
2404 | Calls the identical method from wxDataViewTreeStore. | |
23324ae1 | 2405 | */ |
5b99d5d8 | 2406 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 | 2407 | |
5b99d5d8 RR |
2408 | /** |
2409 | Calls the identical method from wxDataViewTreeStore. | |
2410 | */ | |
2411 | int GetChildCount(const wxDataViewItem& parent) const; | |
23324ae1 | 2412 | |
5b99d5d8 RR |
2413 | /** |
2414 | Returns the image list. | |
2415 | */ | |
2416 | wxImageList* GetImageList(); | |
05303ccd | 2417 | |
5b99d5d8 RR |
2418 | /** |
2419 | Calls the identical method from wxDataViewTreeStore. | |
2420 | */ | |
2421 | wxClientData* GetItemData(const wxDataViewItem& item) const; | |
05303ccd | 2422 | |
5b99d5d8 RR |
2423 | /** |
2424 | Calls the identical method from wxDataViewTreeStore. | |
2425 | */ | |
b91c4601 | 2426 | const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const; |
05303ccd | 2427 | |
05303ccd | 2428 | /** |
5b99d5d8 | 2429 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2430 | */ |
b91c4601 | 2431 | const wxIcon& GetItemIcon(const wxDataViewItem& item) const; |
05303ccd RR |
2432 | |
2433 | /** | |
5b99d5d8 | 2434 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2435 | */ |
5b99d5d8 RR |
2436 | wxString GetItemText(const wxDataViewItem& item) const; |
2437 | ||
2438 | /** | |
2439 | Calls the identical method from wxDataViewTreeStore. | |
2440 | */ | |
2441 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, | |
2442 | unsigned int pos) const; | |
05303ccd | 2443 | |
5b99d5d8 | 2444 | //@{ |
05303ccd | 2445 | /** |
5b99d5d8 | 2446 | Returns the store. |
05303ccd | 2447 | */ |
882678eb | 2448 | wxDataViewTreeStore* GetStore(); |
5b99d5d8 RR |
2449 | const wxDataViewTreeStore* GetStore() const; |
2450 | //@} | |
05303ccd RR |
2451 | |
2452 | /** | |
c4e57202 FM |
2453 | Calls the same method from wxDataViewTreeStore but uses |
2454 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2455 | */ |
5b99d5d8 RR |
2456 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
2457 | const wxDataViewItem& previous, | |
2458 | const wxString& text, | |
2459 | int icon = -1, | |
2460 | int expanded = -1, | |
2461 | wxClientData* data = NULL); | |
05303ccd RR |
2462 | |
2463 | /** | |
c4e57202 FM |
2464 | Calls the same method from wxDataViewTreeStore but uses |
2465 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2466 | */ |
5b99d5d8 RR |
2467 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
2468 | const wxDataViewItem& previous, | |
2469 | const wxString& text, | |
2470 | int icon = -1, | |
2471 | wxClientData* data = NULL); | |
05303ccd | 2472 | |
8ddda15b RR |
2473 | /** |
2474 | Returns true if item is a container. | |
2475 | */ | |
2476 | bool IsContainer( const wxDataViewItem& item ); | |
2477 | ||
05303ccd | 2478 | /** |
c4e57202 FM |
2479 | Calls the same method from wxDataViewTreeStore but uses |
2480 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2481 | */ |
5b99d5d8 RR |
2482 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
2483 | const wxString& text, | |
2484 | int icon = -1, | |
2485 | int expanded = -1, | |
2486 | wxClientData* data = NULL); | |
05303ccd RR |
2487 | |
2488 | /** | |
c4e57202 FM |
2489 | Calls the same method from wxDataViewTreeStore but uses |
2490 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2491 | */ |
5b99d5d8 RR |
2492 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
2493 | const wxString& text, | |
2494 | int icon = -1, | |
2495 | wxClientData* data = NULL); | |
05303ccd RR |
2496 | |
2497 | /** | |
5b99d5d8 | 2498 | Sets the image list. |
05303ccd | 2499 | */ |
5b99d5d8 | 2500 | void SetImageList(wxImageList* imagelist); |
05303ccd RR |
2501 | |
2502 | /** | |
5b99d5d8 | 2503 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2504 | */ |
5b99d5d8 | 2505 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
05303ccd RR |
2506 | |
2507 | /** | |
5b99d5d8 | 2508 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2509 | */ |
5b99d5d8 RR |
2510 | void SetItemExpandedIcon(const wxDataViewItem& item, |
2511 | const wxIcon& icon); | |
05303ccd RR |
2512 | |
2513 | /** | |
5b99d5d8 | 2514 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2515 | */ |
5b99d5d8 | 2516 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
05303ccd RR |
2517 | |
2518 | /** | |
5b99d5d8 | 2519 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2520 | */ |
5b99d5d8 RR |
2521 | void SetItemText(const wxDataViewItem& item, |
2522 | const wxString& text); | |
05303ccd RR |
2523 | }; |
2524 | ||
2525 | ||
bda698ed RR |
2526 | /** |
2527 | @class wxDataViewListStore | |
2528 | ||
2529 | wxDataViewListStore is a specialised wxDataViewModel for storing | |
2530 | a simple table of data. Since it derives from wxDataViewIndexListModel | |
2531 | its data is be accessed by row (i.e. by index) instead of only | |
2532 | by wxDataViewItem. | |
2533 | ||
02b51ae5 | 2534 | This class actually stores the values (therefore its name) |
bda698ed | 2535 | and implements all virtual methods from the base classes so it can be |
02b51ae5 | 2536 | used directly without having to derive any class from it, but it is |
bda698ed RR |
2537 | mostly used from within wxDataViewListCtrl. |
2538 | ||
2539 | @library{wxadv} | |
2540 | @category{dvc} | |
2541 | */ | |
2542 | ||
2543 | class wxDataViewListStore: public wxDataViewIndexListModel | |
2544 | { | |
2545 | public: | |
2546 | /** | |
02b51ae5 | 2547 | Constructor |
bda698ed RR |
2548 | */ |
2549 | wxDataViewListStore(); | |
02b51ae5 | 2550 | |
bda698ed | 2551 | /** |
02b51ae5 | 2552 | Destructor |
bda698ed RR |
2553 | */ |
2554 | ~wxDataViewListStore(); | |
2555 | ||
2556 | /** | |
02b51ae5 FM |
2557 | Prepends a data column. |
2558 | ||
2559 | @a variantype indicates the type of values store in the column. | |
2560 | ||
2561 | This does not automatically fill in any (default) values in | |
2562 | rows which exist in the store already. | |
bda698ed RR |
2563 | */ |
2564 | void PrependColumn( const wxString &varianttype ); | |
2565 | ||
2566 | /** | |
02b51ae5 FM |
2567 | Inserts a data column before @a pos. |
2568 | ||
2569 | @a variantype indicates the type of values store in the column. | |
2570 | ||
2571 | This does not automatically fill in any (default) values in | |
2572 | rows which exist in the store already. | |
bda698ed RR |
2573 | */ |
2574 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
2575 | ||
2576 | /** | |
02b51ae5 FM |
2577 | Appends a data column. |
2578 | ||
2579 | @a variantype indicates the type of values store in the column. | |
2580 | ||
2581 | This does not automatically fill in any (default) values in | |
2582 | rows which exist in the store already. | |
bda698ed RR |
2583 | */ |
2584 | void AppendColumn( const wxString &varianttype ); | |
02b51ae5 | 2585 | |
bda698ed RR |
2586 | /** |
2587 | Appends an item (=row) and fills it with @a values. | |
02b51ae5 | 2588 | |
bda698ed RR |
2589 | The values must match the values specifies in the column |
2590 | in number and type. No (default) values are filled in | |
2591 | automatically. | |
2592 | */ | |
2593 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2594 | |
bda698ed RR |
2595 | /** |
2596 | Prepends an item (=row) and fills it with @a values. | |
02b51ae5 | 2597 | |
bda698ed RR |
2598 | The values must match the values specifies in the column |
2599 | in number and type. No (default) values are filled in | |
2600 | automatically. | |
2601 | */ | |
2602 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2603 | |
bda698ed RR |
2604 | /** |
2605 | Inserts an item (=row) and fills it with @a values. | |
02b51ae5 | 2606 | |
bda698ed RR |
2607 | The values must match the values specifies in the column |
2608 | in number and type. No (default) values are filled in | |
2609 | automatically. | |
2610 | */ | |
2611 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2612 | |
bda698ed RR |
2613 | /** |
2614 | Delete the item (=row) at position @a pos. | |
2615 | */ | |
2616 | void DeleteItem( unsigned pos ); | |
02b51ae5 | 2617 | |
bda698ed RR |
2618 | /** |
2619 | Delete all item (=all rows) in the store. | |
2620 | */ | |
2621 | void DeleteAllItems(); | |
2622 | ||
2623 | /** | |
57ab6f23 | 2624 | Overridden from wxDataViewModel |
bda698ed RR |
2625 | */ |
2626 | virtual unsigned int GetColumnCount() const; | |
2627 | ||
2628 | /** | |
57ab6f23 | 2629 | Overridden from wxDataViewModel |
bda698ed RR |
2630 | */ |
2631 | virtual wxString GetColumnType( unsigned int col ) const; | |
2632 | ||
2633 | /** | |
57ab6f23 | 2634 | Overridden from wxDataViewIndexListModel |
bda698ed RR |
2635 | */ |
2636 | virtual void GetValueByRow( wxVariant &value, | |
2637 | unsigned int row, unsigned int col ) const; | |
2638 | ||
2639 | /** | |
57ab6f23 | 2640 | Overridden from wxDataViewIndexListModel |
bda698ed RR |
2641 | */ |
2642 | virtual bool SetValueByRow( const wxVariant &value, | |
2643 | unsigned int row, unsigned int col ); | |
2644 | }; | |
2645 | ||
05303ccd RR |
2646 | |
2647 | /** | |
5b99d5d8 | 2648 | @class wxDataViewTreeStore |
05303ccd | 2649 | |
57ab6f23 | 2650 | wxDataViewTreeStore is a specialised wxDataViewModel for storing simple |
c4e57202 FM |
2651 | trees very much like wxTreeCtrl does and it offers a similar API. |
2652 | ||
02b51ae5 | 2653 | This class actually stores the entire tree and the values (therefore its name) |
8eff6c56 | 2654 | and implements all virtual methods from the base class so it can be used directly |
bda698ed RR |
2655 | without having to derive any class from it, but it is mostly used from within |
2656 | wxDataViewTreeCtrl. | |
05303ccd RR |
2657 | |
2658 | @library{wxadv} | |
b321b61c | 2659 | @category{dvc} |
05303ccd | 2660 | */ |
5b99d5d8 | 2661 | class wxDataViewTreeStore : public wxDataViewModel |
05303ccd RR |
2662 | { |
2663 | public: | |
2664 | /** | |
5b99d5d8 | 2665 | Constructor. Creates the invisible root node internally. |
05303ccd | 2666 | */ |
5b99d5d8 | 2667 | wxDataViewTreeStore(); |
e54c96f1 | 2668 | |
5b99d5d8 RR |
2669 | /** |
2670 | Destructor. | |
2671 | */ | |
adaaa686 | 2672 | virtual ~wxDataViewTreeStore(); |
7c913512 | 2673 | |
5b99d5d8 RR |
2674 | /** |
2675 | Append a container. | |
2676 | */ | |
2677 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
2678 | const wxString& text, | |
2679 | const wxIcon& icon = wxNullIcon, | |
2680 | const wxIcon& expanded = wxNullIcon, | |
2681 | wxClientData* data = NULL); | |
7c913512 | 2682 | |
5b99d5d8 RR |
2683 | /** |
2684 | Append an item. | |
2685 | */ | |
2686 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
2687 | const wxString& text, | |
2688 | const wxIcon& icon = wxNullIcon, | |
2689 | wxClientData* data = NULL); | |
7c913512 | 2690 | |
23324ae1 | 2691 | /** |
5b99d5d8 | 2692 | Delete all item in the model. |
23324ae1 | 2693 | */ |
5b99d5d8 | 2694 | void DeleteAllItems(); |
23324ae1 FM |
2695 | |
2696 | /** | |
5b99d5d8 | 2697 | Delete all children of the item, but not the item itself. |
23324ae1 | 2698 | */ |
5b99d5d8 | 2699 | void DeleteChildren(const wxDataViewItem& item); |
23324ae1 FM |
2700 | |
2701 | /** | |
5b99d5d8 | 2702 | Delete this item. |
23324ae1 | 2703 | */ |
5b99d5d8 | 2704 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 FM |
2705 | |
2706 | /** | |
5b99d5d8 | 2707 | Return the number of children of item. |
23324ae1 | 2708 | */ |
5b99d5d8 | 2709 | int GetChildCount(const wxDataViewItem& parent) const; |
23324ae1 FM |
2710 | |
2711 | /** | |
57ab6f23 | 2712 | Returns the client data associated with the item. |
23324ae1 | 2713 | */ |
5b99d5d8 | 2714 | wxClientData* GetItemData(const wxDataViewItem& item) const; |
23324ae1 FM |
2715 | |
2716 | /** | |
5b99d5d8 | 2717 | Returns the icon to display in expanded containers. |
23324ae1 | 2718 | */ |
b91c4601 | 2719 | const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
2720 | |
2721 | /** | |
5b99d5d8 | 2722 | Returns the icon of the item. |
23324ae1 | 2723 | */ |
b91c4601 | 2724 | const wxIcon& GetItemIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
2725 | |
2726 | /** | |
5b99d5d8 | 2727 | Returns the text of the item. |
23324ae1 | 2728 | */ |
5b99d5d8 | 2729 | wxString GetItemText(const wxDataViewItem& item) const; |
23324ae1 FM |
2730 | |
2731 | /** | |
5b99d5d8 | 2732 | Returns the nth child item of item. |
23324ae1 | 2733 | */ |
5b99d5d8 RR |
2734 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, |
2735 | unsigned int pos) const; | |
23324ae1 FM |
2736 | |
2737 | /** | |
c4e57202 | 2738 | Inserts a container after @a previous. |
23324ae1 | 2739 | */ |
5b99d5d8 RR |
2740 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
2741 | const wxDataViewItem& previous, | |
2742 | const wxString& text, | |
2743 | const wxIcon& icon = wxNullIcon, | |
2744 | const wxIcon& expanded = wxNullIcon, | |
2745 | wxClientData* data = NULL); | |
23324ae1 FM |
2746 | |
2747 | /** | |
c4e57202 | 2748 | Inserts an item after @a previous. |
23324ae1 | 2749 | */ |
5b99d5d8 RR |
2750 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
2751 | const wxDataViewItem& previous, | |
2752 | const wxString& text, | |
2753 | const wxIcon& icon = wxNullIcon, | |
2754 | wxClientData* data = NULL); | |
23324ae1 FM |
2755 | |
2756 | /** | |
c4e57202 | 2757 | Inserts a container before the first child item or @a parent. |
23324ae1 | 2758 | */ |
5b99d5d8 RR |
2759 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
2760 | const wxString& text, | |
2761 | const wxIcon& icon = wxNullIcon, | |
2762 | const wxIcon& expanded = wxNullIcon, | |
2763 | wxClientData* data = NULL); | |
23324ae1 FM |
2764 | |
2765 | /** | |
c4e57202 | 2766 | Inserts an item before the first child item or @a parent. |
23324ae1 | 2767 | */ |
5b99d5d8 RR |
2768 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
2769 | const wxString& text, | |
2770 | const wxIcon& icon = wxNullIcon, | |
2771 | wxClientData* data = NULL); | |
23324ae1 FM |
2772 | |
2773 | /** | |
5b99d5d8 | 2774 | Sets the client data associated with the item. |
23324ae1 | 2775 | */ |
5b99d5d8 | 2776 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
23324ae1 FM |
2777 | |
2778 | /** | |
5b99d5d8 | 2779 | Sets the expanded icon for the item. |
23324ae1 | 2780 | */ |
5b99d5d8 RR |
2781 | void SetItemExpandedIcon(const wxDataViewItem& item, |
2782 | const wxIcon& icon); | |
23324ae1 FM |
2783 | |
2784 | /** | |
5b99d5d8 | 2785 | Sets the icon for the item. |
23324ae1 | 2786 | */ |
5b99d5d8 | 2787 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
23324ae1 | 2788 | }; |
e54c96f1 | 2789 | |
80932a3e FM |
2790 | |
2791 | /** | |
2792 | @class wxDataViewIconText | |
2793 | ||
2794 | wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer. | |
2795 | This class can be converted to and from a wxVariant. | |
2796 | ||
2797 | @library{wxadv} | |
2798 | @category{dvc} | |
2799 | */ | |
2800 | class wxDataViewIconText : public wxObject | |
2801 | { | |
2802 | public: | |
2803 | //@{ | |
2804 | /** | |
2805 | Constructor. | |
2806 | */ | |
2807 | wxDataViewIconText(const wxString& text = wxEmptyString, | |
2808 | const wxIcon& icon = wxNullIcon); | |
2809 | wxDataViewIconText(const wxDataViewIconText& other); | |
2810 | //@} | |
2811 | ||
2812 | /** | |
2813 | Gets the icon. | |
2814 | */ | |
2815 | const wxIcon& GetIcon() const; | |
2816 | ||
2817 | /** | |
2818 | Gets the text. | |
2819 | */ | |
2820 | wxString GetText() const; | |
2821 | ||
2822 | /** | |
2823 | Set the icon. | |
2824 | */ | |
2825 | void SetIcon(const wxIcon& icon); | |
2826 | ||
2827 | /** | |
2828 | Set the text. | |
2829 | */ | |
2830 | void SetText(const wxString& text); | |
2831 | }; | |
2832 | ||
2833 | ||
2834 | ||
2835 | /** | |
2836 | @class wxDataViewEvent | |
2837 | ||
2838 | This is the event class for the wxDataViewCtrl notifications. | |
2839 | ||
14f73cf1 FM |
2840 | @beginEventTable{wxDataViewEvent} |
2841 | @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)} | |
2842 | Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event. | |
2843 | @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)} | |
2844 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. | |
2845 | @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)} | |
2846 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. | |
2847 | @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)} | |
2848 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event. | |
2849 | @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)} | |
2850 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event. | |
2851 | @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)} | |
2852 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event. | |
2853 | @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)} | |
2854 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event. | |
2855 | @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)} | |
2856 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event. | |
2857 | @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)} | |
2858 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event. | |
2859 | @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)} | |
2860 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event. | |
2861 | @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)} | |
2862 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event. | |
2863 | @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)} | |
2864 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event. | |
2865 | @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)} | |
2866 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event. | |
2867 | @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)} | |
2868 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event. | |
2869 | @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)} | |
2870 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event. | |
2871 | @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)} | |
2872 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event. | |
2873 | @event{EVT_DATAVIEW_ITEM_DROP(id, func)} | |
2874 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event. | |
47a8b1e1 VZ |
2875 | @event{EVT_DATAVIEW_CACHE_HINT(id, func)} |
2876 | Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event. | |
14f73cf1 | 2877 | @endEventTable |
43c64cc6 | 2878 | |
80932a3e FM |
2879 | @library{wxadv} |
2880 | @category{events,dvc} | |
2881 | */ | |
2882 | class wxDataViewEvent : public wxNotifyEvent | |
2883 | { | |
2884 | public: | |
80932a3e FM |
2885 | /** |
2886 | Constructor. Typically used by wxWidgets internals only. | |
2887 | */ | |
2888 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, | |
2889 | int winid = 0); | |
80932a3e FM |
2890 | |
2891 | /** | |
2892 | Returns the position of the column in the control or -1 | |
2893 | if no column field was set by the event emitter. | |
2894 | */ | |
2895 | int GetColumn() const; | |
2896 | ||
2897 | /** | |
2898 | Returns a pointer to the wxDataViewColumn from which | |
2899 | the event was emitted or @NULL. | |
2900 | */ | |
2901 | wxDataViewColumn* GetDataViewColumn() const; | |
2902 | ||
2903 | /** | |
2904 | Returns the wxDataViewModel associated with the event. | |
2905 | */ | |
2906 | wxDataViewModel* GetModel() const; | |
2907 | ||
2908 | /** | |
57ab6f23 | 2909 | Returns the position of a context menu event in screen coordinates. |
80932a3e FM |
2910 | */ |
2911 | wxPoint GetPosition() const; | |
2912 | ||
2913 | /** | |
2914 | Returns a reference to a value. | |
2915 | */ | |
2916 | const wxVariant& GetValue() const; | |
2917 | ||
2a648479 VZ |
2918 | /** |
2919 | Can be used to determine whether the new value is going to be accepted | |
2920 | in wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE handler. | |
2921 | ||
2922 | Returns @true if editing the item was cancelled or if the user tried to | |
2923 | enter an invalid value (refused by wxDataViewRenderer::Validate()). If | |
2924 | this method returns @false, it means that the value in the model is | |
2925 | about to be changed to the new one. | |
2926 | ||
2927 | Notice that wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event handler can | |
2928 | call wxNotifyEvent::Veto() to prevent this from happening. | |
2929 | ||
2930 | Currently support for setting this field and for vetoing the change is | |
2931 | only available in the generic version of wxDataViewCtrl, i.e. under MSW | |
2932 | but not GTK nor OS X. | |
2933 | ||
2934 | @since 2.9.3 | |
2935 | */ | |
2936 | bool IsEditCancelled() const; | |
2937 | ||
80932a3e FM |
2938 | /** |
2939 | Sets the column index associated with this event. | |
2940 | */ | |
2941 | void SetColumn(int col); | |
2942 | ||
2943 | /** | |
3a194bda | 2944 | For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only. |
80932a3e FM |
2945 | */ |
2946 | void SetDataViewColumn(wxDataViewColumn* col); | |
2947 | ||
2948 | /** | |
2949 | Sets the dataview model associated with this event. | |
2950 | */ | |
2951 | void SetModel(wxDataViewModel* model); | |
2952 | ||
2953 | /** | |
2954 | Sets the value associated with this event. | |
2955 | */ | |
2956 | void SetValue(const wxVariant& value); | |
02b51ae5 | 2957 | |
591cc82d | 2958 | /** |
e4de825e | 2959 | Set wxDataObject for data transfer within a drag operation. |
591cc82d RR |
2960 | */ |
2961 | void SetDataObject( wxDataObject *obj ); | |
02b51ae5 | 2962 | |
591cc82d | 2963 | /** |
e4de825e RR |
2964 | Used internally. Gets associated wxDataObject for data transfer |
2965 | within a drag operation. | |
2966 | */ | |
2967 | wxDataObject *GetDataObject() const; | |
02b51ae5 | 2968 | |
e4de825e RR |
2969 | /** |
2970 | Used internally. Sets the wxDataFormat during a drop operation. | |
2971 | */ | |
2972 | void SetDataFormat( const wxDataFormat &format ); | |
02b51ae5 | 2973 | |
e4de825e RR |
2974 | /** |
2975 | Gets the wxDataFormat during a drop operation. | |
2976 | */ | |
2977 | wxDataFormat GetDataFormat() const; | |
02b51ae5 | 2978 | |
e4de825e RR |
2979 | /** |
2980 | Used internally. Sets the data size for a drop data transfer. | |
2981 | */ | |
2982 | void SetDataSize( size_t size ); | |
02b51ae5 | 2983 | |
e4de825e RR |
2984 | /** |
2985 | Gets the data size for a drop data transfer. | |
2986 | */ | |
2987 | size_t GetDataSize() const; | |
02b51ae5 | 2988 | |
e4de825e RR |
2989 | /** |
2990 | Used internally. Sets the data buffer for a drop data transfer. | |
2991 | */ | |
2992 | void SetDataBuffer( void* buf ); | |
02b51ae5 | 2993 | |
e4de825e RR |
2994 | /** |
2995 | Gets the data buffer for a drop data transfer. | |
591cc82d | 2996 | */ |
e4de825e | 2997 | void *GetDataBuffer() const; |
47a8b1e1 VZ |
2998 | |
2999 | /** | |
3000 | Return the first row that will be displayed. | |
3001 | */ | |
3002 | int GetCacheFrom() const; | |
3003 | ||
3004 | /** | |
3005 | Return the last row that will be displayed. | |
3006 | */ | |
3007 | int GetCacheTo() const; | |
80932a3e FM |
3008 | }; |
3009 |