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