]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dataview.h
Change GetC to return an int so that it can return wxEOF on error.
[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 );
47cef10f
RR
224 virtual void SetBitmap( const wxBitmap &bitmap );
225
226 virtual void SetAlignment( wxAlignment align );
31fb32e1
RR
227
228 virtual void SetSortable( bool sortable );
229 virtual bool GetSortable();
47cef10f 230 virtual void SetSortOrder( bool ascending );
31fb32e1 231 virtual bool IsSortOrderAscending();
f554a14b 232
533544f2 233 virtual int GetWidth();
f554a14b 234
4ed7af08 235private:
533544f2 236 int m_width;
533544f2 237 int m_fixedWidth;
4ed7af08
RR
238
239protected:
240 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
241};
242
f554a14b 243// ---------------------------------------------------------
4ed7af08 244// wxDataViewCtrl
f554a14b 245// ---------------------------------------------------------
4ed7af08 246
f460c29d 247class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase,
4ed7af08
RR
248 public wxScrollHelperNative
249{
250public:
251 wxDataViewCtrl() : wxScrollHelperNative(this)
252 {
253 Init();
254 }
f554a14b 255
4ed7af08
RR
256 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
257 const wxPoint& pos = wxDefaultPosition,
258 const wxSize& size = wxDefaultSize, long style = 0,
f554a14b 259 const wxValidator& validator = wxDefaultValidator )
4b3feaa7 260 : wxScrollHelperNative(this)
4ed7af08
RR
261 {
262 Create(parent, id, pos, size, style, validator );
263 }
264
265 virtual ~wxDataViewCtrl();
266
267 void Init();
268
269 bool Create(wxWindow *parent, wxWindowID id,
270 const wxPoint& pos = wxDefaultPosition,
271 const wxSize& size = wxDefaultSize, long style = 0,
272 const wxValidator& validator = wxDefaultValidator );
273
274 virtual bool AssociateModel( wxDataViewListModel *model );
275 virtual bool AppendColumn( wxDataViewColumn *col );
f554a14b 276
6ff7eee7
RR
277 virtual void SetSelection( int row ); // -1 for unselect
278 virtual void SetSelectionRange( unsigned int from, unsigned int to );
279 virtual void SetSelections( const wxArrayInt& aSelections);
fc211fe5 280 virtual void Unselect( unsigned int row );
6ff7eee7
RR
281
282 virtual bool IsSelected( unsigned int row ) const;
283 virtual int GetSelection() const;
284 virtual int GetSelections(wxArrayInt& aSelections) const;
285
4ed7af08 286private:
4b3feaa7 287 friend class wxDataViewMainWindow;
3d9d7cc4 288 friend class wxDataViewHeaderWindow;
4ed7af08 289 wxDataViewListModelNotifier *m_notifier;
4b3feaa7
RR
290 wxDataViewMainWindow *m_clientArea;
291 wxDataViewHeaderWindow *m_headerArea;
f554a14b 292
4ed7af08 293private:
4b3feaa7 294 void OnSize( wxSizeEvent &event );
f554a14b 295
4ed7af08
RR
296 // we need to return a special WM_GETDLGCODE value to process just the
297 // arrows but let the other navigation characters through
298#ifdef __WXMSW__
299 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
300#endif // __WXMSW__
301
302 WX_FORWARD_TO_SCROLL_HELPER()
4b3feaa7 303
4ed7af08
RR
304private:
305 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
306 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
4b3feaa7 307 DECLARE_EVENT_TABLE()
4ed7af08
RR
308};
309
310
311#endif // __GENERICDATAVIEWCTRLH__