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
WXUNUSED(cell
),
41 wxDataViewListModel
*WXUNUSED(model
),
43 size_t WXUNUSED(row
) )
46 virtual bool LeftClick( wxPoint
WXUNUSED(cursor
),
47 wxRect
WXUNUSED(cell
),
48 wxDataViewListModel
*WXUNUSED(model
),
50 size_t WXUNUSED(row
) )
52 virtual bool RightClick( wxPoint
WXUNUSED(cursor
),
53 wxRect
WXUNUSED(cell
),
54 wxDataViewListModel
*WXUNUSED(model
),
56 size_t WXUNUSED(row
) )
58 virtual bool StartDrag( wxPoint
WXUNUSED(cursor
),
59 wxRect
WXUNUSED(cell
),
60 wxDataViewListModel
*WXUNUSED(model
),
62 size_t WXUNUSED(row
) )
65 // Create DC on request
66 virtual wxDC
*GetDC();
72 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell
)
75 // ---------------------------------------------------------
76 // wxDataViewCustomCell
77 // ---------------------------------------------------------
79 class wxDataViewCustomCell
: public wxDataViewCell
82 wxDataViewCustomCell( const wxString
&varianttype
= wxT("string"),
83 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
86 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell
)
89 // ---------------------------------------------------------
91 // ---------------------------------------------------------
93 class wxDataViewTextCell
: public wxDataViewCustomCell
96 wxDataViewTextCell( const wxString
&varianttype
= wxT("string"),
97 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
99 bool SetValue( const wxVariant
&value
);
100 bool GetValue( wxVariant
&value
);
102 bool Render( wxRect cell
, wxDC
*dc
, int state
);
109 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell
)
112 // ---------------------------------------------------------
113 // wxDataViewToggleCell
114 // ---------------------------------------------------------
116 class wxDataViewToggleCell
: public wxDataViewCustomCell
119 wxDataViewToggleCell( const wxString
&varianttype
= wxT("bool"),
120 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
122 bool SetValue( const wxVariant
&value
);
123 bool GetValue( wxVariant
&value
);
125 bool Render( wxRect cell
, wxDC
*dc
, int state
);
126 bool Activate( wxRect cell
, wxDataViewListModel
*model
, size_t col
, size_t row
);
133 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell
)
136 // ---------------------------------------------------------
137 // wxDataViewProgressCell
138 // ---------------------------------------------------------
140 class wxDataViewProgressCell
: public wxDataViewCustomCell
143 wxDataViewProgressCell( const wxString
&label
= wxEmptyString
,
144 const wxString
&varianttype
= wxT("long"),
145 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
146 ~wxDataViewProgressCell();
148 bool SetValue( const wxVariant
&value
);
150 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
151 virtual wxSize
GetSize();
158 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell
)
161 // ---------------------------------------------------------
162 // wxDataViewDateCell
163 // ---------------------------------------------------------
165 class wxDataViewDateCell
: public wxDataViewCustomCell
168 wxDataViewDateCell( const wxString
&varianttype
= wxT("datetime"),
169 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
171 bool SetValue( const wxVariant
&value
);
173 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
174 virtual wxSize
GetSize();
175 virtual bool Activate( wxRect cell
,
176 wxDataViewListModel
*model
, size_t col
, size_t row
);
182 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell
)
185 // ---------------------------------------------------------
187 // ---------------------------------------------------------
189 class WXDLLIMPEXP_CORE wxDataViewColumn
: public wxDataViewColumnBase
192 wxDataViewColumn( const wxString
&title
, wxDataViewCell
*cell
, size_t model_column
, int flags
= 0 );
193 virtual ~wxDataViewColumn();
195 virtual void SetTitle( const wxString
&title
);
197 void SetWidth( int width
) { m_width
= width
; }
198 int GetWidth() { return m_width
; }
204 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn
)
207 // ---------------------------------------------------------
209 // ---------------------------------------------------------
211 class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxDataViewCtrlBase
,
212 public wxScrollHelperNative
215 wxDataViewCtrl() : wxScrollHelperNative(this)
220 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
221 const wxPoint
& pos
= wxDefaultPosition
,
222 const wxSize
& size
= wxDefaultSize
, long style
= 0,
223 const wxValidator
& validator
= wxDefaultValidator
)
224 : wxScrollHelperNative(this)
226 Create(parent
, id
, pos
, size
, style
, validator
);
229 virtual ~wxDataViewCtrl();
233 bool Create(wxWindow
*parent
, wxWindowID id
,
234 const wxPoint
& pos
= wxDefaultPosition
,
235 const wxSize
& size
= wxDefaultSize
, long style
= 0,
236 const wxValidator
& validator
= wxDefaultValidator
);
238 virtual bool AssociateModel( wxDataViewListModel
*model
);
239 virtual bool AppendColumn( wxDataViewColumn
*col
);
242 friend class wxDataViewMainWindow
;
243 friend class wxDataViewHeaderWindow
;
244 wxDataViewListModelNotifier
*m_notifier
;
245 wxDataViewMainWindow
*m_clientArea
;
246 wxDataViewHeaderWindow
*m_headerArea
;
249 void OnSize( wxSizeEvent
&event
);
251 // we need to return a special WM_GETDLGCODE value to process just the
252 // arrows but let the other navigation characters through
254 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
257 WX_FORWARD_TO_SCROLL_HELPER()
260 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
261 DECLARE_NO_COPY_CLASS(wxDataViewCtrl
)
262 DECLARE_EVENT_TABLE()
266 #endif // __GENERICDATAVIEWCTRLH__