]>
Commit | Line | Data |
---|---|---|
4ed7af08 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/generic/dataview.h | |
3 | // Purpose: wxDataViewCtrl generic implementation header | |
4 | // Author: Robert Roebling | |
b7e9f8b1 | 5 | // Modified By: Bo Yang |
4ed7af08 RR |
6 | // Id: $Id$ |
7 | // Copyright: (c) 1998 Robert Roebling | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef __GENERICDATAVIEWCTRLH__ | |
12 | #define __GENERICDATAVIEWCTRLH__ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | #include "wx/object.h" | |
16 | #include "wx/list.h" | |
17 | #include "wx/control.h" | |
9d14de69 | 18 | #include "wx/scrolwin.h" |
2586d4a1 | 19 | #include "wx/icon.h" |
4ed7af08 | 20 | |
f554a14b | 21 | // --------------------------------------------------------- |
4ed7af08 | 22 | // classes |
f554a14b | 23 | // --------------------------------------------------------- |
4ed7af08 | 24 | |
b5dbe15d VS |
25 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; |
26 | class WXDLLIMPEXP_FWD_ADV wxDataViewMainWindow; | |
27 | class WXDLLIMPEXP_FWD_ADV wxDataViewHeaderWindow; | |
4ed7af08 | 28 | |
f554a14b | 29 | // --------------------------------------------------------- |
baa9ebc4 | 30 | // wxDataViewRenderer |
f554a14b | 31 | // --------------------------------------------------------- |
4ed7af08 | 32 | |
baa9ebc4 | 33 | class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase |
4ed7af08 RR |
34 | { |
35 | public: | |
e2bfe673 | 36 | wxDataViewRenderer( const wxString &varianttype, |
9861f022 RR |
37 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
38 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 39 | virtual ~wxDataViewRenderer(); |
4ed7af08 | 40 | |
3d9d7cc4 | 41 | virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0; |
9861f022 RR |
42 | virtual wxSize GetSize() const = 0; |
43 | ||
e51bf699 RR |
44 | virtual void SetAlignment( int align ); |
45 | virtual int GetAlignment() const; | |
9861f022 RR |
46 | |
47 | virtual void SetMode( wxDataViewCellMode mode ) | |
48 | { m_mode=mode; } | |
49 | virtual wxDataViewCellMode GetMode() const | |
50 | { return m_mode; } | |
f554a14b WS |
51 | |
52 | virtual bool Activate( wxRect WXUNUSED(cell), | |
aba9bfd0 | 53 | wxDataViewModel *WXUNUSED(model), |
e2bfe673 | 54 | const wxDataViewItem & WXUNUSED(item), |
aba9bfd0 | 55 | unsigned int WXUNUSED(col) ) |
3d9d7cc4 | 56 | { return false; } |
f554a14b WS |
57 | |
58 | virtual bool LeftClick( wxPoint WXUNUSED(cursor), | |
59 | wxRect WXUNUSED(cell), | |
aba9bfd0 | 60 | wxDataViewModel *WXUNUSED(model), |
e2bfe673 | 61 | const wxDataViewItem & WXUNUSED(item), |
aba9bfd0 | 62 | unsigned int WXUNUSED(col) ) |
f554a14b WS |
63 | { return false; } |
64 | virtual bool RightClick( wxPoint WXUNUSED(cursor), | |
65 | wxRect WXUNUSED(cell), | |
aba9bfd0 | 66 | wxDataViewModel *WXUNUSED(model), |
e2bfe673 | 67 | const wxDataViewItem & WXUNUSED(item), |
aba9bfd0 | 68 | unsigned int WXUNUSED(col) ) |
f554a14b WS |
69 | { return false; } |
70 | virtual bool StartDrag( wxPoint WXUNUSED(cursor), | |
71 | wxRect WXUNUSED(cell), | |
aba9bfd0 | 72 | wxDataViewModel *WXUNUSED(model), |
e2bfe673 | 73 | const wxDataViewItem & WXUNUSED(item), |
aba9bfd0 | 74 | unsigned int WXUNUSED(col) ) |
f554a14b WS |
75 | { return false; } |
76 | ||
3d9d7cc4 RR |
77 | // Create DC on request |
78 | virtual wxDC *GetDC(); | |
e2bfe673 | 79 | |
4264606e RR |
80 | void SetHasAttr( bool set ) { m_hasAttr = set; } |
81 | void SetAttr( const wxDataViewItemAttr &attr ) { m_attr = attr; } | |
bc4f1ff2 | 82 | bool GetWantsAttr() const { return m_wantsAttr; } |
f554a14b | 83 | |
e51bf699 RR |
84 | // implementation |
85 | int CalculateAlignment() const; | |
86 | ||
3d9d7cc4 | 87 | private: |
99d471a5 RR |
88 | wxDC *m_dc; |
89 | int m_align; | |
90 | wxDataViewCellMode m_mode; | |
e2bfe673 | 91 | |
4264606e RR |
92 | protected: |
93 | bool m_wantsAttr; | |
94 | bool m_hasAttr; | |
95 | wxDataViewItemAttr m_attr; | |
f554a14b | 96 | |
4ed7af08 | 97 | protected: |
baa9ebc4 | 98 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) |
4ed7af08 | 99 | }; |
f554a14b WS |
100 | |
101 | // --------------------------------------------------------- | |
baa9ebc4 | 102 | // wxDataViewCustomRenderer |
f554a14b | 103 | // --------------------------------------------------------- |
4ed7af08 | 104 | |
baa9ebc4 | 105 | class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer |
4ed7af08 RR |
106 | { |
107 | public: | |
baa9ebc4 | 108 | wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"), |
9861f022 RR |
109 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
110 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
f554a14b | 111 | |
52e750fc RR |
112 | void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ); |
113 | ||
4ed7af08 | 114 | protected: |
baa9ebc4 | 115 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) |
4ed7af08 | 116 | }; |
f554a14b | 117 | |
99d471a5 | 118 | |
f554a14b | 119 | // --------------------------------------------------------- |
baa9ebc4 | 120 | // wxDataViewTextRenderer |
f554a14b | 121 | // --------------------------------------------------------- |
4ed7af08 | 122 | |
baa9ebc4 | 123 | class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
124 | { |
125 | public: | |
baa9ebc4 | 126 | wxDataViewTextRenderer( const wxString &varianttype = wxT("string"), |
9861f022 RR |
127 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
128 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
4ed7af08 RR |
129 | |
130 | bool SetValue( const wxVariant &value ); | |
9861f022 | 131 | bool GetValue( wxVariant &value ) const; |
f554a14b | 132 | |
3d9d7cc4 | 133 | bool Render( wxRect cell, wxDC *dc, int state ); |
9861f022 | 134 | wxSize GetSize() const; |
f554a14b | 135 | |
99d471a5 | 136 | // in-place editing |
bc4f1ff2 | 137 | virtual bool HasEditorCtrl() const; |
03647350 | 138 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, |
bc4f1ff2 | 139 | const wxVariant &value ); |
99d471a5 | 140 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); |
e2bfe673 | 141 | |
4264606e | 142 | protected: |
99d471a5 | 143 | wxString m_text; |
f554a14b | 144 | |
4ed7af08 | 145 | protected: |
baa9ebc4 | 146 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) |
4ed7af08 | 147 | }; |
f554a14b | 148 | |
4264606e RR |
149 | // --------------------------------------------------------- |
150 | // wxDataViewTextRendererAttr | |
151 | // --------------------------------------------------------- | |
152 | ||
153 | class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer | |
154 | { | |
155 | public: | |
156 | wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"), | |
157 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
158 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
159 | ||
160 | bool Render( wxRect cell, wxDC *dc, int state ); | |
e2bfe673 | 161 | |
4264606e RR |
162 | protected: |
163 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr) | |
164 | }; | |
165 | ||
2586d4a1 | 166 | // --------------------------------------------------------- |
baa9ebc4 | 167 | // wxDataViewBitmapRenderer |
2586d4a1 RR |
168 | // --------------------------------------------------------- |
169 | ||
baa9ebc4 | 170 | class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewCustomRenderer |
2586d4a1 RR |
171 | { |
172 | public: | |
baa9ebc4 | 173 | wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"), |
9861f022 RR |
174 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
175 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
2586d4a1 RR |
176 | |
177 | bool SetValue( const wxVariant &value ); | |
9861f022 | 178 | bool GetValue( wxVariant &value ) const; |
2586d4a1 RR |
179 | |
180 | bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 181 | wxSize GetSize() const; |
2586d4a1 RR |
182 | |
183 | private: | |
184 | wxIcon m_icon; | |
185 | wxBitmap m_bitmap; | |
186 | ||
187 | protected: | |
baa9ebc4 | 188 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) |
2586d4a1 RR |
189 | }; |
190 | ||
f554a14b | 191 | // --------------------------------------------------------- |
baa9ebc4 | 192 | // wxDataViewToggleRenderer |
f554a14b | 193 | // --------------------------------------------------------- |
4ed7af08 | 194 | |
baa9ebc4 | 195 | class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
196 | { |
197 | public: | |
baa9ebc4 | 198 | wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"), |
9861f022 RR |
199 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
200 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
3d9d7cc4 RR |
201 | |
202 | bool SetValue( const wxVariant &value ); | |
9861f022 | 203 | bool GetValue( wxVariant &value ) const; |
f554a14b | 204 | |
3d9d7cc4 | 205 | bool Render( wxRect cell, wxDC *dc, int state ); |
e2bfe673 | 206 | bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item, |
aba9bfd0 | 207 | unsigned int col ); |
9861f022 | 208 | wxSize GetSize() const; |
f554a14b | 209 | |
90675b95 RR |
210 | private: |
211 | bool m_toggle; | |
f554a14b | 212 | |
4ed7af08 | 213 | protected: |
baa9ebc4 | 214 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) |
4ed7af08 | 215 | }; |
f554a14b WS |
216 | |
217 | // --------------------------------------------------------- | |
baa9ebc4 | 218 | // wxDataViewProgressRenderer |
f554a14b | 219 | // --------------------------------------------------------- |
4ed7af08 | 220 | |
baa9ebc4 | 221 | class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
222 | { |
223 | public: | |
baa9ebc4 RR |
224 | wxDataViewProgressRenderer( const wxString &label = wxEmptyString, |
225 | const wxString &varianttype = wxT("long"), | |
9861f022 RR |
226 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
227 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 228 | virtual ~wxDataViewProgressRenderer(); |
f554a14b | 229 | |
4ed7af08 | 230 | bool SetValue( const wxVariant &value ); |
9861f022 | 231 | bool GetValue( wxVariant& value ) const; |
f554a14b | 232 | |
4ed7af08 | 233 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
9861f022 | 234 | virtual wxSize GetSize() const; |
f554a14b | 235 | |
4ed7af08 RR |
236 | private: |
237 | wxString m_label; | |
238 | int m_value; | |
f554a14b | 239 | |
4ed7af08 | 240 | protected: |
baa9ebc4 | 241 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) |
4ed7af08 | 242 | }; |
e2bfe673 VZ |
243 | |
244 | // --------------------------------------------------------- | |
24c4a50f | 245 | // wxDataViewIconTextRenderer |
e2bfe673 | 246 | // --------------------------------------------------------- |
24c4a50f | 247 | |
5cfb6fee | 248 | class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer |
24c4a50f RR |
249 | { |
250 | public: | |
e2bfe673 | 251 | wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), |
24c4a50f RR |
252 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
253 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
254 | virtual ~wxDataViewIconTextRenderer(); | |
e2bfe673 | 255 | |
24c4a50f RR |
256 | bool SetValue( const wxVariant &value ); |
257 | bool GetValue( wxVariant &value ) const; | |
e2bfe673 | 258 | |
24c4a50f RR |
259 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
260 | virtual wxSize GetSize() const; | |
e2bfe673 | 261 | |
220bfe15 | 262 | virtual bool HasEditorCtrl() const { return true; } |
03647350 | 263 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, |
bc4f1ff2 | 264 | const wxVariant &value ); |
24c4a50f | 265 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); |
e2bfe673 | 266 | |
24c4a50f RR |
267 | private: |
268 | wxDataViewIconText m_value; | |
e2bfe673 | 269 | |
24c4a50f RR |
270 | protected: |
271 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) | |
272 | }; | |
f554a14b WS |
273 | |
274 | // --------------------------------------------------------- | |
baa9ebc4 | 275 | // wxDataViewDateRenderer |
f554a14b | 276 | // --------------------------------------------------------- |
4ed7af08 | 277 | |
baa9ebc4 | 278 | class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
279 | { |
280 | public: | |
baa9ebc4 | 281 | wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"), |
9861f022 RR |
282 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
283 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
f554a14b | 284 | |
4ed7af08 | 285 | bool SetValue( const wxVariant &value ); |
9861f022 | 286 | bool GetValue( wxVariant& value ) const; |
f554a14b | 287 | |
4ed7af08 | 288 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
9861f022 | 289 | virtual wxSize GetSize() const; |
4ed7af08 | 290 | virtual bool Activate( wxRect cell, |
03647350 VZ |
291 | wxDataViewModel *model, |
292 | const wxDataViewItem& item, | |
bc4f1ff2 | 293 | unsigned int col ); |
f554a14b | 294 | |
4ed7af08 RR |
295 | private: |
296 | wxDateTime m_date; | |
f554a14b | 297 | |
4ed7af08 | 298 | protected: |
baa9ebc4 | 299 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) |
4ed7af08 | 300 | }; |
f554a14b WS |
301 | |
302 | // --------------------------------------------------------- | |
4ed7af08 | 303 | // wxDataViewColumn |
f554a14b | 304 | // --------------------------------------------------------- |
4ed7af08 | 305 | |
56873923 | 306 | class WXDLLIMPEXP_ADV wxDataViewColumn : public wxDataViewColumnBase |
4ed7af08 RR |
307 | { |
308 | public: | |
e2bfe673 VZ |
309 | wxDataViewColumn(const wxString& title, |
310 | wxDataViewRenderer *renderer, | |
311 | unsigned int model_column, | |
312 | int width = wxDVC_DEFAULT_WIDTH, | |
313 | wxAlignment align = wxALIGN_CENTER, | |
314 | int flags = wxDATAVIEW_COL_RESIZABLE) | |
315 | : wxDataViewColumnBase(renderer, model_column), | |
316 | m_title(title) | |
317 | { | |
318 | Init(width, align, flags); | |
319 | } | |
320 | ||
321 | wxDataViewColumn(const wxBitmap& bitmap, | |
322 | wxDataViewRenderer *renderer, | |
323 | unsigned int model_column, | |
324 | int width = wxDVC_DEFAULT_WIDTH, | |
325 | wxAlignment align = wxALIGN_CENTER, | |
326 | int flags = wxDATAVIEW_COL_RESIZABLE) | |
327 | : wxDataViewColumnBase(bitmap, renderer, model_column) | |
328 | { | |
329 | Init(width, align, flags); | |
330 | } | |
331 | ||
332 | // implement wxHeaderColumnBase methods | |
333 | virtual void SetTitle(const wxString& title) { m_title = title; } | |
334 | virtual wxString GetTitle() const { return m_title; } | |
335 | ||
336 | virtual void SetWidth(int width) { m_width = width; } | |
337 | virtual int GetWidth() const { return m_width; } | |
338 | ||
339 | virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; } | |
340 | virtual int GetMinWidth() const { return m_minWidth; } | |
341 | ||
342 | virtual void SetAlignment(wxAlignment align) { m_align = align; } | |
343 | virtual wxAlignment GetAlignment() const { return m_align; } | |
344 | ||
345 | virtual void SetFlags(int flags) { m_flags = flags; } | |
346 | virtual int GetFlags() const { return m_flags; } | |
347 | ||
348 | virtual void SetAsSortKey(bool sort = true) { m_sort = sort; } | |
349 | virtual bool IsSortKey() const { return m_sort; } | |
350 | ||
351 | virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; } | |
352 | virtual bool IsSortOrderAscending() const { return m_sortAscending; } | |
4ed7af08 | 353 | |
56873923 | 354 | private: |
e2bfe673 VZ |
355 | // common part of all ctors |
356 | void Init(int width, wxAlignment align, int flags) | |
357 | { | |
358 | m_width = width == wxCOL_WIDTH_DEFAULT ? wxDVC_DEFAULT_WIDTH : width; | |
359 | m_minWidth = 0; | |
360 | m_align = align; | |
361 | m_flags = flags; | |
362 | m_sort = false; | |
363 | m_sortAscending = true; | |
364 | } | |
365 | ||
e2bfe673 VZ |
366 | wxString m_title; |
367 | int m_width, | |
368 | m_minWidth; | |
369 | wxAlignment m_align; | |
370 | int m_flags; | |
371 | bool m_sort, | |
372 | m_sortAscending; | |
373 | ||
56873923 VZ |
374 | friend class wxDataViewHeaderWindowBase; |
375 | friend class wxDataViewHeaderWindow; | |
376 | friend class wxDataViewHeaderWindowMSW; | |
4ed7af08 RR |
377 | }; |
378 | ||
f554a14b | 379 | // --------------------------------------------------------- |
4ed7af08 | 380 | // wxDataViewCtrl |
f554a14b | 381 | // --------------------------------------------------------- |
4ed7af08 | 382 | |
4660b556 VZ |
383 | WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, |
384 | class WXDLLIMPEXP_ADV); | |
afebb87b | 385 | |
938161a6 VZ |
386 | class WXDLLIMPEXP_ADV wxDataViewCtrl : public wxDataViewCtrlBase, |
387 | public wxScrollHelper | |
4ed7af08 | 388 | { |
87f0efe2 RR |
389 | friend class wxDataViewMainWindow; |
390 | friend class wxDataViewHeaderWindowBase; | |
391 | friend class wxDataViewHeaderWindow; | |
392 | friend class wxDataViewHeaderWindowMSW; | |
9861f022 | 393 | friend class wxDataViewColumn; |
87f0efe2 | 394 | |
4ed7af08 | 395 | public: |
938161a6 | 396 | wxDataViewCtrl() : wxScrollHelper(this) |
4ed7af08 RR |
397 | { |
398 | Init(); | |
399 | } | |
f554a14b | 400 | |
4ed7af08 RR |
401 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, |
402 | const wxPoint& pos = wxDefaultPosition, | |
403 | const wxSize& size = wxDefaultSize, long style = 0, | |
f554a14b | 404 | const wxValidator& validator = wxDefaultValidator ) |
938161a6 | 405 | : wxScrollHelper(this) |
4ed7af08 RR |
406 | { |
407 | Create(parent, id, pos, size, style, validator ); | |
408 | } | |
409 | ||
410 | virtual ~wxDataViewCtrl(); | |
411 | ||
412 | void Init(); | |
413 | ||
414 | bool Create(wxWindow *parent, wxWindowID id, | |
bc4f1ff2 FM |
415 | const wxPoint& pos = wxDefaultPosition, |
416 | const wxSize& size = wxDefaultSize, long style = 0, | |
417 | const wxValidator& validator = wxDefaultValidator ); | |
4ed7af08 | 418 | |
aba9bfd0 | 419 | virtual bool AssociateModel( wxDataViewModel *model ); |
e2bfe673 | 420 | |
4ed7af08 | 421 | virtual bool AppendColumn( wxDataViewColumn *col ); |
736fe67c | 422 | virtual bool PrependColumn( wxDataViewColumn *col ); |
19723525 | 423 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
f554a14b | 424 | |
3b6280be RR |
425 | virtual void DoSetExpanderColumn(); |
426 | virtual void DoSetIndent(); | |
427 | ||
afebb87b RR |
428 | virtual unsigned int GetColumnCount() const; |
429 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; | |
430 | virtual bool DeleteColumn( wxDataViewColumn *column ); | |
431 | virtual bool ClearColumns(); | |
453091c2 | 432 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const; |
afebb87b | 433 | |
21f47fb9 | 434 | virtual wxDataViewColumn *GetSortingColumn() const; |
e2bfe673 | 435 | |
fbda518c | 436 | virtual wxDataViewItem GetSelection() const; |
b7e9f8b1 RR |
437 | virtual int GetSelections( wxDataViewItemArray & sel ) const; |
438 | virtual void SetSelections( const wxDataViewItemArray & sel ); | |
439 | virtual void Select( const wxDataViewItem & item ); | |
440 | virtual void Unselect( const wxDataViewItem & item ); | |
441 | virtual bool IsSelected( const wxDataViewItem & item ) const; | |
442 | ||
66e09788 RR |
443 | virtual void SelectAll(); |
444 | virtual void UnselectAll(); | |
445 | ||
446 | virtual void EnsureVisible( const wxDataViewItem & item, | |
fbda518c | 447 | const wxDataViewColumn *column = NULL ); |
03647350 | 448 | virtual void HitTest( const wxPoint & point, wxDataViewItem & item, |
bc4f1ff2 | 449 | wxDataViewColumn* &column ) const; |
03647350 | 450 | virtual wxRect GetItemRect( const wxDataViewItem & item, |
bc4f1ff2 | 451 | const wxDataViewColumn *column = NULL ) const; |
66e09788 | 452 | |
afebb87b RR |
453 | virtual void Expand( const wxDataViewItem & item ); |
454 | virtual void Collapse( const wxDataViewItem & item ); | |
739a8399 | 455 | virtual bool IsExpanded( const wxDataViewItem & item ) const; |
e2bfe673 | 456 | |
788432e3 | 457 | virtual void SetFocus(); |
9adeb77a VZ |
458 | |
459 | #if wxUSE_DRAG_AND_DROP | |
821baf7d RR |
460 | virtual bool EnableDragSource( const wxDataFormat &format ); |
461 | virtual bool EnableDropTarget( const wxDataFormat &format ); | |
9adeb77a | 462 | #endif // wxUSE_DRAG_AND_DROP |
afebb87b | 463 | |
3fdf86f9 RR |
464 | virtual wxBorder GetDefaultBorder() const; |
465 | ||
c937344c RR |
466 | void StartEditor( const wxDataViewItem & item, unsigned int column ); |
467 | ||
66e09788 | 468 | protected: |
e2bfe673 | 469 | virtual int GetSelections( wxArrayInt & sel ) const; |
b7e9f8b1 RR |
470 | virtual void SetSelections( const wxArrayInt & sel ); |
471 | virtual void Select( int row ); | |
472 | virtual void Unselect( int row ); | |
473 | virtual bool IsSelected( int row ) const; | |
474 | virtual void SelectRange( int from, int to ); | |
475 | virtual void UnselectRange( int from, int to ); | |
476 | ||
fbda518c | 477 | virtual void EnsureVisible( int row, int column ); |
b7e9f8b1 RR |
478 | |
479 | virtual wxDataViewItem GetItemByRow( unsigned int row ) const; | |
480 | virtual int GetRowByItem( const wxDataViewItem & item ) const; | |
481 | ||
46234a03 VZ |
482 | int GetSortingColumnIndex() const { return m_sortingColumnIdx; } |
483 | void SetSortingColumnIndex(int idx) { m_sortingColumnIdx = idx; } | |
6ff7eee7 | 484 | |
9861f022 RR |
485 | public: // utility functions not part of the API |
486 | ||
87f0efe2 | 487 | // returns the "best" width for the idx-th column |
9861f022 | 488 | unsigned int GetBestColumnWidth(int WXUNUSED(idx)) const |
87f0efe2 | 489 | { |
9861f022 | 490 | return GetClientSize().GetWidth() / GetColumnCount(); |
87f0efe2 RR |
491 | } |
492 | ||
fc8c1a15 RR |
493 | // called by header window after reorder |
494 | void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos ); | |
495 | ||
aef252d9 VZ |
496 | // update the display after a change to an individual column |
497 | void OnColumnChange(unsigned int idx); | |
498 | ||
499 | // update after a change to the number of columns | |
500 | void OnColumnsCountChanged(); | |
87f0efe2 | 501 | |
1e510b1e | 502 | wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; } |
99d471a5 | 503 | |
702f5349 VZ |
504 | // return the index of the given column in m_cols |
505 | int GetColumnIndex(const wxDataViewColumn *column) const; | |
506 | ||
507 | // return the column displayed at the given position in the control | |
508 | wxDataViewColumn *GetColumnAt(unsigned int pos) const; | |
509 | ||
4ed7af08 | 510 | private: |
ad386793 RR |
511 | wxDataViewColumnList m_cols; |
512 | wxDataViewModelNotifier *m_notifier; | |
513 | wxDataViewMainWindow *m_clientArea; | |
514 | wxDataViewHeaderWindow *m_headerArea; | |
46234a03 VZ |
515 | |
516 | // the index of the column currently used for sorting or -1 | |
517 | int m_sortingColumnIdx; | |
f554a14b | 518 | |
4ed7af08 | 519 | private: |
4b3feaa7 | 520 | void OnSize( wxSizeEvent &event ); |
2571a33f | 521 | virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); |
f554a14b | 522 | |
4ed7af08 RR |
523 | // we need to return a special WM_GETDLGCODE value to process just the |
524 | // arrows but let the other navigation characters through | |
525 | #ifdef __WXMSW__ | |
526 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
527 | #endif // __WXMSW__ | |
528 | ||
529 | WX_FORWARD_TO_SCROLL_HELPER() | |
4b3feaa7 | 530 | |
4ed7af08 RR |
531 | private: |
532 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) | |
c0c133e1 | 533 | wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl); |
4b3feaa7 | 534 | DECLARE_EVENT_TABLE() |
4ed7af08 RR |
535 | }; |
536 | ||
537 | ||
538 | #endif // __GENERICDATAVIEWCTRLH__ |