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