]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dataview.h
listbox cleanup
[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"
4ed7af08 18
f554a14b 19// ---------------------------------------------------------
4ed7af08 20// classes
f554a14b 21// ---------------------------------------------------------
4ed7af08
RR
22
23class WXDLLIMPEXP_CORE wxDataViewCtrl;
4b3feaa7
RR
24class WXDLLIMPEXP_CORE wxDataViewMainWindow;
25class WXDLLIMPEXP_CORE wxDataViewHeaderWindow;
4ed7af08 26
f554a14b 27// ---------------------------------------------------------
4ed7af08 28// wxDataViewCell
f554a14b 29// ---------------------------------------------------------
4ed7af08
RR
30
31class wxDataViewCell: public wxDataViewCellBase
32{
33public:
34 wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
3d9d7cc4 35 ~wxDataViewCell();
4ed7af08 36
3d9d7cc4
RR
37 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
38 virtual wxSize GetSize() = 0;
f554a14b
WS
39
40 virtual bool Activate( wxRect WXUNUSED(cell),
41 wxDataViewListModel *WXUNUSED(model),
42 size_t WXUNUSED(col),
43 size_t WXUNUSED(row) )
3d9d7cc4 44 { return false; }
f554a14b
WS
45
46 virtual bool LeftClick( wxPoint WXUNUSED(cursor),
47 wxRect WXUNUSED(cell),
48 wxDataViewListModel *WXUNUSED(model),
49 size_t WXUNUSED(col),
50 size_t WXUNUSED(row) )
51 { return false; }
52 virtual bool RightClick( wxPoint WXUNUSED(cursor),
53 wxRect WXUNUSED(cell),
54 wxDataViewListModel *WXUNUSED(model),
55 size_t WXUNUSED(col),
56 size_t WXUNUSED(row) )
57 { return false; }
58 virtual bool StartDrag( wxPoint WXUNUSED(cursor),
59 wxRect WXUNUSED(cell),
60 wxDataViewListModel *WXUNUSED(model),
61 size_t WXUNUSED(col),
62 size_t WXUNUSED(row) )
63 { return false; }
64
3d9d7cc4
RR
65 // Create DC on request
66 virtual wxDC *GetDC();
f554a14b 67
3d9d7cc4
RR
68private:
69 wxDC *m_dc;
f554a14b 70
4ed7af08
RR
71protected:
72 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell)
73};
f554a14b
WS
74
75// ---------------------------------------------------------
3d9d7cc4 76// wxDataViewCustomCell
f554a14b 77// ---------------------------------------------------------
4ed7af08 78
3d9d7cc4 79class wxDataViewCustomCell: public wxDataViewCell
4ed7af08
RR
80{
81public:
f554a14b 82 wxDataViewCustomCell( const wxString &varianttype = wxT("string"),
3d9d7cc4 83 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
f554a14b 84
4ed7af08 85protected:
3d9d7cc4 86 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell)
4ed7af08 87};
f554a14b
WS
88
89// ---------------------------------------------------------
3d9d7cc4 90// wxDataViewTextCell
f554a14b 91// ---------------------------------------------------------
4ed7af08 92
3d9d7cc4 93class wxDataViewTextCell: public wxDataViewCustomCell
4ed7af08
RR
94{
95public:
f554a14b 96 wxDataViewTextCell( const wxString &varianttype = wxT("string"),
4ed7af08
RR
97 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
98
99 bool SetValue( const wxVariant &value );
100 bool GetValue( wxVariant &value );
f554a14b 101
3d9d7cc4
RR
102 bool Render( wxRect cell, wxDC *dc, int state );
103 wxSize GetSize();
f554a14b 104
90675b95
RR
105private:
106 wxString m_text;
f554a14b 107
4ed7af08 108protected:
3d9d7cc4 109 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
4ed7af08 110};
f554a14b
WS
111
112// ---------------------------------------------------------
3d9d7cc4 113// wxDataViewToggleCell
f554a14b 114// ---------------------------------------------------------
4ed7af08 115
3d9d7cc4 116class wxDataViewToggleCell: public wxDataViewCustomCell
4ed7af08
RR
117{
118public:
f554a14b 119 wxDataViewToggleCell( const wxString &varianttype = wxT("bool"),
3d9d7cc4
RR
120 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
121
122 bool SetValue( const wxVariant &value );
123 bool GetValue( wxVariant &value );
f554a14b 124
3d9d7cc4 125 bool Render( wxRect cell, wxDC *dc, int state );
0fdc2321 126 bool Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row );
3d9d7cc4 127 wxSize GetSize();
f554a14b 128
90675b95
RR
129private:
130 bool m_toggle;
f554a14b 131
4ed7af08 132protected:
3d9d7cc4 133 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell)
4ed7af08 134};
f554a14b
WS
135
136// ---------------------------------------------------------
4ed7af08 137// wxDataViewProgressCell
f554a14b 138// ---------------------------------------------------------
4ed7af08
RR
139
140class wxDataViewProgressCell: public wxDataViewCustomCell
141{
142public:
f554a14b
WS
143 wxDataViewProgressCell( const wxString &label = wxEmptyString,
144 const wxString &varianttype = wxT("long"),
4ed7af08
RR
145 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
146 ~wxDataViewProgressCell();
f554a14b 147
4ed7af08 148 bool SetValue( const wxVariant &value );
f554a14b 149
4ed7af08
RR
150 virtual bool Render( wxRect cell, wxDC *dc, int state );
151 virtual wxSize GetSize();
f554a14b 152
4ed7af08
RR
153private:
154 wxString m_label;
155 int m_value;
f554a14b 156
4ed7af08
RR
157protected:
158 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
159};
f554a14b
WS
160
161// ---------------------------------------------------------
4ed7af08 162// wxDataViewDateCell
f554a14b 163// ---------------------------------------------------------
4ed7af08
RR
164
165class wxDataViewDateCell: public wxDataViewCustomCell
166{
167public:
f554a14b 168 wxDataViewDateCell( const wxString &varianttype = wxT("datetime"),
4ed7af08 169 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
f554a14b 170
4ed7af08 171 bool SetValue( const wxVariant &value );
f554a14b 172
4ed7af08
RR
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 );
f554a14b 177
4ed7af08
RR
178private:
179 wxDateTime m_date;
f554a14b 180
4ed7af08
RR
181protected:
182 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell)
183};
f554a14b
WS
184
185// ---------------------------------------------------------
4ed7af08 186// wxDataViewColumn
f554a14b 187// ---------------------------------------------------------
4ed7af08
RR
188
189class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
190{
191public:
192 wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
193 virtual ~wxDataViewColumn();
194
195 virtual void SetTitle( const wxString &title );
f554a14b 196
4b3feaa7
RR
197 void SetWidth( int width ) { m_width = width; }
198 int GetWidth() { return m_width; }
f554a14b 199
4ed7af08 200private:
4b3feaa7 201 int m_width;
4ed7af08
RR
202
203protected:
204 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
205};
206
f554a14b 207// ---------------------------------------------------------
4ed7af08 208// wxDataViewCtrl
f554a14b 209// ---------------------------------------------------------
4ed7af08 210
f554a14b 211class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase,
4ed7af08
RR
212 public wxScrollHelperNative
213{
214public:
215 wxDataViewCtrl() : wxScrollHelperNative(this)
216 {
217 Init();
218 }
f554a14b 219
4ed7af08
RR
220 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
221 const wxPoint& pos = wxDefaultPosition,
222 const wxSize& size = wxDefaultSize, long style = 0,
f554a14b 223 const wxValidator& validator = wxDefaultValidator )
4b3feaa7 224 : wxScrollHelperNative(this)
4ed7af08
RR
225 {
226 Create(parent, id, pos, size, style, validator );
227 }
228
229 virtual ~wxDataViewCtrl();
230
231 void Init();
232
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 );
237
238 virtual bool AssociateModel( wxDataViewListModel *model );
239 virtual bool AppendColumn( wxDataViewColumn *col );
f554a14b 240
4ed7af08 241private:
4b3feaa7 242 friend class wxDataViewMainWindow;
3d9d7cc4 243 friend class wxDataViewHeaderWindow;
4ed7af08 244 wxDataViewListModelNotifier *m_notifier;
4b3feaa7
RR
245 wxDataViewMainWindow *m_clientArea;
246 wxDataViewHeaderWindow *m_headerArea;
f554a14b 247
4ed7af08 248private:
4b3feaa7 249 void OnSize( wxSizeEvent &event );
f554a14b 250
4ed7af08
RR
251 // we need to return a special WM_GETDLGCODE value to process just the
252 // arrows but let the other navigation characters through
253#ifdef __WXMSW__
254 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
255#endif // __WXMSW__
256
257 WX_FORWARD_TO_SCROLL_HELPER()
4b3feaa7 258
4ed7af08
RR
259private:
260 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
261 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
4b3feaa7 262 DECLARE_EVENT_TABLE()
4ed7af08
RR
263};
264
265
266#endif // __GENERICDATAVIEWCTRLH__