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