]>
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 | 6 | // Created: 08.01.06 |
bcd846ea RR |
7 | // Copyright: (c) Robert Roebling |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_DATAVIEW_H_BASE_ | |
12 | #define _WX_DATAVIEW_H_BASE_ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_DATAVIEWCTRL | |
17 | ||
239eaa41 | 18 | #include "wx/textctrl.h" |
56873923 | 19 | #include "wx/headercol.h" |
64ffb888 | 20 | #include "wx/variant.h" |
c04be1a2 | 21 | #include "wx/dnd.h" // For wxDragResult declaration only. |
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 | ||
1582a1db | 231 | // define hierarchy |
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 | // implement base methods |
74fe973b | 380 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
b5ec7dd6 | 381 | |
9330d5af | 382 | unsigned int GetCount() const { return m_hash.GetCount(); } |
c058cafa | 383 | |
c534e696 | 384 | private: |
cd722937 | 385 | wxDataViewItemArray m_hash; |
9330d5af | 386 | unsigned int m_nextFreeID; |
517166e6 | 387 | bool m_ordered; |
239eaa41 RR |
388 | }; |
389 | ||
e39de702 RR |
390 | // --------------------------------------------------------- |
391 | // wxDataViewVirtualListModel | |
392 | // --------------------------------------------------------- | |
393 | ||
394 | #ifdef __WXMAC__ | |
395 | // better than nothing | |
f1399150 | 396 | typedef wxDataViewIndexListModel wxDataViewVirtualListModel; |
e39de702 RR |
397 | #else |
398 | ||
2feacb6e | 399 | class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewListModel |
e39de702 RR |
400 | { |
401 | public: | |
402 | wxDataViewVirtualListModel( unsigned int initial_size = 0 ); | |
e39de702 RR |
403 | |
404 | void RowPrepended(); | |
405 | void RowInserted( unsigned int before ); | |
406 | void RowAppended(); | |
407 | void RowDeleted( unsigned int row ); | |
408 | void RowsDeleted( const wxArrayInt &rows ); | |
409 | void RowChanged( unsigned int row ); | |
410 | void RowValueChanged( unsigned int row, unsigned int col ); | |
411 | void Reset( unsigned int new_size ); | |
412 | ||
413 | // convert to/from row/wxDataViewItem | |
414 | ||
2feacb6e | 415 | virtual unsigned GetRow( const wxDataViewItem &item ) const; |
e39de702 RR |
416 | wxDataViewItem GetItem( unsigned int row ) const; |
417 | ||
418 | // compare based on index | |
419 | ||
420 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
862de7b3 | 421 | unsigned int column, bool ascending ) const; |
e39de702 RR |
422 | virtual bool HasDefaultCompare() const; |
423 | ||
424 | // implement base methods | |
e39de702 RR |
425 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
426 | ||
74d9b8fb VZ |
427 | unsigned int GetCount() const { return m_size; } |
428 | ||
e39de702 RR |
429 | // internal |
430 | virtual bool IsVirtualListModel() const { return true; } | |
e39de702 RR |
431 | |
432 | private: | |
9330d5af | 433 | unsigned int m_size; |
e39de702 RR |
434 | }; |
435 | #endif | |
c33edc08 | 436 | |
6eec70b9 VZ |
437 | // ---------------------------------------------------------------------------- |
438 | // wxDataViewRenderer and related classes | |
439 | // ---------------------------------------------------------------------------- | |
89352653 | 440 | |
6eec70b9 | 441 | #include "wx/dvrenderers.h" |
89352653 | 442 | |
f554a14b | 443 | // --------------------------------------------------------- |
6842a71a | 444 | // wxDataViewColumnBase |
f554a14b | 445 | // --------------------------------------------------------- |
6842a71a | 446 | |
56873923 | 447 | // for compatibility only, do not use |
fa28826d RR |
448 | enum wxDataViewColumnFlags |
449 | { | |
56873923 VZ |
450 | wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE, |
451 | wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE, | |
452 | wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE, | |
453 | wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN | |
fa28826d RR |
454 | }; |
455 | ||
dcb6cbec | 456 | class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn |
fa28826d RR |
457 | { |
458 | public: | |
e2bfe673 VZ |
459 | // ctor for the text columns: takes ownership of renderer |
460 | wxDataViewColumnBase(wxDataViewRenderer *renderer, | |
461 | unsigned int model_column) | |
462 | { | |
463 | Init(renderer, model_column); | |
464 | } | |
465 | ||
466 | // ctor for the bitmap columns | |
467 | wxDataViewColumnBase(const wxBitmap& bitmap, | |
468 | wxDataViewRenderer *renderer, | |
469 | unsigned int model_column) | |
470 | : m_bitmap(bitmap) | |
471 | { | |
472 | Init(renderer, model_column); | |
473 | } | |
474 | ||
d3c7fc99 | 475 | virtual ~wxDataViewColumnBase(); |
fa28826d | 476 | |
9861f022 | 477 | // setters: |
b5ec7dd6 | 478 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 | 479 | { m_owner = owner; } |
f554a14b | 480 | |
9861f022 | 481 | // getters: |
e86edab0 | 482 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
594d5596 RR |
483 | wxDataViewCtrl *GetOwner() const { return m_owner; } |
484 | wxDataViewRenderer* GetRenderer() const { return m_renderer; } | |
9861f022 | 485 | |
56873923 VZ |
486 | // implement some of base class pure virtuals (the rest is port-dependent |
487 | // and done differently in generic and native versions) | |
488 | virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } | |
489 | virtual wxBitmap GetBitmap() const { return m_bitmap; } | |
56873923 | 490 | |
9861f022 | 491 | protected: |
baa9ebc4 | 492 | wxDataViewRenderer *m_renderer; |
6842a71a | 493 | int m_model_column; |
07a84e7b | 494 | wxBitmap m_bitmap; |
6842a71a | 495 | wxDataViewCtrl *m_owner; |
fa28826d | 496 | |
e2bfe673 VZ |
497 | private: |
498 | // common part of all ctors | |
499 | void Init(wxDataViewRenderer *renderer, unsigned int model_column); | |
fa28826d RR |
500 | }; |
501 | ||
f554a14b | 502 | // --------------------------------------------------------- |
239eaa41 | 503 | // wxDataViewCtrlBase |
f554a14b | 504 | // --------------------------------------------------------- |
239eaa41 | 505 | |
c21f7aa1 | 506 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
507 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
508 | ||
509 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
510 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
511 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 512 | |
1a07a730 | 513 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows |
344ed1f3 | 514 | #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height |
1a07a730 | 515 | |
f460c29d | 516 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
517 | { |
518 | public: | |
519 | wxDataViewCtrlBase(); | |
d3c7fc99 | 520 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 521 | |
ce468dc2 FM |
522 | // model |
523 | // ----- | |
524 | ||
e0062c04 RR |
525 | virtual bool AssociateModel( wxDataViewModel *model ); |
526 | wxDataViewModel* GetModel(); | |
a75124d0 | 527 | const wxDataViewModel* GetModel() const; |
f554a14b | 528 | |
ce468dc2 FM |
529 | |
530 | // column management | |
531 | // ----------------- | |
532 | ||
b5ec7dd6 | 533 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 534 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 535 | wxAlignment align = wxALIGN_NOT, |
736fe67c | 536 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 537 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 538 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 539 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
540 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
541 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
542 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
543 | wxAlignment align = wxALIGN_CENTER, | |
544 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 545 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
546 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
547 | wxAlignment align = wxALIGN_CENTER, | |
548 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
549 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
550 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 551 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
552 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
553 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
554 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
555 | wxAlignment align = wxALIGN_CENTER, | |
556 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
557 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
558 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 559 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
560 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
561 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
562 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 563 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
564 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
565 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
566 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
567 | wxAlignment align = wxALIGN_CENTER, | |
568 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
569 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
570 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
571 | wxAlignment align = wxALIGN_CENTER, | |
572 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
573 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
574 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 575 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
576 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
577 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
578 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
579 | wxAlignment align = wxALIGN_CENTER, | |
580 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
581 | |
582 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 583 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 584 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 585 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 586 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 587 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 588 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 589 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 590 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
591 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
592 | wxAlignment align = wxALIGN_CENTER, | |
593 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 594 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
595 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
596 | wxAlignment align = wxALIGN_CENTER, | |
597 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 598 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 599 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 600 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 601 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 602 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
603 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
604 | wxAlignment align = wxALIGN_CENTER, | |
605 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 606 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 607 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 608 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 609 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
610 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
611 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 612 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 613 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 614 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
615 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
616 | wxAlignment align = wxALIGN_CENTER, | |
617 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 618 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
619 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
620 | wxAlignment align = wxALIGN_CENTER, | |
621 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 622 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 623 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 624 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 625 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 626 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
627 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
628 | wxAlignment align = wxALIGN_CENTER, | |
629 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c | 630 | |
736fe67c | 631 | virtual bool PrependColumn( wxDataViewColumn *col ); |
19723525 | 632 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
f554a14b | 633 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 634 | |
91a6c655 RR |
635 | virtual unsigned int GetColumnCount() const = 0; |
636 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 637 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 638 | |
91a6c655 RR |
639 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
640 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 641 | |
1b27b2bd | 642 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 643 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 644 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 645 | { return m_expander_column; } |
b5ec7dd6 | 646 | |
21f47fb9 | 647 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
23318a53 | 648 | |
ce468dc2 FM |
649 | |
650 | // items management | |
651 | // ---------------- | |
652 | ||
3b6280be RR |
653 | void SetIndent( int indent ) |
654 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
655 | int GetIndent() const |
656 | { return m_indent; } | |
3b6280be | 657 | |
80ce465c VZ |
658 | // Current item is the one used by the keyboard navigation, it is the same |
659 | // as the (unique) selected item in single selection mode so these | |
660 | // functions are mostly useful for controls with wxDV_MULTIPLE style. | |
661 | wxDataViewItem GetCurrentItem() const; | |
662 | void SetCurrentItem(const wxDataViewItem& item); | |
663 | ||
ee1377e1 VS |
664 | // Currently focused column of the current item or NULL if no column has focus |
665 | virtual wxDataViewColumn *GetCurrentColumn() const = 0; | |
666 | ||
fa93d732 VZ |
667 | // Selection: both GetSelection() and GetSelections() can be used for the |
668 | // controls both with and without wxDV_MULTIPLE style. For single selection | |
669 | // controls GetSelections() is not very useful however. And for multi | |
670 | // selection controls GetSelection() returns an invalid item if more than | |
671 | // one item is selected. Use GetSelectedItemsCount() or HasSelection() to | |
672 | // check if any items are selected at all. | |
673 | virtual int GetSelectedItemsCount() const = 0; | |
674 | bool HasSelection() const { return GetSelectedItemsCount() != 0; } | |
675 | wxDataViewItem GetSelection() const; | |
b7e9f8b1 RR |
676 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
677 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
678 | virtual void Select( const wxDataViewItem & item ) = 0; | |
679 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
680 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
681 | ||
b7e9f8b1 RR |
682 | virtual void SelectAll() = 0; |
683 | virtual void UnselectAll() = 0; | |
684 | ||
f71d3ba4 | 685 | virtual void Expand( const wxDataViewItem & item ) = 0; |
4219d8b0 | 686 | virtual void ExpandAncestors( const wxDataViewItem & item ); |
f71d3ba4 | 687 | virtual void Collapse( const wxDataViewItem & item ) = 0; |
739a8399 | 688 | virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; |
f71d3ba4 | 689 | |
6154212e | 690 | virtual void EnsureVisible( const wxDataViewItem & item, |
4219d8b0 | 691 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 692 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 693 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
bbfd4548 VZ |
694 | |
695 | virtual bool SetRowHeight( int WXUNUSED(rowHeight) ) { return false; } | |
696 | ||
907f09f4 VS |
697 | virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) = 0; |
698 | ||
699 | // Use EditItem() instead | |
700 | wxDEPRECATED( void StartEditor(const wxDataViewItem& item, unsigned int column) ); | |
8c2654ce | 701 | |
f54e5c1a VZ |
702 | #if wxUSE_DRAG_AND_DROP |
703 | virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format)) | |
704 | { return false; } | |
705 | virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format)) | |
706 | { return false; } | |
707 | #endif // wxUSE_DRAG_AND_DROP | |
b7e9f8b1 | 708 | |
2fa90e33 VZ |
709 | // define control visual attributes |
710 | // -------------------------------- | |
711 | ||
712 | virtual wxVisualAttributes GetDefaultAttributes() const | |
713 | { | |
714 | return GetClassDefaultAttributes(GetWindowVariant()); | |
715 | } | |
716 | ||
717 | static wxVisualAttributes | |
718 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) | |
719 | { | |
720 | return wxControl::GetCompositeControlsDefaultAttributes(variant); | |
721 | } | |
722 | ||
3b6280be RR |
723 | protected: |
724 | virtual void DoSetExpanderColumn() = 0 ; | |
725 | virtual void DoSetIndent() = 0; | |
726 | ||
239eaa41 | 727 | private: |
80ce465c VZ |
728 | // Implementation of the public Set/GetCurrentItem() methods which are only |
729 | // called in multi selection case (for single selection controls their | |
730 | // implementation is trivial and is done in the base class itself). | |
731 | virtual wxDataViewItem DoGetCurrentItem() const = 0; | |
732 | virtual void DoSetCurrentItem(const wxDataViewItem& item) = 0; | |
733 | ||
e0062c04 | 734 | wxDataViewModel *m_model; |
1b27b2bd | 735 | wxDataViewColumn *m_expander_column; |
3b6280be | 736 | int m_indent ; |
b5ec7dd6 | 737 | |
239eaa41 | 738 | protected: |
260b9be7 | 739 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 740 | }; |
bcd846ea | 741 | |
eb7f97f8 RR |
742 | // ---------------------------------------------------------------------------- |
743 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
744 | // ---------------------------------------------------------------------------- | |
745 | ||
2f799ae8 | 746 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
747 | { |
748 | public: | |
749 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
750 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 751 | m_item(0), |
eb7f97f8 | 752 | m_col(-1), |
eb7f97f8 RR |
753 | m_model(NULL), |
754 | m_value(wxNullVariant), | |
6af3eec2 | 755 | m_column(NULL), |
47a8b1e1 VZ |
756 | m_pos(-1,-1), |
757 | m_cacheFrom(0), | |
2a648479 VZ |
758 | m_cacheTo(0), |
759 | m_editCancelled(false) | |
6effcb7c FM |
760 | #if wxUSE_DRAG_AND_DROP |
761 | , m_dataObject(NULL), | |
e4de825e | 762 | m_dataBuffer(NULL), |
c04be1a2 VZ |
763 | m_dataSize(0), |
764 | m_dragFlags(0), | |
765 | m_dropEffect(wxDragNone) | |
6effcb7c | 766 | #endif |
eb7f97f8 RR |
767 | { } |
768 | ||
769 | wxDataViewEvent(const wxDataViewEvent& event) | |
770 | : wxNotifyEvent(event), | |
e0062c04 | 771 | m_item(event.m_item), |
eb7f97f8 | 772 | m_col(event.m_col), |
eb7f97f8 RR |
773 | m_model(event.m_model), |
774 | m_value(event.m_value), | |
6af3eec2 | 775 | m_column(event.m_column), |
4bc3adad | 776 | m_pos(event.m_pos), |
47a8b1e1 | 777 | m_cacheFrom(event.m_cacheFrom), |
2a648479 VZ |
778 | m_cacheTo(event.m_cacheTo), |
779 | m_editCancelled(event.m_editCancelled) | |
6effcb7c FM |
780 | #if wxUSE_DRAG_AND_DROP |
781 | , m_dataObject(event.m_dataObject), | |
e4de825e RR |
782 | m_dataFormat(event.m_dataFormat), |
783 | m_dataBuffer(event.m_dataBuffer), | |
c04be1a2 VZ |
784 | m_dataSize(event.m_dataSize), |
785 | m_dragFlags(event.m_dragFlags), | |
786 | m_dropEffect(event.m_dropEffect) | |
6effcb7c | 787 | #endif |
eb7f97f8 RR |
788 | { } |
789 | ||
e0062c04 RR |
790 | wxDataViewItem GetItem() const { return m_item; } |
791 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
792 | ||
eb7f97f8 RR |
793 | int GetColumn() const { return m_col; } |
794 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 795 | |
eb7f97f8 RR |
796 | wxDataViewModel* GetModel() const { return m_model; } |
797 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 798 | |
eb7f97f8 RR |
799 | const wxVariant &GetValue() const { return m_value; } |
800 | void SetValue( const wxVariant &value ) { m_value = value; } | |
801 | ||
ce7fe42e | 802 | // for wxEVT_DATAVIEW_ITEM_EDITING_DONE only |
2a648479 VZ |
803 | bool IsEditCancelled() const { return m_editCancelled; } |
804 | void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } | |
805 | ||
31fb32e1 RR |
806 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
807 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 808 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
c058cafa | 809 | |
6af3eec2 | 810 | // for wxEVT_DATAVIEW_CONTEXT_MENU only |
5cfb6fee | 811 | wxPoint GetPosition() const { return m_pos; } |
6af3eec2 | 812 | void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } |
31fb32e1 | 813 | |
ce7fe42e | 814 | // For wxEVT_DATAVIEW_CACHE_HINT |
47a8b1e1 VZ |
815 | int GetCacheFrom() const { return m_cacheFrom; } |
816 | int GetCacheTo() const { return m_cacheTo; } | |
817 | void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; } | |
818 | ||
819 | ||
62c9b3d7 | 820 | #if wxUSE_DRAG_AND_DROP |
e4de825e | 821 | // For drag operations |
591cc82d | 822 | void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } |
e4de825e | 823 | wxDataObject *GetDataObject() const { return m_dataObject; } |
8c2654ce | 824 | |
e4de825e RR |
825 | // For drop operations |
826 | void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } | |
827 | wxDataFormat GetDataFormat() const { return m_dataFormat; } | |
828 | void SetDataSize( size_t size ) { m_dataSize = size; } | |
829 | size_t GetDataSize() const { return m_dataSize; } | |
830 | void SetDataBuffer( void* buf ) { m_dataBuffer = buf;} | |
831 | void *GetDataBuffer() const { return m_dataBuffer; } | |
c04be1a2 VZ |
832 | void SetDragFlags( int flags ) { m_dragFlags = flags; } |
833 | int GetDragFlags() const { return m_dragFlags; } | |
834 | void SetDropEffect( wxDragResult effect ) { m_dropEffect = effect; } | |
835 | wxDragResult GetDropEffect() const { return m_dropEffect; } | |
664e1314 | 836 | #endif // wxUSE_DRAG_AND_DROP |
15cac64f | 837 | |
eb7f97f8 RR |
838 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
839 | ||
840 | protected: | |
e0062c04 | 841 | wxDataViewItem m_item; |
eb7f97f8 | 842 | int m_col; |
eb7f97f8 RR |
843 | wxDataViewModel *m_model; |
844 | wxVariant m_value; | |
31fb32e1 | 845 | wxDataViewColumn *m_column; |
6af3eec2 | 846 | wxPoint m_pos; |
47a8b1e1 VZ |
847 | int m_cacheFrom; |
848 | int m_cacheTo; | |
2a648479 | 849 | bool m_editCancelled; |
8c2654ce | 850 | |
5e14f15d | 851 | #if wxUSE_DRAG_AND_DROP |
591cc82d | 852 | wxDataObject *m_dataObject; |
8c2654ce | 853 | |
e4de825e RR |
854 | wxDataFormat m_dataFormat; |
855 | void* m_dataBuffer; | |
856 | size_t m_dataSize; | |
c04be1a2 VZ |
857 | |
858 | int m_dragFlags; | |
859 | wxDragResult m_dropEffect; | |
5e14f15d | 860 | #endif // wxUSE_DRAG_AND_DROP |
eb7f97f8 RR |
861 | |
862 | private: | |
863 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
864 | }; | |
865 | ||
ce7fe42e | 866 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); |
9b11752c | 867 | |
ce7fe42e VZ |
868 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); |
869 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); | |
870 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); | |
871 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); | |
872 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); | |
873 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); | |
874 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); | |
875 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); | |
876 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); | |
9b11752c | 877 | |
ce7fe42e | 878 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); |
9b11752c | 879 | |
ce7fe42e | 880 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); |
3bc1418b | 881 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); |
ce7fe42e VZ |
882 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); |
883 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); | |
9b11752c | 884 | |
ce7fe42e | 885 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_CACHE_HINT, wxDataViewEvent ); |
47a8b1e1 | 886 | |
ce7fe42e VZ |
887 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); |
888 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); | |
889 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent ); | |
15cac64f | 890 | |
eb7f97f8 RR |
891 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); |
892 | ||
893 | #define wxDataViewEventHandler(func) \ | |
3c778901 | 894 | wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func) |
eb7f97f8 RR |
895 | |
896 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
ce7fe42e | 897 | wx__DECLARE_EVT1(wxEVT_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) |
eb7f97f8 | 898 | |
d86c1870 RR |
899 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
900 | ||
e0062c04 | 901 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 902 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 903 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 904 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 905 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
3e978cf7 | 906 | #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn) |
e0000f94 RR |
907 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
908 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 909 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 910 | |
6af3eec2 RR |
911 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
912 | ||
31fb32e1 | 913 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
f6b82656 | 914 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) |
c0a66d92 | 915 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
e483dfcb | 916 | #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) |
47a8b1e1 | 917 | #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn) |
eb7f97f8 | 918 | |
591cc82d | 919 | #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) |
e4de825e RR |
920 | #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) |
921 | #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn) | |
fe9fb970 | 922 | |
f6b82656 VZ |
923 | // Old and not documented synonym, don't use. |
924 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn) | |
925 | ||
56873923 | 926 | #ifdef wxHAS_GENERIC_DATAVIEWCTRL |
56873923 VZ |
927 | #include "wx/generic/dataview.h" |
928 | #elif defined(__WXGTK20__) | |
bcd846ea | 929 | #include "wx/gtk/dataview.h" |
56873923 | 930 | #elif defined(__WXMAC__) |
ef0e9220 | 931 | #include "wx/osx/dataview.h" |
bcd846ea | 932 | #else |
56873923 | 933 | #error "unknown native wxDataViewCtrl implementation" |
bcd846ea RR |
934 | #endif |
935 | ||
8eff6c56 RR |
936 | //----------------------------------------------------------------------------- |
937 | // wxDataViewListStore | |
938 | //----------------------------------------------------------------------------- | |
939 | ||
940 | class WXDLLIMPEXP_ADV wxDataViewListStoreLine | |
941 | { | |
942 | public: | |
c0a2b718 | 943 | wxDataViewListStoreLine( wxUIntPtr data = 0 ) |
8eff6c56 RR |
944 | { |
945 | m_data = data; | |
946 | } | |
8eff6c56 | 947 | |
41abc29a VZ |
948 | void SetData( wxUIntPtr data ) |
949 | { m_data = data; } | |
950 | wxUIntPtr GetData() const | |
8eff6c56 | 951 | { return m_data; } |
8c2654ce | 952 | |
8eff6c56 | 953 | wxVector<wxVariant> m_values; |
8c2654ce | 954 | |
8eff6c56 | 955 | private: |
41abc29a | 956 | wxUIntPtr m_data; |
8eff6c56 RR |
957 | }; |
958 | ||
959 | ||
960 | class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel | |
961 | { | |
962 | public: | |
963 | wxDataViewListStore(); | |
964 | ~wxDataViewListStore(); | |
965 | ||
966 | void PrependColumn( const wxString &varianttype ); | |
967 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
968 | void AppendColumn( const wxString &varianttype ); | |
8c2654ce | 969 | |
c0a2b718 PC |
970 | void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); |
971 | void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); | |
972 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); | |
8af28fab | 973 | void DeleteItem( unsigned int pos ); |
8eff6c56 RR |
974 | void DeleteAllItems(); |
975 | ||
5fb4b6cd VZ |
976 | unsigned int GetItemCount() const; |
977 | ||
518cef04 VZ |
978 | void SetItemData( const wxDataViewItem& item, wxUIntPtr data ); |
979 | wxUIntPtr GetItemData( const wxDataViewItem& item ) const; | |
980 | ||
8eff6c56 RR |
981 | // override base virtuals |
982 | ||
983 | virtual unsigned int GetColumnCount() const; | |
984 | ||
985 | virtual wxString GetColumnType( unsigned int col ) const; | |
986 | ||
987 | virtual void GetValueByRow( wxVariant &value, | |
988 | unsigned int row, unsigned int col ) const; | |
989 | ||
990 | virtual bool SetValueByRow( const wxVariant &value, | |
991 | unsigned int row, unsigned int col ); | |
992 | ||
8c2654ce | 993 | |
8eff6c56 RR |
994 | public: |
995 | wxVector<wxDataViewListStoreLine*> m_data; | |
996 | wxArrayString m_cols; | |
997 | }; | |
998 | ||
dc813e6c RR |
999 | //----------------------------------------------------------------------------- |
1000 | ||
1001 | class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl | |
1002 | { | |
1003 | public: | |
1004 | wxDataViewListCtrl(); | |
1005 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
1006 | const wxPoint& pos = wxDefaultPosition, | |
1007 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1008 | const wxValidator& validator = wxDefaultValidator ); | |
1009 | ~wxDataViewListCtrl(); | |
1010 | ||
1011 | bool Create( wxWindow *parent, wxWindowID id, | |
1012 | const wxPoint& pos = wxDefaultPosition, | |
1013 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1014 | const wxValidator& validator = wxDefaultValidator ); | |
1015 | ||
1016 | wxDataViewListStore *GetStore() | |
1017 | { return (wxDataViewListStore*) GetModel(); } | |
1018 | const wxDataViewListStore *GetStore() const | |
1019 | { return (const wxDataViewListStore*) GetModel(); } | |
1020 | ||
17de95e4 | 1021 | int ItemToRow(const wxDataViewItem &item) const |
780e4fd0 | 1022 | { return item.IsOk() ? (int)GetStore()->GetRow(item) : wxNOT_FOUND; } |
17de95e4 VS |
1023 | wxDataViewItem RowToItem(int row) const |
1024 | { return row == wxNOT_FOUND ? wxDataViewItem() : GetStore()->GetItem(row); } | |
1025 | ||
fa629ada VS |
1026 | int GetSelectedRow() const |
1027 | { return ItemToRow(GetSelection()); } | |
1028 | void SelectRow(unsigned row) | |
1029 | { Select(RowToItem(row)); } | |
1030 | void UnselectRow(unsigned row) | |
1031 | { Unselect(RowToItem(row)); } | |
1032 | bool IsRowSelected(unsigned row) const | |
1033 | { return IsSelected(RowToItem(row)); } | |
1034 | ||
95b20f41 RR |
1035 | bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
1036 | bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); | |
1037 | bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); | |
8c2654ce | 1038 | |
95b20f41 RR |
1039 | // overridden from base class |
1040 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
1041 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); | |
1042 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
1043 | ||
f54e5c1a VZ |
1044 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
1045 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1046 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1047 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
1048 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
dc813e6c | 1049 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1050 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
1051 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1052 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1053 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
1054 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c RR |
1055 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
1056 | ||
c0a2b718 | 1057 | void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ) |
dc813e6c | 1058 | { GetStore()->AppendItem( values, data ); } |
c0a2b718 | 1059 | void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ) |
dc813e6c | 1060 | { GetStore()->PrependItem( values, data ); } |
c0a2b718 | 1061 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = 0 ) |
dc813e6c RR |
1062 | { GetStore()->InsertItem( row, values, data ); } |
1063 | void DeleteItem( unsigned row ) | |
1064 | { GetStore()->DeleteItem( row ); } | |
1065 | void DeleteAllItems() | |
1066 | { GetStore()->DeleteAllItems(); } | |
1067 | ||
1068 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) | |
f54e5c1a | 1069 | { GetStore()->SetValueByRow( value, row, col ); |
832df171 RR |
1070 | GetStore()->RowValueChanged( row, col); } |
1071 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ) | |
1072 | { GetStore()->GetValueByRow( value, row, col ); } | |
dc813e6c RR |
1073 | |
1074 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) | |
832df171 RR |
1075 | { GetStore()->SetValueByRow( value, row, col ); |
1076 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1077 | wxString GetTextValue( unsigned int row, unsigned int col ) const |
1078 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } | |
1079 | ||
1080 | void SetToggleValue( bool value, unsigned int row, unsigned int col ) | |
832df171 RR |
1081 | { GetStore()->SetValueByRow( value, row, col ); |
1082 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1083 | bool GetToggleValue( unsigned int row, unsigned int col ) const |
1084 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } | |
1085 | ||
518cef04 VZ |
1086 | void SetItemData( const wxDataViewItem& item, wxUIntPtr data ) |
1087 | { GetStore()->SetItemData( item, data ); } | |
1088 | wxUIntPtr GetItemData( const wxDataViewItem& item ) const | |
1089 | { return GetStore()->GetItemData( item ); } | |
1090 | ||
5fb4b6cd VZ |
1091 | int GetItemCount() const |
1092 | { return GetStore()->GetItemCount(); } | |
1093 | ||
dc813e6c RR |
1094 | void OnSize( wxSizeEvent &event ); |
1095 | ||
1096 | private: | |
1097 | DECLARE_EVENT_TABLE() | |
1098 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl) | |
1099 | }; | |
8eff6c56 | 1100 | |
e94d0c1e RR |
1101 | //----------------------------------------------------------------------------- |
1102 | // wxDataViewTreeStore | |
1103 | //----------------------------------------------------------------------------- | |
1104 | ||
1105 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
1106 | { | |
1107 | public: | |
1108 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
1109 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1110 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
1111 | |
1112 | void SetText( const wxString &text ) | |
e94d0c1e RR |
1113 | { m_text = text; } |
1114 | wxString GetText() const | |
1115 | { return m_text; } | |
1116 | void SetIcon( const wxIcon &icon ) | |
1117 | { m_icon = icon; } | |
1118 | const wxIcon &GetIcon() const | |
1119 | { return m_icon; } | |
1120 | void SetData( wxClientData *data ) | |
1121 | { if (m_data) delete m_data; m_data = data; } | |
1122 | wxClientData *GetData() const | |
1123 | { return m_data; } | |
b5ec7dd6 | 1124 | |
e94d0c1e RR |
1125 | wxDataViewItem GetItem() const |
1126 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 1127 | |
e94d0c1e RR |
1128 | virtual bool IsContainer() |
1129 | { return false; } | |
b5ec7dd6 | 1130 | |
e94d0c1e RR |
1131 | wxDataViewTreeStoreNode *GetParent() |
1132 | { return m_parent; } | |
b5ec7dd6 | 1133 | |
e94d0c1e RR |
1134 | private: |
1135 | wxDataViewTreeStoreNode *m_parent; | |
1136 | wxString m_text; | |
1137 | wxIcon m_icon; | |
1138 | wxClientData *m_data; | |
1139 | }; | |
1140 | ||
1141 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
1142 | class WXDLLIMPEXP_ADV); | |
1143 | ||
1144 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
1145 | { | |
1146 | public: | |
b5ec7dd6 VZ |
1147 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
1148 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1149 | wxClientData *data = NULL ); |
1150 | virtual ~wxDataViewTreeStoreContainerNode(); | |
1151 | ||
b5ec7dd6 | 1152 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 1153 | { return m_children; } |
b5ec7dd6 | 1154 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
1155 | { return m_children; } |
1156 | ||
1157 | void SetExpandedIcon( const wxIcon &icon ) | |
1158 | { m_iconExpanded = icon; } | |
1159 | const wxIcon &GetExpandedIcon() const | |
1160 | { return m_iconExpanded; } | |
b5ec7dd6 | 1161 | |
a75124d0 RR |
1162 | void SetExpanded( bool expanded = true ) |
1163 | { m_isExpanded = expanded; } | |
1164 | bool IsExpanded() const | |
1165 | { return m_isExpanded; } | |
1166 | ||
e94d0c1e RR |
1167 | virtual bool IsContainer() |
1168 | { return true; } | |
b5ec7dd6 | 1169 | |
e94d0c1e RR |
1170 | private: |
1171 | wxDataViewTreeStoreNodeList m_children; | |
1172 | wxIcon m_iconExpanded; | |
a75124d0 | 1173 | bool m_isExpanded; |
e94d0c1e RR |
1174 | }; |
1175 | ||
1176 | //----------------------------------------------------------------------------- | |
1177 | ||
1178 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
1179 | { | |
1180 | public: | |
1181 | wxDataViewTreeStore(); | |
1182 | ~wxDataViewTreeStore(); | |
1183 | ||
b5ec7dd6 | 1184 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
1185 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
1186 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1187 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1188 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1189 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
1190 | |
1191 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1192 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1193 | wxClientData *data = NULL ); |
1194 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 1195 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1196 | wxClientData *data = NULL ); |
1197 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 1198 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1199 | wxClientData *data = NULL ); |
1200 | ||
1201 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
1202 | int GetChildCount( const wxDataViewItem& parent ) const; | |
ce00f59b | 1203 | |
e94d0c1e RR |
1204 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
1205 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 1206 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
1207 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
1208 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
1209 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
1210 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
1211 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
1212 | ||
1213 | void DeleteItem( const wxDataViewItem& item ); | |
1214 | void DeleteChildren( const wxDataViewItem& item ); | |
1215 | void DeleteAllItems(); | |
b5ec7dd6 | 1216 | |
e94d0c1e RR |
1217 | // implement base methods |
1218 | ||
b5ec7dd6 | 1219 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 1220 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 1221 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
1222 | const wxDataViewItem &item, unsigned int col ); |
1223 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
1224 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
1225 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
1226 | ||
b5ec7dd6 | 1227 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
862de7b3 | 1228 | unsigned int column, bool ascending ) const; |
b5ec7dd6 VZ |
1229 | |
1230 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 1231 | { return true; } |
b5ec7dd6 | 1232 | virtual unsigned int GetColumnCount() const |
6dd0883d | 1233 | { return 1; } |
b5ec7dd6 | 1234 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 1235 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 1236 | |
e94d0c1e RR |
1237 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
1238 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
1239 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 1240 | |
e94d0c1e RR |
1241 | public: |
1242 | wxDataViewTreeStoreNode *m_root; | |
1243 | }; | |
1244 | ||
dc813e6c RR |
1245 | //----------------------------------------------------------------------------- |
1246 | ||
abfdefed VZ |
1247 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl, |
1248 | public wxWithImages | |
e94d0c1e RR |
1249 | { |
1250 | public: | |
abfdefed | 1251 | wxDataViewTreeCtrl() { } |
43c64cc6 VZ |
1252 | wxDataViewTreeCtrl(wxWindow *parent, |
1253 | wxWindowID id, | |
1254 | const wxPoint& pos = wxDefaultPosition, | |
1255 | const wxSize& size = wxDefaultSize, | |
1256 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, | |
1257 | const wxValidator& validator = wxDefaultValidator) | |
1258 | { | |
43c64cc6 VZ |
1259 | Create(parent, id, pos, size, style, validator); |
1260 | } | |
1261 | ||
43c64cc6 VZ |
1262 | bool Create(wxWindow *parent, |
1263 | wxWindowID id, | |
1264 | const wxPoint& pos = wxDefaultPosition, | |
1265 | const wxSize& size = wxDefaultSize, | |
1266 | long style = wxDV_NO_HEADER | wxDV_ROW_LINES, | |
1267 | const wxValidator& validator = wxDefaultValidator); | |
e94d0c1e RR |
1268 | |
1269 | wxDataViewTreeStore *GetStore() | |
1270 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
1271 | const wxDataViewTreeStore *GetStore() const |
1272 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 1273 | |
8ddda15b RR |
1274 | bool IsContainer( const wxDataViewItem& item ) const |
1275 | { return GetStore()->IsContainer(item); } | |
1276 | ||
a75124d0 | 1277 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
1871b9fa | 1278 | const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); |
a75124d0 | 1279 | wxDataViewItem PrependItem( const wxDataViewItem& parent, |
1871b9fa | 1280 | const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); |
a75124d0 | 1281 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, |
1871b9fa | 1282 | const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL ); |
a75124d0 RR |
1283 | |
1284 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1871b9fa | 1285 | const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, |
a75124d0 RR |
1286 | wxClientData *data = NULL ); |
1287 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
1871b9fa | 1288 | const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, |
a75124d0 RR |
1289 | wxClientData *data = NULL ); |
1290 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1871b9fa | 1291 | const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE, |
a75124d0 RR |
1292 | wxClientData *data = NULL ); |
1293 | ||
1294 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
1295 | { return GetStore()->GetNthChild(parent, pos); } | |
1296 | int GetChildCount( const wxDataViewItem& parent ) const | |
1297 | { return GetStore()->GetChildCount(parent); } | |
1298 | ||
e700e296 | 1299 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
a75124d0 RR |
1300 | wxString GetItemText( const wxDataViewItem& item ) const |
1301 | { return GetStore()->GetItemText(item); } | |
e700e296 | 1302 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1303 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const |
1304 | { return GetStore()->GetItemIcon(item); } | |
e700e296 | 1305 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1306 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const |
1307 | { return GetStore()->GetItemExpandedIcon(item); } | |
1308 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1309 | { GetStore()->SetItemData(item,data); } | |
1310 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1311 | { return GetStore()->GetItemData(item); } | |
1312 | ||
e700e296 RR |
1313 | void DeleteItem( const wxDataViewItem& item ); |
1314 | void DeleteChildren( const wxDataViewItem& item ); | |
1315 | void DeleteAllItems(); | |
a75124d0 RR |
1316 | |
1317 | void OnExpanded( wxDataViewEvent &event ); | |
1318 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1319 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1320 | |
a75124d0 RR |
1321 | private: |
1322 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1323 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1324 | }; | |
e94d0c1e | 1325 | |
ce7fe42e VZ |
1326 | // old wxEVT_COMMAND_* constants |
1327 | #define wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED wxEVT_DATAVIEW_SELECTION_CHANGED | |
1328 | #define wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED wxEVT_DATAVIEW_ITEM_ACTIVATED | |
1329 | #define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED wxEVT_DATAVIEW_ITEM_COLLAPSED | |
1330 | #define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED wxEVT_DATAVIEW_ITEM_EXPANDED | |
1331 | #define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING wxEVT_DATAVIEW_ITEM_COLLAPSING | |
1332 | #define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING wxEVT_DATAVIEW_ITEM_EXPANDING | |
1333 | #define wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING wxEVT_DATAVIEW_ITEM_START_EDITING | |
1334 | #define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED wxEVT_DATAVIEW_ITEM_EDITING_STARTED | |
1335 | #define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE wxEVT_DATAVIEW_ITEM_EDITING_DONE | |
1336 | #define wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED wxEVT_DATAVIEW_ITEM_VALUE_CHANGED | |
1337 | #define wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU wxEVT_DATAVIEW_ITEM_CONTEXT_MENU | |
1338 | #define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_CLICK | |
3bc1418b | 1339 | #define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK |
ce7fe42e VZ |
1340 | #define wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED wxEVT_DATAVIEW_COLUMN_SORTED |
1341 | #define wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED wxEVT_DATAVIEW_COLUMN_REORDERED | |
1342 | #define wxEVT_COMMAND_DATAVIEW_CACHE_HINT wxEVT_DATAVIEW_CACHE_HINT | |
1343 | #define wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG wxEVT_DATAVIEW_ITEM_BEGIN_DRAG | |
1344 | #define wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE | |
1345 | #define wxEVT_COMMAND_DATAVIEW_ITEM_DROP wxEVT_DATAVIEW_ITEM_DROP | |
1346 | ||
bcd846ea RR |
1347 | #endif // wxUSE_DATAVIEWCTRL |
1348 | ||
1349 | #endif | |
1350 | // _WX_DATAVIEW_H_BASE_ |