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