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