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