]>
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 RR |
19 | #include "wx/control.h" |
20 | #include "wx/textctrl.h" | |
21 | #include "wx/bitmap.h" | |
64ffb888 | 22 | #include "wx/variant.h" |
b7e9f8b1 | 23 | #include "wx/dynarray.h" |
89352653 | 24 | #include "wx/icon.h" |
a75124d0 | 25 | #include "wx/imaglist.h" |
c232dfe5 | 26 | #include "wx/weakref.h" |
4ed7af08 | 27 | |
5e6f8927 PC |
28 | class WXDLLIMPEXP_FWD_CORE wxDataFormat; |
29 | ||
4ed7af08 RR |
30 | #if defined(__WXGTK20__) |
31 | // for testing | |
001f0f82 | 32 | // #define wxUSE_GENERICDATAVIEWCTRL 1 |
4ed7af08 | 33 | #elif defined(__WXMAC__) |
4ed7af08 RR |
34 | #else |
35 | #define wxUSE_GENERICDATAVIEWCTRL 1 | |
36 | #endif | |
37 | ||
bcd846ea | 38 | // ---------------------------------------------------------------------------- |
f554a14b | 39 | // wxDataViewCtrl flags |
bcd846ea RR |
40 | // ---------------------------------------------------------------------------- |
41 | ||
239eaa41 RR |
42 | // ---------------------------------------------------------------------------- |
43 | // wxDataViewCtrl globals | |
44 | // ---------------------------------------------------------------------------- | |
bcd846ea | 45 | |
b5dbe15d VS |
46 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; |
47 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
48 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
49 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
50 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
51 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
fa28826d | 52 | |
f460c29d | 53 | extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; |
bcd846ea | 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 | |
f6f0ef85 RR |
198 | // define DnD capabilities |
199 | virtual bool IsDraggable( const wxDataViewItem &WXUNUSED(item) ) | |
200 | { return false; } | |
201 | virtual size_t GetDragDataSize( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format) ) | |
202 | { return 0; } | |
c058cafa | 203 | virtual bool GetDragData( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format), |
f6f0ef85 RR |
204 | void* WXUNUSED(data), size_t WXUNUSED(size) ) |
205 | { return FALSE; } | |
206 | ||
239eaa41 | 207 | // delegated notifiers |
e0062c04 | 208 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 209 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
469d3e9b | 210 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 211 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
e0062c04 | 212 | virtual bool ItemChanged( const wxDataViewItem &item ); |
854cdb09 | 213 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); |
e0062c04 | 214 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); |
8981608c | 215 | virtual bool Cleared(); |
b5d777c7 | 216 | |
ef427989 RR |
217 | // delegatd action |
218 | virtual void Resort(); | |
219 | ||
e0062c04 RR |
220 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
221 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
b5ec7dd6 | 222 | |
ef427989 | 223 | // default compare function |
b5ec7dd6 | 224 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
7ee7191c | 225 | unsigned int column, bool ascending ); |
09711964 | 226 | virtual bool HasDefaultCompare() const { return false; } |
c058cafa | 227 | |
2056dede | 228 | // internal |
e39de702 | 229 | virtual bool IsVirtualListModel() const { return false; } |
66e09788 | 230 | |
87f0efe2 RR |
231 | protected: |
232 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 233 | virtual ~wxDataViewModel() { } |
87f0efe2 | 234 | |
9d8fe14a | 235 | wxDataViewModelNotifiers m_notifiers; |
ef427989 RR |
236 | }; |
237 | ||
238 | // --------------------------------------------------------- | |
c534e696 | 239 | // wxDataViewIndexListModel |
ef427989 RR |
240 | // --------------------------------------------------------- |
241 | ||
d350fbec | 242 | class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel |
ef427989 RR |
243 | { |
244 | public: | |
c534e696 | 245 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); |
ef427989 | 246 | ~wxDataViewIndexListModel(); |
b5ec7dd6 | 247 | |
b5ec7dd6 | 248 | virtual void GetValue( wxVariant &variant, |
ef427989 RR |
249 | unsigned int row, unsigned int col ) const = 0; |
250 | ||
b5ec7dd6 | 251 | virtual bool SetValue( const wxVariant &variant, |
ef427989 | 252 | unsigned int row, unsigned int col ) = 0; |
b5ec7dd6 | 253 | |
4264606e RR |
254 | virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) |
255 | { return false; } | |
c058cafa | 256 | |
c534e696 RR |
257 | void RowPrepended(); |
258 | void RowInserted( unsigned int before ); | |
259 | void RowAppended(); | |
260 | void RowDeleted( unsigned int row ); | |
8b6cf9bf | 261 | void RowsDeleted( const wxArrayInt &rows ); |
c534e696 RR |
262 | void RowChanged( unsigned int row ); |
263 | void RowValueChanged( unsigned int row, unsigned int col ); | |
33ba5a05 | 264 | void Reset( unsigned int new_size ); |
b5ec7dd6 | 265 | |
c534e696 | 266 | // convert to/from row/wxDataViewItem |
b5ec7dd6 | 267 | |
c534e696 RR |
268 | unsigned int GetRow( const wxDataViewItem &item ) const; |
269 | wxDataViewItem GetItem( unsigned int row ) const; | |
b5ec7dd6 | 270 | |
c534e696 | 271 | // compare based on index |
b5ec7dd6 VZ |
272 | |
273 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
7ee7191c | 274 | unsigned int column, bool ascending ); |
517166e6 | 275 | virtual bool HasDefaultCompare() const; |
c534e696 RR |
276 | |
277 | // implement base methods | |
278 | ||
b5ec7dd6 | 279 | virtual void GetValue( wxVariant &variant, |
c534e696 | 280 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 281 | virtual bool SetValue( const wxVariant &variant, |
c534e696 | 282 | const wxDataViewItem &item, unsigned int col ); |
4264606e | 283 | virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr ); |
c534e696 RR |
284 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; |
285 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
74fe973b | 286 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
b5ec7dd6 | 287 | |
2056dede | 288 | // internal |
e39de702 | 289 | virtual bool IsVirtualListModel() const { return false; } |
2056dede | 290 | unsigned int GetLastIndex() const { return m_lastIndex; } |
c058cafa | 291 | |
c534e696 | 292 | private: |
cd722937 | 293 | wxDataViewItemArray m_hash; |
c534e696 | 294 | unsigned int m_lastIndex; |
517166e6 | 295 | bool m_ordered; |
239eaa41 RR |
296 | }; |
297 | ||
e39de702 RR |
298 | // --------------------------------------------------------- |
299 | // wxDataViewVirtualListModel | |
300 | // --------------------------------------------------------- | |
301 | ||
302 | #ifdef __WXMAC__ | |
303 | // better than nothing | |
f1399150 | 304 | typedef wxDataViewIndexListModel wxDataViewVirtualListModel; |
e39de702 RR |
305 | #else |
306 | ||
307 | class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel | |
308 | { | |
309 | public: | |
310 | wxDataViewVirtualListModel( unsigned int initial_size = 0 ); | |
311 | ~wxDataViewVirtualListModel(); | |
312 | ||
313 | virtual void GetValue( wxVariant &variant, | |
314 | unsigned int row, unsigned int col ) const = 0; | |
315 | ||
316 | virtual bool SetValue( const wxVariant &variant, | |
317 | unsigned int row, unsigned int col ) = 0; | |
318 | ||
319 | virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) | |
320 | { return false; } | |
321 | ||
322 | void RowPrepended(); | |
323 | void RowInserted( unsigned int before ); | |
324 | void RowAppended(); | |
325 | void RowDeleted( unsigned int row ); | |
326 | void RowsDeleted( const wxArrayInt &rows ); | |
327 | void RowChanged( unsigned int row ); | |
328 | void RowValueChanged( unsigned int row, unsigned int col ); | |
329 | void Reset( unsigned int new_size ); | |
330 | ||
331 | // convert to/from row/wxDataViewItem | |
332 | ||
333 | unsigned int GetRow( const wxDataViewItem &item ) const; | |
334 | wxDataViewItem GetItem( unsigned int row ) const; | |
335 | ||
336 | // compare based on index | |
337 | ||
338 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
339 | unsigned int column, bool ascending ); | |
340 | virtual bool HasDefaultCompare() const; | |
341 | ||
342 | // implement base methods | |
343 | ||
344 | virtual void GetValue( wxVariant &variant, | |
345 | const wxDataViewItem &item, unsigned int col ) const; | |
346 | virtual bool SetValue( const wxVariant &variant, | |
347 | const wxDataViewItem &item, unsigned int col ); | |
348 | virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr ); | |
349 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
350 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
351 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
352 | ||
353 | // internal | |
354 | virtual bool IsVirtualListModel() const { return true; } | |
355 | unsigned int GetLastIndex() const { return m_lastIndex; } | |
356 | ||
357 | private: | |
358 | wxDataViewItemArray m_hash; | |
359 | unsigned int m_lastIndex; | |
360 | bool m_ordered; | |
361 | }; | |
362 | #endif | |
c33edc08 | 363 | |
1e510b1e RR |
364 | //----------------------------------------------------------------------------- |
365 | // wxDataViewEditorCtrlEvtHandler | |
366 | //----------------------------------------------------------------------------- | |
367 | ||
368 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
369 | { | |
370 | public: | |
371 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
b5ec7dd6 | 372 | |
1e510b1e | 373 | void AcceptChangesAndFinish(); |
30715fa1 | 374 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
375 | |
376 | protected: | |
377 | void OnChar( wxKeyEvent &event ); | |
378 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 379 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
380 | |
381 | private: | |
382 | wxDataViewRenderer *m_owner; | |
383 | wxControl *m_editorCtrl; | |
384 | bool m_finished; | |
30715fa1 | 385 | bool m_focusOnIdle; |
1e510b1e RR |
386 | |
387 | private: | |
388 | DECLARE_EVENT_TABLE() | |
389 | }; | |
390 | ||
f554a14b | 391 | // --------------------------------------------------------- |
baa9ebc4 | 392 | // wxDataViewRendererBase |
f554a14b | 393 | // --------------------------------------------------------- |
fa28826d | 394 | |
6842a71a | 395 | enum wxDataViewCellMode |
fa28826d | 396 | { |
6842a71a RR |
397 | wxDATAVIEW_CELL_INERT, |
398 | wxDATAVIEW_CELL_ACTIVATABLE, | |
399 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
400 | }; |
401 | ||
6842a71a RR |
402 | enum wxDataViewCellRenderState |
403 | { | |
404 | wxDATAVIEW_CELL_SELECTED = 1, | |
405 | wxDATAVIEW_CELL_PRELIT = 2, | |
406 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
407 | wxDATAVIEW_CELL_FOCUSED = 8 | |
408 | }; | |
409 | ||
baa9ebc4 | 410 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
411 | { |
412 | public: | |
b5ec7dd6 | 413 | wxDataViewRendererBase( const wxString &varianttype, |
9861f022 RR |
414 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
415 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
c232dfe5 | 416 | ~wxDataViewRendererBase(); |
6842a71a | 417 | |
9861f022 RR |
418 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
419 | { return true; } | |
f554a14b | 420 | |
6842a71a | 421 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
e51bf699 | 422 | wxDataViewColumn* GetOwner() const { return m_owner; } |
f554a14b | 423 | |
9861f022 RR |
424 | // renderer properties: |
425 | ||
426 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
427 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
428 | ||
429 | wxString GetVariantType() const { return m_variantType; } | |
430 | ||
431 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
432 | virtual wxDataViewCellMode GetMode() const = 0; | |
433 | ||
434 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
435 | // rather an "int"; that's because for rendering cells it's allowed | |
436 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
437 | virtual void SetAlignment( int align ) = 0; | |
438 | virtual int GetAlignment() const = 0; | |
b5ec7dd6 | 439 | |
1e510b1e RR |
440 | // in-place editing |
441 | virtual bool HasEditorCtrl() | |
442 | { return false; } | |
96c2a0dd VZ |
443 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
444 | wxRect WXUNUSED(labelRect), | |
445 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 446 | { return NULL; } |
96c2a0dd VZ |
447 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
448 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
449 | { return false; } |
450 | ||
e0062c04 | 451 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
452 | virtual void CancelEditing(); |
453 | virtual bool FinishEditing(); | |
b5ec7dd6 | 454 | |
1e510b1e | 455 | wxControl *GetEditorCtrl() { return m_editorCtrl; } |
b5ec7dd6 | 456 | |
a7f61f76 | 457 | protected: |
6842a71a RR |
458 | wxString m_variantType; |
459 | wxDataViewColumn *m_owner; | |
c232dfe5 | 460 | wxWeakRef<wxControl> m_editorCtrl; |
e0062c04 | 461 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 462 | |
9861f022 RR |
463 | // internal utility: |
464 | const wxDataViewCtrl* GetView() const; | |
465 | ||
6842a71a | 466 | protected: |
baa9ebc4 | 467 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
468 | }; |
469 | ||
89352653 RR |
470 | //----------------------------------------------------------------------------- |
471 | // wxDataViewIconText | |
472 | //----------------------------------------------------------------------------- | |
473 | ||
d350fbec | 474 | class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject |
89352653 RR |
475 | { |
476 | public: | |
477 | wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) | |
5e6f8927 PC |
478 | : m_text(text), m_icon(icon) |
479 | { } | |
89352653 RR |
480 | wxDataViewIconText( const wxDataViewIconText &other ) |
481 | { m_icon = other.m_icon; m_text = other.m_text; } | |
482 | ||
483 | void SetText( const wxString &text ) { m_text = text; } | |
484 | wxString GetText() const { return m_text; } | |
485 | void SetIcon( const wxIcon &icon ) { m_icon = icon; } | |
486 | const wxIcon &GetIcon() const { return m_icon; } | |
487 | ||
488 | private: | |
489 | wxString m_text; | |
490 | wxIcon m_icon; | |
491 | ||
492 | private: | |
493 | DECLARE_DYNAMIC_CLASS(wxDataViewIconText) | |
494 | }; | |
495 | ||
496 | bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two); | |
497 | ||
d350fbec | 498 | DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) |
89352653 | 499 | |
f554a14b | 500 | // --------------------------------------------------------- |
6842a71a | 501 | // wxDataViewColumnBase |
f554a14b | 502 | // --------------------------------------------------------- |
6842a71a | 503 | |
fa28826d RR |
504 | enum wxDataViewColumnFlags |
505 | { | |
e483dfcb RR |
506 | wxDATAVIEW_COL_RESIZABLE = 1, |
507 | wxDATAVIEW_COL_SORTABLE = 2, | |
508 | wxDATAVIEW_COL_REORDERABLE = 4, | |
509 | wxDATAVIEW_COL_HIDDEN = 8 | |
fa28826d RR |
510 | }; |
511 | ||
f460c29d | 512 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
513 | { |
514 | public: | |
b5ec7dd6 VZ |
515 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
516 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
517 | wxAlignment align = wxALIGN_CENTER, |
518 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
519 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, |
520 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
521 | wxAlignment align = wxALIGN_CENTER, |
522 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 523 | virtual ~wxDataViewColumnBase(); |
fa28826d | 524 | |
9861f022 | 525 | // setters: |
07b6378f | 526 | |
9861f022 | 527 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 528 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 529 | virtual void SetSortable( bool sortable ) = 0; |
99c75ebc | 530 | virtual void SetReorderable(bool reorderable) = 0; |
9861f022 RR |
531 | virtual void SetResizeable( bool resizeable ) = 0; |
532 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 533 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 | 534 | virtual void SetFlags( int flags ); |
b5ec7dd6 | 535 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 RR |
536 | { m_owner = owner; } |
537 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
538 | { m_bitmap=bitmap; } | |
07a84e7b | 539 | |
9861f022 RR |
540 | virtual void SetMinWidth( int minWidth ) = 0; |
541 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 542 | |
f554a14b | 543 | |
9861f022 | 544 | // getters: |
07b6378f | 545 | |
9861f022 RR |
546 | virtual wxString GetTitle() const = 0; |
547 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 548 | virtual int GetWidth() const = 0; |
9861f022 | 549 | virtual int GetMinWidth() const = 0; |
07b6378f | 550 | |
9861f022 RR |
551 | virtual int GetFlags() const; |
552 | ||
9861f022 | 553 | virtual bool IsHidden() const = 0; |
99c75ebc RR |
554 | virtual bool IsReorderable() const = 0; |
555 | virtual bool IsResizeable() const = 0; | |
556 | virtual bool IsSortable() const = 0; | |
9861f022 RR |
557 | virtual bool IsSortOrderAscending() const = 0; |
558 | ||
559 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
6d9ecc87 | 560 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
9861f022 | 561 | |
594d5596 RR |
562 | wxDataViewCtrl *GetOwner() const { return m_owner; } |
563 | wxDataViewRenderer* GetRenderer() const { return m_renderer; } | |
9861f022 RR |
564 | |
565 | protected: | |
baa9ebc4 | 566 | wxDataViewRenderer *m_renderer; |
6842a71a | 567 | int m_model_column; |
07a84e7b | 568 | wxBitmap m_bitmap; |
6842a71a | 569 | wxDataViewCtrl *m_owner; |
fa28826d RR |
570 | |
571 | protected: | |
572 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
573 | }; | |
574 | ||
f554a14b | 575 | // --------------------------------------------------------- |
239eaa41 | 576 | // wxDataViewCtrlBase |
f554a14b | 577 | // --------------------------------------------------------- |
239eaa41 | 578 | |
c21f7aa1 | 579 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
580 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
581 | ||
582 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
583 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
584 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 585 | |
1a07a730 RR |
586 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows |
587 | ||
f460c29d | 588 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
589 | { |
590 | public: | |
591 | wxDataViewCtrlBase(); | |
d3c7fc99 | 592 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 593 | |
e0062c04 RR |
594 | virtual bool AssociateModel( wxDataViewModel *model ); |
595 | wxDataViewModel* GetModel(); | |
a75124d0 | 596 | const wxDataViewModel* GetModel() const; |
f554a14b | 597 | |
07a84e7b | 598 | // short cuts |
b5ec7dd6 | 599 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
600 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
601 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
602 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 603 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
604 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
605 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
606 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
607 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
608 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
609 | wxAlignment align = wxALIGN_CENTER, | |
610 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 611 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
612 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
613 | wxAlignment align = wxALIGN_CENTER, | |
614 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
615 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
616 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
617 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
618 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
619 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
620 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
621 | wxAlignment align = wxALIGN_CENTER, | |
622 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
623 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
624 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
625 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
626 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
627 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
628 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
629 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
630 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
631 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
632 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
633 | wxAlignment align = wxALIGN_CENTER, | |
634 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
635 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
636 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
637 | wxAlignment align = wxALIGN_CENTER, | |
638 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
639 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
640 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
641 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
642 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
643 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
644 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
645 | wxAlignment align = wxALIGN_CENTER, | |
646 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
647 | |
648 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 649 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 650 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 651 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 652 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 653 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 654 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 655 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 656 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
657 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
658 | wxAlignment align = wxALIGN_CENTER, | |
659 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 660 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
661 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
662 | wxAlignment align = wxALIGN_CENTER, | |
663 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 664 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 665 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 666 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 667 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 668 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
669 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
670 | wxAlignment align = wxALIGN_CENTER, | |
671 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 672 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 673 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 674 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 675 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
676 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
677 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
e2da67f6 | 678 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 679 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 680 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
681 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
682 | wxAlignment align = wxALIGN_CENTER, | |
683 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 684 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
685 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
686 | wxAlignment align = wxALIGN_CENTER, | |
687 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 688 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 689 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 690 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 691 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 692 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
693 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
694 | wxAlignment align = wxALIGN_CENTER, | |
695 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c RR |
696 | |
697 | ||
698 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
f554a14b | 699 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 700 | |
91a6c655 RR |
701 | virtual unsigned int GetColumnCount() const = 0; |
702 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 703 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 704 | |
91a6c655 RR |
705 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
706 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 707 | |
1b27b2bd | 708 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 709 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 710 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 711 | { return m_expander_column; } |
b5ec7dd6 | 712 | |
21f47fb9 | 713 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
3b6280be RR |
714 | |
715 | void SetIndent( int indent ) | |
716 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
717 | int GetIndent() const |
718 | { return m_indent; } | |
3b6280be | 719 | |
fbda518c | 720 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
721 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
722 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
723 | virtual void Select( const wxDataViewItem & item ) = 0; | |
724 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
725 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
726 | ||
b7e9f8b1 RR |
727 | virtual void SelectAll() = 0; |
728 | virtual void UnselectAll() = 0; | |
729 | ||
f71d3ba4 RR |
730 | virtual void Expand( const wxDataViewItem & item ) = 0; |
731 | virtual void Collapse( const wxDataViewItem & item ) = 0; | |
732 | ||
6154212e | 733 | virtual void EnsureVisible( const wxDataViewItem & item, |
fbda518c | 734 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 735 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 736 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
b7e9f8b1 | 737 | |
3b6280be RR |
738 | protected: |
739 | virtual void DoSetExpanderColumn() = 0 ; | |
740 | virtual void DoSetIndent() = 0; | |
741 | ||
239eaa41 | 742 | private: |
e0062c04 | 743 | wxDataViewModel *m_model; |
1b27b2bd | 744 | wxDataViewColumn *m_expander_column; |
3b6280be | 745 | int m_indent ; |
b5ec7dd6 | 746 | |
239eaa41 | 747 | protected: |
260b9be7 | 748 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 749 | }; |
bcd846ea | 750 | |
eb7f97f8 RR |
751 | // ---------------------------------------------------------------------------- |
752 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
753 | // ---------------------------------------------------------------------------- | |
754 | ||
2f799ae8 | 755 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
756 | { |
757 | public: | |
758 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
759 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 760 | m_item(0), |
eb7f97f8 | 761 | m_col(-1), |
eb7f97f8 RR |
762 | m_model(NULL), |
763 | m_value(wxNullVariant), | |
6af3eec2 RR |
764 | m_column(NULL), |
765 | m_pos(-1,-1) | |
eb7f97f8 RR |
766 | { } |
767 | ||
768 | wxDataViewEvent(const wxDataViewEvent& event) | |
769 | : wxNotifyEvent(event), | |
e0062c04 | 770 | m_item(event.m_item), |
eb7f97f8 | 771 | m_col(event.m_col), |
eb7f97f8 RR |
772 | m_model(event.m_model), |
773 | m_value(event.m_value), | |
6af3eec2 RR |
774 | m_column(event.m_column), |
775 | m_pos(m_pos) | |
eb7f97f8 RR |
776 | { } |
777 | ||
e0062c04 RR |
778 | wxDataViewItem GetItem() const { return m_item; } |
779 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
780 | ||
eb7f97f8 RR |
781 | int GetColumn() const { return m_col; } |
782 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 783 | |
eb7f97f8 RR |
784 | wxDataViewModel* GetModel() const { return m_model; } |
785 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 786 | |
eb7f97f8 RR |
787 | const wxVariant &GetValue() const { return m_value; } |
788 | void SetValue( const wxVariant &value ) { m_value = value; } | |
789 | ||
31fb32e1 RR |
790 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
791 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 792 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
c058cafa | 793 | |
6af3eec2 | 794 | // for wxEVT_DATAVIEW_CONTEXT_MENU only |
5cfb6fee | 795 | wxPoint GetPosition() const { return m_pos; } |
6af3eec2 | 796 | void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } |
31fb32e1 | 797 | |
eb7f97f8 RR |
798 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
799 | ||
800 | protected: | |
e0062c04 | 801 | wxDataViewItem m_item; |
eb7f97f8 | 802 | int m_col; |
eb7f97f8 RR |
803 | wxDataViewModel *m_model; |
804 | wxVariant m_value; | |
31fb32e1 | 805 | wxDataViewColumn *m_column; |
6af3eec2 | 806 | wxPoint m_pos; |
eb7f97f8 RR |
807 | |
808 | private: | |
809 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
810 | }; | |
811 | ||
c058cafa VZ |
812 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED; |
813 | ||
814 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED; | |
815 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED; | |
816 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED; | |
817 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING; | |
818 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING; | |
819 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED; | |
820 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE; | |
821 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED; | |
822 | ||
823 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU; | |
824 | ||
825 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK; | |
826 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK; | |
827 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED; | |
828 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED; | |
eb7f97f8 RR |
829 | |
830 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
831 | ||
832 | #define wxDataViewEventHandler(func) \ | |
833 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
834 | ||
835 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
836 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
837 | ||
d86c1870 RR |
838 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
839 | ||
e0062c04 | 840 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 841 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 842 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 843 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 844 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
e0000f94 RR |
845 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
846 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 847 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 848 | |
6af3eec2 RR |
849 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
850 | ||
31fb32e1 RR |
851 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
852 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 853 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
e483dfcb | 854 | #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) |
eb7f97f8 | 855 | |
4ed7af08 RR |
856 | #if defined(wxUSE_GENERICDATAVIEWCTRL) |
857 | #include "wx/generic/dataview.h" | |
858 | #elif defined(__WXGTK20__) | |
bcd846ea RR |
859 | #include "wx/gtk/dataview.h" |
860 | #elif defined(__WXMAC__) | |
c0a66d92 | 861 | #include "wx/mac/dataview.h" |
bcd846ea RR |
862 | #else |
863 | #include "wx/generic/dataview.h" | |
864 | #endif | |
865 | ||
52e750fc RR |
866 | // ------------------------------------- |
867 | // wxDataViewSpinRenderer | |
868 | // ------------------------------------- | |
869 | ||
4660b556 | 870 | class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer |
52e750fc RR |
871 | { |
872 | public: | |
873 | wxDataViewSpinRenderer( int min, int max, | |
874 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
875 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
876 | virtual bool HasEditorCtrl() { return true; } | |
877 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
878 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
879 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
880 | virtual wxSize GetSize() const; | |
881 | virtual bool SetValue( const wxVariant &value ); | |
882 | virtual bool GetValue( wxVariant &value ) const; | |
b5ec7dd6 | 883 | |
52e750fc RR |
884 | private: |
885 | long m_data; | |
886 | long m_min,m_max; | |
887 | }; | |
888 | ||
e94d0c1e RR |
889 | //----------------------------------------------------------------------------- |
890 | // wxDataViewTreeStore | |
891 | //----------------------------------------------------------------------------- | |
892 | ||
893 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
894 | { | |
895 | public: | |
896 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
897 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
898 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
899 | |
900 | void SetText( const wxString &text ) | |
e94d0c1e RR |
901 | { m_text = text; } |
902 | wxString GetText() const | |
903 | { return m_text; } | |
904 | void SetIcon( const wxIcon &icon ) | |
905 | { m_icon = icon; } | |
906 | const wxIcon &GetIcon() const | |
907 | { return m_icon; } | |
908 | void SetData( wxClientData *data ) | |
909 | { if (m_data) delete m_data; m_data = data; } | |
910 | wxClientData *GetData() const | |
911 | { return m_data; } | |
b5ec7dd6 | 912 | |
e94d0c1e RR |
913 | wxDataViewItem GetItem() const |
914 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 915 | |
e94d0c1e RR |
916 | virtual bool IsContainer() |
917 | { return false; } | |
b5ec7dd6 | 918 | |
e94d0c1e RR |
919 | wxDataViewTreeStoreNode *GetParent() |
920 | { return m_parent; } | |
b5ec7dd6 | 921 | |
e94d0c1e RR |
922 | private: |
923 | wxDataViewTreeStoreNode *m_parent; | |
924 | wxString m_text; | |
925 | wxIcon m_icon; | |
926 | wxClientData *m_data; | |
927 | }; | |
928 | ||
929 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
930 | class WXDLLIMPEXP_ADV); | |
931 | ||
932 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
933 | { | |
934 | public: | |
b5ec7dd6 VZ |
935 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
936 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
937 | wxClientData *data = NULL ); |
938 | virtual ~wxDataViewTreeStoreContainerNode(); | |
939 | ||
b5ec7dd6 | 940 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 941 | { return m_children; } |
b5ec7dd6 | 942 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
943 | { return m_children; } |
944 | ||
945 | void SetExpandedIcon( const wxIcon &icon ) | |
946 | { m_iconExpanded = icon; } | |
947 | const wxIcon &GetExpandedIcon() const | |
948 | { return m_iconExpanded; } | |
b5ec7dd6 | 949 | |
a75124d0 RR |
950 | void SetExpanded( bool expanded = true ) |
951 | { m_isExpanded = expanded; } | |
952 | bool IsExpanded() const | |
953 | { return m_isExpanded; } | |
954 | ||
e94d0c1e RR |
955 | virtual bool IsContainer() |
956 | { return true; } | |
b5ec7dd6 | 957 | |
e94d0c1e RR |
958 | private: |
959 | wxDataViewTreeStoreNodeList m_children; | |
960 | wxIcon m_iconExpanded; | |
a75124d0 | 961 | bool m_isExpanded; |
e94d0c1e RR |
962 | }; |
963 | ||
964 | //----------------------------------------------------------------------------- | |
965 | ||
966 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
967 | { | |
968 | public: | |
969 | wxDataViewTreeStore(); | |
970 | ~wxDataViewTreeStore(); | |
971 | ||
b5ec7dd6 | 972 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
973 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
974 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
975 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
976 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
977 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
978 | |
979 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
980 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
981 | wxClientData *data = NULL ); |
982 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 983 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
984 | wxClientData *data = NULL ); |
985 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 986 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
987 | wxClientData *data = NULL ); |
988 | ||
989 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
990 | int GetChildCount( const wxDataViewItem& parent ) const; | |
b5ec7dd6 | 991 | |
e94d0c1e RR |
992 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
993 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 994 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
995 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
996 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
997 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
998 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
999 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
1000 | ||
1001 | void DeleteItem( const wxDataViewItem& item ); | |
1002 | void DeleteChildren( const wxDataViewItem& item ); | |
1003 | void DeleteAllItems(); | |
b5ec7dd6 | 1004 | |
e94d0c1e RR |
1005 | // implement base methods |
1006 | ||
b5ec7dd6 | 1007 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 1008 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 1009 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
1010 | const wxDataViewItem &item, unsigned int col ); |
1011 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
1012 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
1013 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
1014 | ||
b5ec7dd6 | 1015 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
e94d0c1e | 1016 | unsigned int column, bool ascending ); |
b5ec7dd6 VZ |
1017 | |
1018 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 1019 | { return true; } |
b5ec7dd6 | 1020 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 1021 | { return 1; }; |
b5ec7dd6 | 1022 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 1023 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 1024 | |
e94d0c1e RR |
1025 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
1026 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
1027 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 1028 | |
e94d0c1e RR |
1029 | public: |
1030 | wxDataViewTreeStoreNode *m_root; | |
1031 | }; | |
1032 | ||
e94d0c1e RR |
1033 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl |
1034 | { | |
1035 | public: | |
a75124d0 RR |
1036 | wxDataViewTreeCtrl(); |
1037 | wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id, | |
e94d0c1e | 1038 | const wxPoint& pos = wxDefaultPosition, |
1a07a730 | 1039 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e | 1040 | const wxValidator& validator = wxDefaultValidator ); |
a75124d0 | 1041 | ~wxDataViewTreeCtrl(); |
e94d0c1e RR |
1042 | |
1043 | bool Create( wxWindow *parent, wxWindowID id, | |
1044 | const wxPoint& pos = wxDefaultPosition, | |
1a07a730 | 1045 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e RR |
1046 | const wxValidator& validator = wxDefaultValidator ); |
1047 | ||
1048 | wxDataViewTreeStore *GetStore() | |
1049 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
1050 | const wxDataViewTreeStore *GetStore() const |
1051 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 1052 | |
a75124d0 RR |
1053 | void SetImageList( wxImageList *imagelist ); |
1054 | wxImageList* GetImageList() { return m_imageList; } | |
c058cafa | 1055 | |
a75124d0 RR |
1056 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
1057 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1058 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
1059 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1060 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1061 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
1062 | ||
1063 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
1064 | const wxString &text, int icon = -1, int expanded = -1, | |
1065 | wxClientData *data = NULL ); | |
1066 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
1067 | const wxString &text, int icon = -1, int expanded = -1, | |
1068 | wxClientData *data = NULL ); | |
1069 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
1070 | const wxString &text, int icon = -1, int expanded = -1, | |
1071 | wxClientData *data = NULL ); | |
1072 | ||
1073 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
1074 | { return GetStore()->GetNthChild(parent, pos); } | |
1075 | int GetChildCount( const wxDataViewItem& parent ) const | |
1076 | { return GetStore()->GetChildCount(parent); } | |
1077 | ||
1078 | void SetItemText( const wxDataViewItem& item, const wxString &text ) | |
1079 | { GetStore()->SetItemText(item,text); } | |
1080 | wxString GetItemText( const wxDataViewItem& item ) const | |
1081 | { return GetStore()->GetItemText(item); } | |
1082 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) | |
1083 | { GetStore()->SetItemIcon(item,icon); } | |
1084 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const | |
1085 | { return GetStore()->GetItemIcon(item); } | |
1086 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) | |
1087 | { GetStore()->SetItemExpandedIcon(item,icon); } | |
1088 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const | |
1089 | { return GetStore()->GetItemExpandedIcon(item); } | |
1090 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1091 | { GetStore()->SetItemData(item,data); } | |
1092 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1093 | { return GetStore()->GetItemData(item); } | |
1094 | ||
1095 | void DeleteItem( const wxDataViewItem& item ) | |
1096 | { GetStore()->DeleteItem(item); } | |
1097 | void DeleteChildren( const wxDataViewItem& item ) | |
1098 | { GetStore()->DeleteChildren(item); } | |
1099 | void DeleteAllItems() | |
1100 | { GetStore()->DeleteAllItems(); } | |
1101 | ||
1102 | void OnExpanded( wxDataViewEvent &event ); | |
1103 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1104 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1105 | |
e94d0c1e | 1106 | private: |
a75124d0 RR |
1107 | wxImageList *m_imageList; |
1108 | ||
1109 | private: | |
1110 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1111 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1112 | }; | |
e94d0c1e | 1113 | |
bcd846ea RR |
1114 | #endif // wxUSE_DATAVIEWCTRL |
1115 | ||
1116 | #endif | |
1117 | // _WX_DATAVIEW_H_BASE_ |