1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/dataview.h
3 // Purpose: wxDataViewCtrl generic implementation header
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GENERICDATAVIEWCTRLH__
11 #define __GENERICDATAVIEWCTRLH__
14 #include "wx/object.h"
16 #include "wx/control.h"
17 #include "wx/scrolwin.h"
19 // ---------------------------------------------------------
21 // ---------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxDataViewCtrl
;
24 class WXDLLIMPEXP_CORE wxDataViewMainWindow
;
25 class WXDLLIMPEXP_CORE wxDataViewHeaderWindow
;
27 // ---------------------------------------------------------
29 // ---------------------------------------------------------
31 class wxDataViewCell
: public wxDataViewCellBase
34 wxDataViewCell( const wxString
&varianttype
, wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
37 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
) = 0;
38 virtual wxSize
GetSize() = 0;
40 virtual bool Activate( wxRect cell
,
41 wxDataViewListModel
*model
, size_t col
, size_t row
)
44 virtual bool LeftClick( wxPoint cursor
, wxRect cell
,
45 wxDataViewListModel
*model
, size_t col
, size_t row
)
47 virtual bool RightClick( wxPoint cursor
, wxRect cell
,
48 wxDataViewListModel
*model
, size_t col
, size_t row
)
50 virtual bool StartDrag( wxPoint cursor
, wxRect cell
,
51 wxDataViewListModel
*model
, size_t col
, size_t row
)
54 // Create DC on request
55 virtual wxDC
*GetDC();
61 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell
)
64 // ---------------------------------------------------------
65 // wxDataViewCustomCell
66 // ---------------------------------------------------------
68 class wxDataViewCustomCell
: public wxDataViewCell
71 wxDataViewCustomCell( const wxString
&varianttype
= wxT("string"),
72 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
75 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell
)
78 // ---------------------------------------------------------
80 // ---------------------------------------------------------
82 class wxDataViewTextCell
: public wxDataViewCustomCell
85 wxDataViewTextCell( const wxString
&varianttype
= wxT("string"),
86 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
88 bool SetValue( const wxVariant
&value
);
89 bool GetValue( wxVariant
&value
);
91 bool Render( wxRect cell
, wxDC
*dc
, int state
);
98 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell
)
101 // ---------------------------------------------------------
102 // wxDataViewToggleCell
103 // ---------------------------------------------------------
105 class wxDataViewToggleCell
: public wxDataViewCustomCell
108 wxDataViewToggleCell( const wxString
&varianttype
= wxT("bool"),
109 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
111 bool SetValue( const wxVariant
&value
);
112 bool GetValue( wxVariant
&value
);
114 bool Render( wxRect cell
, wxDC
*dc
, int state
);
115 bool Activate( wxRect cell
, wxDataViewListModel
*model
, size_t col
, size_t row
);
122 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell
)
125 // ---------------------------------------------------------
126 // wxDataViewProgressCell
127 // ---------------------------------------------------------
129 class wxDataViewProgressCell
: public wxDataViewCustomCell
132 wxDataViewProgressCell( const wxString
&label
= wxEmptyString
,
133 const wxString
&varianttype
= wxT("long"),
134 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
135 ~wxDataViewProgressCell();
137 bool SetValue( const wxVariant
&value
);
139 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
140 virtual wxSize
GetSize();
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell
)
150 // ---------------------------------------------------------
151 // wxDataViewDateCell
152 // ---------------------------------------------------------
154 class wxDataViewDateCell
: public wxDataViewCustomCell
157 wxDataViewDateCell( const wxString
&varianttype
= wxT("datetime"),
158 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
160 bool SetValue( const wxVariant
&value
);
162 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
163 virtual wxSize
GetSize();
164 virtual bool Activate( wxRect cell
,
165 wxDataViewListModel
*model
, size_t col
, size_t row
);
171 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell
)
174 // ---------------------------------------------------------
176 // ---------------------------------------------------------
178 class WXDLLIMPEXP_CORE wxDataViewColumn
: public wxDataViewColumnBase
181 wxDataViewColumn( const wxString
&title
, wxDataViewCell
*cell
, size_t model_column
, int flags
= 0 );
182 virtual ~wxDataViewColumn();
184 virtual void SetTitle( const wxString
&title
);
186 void SetWidth( int width
) { m_width
= width
; }
187 int GetWidth() { return m_width
; }
193 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn
)
196 // ---------------------------------------------------------
198 // ---------------------------------------------------------
200 class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxDataViewCtrlBase
,
201 public wxScrollHelperNative
204 wxDataViewCtrl() : wxScrollHelperNative(this)
209 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
210 const wxPoint
& pos
= wxDefaultPosition
,
211 const wxSize
& size
= wxDefaultSize
, long style
= 0,
212 const wxValidator
& validator
= wxDefaultValidator
)
213 : wxScrollHelperNative(this)
215 Create(parent
, id
, pos
, size
, style
, validator
);
218 virtual ~wxDataViewCtrl();
222 bool Create(wxWindow
*parent
, wxWindowID id
,
223 const wxPoint
& pos
= wxDefaultPosition
,
224 const wxSize
& size
= wxDefaultSize
, long style
= 0,
225 const wxValidator
& validator
= wxDefaultValidator
);
227 virtual bool AssociateModel( wxDataViewListModel
*model
);
228 virtual bool AppendColumn( wxDataViewColumn
*col
);
231 friend class wxDataViewMainWindow
;
232 friend class wxDataViewHeaderWindow
;
233 wxDataViewListModelNotifier
*m_notifier
;
234 wxDataViewMainWindow
*m_clientArea
;
235 wxDataViewHeaderWindow
*m_headerArea
;
238 void OnSize( wxSizeEvent
&event
);
240 // we need to return a special WM_GETDLGCODE value to process just the
241 // arrows but let the other navigation characters through
243 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
246 WX_FORWARD_TO_SCROLL_HELPER()
249 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
250 DECLARE_NO_COPY_CLASS(wxDataViewCtrl
)
251 DECLARE_EVENT_TABLE()
255 #endif // __GENERICDATAVIEWCTRLH__