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