1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
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"
24 // ----------------------------------------------------------------------------
25 // wxDataViewCtrl flags
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
29 // wxDataViewCtrl globals
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxDataViewCtrl
;
33 class WXDLLIMPEXP_CORE wxDataViewColumn
;
35 extern WXDLLEXPORT_DATA(const wxChar
) wxDataViewCtrlNameStr
[];
37 // ---------------------------------------------------------
39 // ---------------------------------------------------------
41 class wxDataViewModel
: public wxObject
45 virtual ~wxDataViewModel() { }
48 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel
)
51 // ---------------------------------------------------------
52 // wxDataViewListModelNotifier
53 // ---------------------------------------------------------
55 class wxDataViewListModelNotifier
58 wxDataViewListModelNotifier() { }
59 virtual ~wxDataViewListModelNotifier() { }
61 virtual bool RowAppended() = 0;
62 virtual bool RowPrepended() = 0;
63 virtual bool RowInserted( size_t before
) = 0;
64 virtual bool RowDeleted( size_t row
) = 0;
65 virtual bool RowChanged( size_t row
) = 0;
66 virtual bool ValueChanged( size_t row
, size_t col
) = 0;
67 virtual bool Cleared() = 0;
70 // ---------------------------------------------------------
71 // wxDataViewListModel
72 // ---------------------------------------------------------
74 class wxDataViewListModel
: public wxDataViewModel
77 wxDataViewListModel();
78 virtual ~wxDataViewListModel();
80 virtual size_t GetNumberOfRows() = 0;
81 virtual size_t GetNumberOfCols() = 0;
82 // as reported by wxVariant
83 virtual wxString
GetColType( size_t col
) = 0;
84 virtual wxVariant
GetValue( size_t col
, size_t row
) = 0;
86 // delegated notifiers
89 bool RowInserted( size_t before
);
90 bool RowDeleted( size_t row
);
91 bool RowChanged( size_t row
);
92 bool ValueChanged( size_t row
, size_t col
);
95 void SetNotifier( wxDataViewListModelNotifier
*notifier
);
96 wxDataViewListModelNotifier
* GetNotifier();
99 wxDataViewListModelNotifier
*m_notifier
;
102 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel
)
105 // ---------------------------------------------------------
107 // ---------------------------------------------------------
109 enum wxDataViewColumnType
113 wxDATAVIEW_COL_ICONTEXT
,
114 wxDATAVIEW_COL_CHECK
,
115 wxDATAVIEW_COL_DATETIME
,
116 wxDATAVIEW_COL_PROGRESS
,
117 wxDATAVIEW_COL_CHOICE
,
118 wxDATAVIEW_COL_CUSTOM
121 enum wxDataViewColumnFlags
123 wxDATAVIEW_COL_RESIZABLE
= 1,
124 wxDATAVIEW_COL_SORTABLE
= 2,
125 wxDATAVIEW_COL_HIDDEN
= 4
128 class wxDataViewColumnBase
: public wxObject
131 wxDataViewColumnBase( const wxString
&title
, wxDataViewCtrl
*ctrl
,
132 wxDataViewColumnType kind
, int flags
= 0 );
134 virtual void SetTitle( const wxString
&title
);
135 virtual wxString
GetTitle();
138 wxDataViewCtrl
*m_ctrl
;
139 wxDataViewColumnType m_kind
;
144 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase
)
147 // ---------------------------------------------------------
148 // wxDataViewCtrlBase
149 // ---------------------------------------------------------
151 class wxDataViewCtrlBase
: public wxControl
154 wxDataViewCtrlBase();
155 ~wxDataViewCtrlBase();
158 virtual bool AssociateModel( wxDataViewListModel
*model
);
159 wxDataViewListModel
* GetModel();
161 virtual bool AppendStringColumn( const wxString
&label
);
162 virtual bool AppendColumn( wxDataViewColumn
*col
);
163 virtual size_t GetNumberOfColumns();
164 virtual bool DeleteColumn( size_t pos
);
165 virtual bool ClearColumns();
166 virtual wxDataViewColumn
* GetColumn( size_t pos
);
169 wxDataViewListModel
*m_model
;
173 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
176 #if defined(__WXGTK20__)
177 #include "wx/gtk/dataview.h"
178 #elif defined(__WXMAC__)
179 #include "wx/mac/dataview.h"
181 #include "wx/generic/dataview.h"
184 #endif // wxUSE_DATAVIEWCTRL
187 // _WX_DATAVIEW_H_BASE_