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