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