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