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