]>
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, |
862de7b3 | 216 | unsigned int column, bool ascending ) const; |
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, | |
862de7b3 | 265 | unsigned int column, bool ascending ) const; |
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, | |
862de7b3 | 330 | unsigned int column, bool ascending ) const; |
e39de702 RR |
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 ); | |
3e978cf7 | 850 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent ); |
9b11752c VZ |
851 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); |
852 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); | |
853 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); | |
854 | ||
855 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); | |
856 | ||
857 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); | |
858 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); | |
859 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); | |
860 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); | |
861 | ||
862 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); | |
863 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); | |
864 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); | |
15cac64f | 865 | |
eb7f97f8 RR |
866 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); |
867 | ||
868 | #define wxDataViewEventHandler(func) \ | |
3c778901 | 869 | wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func) |
eb7f97f8 RR |
870 | |
871 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
872 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
873 | ||
d86c1870 RR |
874 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
875 | ||
e0062c04 | 876 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 877 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 878 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 879 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 880 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
3e978cf7 | 881 | #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn) |
e0000f94 RR |
882 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
883 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 884 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 885 | |
6af3eec2 RR |
886 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
887 | ||
31fb32e1 RR |
888 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
889 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 890 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
e483dfcb | 891 | #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) |
eb7f97f8 | 892 | |
591cc82d | 893 | #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) |
e4de825e RR |
894 | #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) |
895 | #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn) | |
fe9fb970 | 896 | |
56873923 VZ |
897 | #ifdef wxHAS_GENERIC_DATAVIEWCTRL |
898 | // this symbol doesn't follow the convention for wxUSE_XXX symbols which | |
899 | // are normally always defined as either 0 or 1, so its use is deprecated | |
900 | // and it only exists for backwards compatibility, don't use it any more | |
901 | // and use wxHAS_GENERIC_DATAVIEWCTRL instead | |
902 | #define wxUSE_GENERICDATAVIEWCTRL | |
903 | ||
904 | #include "wx/generic/dataview.h" | |
905 | #elif defined(__WXGTK20__) | |
bcd846ea | 906 | #include "wx/gtk/dataview.h" |
56873923 | 907 | #elif defined(__WXMAC__) |
ef0e9220 | 908 | #include "wx/osx/dataview.h" |
bcd846ea | 909 | #else |
56873923 | 910 | #error "unknown native wxDataViewCtrl implementation" |
bcd846ea RR |
911 | #endif |
912 | ||
52e750fc RR |
913 | // ------------------------------------- |
914 | // wxDataViewSpinRenderer | |
915 | // ------------------------------------- | |
916 | ||
4660b556 | 917 | class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer |
52e750fc RR |
918 | { |
919 | public: | |
920 | wxDataViewSpinRenderer( int min, int max, | |
921 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
922 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
fca0d8b5 | 923 | virtual bool HasEditorCtrl() const { return true; } |
52e750fc RR |
924 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); |
925 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
926 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
927 | virtual wxSize GetSize() const; | |
928 | virtual bool SetValue( const wxVariant &value ); | |
929 | virtual bool GetValue( wxVariant &value ) const; | |
b5ec7dd6 | 930 | |
52e750fc RR |
931 | private: |
932 | long m_data; | |
933 | long m_min,m_max; | |
934 | }; | |
935 | ||
a881f34e | 936 | #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__) |
7448d67c RR |
937 | |
938 | // ------------------------------------- | |
939 | // wxDataViewChoiceRenderer | |
940 | // ------------------------------------- | |
941 | ||
942 | class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer | |
943 | { | |
944 | public: | |
945 | wxDataViewChoiceRenderer( const wxArrayString &choices, | |
946 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
947 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
fca0d8b5 | 948 | virtual bool HasEditorCtrl() const { return true; } |
7448d67c RR |
949 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); |
950 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
951 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
952 | virtual wxSize GetSize() const; | |
953 | virtual bool SetValue( const wxVariant &value ); | |
954 | virtual bool GetValue( wxVariant &value ) const; | |
955 | ||
956 | private: | |
957 | wxArrayString m_choices; | |
958 | wxString m_data; | |
959 | }; | |
960 | ||
961 | #endif | |
962 | ||
8eff6c56 RR |
963 | //----------------------------------------------------------------------------- |
964 | // wxDataViewListStore | |
965 | //----------------------------------------------------------------------------- | |
966 | ||
967 | class WXDLLIMPEXP_ADV wxDataViewListStoreLine | |
968 | { | |
969 | public: | |
970 | wxDataViewListStoreLine( wxClientData *data = NULL ) | |
971 | { | |
972 | m_data = data; | |
973 | } | |
974 | virtual ~wxDataViewListStoreLine() | |
975 | { | |
976 | delete m_data; | |
977 | } | |
978 | ||
979 | void SetData( wxClientData *data ) | |
980 | { if (m_data) delete m_data; m_data = data; } | |
981 | wxClientData *GetData() const | |
982 | { return m_data; } | |
8c2654ce | 983 | |
8eff6c56 | 984 | wxVector<wxVariant> m_values; |
8c2654ce | 985 | |
8eff6c56 RR |
986 | private: |
987 | wxClientData *m_data; | |
988 | }; | |
989 | ||
990 | ||
991 | class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel | |
992 | { | |
993 | public: | |
994 | wxDataViewListStore(); | |
995 | ~wxDataViewListStore(); | |
996 | ||
997 | void PrependColumn( const wxString &varianttype ); | |
998 | void InsertColumn( unsigned int pos, const wxString &varianttype ); | |
999 | void AppendColumn( const wxString &varianttype ); | |
8c2654ce | 1000 | |
8eff6c56 RR |
1001 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); |
1002 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
1003 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); | |
8af28fab | 1004 | void DeleteItem( unsigned int pos ); |
8eff6c56 RR |
1005 | void DeleteAllItems(); |
1006 | ||
8eff6c56 RR |
1007 | // override base virtuals |
1008 | ||
1009 | virtual unsigned int GetColumnCount() const; | |
1010 | ||
1011 | virtual wxString GetColumnType( unsigned int col ) const; | |
1012 | ||
1013 | virtual void GetValueByRow( wxVariant &value, | |
1014 | unsigned int row, unsigned int col ) const; | |
1015 | ||
1016 | virtual bool SetValueByRow( const wxVariant &value, | |
1017 | unsigned int row, unsigned int col ); | |
1018 | ||
8c2654ce | 1019 | |
8eff6c56 RR |
1020 | public: |
1021 | wxVector<wxDataViewListStoreLine*> m_data; | |
1022 | wxArrayString m_cols; | |
1023 | }; | |
1024 | ||
dc813e6c RR |
1025 | //----------------------------------------------------------------------------- |
1026 | ||
1027 | class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl | |
1028 | { | |
1029 | public: | |
1030 | wxDataViewListCtrl(); | |
1031 | wxDataViewListCtrl( wxWindow *parent, wxWindowID id, | |
1032 | const wxPoint& pos = wxDefaultPosition, | |
1033 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1034 | const wxValidator& validator = wxDefaultValidator ); | |
1035 | ~wxDataViewListCtrl(); | |
1036 | ||
1037 | bool Create( wxWindow *parent, wxWindowID id, | |
1038 | const wxPoint& pos = wxDefaultPosition, | |
1039 | const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, | |
1040 | const wxValidator& validator = wxDefaultValidator ); | |
1041 | ||
1042 | wxDataViewListStore *GetStore() | |
1043 | { return (wxDataViewListStore*) GetModel(); } | |
1044 | const wxDataViewListStore *GetStore() const | |
1045 | { return (const wxDataViewListStore*) GetModel(); } | |
1046 | ||
95b20f41 RR |
1047 | bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); |
1048 | bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); | |
1049 | bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); | |
8c2654ce | 1050 | |
95b20f41 RR |
1051 | // overridden from base class |
1052 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
1053 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); | |
1054 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
1055 | ||
f54e5c1a VZ |
1056 | wxDataViewColumn *AppendTextColumn( const wxString &label, |
1057 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1058 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1059 | wxDataViewColumn *AppendToggleColumn( const wxString &label, |
1060 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, | |
dc813e6c | 1061 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1062 | wxDataViewColumn *AppendProgressColumn( const wxString &label, |
1063 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c | 1064 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
f54e5c1a VZ |
1065 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, |
1066 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
dc813e6c RR |
1067 | int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); |
1068 | ||
1069 | void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1070 | { GetStore()->AppendItem( values, data ); } | |
1071 | void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1072 | { GetStore()->PrependItem( values, data ); } | |
1073 | void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ) | |
1074 | { GetStore()->InsertItem( row, values, data ); } | |
1075 | void DeleteItem( unsigned row ) | |
1076 | { GetStore()->DeleteItem( row ); } | |
1077 | void DeleteAllItems() | |
1078 | { GetStore()->DeleteAllItems(); } | |
1079 | ||
1080 | void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) | |
f54e5c1a | 1081 | { GetStore()->SetValueByRow( value, row, col ); |
832df171 RR |
1082 | GetStore()->RowValueChanged( row, col); } |
1083 | void GetValue( wxVariant &value, unsigned int row, unsigned int col ) | |
1084 | { GetStore()->GetValueByRow( value, row, col ); } | |
dc813e6c RR |
1085 | |
1086 | void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) | |
832df171 RR |
1087 | { GetStore()->SetValueByRow( value, row, col ); |
1088 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1089 | wxString GetTextValue( unsigned int row, unsigned int col ) const |
1090 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } | |
1091 | ||
1092 | void SetToggleValue( bool value, unsigned int row, unsigned int col ) | |
832df171 RR |
1093 | { GetStore()->SetValueByRow( value, row, col ); |
1094 | GetStore()->RowValueChanged( row, col); } | |
dc813e6c RR |
1095 | bool GetToggleValue( unsigned int row, unsigned int col ) const |
1096 | { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } | |
1097 | ||
1098 | void OnSize( wxSizeEvent &event ); | |
1099 | ||
1100 | private: | |
1101 | DECLARE_EVENT_TABLE() | |
1102 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl) | |
1103 | }; | |
8eff6c56 | 1104 | |
e94d0c1e RR |
1105 | //----------------------------------------------------------------------------- |
1106 | // wxDataViewTreeStore | |
1107 | //----------------------------------------------------------------------------- | |
1108 | ||
1109 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
1110 | { | |
1111 | public: | |
1112 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
1113 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1114 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
1115 | |
1116 | void SetText( const wxString &text ) | |
e94d0c1e RR |
1117 | { m_text = text; } |
1118 | wxString GetText() const | |
1119 | { return m_text; } | |
1120 | void SetIcon( const wxIcon &icon ) | |
1121 | { m_icon = icon; } | |
1122 | const wxIcon &GetIcon() const | |
1123 | { return m_icon; } | |
1124 | void SetData( wxClientData *data ) | |
1125 | { if (m_data) delete m_data; m_data = data; } | |
1126 | wxClientData *GetData() const | |
1127 | { return m_data; } | |
b5ec7dd6 | 1128 | |
e94d0c1e RR |
1129 | wxDataViewItem GetItem() const |
1130 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 1131 | |
e94d0c1e RR |
1132 | virtual bool IsContainer() |
1133 | { return false; } | |
b5ec7dd6 | 1134 | |
e94d0c1e RR |
1135 | wxDataViewTreeStoreNode *GetParent() |
1136 | { return m_parent; } | |
b5ec7dd6 | 1137 | |
e94d0c1e RR |
1138 | private: |
1139 | wxDataViewTreeStoreNode *m_parent; | |
1140 | wxString m_text; | |
1141 | wxIcon m_icon; | |
1142 | wxClientData *m_data; | |
1143 | }; | |
1144 | ||
1145 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
1146 | class WXDLLIMPEXP_ADV); | |
1147 | ||
1148 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
1149 | { | |
1150 | public: | |
b5ec7dd6 VZ |
1151 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
1152 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1153 | wxClientData *data = NULL ); |
1154 | virtual ~wxDataViewTreeStoreContainerNode(); | |
1155 | ||
b5ec7dd6 | 1156 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 1157 | { return m_children; } |
b5ec7dd6 | 1158 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
1159 | { return m_children; } |
1160 | ||
1161 | void SetExpandedIcon( const wxIcon &icon ) | |
1162 | { m_iconExpanded = icon; } | |
1163 | const wxIcon &GetExpandedIcon() const | |
1164 | { return m_iconExpanded; } | |
b5ec7dd6 | 1165 | |
a75124d0 RR |
1166 | void SetExpanded( bool expanded = true ) |
1167 | { m_isExpanded = expanded; } | |
1168 | bool IsExpanded() const | |
1169 | { return m_isExpanded; } | |
1170 | ||
e94d0c1e RR |
1171 | virtual bool IsContainer() |
1172 | { return true; } | |
b5ec7dd6 | 1173 | |
e94d0c1e RR |
1174 | private: |
1175 | wxDataViewTreeStoreNodeList m_children; | |
1176 | wxIcon m_iconExpanded; | |
a75124d0 | 1177 | bool m_isExpanded; |
e94d0c1e RR |
1178 | }; |
1179 | ||
1180 | //----------------------------------------------------------------------------- | |
1181 | ||
1182 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
1183 | { | |
1184 | public: | |
1185 | wxDataViewTreeStore(); | |
1186 | ~wxDataViewTreeStore(); | |
1187 | ||
b5ec7dd6 | 1188 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
1189 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
1190 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1191 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
1192 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1193 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
1194 | |
1195 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1196 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
1197 | wxClientData *data = NULL ); |
1198 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 1199 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1200 | wxClientData *data = NULL ); |
1201 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 1202 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
1203 | wxClientData *data = NULL ); |
1204 | ||
1205 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
1206 | int GetChildCount( const wxDataViewItem& parent ) const; | |
b5ec7dd6 | 1207 | |
e94d0c1e RR |
1208 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
1209 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 1210 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
1211 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
1212 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
1213 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
1214 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
1215 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
1216 | ||
1217 | void DeleteItem( const wxDataViewItem& item ); | |
1218 | void DeleteChildren( const wxDataViewItem& item ); | |
1219 | void DeleteAllItems(); | |
b5ec7dd6 | 1220 | |
e94d0c1e RR |
1221 | // implement base methods |
1222 | ||
b5ec7dd6 | 1223 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 1224 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 1225 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
1226 | const wxDataViewItem &item, unsigned int col ); |
1227 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
1228 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
1229 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
1230 | ||
b5ec7dd6 | 1231 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
862de7b3 | 1232 | unsigned int column, bool ascending ) const; |
b5ec7dd6 VZ |
1233 | |
1234 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 1235 | { return true; } |
b5ec7dd6 | 1236 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 1237 | { return 1; }; |
b5ec7dd6 | 1238 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 1239 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 1240 | |
e94d0c1e RR |
1241 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
1242 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
1243 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 1244 | |
e94d0c1e RR |
1245 | public: |
1246 | wxDataViewTreeStoreNode *m_root; | |
1247 | }; | |
1248 | ||
dc813e6c RR |
1249 | //----------------------------------------------------------------------------- |
1250 | ||
e94d0c1e RR |
1251 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl |
1252 | { | |
1253 | public: | |
a75124d0 RR |
1254 | wxDataViewTreeCtrl(); |
1255 | wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id, | |
e94d0c1e | 1256 | const wxPoint& pos = wxDefaultPosition, |
1a07a730 | 1257 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e | 1258 | const wxValidator& validator = wxDefaultValidator ); |
a75124d0 | 1259 | ~wxDataViewTreeCtrl(); |
e94d0c1e RR |
1260 | |
1261 | bool Create( wxWindow *parent, wxWindowID id, | |
1262 | const wxPoint& pos = wxDefaultPosition, | |
1a07a730 | 1263 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e RR |
1264 | const wxValidator& validator = wxDefaultValidator ); |
1265 | ||
1266 | wxDataViewTreeStore *GetStore() | |
1267 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
1268 | const wxDataViewTreeStore *GetStore() const |
1269 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 1270 | |
a75124d0 RR |
1271 | void SetImageList( wxImageList *imagelist ); |
1272 | wxImageList* GetImageList() { return m_imageList; } | |
c058cafa | 1273 | |
a75124d0 RR |
1274 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
1275 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1276 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1277 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1278 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1279 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1280 | ||
1281 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1282 | const wxString &text, int icon = -1, int expanded = -1, | |
1283 | wxClientData *data = NULL ); | |
1284 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
1285 | const wxString &text, int icon = -1, int expanded = -1, | |
1286 | wxClientData *data = NULL ); | |
1287 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1288 | const wxString &text, int icon = -1, int expanded = -1, | |
1289 | wxClientData *data = NULL ); | |
1290 | ||
1291 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
1292 | { return GetStore()->GetNthChild(parent, pos); } | |
1293 | int GetChildCount( const wxDataViewItem& parent ) const | |
1294 | { return GetStore()->GetChildCount(parent); } | |
1295 | ||
e700e296 | 1296 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
a75124d0 RR |
1297 | wxString GetItemText( const wxDataViewItem& item ) const |
1298 | { return GetStore()->GetItemText(item); } | |
e700e296 | 1299 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1300 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const |
1301 | { return GetStore()->GetItemIcon(item); } | |
e700e296 | 1302 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); |
a75124d0 RR |
1303 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const |
1304 | { return GetStore()->GetItemExpandedIcon(item); } | |
1305 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1306 | { GetStore()->SetItemData(item,data); } | |
1307 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1308 | { return GetStore()->GetItemData(item); } | |
1309 | ||
e700e296 RR |
1310 | void DeleteItem( const wxDataViewItem& item ); |
1311 | void DeleteChildren( const wxDataViewItem& item ); | |
1312 | void DeleteAllItems(); | |
a75124d0 RR |
1313 | |
1314 | void OnExpanded( wxDataViewEvent &event ); | |
1315 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1316 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1317 | |
e94d0c1e | 1318 | private: |
a75124d0 RR |
1319 | wxImageList *m_imageList; |
1320 | ||
1321 | private: | |
1322 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1323 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1324 | }; | |
e94d0c1e | 1325 | |
bcd846ea RR |
1326 | #endif // wxUSE_DATAVIEWCTRL |
1327 | ||
1328 | #endif | |
1329 | // _WX_DATAVIEW_H_BASE_ |