]>
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 | |
30715fa1 | 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 | |
f460c29d RD |
41 | class WXDLLIMPEXP_ADV wxDataViewModel; |
42 | class WXDLLIMPEXP_ADV wxDataViewListModel; | |
43 | class WXDLLIMPEXP_ADV wxDataViewCtrl; | |
44 | class WXDLLIMPEXP_ADV wxDataViewColumn; | |
baa9ebc4 | 45 | class WXDLLIMPEXP_ADV wxDataViewRenderer; |
1821abd1 | 46 | class wxDataViewEventListModelNotifier; |
fa28826d | 47 | |
f460c29d | 48 | extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; |
bcd846ea | 49 | |
87f0efe2 RR |
50 | // the default width of new (text) columns: |
51 | #define wxDVC_DEFAULT_WIDTH 80 | |
52 | ||
53 | // the default width of new toggle columns: | |
54 | #define wxDVC_TOGGLE_DEFAULT_WIDTH 30 | |
55 | ||
9861f022 RR |
56 | // the default minimal width of the columns: |
57 | #define wxDVC_DEFAULT_MINWIDTH 30 | |
58 | ||
59 | // the default alignment of wxDataViewRenderers: | |
60 | #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP) | |
61 | ||
87f0efe2 | 62 | |
f554a14b | 63 | // --------------------------------------------------------- |
239eaa41 | 64 | // wxDataViewModel |
f554a14b | 65 | // --------------------------------------------------------- |
239eaa41 | 66 | |
87f0efe2 | 67 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData |
239eaa41 RR |
68 | { |
69 | public: | |
70 | wxDataViewModel() { } | |
f554a14b | 71 | |
239eaa41 | 72 | protected: |
87f0efe2 RR |
73 | // the user should not delete this class directly: he should use DecRef() instead! |
74 | virtual ~wxDataViewModel() { } | |
239eaa41 RR |
75 | }; |
76 | ||
f554a14b | 77 | // --------------------------------------------------------- |
239eaa41 | 78 | // wxDataViewListModelNotifier |
f554a14b | 79 | // --------------------------------------------------------- |
239eaa41 | 80 | |
f460c29d | 81 | class WXDLLIMPEXP_ADV wxDataViewListModelNotifier: public wxObject |
239eaa41 RR |
82 | { |
83 | public: | |
84 | wxDataViewListModelNotifier() { } | |
f7ed8c89 | 85 | virtual ~wxDataViewListModelNotifier() { m_owner = NULL; } |
f554a14b | 86 | |
239eaa41 RR |
87 | virtual bool RowAppended() = 0; |
88 | virtual bool RowPrepended() = 0; | |
0a71f9e9 RR |
89 | virtual bool RowInserted( unsigned int before ) = 0; |
90 | virtual bool RowDeleted( unsigned int row ) = 0; | |
91 | virtual bool RowChanged( unsigned int row ) = 0; | |
92 | virtual bool ValueChanged( unsigned int col, unsigned int row ) = 0; | |
93 | virtual bool RowsReordered( unsigned int *new_order ) = 0; | |
239eaa41 | 94 | virtual bool Cleared() = 0; |
f554a14b | 95 | |
8f850e28 RR |
96 | void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; } |
97 | wxDataViewListModel *GetOwner() { return m_owner; } | |
f554a14b | 98 | |
8f850e28 RR |
99 | private: |
100 | wxDataViewListModel *m_owner; | |
64ffb888 | 101 | }; |
239eaa41 | 102 | |
f554a14b | 103 | // --------------------------------------------------------- |
239eaa41 | 104 | // wxDataViewListModel |
f554a14b | 105 | // --------------------------------------------------------- |
239eaa41 | 106 | |
f460c29d | 107 | class WXDLLIMPEXP_ADV wxDataViewListModel: public wxDataViewModel |
239eaa41 RR |
108 | { |
109 | public: | |
110 | wxDataViewListModel(); | |
239eaa41 | 111 | |
9861f022 RR |
112 | virtual unsigned int GetRowCount() const = 0; |
113 | virtual unsigned int GetColumnCount() const = 0; | |
87f0efe2 | 114 | |
a7f61f76 | 115 | // return type as reported by wxVariant |
9861f022 | 116 | virtual wxString GetColumnType( unsigned int col ) const = 0; |
87f0efe2 | 117 | |
a7f61f76 | 118 | // get value into a wxVariant |
9861f022 | 119 | virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const = 0; |
87f0efe2 | 120 | |
a7f61f76 | 121 | // set value, call ValueChanged() afterwards! |
2fa73716 | 122 | virtual bool SetValue( const wxVariant &variant, unsigned int col, unsigned int row ) = 0; |
239eaa41 | 123 | |
b9b8b59c | 124 | // override to set cell attributes |
b01204c9 VZ |
125 | virtual void GetAttr( wxListItemAttr& WXUNUSED(attr), |
126 | unsigned int WXUNUSED(col), | |
127 | unsigned int WXUNUSED(row) ) | |
128 | { | |
129 | } | |
b9b8b59c | 130 | |
239eaa41 | 131 | // delegated notifiers |
8981608c RR |
132 | virtual bool RowAppended(); |
133 | virtual bool RowPrepended(); | |
0a71f9e9 RR |
134 | virtual bool RowInserted( unsigned int before ); |
135 | virtual bool RowDeleted( unsigned int row ); | |
136 | virtual bool RowChanged( unsigned int row ); | |
137 | virtual bool ValueChanged( unsigned int col, unsigned int row ); | |
138 | virtual bool RowsReordered( unsigned int *new_order ); | |
8981608c | 139 | virtual bool Cleared(); |
b5d777c7 | 140 | |
63415a42 RR |
141 | void AddNotifier( wxDataViewListModelNotifier *notifier ); |
142 | void RemoveNotifier( wxDataViewListModelNotifier *notifier ); | |
143 | ||
87f0efe2 RR |
144 | protected: |
145 | // the user should not delete this class directly: he should use DecRef() instead! | |
146 | virtual ~wxDataViewListModel(); | |
147 | ||
1821abd1 | 148 | wxList m_notifiers; |
239eaa41 RR |
149 | }; |
150 | ||
f554a14b | 151 | // --------------------------------------------------------- |
8981608c | 152 | // wxDataViewSortedListModel |
f554a14b | 153 | // --------------------------------------------------------- |
8981608c RR |
154 | |
155 | typedef int (wxCALLBACK *wxDataViewListModelCompare) | |
0a71f9e9 | 156 | (unsigned int row1, unsigned int row2, unsigned int col, wxDataViewListModel* model ); |
8981608c | 157 | |
9861f022 RR |
158 | WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, |
159 | wxDataViewSortedIndexArray, WXDLLIMPEXP_ADV); | |
8981608c | 160 | |
f460c29d | 161 | class WXDLLIMPEXP_ADV wxDataViewSortedListModel: public wxDataViewListModel |
8981608c | 162 | { |
87f0efe2 RR |
163 | friend class wxDataViewSortedListModelNotifier; |
164 | ||
8981608c RR |
165 | public: |
166 | wxDataViewSortedListModel( wxDataViewListModel *child ); | |
167 | virtual ~wxDataViewSortedListModel(); | |
168 | ||
31fb32e1 | 169 | void SetAscending( bool ascending ) { m_ascending = ascending; } |
9861f022 RR |
170 | bool IsAscending() const { return m_ascending; } |
171 | ||
172 | virtual unsigned int GetRowCount() const; | |
173 | virtual unsigned int GetColumnCount() const; | |
31fb32e1 | 174 | |
8981608c | 175 | // return type as reported by wxVariant |
9861f022 RR |
176 | virtual wxString GetColumnType( unsigned int col ) const; |
177 | ||
8981608c | 178 | // get value into a wxVariant |
9861f022 RR |
179 | virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const; |
180 | ||
8981608c | 181 | // set value, call ValueChanged() afterwards! |
2fa73716 | 182 | virtual bool SetValue( const wxVariant &variant, unsigned int col, unsigned int row ); |
8981608c | 183 | |
4627af27 | 184 | // called from user |
8981608c RR |
185 | virtual bool RowAppended(); |
186 | virtual bool RowPrepended(); | |
0a71f9e9 RR |
187 | virtual bool RowInserted( unsigned int before ); |
188 | virtual bool RowDeleted( unsigned int row ); | |
189 | virtual bool RowChanged( unsigned int row ); | |
190 | virtual bool ValueChanged( unsigned int col, unsigned int row ); | |
191 | virtual bool RowsReordered( unsigned int *new_order ); | |
8981608c RR |
192 | virtual bool Cleared(); |
193 | ||
4627af27 RR |
194 | // called if child's notifiers are called |
195 | bool ChildRowAppended(); | |
196 | bool ChildRowPrepended(); | |
0a71f9e9 RR |
197 | bool ChildRowInserted( unsigned int before ); |
198 | bool ChildRowDeleted( unsigned int row ); | |
199 | bool ChildRowChanged( unsigned int row ); | |
200 | bool ChildValueChanged( unsigned int col, unsigned int row ); | |
201 | bool ChildRowsReordered( unsigned int *new_order ); | |
4627af27 | 202 | bool ChildCleared(); |
4eccd3a1 | 203 | |
8f850e28 | 204 | virtual void Resort(); |
f7ed8c89 RR |
205 | |
206 | void DetachChild(); | |
8f850e28 | 207 | |
8981608c | 208 | private: |
31fb32e1 | 209 | bool m_ascending; |
8981608c RR |
210 | wxDataViewListModel *m_child; |
211 | wxDataViewSortedIndexArray m_array; | |
4eccd3a1 | 212 | wxDataViewListModelNotifier *m_notifierOnChild; |
31fb32e1 RR |
213 | |
214 | void InitStatics(); // BAD | |
8981608c RR |
215 | }; |
216 | ||
1e510b1e RR |
217 | //----------------------------------------------------------------------------- |
218 | // wxDataViewEditorCtrlEvtHandler | |
219 | //----------------------------------------------------------------------------- | |
220 | ||
221 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
222 | { | |
223 | public: | |
224 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
225 | ||
226 | void AcceptChangesAndFinish(); | |
30715fa1 | 227 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
228 | |
229 | protected: | |
230 | void OnChar( wxKeyEvent &event ); | |
231 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 232 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
233 | |
234 | private: | |
235 | wxDataViewRenderer *m_owner; | |
236 | wxControl *m_editorCtrl; | |
237 | bool m_finished; | |
30715fa1 | 238 | bool m_focusOnIdle; |
1e510b1e RR |
239 | |
240 | private: | |
241 | DECLARE_EVENT_TABLE() | |
242 | }; | |
243 | ||
f554a14b | 244 | // --------------------------------------------------------- |
baa9ebc4 | 245 | // wxDataViewRendererBase |
f554a14b | 246 | // --------------------------------------------------------- |
fa28826d | 247 | |
6842a71a | 248 | enum wxDataViewCellMode |
fa28826d | 249 | { |
6842a71a RR |
250 | wxDATAVIEW_CELL_INERT, |
251 | wxDATAVIEW_CELL_ACTIVATABLE, | |
252 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
253 | }; |
254 | ||
6842a71a RR |
255 | enum wxDataViewCellRenderState |
256 | { | |
257 | wxDATAVIEW_CELL_SELECTED = 1, | |
258 | wxDATAVIEW_CELL_PRELIT = 2, | |
259 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
260 | wxDATAVIEW_CELL_FOCUSED = 8 | |
261 | }; | |
262 | ||
baa9ebc4 | 263 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
264 | { |
265 | public: | |
9861f022 RR |
266 | wxDataViewRendererBase( const wxString &varianttype, |
267 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
268 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 269 | |
9861f022 RR |
270 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
271 | { return true; } | |
f554a14b | 272 | |
6842a71a RR |
273 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
274 | wxDataViewColumn* GetOwner() { return m_owner; } | |
f554a14b | 275 | |
9861f022 RR |
276 | // renderer properties: |
277 | ||
278 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
279 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
280 | ||
281 | wxString GetVariantType() const { return m_variantType; } | |
282 | ||
283 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
284 | virtual wxDataViewCellMode GetMode() const = 0; | |
285 | ||
286 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
287 | // rather an "int"; that's because for rendering cells it's allowed | |
288 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
289 | virtual void SetAlignment( int align ) = 0; | |
290 | virtual int GetAlignment() const = 0; | |
99d471a5 | 291 | |
1e510b1e RR |
292 | // in-place editing |
293 | virtual bool HasEditorCtrl() | |
294 | { return false; } | |
96c2a0dd VZ |
295 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
296 | wxRect WXUNUSED(labelRect), | |
297 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 298 | { return NULL; } |
96c2a0dd VZ |
299 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
300 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
301 | { return false; } |
302 | ||
303 | virtual bool StartEditing( unsigned int row, wxRect labelRect ); | |
304 | virtual void CancelEditing(); | |
305 | virtual bool FinishEditing(); | |
306 | ||
307 | wxControl *GetEditorCtrl() { return m_editorCtrl; } | |
308 | ||
a7f61f76 | 309 | protected: |
6842a71a RR |
310 | wxString m_variantType; |
311 | wxDataViewColumn *m_owner; | |
1e510b1e RR |
312 | wxControl *m_editorCtrl; |
313 | unsigned int m_row; // for m_editorCtrl | |
6842a71a | 314 | |
9861f022 RR |
315 | // internal utility: |
316 | const wxDataViewCtrl* GetView() const; | |
317 | ||
6842a71a | 318 | protected: |
baa9ebc4 | 319 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
320 | }; |
321 | ||
f554a14b | 322 | // --------------------------------------------------------- |
6842a71a | 323 | // wxDataViewColumnBase |
f554a14b | 324 | // --------------------------------------------------------- |
6842a71a | 325 | |
fa28826d RR |
326 | enum wxDataViewColumnFlags |
327 | { | |
328 | wxDATAVIEW_COL_RESIZABLE = 1, | |
329 | wxDATAVIEW_COL_SORTABLE = 2, | |
330 | wxDATAVIEW_COL_HIDDEN = 4 | |
331 | }; | |
332 | ||
f460c29d | 333 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
334 | { |
335 | public: | |
87f0efe2 RR |
336 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
337 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
338 | wxAlignment align = wxALIGN_CENTER, | |
339 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
340 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
341 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
342 | wxAlignment align = wxALIGN_CENTER, | |
343 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 344 | virtual ~wxDataViewColumnBase(); |
fa28826d | 345 | |
9861f022 | 346 | // setters: |
07b6378f | 347 | |
9861f022 | 348 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 349 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 350 | virtual void SetSortable( bool sortable ) = 0; |
9861f022 RR |
351 | virtual void SetResizeable( bool resizeable ) = 0; |
352 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 353 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 RR |
354 | virtual void SetFlags( int flags ); |
355 | virtual void SetOwner( wxDataViewCtrl *owner ) | |
356 | { m_owner = owner; } | |
357 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
358 | { m_bitmap=bitmap; } | |
07a84e7b | 359 | |
9861f022 RR |
360 | virtual void SetMinWidth( int minWidth ) = 0; |
361 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 362 | |
f554a14b | 363 | |
9861f022 | 364 | // getters: |
07b6378f | 365 | |
9861f022 RR |
366 | virtual wxString GetTitle() const = 0; |
367 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 368 | virtual int GetWidth() const = 0; |
9861f022 | 369 | virtual int GetMinWidth() const = 0; |
07b6378f | 370 | |
9861f022 RR |
371 | virtual int GetFlags() const; |
372 | ||
373 | virtual bool IsSortable() const = 0; | |
374 | virtual bool IsResizeable() const = 0; | |
375 | virtual bool IsHidden() const = 0; | |
376 | virtual bool IsSortOrderAscending() const = 0; | |
377 | ||
378 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
379 | unsigned int GetModelColumn() const { return m_model_column; } | |
380 | ||
381 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
382 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
383 | ||
384 | protected: | |
baa9ebc4 | 385 | wxDataViewRenderer *m_renderer; |
6842a71a | 386 | int m_model_column; |
07a84e7b | 387 | wxBitmap m_bitmap; |
6842a71a | 388 | wxDataViewCtrl *m_owner; |
fa28826d RR |
389 | |
390 | protected: | |
391 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
392 | }; | |
393 | ||
f554a14b | 394 | // --------------------------------------------------------- |
239eaa41 | 395 | // wxDataViewCtrlBase |
f554a14b | 396 | // --------------------------------------------------------- |
239eaa41 | 397 | |
c21f7aa1 | 398 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
399 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
400 | ||
401 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
402 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
403 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 404 | |
f460c29d | 405 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
406 | { |
407 | public: | |
408 | wxDataViewCtrlBase(); | |
d3c7fc99 | 409 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 410 | |
6e2e590f RR |
411 | virtual bool AssociateModel( wxDataViewListModel *model ); |
412 | wxDataViewListModel* GetModel(); | |
f554a14b | 413 | |
07a84e7b | 414 | // short cuts |
1286b7ba | 415 | bool AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
416 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
417 | wxAlignment align = wxALIGN_CENTER, | |
418 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 419 | bool AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
420 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
421 | wxAlignment align = wxALIGN_CENTER, | |
422 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 423 | bool AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
424 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
425 | wxAlignment align = wxALIGN_CENTER, | |
426 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 427 | bool AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
428 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
429 | wxAlignment align = wxALIGN_CENTER, | |
430 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 431 | bool AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
432 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
433 | wxAlignment align = wxALIGN_CENTER, | |
434 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 435 | bool AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
436 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
437 | wxAlignment align = wxALIGN_CENTER, | |
438 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 439 | bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
440 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
441 | wxAlignment align = wxALIGN_CENTER, | |
442 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 443 | bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
444 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
445 | wxAlignment align = wxALIGN_CENTER, | |
446 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 447 | bool AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
448 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
449 | wxAlignment align = wxALIGN_CENTER, | |
450 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
1286b7ba | 451 | bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
452 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
453 | wxAlignment align = wxALIGN_CENTER, | |
454 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
07a84e7b | 455 | |
f554a14b | 456 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 RR |
457 | |
458 | virtual unsigned int GetColumnCount() const; | |
459 | ||
0a71f9e9 | 460 | virtual bool DeleteColumn( unsigned int pos ); |
fa28826d | 461 | virtual bool ClearColumns(); |
0a71f9e9 | 462 | virtual wxDataViewColumn* GetColumn( unsigned int pos ); |
f554a14b | 463 | |
6ff7eee7 RR |
464 | virtual void SetSelection( int row ) = 0; // -1 for unselect |
465 | inline void ClearSelection() { SetSelection( -1 ); } | |
fc211fe5 | 466 | virtual void Unselect( unsigned int row ) = 0; |
6ff7eee7 RR |
467 | virtual void SetSelectionRange( unsigned int from, unsigned int to ) = 0; |
468 | virtual void SetSelections( const wxArrayInt& aSelections) = 0; | |
469 | ||
470 | virtual bool IsSelected( unsigned int row ) const = 0; | |
471 | virtual int GetSelection() const = 0; | |
472 | virtual int GetSelections(wxArrayInt& aSelections) const = 0; | |
473 | ||
239eaa41 | 474 | private: |
6e2e590f | 475 | wxDataViewListModel *m_model; |
fa28826d | 476 | wxList m_cols; |
1821abd1 | 477 | wxDataViewEventListModelNotifier *m_eventNotifier; |
30715fa1 | 478 | |
239eaa41 | 479 | protected: |
260b9be7 | 480 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 481 | }; |
bcd846ea | 482 | |
eb7f97f8 RR |
483 | |
484 | // ---------------------------------------------------------------------------- | |
485 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
486 | // ---------------------------------------------------------------------------- | |
487 | ||
2f799ae8 | 488 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
489 | { |
490 | public: | |
491 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
492 | : wxNotifyEvent(commandType, winid), | |
493 | m_col(-1), | |
494 | m_row(-1), | |
495 | m_model(NULL), | |
496 | m_value(wxNullVariant), | |
31fb32e1 RR |
497 | m_editCancelled(false), |
498 | m_column(NULL) | |
eb7f97f8 RR |
499 | { } |
500 | ||
501 | wxDataViewEvent(const wxDataViewEvent& event) | |
502 | : wxNotifyEvent(event), | |
503 | m_col(event.m_col), | |
504 | m_row(event.m_col), | |
505 | m_model(event.m_model), | |
506 | m_value(event.m_value), | |
31fb32e1 RR |
507 | m_editCancelled(event.m_editCancelled), |
508 | m_column(event.m_column) | |
eb7f97f8 RR |
509 | { } |
510 | ||
511 | int GetColumn() const { return m_col; } | |
512 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 513 | |
eb7f97f8 RR |
514 | int GetRow() const { return m_row; } |
515 | void SetRow( int row ) { m_row = row; } | |
9861f022 | 516 | |
eb7f97f8 RR |
517 | wxDataViewModel* GetModel() const { return m_model; } |
518 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 519 | |
eb7f97f8 RR |
520 | const wxVariant &GetValue() const { return m_value; } |
521 | void SetValue( const wxVariant &value ) { m_value = value; } | |
522 | ||
31fb32e1 RR |
523 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
524 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 525 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
31fb32e1 | 526 | |
eb7f97f8 RR |
527 | // was label editing canceled? (for wxEVT_COMMAND_DATVIEW_END_LABEL_EDIT only) |
528 | bool IsEditCancelled() const { return m_editCancelled; } | |
529 | void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } | |
530 | ||
531 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } | |
532 | ||
533 | protected: | |
534 | int m_col; | |
535 | int m_row; | |
536 | wxDataViewModel *m_model; | |
537 | wxVariant m_value; | |
538 | bool m_editCancelled; | |
31fb32e1 | 539 | wxDataViewColumn *m_column; |
eb7f97f8 RR |
540 | |
541 | private: | |
542 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
543 | }; | |
544 | ||
545 | BEGIN_DECLARE_EVENT_TYPES() | |
e07c1146 PC |
546 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, -1) |
547 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, -1) | |
548 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) | |
549 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
c0a66d92 | 550 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) |
1821abd1 RR |
551 | // notifications from the model to the control |
552 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_APPENDED, -1) | |
553 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_PREPENDED, -1) | |
554 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_INSERTED, -1) | |
555 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_DELETED, -1) | |
556 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_CHANGED, -1) | |
557 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1) | |
558 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROWS_REORDERED, -1) | |
559 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1) | |
eb7f97f8 RR |
560 | END_DECLARE_EVENT_TYPES() |
561 | ||
562 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
563 | ||
564 | #define wxDataViewEventHandler(func) \ | |
565 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
566 | ||
567 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
568 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
569 | ||
570 | #define EVT_DATAVIEW_ROW_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_SELECTED, id, fn) | |
f828871d | 571 | #define EVT_DATAVIEW_ROW_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_ACTIVATED, id, fn) |
31fb32e1 RR |
572 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
573 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 574 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
eb7f97f8 | 575 | |
1821abd1 RR |
576 | #define EVT_DATAVIEW_MODEL_ROW_APPENDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_APPENDED, id, fn) |
577 | #define EVT_DATAVIEW_MODEL_ROW_PREPENDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_PREPENDED, id, fn) | |
578 | #define EVT_DATAVIEW_MODEL_ROW_INSERTED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_INSERTED, id, fn) | |
579 | #define EVT_DATAVIEW_MODEL_ROW_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_DELETED, id, fn) | |
580 | #define EVT_DATAVIEW_MODEL_ROW_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_CHANGED, id, fn) | |
581 | #define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn) | |
582 | #define EVT_DATAVIEW_MODEL_ROWS_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROWS_REORDERED, id, fn) | |
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_ |