]>
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; } | |
82 | bool GetWantsAttr() { 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 RR |
136 | // in-place editing |
137 | virtual bool HasEditorCtrl(); | |
138 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
139 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
e2bfe673 | 140 | |
4264606e | 141 | protected: |
99d471a5 | 142 | wxString m_text; |
f554a14b | 143 | |
4ed7af08 | 144 | protected: |
baa9ebc4 | 145 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) |
4ed7af08 | 146 | }; |
f554a14b | 147 | |
4264606e RR |
148 | // --------------------------------------------------------- |
149 | // wxDataViewTextRendererAttr | |
150 | // --------------------------------------------------------- | |
151 | ||
152 | class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer | |
153 | { | |
154 | public: | |
155 | wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"), | |
156 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
157 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
158 | ||
159 | bool Render( wxRect cell, wxDC *dc, int state ); | |
e2bfe673 | 160 | |
4264606e RR |
161 | protected: |
162 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr) | |
163 | }; | |
164 | ||
2586d4a1 | 165 | // --------------------------------------------------------- |
baa9ebc4 | 166 | // wxDataViewBitmapRenderer |
2586d4a1 RR |
167 | // --------------------------------------------------------- |
168 | ||
baa9ebc4 | 169 | class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewCustomRenderer |
2586d4a1 RR |
170 | { |
171 | public: | |
baa9ebc4 | 172 | wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"), |
9861f022 RR |
173 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
174 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
2586d4a1 RR |
175 | |
176 | bool SetValue( const wxVariant &value ); | |
9861f022 | 177 | bool GetValue( wxVariant &value ) const; |
2586d4a1 RR |
178 | |
179 | bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 180 | wxSize GetSize() const; |
2586d4a1 RR |
181 | |
182 | private: | |
183 | wxIcon m_icon; | |
184 | wxBitmap m_bitmap; | |
185 | ||
186 | protected: | |
baa9ebc4 | 187 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) |
2586d4a1 RR |
188 | }; |
189 | ||
f554a14b | 190 | // --------------------------------------------------------- |
baa9ebc4 | 191 | // wxDataViewToggleRenderer |
f554a14b | 192 | // --------------------------------------------------------- |
4ed7af08 | 193 | |
baa9ebc4 | 194 | class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
195 | { |
196 | public: | |
baa9ebc4 | 197 | wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"), |
9861f022 RR |
198 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
199 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
3d9d7cc4 RR |
200 | |
201 | bool SetValue( const wxVariant &value ); | |
9861f022 | 202 | bool GetValue( wxVariant &value ) const; |
f554a14b | 203 | |
3d9d7cc4 | 204 | bool Render( wxRect cell, wxDC *dc, int state ); |
e2bfe673 | 205 | bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item, |
aba9bfd0 | 206 | unsigned int col ); |
9861f022 | 207 | wxSize GetSize() const; |
f554a14b | 208 | |
90675b95 RR |
209 | private: |
210 | bool m_toggle; | |
f554a14b | 211 | |
4ed7af08 | 212 | protected: |
baa9ebc4 | 213 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) |
4ed7af08 | 214 | }; |
f554a14b WS |
215 | |
216 | // --------------------------------------------------------- | |
baa9ebc4 | 217 | // wxDataViewProgressRenderer |
f554a14b | 218 | // --------------------------------------------------------- |
4ed7af08 | 219 | |
baa9ebc4 | 220 | class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
221 | { |
222 | public: | |
baa9ebc4 RR |
223 | wxDataViewProgressRenderer( const wxString &label = wxEmptyString, |
224 | const wxString &varianttype = wxT("long"), | |
9861f022 RR |
225 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
226 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 227 | virtual ~wxDataViewProgressRenderer(); |
f554a14b | 228 | |
4ed7af08 | 229 | bool SetValue( const wxVariant &value ); |
9861f022 | 230 | bool GetValue( wxVariant& value ) const; |
f554a14b | 231 | |
4ed7af08 | 232 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
9861f022 | 233 | virtual wxSize GetSize() const; |
f554a14b | 234 | |
4ed7af08 RR |
235 | private: |
236 | wxString m_label; | |
237 | int m_value; | |
f554a14b | 238 | |
4ed7af08 | 239 | protected: |
baa9ebc4 | 240 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) |
4ed7af08 | 241 | }; |
e2bfe673 VZ |
242 | |
243 | // --------------------------------------------------------- | |
24c4a50f | 244 | // wxDataViewIconTextRenderer |
e2bfe673 | 245 | // --------------------------------------------------------- |
24c4a50f | 246 | |
5cfb6fee | 247 | class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer |
24c4a50f RR |
248 | { |
249 | public: | |
e2bfe673 | 250 | wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), |
24c4a50f RR |
251 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
252 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
253 | virtual ~wxDataViewIconTextRenderer(); | |
e2bfe673 | 254 | |
24c4a50f RR |
255 | bool SetValue( const wxVariant &value ); |
256 | bool GetValue( wxVariant &value ) const; | |
e2bfe673 | 257 | |
24c4a50f RR |
258 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
259 | virtual wxSize GetSize() const; | |
e2bfe673 | 260 | |
24c4a50f RR |
261 | virtual bool HasEditorCtrl() { return true; } |
262 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
263 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
e2bfe673 | 264 | |
24c4a50f RR |
265 | private: |
266 | wxDataViewIconText m_value; | |
e2bfe673 | 267 | |
24c4a50f RR |
268 | protected: |
269 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) | |
270 | }; | |
f554a14b WS |
271 | |
272 | // --------------------------------------------------------- | |
baa9ebc4 | 273 | // wxDataViewDateRenderer |
f554a14b | 274 | // --------------------------------------------------------- |
4ed7af08 | 275 | |
baa9ebc4 | 276 | class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer |
4ed7af08 RR |
277 | { |
278 | public: | |
baa9ebc4 | 279 | wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"), |
9861f022 RR |
280 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
281 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
f554a14b | 282 | |
4ed7af08 | 283 | bool SetValue( const wxVariant &value ); |
9861f022 | 284 | bool GetValue( wxVariant& value ) const; |
f554a14b | 285 | |
4ed7af08 | 286 | virtual bool Render( wxRect cell, wxDC *dc, int state ); |
9861f022 | 287 | virtual wxSize GetSize() const; |
4ed7af08 | 288 | virtual bool Activate( wxRect cell, |
aba9bfd0 | 289 | wxDataViewModel *model, const wxDataViewItem & item, unsigned int col ); |
f554a14b | 290 | |
4ed7af08 RR |
291 | private: |
292 | wxDateTime m_date; | |
f554a14b | 293 | |
4ed7af08 | 294 | protected: |
baa9ebc4 | 295 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) |
4ed7af08 | 296 | }; |
f554a14b WS |
297 | |
298 | // --------------------------------------------------------- | |
4ed7af08 | 299 | // wxDataViewColumn |
f554a14b | 300 | // --------------------------------------------------------- |
4ed7af08 | 301 | |
56873923 | 302 | class WXDLLIMPEXP_ADV wxDataViewColumn : public wxDataViewColumnBase |
4ed7af08 RR |
303 | { |
304 | public: | |
e2bfe673 VZ |
305 | wxDataViewColumn(const wxString& title, |
306 | wxDataViewRenderer *renderer, | |
307 | unsigned int model_column, | |
308 | int width = wxDVC_DEFAULT_WIDTH, | |
309 | wxAlignment align = wxALIGN_CENTER, | |
310 | int flags = wxDATAVIEW_COL_RESIZABLE) | |
311 | : wxDataViewColumnBase(renderer, model_column), | |
312 | m_title(title) | |
313 | { | |
314 | Init(width, align, flags); | |
315 | } | |
316 | ||
317 | wxDataViewColumn(const wxBitmap& bitmap, | |
318 | wxDataViewRenderer *renderer, | |
319 | unsigned int model_column, | |
320 | int width = wxDVC_DEFAULT_WIDTH, | |
321 | wxAlignment align = wxALIGN_CENTER, | |
322 | int flags = wxDATAVIEW_COL_RESIZABLE) | |
323 | : wxDataViewColumnBase(bitmap, renderer, model_column) | |
324 | { | |
325 | Init(width, align, flags); | |
326 | } | |
327 | ||
328 | // implement wxHeaderColumnBase methods | |
329 | virtual void SetTitle(const wxString& title) { m_title = title; } | |
330 | virtual wxString GetTitle() const { return m_title; } | |
331 | ||
332 | virtual void SetWidth(int width) { m_width = width; } | |
333 | virtual int GetWidth() const { return m_width; } | |
334 | ||
335 | virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; } | |
336 | virtual int GetMinWidth() const { return m_minWidth; } | |
337 | ||
338 | virtual void SetAlignment(wxAlignment align) { m_align = align; } | |
339 | virtual wxAlignment GetAlignment() const { return m_align; } | |
340 | ||
341 | virtual void SetFlags(int flags) { m_flags = flags; } | |
342 | virtual int GetFlags() const { return m_flags; } | |
343 | ||
344 | virtual void SetAsSortKey(bool sort = true) { m_sort = sort; } | |
345 | virtual bool IsSortKey() const { return m_sort; } | |
346 | ||
347 | virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; } | |
348 | virtual bool IsSortOrderAscending() const { return m_sortAscending; } | |
4ed7af08 | 349 | |
56873923 | 350 | private: |
e2bfe673 VZ |
351 | // common part of all ctors |
352 | void Init(int width, wxAlignment align, int flags) | |
353 | { | |
354 | m_width = width == wxCOL_WIDTH_DEFAULT ? wxDVC_DEFAULT_WIDTH : width; | |
355 | m_minWidth = 0; | |
356 | m_align = align; | |
357 | m_flags = flags; | |
358 | m_sort = false; | |
359 | m_sortAscending = true; | |
360 | } | |
361 | ||
e2bfe673 VZ |
362 | wxString m_title; |
363 | int m_width, | |
364 | m_minWidth; | |
365 | wxAlignment m_align; | |
366 | int m_flags; | |
367 | bool m_sort, | |
368 | m_sortAscending; | |
369 | ||
56873923 VZ |
370 | friend class wxDataViewHeaderWindowBase; |
371 | friend class wxDataViewHeaderWindow; | |
372 | friend class wxDataViewHeaderWindowMSW; | |
4ed7af08 RR |
373 | }; |
374 | ||
f554a14b | 375 | // --------------------------------------------------------- |
4ed7af08 | 376 | // wxDataViewCtrl |
f554a14b | 377 | // --------------------------------------------------------- |
4ed7af08 | 378 | |
4660b556 VZ |
379 | WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, |
380 | class WXDLLIMPEXP_ADV); | |
afebb87b | 381 | |
938161a6 VZ |
382 | class WXDLLIMPEXP_ADV wxDataViewCtrl : public wxDataViewCtrlBase, |
383 | public wxScrollHelper | |
4ed7af08 | 384 | { |
87f0efe2 RR |
385 | friend class wxDataViewMainWindow; |
386 | friend class wxDataViewHeaderWindowBase; | |
387 | friend class wxDataViewHeaderWindow; | |
388 | friend class wxDataViewHeaderWindowMSW; | |
9861f022 | 389 | friend class wxDataViewColumn; |
87f0efe2 | 390 | |
4ed7af08 | 391 | public: |
938161a6 | 392 | wxDataViewCtrl() : wxScrollHelper(this) |
4ed7af08 RR |
393 | { |
394 | Init(); | |
395 | } | |
f554a14b | 396 | |
4ed7af08 RR |
397 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, |
398 | const wxPoint& pos = wxDefaultPosition, | |
399 | const wxSize& size = wxDefaultSize, long style = 0, | |
f554a14b | 400 | const wxValidator& validator = wxDefaultValidator ) |
938161a6 | 401 | : wxScrollHelper(this) |
4ed7af08 RR |
402 | { |
403 | Create(parent, id, pos, size, style, validator ); | |
404 | } | |
405 | ||
406 | virtual ~wxDataViewCtrl(); | |
407 | ||
408 | void Init(); | |
409 | ||
410 | bool Create(wxWindow *parent, wxWindowID id, | |
411 | const wxPoint& pos = wxDefaultPosition, | |
412 | const wxSize& size = wxDefaultSize, long style = 0, | |
413 | const wxValidator& validator = wxDefaultValidator ); | |
414 | ||
aba9bfd0 | 415 | virtual bool AssociateModel( wxDataViewModel *model ); |
e2bfe673 | 416 | |
4ed7af08 | 417 | virtual bool AppendColumn( wxDataViewColumn *col ); |
736fe67c | 418 | virtual bool PrependColumn( wxDataViewColumn *col ); |
19723525 | 419 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
f554a14b | 420 | |
3b6280be RR |
421 | virtual void DoSetExpanderColumn(); |
422 | virtual void DoSetIndent(); | |
423 | ||
afebb87b RR |
424 | virtual unsigned int GetColumnCount() const; |
425 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; | |
426 | virtual bool DeleteColumn( wxDataViewColumn *column ); | |
427 | virtual bool ClearColumns(); | |
453091c2 | 428 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const; |
afebb87b | 429 | |
21f47fb9 | 430 | virtual wxDataViewColumn *GetSortingColumn() const; |
e2bfe673 | 431 | |
fbda518c | 432 | virtual wxDataViewItem GetSelection() const; |
b7e9f8b1 RR |
433 | virtual int GetSelections( wxDataViewItemArray & sel ) const; |
434 | virtual void SetSelections( const wxDataViewItemArray & sel ); | |
435 | virtual void Select( const wxDataViewItem & item ); | |
436 | virtual void Unselect( const wxDataViewItem & item ); | |
437 | virtual bool IsSelected( const wxDataViewItem & item ) const; | |
438 | ||
66e09788 RR |
439 | virtual void SelectAll(); |
440 | virtual void UnselectAll(); | |
441 | ||
442 | virtual void EnsureVisible( const wxDataViewItem & item, | |
fbda518c | 443 | const wxDataViewColumn *column = NULL ); |
a87b466d | 444 | virtual void HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column ) const; |
fbda518c | 445 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const; |
66e09788 | 446 | |
afebb87b RR |
447 | virtual void Expand( const wxDataViewItem & item ); |
448 | virtual void Collapse( const wxDataViewItem & item ); | |
739a8399 | 449 | virtual bool IsExpanded( const wxDataViewItem & item ) const; |
e2bfe673 | 450 | |
788432e3 | 451 | virtual void SetFocus(); |
afebb87b | 452 | |
66e09788 | 453 | protected: |
e2bfe673 | 454 | virtual int GetSelections( wxArrayInt & sel ) const; |
b7e9f8b1 RR |
455 | virtual void SetSelections( const wxArrayInt & sel ); |
456 | virtual void Select( int row ); | |
457 | virtual void Unselect( int row ); | |
458 | virtual bool IsSelected( int row ) const; | |
459 | virtual void SelectRange( int from, int to ); | |
460 | virtual void UnselectRange( int from, int to ); | |
461 | ||
fbda518c | 462 | virtual void EnsureVisible( int row, int column ); |
b7e9f8b1 RR |
463 | |
464 | virtual wxDataViewItem GetItemByRow( unsigned int row ) const; | |
465 | virtual int GetRowByItem( const wxDataViewItem & item ) const; | |
466 | ||
46234a03 VZ |
467 | int GetSortingColumnIndex() const { return m_sortingColumnIdx; } |
468 | void SetSortingColumnIndex(int idx) { m_sortingColumnIdx = idx; } | |
6ff7eee7 | 469 | |
9861f022 RR |
470 | public: // utility functions not part of the API |
471 | ||
87f0efe2 | 472 | // returns the "best" width for the idx-th column |
9861f022 | 473 | unsigned int GetBestColumnWidth(int WXUNUSED(idx)) const |
87f0efe2 | 474 | { |
9861f022 | 475 | return GetClientSize().GetWidth() / GetColumnCount(); |
87f0efe2 RR |
476 | } |
477 | ||
fc8c1a15 RR |
478 | // called by header window after reorder |
479 | void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos ); | |
480 | ||
aef252d9 VZ |
481 | // update the display after a change to an individual column |
482 | void OnColumnChange(unsigned int idx); | |
483 | ||
484 | // update after a change to the number of columns | |
485 | void OnColumnsCountChanged(); | |
87f0efe2 | 486 | |
1e510b1e | 487 | wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; } |
99d471a5 | 488 | |
702f5349 VZ |
489 | // return the index of the given column in m_cols |
490 | int GetColumnIndex(const wxDataViewColumn *column) const; | |
491 | ||
492 | // return the column displayed at the given position in the control | |
493 | wxDataViewColumn *GetColumnAt(unsigned int pos) const; | |
494 | ||
4ed7af08 | 495 | private: |
ad386793 RR |
496 | wxDataViewColumnList m_cols; |
497 | wxDataViewModelNotifier *m_notifier; | |
498 | wxDataViewMainWindow *m_clientArea; | |
499 | wxDataViewHeaderWindow *m_headerArea; | |
46234a03 VZ |
500 | |
501 | // the index of the column currently used for sorting or -1 | |
502 | int m_sortingColumnIdx; | |
f554a14b | 503 | |
4ed7af08 | 504 | private: |
4b3feaa7 | 505 | void OnSize( wxSizeEvent &event ); |
2571a33f | 506 | virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); |
f554a14b | 507 | |
4ed7af08 RR |
508 | // we need to return a special WM_GETDLGCODE value to process just the |
509 | // arrows but let the other navigation characters through | |
510 | #ifdef __WXMSW__ | |
511 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
512 | #endif // __WXMSW__ | |
513 | ||
514 | WX_FORWARD_TO_SCROLL_HELPER() | |
4b3feaa7 | 515 | |
4ed7af08 RR |
516 | private: |
517 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) | |
518 | DECLARE_NO_COPY_CLASS(wxDataViewCtrl) | |
4b3feaa7 | 519 | DECLARE_EVENT_TABLE() |
4ed7af08 RR |
520 | }; |
521 | ||
522 | ||
523 | #endif // __GENERICDATAVIEWCTRLH__ |