]>
Commit | Line | Data |
---|---|---|
bcd846ea RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/dataview.h | |
3 | // Purpose: wxDataViewCtrl base classes | |
4 | // Author: Robert Roebling | |
b7e9f8b1 | 5 | // Modified by: Bo Yang |
bcd846ea RR |
6 | // Created: 08.01.06 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Robert Roebling | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DATAVIEW_H_BASE_ | |
13 | #define _WX_DATAVIEW_H_BASE_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_DATAVIEWCTRL | |
18 | ||
239eaa41 | 19 | #include "wx/textctrl.h" |
56873923 | 20 | #include "wx/headercol.h" |
64ffb888 | 21 | #include "wx/variant.h" |
b7e9f8b1 | 22 | #include "wx/dynarray.h" |
89352653 | 23 | #include "wx/icon.h" |
c232dfe5 | 24 | #include "wx/weakref.h" |
8eff6c56 | 25 | #include "wx/vector.h" |
8c2654ce PC |
26 | #include "wx/dataobj.h" |
27 | ||
28 | class WXDLLIMPEXP_FWD_CORE wxImageList; | |
4ed7af08 | 29 | |
e86edab0 | 30 | #if !(defined(__WXGTK20__) || defined(__WXOSX__)) || defined(__WXUNIVERSAL__) |
0a807957 | 31 | // #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__) |
56873923 VZ |
32 | #define wxHAS_GENERIC_DATAVIEWCTRL |
33 | #endif | |
34 | ||
6eec70b9 VZ |
35 | #ifdef wxHAS_GENERIC_DATAVIEWCTRL |
36 | // this symbol doesn't follow the convention for wxUSE_XXX symbols which | |
37 | // are normally always defined as either 0 or 1, so its use is deprecated | |
38 | // and it only exists for backwards compatibility, don't use it any more | |
39 | // and use wxHAS_GENERIC_DATAVIEWCTRL instead | |
40 | #define wxUSE_GENERICDATAVIEWCTRL | |
41 | #endif | |
42 | ||
239eaa41 RR |
43 | // ---------------------------------------------------------------------------- |
44 | // wxDataViewCtrl globals | |
45 | // ---------------------------------------------------------------------------- | |
bcd846ea | 46 | |
b5dbe15d VS |
47 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; |
48 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
49 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
50 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
51 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
52 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
fa28826d | 53 | |
23318a53 | 54 | extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[]; |
bcd846ea | 55 | |
ce468dc2 FM |
56 | // ---------------------------------------------------------------------------- |
57 | // wxDataViewCtrl flags | |
58 | // ---------------------------------------------------------------------------- | |
59 | ||
60 | // size of a wxDataViewRenderer without contents: | |
61 | #define wxDVC_DEFAULT_RENDERER_SIZE 20 | |
62 | ||
87f0efe2 RR |
63 | // the default width of new (text) columns: |
64 | #define wxDVC_DEFAULT_WIDTH 80 | |
65 | ||
66 | // the default width of new toggle columns: | |
67 | #define wxDVC_TOGGLE_DEFAULT_WIDTH 30 | |
68 | ||
9861f022 RR |
69 | // the default minimal width of the columns: |
70 | #define wxDVC_DEFAULT_MINWIDTH 30 | |
71 | ||
f2b7492a RR |
72 | // The default alignment of wxDataViewRenderers is to take |
73 | // the alignment from the column it owns. | |
74 | #define wxDVR_DEFAULT_ALIGNMENT -1 | |
9861f022 | 75 | |
87f0efe2 | 76 | |
f554a14b | 77 | // --------------------------------------------------------- |
e0062c04 | 78 | // wxDataViewItem |
f554a14b | 79 | // --------------------------------------------------------- |
239eaa41 | 80 | |
e0062c04 | 81 | class WXDLLIMPEXP_ADV wxDataViewItem |
239eaa41 RR |
82 | { |
83 | public: | |
b5ec7dd6 | 84 | wxDataViewItem( void* id = NULL ) |
9d52aad3 | 85 | { m_id = id; } |
e0062c04 | 86 | wxDataViewItem( const wxDataViewItem &item ) |
9d52aad3 RR |
87 | { m_id = item.m_id; } |
88 | bool IsOk() const { return m_id != NULL; } | |
89 | void* GetID() const { return m_id; } | |
4f1cf94b | 90 | operator const void* () const { return m_id; } |
b5ec7dd6 | 91 | |
8f850e28 | 92 | private: |
9d52aad3 | 93 | void* m_id; |
64ffb888 | 94 | }; |
239eaa41 | 95 | |
9aa2e298 VZ |
96 | inline |
97 | bool operator==(const wxDataViewItem& left, const wxDataViewItem& right) | |
98 | { | |
99 | return left.GetID() == right.GetID(); | |
100 | } | |
101 | ||
102 | inline | |
103 | bool operator!=(const wxDataViewItem& left, const wxDataViewItem& right) | |
104 | { | |
105 | return !(left == right); | |
106 | } | |
aba9bfd0 | 107 | |
cd722937 RR |
108 | WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); |
109 | ||
9d8fe14a RR |
110 | // --------------------------------------------------------- |
111 | // wxDataViewModelNotifier | |
112 | // --------------------------------------------------------- | |
113 | ||
114 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier | |
115 | { | |
116 | public: | |
5e6f8927 | 117 | wxDataViewModelNotifier() { m_owner = NULL; } |
9d8fe14a RR |
118 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } |
119 | ||
120 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
121 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
122 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
854cdb09 RR |
123 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
124 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
125 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); | |
9d8fe14a RR |
126 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; |
127 | virtual bool Cleared() = 0; | |
ce00f59b | 128 | |
d8090b5e RR |
129 | // some platforms, such as GTK+, may need a two step procedure for ::Reset() |
130 | virtual bool BeforeReset() { return true; } | |
673810ee | 131 | virtual bool AfterReset() { return Cleared(); } |
b5ec7dd6 | 132 | |
d3f00f59 | 133 | virtual void Resort() = 0; |
9d8fe14a RR |
134 | |
135 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } | |
e51bf699 | 136 | wxDataViewModel *GetOwner() const { return m_owner; } |
9d8fe14a RR |
137 | |
138 | private: | |
139 | wxDataViewModel *m_owner; | |
140 | }; | |
141 | ||
142 | ||
4264606e RR |
143 | |
144 | // ---------------------------------------------------------------------------- | |
145 | // wxDataViewItemAttr: a structure containing the visual attributes of an item | |
146 | // ---------------------------------------------------------------------------- | |
147 | ||
148 | // TODO: this should be renamed to wxItemAttr or something general like this | |
149 | ||
150 | class WXDLLIMPEXP_ADV wxDataViewItemAttr | |
151 | { | |
152 | public: | |
153 | // ctors | |
c058cafa VZ |
154 | wxDataViewItemAttr() |
155 | { | |
4264606e RR |
156 | m_bold = false; |
157 | m_italic = false; | |
158 | } | |
159 | ||
160 | // setters | |
161 | void SetColour(const wxColour& colour) { m_colour = colour; } | |
162 | void SetBold( bool set ) { m_bold = set; } | |
163 | void SetItalic( bool set ) { m_italic = set; } | |
c058cafa | 164 | |
4264606e | 165 | // accessors |
a1b806b9 | 166 | bool HasColour() const { return m_colour.IsOk(); } |
4264606e | 167 | const wxColour& GetColour() const { return m_colour; } |
c058cafa | 168 | |
2d0d7813 | 169 | bool HasFont() const { return m_bold || m_italic; } |
4264606e RR |
170 | bool GetBold() const { return m_bold; } |
171 | bool GetItalic() const { return m_italic; } | |
172 | ||
c80cde00 VZ |
173 | bool IsDefault() const { return !(HasColour() || HasFont()); } |
174 | ||
86755098 VS |
175 | // Return the font based on the given one with this attribute applied to it. |
176 | wxFont GetEffectiveFont(const wxFont& font) const; | |
177 | ||
4264606e RR |
178 | private: |
179 | wxColour m_colour; | |
180 | bool m_bold; | |
181 | bool m_italic; | |
182 | }; | |
183 | ||
184 | ||
f554a14b | 185 | // --------------------------------------------------------- |
e0062c04 | 186 | // wxDataViewModel |
f554a14b | 187 | // --------------------------------------------------------- |
239eaa41 | 188 | |
d350fbec VS |
189 | WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers, |
190 | class WXDLLIMPEXP_ADV); | |
9d8fe14a | 191 | |
e4e83d3a | 192 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter |
239eaa41 RR |
193 | { |
194 | public: | |
e0062c04 | 195 | wxDataViewModel(); |
239eaa41 | 196 | |
9861f022 | 197 | virtual unsigned int GetColumnCount() const = 0; |
87f0efe2 | 198 | |
a7f61f76 | 199 | // return type as reported by wxVariant |
9861f022 | 200 | virtual wxString GetColumnType( unsigned int col ) const = 0; |
87f0efe2 | 201 | |
a7f61f76 | 202 | // get value into a wxVariant |
b5ec7dd6 | 203 | virtual void GetValue( wxVariant &variant, |
e0062c04 | 204 | const wxDataViewItem &item, unsigned int col ) const = 0; |
87f0efe2 | 205 | |
b372f20e VZ |
206 | // return true if the given item has a value to display in the given |
207 | // column: this is always true except for container items which by default | |
208 | // only show their label in the first column (but see HasContainerColumns()) | |
209 | bool HasValue(const wxDataViewItem& item, unsigned col) const | |
210 | { | |
211 | return col == 0 || !IsContainer(item) || HasContainerColumns(item); | |
212 | } | |
213 | ||
795dac4c VZ |
214 | // usually ValueChanged() should be called after changing the value in the |
215 | // model to update the control, ChangeValue() does it on its own while | |
216 | // SetValue() does not -- so while you will override SetValue(), you should | |
217 | // be usually calling ChangeValue() | |
218 | virtual bool SetValue(const wxVariant &variant, | |
219 | const wxDataViewItem &item, | |
220 | unsigned int col) = 0; | |
221 | ||
222 | bool ChangeValue(const wxVariant& variant, | |
223 | const wxDataViewItem& item, | |
224 | unsigned int col) | |
225 | { | |
226 | return SetValue(variant, item, col) && ValueChanged(item, col); | |
227 | } | |
239eaa41 | 228 | |
4264606e | 229 | // Get text attribute, return false of default attributes should be used |
7fadac88 VZ |
230 | virtual bool GetAttr(const wxDataViewItem &WXUNUSED(item), |
231 | unsigned int WXUNUSED(col), | |
232 | wxDataViewItemAttr &WXUNUSED(attr)) const | |
233 | { | |
234 | return false; | |
235 | } | |
4264606e | 236 | |
98f8e666 VZ |
237 | // Override this if you want to disable specific items |
238 | virtual bool IsEnabled(const wxDataViewItem &WXUNUSED(item), | |
239 | unsigned int WXUNUSED(col)) const | |
240 | { | |
241 | return true; | |
242 | } | |
243 | ||
e0062c04 | 244 | // define hierachy |
ed903e42 RR |
245 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; |
246 | virtual bool IsContainer( const wxDataViewItem &item ) const = 0; | |
1e40f667 | 247 | // Is the container just a header or an item with all columns |
b5ec7dd6 VZ |
248 | virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const |
249 | { return false; } | |
74fe973b | 250 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; |
b9b8b59c | 251 | |
239eaa41 | 252 | // delegated notifiers |
9ca2afd1 RR |
253 | bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
254 | bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
255 | bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); | |
256 | bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
257 | bool ItemChanged( const wxDataViewItem &item ); | |
258 | bool ItemsChanged( const wxDataViewItemArray &items ); | |
259 | bool ValueChanged( const wxDataViewItem &item, unsigned int col ); | |
260 | bool Cleared(); | |
b5d777c7 | 261 | |
d8090b5e RR |
262 | // some platforms, such as GTK+, may need a two step procedure for ::Reset() |
263 | bool BeforeReset(); | |
673810ee RR |
264 | bool AfterReset(); |
265 | ||
266 | ||
267 | // delegated action | |
ef427989 RR |
268 | virtual void Resort(); |
269 | ||
e0062c04 RR |
270 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
271 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
b5ec7dd6 | 272 | |
ef427989 | 273 | // default compare function |
b5ec7dd6 | 274 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
862de7b3 | 275 | unsigned int column, bool ascending ) const; |
09711964 | 276 | virtual bool HasDefaultCompare() const { return false; } |
c058cafa | 277 | |
2056dede | 278 | // internal |
ce5abbf9 | 279 | virtual bool IsListModel() const { return false; } |
e39de702 | 280 | virtual bool IsVirtualListModel() const { return false; } |
66e09788 | 281 | |
87f0efe2 RR |
282 | protected: |
283 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 284 | virtual ~wxDataViewModel() { } |
87f0efe2 | 285 | |
9d8fe14a | 286 | wxDataViewModelNotifiers m_notifiers; |
ef427989 RR |
287 | }; |
288 | ||
2feacb6e VZ |
289 | // ---------------------------------------------------------------------------- |
290 | // wxDataViewListModel: a model of a list, i.e. flat data structure without any | |
291 | // branches/containers, used as base class by wxDataViewIndexListModel and | |
292 | // wxDataViewVirtualListModel | |
293 | // ---------------------------------------------------------------------------- | |
294 | ||
295 | class WXDLLIMPEXP_ADV wxDataViewListModel : public wxDataViewModel | |
296 | { | |
297 | public: | |
298 | // derived classes should override these methods instead of | |
299 | // {Get,Set}Value() and GetAttr() inherited from the base class | |
300 | ||
301 | virtual void GetValueByRow(wxVariant &variant, | |
302 | unsigned row, unsigned col) const = 0; | |
303 | ||
304 | virtual bool SetValueByRow(const wxVariant &variant, | |
305 | unsigned row, unsigned col) = 0; | |
306 | ||
307 | virtual bool | |
308 | GetAttrByRow(unsigned WXUNUSED(row), unsigned WXUNUSED(col), | |
7fadac88 | 309 | wxDataViewItemAttr &WXUNUSED(attr)) const |
2feacb6e VZ |
310 | { |
311 | return false; | |
312 | } | |
313 | ||
98f8e666 VZ |
314 | virtual bool IsEnabledByRow(unsigned int WXUNUSED(row), |
315 | unsigned int WXUNUSED(col)) const | |
316 | { | |
317 | return true; | |
318 | } | |
319 | ||
2feacb6e VZ |
320 | |
321 | // helper methods provided by list models only | |
322 | virtual unsigned GetRow( const wxDataViewItem &item ) const = 0; | |
323 | ||
ce00f59b | 324 | // returns the number of rows |
b955766e | 325 | virtual unsigned int GetCount() const = 0; |
2feacb6e VZ |
326 | |
327 | // implement some base class pure virtual directly | |
328 | virtual wxDataViewItem | |
329 | GetParent( const wxDataViewItem & WXUNUSED(item) ) const | |
330 | { | |
331 | // items never have valid parent in this model | |
332 | return wxDataViewItem(); | |
333 | } | |
334 | ||
335 | virtual bool IsContainer( const wxDataViewItem &item ) const | |
336 | { | |
337 | // only the invisible (and invalid) root item has children | |
338 | return !item.IsOk(); | |
339 | } | |
340 | ||
341 | // and implement some others by forwarding them to our own ones | |
342 | virtual void GetValue( wxVariant &variant, | |
343 | const wxDataViewItem &item, unsigned int col ) const | |
344 | { | |
345 | GetValueByRow(variant, GetRow(item), col); | |
346 | } | |
347 | ||
348 | virtual bool SetValue( const wxVariant &variant, | |
349 | const wxDataViewItem &item, unsigned int col ) | |
350 | { | |
351 | return SetValueByRow( variant, GetRow(item), col ); | |
352 | } | |
353 | ||
354 | virtual bool GetAttr(const wxDataViewItem &item, unsigned int col, | |
7fadac88 | 355 | wxDataViewItemAttr &attr) const |
2feacb6e VZ |
356 | { |
357 | return GetAttrByRow( GetRow(item), col, attr ); | |
358 | } | |
ce5abbf9 | 359 | |
98f8e666 VZ |
360 | virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const |
361 | { | |
362 | return IsEnabledByRow( GetRow(item), col ); | |
363 | } | |
364 | ||
b955766e | 365 | |
ce5abbf9 | 366 | virtual bool IsListModel() const { return true; } |
2feacb6e VZ |
367 | }; |
368 | ||
ef427989 | 369 | // --------------------------------------------------------- |
c534e696 | 370 | // wxDataViewIndexListModel |
ef427989 RR |
371 | // --------------------------------------------------------- |
372 | ||
2feacb6e | 373 | class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewListModel |
ef427989 RR |
374 | { |
375 | public: | |
c534e696 | 376 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); |
c058cafa | 377 | |
c534e696 RR |
378 | void RowPrepended(); |
379 | void RowInserted( unsigned int before ); | |
380 | void RowAppended(); | |
381 | void RowDeleted( unsigned int row ); | |
8b6cf9bf | 382 | void RowsDeleted( const wxArrayInt &rows ); |
c534e696 RR |
383 | void RowChanged( unsigned int row ); |
384 | void RowValueChanged( unsigned int row, unsigned int col ); | |
33ba5a05 | 385 | void Reset( unsigned int new_size ); |
b5ec7dd6 | 386 | |
c534e696 | 387 | // convert to/from row/wxDataViewItem |
b5ec7dd6 | 388 | |
2feacb6e | 389 | virtual unsigned GetRow( const wxDataViewItem &item ) const; |
c534e696 | 390 | wxDataViewItem GetItem( unsigned int row ) const; |
b5ec7dd6 | 391 | |
c534e696 | 392 | // compare based on index |
b5ec7dd6 VZ |
393 | |
394 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
862de7b3 | 395 | unsigned int column, bool ascending ) const; |
517166e6 | 396 | virtual bool HasDefaultCompare() const; |
c534e696 RR |
397 | |
398 | // implement base methods | |
74fe973b | 399 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
b5ec7dd6 | 400 | |
9330d5af | 401 | unsigned int GetCount() const { return m_hash.GetCount(); } |
c058cafa | 402 | |
c534e696 | 403 | private: |
cd722937 | 404 | wxDataViewItemArray m_hash; |
9330d5af | 405 | unsigned int m_nextFreeID; |
517166e6 | 406 | bool m_ordered; |
239eaa41 RR |
407 | }; |
408 | ||
e39de702 RR |
409 | // --------------------------------------------------------- |
410 | // wxDataViewVirtualListModel | |
411 | // --------------------------------------------------------- | |
412 | ||
413 | #ifdef __WXMAC__ | |
414 | // better than nothing | |
f1399150 | 415 | typedef wxDataViewIndexListModel wxDataViewVirtualListModel; |
e39de702 RR |
416 | #else |
417 | ||
2feacb6e | 418 | class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewListModel |
e39de702 RR |
419 | { |
420 | public: | |
421 | wxDataViewVirtualListModel( unsigned int initial_size = 0 ); | |
e39de702 RR |
422 | |
423 | void RowPrepended(); | |
424 | void RowInserted( unsigned int before ); | |
425 | void RowAppended(); | |
426 | void RowDeleted( unsigned int row ); | |
427 | void RowsDeleted( const wxArrayInt &rows ); | |
428 | void RowChanged( unsigned int row ); | |
429 | void RowValueChanged( unsigned int row, unsigned int col ); | |
430 | void Reset( unsigned int new_size ); | |
431 | ||
432 | // convert to/from row/wxDataViewItem | |
433 | ||
2feacb6e | 434 | virtual unsigned GetRow( const wxDataViewItem &item ) const; |
e39de702 RR |
435 | wxDataViewItem GetItem( unsigned int row ) const; |
436 | ||
437 | // compare based on index | |
438 | ||
439 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
862de7b3 | 440 | unsigned int column, bool ascending ) const; |
e39de702 RR |
441 | virtual bool HasDefaultCompare() const; |
442 | ||
443 | // implement base methods | |
e39de702 RR |
444 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
445 | ||
74d9b8fb VZ |
446 | unsigned int GetCount() const { return m_size; } |
447 | ||
e39de702 RR |
448 | // internal |
449 | virtual bool IsVirtualListModel() const { return true; } | |
e39de702 RR |
450 | |
451 | private: | |
9330d5af | 452 | unsigned int m_size; |
e39de702 RR |
453 | bool m_ordered; |
454 | }; | |
455 | #endif | |
c33edc08 | 456 | |
6eec70b9 VZ |
457 | // ---------------------------------------------------------------------------- |
458 | // wxDataViewRenderer and related classes | |
459 | // ---------------------------------------------------------------------------- | |
89352653 | 460 | |
6eec70b9 | 461 | #include "wx/dvrenderers.h" |
89352653 | 462 | |
f554a14b | 463 | // --------------------------------------------------------- |
6842a71a | 464 | // wxDataViewColumnBase |
f554a14b | 465 | // --------------------------------------------------------- |
6842a71a | 466 | |
56873923 | 467 | // for compatibility only, do not use |
fa28826d RR |
468 | enum wxDataViewColumnFlags |
469 | { | |
56873923 VZ |
470 | wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE, |
471 | wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE, | |
472 | wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE, | |
473 | wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN | |
fa28826d RR |
474 | }; |
475 | ||
dcb6cbec | 476 | class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn |
fa28826d RR |
477 | { |
478 | public: | |
e2bfe673 VZ |
479 | // ctor for the text columns: takes ownership of renderer |
480 | wxDataViewColumnBase(wxDataViewRenderer *renderer, | |
481 | unsigned int model_column) | |
482 | { | |
483 | Init(renderer, model_column); | |
484 | } | |
485 | ||
486 | // ctor for the bitmap columns | |
487 | wxDataViewColumnBase(const wxBitmap& bitmap, | |
488 | wxDataViewRenderer *renderer, | |
489 | unsigned int model_column) | |
490 | : m_bitmap(bitmap) | |
491 | { | |
492 | Init(renderer, model_column); | |
493 | } | |
494 | ||
d3c7fc99 | 495 | virtual ~wxDataViewColumnBase(); |
fa28826d | 496 | |
9861f022 | 497 | // setters: |
b5ec7dd6 | 498 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 | 499 | { m_owner = owner; } |
f554a14b | 500 | |
9861f022 | 501 | // getters: |
e86edab0 | 502 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
594d5596 RR |
503 | wxDataViewCtrl *GetOwner() const { return m_owner; } |
504 | wxDataViewRenderer* GetRenderer() const { return m_renderer; } | |
9861f022 | 505 | |
56873923 VZ |
506 | // implement some of base class pure virtuals (the rest is port-dependent |
507 | // and done differently in generic and native versions) | |
508 | virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } | |
509 | virtual wxBitmap GetBitmap() const { return m_bitmap; } | |
56873923 | 510 | |
9861f022 | 511 | protected: |
baa9ebc4 | 512 | wxDataViewRenderer *m_renderer; |
6842a71a | 513 | int m_model_column; |
07a84e7b | 514 | wxBitmap m_bitmap; |
6842a71a | 515 | wxDataViewCtrl *m_owner; |
fa28826d | 516 | |
e2bfe673 VZ |
517 | private: |
518 | // common part of all ctors | |
519 | void Init(wxDataViewRenderer *renderer, unsigned int model_column); | |
fa28826d RR |
520 | }; |
521 | ||
f554a14b | 522 | // --------------------------------------------------------- |
239eaa41 | 523 | // wxDataViewCtrlBase |
f554a14b | 524 | // --------------------------------------------------------- |
239eaa41 | 525 | |
c21f7aa1 | 526 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
527 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
528 | ||
529 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
530 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
531 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 532 | |
1a07a730 | 533 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows |
344ed1f3 | 534 | #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height |
1a07a730 | 535 | |
f460c29d | 536 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
537 | { |
538 | public: | |
539 | wxDataViewCtrlBase(); | |
d3c7fc99 | 540 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 541 | |
ce468dc2 FM |
542 | // model |
543 | // ----- | |
544 | ||
e0062c04 RR |
545 | virtual bool AssociateModel( wxDataViewModel *model ); |
546 | wxDataViewModel* GetModel(); | |
a75124d0 | 547 | const wxDataViewModel* GetModel() const; |
f554a14b | 548 | |
ce468dc2 FM |
549 | |
550 | // column management | |
551 | // ----------------- | |
552 | ||
b5ec7dd6 | 553 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 554 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 555 | wxAlignment align = wxALIGN_NOT, |
736fe67c | 556 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 557 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 558 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 559 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
560 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
561 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
562 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
563 | wxAlignment align = wxALIGN_CENTER, | |
564 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 565 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
566 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
567 | wxAlignment align = wxALIGN_CENTER, | |
568 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
569 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
570 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 571 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
572 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
573 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
574 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
575 | wxAlignment align = wxALIGN_CENTER, | |
576 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
577 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
578 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 579 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
580 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
581 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
582 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 583 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
584 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
585 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
586 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
587 | wxAlignment align = wxALIGN_CENTER, | |
588 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
589 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
590 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
591 | wxAlignment align = wxALIGN_CENTER, | |
592 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
593 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
594 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 595 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
596 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
597 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
598 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
599 | wxAlignment align = wxALIGN_CENTER, | |
600 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
601 | |
602 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 603 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 604 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 605 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 606 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 607 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 608 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 609 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 610 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
611 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
612 | wxAlignment align = wxALIGN_CENTER, | |
613 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 614 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
615 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
616 | wxAlignment align = wxALIGN_CENTER, | |
617 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 618 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 619 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 620 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 621 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 622 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
623 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
624 | wxAlignment align = wxALIGN_CENTER, | |
625 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 626 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 627 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 628 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 629 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
630 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
631 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 632 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 633 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 634 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
635 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
636 | wxAlignment align = wxALIGN_CENTER, | |
637 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 638 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
639 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
640 | wxAlignment align = wxALIGN_CENTER, | |
641 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 642 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 643 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 644 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 645 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 646 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
647 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
648 | wxAlignment align = wxALIGN_CENTER, | |
649 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c | 650 | |
736fe67c | 651 | virtual bool PrependColumn( wxDataViewColumn *col ); |
19723525 | 652 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
f554a14b | 653 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 654 | |
91a6c655 RR |
655 | virtual unsigned int GetColumnCount() const = 0; |
656 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 657 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 658 | |
91a6c655 RR |
659 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
660 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 661 | |
1b27b2bd | 662 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 663 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 664 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 665 | { return m_expander_column; } |
b5ec7dd6 | 666 | |
21f47fb9 | 667 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
23318a53 | 668 | |
ce468dc2 FM |
669 | |
670 | // items management | |
671 | // ---------------- | |
672 | ||
3b6280be RR |
673 | void SetIndent( int indent ) |
674 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
675 | int GetIndent() const |
676 | { return m_indent; } | |
3b6280be | 677 | |
80ce465c VZ |
678 | // Current item is the one used by the keyboard navigation, it is the same |
679 | // as the (unique) selected item in single selection mode so these | |
680 | // functions are mostly useful for controls with wxDV_MULTIPLE style. | |
681 | wxDataViewItem GetCurrentItem() const; | |
682 | void SetCurrentItem(const wxDataViewItem& item); | |
683 | ||
fbda518c | 684 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
685 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
686 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
687 | virtual void Select( const wxDataViewItem & item ) = 0; | |
688 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
689 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
690 | ||
b7e9f8b1 RR |
691 | virtual void SelectAll() = 0; |
692 | virtual void UnselectAll() = 0; | |
693 | ||
f71d3ba4 | 694 | virtual void Expand( const wxDataViewItem & item ) = 0; |
4219d8b0 | 695 | virtual void ExpandAncestors( const wxDataViewItem & item ); |
f71d3ba4 | 696 | virtual void Collapse( const wxDataViewItem & item ) = 0; |
739a8399 | 697 | virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; |
f71d3ba4 | 698 | |
6154212e | 699 | virtual void EnsureVisible( const wxDataViewItem & item, |
4219d8b0 | 700 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 701 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 702 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
bbfd4548 VZ |
703 | |
704 | virtual bool SetRowHeight( int WXUNUSED(rowHeight) ) { return false; } | |
705 | ||
7cc84a73 VZ |
706 | virtual void StartEditor( const wxDataViewItem & WXUNUSED(item), |
707 | unsigned int WXUNUSED(column) ) | |
708 | { } | |
8c2654ce | 709 | |
f54e5c1a VZ |
710 | #if wxUSE_DRAG_AND_DROP |
711 | virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format)) | |
712 | { return false; } | |
713 | virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format)) | |
714 | { return false; } | |
715 | #endif // wxUSE_DRAG_AND_DROP | |
b7e9f8b1 | 716 | |
2fa90e33 VZ |
717 | // define control visual attributes |
718 | // -------------------------------- | |
719 | ||
720 | virtual wxVisualAttributes GetDefaultAttributes() const | |
721 | { | |
722 | return GetClassDefaultAttributes(GetWindowVariant()); | |
723 | } | |
724 | ||
725 | static wxVisualAttributes | |
726 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) | |
727 | { | |
728 | return wxControl::GetCompositeControlsDefaultAttributes(variant); | |
729 | } | |
730 | ||
3b6280be RR |
731 | protected: |
732 | virtual void DoSetExpanderColumn() = 0 ; | |
733 | virtual void DoSetIndent() = 0; | |
734 | ||
239eaa41 | 735 | private: |
80ce465c VZ |
736 | // Implementation of the public Set/GetCurrentItem() methods which are only |
737 | // called in multi selection case (for single selection controls their | |
738 | // implementation is trivial and is done in the base class itself). | |
739 | virtual wxDataViewItem DoGetCurrentItem() const = 0; | |
740 | virtual void DoSetCurrentItem(const wxDataViewItem& item) = 0; | |
741 | ||
e0062c04 | 742 | wxDataViewModel *m_model; |
1b27b2bd | 743 | wxDataViewColumn *m_expander_column; |
3b6280be | 744 | int m_indent ; |
b5ec7dd6 | 745 | |
239eaa41 | 746 | protected: |
260b9be7 | 747 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 748 | }; |
bcd846ea | 749 | |
eb7f97f8 RR |
750 | // ---------------------------------------------------------------------------- |
751 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
752 | // ---------------------------------------------------------------------------- | |
753 | ||
2f799ae8 | 754 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
755 | { |
756 | public: | |
757 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
758 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 759 | m_item(0), |
eb7f97f8 | 760 | m_col(-1), |
eb7f97f8 RR |
761 | m_model(NULL), |
762 | m_value(wxNullVariant), | |
6af3eec2 | 763 | m_column(NULL), |
47a8b1e1 VZ |
764 | m_pos(-1,-1), |
765 | m_cacheFrom(0), | |
2a648479 VZ |
766 | m_cacheTo(0), |
767 | m_editCancelled(false) | |
6effcb7c FM |
768 | #if wxUSE_DRAG_AND_DROP |
769 | , m_dataObject(NULL), | |
e4de825e RR |
770 | m_dataBuffer(NULL), |
771 | m_dataSize(0) | |
6effcb7c | 772 | #endif |
eb7f97f8 RR |
773 | { } |
774 | ||
775 | wxDataViewEvent(const wxDataViewEvent& event) | |
776 | : wxNotifyEvent(event), | |
e0062c04 | 777 | m_item(event.m_item), |
eb7f97f8 | 778 | m_col(event.m_col), |
eb7f97f8 RR |
779 | m_model(event.m_model), |
780 | m_value(event.m_value), | |
6af3eec2 | 781 | m_column(event.m_column), |
4bc3adad | 782 | m_pos(event.m_pos), |
47a8b1e1 | 783 | m_cacheFrom(event.m_cacheFrom), |
2a648479 VZ |
784 | m_cacheTo(event.m_cacheTo), |
785 | m_editCancelled(event.m_editCancelled) | |
6effcb7c FM |
786 | #if wxUSE_DRAG_AND_DROP |
787 | , m_dataObject(event.m_dataObject), | |
e4de825e RR |
788 | m_dataFormat(event.m_dataFormat), |
789 | m_dataBuffer(event.m_dataBuffer), | |
790 | m_dataSize(event.m_dataSize) | |
6effcb7c | 791 | #endif |
eb7f97f8 RR |
792 | { } |
793 | ||
e0062c04 RR |
794 | wxDataViewItem GetItem() const { return m_item; } |
795 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
796 | ||
eb7f97f8 RR |
797 | int GetColumn() const { return m_col; } |
798 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 799 | |
eb7f97f8 RR |
800 | wxDataViewModel* GetModel() const { return m_model; } |
801 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 802 | |
eb7f97f8 RR |
803 | const wxVariant &GetValue() const { return m_value; } |
804 | void SetValue( const wxVariant &value ) { m_value = value; } | |
805 | ||
2a648479 VZ |
806 | // for wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE only |
807 | bool IsEditCancelled() const { return m_editCancelled; } | |
808 | void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } | |
809 | ||
31fb32e1 RR |
810 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
811 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 812 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
c058cafa | 813 | |
6af3eec2 | 814 | // for wxEVT_DATAVIEW_CONTEXT_MENU only |
5cfb6fee | 815 | wxPoint GetPosition() const { return m_pos; } |
6af3eec2 | 816 | void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } |
31fb32e1 | 817 | |
47a8b1e1 VZ |
818 | // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT |
819 | int GetCacheFrom() const { return m_cacheFrom; } | |
820 | int GetCacheTo() const { return m_cacheTo; } | |
821 | void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; } | |
822 | ||
823 | ||
62c9b3d7 | 824 | #if wxUSE_DRAG_AND_DROP |
e4de825e | 825 | // For drag operations |
591cc82d | 826 | void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } |
e4de825e | 827 | wxDataObject *GetDataObject() const { return m_dataObject; } |
8c2654ce | 828 | |
e4de825e RR |
829 | // For drop operations |
830 | void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } | |
831 | wxDataFormat GetDataFormat() const { return m_dataFormat; } | |
832 | void SetDataSize( size_t size ) { m_dataSize = size; } | |
833 | size_t GetDataSize() const { return m_dataSize; } | |
834 | void SetDataBuffer( void* buf ) { m_dataBuffer = buf;} | |
835 | void *GetDataBuffer() const { return m_dataBuffer; } | |
664e1314 | 836 | #endif // wxUSE_DRAG_AND_DROP |
15cac64f | 837 | |
eb7f97f8 RR |
838 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
839 | ||
840 | protected: | |
e0062c04 | 841 | wxDataViewItem m_item; |
eb7f97f8 | 842 | int m_col; |
eb7f97f8 RR |
843 | wxDataViewModel *m_model; |
844 | wxVariant m_value; | |
31fb32e1 | 845 | wxDataViewColumn *m_column; |
6af3eec2 | 846 | wxPoint m_pos; |
47a8b1e1 VZ |
847 | int m_cacheFrom; |
848 | int m_cacheTo; | |
2a648479 | 849 | bool m_editCancelled; |
8c2654ce | 850 | |
5e14f15d | 851 | #if wxUSE_DRAG_AND_DROP |
591cc82d | 852 | wxDataObject *m_dataObject; |
8c2654ce | 853 | |
e4de825e RR |
854 | wxDataFormat m_dataFormat; |
855 | void* m_dataBuffer; | |
856 | size_t m_dataSize; | |
5e14f15d | 857 | #endif // wxUSE_DRAG_AND_DROP |
eb7f97f8 RR |
858 | |
859 | private: | |
860 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
861 | }; | |
862 | ||
9b11752c VZ |
863 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); |
864 | ||
865 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); | |
866 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); | |
867 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); | |
868 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); | |
869 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); | |
3e978cf7 | 870 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); |
9b11752c VZ |
871 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); |
872 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); | |
873 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); | |
874 | ||
875 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); | |
876 | ||
877 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); | |
878 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); | |
879 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); | |
880 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); | |
881 | ||
47a8b1e1 VZ |
882 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_CACHE_HINT, wxDataViewEvent ); |
883 | ||
9b11752c VZ |
884 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); |
885 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); | |
886 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); | |
15cac64f | 887 | |
eb7f97f8 RR |
888 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); |
889 | ||
890 | #define wxDataViewEventHandler(func) \ | |
3c778901 | 891 | wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func) |
eb7f97f8 RR |
892 | |
893 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
894 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
895 | ||
d86c1870 RR |
896 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
897 | ||
e0062c04 | 898 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 899 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 900 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 901 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 902 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
3e978cf7 | 903 | #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn) |
e0000f94 RR |
904 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
905 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 906 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 907 | |
6af3eec2 RR |
908 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
909 | ||
31fb32e1 RR |
910 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
911 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 912 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
e483dfcb | 913 | #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) |
47a8b1e1 | 914 | #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn) |
eb7f97f8 | 915 | |
591cc82d | 916 | #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) |
e4de825e RR |
917 | #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) |
918 | #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn) | |
fe9fb970 | 919 | |
56873923 | 920 | #ifdef wxHAS_GENERIC_DATAVIEWCTRL |
56873923 VZ |
921 | #include "wx/generic/dataview.h" |
922 | #elif defined(__WXGTK20__) | |
bcd846ea | 923 | #include "wx/gtk/dataview.h" |
56873923 | 924 | #elif defined(__WXMAC__) |
ef0e9220 | 925 | #include "wx/osx/dataview.h" |
bcd846ea | 926 | #else |
56873923 | 927 | #error "unknown native wxDataViewCtrl implementation" |
bcd846ea RR |
928 | #endif |
929 | ||
8eff6c56 RR |
930 | //----------------------------------------------------------------------------- |
931 | // wxDataViewListStore | |
932 | //----------------------------------------------------------------------------- | |
933 | ||
934 | class WXDLLIMPEXP_ADV wxDataViewListStoreLine | |
935 | { | |
936 | public: | |
937 | wxDataViewListStoreLine( wxClientData *data = NULL ) | |
938 | { | |
939 | m_data = data; | |
940 | } | |
941 | virtual ~wxDataViewListStoreLine() | |
942 | { | |
943 | delete m_data; | |
944 | } | |
945 | ||
946 | void SetData( wxClientData *data ) | |
947 | { if (m_data) delete m_data; m_data = data; } | |
948 | wxClientData *GetData() const | |
949 | { return m_data; } | |
8c2654ce | 950 | |
8eff6c56 | 951 | wxVector<wxVariant> m_values; |
8c2654ce | 952 | |
8eff6c56 RR |
953 | private: |
954 | wxClientData *m_data; | |
955 | }; | |
956 | ||
957 | ||
958 | class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel | |
959 | { | |
960 | public: | |
961 | wxDataViewListStore(); | |
962 | ~wxDataViewListStore(); | |
963 | ||
964 | void PrependColumn( const wxString &varianttype ); | |
965 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
966 | void AppendColumn( const wxString &varianttype ); | |
8c2654ce | 967 | |
8eff6c56 RR |
968 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); |
969 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
970 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
8af28fab | 971 | void DeleteItem( unsigned int pos ); |
8eff6c56 RR |
972 | void DeleteAllItems(); |
973 | ||
8eff6c56 RR |
974 | // override base virtuals |
975 | ||
976 | virtual unsigned int GetColumnCount() const; | |
977 | ||
978 | virtual wxString GetColumnType( unsigned int col ) const; | |
979 | ||
980 | virtual void GetValueByRow( wxVariant &value, | |
981 | unsigned int row, unsigned int col ) const; | |
982 | ||
983 | virtual bool SetValueByRow( const wxVariant &value, | |
984 | unsigned int row, unsigned int col ); | |
985 | ||
8c2654ce | 986 | |
8eff6c56 RR |
987 | public: |
988 | wxVector<wxDataViewListStoreLine*> m_data; | |
989 | wxArrayString m_cols; | |
990 | }; | |
991 | ||
dc813e6c RR |
992 | //----------------------------------------------------------------------------- |
993 | ||
994 | class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl | |
995 | { | |
996 | public: | |
997 | wxDataViewListCtrl(); | |
998 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
999 | const wxPoint& pos = wxDefaultPosition, | |
1000 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1001 | const wxValidator& validator = wxDefaultValidator ); | |
1002 | ~wxDataViewListCtrl(); | |
1003 | ||
1004 | bool Create( wxWindow *parent, wxWindowID id, | |
1005 | const wxPoint& pos = wxDefaultPosition, | |
1006 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1007 | const wxValidator& validator = wxDefaultValidator ); | |
1008 | ||
1009 | wxDataViewListStore *GetStore() | |
1010 | { return (wxDataViewListStore*) GetModel(); } | |
1011 | const wxDataViewListStore *GetStore() const | |
1012 | { return (const wxDataViewListStore*) GetModel(); } | |
1013 | ||
17de95e4 | 1014 | int ItemToRow(const wxDataViewItem &item) const |
780e4fd0 | 1015 | { return item.IsOk() ? (int)GetStore()->GetRow(item) : wxNOT_FOUND; } |
17de95e4 VS |
1016 | wxDataViewItem RowToItem(int row) const |
1017 | { return row == wxNOT_FOUND ? wxDataViewItem() : GetStore()->GetItem(row); } | |
1018 | ||
fa629ada VS |
1019 | int GetSelectedRow() const |
1020 | { return ItemToRow(GetSelection()); } | |
1021 | void SelectRow(unsigned row) | |
1022 | { Select(RowToItem(row)); } | |
1023 | void UnselectRow(unsigned row) | |
1024 | { Unselect(RowToItem(row)); } | |
1025 | bool IsRowSelected(unsigned row) const | |
1026 | { return IsSelected(RowToItem(row)); } | |
1027 | ||
95b20f41 RR |
1028 | bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
1029 | bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); | |
1030 | bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); | |
8c2654ce | 1031 | |
95b20f41 RR |
1032 | // overridden from base class |
1033 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
1034 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); | |
1035 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
1036 | ||
f54e5c1a VZ |
1037 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
1038 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1039 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1040 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
1041 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
dc813e6c | 1042 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1043 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
1044 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1045 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1046 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
1047 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c RR |
1048 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
1049 | ||
1050 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1051 | { GetStore()->AppendItem( values, data ); } | |
1052 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1053 | { GetStore()->PrependItem( values, data ); } | |
1054 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1055 | { GetStore()->InsertItem( row, values, data ); } | |
1056 | void DeleteItem( unsigned row ) | |
1057 | { GetStore()->DeleteItem( row ); } | |
1058 | void DeleteAllItems() | |
1059 | { GetStore()->DeleteAllItems(); } | |
1060 | ||
1061 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) | |
f54e5c1a | 1062 | { GetStore()->SetValueByRow( value, row, col ); |
832df171 RR |
1063 | GetStore()->RowValueChanged( row, col); } |
1064 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ) | |
1065 | { GetStore()->GetValueByRow( value, row, col ); } | |
dc813e6c RR |
1066 | |
1067 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) | |
832df171 RR |
1068 | { GetStore()->SetValueByRow( value, row, col ); |
1069 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1070 | wxString GetTextValue( unsigned int row, unsigned int col ) const |
1071 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } | |
1072 | ||
1073 | void SetToggleValue( bool value, unsigned int row, unsigned int col ) | |
832df171 RR |
1074 | { GetStore()->SetValueByRow( value, row, col ); |
1075 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1076 | bool GetToggleValue( unsigned int row, unsigned int col ) const |
1077 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } | |
1078 | ||
1079 | void OnSize( wxSizeEvent &event ); | |
1080 | ||
1081 | private: | |
1082 | DECLARE_EVENT_TABLE() | |
1083 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl) | |
1084 | }; | |
8eff6c56 | 1085 | |
e94d0c1e RR |
1086 | //----------------------------------------------------------------------------- |
1087 | // wxDataViewTreeStore | |
1088 | //----------------------------------------------------------------------------- | |
1089 | ||
1090 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
1091 | { | |
1092 | public: | |
1093 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
1094 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1095 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
1096 | |
1097 | void SetText( const wxString &text ) | |
e94d0c1e RR |
1098 | { m_text = text; } |
1099 | wxString GetText() const | |
1100 | { return m_text; } | |
1101 | void SetIcon( const wxIcon &icon ) | |
1102 | { m_icon = icon; } | |
1103 | const wxIcon &GetIcon() const | |
1104 | { return m_icon; } | |
1105 | void SetData( wxClientData *data ) | |
1106 | { if (m_data) delete m_data; m_data = data; } | |
1107 | wxClientData *GetData() const | |
1108 | { return m_data; } | |
b5ec7dd6 | 1109 | |
e94d0c1e RR |
1110 | wxDataViewItem GetItem() const |
1111 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 1112 | |
e94d0c1e RR |
1113 | virtual bool IsContainer() |
1114 | { return false; } | |
b5ec7dd6 | 1115 | |
e94d0c1e RR |
1116 | wxDataViewTreeStoreNode *GetParent() |
1117 | { return m_parent; } | |
b5ec7dd6 | 1118 | |
e94d0c1e RR |
1119 | private: |
1120 | wxDataViewTreeStoreNode *m_parent; | |
1121 | wxString m_text; | |
1122 | wxIcon m_icon; | |
1123 | wxClientData *m_data; | |
1124 | }; | |
1125 | ||
1126 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
1127 | class WXDLLIMPEXP_ADV); | |
1128 | ||
1129 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
1130 | { | |
1131 | public: | |
b5ec7dd6 VZ |
1132 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
1133 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1134 | wxClientData *data = NULL ); |
1135 | virtual ~wxDataViewTreeStoreContainerNode(); | |
1136 | ||
b5ec7dd6 | 1137 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 1138 | { return m_children; } |
b5ec7dd6 | 1139 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
1140 | { return m_children; } |
1141 | ||
1142 | void SetExpandedIcon( const wxIcon &icon ) | |
1143 | { m_iconExpanded = icon; } | |
1144 | const wxIcon &GetExpandedIcon() const | |
1145 | { return m_iconExpanded; } | |
b5ec7dd6 | 1146 | |
a75124d0 RR |
1147 | void SetExpanded( bool expanded = true ) |
1148 | { m_isExpanded = expanded; } | |
1149 | bool IsExpanded() const | |
1150 | { return m_isExpanded; } | |
1151 | ||
e94d0c1e RR |
1152 | virtual bool IsContainer() |
1153 | { return true; } | |
b5ec7dd6 | 1154 | |
e94d0c1e RR |
1155 | private: |
1156 | wxDataViewTreeStoreNodeList m_children; | |
1157 | wxIcon m_iconExpanded; | |
a75124d0 | 1158 | bool m_isExpanded; |
e94d0c1e RR |
1159 | }; |
1160 | ||
1161 | //----------------------------------------------------------------------------- | |
1162 | ||
1163 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
1164 | { | |
1165 | public: | |
1166 | wxDataViewTreeStore(); | |
1167 | ~wxDataViewTreeStore(); | |
1168 | ||
b5ec7dd6 | 1169 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
1170 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
1171 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1172 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1173 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1174 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
1175 | |
1176 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1177 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1178 | wxClientData *data = NULL ); |
1179 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 1180 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1181 | wxClientData *data = NULL ); |
1182 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 1183 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1184 | wxClientData *data = NULL ); |
1185 | ||
1186 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
1187 | int GetChildCount( const wxDataViewItem& parent ) const; | |
ce00f59b | 1188 | |
e94d0c1e RR |
1189 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
1190 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 1191 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
1192 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
1193 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
1194 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
1195 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
1196 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
1197 | ||
1198 | void DeleteItem( const wxDataViewItem& item ); | |
1199 | void DeleteChildren( const wxDataViewItem& item ); | |
1200 | void DeleteAllItems(); | |
b5ec7dd6 | 1201 | |
e94d0c1e RR |
1202 | // implement base methods |
1203 | ||
b5ec7dd6 | 1204 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 1205 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 1206 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
1207 | const wxDataViewItem &item, unsigned int col ); |
1208 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
1209 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
1210 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
1211 | ||
b5ec7dd6 | 1212 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
862de7b3 | 1213 | unsigned int column, bool ascending ) const; |
b5ec7dd6 VZ |
1214 | |
1215 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 1216 | { return true; } |
b5ec7dd6 | 1217 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 1218 | { return 1; }; |
b5ec7dd6 | 1219 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 1220 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 1221 | |
e94d0c1e RR |
1222 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
1223 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
1224 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 1225 | |
e94d0c1e RR |
1226 | public: |
1227 | wxDataViewTreeStoreNode *m_root; | |
1228 | }; | |
1229 | ||
dc813e6c RR |
1230 | //----------------------------------------------------------------------------- |
1231 | ||
e94d0c1e RR |
1232 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl |
1233 | { | |
1234 | public: | |
43c64cc6 VZ |
1235 | wxDataViewTreeCtrl() { Init(); } |
1236 | wxDataViewTreeCtrl(wxWindow *parent, | |
1237 | wxWindowID id, | |
1238 | const wxPoint& pos = wxDefaultPosition, | |
1239 | const wxSize& size = wxDefaultSize, | |
1240 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, | |
1241 | const wxValidator& validator = wxDefaultValidator) | |
1242 | { | |
1243 | Init(); | |
e94d0c1e | 1244 | |
43c64cc6 VZ |
1245 | Create(parent, id, pos, size, style, validator); |
1246 | } | |
1247 | ||
1248 | virtual ~wxDataViewTreeCtrl(); | |
1249 | ||
1250 | bool Create(wxWindow *parent, | |
1251 | wxWindowID id, | |
1252 | const wxPoint& pos = wxDefaultPosition, | |
1253 | const wxSize& size = wxDefaultSize, | |
1254 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, | |
1255 | const wxValidator& validator = wxDefaultValidator); | |
e94d0c1e RR |
1256 | |
1257 | wxDataViewTreeStore *GetStore() | |
1258 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
1259 | const wxDataViewTreeStore *GetStore() const |
1260 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 1261 | |
8ddda15b RR |
1262 | bool IsContainer( const wxDataViewItem& item ) const |
1263 | { return GetStore()->IsContainer(item); } | |
1264 | ||
a75124d0 RR |
1265 | void SetImageList( wxImageList *imagelist ); |
1266 | wxImageList* GetImageList() { return m_imageList; } | |
c058cafa | 1267 | |
a75124d0 RR |
1268 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
1269 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1270 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1271 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1272 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1273 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1274 | ||
1275 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1276 | const wxString &text, int icon = -1, int expanded = -1, | |
1277 | wxClientData *data = NULL ); | |
1278 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
1279 | const wxString &text, int icon = -1, int expanded = -1, | |
1280 | wxClientData *data = NULL ); | |
1281 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1282 | const wxString &text, int icon = -1, int expanded = -1, | |
1283 | wxClientData *data = NULL ); | |
1284 | ||
1285 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
1286 | { return GetStore()->GetNthChild(parent, pos); } | |
1287 | int GetChildCount( const wxDataViewItem& parent ) const | |
1288 | { return GetStore()->GetChildCount(parent); } | |
1289 | ||
e700e296 | 1290 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
a75124d0 RR |
1291 | wxString GetItemText( const wxDataViewItem& item ) const |
1292 | { return GetStore()->GetItemText(item); } | |
e700e296 | 1293 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1294 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const |
1295 | { return GetStore()->GetItemIcon(item); } | |
e700e296 | 1296 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1297 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const |
1298 | { return GetStore()->GetItemExpandedIcon(item); } | |
1299 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1300 | { GetStore()->SetItemData(item,data); } | |
1301 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1302 | { return GetStore()->GetItemData(item); } | |
1303 | ||
e700e296 RR |
1304 | void DeleteItem( const wxDataViewItem& item ); |
1305 | void DeleteChildren( const wxDataViewItem& item ); | |
1306 | void DeleteAllItems(); | |
a75124d0 RR |
1307 | |
1308 | void OnExpanded( wxDataViewEvent &event ); | |
1309 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1310 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1311 | |
e94d0c1e | 1312 | private: |
43c64cc6 VZ |
1313 | void Init() |
1314 | { | |
1315 | m_imageList = NULL; | |
1316 | } | |
1317 | ||
1318 | wxImageList *m_imageList; | |
a75124d0 RR |
1319 | |
1320 | private: | |
1321 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1322 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1323 | }; | |
e94d0c1e | 1324 | |
bcd846ea RR |
1325 | #endif // wxUSE_DATAVIEWCTRL |
1326 | ||
1327 | #endif | |
1328 | // _WX_DATAVIEW_H_BASE_ |