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"
20 // ---------------------------------------------------------
22 // ---------------------------------------------------------
24 class WXDLLIMPEXP_ADV wxDataViewCtrl
;
25 class WXDLLIMPEXP_ADV wxDataViewMainWindow
;
26 class WXDLLIMPEXP_ADV wxDataViewHeaderWindow
;
28 // ---------------------------------------------------------
30 // ---------------------------------------------------------
32 class WXDLLIMPEXP_ADV wxDataViewRenderer
: public wxDataViewRendererBase
35 wxDataViewRenderer( const wxString
&varianttype
,
36 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
37 virtual ~wxDataViewRenderer();
39 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
) = 0;
40 virtual wxSize
GetSize() = 0;
42 virtual bool Activate( wxRect
WXUNUSED(cell
),
43 wxDataViewListModel
*WXUNUSED(model
),
44 unsigned int WXUNUSED(col
),
45 unsigned int WXUNUSED(row
) )
48 virtual bool LeftClick( wxPoint
WXUNUSED(cursor
),
49 wxRect
WXUNUSED(cell
),
50 wxDataViewListModel
*WXUNUSED(model
),
51 unsigned int WXUNUSED(col
),
52 unsigned int WXUNUSED(row
) )
54 virtual bool RightClick( wxPoint
WXUNUSED(cursor
),
55 wxRect
WXUNUSED(cell
),
56 wxDataViewListModel
*WXUNUSED(model
),
57 unsigned int WXUNUSED(col
),
58 unsigned int WXUNUSED(row
) )
60 virtual bool StartDrag( wxPoint
WXUNUSED(cursor
),
61 wxRect
WXUNUSED(cell
),
62 wxDataViewListModel
*WXUNUSED(model
),
63 unsigned int WXUNUSED(col
),
64 unsigned int WXUNUSED(row
) )
67 // Create DC on request
68 virtual wxDC
*GetDC();
74 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer
)
77 // ---------------------------------------------------------
78 // wxDataViewCustomRenderer
79 // ---------------------------------------------------------
81 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer
: public wxDataViewRenderer
84 wxDataViewCustomRenderer( const wxString
&varianttype
= wxT("string"),
85 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
88 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
91 // ---------------------------------------------------------
92 // wxDataViewTextRenderer
93 // ---------------------------------------------------------
95 class WXDLLIMPEXP_ADV wxDataViewTextRenderer
: public wxDataViewCustomRenderer
98 wxDataViewTextRenderer( const wxString
&varianttype
= wxT("string"),
99 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
101 bool SetValue( const wxVariant
&value
);
102 bool GetValue( wxVariant
&value
);
104 bool Render( wxRect cell
, wxDC
*dc
, int state
);
111 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer
)
114 // ---------------------------------------------------------
115 // wxDataViewBitmapRenderer
116 // ---------------------------------------------------------
118 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer
: public wxDataViewCustomRenderer
121 wxDataViewBitmapRenderer( const wxString
&varianttype
= wxT("wxBitmap"),
122 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
124 bool SetValue( const wxVariant
&value
);
125 bool GetValue( wxVariant
&value
);
127 bool Render( wxRect cell
, wxDC
*dc
, int state
);
135 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer
)
138 // ---------------------------------------------------------
139 // wxDataViewToggleRenderer
140 // ---------------------------------------------------------
142 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer
: public wxDataViewCustomRenderer
145 wxDataViewToggleRenderer( const wxString
&varianttype
= wxT("bool"),
146 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
148 bool SetValue( const wxVariant
&value
);
149 bool GetValue( wxVariant
&value
);
151 bool Render( wxRect cell
, wxDC
*dc
, int state
);
152 bool Activate( wxRect cell
, wxDataViewListModel
*model
, unsigned int col
,
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer
)
163 // ---------------------------------------------------------
164 // wxDataViewProgressRenderer
165 // ---------------------------------------------------------
167 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
170 wxDataViewProgressRenderer( const wxString
&label
= wxEmptyString
,
171 const wxString
&varianttype
= wxT("long"),
172 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
173 virtual ~wxDataViewProgressRenderer();
175 bool SetValue( const wxVariant
&value
);
177 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
178 virtual wxSize
GetSize();
185 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
188 // ---------------------------------------------------------
189 // wxDataViewDateRenderer
190 // ---------------------------------------------------------
192 class WXDLLIMPEXP_ADV wxDataViewDateRenderer
: public wxDataViewCustomRenderer
195 wxDataViewDateRenderer( const wxString
&varianttype
= wxT("datetime"),
196 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
198 bool SetValue( const wxVariant
&value
);
200 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
201 virtual wxSize
GetSize();
202 virtual bool Activate( wxRect cell
,
203 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
);
209 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
212 // ---------------------------------------------------------
214 // ---------------------------------------------------------
216 class WXDLLIMPEXP_ADV wxDataViewColumn
: public wxDataViewColumnBase
218 friend class wxDataViewHeaderWindowBase
;
219 friend class wxDataViewHeaderWindow
;
220 friend class wxDataViewHeaderWindowMSW
;
223 wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*renderer
,
224 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
225 wxAlignment align
= wxALIGN_CENTER
,
226 int flags
= wxDATAVIEW_COL_RESIZABLE
);
227 wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*renderer
,
228 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
229 wxAlignment align
= wxALIGN_CENTER
,
230 int flags
= wxDATAVIEW_COL_RESIZABLE
);
231 virtual ~wxDataViewColumn();
233 virtual void SetTitle( const wxString
&title
);
234 virtual void SetBitmap( const wxBitmap
&bitmap
);
236 virtual void SetAlignment( wxAlignment align
)
238 wxAlignment
GetAlignment() const
241 virtual void SetSortable( bool sortable
);
242 virtual void SetSortOrder( bool ascending
);
243 virtual bool IsSortOrderAscending() const;
245 virtual int GetWidth() const;
257 void Init(int width
);
260 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn
)
263 // ---------------------------------------------------------
265 // ---------------------------------------------------------
267 class WXDLLIMPEXP_ADV wxDataViewCtrl
: public wxDataViewCtrlBase
,
268 public wxScrollHelperNative
270 friend class wxDataViewMainWindow
;
271 friend class wxDataViewHeaderWindowBase
;
272 friend class wxDataViewHeaderWindow
;
273 friend class wxDataViewHeaderWindowMSW
;
276 wxDataViewCtrl() : wxScrollHelperNative(this)
281 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
282 const wxPoint
& pos
= wxDefaultPosition
,
283 const wxSize
& size
= wxDefaultSize
, long style
= 0,
284 const wxValidator
& validator
= wxDefaultValidator
)
285 : wxScrollHelperNative(this)
287 Create(parent
, id
, pos
, size
, style
, validator
);
290 virtual ~wxDataViewCtrl();
294 bool Create(wxWindow
*parent
, wxWindowID id
,
295 const wxPoint
& pos
= wxDefaultPosition
,
296 const wxSize
& size
= wxDefaultSize
, long style
= 0,
297 const wxValidator
& validator
= wxDefaultValidator
);
299 virtual bool AssociateModel( wxDataViewListModel
*model
);
300 virtual bool AppendColumn( wxDataViewColumn
*col
);
302 virtual void SetSelection( int row
); // -1 for unselect
303 virtual void SetSelectionRange( unsigned int from
, unsigned int to
);
304 virtual void SetSelections( const wxArrayInt
& aSelections
);
305 virtual void Unselect( unsigned int row
);
307 virtual bool IsSelected( unsigned int row
) const;
308 virtual int GetSelection() const;
309 virtual int GetSelections(wxArrayInt
& aSelections
) const;
311 // returns the "best" width for the idx-th column
312 unsigned int GetBestColumnWidth(int WXUNUSED(idx
))
314 return GetClientSize().GetWidth() / GetNumberOfColumns();
319 wxDataViewListModelNotifier
*m_notifier
;
320 wxDataViewMainWindow
*m_clientArea
;
321 wxDataViewHeaderWindow
*m_headerArea
;
324 void OnSize( wxSizeEvent
&event
);
326 // we need to return a special WM_GETDLGCODE value to process just the
327 // arrows but let the other navigation characters through
329 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
332 WX_FORWARD_TO_SCROLL_HELPER()
335 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
336 DECLARE_NO_COPY_CLASS(wxDataViewCtrl
)
337 DECLARE_EVENT_TABLE()
341 #endif // __GENERICDATAVIEWCTRLH__