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