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