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