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