]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dataview.h
Fix buffer overrun in Linux/x86_64 (Pixel is a 64 bit long, passing
[wxWidgets.git] / include / wx / generic / dataview.h
CommitLineData
4ed7af08
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/dataview.h
3// Purpose: wxDataViewCtrl generic implementation header
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef __GENERICDATAVIEWCTRLH__
11#define __GENERICDATAVIEWCTRLH__
12
13#include "wx/defs.h"
14#include "wx/object.h"
15#include "wx/list.h"
16#include "wx/control.h"
9d14de69 17#include "wx/scrolwin.h"
2586d4a1 18#include "wx/icon.h"
4ed7af08 19
f554a14b 20// ---------------------------------------------------------
4ed7af08 21// classes
f554a14b 22// ---------------------------------------------------------
4ed7af08 23
f460c29d
RD
24class WXDLLIMPEXP_ADV wxDataViewCtrl;
25class WXDLLIMPEXP_ADV wxDataViewMainWindow;
26class WXDLLIMPEXP_ADV wxDataViewHeaderWindow;
4ed7af08 27
f554a14b 28// ---------------------------------------------------------
baa9ebc4 29// wxDataViewRenderer
f554a14b 30// ---------------------------------------------------------
4ed7af08 31
baa9ebc4 32class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
4ed7af08
RR
33{
34public:
baa9ebc4
RR
35 wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
36 virtual ~wxDataViewRenderer();
4ed7af08 37
3d9d7cc4
RR
38 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
39 virtual wxSize GetSize() = 0;
f554a14b
WS
40
41 virtual bool Activate( wxRect WXUNUSED(cell),
42 wxDataViewListModel *WXUNUSED(model),
0a71f9e9
RR
43 unsigned int WXUNUSED(col),
44 unsigned int WXUNUSED(row) )
3d9d7cc4 45 { return false; }
f554a14b
WS
46
47 virtual bool LeftClick( wxPoint WXUNUSED(cursor),
48 wxRect WXUNUSED(cell),
49 wxDataViewListModel *WXUNUSED(model),
0a71f9e9
RR
50 unsigned int WXUNUSED(col),
51 unsigned int WXUNUSED(row) )
f554a14b
WS
52 { return false; }
53 virtual bool RightClick( wxPoint WXUNUSED(cursor),
54 wxRect WXUNUSED(cell),
55 wxDataViewListModel *WXUNUSED(model),
0a71f9e9
RR
56 unsigned int WXUNUSED(col),
57 unsigned int WXUNUSED(row) )
f554a14b
WS
58 { return false; }
59 virtual bool StartDrag( wxPoint WXUNUSED(cursor),
60 wxRect WXUNUSED(cell),
61 wxDataViewListModel *WXUNUSED(model),
0a71f9e9
RR
62 unsigned int WXUNUSED(col),
63 unsigned int WXUNUSED(row) )
f554a14b
WS
64 { return false; }
65
3d9d7cc4
RR
66 // Create DC on request
67 virtual wxDC *GetDC();
f554a14b 68
3d9d7cc4
RR
69private:
70 wxDC *m_dc;
f554a14b 71
4ed7af08 72protected:
baa9ebc4 73 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
4ed7af08 74};
f554a14b
WS
75
76// ---------------------------------------------------------
baa9ebc4 77// wxDataViewCustomRenderer
f554a14b 78// ---------------------------------------------------------
4ed7af08 79
baa9ebc4 80class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
4ed7af08
RR
81{
82public:
baa9ebc4
RR
83 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
84 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
f554a14b 85
4ed7af08 86protected:
baa9ebc4 87 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
4ed7af08 88};
f554a14b
WS
89
90// ---------------------------------------------------------
baa9ebc4 91// wxDataViewTextRenderer
f554a14b 92// ---------------------------------------------------------
4ed7af08 93
baa9ebc4 94class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewCustomRenderer
4ed7af08
RR
95{
96public:
baa9ebc4
RR
97 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
98 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
4ed7af08
RR
99
100 bool SetValue( const wxVariant &value );
101 bool GetValue( wxVariant &value );
f554a14b 102
3d9d7cc4
RR
103 bool Render( wxRect cell, wxDC *dc, int state );
104 wxSize GetSize();
f554a14b 105
90675b95
RR
106private:
107 wxString m_text;
f554a14b 108
4ed7af08 109protected:
baa9ebc4 110 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
4ed7af08 111};
f554a14b 112
2586d4a1 113// ---------------------------------------------------------
baa9ebc4 114// wxDataViewBitmapRenderer
2586d4a1
RR
115// ---------------------------------------------------------
116
baa9ebc4 117class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewCustomRenderer
2586d4a1
RR
118{
119public:
baa9ebc4
RR
120 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
121 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
2586d4a1
RR
122
123 bool SetValue( const wxVariant &value );
124 bool GetValue( wxVariant &value );
125
126 bool Render( wxRect cell, wxDC *dc, int state );
127 wxSize GetSize();
128
129private:
130 wxIcon m_icon;
131 wxBitmap m_bitmap;
132
133protected:
baa9ebc4 134 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
2586d4a1
RR
135};
136
f554a14b 137// ---------------------------------------------------------
baa9ebc4 138// wxDataViewToggleRenderer
f554a14b 139// ---------------------------------------------------------
4ed7af08 140
baa9ebc4 141class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewCustomRenderer
4ed7af08
RR
142{
143public:
baa9ebc4
RR
144 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
145 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
3d9d7cc4
RR
146
147 bool SetValue( const wxVariant &value );
148 bool GetValue( wxVariant &value );
f554a14b 149
3d9d7cc4 150 bool Render( wxRect cell, wxDC *dc, int state );
0a71f9e9 151 bool Activate( wxRect cell, wxDataViewListModel *model, unsigned int col, unsigned int row );
3d9d7cc4 152 wxSize GetSize();
f554a14b 153
90675b95
RR
154private:
155 bool m_toggle;
f554a14b 156
4ed7af08 157protected:
baa9ebc4 158 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
4ed7af08 159};
f554a14b
WS
160
161// ---------------------------------------------------------
baa9ebc4 162// wxDataViewProgressRenderer
f554a14b 163// ---------------------------------------------------------
4ed7af08 164
baa9ebc4 165class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
4ed7af08
RR
166{
167public:
baa9ebc4
RR
168 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
169 const wxString &varianttype = wxT("long"),
170 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
171 virtual ~wxDataViewProgressRenderer();
f554a14b 172
4ed7af08 173 bool SetValue( const wxVariant &value );
f554a14b 174
4ed7af08
RR
175 virtual bool Render( wxRect cell, wxDC *dc, int state );
176 virtual wxSize GetSize();
f554a14b 177
4ed7af08
RR
178private:
179 wxString m_label;
180 int m_value;
f554a14b 181
4ed7af08 182protected:
baa9ebc4 183 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
4ed7af08 184};
f554a14b
WS
185
186// ---------------------------------------------------------
baa9ebc4 187// wxDataViewDateRenderer
f554a14b 188// ---------------------------------------------------------
4ed7af08 189
baa9ebc4 190class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
4ed7af08
RR
191{
192public:
baa9ebc4
RR
193 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
194 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
f554a14b 195
4ed7af08 196 bool SetValue( const wxVariant &value );
f554a14b 197
4ed7af08
RR
198 virtual bool Render( wxRect cell, wxDC *dc, int state );
199 virtual wxSize GetSize();
200 virtual bool Activate( wxRect cell,
0a71f9e9 201 wxDataViewListModel *model, unsigned int col, unsigned int row );
f554a14b 202
4ed7af08
RR
203private:
204 wxDateTime m_date;
f554a14b 205
4ed7af08 206protected:
baa9ebc4 207 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
4ed7af08 208};
f554a14b
WS
209
210// ---------------------------------------------------------
4ed7af08 211// wxDataViewColumn
f554a14b 212// ---------------------------------------------------------
4ed7af08 213
f460c29d 214class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
4ed7af08
RR
215{
216public:
baa9ebc4 217 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
008b5a66 218 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
07a84e7b
RR
219 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
220 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
4ed7af08
RR
221 virtual ~wxDataViewColumn();
222
223 virtual void SetTitle( const wxString &title );
f554a14b 224
533544f2 225 virtual int GetWidth();
f554a14b 226
4ed7af08 227private:
533544f2 228 int m_width;
533544f2 229 int m_fixedWidth;
4ed7af08
RR
230
231protected:
232 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
233};
234
f554a14b 235// ---------------------------------------------------------
4ed7af08 236// wxDataViewCtrl
f554a14b 237// ---------------------------------------------------------
4ed7af08 238
f460c29d 239class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase,
4ed7af08
RR
240 public wxScrollHelperNative
241{
242public:
243 wxDataViewCtrl() : wxScrollHelperNative(this)
244 {
245 Init();
246 }
f554a14b 247
4ed7af08
RR
248 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
249 const wxPoint& pos = wxDefaultPosition,
250 const wxSize& size = wxDefaultSize, long style = 0,
f554a14b 251 const wxValidator& validator = wxDefaultValidator )
4b3feaa7 252 : wxScrollHelperNative(this)
4ed7af08
RR
253 {
254 Create(parent, id, pos, size, style, validator );
255 }
256
257 virtual ~wxDataViewCtrl();
258
259 void Init();
260
261 bool Create(wxWindow *parent, wxWindowID id,
262 const wxPoint& pos = wxDefaultPosition,
263 const wxSize& size = wxDefaultSize, long style = 0,
264 const wxValidator& validator = wxDefaultValidator );
265
266 virtual bool AssociateModel( wxDataViewListModel *model );
267 virtual bool AppendColumn( wxDataViewColumn *col );
f554a14b 268
6ff7eee7
RR
269 virtual void SetSelection( int row ); // -1 for unselect
270 virtual void SetSelectionRange( unsigned int from, unsigned int to );
271 virtual void SetSelections( const wxArrayInt& aSelections);
fc211fe5 272 virtual void Unselect( unsigned int row );
6ff7eee7
RR
273
274 virtual bool IsSelected( unsigned int row ) const;
275 virtual int GetSelection() const;
276 virtual int GetSelections(wxArrayInt& aSelections) const;
277
4ed7af08 278private:
4b3feaa7 279 friend class wxDataViewMainWindow;
3d9d7cc4 280 friend class wxDataViewHeaderWindow;
4ed7af08 281 wxDataViewListModelNotifier *m_notifier;
4b3feaa7
RR
282 wxDataViewMainWindow *m_clientArea;
283 wxDataViewHeaderWindow *m_headerArea;
f554a14b 284
4ed7af08 285private:
4b3feaa7 286 void OnSize( wxSizeEvent &event );
f554a14b 287
4ed7af08
RR
288 // we need to return a special WM_GETDLGCODE value to process just the
289 // arrows but let the other navigation characters through
290#ifdef __WXMSW__
291 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
292#endif // __WXMSW__
293
294 WX_FORWARD_TO_SCROLL_HELPER()
4b3feaa7 295
4ed7af08
RR
296private:
297 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
298 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
4b3feaa7 299 DECLARE_EVENT_TABLE()
4ed7af08
RR
300};
301
302
303#endif // __GENERICDATAVIEWCTRLH__