1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
5 // Modified by: Bo Yang
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
17 #if wxUSE_DATAVIEWCTRL
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"
27 #if defined(__WXGTK20__)
29 // #define wxUSE_GENERICDATAVIEWCTRL 1
30 #elif defined(__WXMAC__)
32 #define wxUSE_GENERICDATAVIEWCTRL 1
35 // ----------------------------------------------------------------------------
36 // wxDataViewCtrl flags
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
40 // wxDataViewCtrl globals
41 // ----------------------------------------------------------------------------
43 class WXDLLIMPEXP_FWD_ADV wxDataViewItem
;
44 class WXDLLIMPEXP_FWD_ADV wxDataViewModel
;
45 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl
;
46 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn
;
47 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer
;
48 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier
;
50 extern WXDLLIMPEXP_DATA_ADV(const wxChar
) wxDataViewCtrlNameStr
[];
52 // the default width of new (text) columns:
53 #define wxDVC_DEFAULT_WIDTH 80
55 // the default width of new toggle columns:
56 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
58 // the default minimal width of the columns:
59 #define wxDVC_DEFAULT_MINWIDTH 30
61 // the default alignment of wxDataViewRenderers:
62 #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP)
65 // ---------------------------------------------------------
67 // ---------------------------------------------------------
69 class WXDLLIMPEXP_ADV wxDataViewItem
72 wxDataViewItem( void* id
= NULL
)
74 wxDataViewItem( const wxDataViewItem
&item
)
76 bool IsOk() const { return m_id
!= NULL
; }
77 void* GetID() const { return m_id
; }
78 operator const void* () const { return m_id
; }
84 bool operator == (const wxDataViewItem
&left
, const wxDataViewItem
&right
);
86 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
88 // ---------------------------------------------------------
89 // wxDataViewModelNotifier
90 // ---------------------------------------------------------
92 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
95 wxDataViewModelNotifier() { }
96 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
98 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
99 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
100 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
101 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
102 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
103 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
104 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
105 virtual bool Cleared() = 0;
107 virtual void Resort() = 0;
109 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
110 wxDataViewModel
*GetOwner() { return m_owner
; }
113 wxDataViewModel
*m_owner
;
117 // ---------------------------------------------------------
119 // ---------------------------------------------------------
121 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
122 class WXDLLIMPEXP_ADV
);
124 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxObjectRefData
129 virtual unsigned int GetColumnCount() const = 0;
131 // return type as reported by wxVariant
132 virtual wxString
GetColumnType( unsigned int col
) const = 0;
134 // get value into a wxVariant
135 virtual void GetValue( wxVariant
&variant
,
136 const wxDataViewItem
&item
, unsigned int col
) const = 0;
138 // set value, call ValueChanged() afterwards!
139 virtual bool SetValue( const wxVariant
&variant
,
140 const wxDataViewItem
&item
, unsigned int col
) = 0;
143 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
144 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
145 // Is the container just a header or an item with all columns
146 virtual bool HasContainerColumns( const wxDataViewItem
&item
) const { return false; }
147 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
149 // delegated notifiers
150 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
151 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
152 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
153 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
154 virtual bool ItemChanged( const wxDataViewItem
&item
);
155 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
156 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
157 virtual bool Cleared();
160 virtual void Resort();
162 void AddNotifier( wxDataViewModelNotifier
*notifier
);
163 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
165 // default compare function
166 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
167 unsigned int column
, bool ascending
);
168 virtual bool HasDefaultCompare() const { return false; }
171 // the user should not delete this class directly: he should use DecRef() instead!
172 virtual ~wxDataViewModel() { }
174 wxDataViewModelNotifiers m_notifiers
;
177 // ---------------------------------------------------------
178 // wxDataViewIndexListModel
179 // ---------------------------------------------------------
181 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
184 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
185 ~wxDataViewIndexListModel();
187 virtual unsigned int GetRowCount() = 0;
189 virtual void GetValue( wxVariant
&variant
,
190 unsigned int row
, unsigned int col
) const = 0;
192 virtual bool SetValue( const wxVariant
&variant
,
193 unsigned int row
, unsigned int col
) = 0;
196 void RowInserted( unsigned int before
);
198 void RowDeleted( unsigned int row
);
199 void RowChanged( unsigned int row
);
200 void RowValueChanged( unsigned int row
, unsigned int col
);
202 // convert to/from row/wxDataViewItem
204 unsigned int GetRow( const wxDataViewItem
&item
) const;
205 wxDataViewItem
GetItem( unsigned int row
) const;
207 // compare based on index
209 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
210 unsigned int column
, bool ascending
);
211 virtual bool HasDefaultCompare() const { return true; }
213 // implement base methods
215 virtual void GetValue( wxVariant
&variant
,
216 const wxDataViewItem
&item
, unsigned int col
) const;
217 virtual bool SetValue( const wxVariant
&variant
,
218 const wxDataViewItem
&item
, unsigned int col
);
219 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
220 virtual bool IsContainer( const wxDataViewItem
&item
) const;
221 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
224 wxDataViewItemArray m_hash
;
225 unsigned int m_lastIndex
;
228 //-----------------------------------------------------------------------------
229 // wxDataViewTreeStore
230 //-----------------------------------------------------------------------------
233 class wxDataViewTreeStore
: public wxDataViewModel
236 wxDataViewTreeStore();
237 ~wxDataViewTreeStore();
239 void AddColumn( const wxString
&variant_type
);
241 wxDataViewItem
AddItem( const wxDataViewItem
& parent
, const wxVariant
&value
);
242 wxDataViewItem
AddContainer( const wxDataViewItem
& parent
, const wxVariant
&value
);
244 // implement base methods
246 virtual void GetValue( wxVariant
&variant
,
247 const wxDataViewItem
&item
, unsigned int col
) const;
248 virtual bool SetValue( const wxVariant
&variant
,
249 const wxDataViewItem
&item
, unsigned int col
);
250 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
251 virtual bool IsContainer( const wxDataViewItem
&item
) const;
252 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
256 //-----------------------------------------------------------------------------
257 // wxDataViewEditorCtrlEvtHandler
258 //-----------------------------------------------------------------------------
260 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
263 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
265 void AcceptChangesAndFinish();
266 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
269 void OnChar( wxKeyEvent
&event
);
270 void OnKillFocus( wxFocusEvent
&event
);
271 void OnIdle( wxIdleEvent
&event
);
274 wxDataViewRenderer
*m_owner
;
275 wxControl
*m_editorCtrl
;
280 DECLARE_EVENT_TABLE()
283 // ---------------------------------------------------------
284 // wxDataViewRendererBase
285 // ---------------------------------------------------------
287 enum wxDataViewCellMode
289 wxDATAVIEW_CELL_INERT
,
290 wxDATAVIEW_CELL_ACTIVATABLE
,
291 wxDATAVIEW_CELL_EDITABLE
294 enum wxDataViewCellRenderState
296 wxDATAVIEW_CELL_SELECTED
= 1,
297 wxDATAVIEW_CELL_PRELIT
= 2,
298 wxDATAVIEW_CELL_INSENSITIVE
= 4,
299 wxDATAVIEW_CELL_FOCUSED
= 8
302 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
305 wxDataViewRendererBase( const wxString
&varianttype
,
306 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
307 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
309 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
312 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
313 wxDataViewColumn
* GetOwner() { return m_owner
; }
315 // renderer properties:
317 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
318 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
320 wxString
GetVariantType() const { return m_variantType
; }
322 virtual void SetMode( wxDataViewCellMode mode
) = 0;
323 virtual wxDataViewCellMode
GetMode() const = 0;
325 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
326 // rather an "int"; that's because for rendering cells it's allowed
327 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
328 virtual void SetAlignment( int align
) = 0;
329 virtual int GetAlignment() const = 0;
332 virtual bool HasEditorCtrl()
334 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
335 wxRect
WXUNUSED(labelRect
),
336 const wxVariant
& WXUNUSED(value
))
338 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
339 wxVariant
& WXUNUSED(value
))
342 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
343 virtual void CancelEditing();
344 virtual bool FinishEditing();
346 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
349 wxString m_variantType
;
350 wxDataViewColumn
*m_owner
;
351 wxControl
*m_editorCtrl
;
352 wxDataViewItem m_item
; // for m_editorCtrl
355 const wxDataViewCtrl
* GetView() const;
358 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
361 //-----------------------------------------------------------------------------
362 // wxDataViewIconText
363 //-----------------------------------------------------------------------------
365 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
368 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
369 { m_icon
= icon
; m_text
= text
; }
370 wxDataViewIconText( const wxDataViewIconText
&other
)
371 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
373 void SetText( const wxString
&text
) { m_text
= text
; }
374 wxString
GetText() const { return m_text
; }
375 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
376 const wxIcon
&GetIcon() const { return m_icon
; }
383 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
386 bool operator == (const wxDataViewIconText
&one
, const wxDataViewIconText
&two
);
388 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
390 // ---------------------------------------------------------
391 // wxDataViewColumnBase
392 // ---------------------------------------------------------
394 enum wxDataViewColumnFlags
396 wxDATAVIEW_COL_RESIZABLE
= 1,
397 wxDATAVIEW_COL_SORTABLE
= 2,
398 wxDATAVIEW_COL_HIDDEN
= 4
401 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxObject
404 wxDataViewColumnBase( const wxString
&title
, wxDataViewRenderer
*renderer
,
405 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
406 wxAlignment align
= wxALIGN_CENTER
,
407 int flags
= wxDATAVIEW_COL_RESIZABLE
);
408 wxDataViewColumnBase( const wxBitmap
&bitmap
, wxDataViewRenderer
*renderer
,
409 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
410 wxAlignment align
= wxALIGN_CENTER
,
411 int flags
= wxDATAVIEW_COL_RESIZABLE
);
412 virtual ~wxDataViewColumnBase();
416 virtual void SetTitle( const wxString
&title
) = 0;
417 virtual void SetAlignment( wxAlignment align
) = 0;
418 virtual void SetSortable( bool sortable
) = 0;
419 virtual void SetResizeable( bool resizeable
) = 0;
420 virtual void SetHidden( bool hidden
) = 0;
421 virtual void SetSortOrder( bool ascending
) = 0;
422 virtual void SetFlags( int flags
);
423 virtual void SetOwner( wxDataViewCtrl
*owner
)
425 virtual void SetBitmap( const wxBitmap
&bitmap
)
428 virtual void SetMinWidth( int minWidth
) = 0;
429 virtual void SetWidth( int width
) = 0;
434 virtual wxString
GetTitle() const = 0;
435 virtual wxAlignment
GetAlignment() const = 0;
436 virtual int GetWidth() const = 0;
437 virtual int GetMinWidth() const = 0;
439 virtual int GetFlags() const;
441 virtual bool IsSortable() const = 0;
442 virtual bool IsResizeable() const = 0;
443 virtual bool IsHidden() const = 0;
444 virtual bool IsSortOrderAscending() const = 0;
446 const wxBitmap
&GetBitmap() const { return m_bitmap
; }
447 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
449 wxDataViewCtrl
*GetOwner() { return m_owner
; }
450 wxDataViewRenderer
* GetRenderer() { return m_renderer
; }
453 wxDataViewRenderer
*m_renderer
;
456 wxDataViewCtrl
*m_owner
;
459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase
)
462 // ---------------------------------------------------------
463 // wxDataViewCtrlBase
464 // ---------------------------------------------------------
466 #define wxDV_SINGLE 0x0000 // for convenience
467 #define wxDV_MULTIPLE 0x0001 // can select multiple items
469 #define wxDV_NO_HEADER 0x0002 // column titles not visible
470 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
471 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
473 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
476 wxDataViewCtrlBase();
477 virtual ~wxDataViewCtrlBase();
479 virtual bool AssociateModel( wxDataViewModel
*model
);
480 wxDataViewModel
* GetModel();
483 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
484 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
485 wxAlignment align
= wxALIGN_CENTER
,
486 int flags
= wxDATAVIEW_COL_RESIZABLE
);
487 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
488 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
489 wxAlignment align
= wxALIGN_CENTER
,
490 int flags
= wxDATAVIEW_COL_RESIZABLE
);
491 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
492 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
493 wxAlignment align
= wxALIGN_CENTER
,
494 int flags
= wxDATAVIEW_COL_RESIZABLE
);
495 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
496 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
497 wxAlignment align
= wxALIGN_CENTER
,
498 int flags
= wxDATAVIEW_COL_RESIZABLE
);
499 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
500 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
501 wxAlignment align
= wxALIGN_CENTER
,
502 int flags
= wxDATAVIEW_COL_RESIZABLE
);
503 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
504 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
505 wxAlignment align
= wxALIGN_CENTER
,
506 int flags
= wxDATAVIEW_COL_RESIZABLE
);
507 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
508 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
509 wxAlignment align
= wxALIGN_CENTER
,
510 int flags
= wxDATAVIEW_COL_RESIZABLE
);
511 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
512 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
513 wxAlignment align
= wxALIGN_CENTER
,
514 int flags
= wxDATAVIEW_COL_RESIZABLE
);
515 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
516 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
517 wxAlignment align
= wxALIGN_CENTER
,
518 int flags
= wxDATAVIEW_COL_RESIZABLE
);
519 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
520 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
521 wxAlignment align
= wxALIGN_CENTER
,
522 int flags
= wxDATAVIEW_COL_RESIZABLE
);
523 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
524 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
525 wxAlignment align
= wxALIGN_CENTER
,
526 int flags
= wxDATAVIEW_COL_RESIZABLE
);
528 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
529 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
530 wxAlignment align
= wxALIGN_CENTER
,
531 int flags
= wxDATAVIEW_COL_RESIZABLE
);
533 virtual bool AppendColumn( wxDataViewColumn
*col
);
535 virtual unsigned int GetColumnCount() const = 0;
536 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
537 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
539 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
540 virtual bool ClearColumns() = 0;
542 void SetExpanderColumn( wxDataViewColumn
*col
)
543 { m_expander_column
= col
; DoSetExpanderColumn(); }
544 wxDataViewColumn
*GetExpanderColumn() const
545 { return m_expander_column
; }
547 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
549 void SetIndent( int indent
)
550 { m_indent
= indent
; DoSetIndent(); }
551 int GetIndent() const
554 virtual wxDataViewItem
GetSelection() const = 0;
555 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
556 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
557 virtual void Select( const wxDataViewItem
& item
) = 0;
558 virtual void Unselect( const wxDataViewItem
& item
) = 0;
559 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
561 virtual void SelectAll() = 0;
562 virtual void UnselectAll() = 0;
564 virtual void Expand( const wxDataViewItem
& item
) = 0;
565 virtual void Collapse( const wxDataViewItem
& item
) = 0;
567 virtual void EnsureVisible( const wxDataViewItem
& item
,
568 const wxDataViewColumn
*column
= NULL
) = 0;
569 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
570 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
573 virtual void DoSetExpanderColumn() = 0 ;
574 virtual void DoSetIndent() = 0;
577 wxDataViewModel
*m_model
;
578 wxDataViewColumn
*m_expander_column
;
582 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
585 // ----------------------------------------------------------------------------
586 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
587 // ----------------------------------------------------------------------------
589 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
592 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
593 : wxNotifyEvent(commandType
, winid
),
597 m_value(wxNullVariant
),
601 wxDataViewEvent(const wxDataViewEvent
& event
)
602 : wxNotifyEvent(event
),
603 m_item(event
.m_item
),
605 m_model(event
.m_model
),
606 m_value(event
.m_value
),
607 m_column(event
.m_column
)
610 wxDataViewItem
GetItem() const { return m_item
; }
611 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
613 int GetColumn() const { return m_col
; }
614 void SetColumn( int col
) { m_col
= col
; }
616 wxDataViewModel
* GetModel() const { return m_model
; }
617 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
619 const wxVariant
&GetValue() const { return m_value
; }
620 void SetValue( const wxVariant
&value
) { m_value
= value
; }
622 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
623 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
624 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
626 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
629 wxDataViewItem m_item
;
631 wxDataViewModel
*m_model
;
633 wxDataViewColumn
*m_column
;
636 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
639 BEGIN_DECLARE_EVENT_TYPES()
640 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, -1)
642 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, -1)
643 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, -1)
644 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, -1)
645 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, -1)
646 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, -1)
647 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, -1)
648 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, -1)
649 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, -1)
651 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, -1)
652 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, -1)
653 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, -1)
654 END_DECLARE_EVENT_TYPES()
656 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
658 #define wxDataViewEventHandler(func) \
659 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
661 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
662 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
664 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
666 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
667 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
668 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
669 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
670 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
671 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
672 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
673 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
675 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
676 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
677 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
679 #if defined(wxUSE_GENERICDATAVIEWCTRL)
680 #include "wx/generic/dataview.h"
681 #elif defined(__WXGTK20__)
682 #include "wx/gtk/dataview.h"
683 #elif defined(__WXMAC__)
684 #include "wx/mac/dataview.h"
686 #include "wx/generic/dataview.h"
689 #endif // wxUSE_DATAVIEWCTRL
692 // _WX_DATAVIEW_H_BASE_