]>
Commit | Line | Data |
---|---|---|
bcd846ea RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/dataview.h | |
3 | // Purpose: wxDataViewCtrl base classes | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
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" |
b9b8b59c | 23 | #include "wx/listctrl.h" |
4ed7af08 RR |
24 | |
25 | #if defined(__WXGTK20__) | |
26 | // for testing | |
1e08ad10 | 27 | // #define wxUSE_GENERICDATAVIEWCTRL 1 |
4ed7af08 | 28 | #elif defined(__WXMAC__) |
4ed7af08 RR |
29 | #else |
30 | #define wxUSE_GENERICDATAVIEWCTRL 1 | |
31 | #endif | |
32 | ||
bcd846ea | 33 | // ---------------------------------------------------------------------------- |
f554a14b | 34 | // wxDataViewCtrl flags |
bcd846ea RR |
35 | // ---------------------------------------------------------------------------- |
36 | ||
239eaa41 RR |
37 | // ---------------------------------------------------------------------------- |
38 | // wxDataViewCtrl globals | |
39 | // ---------------------------------------------------------------------------- | |
bcd846ea | 40 | |
b5dbe15d VS |
41 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; |
42 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
43 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
44 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
45 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
46 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
e0062c04 | 47 | class wxDataViewEventModelNotifier; |
fa28826d | 48 | |
f460c29d | 49 | extern WXDLLIMPEXP_DATA_ADV(const wxChar) 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 | ||
60 | // the default alignment of wxDataViewRenderers: | |
61 | #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP) | |
62 | ||
87f0efe2 | 63 | |
f554a14b | 64 | // --------------------------------------------------------- |
e0062c04 | 65 | // wxDataViewItem |
f554a14b | 66 | // --------------------------------------------------------- |
239eaa41 | 67 | |
e0062c04 | 68 | class WXDLLIMPEXP_ADV wxDataViewItem |
239eaa41 RR |
69 | { |
70 | public: | |
9d52aad3 RR |
71 | wxDataViewItem( void* id = NULL ) |
72 | { m_id = id; } | |
e0062c04 | 73 | wxDataViewItem( const wxDataViewItem &item ) |
9d52aad3 RR |
74 | { m_id = item.m_id; } |
75 | bool IsOk() const { return m_id != NULL; } | |
76 | void* GetID() const { return m_id; } | |
e0062c04 | 77 | |
8f850e28 | 78 | private: |
9d52aad3 | 79 | void* m_id; |
64ffb888 | 80 | }; |
239eaa41 | 81 | |
d5025dc0 | 82 | bool operator == (const wxDataViewItem &left, const wxDataViewItem &right); |
aba9bfd0 | 83 | |
f554a14b | 84 | // --------------------------------------------------------- |
e0062c04 | 85 | // wxDataViewModel |
f554a14b | 86 | // --------------------------------------------------------- |
239eaa41 | 87 | |
e0062c04 | 88 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData |
239eaa41 RR |
89 | { |
90 | public: | |
e0062c04 | 91 | wxDataViewModel(); |
239eaa41 | 92 | |
9861f022 | 93 | virtual unsigned int GetColumnCount() const = 0; |
87f0efe2 | 94 | |
a7f61f76 | 95 | // return type as reported by wxVariant |
9861f022 | 96 | virtual wxString GetColumnType( unsigned int col ) const = 0; |
87f0efe2 | 97 | |
a7f61f76 | 98 | // get value into a wxVariant |
e0062c04 RR |
99 | virtual void GetValue( wxVariant &variant, |
100 | const wxDataViewItem &item, unsigned int col ) const = 0; | |
87f0efe2 | 101 | |
a7f61f76 | 102 | // set value, call ValueChanged() afterwards! |
e0062c04 RR |
103 | virtual bool SetValue( const wxVariant &variant, |
104 | const wxDataViewItem &item, unsigned int col ) = 0; | |
239eaa41 | 105 | |
e0062c04 RR |
106 | // define hierachy |
107 | virtual bool HasChildren( const wxDataViewItem &item ) const = 0; | |
e0062c04 RR |
108 | virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const = 0; |
109 | virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const = 0; | |
b9b8b59c | 110 | |
239eaa41 | 111 | // delegated notifiers |
e0062c04 RR |
112 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
113 | virtual bool ItemDeleted( const wxDataViewItem &item ); | |
114 | virtual bool ItemChanged( const wxDataViewItem &item ); | |
115 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); | |
8981608c | 116 | virtual bool Cleared(); |
b5d777c7 | 117 | |
ef427989 RR |
118 | // delegatd action |
119 | virtual void Resort(); | |
120 | ||
e0062c04 RR |
121 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
122 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
63415a42 | 123 | |
ef427989 RR |
124 | // default compare function |
125 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 ); | |
126 | ||
127 | void SetSortingColumn( unsigned int col ) { m_sortingColumn = col; } | |
128 | unsigned int GetSortingColumn() { return m_sortingColumn; } | |
4508fcd2 | 129 | void SetSortOrderAscending( bool ascending ) { m_ascending = ascending; } |
ef427989 RR |
130 | bool GetSortOrderAscending() { return m_ascending; } |
131 | ||
5732efaa | 132 | |
87f0efe2 RR |
133 | protected: |
134 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 135 | virtual ~wxDataViewModel() { } |
87f0efe2 | 136 | |
5732efaa | 137 | wxList m_notifiers; |
ef427989 RR |
138 | unsigned int m_sortingColumn; |
139 | bool m_ascending; | |
140 | }; | |
141 | ||
142 | // --------------------------------------------------------- | |
143 | // wxDataViewVirtualListModel | |
144 | // --------------------------------------------------------- | |
145 | ||
146 | class wxDataViewIndexListModel: public wxDataViewModel | |
147 | { | |
148 | public: | |
149 | wxDataViewIndexListModel(); | |
150 | ~wxDataViewIndexListModel(); | |
151 | ||
152 | virtual unsigned int GetRowCount() = 0; | |
153 | ||
154 | virtual void GetValue( wxVariant &variant, | |
155 | unsigned int row, unsigned int col ) const = 0; | |
156 | ||
157 | virtual bool SetValue( const wxVariant &variant, | |
158 | unsigned int row, unsigned int col ) = 0; | |
159 | ||
160 | void ItemPrepended(); | |
161 | void ItemInserted( unsigned int before ); | |
162 | void ItemAppended(); | |
163 | void ItemChanged( unsigned int row ); | |
164 | void ValueChanged( unsigned int row, unsigned int col ); | |
165 | ||
166 | wxDataViewItem GetItem( unsigned int row ); | |
167 | ||
168 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 ); | |
169 | ||
239eaa41 RR |
170 | }; |
171 | ||
f554a14b | 172 | // --------------------------------------------------------- |
e0062c04 | 173 | // wxDataViewModelNotifier |
f554a14b | 174 | // --------------------------------------------------------- |
8981608c | 175 | |
e0062c04 | 176 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier: public wxObject |
8981608c RR |
177 | { |
178 | public: | |
e0062c04 RR |
179 | wxDataViewModelNotifier() { } |
180 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } | |
9861f022 | 181 | |
e0062c04 RR |
182 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; |
183 | virtual bool ItemDeleted( const wxDataViewItem &item ) = 0; | |
184 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
185 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; | |
186 | virtual bool Cleared() = 0; | |
ef427989 RR |
187 | |
188 | virtual void Resort() { }; | |
8981608c | 189 | |
e0062c04 RR |
190 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } |
191 | wxDataViewModel *GetOwner() { return m_owner; } | |
8f850e28 | 192 | |
8981608c | 193 | private: |
e0062c04 | 194 | wxDataViewModel *m_owner; |
8981608c RR |
195 | }; |
196 | ||
e0062c04 | 197 | |
1e510b1e RR |
198 | //----------------------------------------------------------------------------- |
199 | // wxDataViewEditorCtrlEvtHandler | |
200 | //----------------------------------------------------------------------------- | |
201 | ||
202 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
203 | { | |
204 | public: | |
205 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
206 | ||
207 | void AcceptChangesAndFinish(); | |
30715fa1 | 208 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
209 | |
210 | protected: | |
211 | void OnChar( wxKeyEvent &event ); | |
212 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 213 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
214 | |
215 | private: | |
216 | wxDataViewRenderer *m_owner; | |
217 | wxControl *m_editorCtrl; | |
218 | bool m_finished; | |
30715fa1 | 219 | bool m_focusOnIdle; |
1e510b1e RR |
220 | |
221 | private: | |
222 | DECLARE_EVENT_TABLE() | |
223 | }; | |
224 | ||
f554a14b | 225 | // --------------------------------------------------------- |
baa9ebc4 | 226 | // wxDataViewRendererBase |
f554a14b | 227 | // --------------------------------------------------------- |
fa28826d | 228 | |
6842a71a | 229 | enum wxDataViewCellMode |
fa28826d | 230 | { |
6842a71a RR |
231 | wxDATAVIEW_CELL_INERT, |
232 | wxDATAVIEW_CELL_ACTIVATABLE, | |
233 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
234 | }; |
235 | ||
6842a71a RR |
236 | enum wxDataViewCellRenderState |
237 | { | |
238 | wxDATAVIEW_CELL_SELECTED = 1, | |
239 | wxDATAVIEW_CELL_PRELIT = 2, | |
240 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
241 | wxDATAVIEW_CELL_FOCUSED = 8 | |
242 | }; | |
243 | ||
baa9ebc4 | 244 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
245 | { |
246 | public: | |
9861f022 RR |
247 | wxDataViewRendererBase( const wxString &varianttype, |
248 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
249 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 250 | |
9861f022 RR |
251 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
252 | { return true; } | |
f554a14b | 253 | |
6842a71a RR |
254 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
255 | wxDataViewColumn* GetOwner() { return m_owner; } | |
f554a14b | 256 | |
9861f022 RR |
257 | // renderer properties: |
258 | ||
259 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
260 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
261 | ||
262 | wxString GetVariantType() const { return m_variantType; } | |
263 | ||
264 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
265 | virtual wxDataViewCellMode GetMode() const = 0; | |
266 | ||
267 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
268 | // rather an "int"; that's because for rendering cells it's allowed | |
269 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
270 | virtual void SetAlignment( int align ) = 0; | |
271 | virtual int GetAlignment() const = 0; | |
99d471a5 | 272 | |
1e510b1e RR |
273 | // in-place editing |
274 | virtual bool HasEditorCtrl() | |
275 | { return false; } | |
96c2a0dd VZ |
276 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
277 | wxRect WXUNUSED(labelRect), | |
278 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 279 | { return NULL; } |
96c2a0dd VZ |
280 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
281 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
282 | { return false; } |
283 | ||
e0062c04 | 284 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
285 | virtual void CancelEditing(); |
286 | virtual bool FinishEditing(); | |
287 | ||
288 | wxControl *GetEditorCtrl() { return m_editorCtrl; } | |
289 | ||
a7f61f76 | 290 | protected: |
6842a71a RR |
291 | wxString m_variantType; |
292 | wxDataViewColumn *m_owner; | |
1e510b1e | 293 | wxControl *m_editorCtrl; |
e0062c04 | 294 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 295 | |
9861f022 RR |
296 | // internal utility: |
297 | const wxDataViewCtrl* GetView() const; | |
298 | ||
6842a71a | 299 | protected: |
baa9ebc4 | 300 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
301 | }; |
302 | ||
f554a14b | 303 | // --------------------------------------------------------- |
6842a71a | 304 | // wxDataViewColumnBase |
f554a14b | 305 | // --------------------------------------------------------- |
6842a71a | 306 | |
fa28826d RR |
307 | enum wxDataViewColumnFlags |
308 | { | |
309 | wxDATAVIEW_COL_RESIZABLE = 1, | |
310 | wxDATAVIEW_COL_SORTABLE = 2, | |
311 | wxDATAVIEW_COL_HIDDEN = 4 | |
312 | }; | |
313 | ||
f460c29d | 314 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
315 | { |
316 | public: | |
87f0efe2 RR |
317 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
318 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
319 | wxAlignment align = wxALIGN_CENTER, | |
320 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
321 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
322 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
323 | wxAlignment align = wxALIGN_CENTER, | |
324 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 325 | virtual ~wxDataViewColumnBase(); |
fa28826d | 326 | |
9861f022 | 327 | // setters: |
07b6378f | 328 | |
9861f022 | 329 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 330 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 331 | virtual void SetSortable( bool sortable ) = 0; |
9861f022 RR |
332 | virtual void SetResizeable( bool resizeable ) = 0; |
333 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 334 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 RR |
335 | virtual void SetFlags( int flags ); |
336 | virtual void SetOwner( wxDataViewCtrl *owner ) | |
337 | { m_owner = owner; } | |
338 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
339 | { m_bitmap=bitmap; } | |
07a84e7b | 340 | |
9861f022 RR |
341 | virtual void SetMinWidth( int minWidth ) = 0; |
342 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 343 | |
f554a14b | 344 | |
9861f022 | 345 | // getters: |
07b6378f | 346 | |
9861f022 RR |
347 | virtual wxString GetTitle() const = 0; |
348 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 349 | virtual int GetWidth() const = 0; |
9861f022 | 350 | virtual int GetMinWidth() const = 0; |
07b6378f | 351 | |
9861f022 RR |
352 | virtual int GetFlags() const; |
353 | ||
354 | virtual bool IsSortable() const = 0; | |
355 | virtual bool IsResizeable() const = 0; | |
356 | virtual bool IsHidden() const = 0; | |
357 | virtual bool IsSortOrderAscending() const = 0; | |
358 | ||
359 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
360 | unsigned int GetModelColumn() const { return m_model_column; } | |
361 | ||
362 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
363 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
364 | ||
365 | protected: | |
baa9ebc4 | 366 | wxDataViewRenderer *m_renderer; |
6842a71a | 367 | int m_model_column; |
07a84e7b | 368 | wxBitmap m_bitmap; |
6842a71a | 369 | wxDataViewCtrl *m_owner; |
fa28826d RR |
370 | |
371 | protected: | |
372 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
373 | }; | |
374 | ||
f554a14b | 375 | // --------------------------------------------------------- |
239eaa41 | 376 | // wxDataViewCtrlBase |
f554a14b | 377 | // --------------------------------------------------------- |
239eaa41 | 378 | |
c21f7aa1 | 379 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
380 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
381 | ||
382 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
383 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
384 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 385 | |
f460c29d | 386 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
387 | { |
388 | public: | |
389 | wxDataViewCtrlBase(); | |
d3c7fc99 | 390 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 391 | |
e0062c04 RR |
392 | virtual bool AssociateModel( wxDataViewModel *model ); |
393 | wxDataViewModel* GetModel(); | |
f554a14b | 394 | |
07a84e7b | 395 | // short cuts |
1286b7ba | 396 | bool AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
397 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
398 | wxAlignment align = wxALIGN_CENTER, | |
399 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 400 | bool AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
401 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
402 | wxAlignment align = wxALIGN_CENTER, | |
403 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 404 | bool AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
405 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
406 | wxAlignment align = wxALIGN_CENTER, | |
407 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 408 | bool AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
409 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
410 | wxAlignment align = wxALIGN_CENTER, | |
411 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 412 | bool AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
413 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
414 | wxAlignment align = wxALIGN_CENTER, | |
415 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 416 | bool AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
417 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
418 | wxAlignment align = wxALIGN_CENTER, | |
419 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 420 | bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
421 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
422 | wxAlignment align = wxALIGN_CENTER, | |
423 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 424 | bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
425 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
426 | wxAlignment align = wxALIGN_CENTER, | |
427 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 428 | bool AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
429 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
430 | wxAlignment align = wxALIGN_CENTER, | |
431 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 432 | bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
433 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
434 | wxAlignment align = wxALIGN_CENTER, | |
435 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
07a84e7b | 436 | |
f554a14b | 437 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 RR |
438 | |
439 | virtual unsigned int GetColumnCount() const; | |
440 | ||
0a71f9e9 | 441 | virtual bool DeleteColumn( unsigned int pos ); |
fa28826d | 442 | virtual bool ClearColumns(); |
0a71f9e9 | 443 | virtual wxDataViewColumn* GetColumn( unsigned int pos ); |
f554a14b | 444 | |
3b6280be RR |
445 | void SetExpanderColumn( unsigned int col ) |
446 | { m_expander_column = col ; DoSetExpanderColumn(); } | |
447 | unsigned int GetExpanderColumn() const | |
448 | { return m_expander_column; } | |
449 | ||
450 | void SetIndent( int indent ) | |
451 | { m_indent = indent ; DoSetIndent(); } | |
452 | int GetIndent() const | |
453 | { return m_indent; } | |
454 | ||
e0062c04 | 455 | // TODO selection code |
1e08ad10 | 456 | virtual wxDataViewItem GetSelection() = 0; |
6ff7eee7 | 457 | |
3b6280be RR |
458 | protected: |
459 | virtual void DoSetExpanderColumn() = 0 ; | |
460 | virtual void DoSetIndent() = 0; | |
461 | ||
239eaa41 | 462 | private: |
e0062c04 | 463 | wxDataViewModel *m_model; |
fa28826d | 464 | wxList m_cols; |
e0062c04 | 465 | wxDataViewEventModelNotifier *m_eventNotifier; |
3b6280be RR |
466 | unsigned int m_expander_column; |
467 | int m_indent ; | |
468 | ||
239eaa41 | 469 | protected: |
260b9be7 | 470 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 471 | }; |
bcd846ea | 472 | |
eb7f97f8 RR |
473 | // ---------------------------------------------------------------------------- |
474 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
475 | // ---------------------------------------------------------------------------- | |
476 | ||
2f799ae8 | 477 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
478 | { |
479 | public: | |
480 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
481 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 482 | m_item(0), |
eb7f97f8 | 483 | m_col(-1), |
eb7f97f8 RR |
484 | m_model(NULL), |
485 | m_value(wxNullVariant), | |
31fb32e1 | 486 | m_column(NULL) |
eb7f97f8 RR |
487 | { } |
488 | ||
489 | wxDataViewEvent(const wxDataViewEvent& event) | |
490 | : wxNotifyEvent(event), | |
e0062c04 | 491 | m_item(event.m_item), |
eb7f97f8 | 492 | m_col(event.m_col), |
eb7f97f8 RR |
493 | m_model(event.m_model), |
494 | m_value(event.m_value), | |
31fb32e1 | 495 | m_column(event.m_column) |
eb7f97f8 RR |
496 | { } |
497 | ||
e0062c04 RR |
498 | wxDataViewItem GetItem() const { return m_item; } |
499 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
500 | ||
eb7f97f8 RR |
501 | int GetColumn() const { return m_col; } |
502 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 503 | |
eb7f97f8 RR |
504 | wxDataViewModel* GetModel() const { return m_model; } |
505 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 506 | |
eb7f97f8 RR |
507 | const wxVariant &GetValue() const { return m_value; } |
508 | void SetValue( const wxVariant &value ) { m_value = value; } | |
509 | ||
31fb32e1 RR |
510 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
511 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 512 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
31fb32e1 | 513 | |
eb7f97f8 RR |
514 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
515 | ||
516 | protected: | |
e0062c04 | 517 | wxDataViewItem m_item; |
eb7f97f8 | 518 | int m_col; |
eb7f97f8 RR |
519 | wxDataViewModel *m_model; |
520 | wxVariant m_value; | |
31fb32e1 | 521 | wxDataViewColumn *m_column; |
eb7f97f8 RR |
522 | |
523 | private: | |
524 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
525 | }; | |
526 | ||
527 | BEGIN_DECLARE_EVENT_TYPES() | |
e0062c04 RR |
528 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED, -1) |
529 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) | |
e07c1146 PC |
530 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) |
531 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
c0a66d92 | 532 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) |
1821abd1 | 533 | // notifications from the model to the control |
e0062c04 RR |
534 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, -1) |
535 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, -1) | |
536 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, -1) | |
1821abd1 | 537 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1) |
1821abd1 | 538 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1) |
eb7f97f8 RR |
539 | END_DECLARE_EVENT_TYPES() |
540 | ||
541 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
542 | ||
543 | #define wxDataViewEventHandler(func) \ | |
544 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
545 | ||
546 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
547 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
548 | ||
e0062c04 RR |
549 | #define EVT_DATAVIEW_ITEM_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_SELECTED, id, fn) |
550 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) | |
31fb32e1 RR |
551 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
552 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 553 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
eb7f97f8 | 554 | |
e0062c04 RR |
555 | #define EVT_DATAVIEW_MODEL_ITEM_ADDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_APPENDED, id, fn) |
556 | #define EVT_DATAVIEW_MODEL_ITEM_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_DELETED, id, fn) | |
557 | #define EVT_DATAVIEW_MODEL_ITEM_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_CHANGED, id, fn) | |
1821abd1 | 558 | #define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn) |
1821abd1 RR |
559 | #define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn) |
560 | ||
eb7f97f8 | 561 | |
4ed7af08 RR |
562 | #if defined(wxUSE_GENERICDATAVIEWCTRL) |
563 | #include "wx/generic/dataview.h" | |
564 | #elif defined(__WXGTK20__) | |
bcd846ea RR |
565 | #include "wx/gtk/dataview.h" |
566 | #elif defined(__WXMAC__) | |
c0a66d92 | 567 | #include "wx/mac/dataview.h" |
bcd846ea RR |
568 | #else |
569 | #include "wx/generic/dataview.h" | |
570 | #endif | |
571 | ||
572 | #endif // wxUSE_DATAVIEWCTRL | |
573 | ||
574 | #endif | |
575 | // _WX_DATAVIEW_H_BASE_ |