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