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