]>
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; } |
2056dede | 277 | unsigned int GetLastIndex() const { return m_lastIndex; } |
c058cafa | 278 | |
c534e696 | 279 | private: |
cd722937 | 280 | wxDataViewItemArray m_hash; |
c534e696 | 281 | unsigned int m_lastIndex; |
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; } | |
342 | unsigned int GetLastIndex() const { return m_lastIndex; } | |
343 | ||
344 | private: | |
345 | wxDataViewItemArray m_hash; | |
346 | unsigned int m_lastIndex; | |
347 | bool m_ordered; | |
348 | }; | |
349 | #endif | |
c33edc08 | 350 | |
1e510b1e RR |
351 | //----------------------------------------------------------------------------- |
352 | // wxDataViewEditorCtrlEvtHandler | |
353 | //----------------------------------------------------------------------------- | |
354 | ||
355 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
356 | { | |
357 | public: | |
358 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
b5ec7dd6 | 359 | |
1e510b1e | 360 | void AcceptChangesAndFinish(); |
30715fa1 | 361 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
362 | |
363 | protected: | |
364 | void OnChar( wxKeyEvent &event ); | |
724852da | 365 | void OnTextEnter( wxCommandEvent &event ); |
1e510b1e | 366 | void OnKillFocus( wxFocusEvent &event ); |
30715fa1 | 367 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
368 | |
369 | private: | |
370 | wxDataViewRenderer *m_owner; | |
371 | wxControl *m_editorCtrl; | |
372 | bool m_finished; | |
30715fa1 | 373 | bool m_focusOnIdle; |
1e510b1e RR |
374 | |
375 | private: | |
376 | DECLARE_EVENT_TABLE() | |
377 | }; | |
378 | ||
f554a14b | 379 | // --------------------------------------------------------- |
baa9ebc4 | 380 | // wxDataViewRendererBase |
f554a14b | 381 | // --------------------------------------------------------- |
fa28826d | 382 | |
6842a71a | 383 | enum wxDataViewCellMode |
fa28826d | 384 | { |
6842a71a RR |
385 | wxDATAVIEW_CELL_INERT, |
386 | wxDATAVIEW_CELL_ACTIVATABLE, | |
387 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
388 | }; |
389 | ||
6842a71a RR |
390 | enum wxDataViewCellRenderState |
391 | { | |
392 | wxDATAVIEW_CELL_SELECTED = 1, | |
393 | wxDATAVIEW_CELL_PRELIT = 2, | |
394 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
395 | wxDATAVIEW_CELL_FOCUSED = 8 | |
396 | }; | |
397 | ||
baa9ebc4 | 398 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
399 | { |
400 | public: | |
b5ec7dd6 | 401 | wxDataViewRendererBase( const wxString &varianttype, |
9861f022 RR |
402 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
403 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
c232dfe5 | 404 | ~wxDataViewRendererBase(); |
6842a71a | 405 | |
9861f022 RR |
406 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
407 | { return true; } | |
f554a14b | 408 | |
6842a71a | 409 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
e51bf699 | 410 | wxDataViewColumn* GetOwner() const { return m_owner; } |
f554a14b | 411 | |
9861f022 RR |
412 | // renderer properties: |
413 | ||
414 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
415 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
416 | ||
417 | wxString GetVariantType() const { return m_variantType; } | |
418 | ||
419 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
420 | virtual wxDataViewCellMode GetMode() const = 0; | |
421 | ||
422 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
423 | // rather an "int"; that's because for rendering cells it's allowed | |
424 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
425 | virtual void SetAlignment( int align ) = 0; | |
426 | virtual int GetAlignment() const = 0; | |
b5ec7dd6 | 427 | |
1e510b1e | 428 | // in-place editing |
fca0d8b5 | 429 | virtual bool HasEditorCtrl() const |
1e510b1e | 430 | { return false; } |
96c2a0dd VZ |
431 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
432 | wxRect WXUNUSED(labelRect), | |
433 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 434 | { return NULL; } |
96c2a0dd VZ |
435 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
436 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
437 | { return false; } |
438 | ||
e0062c04 | 439 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
440 | virtual void CancelEditing(); |
441 | virtual bool FinishEditing(); | |
b5ec7dd6 | 442 | |
1e510b1e | 443 | wxControl *GetEditorCtrl() { return m_editorCtrl; } |
b5ec7dd6 | 444 | |
a7f61f76 | 445 | protected: |
6842a71a RR |
446 | wxString m_variantType; |
447 | wxDataViewColumn *m_owner; | |
c232dfe5 | 448 | wxWeakRef<wxControl> m_editorCtrl; |
e0062c04 | 449 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 450 | |
9861f022 RR |
451 | // internal utility: |
452 | const wxDataViewCtrl* GetView() const; | |
453 | ||
6842a71a | 454 | protected: |
baa9ebc4 | 455 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
456 | }; |
457 | ||
89352653 RR |
458 | //----------------------------------------------------------------------------- |
459 | // wxDataViewIconText | |
460 | //----------------------------------------------------------------------------- | |
461 | ||
d350fbec | 462 | class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject |
89352653 RR |
463 | { |
464 | public: | |
465 | wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) | |
5e6f8927 PC |
466 | : m_text(text), m_icon(icon) |
467 | { } | |
89352653 | 468 | wxDataViewIconText( const wxDataViewIconText &other ) |
4f271814 | 469 | : wxObject() |
344ed1f3 | 470 | { m_icon = other.m_icon; m_text = other.m_text; } |
89352653 RR |
471 | |
472 | void SetText( const wxString &text ) { m_text = text; } | |
473 | wxString GetText() const { return m_text; } | |
474 | void SetIcon( const wxIcon &icon ) { m_icon = icon; } | |
475 | const wxIcon &GetIcon() const { return m_icon; } | |
476 | ||
477 | private: | |
478 | wxString m_text; | |
479 | wxIcon m_icon; | |
480 | ||
481 | private: | |
482 | DECLARE_DYNAMIC_CLASS(wxDataViewIconText) | |
483 | }; | |
484 | ||
485 | bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two); | |
486 | ||
d350fbec | 487 | DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) |
89352653 | 488 | |
f554a14b | 489 | // --------------------------------------------------------- |
6842a71a | 490 | // wxDataViewColumnBase |
f554a14b | 491 | // --------------------------------------------------------- |
6842a71a | 492 | |
56873923 | 493 | // for compatibility only, do not use |
fa28826d RR |
494 | enum wxDataViewColumnFlags |
495 | { | |
56873923 VZ |
496 | wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE, |
497 | wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE, | |
498 | wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE, | |
499 | wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN | |
fa28826d RR |
500 | }; |
501 | ||
dcb6cbec | 502 | class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn |
fa28826d RR |
503 | { |
504 | public: | |
e2bfe673 VZ |
505 | // ctor for the text columns: takes ownership of renderer |
506 | wxDataViewColumnBase(wxDataViewRenderer *renderer, | |
507 | unsigned int model_column) | |
508 | { | |
509 | Init(renderer, model_column); | |
510 | } | |
511 | ||
512 | // ctor for the bitmap columns | |
513 | wxDataViewColumnBase(const wxBitmap& bitmap, | |
514 | wxDataViewRenderer *renderer, | |
515 | unsigned int model_column) | |
516 | : m_bitmap(bitmap) | |
517 | { | |
518 | Init(renderer, model_column); | |
519 | } | |
520 | ||
d3c7fc99 | 521 | virtual ~wxDataViewColumnBase(); |
fa28826d | 522 | |
9861f022 | 523 | // setters: |
b5ec7dd6 | 524 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 | 525 | { m_owner = owner; } |
f554a14b | 526 | |
9861f022 | 527 | // getters: |
e86edab0 | 528 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
594d5596 RR |
529 | wxDataViewCtrl *GetOwner() const { return m_owner; } |
530 | wxDataViewRenderer* GetRenderer() const { return m_renderer; } | |
9861f022 | 531 | |
56873923 VZ |
532 | // implement some of base class pure virtuals (the rest is port-dependent |
533 | // and done differently in generic and native versions) | |
534 | virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } | |
535 | virtual wxBitmap GetBitmap() const { return m_bitmap; } | |
56873923 | 536 | |
9861f022 | 537 | protected: |
baa9ebc4 | 538 | wxDataViewRenderer *m_renderer; |
6842a71a | 539 | int m_model_column; |
07a84e7b | 540 | wxBitmap m_bitmap; |
6842a71a | 541 | wxDataViewCtrl *m_owner; |
fa28826d | 542 | |
e2bfe673 VZ |
543 | private: |
544 | // common part of all ctors | |
545 | void Init(wxDataViewRenderer *renderer, unsigned int model_column); | |
fa28826d RR |
546 | }; |
547 | ||
f554a14b | 548 | // --------------------------------------------------------- |
239eaa41 | 549 | // wxDataViewCtrlBase |
f554a14b | 550 | // --------------------------------------------------------- |
239eaa41 | 551 | |
c21f7aa1 | 552 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
553 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
554 | ||
555 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
556 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
557 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 558 | |
1a07a730 | 559 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows |
344ed1f3 | 560 | #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height |
1a07a730 | 561 | |
f460c29d | 562 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
563 | { |
564 | public: | |
565 | wxDataViewCtrlBase(); | |
d3c7fc99 | 566 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 567 | |
ce468dc2 FM |
568 | // model |
569 | // ----- | |
570 | ||
e0062c04 RR |
571 | virtual bool AssociateModel( wxDataViewModel *model ); |
572 | wxDataViewModel* GetModel(); | |
a75124d0 | 573 | const wxDataViewModel* GetModel() const; |
f554a14b | 574 | |
ce468dc2 FM |
575 | |
576 | // column management | |
577 | // ----------------- | |
578 | ||
b5ec7dd6 | 579 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 580 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 581 | wxAlignment align = wxALIGN_NOT, |
736fe67c | 582 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 583 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c | 584 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 585 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
586 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
587 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
588 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
589 | wxAlignment align = wxALIGN_CENTER, | |
590 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 591 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
592 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
593 | wxAlignment align = wxALIGN_CENTER, | |
594 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
595 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
596 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 597 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
598 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
599 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
600 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
601 | wxAlignment align = wxALIGN_CENTER, | |
602 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
603 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
604 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 605 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
606 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
607 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
608 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 609 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
610 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
611 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
612 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
613 | wxAlignment align = wxALIGN_CENTER, | |
614 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
615 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
616 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
617 | wxAlignment align = wxALIGN_CENTER, | |
618 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
619 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
620 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
56873923 | 621 | wxAlignment align = wxALIGN_NOT, |
736fe67c RR |
622 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
623 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
624 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
625 | wxAlignment align = wxALIGN_CENTER, | |
626 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
627 | |
628 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 629 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 630 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 631 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 632 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 633 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 634 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 635 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 636 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
637 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
638 | wxAlignment align = wxALIGN_CENTER, | |
639 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 640 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
641 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
642 | wxAlignment align = wxALIGN_CENTER, | |
643 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 644 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 645 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 646 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 647 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 648 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
649 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
650 | wxAlignment align = wxALIGN_CENTER, | |
651 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 652 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 653 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
56873923 | 654 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 655 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
656 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
657 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
56873923 | 658 | wxAlignment align = wxALIGN_NOT, |
b04fcede | 659 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 660 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
661 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
662 | wxAlignment align = wxALIGN_CENTER, | |
663 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 664 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
665 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
666 | wxAlignment align = wxALIGN_CENTER, | |
667 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 668 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 669 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
56873923 | 670 | wxAlignment align = wxALIGN_NOT, |
87f0efe2 | 671 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 672 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
673 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
674 | wxAlignment align = wxALIGN_CENTER, | |
675 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c | 676 | |
736fe67c | 677 | virtual bool PrependColumn( wxDataViewColumn *col ); |
19723525 | 678 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
f554a14b | 679 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 680 | |
91a6c655 RR |
681 | virtual unsigned int GetColumnCount() const = 0; |
682 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 683 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 684 | |
91a6c655 RR |
685 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
686 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 687 | |
1b27b2bd | 688 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 689 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 690 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 691 | { return m_expander_column; } |
b5ec7dd6 | 692 | |
21f47fb9 | 693 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
23318a53 | 694 | |
ce468dc2 FM |
695 | |
696 | // items management | |
697 | // ---------------- | |
698 | ||
3b6280be RR |
699 | void SetIndent( int indent ) |
700 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
701 | int GetIndent() const |
702 | { return m_indent; } | |
3b6280be | 703 | |
fbda518c | 704 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
705 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
706 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
707 | virtual void Select( const wxDataViewItem & item ) = 0; | |
708 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
709 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
710 | ||
b7e9f8b1 RR |
711 | virtual void SelectAll() = 0; |
712 | virtual void UnselectAll() = 0; | |
713 | ||
f71d3ba4 | 714 | virtual void Expand( const wxDataViewItem & item ) = 0; |
4219d8b0 | 715 | virtual void ExpandAncestors( const wxDataViewItem & item ); |
f71d3ba4 | 716 | virtual void Collapse( const wxDataViewItem & item ) = 0; |
739a8399 | 717 | virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; |
f71d3ba4 | 718 | |
6154212e | 719 | virtual void EnsureVisible( const wxDataViewItem & item, |
4219d8b0 | 720 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 721 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 722 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
8c2654ce | 723 | |
f54e5c1a VZ |
724 | #if wxUSE_DRAG_AND_DROP |
725 | virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format)) | |
726 | { return false; } | |
727 | virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format)) | |
728 | { return false; } | |
729 | #endif // wxUSE_DRAG_AND_DROP | |
b7e9f8b1 | 730 | |
3b6280be RR |
731 | protected: |
732 | virtual void DoSetExpanderColumn() = 0 ; | |
733 | virtual void DoSetIndent() = 0; | |
734 | ||
239eaa41 | 735 | private: |
e0062c04 | 736 | wxDataViewModel *m_model; |
1b27b2bd | 737 | wxDataViewColumn *m_expander_column; |
3b6280be | 738 | int m_indent ; |
b5ec7dd6 | 739 | |
239eaa41 | 740 | protected: |
260b9be7 | 741 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 742 | }; |
bcd846ea | 743 | |
eb7f97f8 RR |
744 | // ---------------------------------------------------------------------------- |
745 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
746 | // ---------------------------------------------------------------------------- | |
747 | ||
2f799ae8 | 748 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
749 | { |
750 | public: | |
751 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
752 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 753 | m_item(0), |
eb7f97f8 | 754 | m_col(-1), |
eb7f97f8 RR |
755 | m_model(NULL), |
756 | m_value(wxNullVariant), | |
6af3eec2 | 757 | m_column(NULL), |
6effcb7c FM |
758 | m_pos(-1,-1) |
759 | #if wxUSE_DRAG_AND_DROP | |
760 | , m_dataObject(NULL), | |
e4de825e RR |
761 | m_dataBuffer(NULL), |
762 | m_dataSize(0) | |
6effcb7c | 763 | #endif |
eb7f97f8 RR |
764 | { } |
765 | ||
766 | wxDataViewEvent(const wxDataViewEvent& event) | |
767 | : wxNotifyEvent(event), | |
e0062c04 | 768 | m_item(event.m_item), |
eb7f97f8 | 769 | m_col(event.m_col), |
eb7f97f8 RR |
770 | m_model(event.m_model), |
771 | m_value(event.m_value), | |
6af3eec2 | 772 | m_column(event.m_column), |
6effcb7c FM |
773 | m_pos(m_pos) |
774 | #if wxUSE_DRAG_AND_DROP | |
775 | , m_dataObject(event.m_dataObject), | |
e4de825e RR |
776 | m_dataFormat(event.m_dataFormat), |
777 | m_dataBuffer(event.m_dataBuffer), | |
778 | m_dataSize(event.m_dataSize) | |
6effcb7c | 779 | #endif |
eb7f97f8 RR |
780 | { } |
781 | ||
e0062c04 RR |
782 | wxDataViewItem GetItem() const { return m_item; } |
783 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
784 | ||
eb7f97f8 RR |
785 | int GetColumn() const { return m_col; } |
786 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 787 | |
eb7f97f8 RR |
788 | wxDataViewModel* GetModel() const { return m_model; } |
789 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 790 | |
eb7f97f8 RR |
791 | const wxVariant &GetValue() const { return m_value; } |
792 | void SetValue( const wxVariant &value ) { m_value = value; } | |
793 | ||
31fb32e1 RR |
794 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
795 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 796 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
c058cafa | 797 | |
6af3eec2 | 798 | // for wxEVT_DATAVIEW_CONTEXT_MENU only |
5cfb6fee | 799 | wxPoint GetPosition() const { return m_pos; } |
6af3eec2 | 800 | void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } |
31fb32e1 | 801 | |
62c9b3d7 | 802 | #if wxUSE_DRAG_AND_DROP |
e4de825e | 803 | // For drag operations |
591cc82d | 804 | void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } |
e4de825e | 805 | wxDataObject *GetDataObject() const { return m_dataObject; } |
8c2654ce | 806 | |
e4de825e RR |
807 | // For drop operations |
808 | void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } | |
809 | wxDataFormat GetDataFormat() const { return m_dataFormat; } | |
810 | void SetDataSize( size_t size ) { m_dataSize = size; } | |
811 | size_t GetDataSize() const { return m_dataSize; } | |
812 | void SetDataBuffer( void* buf ) { m_dataBuffer = buf;} | |
813 | void *GetDataBuffer() const { return m_dataBuffer; } | |
664e1314 | 814 | #endif // wxUSE_DRAG_AND_DROP |
15cac64f | 815 | |
eb7f97f8 RR |
816 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
817 | ||
818 | protected: | |
e0062c04 | 819 | wxDataViewItem m_item; |
eb7f97f8 | 820 | int m_col; |
eb7f97f8 RR |
821 | wxDataViewModel *m_model; |
822 | wxVariant m_value; | |
31fb32e1 | 823 | wxDataViewColumn *m_column; |
6af3eec2 | 824 | wxPoint m_pos; |
8c2654ce | 825 | |
5e14f15d | 826 | #if wxUSE_DRAG_AND_DROP |
591cc82d | 827 | wxDataObject *m_dataObject; |
8c2654ce | 828 | |
e4de825e RR |
829 | wxDataFormat m_dataFormat; |
830 | void* m_dataBuffer; | |
831 | size_t m_dataSize; | |
5e14f15d | 832 | #endif // wxUSE_DRAG_AND_DROP |
eb7f97f8 RR |
833 | |
834 | private: | |
835 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
836 | }; | |
837 | ||
9b11752c VZ |
838 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); |
839 | ||
840 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); | |
841 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); | |
842 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); | |
843 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); | |
844 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); | |
3e978cf7 | 845 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); |
9b11752c VZ |
846 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); |
847 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); | |
848 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); | |
849 | ||
850 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); | |
851 | ||
852 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); | |
853 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); | |
854 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); | |
855 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); | |
856 | ||
857 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); | |
858 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); | |
859 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); | |
15cac64f | 860 | |
eb7f97f8 RR |
861 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); |
862 | ||
863 | #define wxDataViewEventHandler(func) \ | |
3c778901 | 864 | wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func) |
eb7f97f8 RR |
865 | |
866 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
867 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
868 | ||
d86c1870 RR |
869 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
870 | ||
e0062c04 | 871 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 872 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 873 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 874 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 875 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
3e978cf7 | 876 | #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn) |
e0000f94 RR |
877 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
878 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 879 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 880 | |
6af3eec2 RR |
881 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
882 | ||
31fb32e1 RR |
883 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
884 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 885 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
e483dfcb | 886 | #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) |
eb7f97f8 | 887 | |
591cc82d | 888 | #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) |
e4de825e RR |
889 | #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) |
890 | #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn) | |
fe9fb970 | 891 | |
56873923 VZ |
892 | #ifdef wxHAS_GENERIC_DATAVIEWCTRL |
893 | // this symbol doesn't follow the convention for wxUSE_XXX symbols which | |
894 | // are normally always defined as either 0 or 1, so its use is deprecated | |
895 | // and it only exists for backwards compatibility, don't use it any more | |
896 | // and use wxHAS_GENERIC_DATAVIEWCTRL instead | |
897 | #define wxUSE_GENERICDATAVIEWCTRL | |
898 | ||
899 | #include "wx/generic/dataview.h" | |
900 | #elif defined(__WXGTK20__) | |
bcd846ea | 901 | #include "wx/gtk/dataview.h" |
56873923 | 902 | #elif defined(__WXMAC__) |
ef0e9220 | 903 | #include "wx/osx/dataview.h" |
bcd846ea | 904 | #else |
56873923 | 905 | #error "unknown native wxDataViewCtrl implementation" |
bcd846ea RR |
906 | #endif |
907 | ||
52e750fc RR |
908 | // ------------------------------------- |
909 | // wxDataViewSpinRenderer | |
910 | // ------------------------------------- | |
911 | ||
4660b556 | 912 | class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer |
52e750fc RR |
913 | { |
914 | public: | |
915 | wxDataViewSpinRenderer( int min, int max, | |
916 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
917 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
fca0d8b5 | 918 | virtual bool HasEditorCtrl() const { return true; } |
52e750fc RR |
919 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); |
920 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
921 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
922 | virtual wxSize GetSize() const; | |
923 | virtual bool SetValue( const wxVariant &value ); | |
924 | virtual bool GetValue( wxVariant &value ) const; | |
b5ec7dd6 | 925 | |
52e750fc RR |
926 | private: |
927 | long m_data; | |
928 | long m_min,m_max; | |
929 | }; | |
930 | ||
e86edab0 | 931 | #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__) |
7448d67c RR |
932 | |
933 | // ------------------------------------- | |
934 | // wxDataViewChoiceRenderer | |
935 | // ------------------------------------- | |
936 | ||
937 | class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer | |
938 | { | |
939 | public: | |
940 | wxDataViewChoiceRenderer( const wxArrayString &choices, | |
941 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
942 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
fca0d8b5 | 943 | virtual bool HasEditorCtrl() const { return true; } |
7448d67c RR |
944 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); |
945 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
946 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
947 | virtual wxSize GetSize() const; | |
948 | virtual bool SetValue( const wxVariant &value ); | |
949 | virtual bool GetValue( wxVariant &value ) const; | |
950 | ||
951 | private: | |
952 | wxArrayString m_choices; | |
953 | wxString m_data; | |
954 | }; | |
955 | ||
956 | #endif | |
957 | ||
8eff6c56 RR |
958 | //----------------------------------------------------------------------------- |
959 | // wxDataViewListStore | |
960 | //----------------------------------------------------------------------------- | |
961 | ||
962 | class WXDLLIMPEXP_ADV wxDataViewListStoreLine | |
963 | { | |
964 | public: | |
965 | wxDataViewListStoreLine( wxClientData *data = NULL ) | |
966 | { | |
967 | m_data = data; | |
968 | } | |
969 | virtual ~wxDataViewListStoreLine() | |
970 | { | |
971 | delete m_data; | |
972 | } | |
973 | ||
974 | void SetData( wxClientData *data ) | |
975 | { if (m_data) delete m_data; m_data = data; } | |
976 | wxClientData *GetData() const | |
977 | { return m_data; } | |
8c2654ce | 978 | |
8eff6c56 | 979 | wxVector<wxVariant> m_values; |
8c2654ce | 980 | |
8eff6c56 RR |
981 | private: |
982 | wxClientData *m_data; | |
983 | }; | |
984 | ||
985 | ||
986 | class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel | |
987 | { | |
988 | public: | |
989 | wxDataViewListStore(); | |
990 | ~wxDataViewListStore(); | |
991 | ||
992 | void PrependColumn( const wxString &varianttype ); | |
993 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
994 | void AppendColumn( const wxString &varianttype ); | |
8c2654ce | 995 | |
8eff6c56 RR |
996 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); |
997 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
998 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
8af28fab | 999 | void DeleteItem( unsigned int pos ); |
8eff6c56 RR |
1000 | void DeleteAllItems(); |
1001 | ||
8eff6c56 RR |
1002 | // override base virtuals |
1003 | ||
1004 | virtual unsigned int GetColumnCount() const; | |
1005 | ||
1006 | virtual wxString GetColumnType( unsigned int col ) const; | |
1007 | ||
1008 | virtual void GetValueByRow( wxVariant &value, | |
1009 | unsigned int row, unsigned int col ) const; | |
1010 | ||
1011 | virtual bool SetValueByRow( const wxVariant &value, | |
1012 | unsigned int row, unsigned int col ); | |
1013 | ||
8c2654ce | 1014 | |
8eff6c56 RR |
1015 | public: |
1016 | wxVector<wxDataViewListStoreLine*> m_data; | |
1017 | wxArrayString m_cols; | |
1018 | }; | |
1019 | ||
dc813e6c RR |
1020 | //----------------------------------------------------------------------------- |
1021 | ||
1022 | class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl | |
1023 | { | |
1024 | public: | |
1025 | wxDataViewListCtrl(); | |
1026 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
1027 | const wxPoint& pos = wxDefaultPosition, | |
1028 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1029 | const wxValidator& validator = wxDefaultValidator ); | |
1030 | ~wxDataViewListCtrl(); | |
1031 | ||
1032 | bool Create( wxWindow *parent, wxWindowID id, | |
1033 | const wxPoint& pos = wxDefaultPosition, | |
1034 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1035 | const wxValidator& validator = wxDefaultValidator ); | |
1036 | ||
1037 | wxDataViewListStore *GetStore() | |
1038 | { return (wxDataViewListStore*) GetModel(); } | |
1039 | const wxDataViewListStore *GetStore() const | |
1040 | { return (const wxDataViewListStore*) GetModel(); } | |
1041 | ||
95b20f41 RR |
1042 | bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
1043 | bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); | |
1044 | bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); | |
8c2654ce | 1045 | |
95b20f41 RR |
1046 | // overridden from base class |
1047 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
1048 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); | |
1049 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
1050 | ||
f54e5c1a VZ |
1051 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
1052 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1053 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1054 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
1055 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
dc813e6c | 1056 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1057 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
1058 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1059 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1060 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
1061 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c RR |
1062 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
1063 | ||
1064 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1065 | { GetStore()->AppendItem( values, data ); } | |
1066 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1067 | { GetStore()->PrependItem( values, data ); } | |
1068 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1069 | { GetStore()->InsertItem( row, values, data ); } | |
1070 | void DeleteItem( unsigned row ) | |
1071 | { GetStore()->DeleteItem( row ); } | |
1072 | void DeleteAllItems() | |
1073 | { GetStore()->DeleteAllItems(); } | |
1074 | ||
1075 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) | |
f54e5c1a | 1076 | { GetStore()->SetValueByRow( value, row, col ); |
832df171 RR |
1077 | GetStore()->RowValueChanged( row, col); } |
1078 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ) | |
1079 | { GetStore()->GetValueByRow( value, row, col ); } | |
dc813e6c RR |
1080 | |
1081 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) | |
832df171 RR |
1082 | { GetStore()->SetValueByRow( value, row, col ); |
1083 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1084 | wxString GetTextValue( unsigned int row, unsigned int col ) const |
1085 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } | |
1086 | ||
1087 | void SetToggleValue( bool value, unsigned int row, unsigned int col ) | |
832df171 RR |
1088 | { GetStore()->SetValueByRow( value, row, col ); |
1089 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1090 | bool GetToggleValue( unsigned int row, unsigned int col ) const |
1091 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } | |
1092 | ||
1093 | void OnSize( wxSizeEvent &event ); | |
1094 | ||
1095 | private: | |
1096 | DECLARE_EVENT_TABLE() | |
1097 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl) | |
1098 | }; | |
8eff6c56 | 1099 | |
e94d0c1e RR |
1100 | //----------------------------------------------------------------------------- |
1101 | // wxDataViewTreeStore | |
1102 | //----------------------------------------------------------------------------- | |
1103 | ||
1104 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
1105 | { | |
1106 | public: | |
1107 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
1108 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1109 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
1110 | |
1111 | void SetText( const wxString &text ) | |
e94d0c1e RR |
1112 | { m_text = text; } |
1113 | wxString GetText() const | |
1114 | { return m_text; } | |
1115 | void SetIcon( const wxIcon &icon ) | |
1116 | { m_icon = icon; } | |
1117 | const wxIcon &GetIcon() const | |
1118 | { return m_icon; } | |
1119 | void SetData( wxClientData *data ) | |
1120 | { if (m_data) delete m_data; m_data = data; } | |
1121 | wxClientData *GetData() const | |
1122 | { return m_data; } | |
b5ec7dd6 | 1123 | |
e94d0c1e RR |
1124 | wxDataViewItem GetItem() const |
1125 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 1126 | |
e94d0c1e RR |
1127 | virtual bool IsContainer() |
1128 | { return false; } | |
b5ec7dd6 | 1129 | |
e94d0c1e RR |
1130 | wxDataViewTreeStoreNode *GetParent() |
1131 | { return m_parent; } | |
b5ec7dd6 | 1132 | |
e94d0c1e RR |
1133 | private: |
1134 | wxDataViewTreeStoreNode *m_parent; | |
1135 | wxString m_text; | |
1136 | wxIcon m_icon; | |
1137 | wxClientData *m_data; | |
1138 | }; | |
1139 | ||
1140 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
1141 | class WXDLLIMPEXP_ADV); | |
1142 | ||
1143 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
1144 | { | |
1145 | public: | |
b5ec7dd6 VZ |
1146 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
1147 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1148 | wxClientData *data = NULL ); |
1149 | virtual ~wxDataViewTreeStoreContainerNode(); | |
1150 | ||
b5ec7dd6 | 1151 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 1152 | { return m_children; } |
b5ec7dd6 | 1153 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
1154 | { return m_children; } |
1155 | ||
1156 | void SetExpandedIcon( const wxIcon &icon ) | |
1157 | { m_iconExpanded = icon; } | |
1158 | const wxIcon &GetExpandedIcon() const | |
1159 | { return m_iconExpanded; } | |
b5ec7dd6 | 1160 | |
a75124d0 RR |
1161 | void SetExpanded( bool expanded = true ) |
1162 | { m_isExpanded = expanded; } | |
1163 | bool IsExpanded() const | |
1164 | { return m_isExpanded; } | |
1165 | ||
e94d0c1e RR |
1166 | virtual bool IsContainer() |
1167 | { return true; } | |
b5ec7dd6 | 1168 | |
e94d0c1e RR |
1169 | private: |
1170 | wxDataViewTreeStoreNodeList m_children; | |
1171 | wxIcon m_iconExpanded; | |
a75124d0 | 1172 | bool m_isExpanded; |
e94d0c1e RR |
1173 | }; |
1174 | ||
1175 | //----------------------------------------------------------------------------- | |
1176 | ||
1177 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
1178 | { | |
1179 | public: | |
1180 | wxDataViewTreeStore(); | |
1181 | ~wxDataViewTreeStore(); | |
1182 | ||
b5ec7dd6 | 1183 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
1184 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
1185 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1186 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1187 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1188 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
1189 | |
1190 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1191 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1192 | wxClientData *data = NULL ); |
1193 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 1194 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1195 | wxClientData *data = NULL ); |
1196 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 1197 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1198 | wxClientData *data = NULL ); |
1199 | ||
1200 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
1201 | int GetChildCount( const wxDataViewItem& parent ) const; | |
b5ec7dd6 | 1202 | |
e94d0c1e RR |
1203 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
1204 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 1205 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
1206 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
1207 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
1208 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
1209 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
1210 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
1211 | ||
1212 | void DeleteItem( const wxDataViewItem& item ); | |
1213 | void DeleteChildren( const wxDataViewItem& item ); | |
1214 | void DeleteAllItems(); | |
b5ec7dd6 | 1215 | |
e94d0c1e RR |
1216 | // implement base methods |
1217 | ||
b5ec7dd6 | 1218 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 1219 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 1220 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
1221 | const wxDataViewItem &item, unsigned int col ); |
1222 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
1223 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
1224 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
1225 | ||
b5ec7dd6 | 1226 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
862de7b3 | 1227 | unsigned int column, bool ascending ) const; |
b5ec7dd6 VZ |
1228 | |
1229 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 1230 | { return true; } |
b5ec7dd6 | 1231 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 1232 | { return 1; }; |
b5ec7dd6 | 1233 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 1234 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 1235 | |
e94d0c1e RR |
1236 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
1237 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
1238 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 1239 | |
e94d0c1e RR |
1240 | public: |
1241 | wxDataViewTreeStoreNode *m_root; | |
1242 | }; | |
1243 | ||
dc813e6c RR |
1244 | //----------------------------------------------------------------------------- |
1245 | ||
e94d0c1e RR |
1246 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl |
1247 | { | |
1248 | public: | |
a75124d0 RR |
1249 | wxDataViewTreeCtrl(); |
1250 | wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id, | |
e94d0c1e | 1251 | const wxPoint& pos = wxDefaultPosition, |
1a07a730 | 1252 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e | 1253 | const wxValidator& validator = wxDefaultValidator ); |
a75124d0 | 1254 | ~wxDataViewTreeCtrl(); |
e94d0c1e RR |
1255 | |
1256 | bool Create( wxWindow *parent, wxWindowID id, | |
1257 | const wxPoint& pos = wxDefaultPosition, | |
1a07a730 | 1258 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e RR |
1259 | const wxValidator& validator = wxDefaultValidator ); |
1260 | ||
1261 | wxDataViewTreeStore *GetStore() | |
1262 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
1263 | const wxDataViewTreeStore *GetStore() const |
1264 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 1265 | |
a75124d0 RR |
1266 | void SetImageList( wxImageList *imagelist ); |
1267 | wxImageList* GetImageList() { return m_imageList; } | |
c058cafa | 1268 | |
a75124d0 RR |
1269 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
1270 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1271 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1272 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1273 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1274 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1275 | ||
1276 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1277 | const wxString &text, int icon = -1, int expanded = -1, | |
1278 | wxClientData *data = NULL ); | |
1279 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
1280 | const wxString &text, int icon = -1, int expanded = -1, | |
1281 | wxClientData *data = NULL ); | |
1282 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1283 | const wxString &text, int icon = -1, int expanded = -1, | |
1284 | wxClientData *data = NULL ); | |
1285 | ||
1286 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
1287 | { return GetStore()->GetNthChild(parent, pos); } | |
1288 | int GetChildCount( const wxDataViewItem& parent ) const | |
1289 | { return GetStore()->GetChildCount(parent); } | |
1290 | ||
e700e296 | 1291 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
a75124d0 RR |
1292 | wxString GetItemText( const wxDataViewItem& item ) const |
1293 | { return GetStore()->GetItemText(item); } | |
e700e296 | 1294 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1295 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const |
1296 | { return GetStore()->GetItemIcon(item); } | |
e700e296 | 1297 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1298 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const |
1299 | { return GetStore()->GetItemExpandedIcon(item); } | |
1300 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1301 | { GetStore()->SetItemData(item,data); } | |
1302 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1303 | { return GetStore()->GetItemData(item); } | |
1304 | ||
e700e296 RR |
1305 | void DeleteItem( const wxDataViewItem& item ); |
1306 | void DeleteChildren( const wxDataViewItem& item ); | |
1307 | void DeleteAllItems(); | |
a75124d0 RR |
1308 | |
1309 | void OnExpanded( wxDataViewEvent &event ); | |
1310 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1311 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1312 | |
e94d0c1e | 1313 | private: |
a75124d0 RR |
1314 | wxImageList *m_imageList; |
1315 | ||
1316 | private: | |
1317 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1318 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1319 | }; | |
e94d0c1e | 1320 | |
bcd846ea RR |
1321 | #endif // wxUSE_DATAVIEWCTRL |
1322 | ||
1323 | #endif | |
1324 | // _WX_DATAVIEW_H_BASE_ |