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