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