]>
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 FM |
169 | |
170 | /** | |
c4e57202 FM |
171 | Override this so the control can query the child items of an item. |
172 | Returns the number of items. | |
23324ae1 FM |
173 | */ |
174 | virtual unsigned int GetChildren(const wxDataViewItem& item, | |
fadc2df6 | 175 | wxDataViewItemArray& children) const = 0; |
23324ae1 FM |
176 | |
177 | /** | |
178 | Override this to indicate the number of columns in the model. | |
179 | */ | |
b91c4601 | 180 | virtual unsigned int GetColumnCount() const = 0; |
23324ae1 FM |
181 | |
182 | /** | |
183 | Override this to indicate what type of data is stored in the | |
c4e57202 FM |
184 | column specified by @a col. |
185 | ||
186 | This should return a string indicating the type of data as reported by wxVariant. | |
23324ae1 | 187 | */ |
b91c4601 | 188 | virtual wxString GetColumnType(unsigned int col) const = 0; |
23324ae1 FM |
189 | |
190 | /** | |
191 | Override this to indicate which wxDataViewItem representing the parent | |
4cc4bfaf | 192 | of @a item or an invalid wxDataViewItem if the the root item is |
23324ae1 FM |
193 | the parent item. |
194 | */ | |
b91c4601 | 195 | virtual wxDataViewItem GetParent(const wxDataViewItem& item) const = 0; |
23324ae1 FM |
196 | |
197 | /** | |
c4e57202 | 198 | Override this to indicate the value of @a item. |
23324ae1 FM |
199 | A wxVariant is used to store the data. |
200 | */ | |
b91c4601 FM |
201 | virtual void GetValue(wxVariant& variant, const wxDataViewItem& item, |
202 | unsigned int col) const = 0; | |
23324ae1 FM |
203 | |
204 | /** | |
c4e57202 FM |
205 | Override this method to indicate if a container item merely acts as a |
206 | headline (or for categorisation) or if it also acts a normal item with | |
207 | entries for futher columns. By default returns @false. | |
23324ae1 | 208 | */ |
328f5751 | 209 | virtual bool HasContainerColumns(const wxDataViewItem& item) const; |
23324ae1 FM |
210 | |
211 | /** | |
212 | Override this to indicate that the model provides a default compare | |
213 | function that the control should use if no wxDataViewColumn has been | |
214 | chosen for sorting. Usually, the user clicks on a column header for | |
c4e57202 FM |
215 | sorting, the data will be sorted alphanumerically. |
216 | ||
217 | If any other order (e.g. by index or order of appearance) is required, | |
218 | then this should be used. | |
219 | See wxDataViewIndexListModel for a model which makes use of this. | |
23324ae1 | 220 | */ |
328f5751 | 221 | virtual bool HasDefaultCompare() const; |
23324ae1 | 222 | |
b372f20e VZ |
223 | /** |
224 | Return true if there is a value in the given column of this item. | |
225 | ||
226 | All normal items have values in all columns but the container items | |
227 | only show their label in the first column (@a col == 0) by default (but | |
228 | see HasContainerColumns()). So this function always returns true for | |
229 | the first column while for the other ones it returns true only if the | |
230 | item is not a container or HasContainerColumns() was overridden to | |
231 | return true for it. | |
232 | ||
233 | @since 2.9.1 | |
234 | */ | |
235 | bool HasValue(const wxDataViewItem& item, unsigned col) const; | |
236 | ||
23324ae1 | 237 | /** |
4cc4bfaf | 238 | Override this to indicate of @a item is a container, i.e. if |
23324ae1 FM |
239 | it can have child items. |
240 | */ | |
b91c4601 | 241 | virtual bool IsContainer(const wxDataViewItem& item) const = 0; |
23324ae1 FM |
242 | |
243 | /** | |
c4e57202 | 244 | Call this to inform the model that an item has been added to the data. |
23324ae1 | 245 | */ |
9ca2afd1 | 246 | bool ItemAdded(const wxDataViewItem& parent, |
23324ae1 FM |
247 | const wxDataViewItem& item); |
248 | ||
249 | /** | |
250 | Call this to inform the model that an item has changed. | |
c4e57202 | 251 | |
23324ae1 FM |
252 | This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
253 | event (in which the column fields will not be set) to the user. | |
254 | */ | |
9ca2afd1 | 255 | bool ItemChanged(const wxDataViewItem& item); |
23324ae1 FM |
256 | |
257 | /** | |
258 | Call this to inform the model that an item has been deleted from the data. | |
259 | */ | |
9ca2afd1 | 260 | bool ItemDeleted(const wxDataViewItem& parent, |
23324ae1 FM |
261 | const wxDataViewItem& item); |
262 | ||
263 | /** | |
c4e57202 | 264 | Call this to inform the model that several items have been added to the data. |
23324ae1 | 265 | */ |
9ca2afd1 | 266 | bool ItemsAdded(const wxDataViewItem& parent, |
23324ae1 FM |
267 | const wxDataViewItemArray& items); |
268 | ||
269 | /** | |
270 | Call this to inform the model that several items have changed. | |
c4e57202 | 271 | |
23324ae1 FM |
272 | This will eventually emit wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
273 | events (in which the column fields will not be set) to the user. | |
274 | */ | |
9ca2afd1 | 275 | bool ItemsChanged(const wxDataViewItemArray& items); |
23324ae1 FM |
276 | |
277 | /** | |
278 | Call this to inform the model that several items have been deleted. | |
279 | */ | |
9ca2afd1 | 280 | bool ItemsDeleted(const wxDataViewItem& parent, |
23324ae1 FM |
281 | const wxDataViewItemArray& items); |
282 | ||
283 | /** | |
4cc4bfaf | 284 | Remove the @a notifier from the list of notifiers. |
23324ae1 FM |
285 | */ |
286 | void RemoveNotifier(wxDataViewModelNotifier* notifier); | |
287 | ||
288 | /** | |
c4e57202 | 289 | Call this to initiate a resort after the sort function has been changed. |
23324ae1 FM |
290 | */ |
291 | virtual void Resort(); | |
292 | ||
293 | /** | |
294 | This gets called in order to set a value in the data model. | |
795dac4c | 295 | |
c4e57202 FM |
296 | The most common scenario is that the wxDataViewCtrl calls this method |
297 | after the user changed some data in the view. | |
298 | ||
795dac4c VZ |
299 | This is the function you need to override in your derived class but if |
300 | you want to call it, ChangeValue() is usually more convenient as | |
301 | otherwise you need to manually call ValueChanged() to update the | |
302 | control itself. | |
23324ae1 | 303 | */ |
795dac4c VZ |
304 | virtual bool SetValue(const wxVariant& variant, |
305 | const wxDataViewItem& item, | |
b91c4601 | 306 | unsigned int col) = 0; |
23324ae1 FM |
307 | |
308 | /** | |
c4e57202 FM |
309 | Call this to inform this model that a value in the model has been changed. |
310 | This is also called from wxDataViewCtrl's internal editing code, e.g. when | |
311 | editing a text field in the control. | |
312 | ||
23324ae1 FM |
313 | This will eventually emit a wxEVT_DATAVIEW_ITEM_VALUE_CHANGED |
314 | event to the user. | |
315 | */ | |
316 | virtual bool ValueChanged(const wxDataViewItem& item, | |
317 | unsigned int col); | |
5e6e278d FM |
318 | |
319 | protected: | |
320 | ||
321 | /** | |
322 | Destructor. This should not be called directly. Use DecRef() instead. | |
323 | */ | |
324 | virtual ~wxDataViewModel(); | |
23324ae1 FM |
325 | }; |
326 | ||
327 | ||
e54c96f1 | 328 | |
e39de702 RR |
329 | /** |
330 | @class wxDataViewIndexListModel | |
e39de702 | 331 | |
c4e57202 FM |
332 | wxDataViewIndexListModel is a specialized data model which lets you address |
333 | an item by its position (row) rather than its wxDataViewItem (which you can | |
334 | obtain from this class). | |
e39de702 RR |
335 | This model also provides its own wxDataViewIndexListModel::Compare |
336 | method which sorts the model's data by the index. | |
b91c4601 | 337 | |
c4e57202 FM |
338 | This model is not a virtual model since the control stores each wxDataViewItem. |
339 | Use wxDataViewVirtualListModel if you need to display millions of items or | |
340 | have other reason to use a virtual control. | |
e39de702 | 341 | |
8ed522d9 | 342 | @library{wxadv} |
b321b61c | 343 | @category{dvc} |
e39de702 RR |
344 | */ |
345 | class wxDataViewIndexListModel : public wxDataViewModel | |
346 | { | |
347 | public: | |
348 | /** | |
349 | Constructor. | |
350 | */ | |
351 | wxDataViewIndexListModel(unsigned int initial_size = 0); | |
352 | ||
353 | /** | |
354 | Destructor. | |
355 | */ | |
adaaa686 | 356 | virtual ~wxDataViewIndexListModel(); |
e39de702 RR |
357 | |
358 | /** | |
359 | Compare method that sorts the items by their index. | |
360 | */ | |
361 | int Compare(const wxDataViewItem& item1, | |
362 | const wxDataViewItem& item2, | |
363 | unsigned int column, bool ascending); | |
364 | ||
365 | /** | |
13f184c0 | 366 | Override this to indicate that the row has special font attributes. |
c4e57202 FM |
367 | This only affects the wxDataViewTextRendererText() renderer. |
368 | ||
7fadac88 VZ |
369 | The base class version always simply returns @false. |
370 | ||
c4e57202 | 371 | @see wxDataViewItemAttr. |
7fadac88 VZ |
372 | |
373 | @param row | |
374 | The row for which the attribute is requested. | |
375 | @param col | |
376 | The column for which the attribute is requested. | |
377 | @param attr | |
378 | The attribute to be filled in if the function returns @true. | |
379 | @return | |
380 | @true if this item has an attribute or @false otherwise. | |
e39de702 | 381 | */ |
8eff6c56 | 382 | virtual bool GetAttrByRow(unsigned int row, unsigned int col, |
7fadac88 | 383 | wxDataViewItemAttr& attr) const; |
e39de702 | 384 | |
74d9b8fb VZ |
385 | /** |
386 | Returns the number of items (i.e. rows) in the list. | |
387 | */ | |
388 | unsigned int GetCount() const; | |
389 | ||
e39de702 RR |
390 | /** |
391 | Returns the wxDataViewItem at the given @e row. | |
392 | */ | |
393 | wxDataViewItem GetItem(unsigned int row) const; | |
394 | ||
395 | /** | |
396 | Returns the position of given @e item. | |
397 | */ | |
398 | unsigned int GetRow(const wxDataViewItem& item) const; | |
399 | ||
400 | /** | |
401 | Override this to allow getting values from the model. | |
402 | */ | |
8eff6c56 | 403 | virtual void GetValueByRow(wxVariant& variant, unsigned int row, |
fadc2df6 | 404 | unsigned int col) const = 0; |
e39de702 RR |
405 | |
406 | /** | |
c4e57202 FM |
407 | Call this after if the data has to be read again from the model. |
408 | This is useful after major changes when calling the methods below | |
409 | (possibly thousands of times) doesn't make sense. | |
e39de702 RR |
410 | */ |
411 | void Reset(unsigned int new_size); | |
412 | ||
413 | /** | |
414 | Call this after a row has been appended to the model. | |
415 | */ | |
416 | void RowAppended(); | |
417 | ||
418 | /** | |
419 | Call this after a row has been changed. | |
420 | */ | |
421 | void RowChanged(unsigned int row); | |
422 | ||
423 | /** | |
424 | Call this after a row has been deleted. | |
425 | */ | |
426 | void RowDeleted(unsigned int row); | |
427 | ||
428 | /** | |
429 | Call this after a row has been inserted at the given position. | |
430 | */ | |
431 | void RowInserted(unsigned int before); | |
432 | ||
433 | /** | |
434 | Call this after a row has been prepended to the model. | |
435 | */ | |
436 | void RowPrepended(); | |
437 | ||
438 | /** | |
439 | Call this after a value has been changed. | |
440 | */ | |
441 | void RowValueChanged(unsigned int row, unsigned int col); | |
442 | ||
443 | /** | |
c4e57202 FM |
444 | Call this after rows have been deleted. |
445 | The array will internally get copied and sorted in descending order so | |
446 | that the rows with the highest position will be deleted first. | |
e39de702 RR |
447 | */ |
448 | void RowsDeleted(const wxArrayInt& rows); | |
449 | ||
450 | /** | |
451 | Called in order to set a value in the model. | |
452 | */ | |
8eff6c56 | 453 | virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, |
fadc2df6 | 454 | unsigned int col) = 0; |
e39de702 RR |
455 | }; |
456 | ||
457 | ||
458 | ||
459 | /** | |
460 | @class wxDataViewVirtualListModel | |
e39de702 | 461 | |
c4e57202 FM |
462 | wxDataViewVirtualListModel is a specialized data model which lets you address |
463 | an item by its position (row) rather than its wxDataViewItem and as such offers | |
464 | the exact same interface as wxDataViewIndexListModel. | |
465 | The important difference is that under platforms other than OS X, using this | |
466 | model will result in a truly virtual control able to handle millions of items | |
467 | as the control doesn't store any item (a feature not supported by the | |
e39de702 RR |
468 | Carbon API under OS X). |
469 | ||
470 | @see wxDataViewIndexListModel for the API. | |
471 | ||
8ed522d9 | 472 | @library{wxadv} |
b321b61c | 473 | @category{dvc} |
e39de702 RR |
474 | */ |
475 | class wxDataViewVirtualListModel : public wxDataViewModel | |
476 | { | |
477 | public: | |
478 | /** | |
479 | Constructor. | |
480 | */ | |
481 | wxDataViewVirtualListModel(unsigned int initial_size = 0); | |
74d9b8fb VZ |
482 | |
483 | /** | |
484 | Returns the number of virtual items (i.e. rows) in the list. | |
485 | */ | |
486 | unsigned int GetCount() const; | |
6da3d196 | 487 | }; |
e39de702 RR |
488 | |
489 | ||
490 | ||
23324ae1 FM |
491 | /** |
492 | @class wxDataViewItemAttr | |
7c913512 | 493 | |
c4e57202 FM |
494 | This class is used to indicate to a wxDataViewCtrl that a certain item |
495 | (see wxDataViewItem) has extra font attributes for its renderer. | |
496 | For this, it is required to override wxDataViewModel::GetAttr. | |
7c913512 | 497 | |
c4e57202 | 498 | Attributes are currently only supported by wxDataViewTextRendererText. |
7c913512 | 499 | |
23324ae1 | 500 | @library{wxadv} |
b321b61c | 501 | @category{dvc} |
23324ae1 | 502 | */ |
7c913512 | 503 | class wxDataViewItemAttr |
23324ae1 FM |
504 | { |
505 | public: | |
506 | /** | |
507 | Constructor. | |
508 | */ | |
509 | wxDataViewItemAttr(); | |
510 | ||
511 | /** | |
512 | Call this to indicate that the item shall be displayed in bold text. | |
513 | */ | |
514 | void SetBold(bool set); | |
515 | ||
516 | /** | |
c4e57202 | 517 | Call this to indicate that the item shall be displayed with that colour. |
23324ae1 FM |
518 | */ |
519 | void SetColour(const wxColour& colour); | |
520 | ||
521 | /** | |
522 | Call this to indicate that the item shall be displayed in italic text. | |
523 | */ | |
524 | void SetItalic(bool set); | |
525 | }; | |
526 | ||
527 | ||
e54c96f1 | 528 | |
23324ae1 FM |
529 | /** |
530 | @class wxDataViewItem | |
7c913512 | 531 | |
c4e57202 | 532 | wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl |
fe45d6ff | 533 | in a persistent way, i.e. independent of the position of the item in the control |
c4e57202 FM |
534 | or changes to its contents. |
535 | ||
536 | It must hold a unique ID of type @e void* in its only field and can be converted | |
537 | to and from it. | |
538 | ||
539 | If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will | |
540 | return @false which used in many places in the API of wxDataViewCtrl to | |
541 | indicate that e.g. no item was found. An ID of @NULL is also used to indicate | |
542 | the invisible root. Examples for this are wxDataViewModel::GetParent and | |
23324ae1 | 543 | wxDataViewModel::GetChildren. |
7c913512 | 544 | |
23324ae1 | 545 | @library{wxadv} |
b321b61c | 546 | @category{dvc} |
23324ae1 | 547 | */ |
7c913512 | 548 | class wxDataViewItem |
23324ae1 FM |
549 | { |
550 | public: | |
551 | //@{ | |
552 | /** | |
c4e57202 | 553 | Constructor. |
23324ae1 | 554 | */ |
4cc4bfaf | 555 | wxDataViewItem(void* id = NULL); |
7c913512 | 556 | wxDataViewItem(const wxDataViewItem& item); |
23324ae1 FM |
557 | //@} |
558 | ||
559 | /** | |
560 | Returns the ID. | |
561 | */ | |
328f5751 | 562 | void* GetID() const; |
23324ae1 FM |
563 | |
564 | /** | |
c4e57202 | 565 | Returns @true if the ID is not @NULL. |
23324ae1 | 566 | */ |
328f5751 | 567 | bool IsOk() const; |
23324ae1 FM |
568 | }; |
569 | ||
570 | ||
e54c96f1 | 571 | |
23324ae1 FM |
572 | /** |
573 | @class wxDataViewCtrl | |
7c913512 | 574 | |
c4e57202 FM |
575 | wxDataViewCtrl is a control to display data either in a tree like fashion or |
576 | in a tabular form or both. | |
02b51ae5 | 577 | |
c4e57202 FM |
578 | If you only need to display a simple tree structure with an API more like the |
579 | older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used. | |
02b51ae5 | 580 | Likewise, if you only want to display simple table structure you can use |
832df171 RR |
581 | the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and |
582 | wxDataViewListCtrl can be used without defining your own wxDataViewModel. | |
c4e57202 FM |
583 | |
584 | A wxDataViewItem is used to represent a (visible) item in the control. | |
585 | ||
80932a3e | 586 | Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through |
c4e57202 FM |
587 | virtual functions or by setting it directly. Instead you need to write your own |
588 | wxDataViewModel and associate it with this control. | |
589 | Then you need to add a number of wxDataViewColumn to this control to define | |
590 | what each column shall display. Each wxDataViewColumn in turn owns 1 instance | |
591 | of a wxDataViewRenderer to render its cells. | |
592 | ||
593 | A number of standard renderers for rendering text, dates, images, toggle, | |
594 | a progress bar etc. are provided. Additionally, the user can write custom | |
80932a3e | 595 | renderers deriving from wxDataViewCustomRenderer for displaying anything. |
c4e57202 FM |
596 | |
597 | All data transfer from the control to the model and the user code is done | |
598 | through wxVariant which can be extended to support more data formats as necessary. | |
599 | Accordingly, all type information uses the strings returned from wxVariant::GetType. | |
7c913512 | 600 | |
23324ae1 | 601 | @beginStyleTable |
8c6791e4 | 602 | @style{wxDV_SINGLE} |
23324ae1 | 603 | Single selection mode. This is the default. |
8c6791e4 | 604 | @style{wxDV_MULTIPLE} |
23324ae1 | 605 | Multiple selection mode. |
8c6791e4 | 606 | @style{wxDV_ROW_LINES} |
23324ae1 | 607 | Use alternating colours for rows if supported by platform and theme. |
8c6791e4 | 608 | @style{wxDV_HORIZ_RULES} |
23324ae1 | 609 | Display fine rules between row if supported. |
8c6791e4 | 610 | @style{wxDV_VERT_RULES} |
23324ae1 | 611 | Display fine rules between columns is supported. |
d7c6d397 | 612 | @style{wxDV_VARIABLE_LINE_HEIGHT} |
c4e57202 | 613 | Allow variable line heights. |
14f73cf1 | 614 | This can be inefficient when displaying large number of items. |
b5123fb6 VZ |
615 | @style{wxDV_NO_HEADER} |
616 | Do not show column headers (which are shown by default). | |
23324ae1 | 617 | @endStyleTable |
7c913512 | 618 | |
3051a44a | 619 | @beginEventEmissionTable{wxDataViewEvent} |
7d01d660 | 620 | @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)} |
14f73cf1 | 621 | Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event. |
7d01d660 | 622 | @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)} |
14f73cf1 | 623 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. |
3e978cf7 RR |
624 | @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)} |
625 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. This | |
626 | event can be vetoed in order to prevent editing on an item by item | |
627 | basis. Still experimental. | |
7d01d660 | 628 | @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)} |
14f73cf1 | 629 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. |
7d01d660 | 630 | @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)} |
14f73cf1 | 631 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event. |
7d01d660 | 632 | @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)} |
14f73cf1 | 633 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event. |
7d01d660 | 634 | @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)} |
14f73cf1 | 635 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event. |
7d01d660 | 636 | @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)} |
14f73cf1 | 637 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event. |
7d01d660 | 638 | @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)} |
14f73cf1 | 639 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event. |
7d01d660 | 640 | @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)} |
14f73cf1 | 641 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event. |
7d01d660 | 642 | @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)} |
14f73cf1 | 643 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event. |
7d01d660 | 644 | @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)} |
14f73cf1 | 645 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event. |
7d01d660 | 646 | @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)} |
14f73cf1 | 647 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event. |
7d01d660 | 648 | @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)} |
14f73cf1 | 649 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event. |
7d01d660 | 650 | @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)} |
14f73cf1 | 651 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event. |
591cc82d | 652 | @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)} |
14f73cf1 | 653 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event. |
e4de825e | 654 | @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)} |
14f73cf1 | 655 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event. |
e4de825e | 656 | @event{EVT_DATAVIEW_ITEM_DROP(id, func)} |
14f73cf1 | 657 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event. |
7d01d660 | 658 | @endEventTable |
b91c4601 | 659 | |
23324ae1 | 660 | @library{wxadv} |
b321b61c | 661 | @category{ctrl,dvc} |
7e59b885 | 662 | @appearance{dataviewctrl.png} |
23324ae1 FM |
663 | */ |
664 | class wxDataViewCtrl : public wxControl | |
665 | { | |
666 | public: | |
23324ae1 | 667 | /** |
19723525 | 668 | Default Constructor. |
23324ae1 FM |
669 | */ |
670 | wxDataViewCtrl(); | |
b91c4601 | 671 | |
19723525 RR |
672 | /** |
673 | Constructor. Calls Create(). | |
674 | */ | |
7c913512 FM |
675 | wxDataViewCtrl(wxWindow* parent, wxWindowID id, |
676 | const wxPoint& pos = wxDefaultPosition, | |
677 | const wxSize& size = wxDefaultSize, | |
678 | long style = 0, | |
679 | const wxValidator& validator = wxDefaultValidator); | |
23324ae1 FM |
680 | |
681 | /** | |
682 | Destructor. | |
683 | */ | |
adaaa686 | 684 | virtual ~wxDataViewCtrl(); |
23324ae1 | 685 | |
e39de702 | 686 | /** |
19723525 | 687 | Appends a wxDataViewColumn to the control. Returns @true on success. |
c4e57202 | 688 | |
e39de702 RR |
689 | Note that there is a number of short cut methods which implicitly create |
690 | a wxDataViewColumn and a wxDataViewRenderer for it (see below). | |
691 | */ | |
692 | virtual bool AppendColumn(wxDataViewColumn* col); | |
693 | ||
19723525 RR |
694 | /** |
695 | Prepends a wxDataViewColumn to the control. Returns @true on success. | |
c4e57202 | 696 | |
19723525 RR |
697 | Note that there is a number of short cut methods which implicitly create |
698 | a wxDataViewColumn and a wxDataViewRenderer for it. | |
699 | */ | |
700 | virtual bool PrependColumn(wxDataViewColumn* col); | |
701 | ||
702 | /** | |
703 | Inserts a wxDataViewColumn to the control. Returns @true on success. | |
704 | */ | |
705 | virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col); | |
b91c4601 | 706 | |
23324ae1 FM |
707 | //@{ |
708 | /** | |
709 | Appends a column for rendering a bitmap. Returns the wxDataViewColumn | |
710 | created in the function or @NULL on failure. | |
711 | */ | |
712 | wxDataViewColumn* AppendBitmapColumn(const wxString& label, | |
713 | unsigned int model_column, | |
714 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
715 | int width = -1, | |
716 | wxAlignment align = wxALIGN_CENTER, | |
717 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
718 | wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label, |
719 | unsigned int model_column, | |
720 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
721 | int width = -1, | |
722 | wxAlignment align = wxALIGN_CENTER, | |
723 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
724 | //@} |
725 | ||
23324ae1 FM |
726 | //@{ |
727 | /** | |
728 | Appends a column for rendering a date. Returns the wxDataViewColumn | |
729 | created in the function or @NULL on failure. | |
b91c4601 | 730 | |
c4e57202 FM |
731 | @note The @a align parameter is applied to both the column header and |
732 | the column renderer. | |
23324ae1 FM |
733 | */ |
734 | wxDataViewColumn* AppendDateColumn(const wxString& label, | |
735 | unsigned int model_column, | |
736 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
737 | int width = -1, | |
882678eb | 738 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 739 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
740 | wxDataViewColumn* AppendDateColumn(const wxBitmap& label, |
741 | unsigned int model_column, | |
742 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
743 | int width = -1, | |
882678eb | 744 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 745 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
746 | //@} |
747 | ||
748 | //@{ | |
749 | /** | |
750 | Appends a column for rendering text with an icon. Returns the wxDataViewColumn | |
c4e57202 FM |
751 | created in the function or @NULL on failure. |
752 | This method uses the wxDataViewIconTextRenderer class. | |
b91c4601 | 753 | |
c4e57202 FM |
754 | @note The @a align parameter is applied to both the column header and |
755 | the column renderer. | |
23324ae1 FM |
756 | */ |
757 | wxDataViewColumn* AppendIconTextColumn(const wxString& label, | |
758 | unsigned int model_column, | |
759 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
760 | int width = -1, | |
882678eb | 761 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 762 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
763 | wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label, |
764 | unsigned int model_column, | |
765 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
766 | int width = -1, | |
882678eb | 767 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 768 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
769 | //@} |
770 | ||
771 | //@{ | |
772 | /** | |
773 | Appends a column for rendering a progress indicator. Returns the | |
e39de702 | 774 | wxDataViewColumn created in the function or @NULL on failure. |
b91c4601 | 775 | |
c4e57202 FM |
776 | @note The @a align parameter is applied to both the column header and |
777 | the column renderer. | |
23324ae1 FM |
778 | */ |
779 | wxDataViewColumn* AppendProgressColumn(const wxString& label, | |
780 | unsigned int model_column, | |
781 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
782 | int width = 80, | |
783 | wxAlignment align = wxALIGN_CENTER, | |
784 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
785 | wxDataViewColumn* AppendProgressColumn(const wxBitmap& label, |
786 | unsigned int model_column, | |
787 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
788 | int width = 80, | |
789 | wxAlignment align = wxALIGN_CENTER, | |
790 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
791 | //@} |
792 | ||
793 | //@{ | |
794 | /** | |
795 | Appends a column for rendering text. Returns the wxDataViewColumn | |
796 | created in the function or @NULL on failure. | |
b91c4601 | 797 | |
c4e57202 FM |
798 | @note The @a align parameter is applied to both the column header and |
799 | the column renderer. | |
23324ae1 FM |
800 | */ |
801 | wxDataViewColumn* AppendTextColumn(const wxString& label, | |
802 | unsigned int model_column, | |
803 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
804 | int width = -1, | |
882678eb | 805 | wxAlignment align = wxALIGN_NOT, |
23324ae1 | 806 | int flags = wxDATAVIEW_COL_RESIZABLE); |
7c913512 FM |
807 | wxDataViewColumn* AppendTextColumn(const wxBitmap& label, |
808 | unsigned int model_column, | |
809 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
810 | int width = -1, | |
882678eb | 811 | wxAlignment align = wxALIGN_NOT, |
7c913512 | 812 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 FM |
813 | //@} |
814 | ||
815 | //@{ | |
816 | /** | |
817 | Appends a column for rendering a toggle. Returns the wxDataViewColumn | |
818 | created in the function or @NULL on failure. | |
b91c4601 | 819 | |
c4e57202 FM |
820 | @note The @a align parameter is applied to both the column header and |
821 | the column renderer. | |
23324ae1 FM |
822 | */ |
823 | wxDataViewColumn* AppendToggleColumn(const wxString& label, | |
824 | unsigned int model_column, | |
825 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
826 | int width = 30, | |
827 | wxAlignment align = wxALIGN_CENTER, | |
828 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
7c913512 FM |
829 | wxDataViewColumn* AppendToggleColumn(const wxBitmap& label, |
830 | unsigned int model_column, | |
831 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
832 | int width = 30, | |
833 | wxAlignment align = wxALIGN_CENTER, | |
834 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
23324ae1 FM |
835 | //@} |
836 | ||
837 | /** | |
c4e57202 FM |
838 | Associates a wxDataViewModel with the control. |
839 | This increases the reference count of the model by 1. | |
23324ae1 FM |
840 | */ |
841 | virtual bool AssociateModel(wxDataViewModel* model); | |
842 | ||
843 | /** | |
844 | Removes all columns. | |
845 | */ | |
846 | virtual bool ClearColumns(); | |
847 | ||
23324ae1 FM |
848 | /** |
849 | Collapses the item. | |
850 | */ | |
adaaa686 | 851 | virtual void Collapse(const wxDataViewItem& item); |
23324ae1 FM |
852 | |
853 | /** | |
854 | Create the control. Useful for two step creation. | |
855 | */ | |
856 | bool Create(wxWindow* parent, wxWindowID id, | |
857 | const wxPoint& pos = wxDefaultPosition, | |
858 | const wxSize& size = wxDefaultSize, | |
859 | long style = 0, | |
860 | const wxValidator& validator = wxDefaultValidator); | |
861 | ||
862 | /** | |
863 | Deletes given column. | |
864 | */ | |
50ec54b6 | 865 | virtual bool DeleteColumn(wxDataViewColumn* column); |
23324ae1 | 866 | |
e4de825e RR |
867 | /** |
868 | Enable drag operations using the given @a format. | |
869 | */ | |
870 | virtual bool EnableDragSource( const wxDataFormat &format ); | |
02b51ae5 | 871 | |
e4de825e RR |
872 | /** |
873 | Enable drop operations using the given @a format. | |
874 | */ | |
875 | virtual bool EnableDropTarget( const wxDataFormat &format ); | |
02b51ae5 | 876 | |
23324ae1 FM |
877 | /** |
878 | Call this to ensure that the given item is visible. | |
879 | */ | |
fadc2df6 FM |
880 | virtual void EnsureVisible(const wxDataViewItem& item, |
881 | const wxDataViewColumn* column = NULL); | |
23324ae1 FM |
882 | |
883 | /** | |
884 | Expands the item. | |
885 | */ | |
adaaa686 | 886 | virtual void Expand(const wxDataViewItem& item); |
23324ae1 | 887 | |
4219d8b0 RR |
888 | /** |
889 | Expands all ancestors of the @a item. This method also | |
890 | ensures that the item itself as well as all ancestor | |
891 | items have been read from the model by the control. | |
892 | */ | |
893 | virtual void ExpandAncestors( const wxDataViewItem & item ); | |
798c0d87 | 894 | |
23324ae1 | 895 | /** |
c4e57202 FM |
896 | Returns pointer to the column. @a pos refers to the position in the |
897 | control which may change after reordering columns by the user. | |
23324ae1 | 898 | */ |
328f5751 | 899 | virtual wxDataViewColumn* GetColumn(unsigned int pos) const; |
23324ae1 FM |
900 | |
901 | /** | |
902 | Returns the number of columns. | |
903 | */ | |
328f5751 | 904 | virtual unsigned int GetColumnCount() const; |
23324ae1 FM |
905 | |
906 | /** | |
907 | Returns the position of the column or -1 if not found in the control. | |
908 | */ | |
328f5751 | 909 | virtual int GetColumnPosition(const wxDataViewColumn* column) const; |
23324ae1 FM |
910 | |
911 | /** | |
912 | Returns column containing the expanders. | |
913 | */ | |
328f5751 | 914 | wxDataViewColumn* GetExpanderColumn() const; |
23324ae1 FM |
915 | |
916 | /** | |
917 | Returns indentation. | |
918 | */ | |
328f5751 | 919 | int GetIndent() const; |
23324ae1 FM |
920 | |
921 | /** | |
922 | Returns item rect. | |
923 | */ | |
fadc2df6 FM |
924 | virtual wxRect GetItemRect(const wxDataViewItem& item, |
925 | const wxDataViewColumn* col = NULL) const; | |
23324ae1 FM |
926 | |
927 | /** | |
c4e57202 | 928 | Returns pointer to the data model associated with the control (if any). |
23324ae1 | 929 | */ |
adaaa686 | 930 | wxDataViewModel* GetModel(); |
23324ae1 FM |
931 | |
932 | /** | |
933 | Returns first selected item or an invalid item if none is selected. | |
934 | */ | |
adaaa686 | 935 | virtual wxDataViewItem GetSelection() const; |
23324ae1 FM |
936 | |
937 | /** | |
c4e57202 | 938 | Fills @a sel with currently selected items and returns their number. |
23324ae1 | 939 | */ |
adaaa686 | 940 | virtual int GetSelections(wxDataViewItemArray& sel) const; |
23324ae1 FM |
941 | |
942 | /** | |
943 | Returns the wxDataViewColumn currently responsible for sorting | |
944 | or @NULL if none has been selected. | |
945 | */ | |
328f5751 | 946 | virtual wxDataViewColumn* GetSortingColumn() const; |
23324ae1 FM |
947 | |
948 | /** | |
949 | Hittest. | |
950 | */ | |
fadc2df6 FM |
951 | virtual void HitTest(const wxPoint& point, wxDataViewItem& item, |
952 | wxDataViewColumn*& col) const; | |
23324ae1 | 953 | |
739a8399 RR |
954 | /** |
955 | Return @true if the item is expanded. | |
739a8399 RR |
956 | */ |
957 | virtual bool IsExpanded(const wxDataViewItem& item) const; | |
958 | ||
23324ae1 FM |
959 | /** |
960 | Return @true if the item is selected. | |
961 | */ | |
adaaa686 | 962 | virtual bool IsSelected(const wxDataViewItem& item) const; |
23324ae1 FM |
963 | |
964 | /** | |
965 | Select the given item. | |
966 | */ | |
adaaa686 | 967 | virtual void Select(const wxDataViewItem& item); |
23324ae1 FM |
968 | |
969 | /** | |
970 | Select all items. | |
971 | */ | |
adaaa686 | 972 | virtual void SelectAll(); |
23324ae1 FM |
973 | |
974 | /** | |
975 | Set which column shall contain the tree-like expanders. | |
976 | */ | |
4cc4bfaf | 977 | void SetExpanderColumn(wxDataViewColumn* col); |
23324ae1 FM |
978 | |
979 | /** | |
980 | Sets the indendation. | |
981 | */ | |
982 | void SetIndent(int indent); | |
983 | ||
984 | /** | |
985 | Sets the selection to the array of wxDataViewItems. | |
986 | */ | |
adaaa686 | 987 | virtual void SetSelections(const wxDataViewItemArray& sel); |
23324ae1 FM |
988 | |
989 | /** | |
990 | Unselect the given item. | |
991 | */ | |
adaaa686 | 992 | virtual void Unselect(const wxDataViewItem& item); |
23324ae1 FM |
993 | |
994 | /** | |
c4e57202 FM |
995 | Unselect all item. |
996 | This method only has effect if multiple selections are allowed. | |
23324ae1 | 997 | */ |
adaaa686 | 998 | virtual void UnselectAll(); |
23324ae1 FM |
999 | }; |
1000 | ||
1001 | ||
e54c96f1 | 1002 | |
23324ae1 FM |
1003 | /** |
1004 | @class wxDataViewModelNotifier | |
7c913512 | 1005 | |
c4e57202 FM |
1006 | A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors |
1007 | its notification interface. | |
1008 | See the documentation of that class for further information. | |
7c913512 | 1009 | |
8ed522d9 | 1010 | @library{wxadv} |
b321b61c | 1011 | @category{dvc} |
23324ae1 | 1012 | */ |
7c913512 | 1013 | class wxDataViewModelNotifier |
23324ae1 FM |
1014 | { |
1015 | public: | |
1016 | /** | |
1017 | Constructor. | |
1018 | */ | |
1019 | wxDataViewModelNotifier(); | |
1020 | ||
1021 | /** | |
1022 | Destructor. | |
1023 | */ | |
adaaa686 | 1024 | virtual ~wxDataViewModelNotifier(); |
23324ae1 FM |
1025 | |
1026 | /** | |
1027 | Called by owning model. | |
1028 | */ | |
b91c4601 | 1029 | virtual bool Cleared() = 0; |
23324ae1 FM |
1030 | |
1031 | /** | |
1032 | Get owning wxDataViewModel. | |
1033 | */ | |
e51bf699 | 1034 | wxDataViewModel* GetOwner() const; |
23324ae1 FM |
1035 | |
1036 | /** | |
1037 | Called by owning model. | |
1038 | */ | |
fadc2df6 FM |
1039 | virtual bool ItemAdded(const wxDataViewItem& parent, |
1040 | const wxDataViewItem& item) = 0; | |
23324ae1 FM |
1041 | |
1042 | /** | |
1043 | Called by owning model. | |
1044 | */ | |
b91c4601 | 1045 | virtual bool ItemChanged(const wxDataViewItem& item) = 0; |
23324ae1 FM |
1046 | |
1047 | /** | |
1048 | Called by owning model. | |
1049 | */ | |
fadc2df6 FM |
1050 | virtual bool ItemDeleted(const wxDataViewItem& parent, |
1051 | const wxDataViewItem& item) = 0; | |
23324ae1 FM |
1052 | |
1053 | /** | |
1054 | Called by owning model. | |
1055 | */ | |
fadc2df6 FM |
1056 | virtual bool ItemsAdded(const wxDataViewItem& parent, |
1057 | const wxDataViewItemArray& items); | |
23324ae1 FM |
1058 | |
1059 | /** | |
1060 | Called by owning model. | |
1061 | */ | |
adaaa686 | 1062 | virtual bool ItemsChanged(const wxDataViewItemArray& items); |
23324ae1 FM |
1063 | |
1064 | /** | |
1065 | Called by owning model. | |
1066 | */ | |
fadc2df6 FM |
1067 | virtual bool ItemsDeleted(const wxDataViewItem& parent, |
1068 | const wxDataViewItemArray& items); | |
23324ae1 FM |
1069 | |
1070 | /** | |
1071 | Called by owning model. | |
1072 | */ | |
b91c4601 | 1073 | virtual void Resort() = 0; |
23324ae1 FM |
1074 | |
1075 | /** | |
1076 | Set owner of this notifier. Used internally. | |
1077 | */ | |
1078 | void SetOwner(wxDataViewModel* owner); | |
1079 | ||
1080 | /** | |
1081 | Called by owning model. | |
1082 | */ | |
b91c4601 | 1083 | virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0; |
23324ae1 FM |
1084 | }; |
1085 | ||
1086 | ||
c4e57202 FM |
1087 | /** |
1088 | The mode of a data-view cell; see wxDataViewRenderer for more info. | |
1089 | */ | |
1090 | enum wxDataViewCellMode | |
1091 | { | |
1092 | wxDATAVIEW_CELL_INERT, | |
1093 | ||
1094 | /** | |
1095 | Indicates that the user can double click the cell and something will | |
1096 | happen (e.g. a window for editing a date will pop up). | |
1097 | */ | |
1098 | wxDATAVIEW_CELL_ACTIVATABLE, | |
1099 | ||
1100 | /** | |
1101 | Indicates that the user can edit the data in-place, i.e. an control | |
1102 | will show up after a slow click on the cell. This behaviour is best | |
1103 | known from changing the filename in most file managers etc. | |
1104 | */ | |
1105 | wxDATAVIEW_CELL_EDITABLE | |
1106 | }; | |
1107 | ||
1108 | /** | |
1109 | The values of this enum controls how a wxDataViewRenderer should display | |
1110 | its contents in a cell. | |
1111 | */ | |
1112 | enum wxDataViewCellRenderState | |
1113 | { | |
1114 | wxDATAVIEW_CELL_SELECTED = 1, | |
1115 | wxDATAVIEW_CELL_PRELIT = 2, | |
1116 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
1117 | wxDATAVIEW_CELL_FOCUSED = 8 | |
1118 | }; | |
e54c96f1 | 1119 | |
23324ae1 FM |
1120 | /** |
1121 | @class wxDataViewRenderer | |
7c913512 | 1122 | |
5b99d5d8 | 1123 | This class is used by wxDataViewCtrl to render the individual cells. |
c4e57202 FM |
1124 | One instance of a renderer class is owned by a wxDataViewColumn. |
1125 | There is a number of ready-to-use renderers provided: | |
1126 | - wxDataViewTextRenderer, | |
c4e57202 FM |
1127 | - wxDataViewIconTextRenderer, |
1128 | - wxDataViewToggleRenderer, | |
1129 | - wxDataViewProgressRenderer, | |
1130 | - wxDataViewBitmapRenderer, | |
1131 | - wxDataViewDateRenderer, | |
1132 | - wxDataViewSpinRenderer. | |
f4fcd648 | 1133 | - wxDataViewChoiceRenderer. |
7c913512 | 1134 | |
23324ae1 FM |
1135 | Additionally, the user can write own renderers by deriving from |
1136 | wxDataViewCustomRenderer. | |
7c913512 | 1137 | |
c4e57202 FM |
1138 | The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted |
1139 | by the constructors respectively controls what actions the cell data allows | |
1140 | and how the renderer should display its contents in a cell. | |
7c913512 | 1141 | |
23324ae1 | 1142 | @library{wxadv} |
b321b61c | 1143 | @category{dvc} |
23324ae1 FM |
1144 | */ |
1145 | class wxDataViewRenderer : public wxObject | |
1146 | { | |
1147 | public: | |
1148 | /** | |
b91c4601 | 1149 | Constructor. |
23324ae1 FM |
1150 | */ |
1151 | wxDataViewRenderer(const wxString& varianttype, | |
1152 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
f2b7492a | 1153 | int align = wxDVR_DEFAULT_ALIGNMENT ); |
23324ae1 | 1154 | |
c937bcac VZ |
1155 | /** |
1156 | Enable or disable replacing parts of the item text with ellipsis to | |
1157 | make it fit the column width. | |
1158 | ||
1159 | This method only makes sense for the renderers working with text, such | |
1160 | as wxDataViewTextRenderer or wxDataViewIconTextRenderer. | |
1161 | ||
1162 | By default wxELLIPSIZE_MIDDLE is used. | |
1163 | ||
1164 | @param mode | |
1165 | Ellipsization mode, use wxELLIPSIZE_NONE to disable. | |
1166 | ||
1167 | @since 2.9.1 | |
1168 | */ | |
1169 | void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE); | |
1170 | ||
1171 | /** | |
1172 | Disable replacing parts of the item text with ellipsis. | |
1173 | ||
1174 | If ellipsizing is disabled, the string will be truncated if it doesn't | |
1175 | fit. | |
1176 | ||
1177 | This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode. | |
1178 | ||
1179 | @since 2.9.1 | |
1180 | */ | |
1181 | void DisableEllipsize(); | |
1182 | ||
20c36737 | 1183 | /** |
f2b7492a | 1184 | Returns the alignment. See SetAlignment() |
20c36737 RR |
1185 | */ |
1186 | virtual int GetAlignment() const; | |
1187 | ||
c937bcac VZ |
1188 | /** |
1189 | Returns the ellipsize mode used by the renderer. | |
1190 | ||
1191 | If the return value is wxELLIPSIZE_NONE, the text is simply truncated | |
1192 | if it doesn't fit. | |
1193 | ||
1194 | @see EnableEllipsize() | |
1195 | */ | |
1196 | wxEllipsizeMode GetEllipsizeMode() const; | |
1197 | ||
23324ae1 FM |
1198 | /** |
1199 | Returns the cell mode. | |
1200 | */ | |
adaaa686 | 1201 | virtual wxDataViewCellMode GetMode() const; |
23324ae1 FM |
1202 | |
1203 | /** | |
1204 | Returns pointer to the owning wxDataViewColumn. | |
1205 | */ | |
adaaa686 | 1206 | wxDataViewColumn* GetOwner() const; |
23324ae1 FM |
1207 | |
1208 | /** | |
1209 | This methods retrieves the value from the renderer in order to | |
c4e57202 FM |
1210 | transfer the value back to the data model. |
1211 | ||
1212 | Returns @false on failure. | |
23324ae1 | 1213 | */ |
b91c4601 | 1214 | virtual bool GetValue(wxVariant& value) const = 0; |
23324ae1 FM |
1215 | |
1216 | /** | |
c4e57202 | 1217 | Returns a string with the type of the wxVariant supported by this renderer. |
23324ae1 | 1218 | */ |
adaaa686 | 1219 | wxString GetVariantType() const; |
23324ae1 | 1220 | |
20c36737 | 1221 | /** |
c4e57202 FM |
1222 | Sets the alignment of the renderer's content. |
1223 | The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content | |
1224 | should have the same alignment as the column header. | |
1225 | ||
1226 | The method is not implemented under OS X and the renderer always aligns | |
1227 | its contents as the column header on that platform. The other platforms | |
f2b7492a | 1228 | support both vertical and horizontal alignment. |
20c36737 RR |
1229 | */ |
1230 | virtual void SetAlignment( int align ); | |
23324ae1 | 1231 | /** |
c4e57202 FM |
1232 | Sets the owning wxDataViewColumn. |
1233 | This is usually called from within wxDataViewColumn. | |
23324ae1 | 1234 | */ |
adaaa686 | 1235 | void SetOwner(wxDataViewColumn* owner); |
23324ae1 FM |
1236 | |
1237 | /** | |
c4e57202 | 1238 | Set the value of the renderer (and thus its cell) to @a value. |
23324ae1 FM |
1239 | The internal code will then render this cell with this data. |
1240 | */ | |
b91c4601 | 1241 | virtual bool SetValue(const wxVariant& value) = 0; |
23324ae1 FM |
1242 | |
1243 | /** | |
1244 | Before data is committed to the data model, it is passed to this | |
1245 | method where it can be checked for validity. This can also be | |
1246 | used for checking a valid range or limiting the user input in | |
1247 | a certain aspect (e.g. max number of characters or only alphanumeric | |
c4e57202 FM |
1248 | input, ASCII only etc.). Return @false if the value is not valid. |
1249 | ||
23324ae1 FM |
1250 | Please note that due to implementation limitations, this validation |
1251 | is done after the editing control already is destroyed and the | |
1252 | editing process finished. | |
1253 | */ | |
1254 | virtual bool Validate(wxVariant& value); | |
1255 | }; | |
1256 | ||
1257 | ||
e54c96f1 | 1258 | |
23324ae1 FM |
1259 | /** |
1260 | @class wxDataViewTextRenderer | |
7c913512 | 1261 | |
c4e57202 FM |
1262 | wxDataViewTextRenderer is used for rendering text. |
1263 | It supports in-place editing if desired. | |
7c913512 | 1264 | |
23324ae1 | 1265 | @library{wxadv} |
b321b61c | 1266 | @category{dvc} |
23324ae1 FM |
1267 | */ |
1268 | class wxDataViewTextRenderer : public wxDataViewRenderer | |
1269 | { | |
1270 | public: | |
1271 | /** | |
c4e57202 | 1272 | The ctor. |
23324ae1 FM |
1273 | */ |
1274 | wxDataViewTextRenderer(const wxString& varianttype = "string", | |
05303ccd RR |
1275 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1276 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1277 | }; |
1278 | ||
1279 | ||
e54c96f1 | 1280 | |
f2b7492a RR |
1281 | /** |
1282 | @class wxDataViewIconTextRenderer | |
f2b7492a RR |
1283 | |
1284 | The wxDataViewIconTextRenderer class is used to display text with | |
1285 | a small icon next to it as it is typically done in a file manager. | |
c4e57202 FM |
1286 | |
1287 | This classes uses the wxDataViewIconText helper class to store its data. | |
4d68a949 BP |
1288 | wxDataViewIconText can be converted to and from a wxVariant using the left |
1289 | shift operator. | |
f2b7492a RR |
1290 | |
1291 | @library{wxadv} | |
b321b61c | 1292 | @category{dvc} |
f2b7492a RR |
1293 | */ |
1294 | class wxDataViewIconTextRenderer : public wxDataViewRenderer | |
1295 | { | |
1296 | public: | |
1297 | /** | |
c4e57202 | 1298 | The ctor. |
f2b7492a RR |
1299 | */ |
1300 | wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText", | |
1301 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
1302 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
1303 | }; | |
1304 | ||
1305 | ||
1306 | ||
23324ae1 FM |
1307 | /** |
1308 | @class wxDataViewProgressRenderer | |
7c913512 | 1309 | |
c4e57202 | 1310 | This class is used by wxDataViewCtrl to render progress bars. |
7c913512 | 1311 | |
23324ae1 | 1312 | @library{wxadv} |
b321b61c | 1313 | @category{dvc} |
23324ae1 FM |
1314 | */ |
1315 | class wxDataViewProgressRenderer : public wxDataViewRenderer | |
1316 | { | |
1317 | public: | |
1318 | /** | |
c4e57202 | 1319 | The ctor. |
23324ae1 FM |
1320 | */ |
1321 | wxDataViewProgressRenderer(const wxString& label = wxEmptyString, | |
1322 | const wxString& varianttype = "long", | |
05303ccd RR |
1323 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1324 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
23324ae1 FM |
1325 | }; |
1326 | ||
1327 | ||
e54c96f1 | 1328 | |
23324ae1 FM |
1329 | /** |
1330 | @class wxDataViewSpinRenderer | |
7c913512 | 1331 | |
c4e57202 FM |
1332 | This is a specialized renderer for rendering integer values. |
1333 | It supports modifying the values in-place by using a wxSpinCtrl. | |
23324ae1 | 1334 | The renderer only support variants of type @e long. |
7c913512 | 1335 | |
8ed522d9 | 1336 | @library{wxadv} |
b321b61c | 1337 | @category{dvc} |
23324ae1 FM |
1338 | */ |
1339 | class wxDataViewSpinRenderer : public wxDataViewCustomRenderer | |
1340 | { | |
1341 | public: | |
1342 | /** | |
c4e57202 FM |
1343 | Constructor. |
1344 | @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl. | |
23324ae1 FM |
1345 | */ |
1346 | wxDataViewSpinRenderer(int min, int max, | |
1347 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
05303ccd | 1348 | int align = wxDVR_DEFAULT_ALIGNMENT); |
23324ae1 FM |
1349 | }; |
1350 | ||
1351 | ||
e54c96f1 | 1352 | |
23324ae1 FM |
1353 | /** |
1354 | @class wxDataViewToggleRenderer | |
7c913512 | 1355 | |
c4e57202 | 1356 | This class is used by wxDataViewCtrl to render toggle controls. |
7c913512 | 1357 | |
23324ae1 | 1358 | @library{wxadv} |
b321b61c | 1359 | @category{dvc} |
23324ae1 FM |
1360 | */ |
1361 | class wxDataViewToggleRenderer : public wxDataViewRenderer | |
1362 | { | |
1363 | public: | |
1364 | /** | |
c4e57202 | 1365 | The ctor. |
23324ae1 FM |
1366 | */ |
1367 | wxDataViewToggleRenderer(const wxString& varianttype = "bool", | |
50ec54b6 FM |
1368 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
1369 | int align = wxDVR_DEFAULT_ALIGNMENT); | |
23324ae1 FM |
1370 | }; |
1371 | ||
1372 | ||
f4fcd648 RR |
1373 | /** |
1374 | @class wxDataViewChoiceRenderer | |
1375 | ||
1376 | This class is used by wxDataViewCtrl to render choice controls. | |
1377 | It stores a string so that SetValue() and GetValue() operate | |
1378 | on a variant holding a string. | |
1379 | ||
1380 | @library{wxadv} | |
1381 | @category{dvc} | |
1382 | */ | |
1383 | ||
1384 | class wxDataViewChoiceRenderer: public wxDataViewRenderer | |
1385 | { | |
1386 | public: | |
1387 | /** | |
1388 | The ctor. | |
1389 | */ | |
1390 | wxDataViewChoiceRenderer( const wxArrayString &choices, | |
1391 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
1392 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
1393 | ||
1394 | /** | |
1395 | Returns the choice referred to by index. | |
1396 | */ | |
1397 | wxString GetChoice(size_t index) const; | |
1398 | ||
1399 | /** | |
1400 | Returns all choices. | |
1401 | */ | |
1402 | const wxArrayString& GetChoices() const; | |
1403 | }; | |
1404 | ||
e54c96f1 | 1405 | |
23324ae1 | 1406 | /** |
5b99d5d8 | 1407 | @class wxDataViewDateRenderer |
7c913512 | 1408 | |
c4e57202 | 1409 | This class is used by wxDataViewCtrl to render calendar controls. |
7c913512 | 1410 | |
5b99d5d8 | 1411 | @library{wxadv} |
b321b61c | 1412 | @category{dvc} |
23324ae1 | 1413 | */ |
5b99d5d8 | 1414 | class wxDataViewDateRenderer : public wxDataViewRenderer |
23324ae1 FM |
1415 | { |
1416 | public: | |
23324ae1 | 1417 | /** |
c4e57202 | 1418 | The ctor. |
23324ae1 | 1419 | */ |
5b99d5d8 | 1420 | wxDataViewDateRenderer(const wxString& varianttype = "datetime", |
50ec54b6 FM |
1421 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
1422 | int align = wxDVR_DEFAULT_ALIGNMENT); | |
5b99d5d8 | 1423 | }; |
23324ae1 | 1424 | |
3c4f71cc | 1425 | |
23324ae1 | 1426 | |
5b99d5d8 RR |
1427 | /** |
1428 | @class wxDataViewCustomRenderer | |
23324ae1 | 1429 | |
5b99d5d8 | 1430 | You need to derive a new class from wxDataViewCustomRenderer in |
c4e57202 FM |
1431 | order to write a new renderer. |
1432 | ||
1433 | You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue, | |
1434 | wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render. | |
1435 | ||
1436 | If you want your renderer to support in-place editing then you also need to override | |
1437 | wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl | |
5b99d5d8 | 1438 | and wxDataViewCustomRenderer::GetValueFromEditorCtrl. |
c4e57202 FM |
1439 | |
1440 | Note that a special event handler will be pushed onto that editor control | |
1441 | which handles @e \<ENTER\> and focus out events in order to end the editing. | |
23324ae1 | 1442 | |
5b99d5d8 | 1443 | @library{wxadv} |
b321b61c | 1444 | @category{dvc} |
5b99d5d8 RR |
1445 | */ |
1446 | class wxDataViewCustomRenderer : public wxDataViewRenderer | |
1447 | { | |
1448 | public: | |
23324ae1 | 1449 | /** |
5b99d5d8 | 1450 | Constructor. |
23324ae1 | 1451 | */ |
5b99d5d8 RR |
1452 | wxDataViewCustomRenderer(const wxString& varianttype = "string", |
1453 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
b91c4601 | 1454 | int align = -1, bool no_init = false); |
23324ae1 FM |
1455 | |
1456 | /** | |
5b99d5d8 | 1457 | Destructor. |
23324ae1 | 1458 | */ |
adaaa686 | 1459 | virtual ~wxDataViewCustomRenderer(); |
23324ae1 | 1460 | |
23324ae1 | 1461 | /** |
c4e57202 FM |
1462 | Override this to react to double clicks or ENTER. |
1463 | This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE mode. | |
23324ae1 | 1464 | */ |
5b99d5d8 RR |
1465 | virtual bool Activate( wxRect cell, |
1466 | wxDataViewModel* model, | |
1467 | const wxDataViewItem & item, | |
1468 | unsigned int col ); | |
23324ae1 FM |
1469 | |
1470 | /** | |
5b99d5d8 | 1471 | Override this to create the actual editor control once editing |
c4e57202 FM |
1472 | is about to start. |
1473 | ||
1474 | @a parent is the parent of the editor control, @a labelRect indicates the | |
1475 | position and size of the editor control and @a value is its initial value: | |
1476 | @code | |
1477 | { | |
1478 | long l = value; | |
1479 | return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString, | |
1480 | labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l ); | |
1481 | } | |
1482 | @endcode | |
23324ae1 | 1483 | */ |
5b99d5d8 RR |
1484 | virtual wxControl* CreateEditorCtrl(wxWindow* parent, |
1485 | wxRect labelRect, | |
1486 | const wxVariant& value); | |
23324ae1 FM |
1487 | |
1488 | /** | |
62265c2c VZ |
1489 | Return the attribute to be used for rendering. |
1490 | ||
1491 | This function may be called from Render() implementation to use the | |
1492 | attributes defined for the item if the renderer supports them. | |
1493 | ||
1494 | Notice that when Render() is called, the wxDC object passed to it is | |
1495 | already set up to use the correct attributes (e.g. its font is set to | |
1496 | bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic() | |
1497 | returns true) so it may not be necessary to call it explicitly if you | |
1498 | only want to render text using the items attributes. | |
1499 | ||
1500 | @since 2.9.1 | |
1501 | */ | |
1502 | const wxDataViewItemAttr& GetAttr() const; | |
23324ae1 FM |
1503 | |
1504 | /** | |
5b99d5d8 | 1505 | Return size required to show content. |
23324ae1 | 1506 | */ |
b91c4601 | 1507 | virtual wxSize GetSize() const = 0; |
23324ae1 FM |
1508 | |
1509 | /** | |
80093617 | 1510 | Override this so that the renderer can get the value from the editor |
c4e57202 FM |
1511 | control (pointed to by @a editor): |
1512 | @code | |
1513 | { | |
1514 | wxSpinCtrl *sc = (wxSpinCtrl*) editor; | |
1515 | long l = sc->GetValue(); | |
1516 | value = l; | |
1517 | return true; | |
1518 | } | |
1519 | @endcode | |
23324ae1 | 1520 | */ |
5b99d5d8 RR |
1521 | virtual bool GetValueFromEditorCtrl(wxControl* editor, |
1522 | wxVariant& value); | |
23324ae1 FM |
1523 | |
1524 | /** | |
c4e57202 | 1525 | Override this and make it return @true in order to |
5b99d5d8 | 1526 | indicate that this renderer supports in-place editing. |
23324ae1 | 1527 | */ |
220bfe15 | 1528 | virtual bool HasEditorCtrl() const; |
23324ae1 FM |
1529 | |
1530 | /** | |
80093617 | 1531 | Override this to react to a left click. |
c4e57202 | 1532 | This method will only be called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. |
23324ae1 | 1533 | */ |
5b99d5d8 RR |
1534 | virtual bool LeftClick( wxPoint cursor, |
1535 | wxRect cell, | |
1536 | wxDataViewModel * model, | |
1537 | const wxDataViewItem & item, | |
1538 | unsigned int col ); | |
23324ae1 FM |
1539 | |
1540 | /** | |
c4e57202 FM |
1541 | Override this to render the cell. |
1542 | Before this is called, wxDataViewRenderer::SetValue was called | |
5b99d5d8 | 1543 | so that this instance knows what to render. |
23324ae1 | 1544 | */ |
b91c4601 | 1545 | virtual bool Render(wxRect cell, wxDC* dc, int state) = 0; |
23324ae1 FM |
1546 | |
1547 | /** | |
c4e57202 FM |
1548 | This method should be called from within Render() whenever you need to |
1549 | render simple text. | |
1550 | This will ensure that the correct colour, font and vertical alignment will | |
1551 | be chosen so the text will look the same as text drawn by native renderers. | |
23324ae1 | 1552 | */ |
50ec54b6 | 1553 | void RenderText(const wxString& text, int xoffset, wxRect cell, |
5b99d5d8 | 1554 | wxDC* dc, int state); |
23324ae1 FM |
1555 | |
1556 | /** | |
80093617 | 1557 | Override this to start a drag operation. Not yet supported. |
23324ae1 | 1558 | */ |
5b99d5d8 RR |
1559 | virtual bool StartDrag(wxPoint cursor, wxRect cell, |
1560 | wxDataViewModel* model, | |
1561 | const wxDataViewItem & item, | |
1562 | unsigned int col); | |
23324ae1 FM |
1563 | }; |
1564 | ||
1565 | ||
e54c96f1 | 1566 | |
23324ae1 | 1567 | /** |
5b99d5d8 | 1568 | @class wxDataViewBitmapRenderer |
7c913512 | 1569 | |
c4e57202 | 1570 | This class is used by wxDataViewCtrl to render bitmap controls. |
7c913512 | 1571 | |
23324ae1 | 1572 | @library{wxadv} |
b321b61c | 1573 | @category{dvc} |
23324ae1 | 1574 | */ |
5b99d5d8 | 1575 | class wxDataViewBitmapRenderer : public wxDataViewRenderer |
23324ae1 FM |
1576 | { |
1577 | public: | |
1578 | /** | |
c4e57202 | 1579 | The ctor. |
23324ae1 | 1580 | */ |
5b99d5d8 RR |
1581 | wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap", |
1582 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
14d922d1 | 1583 | int align = wxDVR_DEFAULT_ALIGNMENT); |
5b99d5d8 RR |
1584 | }; |
1585 | ||
23324ae1 | 1586 | |
c4e57202 FM |
1587 | /** |
1588 | The flags used by wxDataViewColumn. | |
02b51ae5 | 1589 | Can be combined together. |
c4e57202 FM |
1590 | */ |
1591 | enum wxDataViewColumnFlags | |
1592 | { | |
1593 | wxDATAVIEW_COL_RESIZABLE = 1, | |
1594 | wxDATAVIEW_COL_SORTABLE = 2, | |
1595 | wxDATAVIEW_COL_REORDERABLE = 4, | |
1596 | wxDATAVIEW_COL_HIDDEN = 8 | |
1597 | }; | |
23324ae1 | 1598 | |
5b99d5d8 RR |
1599 | /** |
1600 | @class wxDataViewColumn | |
5b99d5d8 RR |
1601 | |
1602 | This class represents a column in a wxDataViewCtrl. | |
739a8399 | 1603 | One wxDataViewColumn is bound to one column in the data model to which the |
c4e57202 | 1604 | wxDataViewCtrl has been associated. |
5b99d5d8 | 1605 | |
c4e57202 | 1606 | An instance of wxDataViewRenderer is used by this class to render its data. |
5b99d5d8 RR |
1607 | |
1608 | @library{wxadv} | |
b321b61c | 1609 | @category{dvc} |
5b99d5d8 | 1610 | */ |
c9c59db7 | 1611 | class wxDataViewColumn : public wxSettableHeaderColumn |
5b99d5d8 RR |
1612 | { |
1613 | public: | |
23324ae1 | 1614 | /** |
02b51ae5 FM |
1615 | Constructs a text column. |
1616 | ||
1617 | @param title | |
1618 | The title of the column. | |
1619 | @param renderer | |
1620 | The class which will render the contents of this column. | |
1621 | @param model_column | |
1622 | The index of the model's column which is associated with this object. | |
1623 | @param width | |
1624 | The width of the column. | |
1625 | The @c wxDVC_DEFAULT_WIDTH value is the fixed default value. | |
1626 | @param align | |
1627 | The alignment of the column title. | |
1628 | @param flags | |
1629 | One or more flags of the ::wxDataViewColumnFlags enumeration. | |
23324ae1 | 1630 | */ |
5b99d5d8 RR |
1631 | wxDataViewColumn(const wxString& title, |
1632 | wxDataViewRenderer* renderer, | |
1633 | unsigned int model_column, | |
1634 | int width = wxDVC_DEFAULT_WIDTH, | |
882678eb | 1635 | wxAlignment align = wxALIGN_CENTER, |
5b99d5d8 | 1636 | int flags = wxDATAVIEW_COL_RESIZABLE); |
02b51ae5 FM |
1637 | |
1638 | /** | |
1639 | Constructs a bitmap column. | |
1640 | ||
1641 | @param bitmap | |
1642 | The bitmap of the column. | |
1643 | @param renderer | |
1644 | The class which will render the contents of this column. | |
1645 | @param model_column | |
1646 | The index of the model's column which is associated with this object. | |
1647 | @param width | |
1648 | The width of the column. | |
1649 | The @c wxDVC_DEFAULT_WIDTH value is the fixed default value. | |
1650 | @param align | |
1651 | The alignment of the column title. | |
1652 | @param flags | |
1653 | One or more flags of the ::wxDataViewColumnFlags enumeration. | |
1654 | */ | |
5b99d5d8 RR |
1655 | wxDataViewColumn(const wxBitmap& bitmap, |
1656 | wxDataViewRenderer* renderer, | |
1657 | unsigned int model_column, | |
1658 | int width = wxDVC_DEFAULT_WIDTH, | |
882678eb | 1659 | wxAlignment align = wxALIGN_CENTER, |
5b99d5d8 | 1660 | int flags = wxDATAVIEW_COL_RESIZABLE); |
23324ae1 | 1661 | |
23324ae1 | 1662 | /** |
5b99d5d8 RR |
1663 | Returns the index of the column of the model, which this |
1664 | wxDataViewColumn is displaying. | |
23324ae1 | 1665 | */ |
adaaa686 | 1666 | unsigned int GetModelColumn() const; |
23324ae1 FM |
1667 | |
1668 | /** | |
5b99d5d8 | 1669 | Returns the owning wxDataViewCtrl. |
23324ae1 | 1670 | */ |
e51bf699 | 1671 | wxDataViewCtrl* GetOwner() const; |
23324ae1 FM |
1672 | |
1673 | /** | |
5b99d5d8 | 1674 | Returns the renderer of this wxDataViewColumn. |
c4e57202 FM |
1675 | |
1676 | @see wxDataViewRenderer. | |
23324ae1 | 1677 | */ |
adaaa686 | 1678 | wxDataViewRenderer* GetRenderer() const; |
23324ae1 FM |
1679 | }; |
1680 | ||
1681 | ||
e54c96f1 | 1682 | |
832df171 RR |
1683 | /** |
1684 | @class wxDataViewListCtrl | |
1685 | ||
1686 | This class is a wxDataViewCtrl which internally uses a wxDataViewListStore | |
1687 | and forwards most of its API to that class. | |
1688 | ||
1689 | The purpose of this class is to offer a simple way to display and | |
1690 | edit a small table of data without having to write your own wxDataViewModel. | |
1691 | ||
23efa4bf | 1692 | @code |
14f73cf1 | 1693 | wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY ); |
02b51ae5 | 1694 | |
95b20f41 RR |
1695 | listctrl->AppendToggleColumn( "Toggle" ); |
1696 | listctrl->AppendTextColumn( "Text" ); | |
02b51ae5 | 1697 | |
23efa4bf | 1698 | wxVector<wxVariant> data; |
14f73cf1 FM |
1699 | data.push_back( wxVariant(true) ); |
1700 | data.push_back( wxVariant("row 1") ); | |
23efa4bf | 1701 | listctrl->AppendItem( data ); |
02b51ae5 | 1702 | |
23efa4bf | 1703 | data.clear(); |
14f73cf1 FM |
1704 | data.push_back( wxVariant(false) ); |
1705 | data.push_back( wxVariant("row 3") ); | |
23efa4bf RR |
1706 | listctrl->AppendItem( data ); |
1707 | @endcode | |
43c64cc6 | 1708 | |
14f73cf1 FM |
1709 | @beginStyleTable |
1710 | See wxDataViewCtrl for the list of supported styles. | |
1711 | @endStyleTable | |
43c64cc6 | 1712 | |
14f73cf1 FM |
1713 | @beginEventEmissionTable |
1714 | See wxDataViewCtrl for the list of events emitted by this class. | |
1715 | @endEventTable | |
23efa4bf | 1716 | |
832df171 RR |
1717 | @library{wxadv} |
1718 | @category{ctrl,dvc} | |
1719 | */ | |
832df171 RR |
1720 | class wxDataViewListCtrl: public wxDataViewCtrl |
1721 | { | |
b75b04d4 | 1722 | public: |
832df171 RR |
1723 | /** |
1724 | Default ctor. | |
1725 | */ | |
1726 | wxDataViewListCtrl(); | |
02b51ae5 | 1727 | |
832df171 RR |
1728 | /** |
1729 | Constructor. Calls Create(). | |
1730 | */ | |
1731 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
1732 | const wxPoint& pos = wxDefaultPosition, | |
1733 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1734 | const wxValidator& validator = wxDefaultValidator ); | |
02b51ae5 | 1735 | |
832df171 RR |
1736 | /** |
1737 | Destructor. Deletes the image list if any. | |
1738 | */ | |
1739 | ~wxDataViewListCtrl(); | |
1740 | ||
1741 | /** | |
1742 | Creates the control and a wxDataViewListStore as its internal model. | |
1743 | */ | |
1744 | bool Create( wxWindow *parent, wxWindowID id, | |
1745 | const wxPoint& pos = wxDefaultPosition, | |
1746 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1747 | const wxValidator& validator = wxDefaultValidator ); | |
1748 | ||
1749 | //@{ | |
1750 | /** | |
1751 | Returns the store. | |
1752 | */ | |
1753 | wxDataViewListStore *GetStore(); | |
1754 | const wxDataViewListStore *GetStore() const; | |
1755 | //@} | |
1756 | ||
1757 | /** | |
14f73cf1 FM |
1758 | @name Column management functions |
1759 | */ | |
1760 | //@{ | |
43c64cc6 | 1761 | |
14f73cf1 FM |
1762 | /** |
1763 | Appends a column to the control and additionally appends a | |
1764 | column to the store with the type string. | |
1765 | */ | |
1766 | virtual void AppendColumn( wxDataViewColumn *column ); | |
1767 | ||
1768 | /** | |
1769 | Appends a column to the control and additionally appends a | |
1770 | column to the list store with the type @a varianttype. | |
832df171 | 1771 | */ |
95b20f41 | 1772 | void AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
02b51ae5 | 1773 | |
832df171 | 1774 | /** |
14f73cf1 | 1775 | Appends a text column to the control and the store. |
43c64cc6 | 1776 | |
14f73cf1 FM |
1777 | See wxDataViewColumn::wxDataViewColumn for more info about |
1778 | the parameters. | |
832df171 | 1779 | */ |
14f73cf1 FM |
1780 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
1781 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 1782 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 1783 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 1784 | |
832df171 | 1785 | /** |
14f73cf1 | 1786 | Appends a toggle column to the control and the store. |
43c64cc6 | 1787 | |
14f73cf1 FM |
1788 | See wxDataViewColumn::wxDataViewColumn for more info about |
1789 | the parameters. | |
832df171 | 1790 | */ |
14f73cf1 FM |
1791 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
1792 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
43c64cc6 | 1793 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 1794 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 1795 | |
95b20f41 | 1796 | /** |
14f73cf1 | 1797 | Appends a progress column to the control and the store. |
02b51ae5 | 1798 | |
14f73cf1 FM |
1799 | See wxDataViewColumn::wxDataViewColumn for more info about |
1800 | the parameters. | |
95b20f41 | 1801 | */ |
14f73cf1 FM |
1802 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
1803 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 1804 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 1805 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 1806 | |
95b20f41 | 1807 | /** |
14f73cf1 | 1808 | Appends an icon-and-text column to the control and the store. |
02b51ae5 | 1809 | |
14f73cf1 FM |
1810 | See wxDataViewColumn::wxDataViewColumn for more info about |
1811 | the parameters. | |
95b20f41 | 1812 | */ |
14f73cf1 FM |
1813 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
1814 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
43c64cc6 | 1815 | int width = -1, wxAlignment align = wxALIGN_LEFT, |
14f73cf1 | 1816 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
02b51ae5 | 1817 | |
95b20f41 | 1818 | /** |
14f73cf1 | 1819 | Inserts a column to the control and additionally inserts a |
95b20f41 RR |
1820 | column to the store with the type string. |
1821 | */ | |
1822 | virtual void InsertColumn( unsigned int pos, wxDataViewColumn *column ); | |
02b51ae5 | 1823 | |
832df171 | 1824 | /** |
14f73cf1 FM |
1825 | Inserts a column to the control and additionally inserts a |
1826 | column to the list store with the type @a varianttype. | |
832df171 | 1827 | */ |
43c64cc6 | 1828 | void InsertColumn( unsigned int pos, wxDataViewColumn *column, |
14f73cf1 | 1829 | const wxString &varianttype ); |
02b51ae5 | 1830 | |
832df171 | 1831 | /** |
14f73cf1 FM |
1832 | Prepends a column to the control and additionally prepends a |
1833 | column to the store with the type string. | |
832df171 | 1834 | */ |
14f73cf1 | 1835 | virtual void PrependColumn( wxDataViewColumn *column ); |
02b51ae5 | 1836 | |
832df171 | 1837 | /** |
14f73cf1 FM |
1838 | Prepends a column to the control and additionally prepends a |
1839 | column to the list store with the type @a varianttype. | |
832df171 | 1840 | */ |
14f73cf1 | 1841 | void PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); |
02b51ae5 | 1842 | |
14f73cf1 | 1843 | //@} |
43c64cc6 VZ |
1844 | |
1845 | ||
832df171 | 1846 | /** |
14f73cf1 | 1847 | @name Item management functions |
832df171 | 1848 | */ |
14f73cf1 | 1849 | //@{ |
43c64cc6 | 1850 | |
832df171 RR |
1851 | /** |
1852 | Appends an item (=row) to the control and store. | |
1853 | */ | |
1854 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
1855 | ||
1856 | /** | |
1857 | Prepends an item (=row) to the control and store. | |
1858 | */ | |
1859 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
1860 | ||
1861 | /** | |
1862 | Inserts an item (=row) to the control and store. | |
1863 | */ | |
14f73cf1 | 1864 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); |
02b51ae5 | 1865 | |
832df171 RR |
1866 | /** |
1867 | Delete the row at position @a row. | |
1868 | */ | |
1869 | void DeleteItem( unsigned row ); | |
02b51ae5 | 1870 | |
832df171 RR |
1871 | /** |
1872 | Delete all items (= all rows). | |
1873 | */ | |
1874 | void DeleteAllItems(); | |
02b51ae5 | 1875 | |
832df171 RR |
1876 | /** |
1877 | Sets the value in the store and update the control. | |
1878 | */ | |
1879 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 1880 | |
832df171 RR |
1881 | /** |
1882 | Returns the value from the store. | |
1883 | */ | |
1884 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 1885 | |
832df171 | 1886 | /** |
02b51ae5 FM |
1887 | Sets the value in the store and update the control. |
1888 | ||
832df171 RR |
1889 | This method assumes that the a string is stored in respective |
1890 | column. | |
1891 | */ | |
1892 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ); | |
02b51ae5 | 1893 | |
832df171 RR |
1894 | /** |
1895 | Returns the value from the store. | |
02b51ae5 | 1896 | |
832df171 RR |
1897 | This method assumes that the a string is stored in respective |
1898 | column. | |
1899 | */ | |
1900 | wxString GetTextValue( unsigned int row, unsigned int col ) const; | |
02b51ae5 | 1901 | |
832df171 | 1902 | /** |
02b51ae5 FM |
1903 | Sets the value in the store and update the control. |
1904 | ||
832df171 RR |
1905 | This method assumes that the a boolean value is stored in |
1906 | respective column. | |
1907 | */ | |
1908 | void SetToggleValue( bool value, unsigned int row, unsigned int col ); | |
02b51ae5 | 1909 | |
832df171 RR |
1910 | /** |
1911 | Returns the value from the store. | |
02b51ae5 | 1912 | |
832df171 RR |
1913 | This method assumes that the a boolean value is stored in |
1914 | respective column. | |
1915 | */ | |
1916 | bool GetToggleValue( unsigned int row, unsigned int col ) const; | |
43c64cc6 | 1917 | |
14f73cf1 | 1918 | //@} |
832df171 RR |
1919 | }; |
1920 | ||
1921 | ||
23324ae1 | 1922 | /** |
5b99d5d8 | 1923 | @class wxDataViewTreeCtrl |
7c913512 | 1924 | |
c4e57202 FM |
1925 | This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore |
1926 | and forwards most of its API to that class. | |
1927 | Additionally, it uses a wxImageList to store a list of icons. | |
1928 | ||
43c64cc6 VZ |
1929 | The main purpose of this class is to provide a simple upgrade path for code |
1930 | using wxTreeCtrl. | |
14f73cf1 FM |
1931 | |
1932 | @beginStyleTable | |
1933 | See wxDataViewCtrl for the list of supported styles. | |
1934 | @endStyleTable | |
43c64cc6 | 1935 | |
14f73cf1 FM |
1936 | @beginEventEmissionTable |
1937 | See wxDataViewCtrl for the list of events emitted by this class. | |
1938 | @endEventTable | |
7c913512 | 1939 | |
8ed522d9 | 1940 | @library{wxadv} |
b321b61c | 1941 | @category{ctrl,dvc} |
7e59b885 | 1942 | @appearance{dataviewtreectrl.png} |
23324ae1 | 1943 | */ |
5b99d5d8 | 1944 | class wxDataViewTreeCtrl : public wxDataViewCtrl |
23324ae1 FM |
1945 | { |
1946 | public: | |
1947 | /** | |
c4e57202 | 1948 | Default ctor. |
5b99d5d8 RR |
1949 | */ |
1950 | wxDataViewTreeCtrl(); | |
c4e57202 FM |
1951 | |
1952 | /** | |
43c64cc6 VZ |
1953 | Constructor. |
1954 | ||
1955 | Calls Create(). | |
c4e57202 | 1956 | */ |
5b99d5d8 RR |
1957 | wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id, |
1958 | const wxPoint& pos = wxDefaultPosition, | |
1959 | const wxSize& size = wxDefaultSize, | |
43c64cc6 | 1960 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
5b99d5d8 | 1961 | const wxValidator& validator = wxDefaultValidator); |
3c4f71cc | 1962 | |
5b99d5d8 RR |
1963 | /** |
1964 | Destructor. Deletes the image list if any. | |
23324ae1 | 1965 | */ |
adaaa686 | 1966 | virtual ~wxDataViewTreeCtrl(); |
23324ae1 | 1967 | |
5b99d5d8 | 1968 | /** |
b75b04d4 | 1969 | Appends a container to the given @a parent. |
5b99d5d8 RR |
1970 | */ |
1971 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
1972 | const wxString& text, | |
1973 | int icon = -1, | |
1974 | int expanded = -1, | |
1975 | wxClientData* data = NULL); | |
e54c96f1 | 1976 | |
5b99d5d8 | 1977 | /** |
b75b04d4 | 1978 | Appends an item to the given @a parent. |
5b99d5d8 RR |
1979 | */ |
1980 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
1981 | const wxString& text, | |
1982 | int icon = -1, | |
1983 | wxClientData* data = NULL); | |
7c913512 | 1984 | |
5b99d5d8 | 1985 | /** |
c4e57202 | 1986 | Creates the control and a wxDataViewTreeStore as its internal model. |
43c64cc6 VZ |
1987 | |
1988 | The default tree column created by this method is an editable column | |
1989 | using wxDataViewIconTextRenderer as its renderer. | |
5b99d5d8 RR |
1990 | */ |
1991 | bool Create(wxWindow* parent, wxWindowID id, | |
1992 | const wxPoint& pos = wxDefaultPosition, | |
1993 | const wxSize& size = wxDefaultSize, | |
43c64cc6 | 1994 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
5b99d5d8 RR |
1995 | const wxValidator& validator = wxDefaultValidator); |
1996 | ||
1997 | /** | |
1998 | Calls the identical method from wxDataViewTreeStore. | |
1999 | */ | |
2000 | void DeleteAllItems(); | |
7c913512 | 2001 | |
23324ae1 | 2002 | /** |
5b99d5d8 RR |
2003 | Calls the identical method from wxDataViewTreeStore. |
2004 | */ | |
2005 | void DeleteChildren(const wxDataViewItem& item); | |
3c4f71cc | 2006 | |
5b99d5d8 RR |
2007 | /** |
2008 | Calls the identical method from wxDataViewTreeStore. | |
23324ae1 | 2009 | */ |
5b99d5d8 | 2010 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 | 2011 | |
5b99d5d8 RR |
2012 | /** |
2013 | Calls the identical method from wxDataViewTreeStore. | |
2014 | */ | |
2015 | int GetChildCount(const wxDataViewItem& parent) const; | |
23324ae1 | 2016 | |
5b99d5d8 RR |
2017 | /** |
2018 | Returns the image list. | |
2019 | */ | |
2020 | wxImageList* GetImageList(); | |
05303ccd | 2021 | |
5b99d5d8 RR |
2022 | /** |
2023 | Calls the identical method from wxDataViewTreeStore. | |
2024 | */ | |
2025 | wxClientData* GetItemData(const wxDataViewItem& item) const; | |
05303ccd | 2026 | |
5b99d5d8 RR |
2027 | /** |
2028 | Calls the identical method from wxDataViewTreeStore. | |
2029 | */ | |
b91c4601 | 2030 | const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const; |
05303ccd | 2031 | |
05303ccd | 2032 | /** |
5b99d5d8 | 2033 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2034 | */ |
b91c4601 | 2035 | const wxIcon& GetItemIcon(const wxDataViewItem& item) const; |
05303ccd RR |
2036 | |
2037 | /** | |
5b99d5d8 | 2038 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2039 | */ |
5b99d5d8 RR |
2040 | wxString GetItemText(const wxDataViewItem& item) const; |
2041 | ||
2042 | /** | |
2043 | Calls the identical method from wxDataViewTreeStore. | |
2044 | */ | |
2045 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, | |
2046 | unsigned int pos) const; | |
05303ccd | 2047 | |
5b99d5d8 | 2048 | //@{ |
05303ccd | 2049 | /** |
5b99d5d8 | 2050 | Returns the store. |
05303ccd | 2051 | */ |
882678eb | 2052 | wxDataViewTreeStore* GetStore(); |
5b99d5d8 RR |
2053 | const wxDataViewTreeStore* GetStore() const; |
2054 | //@} | |
05303ccd RR |
2055 | |
2056 | /** | |
c4e57202 FM |
2057 | Calls the same method from wxDataViewTreeStore but uses |
2058 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2059 | */ |
5b99d5d8 RR |
2060 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
2061 | const wxDataViewItem& previous, | |
2062 | const wxString& text, | |
2063 | int icon = -1, | |
2064 | int expanded = -1, | |
2065 | wxClientData* data = NULL); | |
05303ccd RR |
2066 | |
2067 | /** | |
c4e57202 FM |
2068 | Calls the same method from wxDataViewTreeStore but uses |
2069 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2070 | */ |
5b99d5d8 RR |
2071 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
2072 | const wxDataViewItem& previous, | |
2073 | const wxString& text, | |
2074 | int icon = -1, | |
2075 | wxClientData* data = NULL); | |
05303ccd | 2076 | |
8ddda15b RR |
2077 | /** |
2078 | Returns true if item is a container. | |
2079 | */ | |
2080 | bool IsContainer( const wxDataViewItem& item ); | |
2081 | ||
05303ccd | 2082 | /** |
c4e57202 FM |
2083 | Calls the same method from wxDataViewTreeStore but uses |
2084 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2085 | */ |
5b99d5d8 RR |
2086 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
2087 | const wxString& text, | |
2088 | int icon = -1, | |
2089 | int expanded = -1, | |
2090 | wxClientData* data = NULL); | |
05303ccd RR |
2091 | |
2092 | /** | |
c4e57202 FM |
2093 | Calls the same method from wxDataViewTreeStore but uses |
2094 | an index position in the image list instead of a wxIcon. | |
05303ccd | 2095 | */ |
5b99d5d8 RR |
2096 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
2097 | const wxString& text, | |
2098 | int icon = -1, | |
2099 | wxClientData* data = NULL); | |
05303ccd RR |
2100 | |
2101 | /** | |
5b99d5d8 | 2102 | Sets the image list. |
05303ccd | 2103 | */ |
5b99d5d8 | 2104 | void SetImageList(wxImageList* imagelist); |
05303ccd RR |
2105 | |
2106 | /** | |
5b99d5d8 | 2107 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2108 | */ |
5b99d5d8 | 2109 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
05303ccd RR |
2110 | |
2111 | /** | |
5b99d5d8 | 2112 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2113 | */ |
5b99d5d8 RR |
2114 | void SetItemExpandedIcon(const wxDataViewItem& item, |
2115 | const wxIcon& icon); | |
05303ccd RR |
2116 | |
2117 | /** | |
5b99d5d8 | 2118 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2119 | */ |
5b99d5d8 | 2120 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
05303ccd RR |
2121 | |
2122 | /** | |
5b99d5d8 | 2123 | Calls the identical method from wxDataViewTreeStore. |
05303ccd | 2124 | */ |
5b99d5d8 RR |
2125 | void SetItemText(const wxDataViewItem& item, |
2126 | const wxString& text); | |
05303ccd RR |
2127 | }; |
2128 | ||
2129 | ||
bda698ed RR |
2130 | /** |
2131 | @class wxDataViewListStore | |
2132 | ||
2133 | wxDataViewListStore is a specialised wxDataViewModel for storing | |
2134 | a simple table of data. Since it derives from wxDataViewIndexListModel | |
2135 | its data is be accessed by row (i.e. by index) instead of only | |
2136 | by wxDataViewItem. | |
2137 | ||
02b51ae5 | 2138 | This class actually stores the values (therefore its name) |
bda698ed | 2139 | and implements all virtual methods from the base classes so it can be |
02b51ae5 | 2140 | used directly without having to derive any class from it, but it is |
bda698ed RR |
2141 | mostly used from within wxDataViewListCtrl. |
2142 | ||
2143 | @library{wxadv} | |
2144 | @category{dvc} | |
2145 | */ | |
2146 | ||
2147 | class wxDataViewListStore: public wxDataViewIndexListModel | |
2148 | { | |
2149 | public: | |
2150 | /** | |
02b51ae5 | 2151 | Constructor |
bda698ed RR |
2152 | */ |
2153 | wxDataViewListStore(); | |
02b51ae5 | 2154 | |
bda698ed | 2155 | /** |
02b51ae5 | 2156 | Destructor |
bda698ed RR |
2157 | */ |
2158 | ~wxDataViewListStore(); | |
2159 | ||
2160 | /** | |
02b51ae5 FM |
2161 | Prepends a data column. |
2162 | ||
2163 | @a variantype indicates the type of values store in the column. | |
2164 | ||
2165 | This does not automatically fill in any (default) values in | |
2166 | rows which exist in the store already. | |
bda698ed RR |
2167 | */ |
2168 | void PrependColumn( const wxString &varianttype ); | |
2169 | ||
2170 | /** | |
02b51ae5 FM |
2171 | Inserts a data column before @a pos. |
2172 | ||
2173 | @a variantype indicates the type of values store in the column. | |
2174 | ||
2175 | This does not automatically fill in any (default) values in | |
2176 | rows which exist in the store already. | |
bda698ed RR |
2177 | */ |
2178 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
2179 | ||
2180 | /** | |
02b51ae5 FM |
2181 | Appends a data column. |
2182 | ||
2183 | @a variantype indicates the type of values store in the column. | |
2184 | ||
2185 | This does not automatically fill in any (default) values in | |
2186 | rows which exist in the store already. | |
bda698ed RR |
2187 | */ |
2188 | void AppendColumn( const wxString &varianttype ); | |
02b51ae5 | 2189 | |
bda698ed RR |
2190 | /** |
2191 | Appends an item (=row) and fills it with @a values. | |
02b51ae5 | 2192 | |
bda698ed RR |
2193 | The values must match the values specifies in the column |
2194 | in number and type. No (default) values are filled in | |
2195 | automatically. | |
2196 | */ | |
2197 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2198 | |
bda698ed RR |
2199 | /** |
2200 | Prepends an item (=row) and fills it with @a values. | |
02b51ae5 | 2201 | |
bda698ed RR |
2202 | The values must match the values specifies in the column |
2203 | in number and type. No (default) values are filled in | |
2204 | automatically. | |
2205 | */ | |
2206 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2207 | |
bda698ed RR |
2208 | /** |
2209 | Inserts an item (=row) and fills it with @a values. | |
02b51ae5 | 2210 | |
bda698ed RR |
2211 | The values must match the values specifies in the column |
2212 | in number and type. No (default) values are filled in | |
2213 | automatically. | |
2214 | */ | |
2215 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
02b51ae5 | 2216 | |
bda698ed RR |
2217 | /** |
2218 | Delete the item (=row) at position @a pos. | |
2219 | */ | |
2220 | void DeleteItem( unsigned pos ); | |
02b51ae5 | 2221 | |
bda698ed RR |
2222 | /** |
2223 | Delete all item (=all rows) in the store. | |
2224 | */ | |
2225 | void DeleteAllItems(); | |
2226 | ||
2227 | /** | |
2228 | Overriden from wxDataViewModel | |
2229 | */ | |
2230 | virtual unsigned int GetColumnCount() const; | |
2231 | ||
2232 | /** | |
2233 | Overriden from wxDataViewModel | |
2234 | */ | |
2235 | virtual wxString GetColumnType( unsigned int col ) const; | |
2236 | ||
2237 | /** | |
2238 | Overriden from wxDataViewIndexListModel | |
2239 | */ | |
2240 | virtual void GetValueByRow( wxVariant &value, | |
2241 | unsigned int row, unsigned int col ) const; | |
2242 | ||
2243 | /** | |
2244 | Overriden from wxDataViewIndexListModel | |
2245 | */ | |
2246 | virtual bool SetValueByRow( const wxVariant &value, | |
2247 | unsigned int row, unsigned int col ); | |
2248 | }; | |
2249 | ||
05303ccd RR |
2250 | |
2251 | /** | |
5b99d5d8 | 2252 | @class wxDataViewTreeStore |
05303ccd | 2253 | |
bda698ed | 2254 | wxDataViewTreeStore is a specialised wxDataViewModel for stroing simple |
c4e57202 FM |
2255 | trees very much like wxTreeCtrl does and it offers a similar API. |
2256 | ||
02b51ae5 | 2257 | This class actually stores the entire tree and the values (therefore its name) |
8eff6c56 | 2258 | and implements all virtual methods from the base class so it can be used directly |
bda698ed RR |
2259 | without having to derive any class from it, but it is mostly used from within |
2260 | wxDataViewTreeCtrl. | |
05303ccd RR |
2261 | |
2262 | @library{wxadv} | |
b321b61c | 2263 | @category{dvc} |
05303ccd | 2264 | */ |
5b99d5d8 | 2265 | class wxDataViewTreeStore : public wxDataViewModel |
05303ccd RR |
2266 | { |
2267 | public: | |
2268 | /** | |
5b99d5d8 | 2269 | Constructor. Creates the invisible root node internally. |
05303ccd | 2270 | */ |
5b99d5d8 | 2271 | wxDataViewTreeStore(); |
e54c96f1 | 2272 | |
5b99d5d8 RR |
2273 | /** |
2274 | Destructor. | |
2275 | */ | |
adaaa686 | 2276 | virtual ~wxDataViewTreeStore(); |
7c913512 | 2277 | |
5b99d5d8 RR |
2278 | /** |
2279 | Append a container. | |
2280 | */ | |
2281 | wxDataViewItem AppendContainer(const wxDataViewItem& parent, | |
2282 | const wxString& text, | |
2283 | const wxIcon& icon = wxNullIcon, | |
2284 | const wxIcon& expanded = wxNullIcon, | |
2285 | wxClientData* data = NULL); | |
7c913512 | 2286 | |
5b99d5d8 RR |
2287 | /** |
2288 | Append an item. | |
2289 | */ | |
2290 | wxDataViewItem AppendItem(const wxDataViewItem& parent, | |
2291 | const wxString& text, | |
2292 | const wxIcon& icon = wxNullIcon, | |
2293 | wxClientData* data = NULL); | |
7c913512 | 2294 | |
23324ae1 | 2295 | /** |
5b99d5d8 | 2296 | Delete all item in the model. |
23324ae1 | 2297 | */ |
5b99d5d8 | 2298 | void DeleteAllItems(); |
23324ae1 FM |
2299 | |
2300 | /** | |
5b99d5d8 | 2301 | Delete all children of the item, but not the item itself. |
23324ae1 | 2302 | */ |
5b99d5d8 | 2303 | void DeleteChildren(const wxDataViewItem& item); |
23324ae1 FM |
2304 | |
2305 | /** | |
5b99d5d8 | 2306 | Delete this item. |
23324ae1 | 2307 | */ |
5b99d5d8 | 2308 | void DeleteItem(const wxDataViewItem& item); |
23324ae1 FM |
2309 | |
2310 | /** | |
5b99d5d8 | 2311 | Return the number of children of item. |
23324ae1 | 2312 | */ |
5b99d5d8 | 2313 | int GetChildCount(const wxDataViewItem& parent) const; |
23324ae1 FM |
2314 | |
2315 | /** | |
5b99d5d8 | 2316 | Returns the client data asoociated with the item. |
23324ae1 | 2317 | */ |
5b99d5d8 | 2318 | wxClientData* GetItemData(const wxDataViewItem& item) const; |
23324ae1 FM |
2319 | |
2320 | /** | |
5b99d5d8 | 2321 | Returns the icon to display in expanded containers. |
23324ae1 | 2322 | */ |
b91c4601 | 2323 | const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
2324 | |
2325 | /** | |
5b99d5d8 | 2326 | Returns the icon of the item. |
23324ae1 | 2327 | */ |
b91c4601 | 2328 | const wxIcon& GetItemIcon(const wxDataViewItem& item) const; |
23324ae1 FM |
2329 | |
2330 | /** | |
5b99d5d8 | 2331 | Returns the text of the item. |
23324ae1 | 2332 | */ |
5b99d5d8 | 2333 | wxString GetItemText(const wxDataViewItem& item) const; |
23324ae1 FM |
2334 | |
2335 | /** | |
5b99d5d8 | 2336 | Returns the nth child item of item. |
23324ae1 | 2337 | */ |
5b99d5d8 RR |
2338 | wxDataViewItem GetNthChild(const wxDataViewItem& parent, |
2339 | unsigned int pos) const; | |
23324ae1 FM |
2340 | |
2341 | /** | |
c4e57202 | 2342 | Inserts a container after @a previous. |
23324ae1 | 2343 | */ |
5b99d5d8 RR |
2344 | wxDataViewItem InsertContainer(const wxDataViewItem& parent, |
2345 | const wxDataViewItem& previous, | |
2346 | const wxString& text, | |
2347 | const wxIcon& icon = wxNullIcon, | |
2348 | const wxIcon& expanded = wxNullIcon, | |
2349 | wxClientData* data = NULL); | |
23324ae1 FM |
2350 | |
2351 | /** | |
c4e57202 | 2352 | Inserts an item after @a previous. |
23324ae1 | 2353 | */ |
5b99d5d8 RR |
2354 | wxDataViewItem InsertItem(const wxDataViewItem& parent, |
2355 | const wxDataViewItem& previous, | |
2356 | const wxString& text, | |
2357 | const wxIcon& icon = wxNullIcon, | |
2358 | wxClientData* data = NULL); | |
23324ae1 FM |
2359 | |
2360 | /** | |
c4e57202 | 2361 | Inserts a container before the first child item or @a parent. |
23324ae1 | 2362 | */ |
5b99d5d8 RR |
2363 | wxDataViewItem PrependContainer(const wxDataViewItem& parent, |
2364 | const wxString& text, | |
2365 | const wxIcon& icon = wxNullIcon, | |
2366 | const wxIcon& expanded = wxNullIcon, | |
2367 | wxClientData* data = NULL); | |
23324ae1 FM |
2368 | |
2369 | /** | |
c4e57202 | 2370 | Inserts an item before the first child item or @a parent. |
23324ae1 | 2371 | */ |
5b99d5d8 RR |
2372 | wxDataViewItem PrependItem(const wxDataViewItem& parent, |
2373 | const wxString& text, | |
2374 | const wxIcon& icon = wxNullIcon, | |
2375 | wxClientData* data = NULL); | |
23324ae1 FM |
2376 | |
2377 | /** | |
5b99d5d8 | 2378 | Sets the client data associated with the item. |
23324ae1 | 2379 | */ |
5b99d5d8 | 2380 | void SetItemData(const wxDataViewItem& item, wxClientData* data); |
23324ae1 FM |
2381 | |
2382 | /** | |
5b99d5d8 | 2383 | Sets the expanded icon for the item. |
23324ae1 | 2384 | */ |
5b99d5d8 RR |
2385 | void SetItemExpandedIcon(const wxDataViewItem& item, |
2386 | const wxIcon& icon); | |
23324ae1 FM |
2387 | |
2388 | /** | |
5b99d5d8 | 2389 | Sets the icon for the item. |
23324ae1 | 2390 | */ |
5b99d5d8 | 2391 | void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon); |
23324ae1 | 2392 | }; |
e54c96f1 | 2393 | |
80932a3e FM |
2394 | |
2395 | /** | |
2396 | @class wxDataViewIconText | |
2397 | ||
2398 | wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer. | |
2399 | This class can be converted to and from a wxVariant. | |
2400 | ||
2401 | @library{wxadv} | |
2402 | @category{dvc} | |
2403 | */ | |
2404 | class wxDataViewIconText : public wxObject | |
2405 | { | |
2406 | public: | |
2407 | //@{ | |
2408 | /** | |
2409 | Constructor. | |
2410 | */ | |
2411 | wxDataViewIconText(const wxString& text = wxEmptyString, | |
2412 | const wxIcon& icon = wxNullIcon); | |
2413 | wxDataViewIconText(const wxDataViewIconText& other); | |
2414 | //@} | |
2415 | ||
2416 | /** | |
2417 | Gets the icon. | |
2418 | */ | |
2419 | const wxIcon& GetIcon() const; | |
2420 | ||
2421 | /** | |
2422 | Gets the text. | |
2423 | */ | |
2424 | wxString GetText() const; | |
2425 | ||
2426 | /** | |
2427 | Set the icon. | |
2428 | */ | |
2429 | void SetIcon(const wxIcon& icon); | |
2430 | ||
2431 | /** | |
2432 | Set the text. | |
2433 | */ | |
2434 | void SetText(const wxString& text); | |
2435 | }; | |
2436 | ||
2437 | ||
2438 | ||
2439 | /** | |
2440 | @class wxDataViewEvent | |
2441 | ||
2442 | This is the event class for the wxDataViewCtrl notifications. | |
2443 | ||
14f73cf1 FM |
2444 | @beginEventTable{wxDataViewEvent} |
2445 | @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)} | |
2446 | Process a @c wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event. | |
2447 | @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)} | |
2448 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event. | |
2449 | @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)} | |
2450 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event. | |
2451 | @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)} | |
2452 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event. | |
2453 | @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)} | |
2454 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event. | |
2455 | @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)} | |
2456 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event. | |
2457 | @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)} | |
2458 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event. | |
2459 | @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)} | |
2460 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event. | |
2461 | @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)} | |
2462 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event. | |
2463 | @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)} | |
2464 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event. | |
2465 | @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)} | |
2466 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICKED event. | |
2467 | @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)} | |
2468 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED event. | |
2469 | @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)} | |
2470 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event. | |
2471 | @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)} | |
2472 | Process a @c wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event. | |
2473 | @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)} | |
2474 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event. | |
2475 | @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)} | |
2476 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event. | |
2477 | @event{EVT_DATAVIEW_ITEM_DROP(id, func)} | |
2478 | Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event. | |
47a8b1e1 VZ |
2479 | @event{EVT_DATAVIEW_CACHE_HINT(id, func)} |
2480 | Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event. | |
14f73cf1 | 2481 | @endEventTable |
43c64cc6 | 2482 | |
80932a3e FM |
2483 | @library{wxadv} |
2484 | @category{events,dvc} | |
2485 | */ | |
2486 | class wxDataViewEvent : public wxNotifyEvent | |
2487 | { | |
2488 | public: | |
80932a3e FM |
2489 | /** |
2490 | Constructor. Typically used by wxWidgets internals only. | |
2491 | */ | |
2492 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, | |
2493 | int winid = 0); | |
80932a3e FM |
2494 | |
2495 | /** | |
2496 | Returns the position of the column in the control or -1 | |
2497 | if no column field was set by the event emitter. | |
2498 | */ | |
2499 | int GetColumn() const; | |
2500 | ||
2501 | /** | |
2502 | Returns a pointer to the wxDataViewColumn from which | |
2503 | the event was emitted or @NULL. | |
2504 | */ | |
2505 | wxDataViewColumn* GetDataViewColumn() const; | |
2506 | ||
2507 | /** | |
2508 | Returns the wxDataViewModel associated with the event. | |
2509 | */ | |
2510 | wxDataViewModel* GetModel() const; | |
2511 | ||
2512 | /** | |
2513 | Returns a the position of a context menu event in screen coordinates. | |
2514 | */ | |
2515 | wxPoint GetPosition() const; | |
2516 | ||
2517 | /** | |
2518 | Returns a reference to a value. | |
2519 | */ | |
2520 | const wxVariant& GetValue() const; | |
2521 | ||
2522 | /** | |
2523 | Sets the column index associated with this event. | |
2524 | */ | |
2525 | void SetColumn(int col); | |
2526 | ||
2527 | /** | |
2528 | For wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only. | |
2529 | */ | |
2530 | void SetDataViewColumn(wxDataViewColumn* col); | |
2531 | ||
2532 | /** | |
2533 | Sets the dataview model associated with this event. | |
2534 | */ | |
2535 | void SetModel(wxDataViewModel* model); | |
2536 | ||
2537 | /** | |
2538 | Sets the value associated with this event. | |
2539 | */ | |
2540 | void SetValue(const wxVariant& value); | |
02b51ae5 | 2541 | |
591cc82d | 2542 | /** |
e4de825e | 2543 | Set wxDataObject for data transfer within a drag operation. |
591cc82d RR |
2544 | */ |
2545 | void SetDataObject( wxDataObject *obj ); | |
02b51ae5 | 2546 | |
591cc82d | 2547 | /** |
e4de825e RR |
2548 | Used internally. Gets associated wxDataObject for data transfer |
2549 | within a drag operation. | |
2550 | */ | |
2551 | wxDataObject *GetDataObject() const; | |
02b51ae5 | 2552 | |
e4de825e RR |
2553 | /** |
2554 | Used internally. Sets the wxDataFormat during a drop operation. | |
2555 | */ | |
2556 | void SetDataFormat( const wxDataFormat &format ); | |
02b51ae5 | 2557 | |
e4de825e RR |
2558 | /** |
2559 | Gets the wxDataFormat during a drop operation. | |
2560 | */ | |
2561 | wxDataFormat GetDataFormat() const; | |
02b51ae5 | 2562 | |
e4de825e RR |
2563 | /** |
2564 | Used internally. Sets the data size for a drop data transfer. | |
2565 | */ | |
2566 | void SetDataSize( size_t size ); | |
02b51ae5 | 2567 | |
e4de825e RR |
2568 | /** |
2569 | Gets the data size for a drop data transfer. | |
2570 | */ | |
2571 | size_t GetDataSize() const; | |
02b51ae5 | 2572 | |
e4de825e RR |
2573 | /** |
2574 | Used internally. Sets the data buffer for a drop data transfer. | |
2575 | */ | |
2576 | void SetDataBuffer( void* buf ); | |
02b51ae5 | 2577 | |
e4de825e RR |
2578 | /** |
2579 | Gets the data buffer for a drop data transfer. | |
591cc82d | 2580 | */ |
e4de825e | 2581 | void *GetDataBuffer() const; |
47a8b1e1 VZ |
2582 | |
2583 | /** | |
2584 | Return the first row that will be displayed. | |
2585 | */ | |
2586 | int GetCacheFrom() const; | |
2587 | ||
2588 | /** | |
2589 | Return the last row that will be displayed. | |
2590 | */ | |
2591 | int GetCacheTo() const; | |
80932a3e FM |
2592 | }; |
2593 |