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