]>
Commit | Line | Data |
---|---|---|
e86edab0 RR |
1 | |
2 | ///////////////////////////////////////////////////////////////////////////// | |
3 | // Name: wx/osx/dataview.h | |
4 | // Purpose: wxDataViewCtrl native implementation header for OSX | |
5 | // Author: | |
6 | // Id: $Id$ | |
7 | // Copyright: (c) 2009 | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_DATAVIEWCTRL_OSX_H_ | |
12 | #define _WX_DATAVIEWCTRL_OSX_H_ | |
13 | ||
5c6eb3a8 SC |
14 | #ifdef __WXMAC_CLASSIC__ |
15 | # error "Native wxDataViewCtrl for classic environment not defined. Please use generic control." | |
5c6eb3a8 | 16 | #endif |
e86edab0 RR |
17 | |
18 | // -------------------------------------------------------- | |
19 | // Class declarations to mask native types | |
20 | // -------------------------------------------------------- | |
21 | class wxDataViewColumnNativeData; // class storing environment dependent data for the native implementation | |
22 | class wxDataViewRendererNativeData; // class storing environment dependent data for the native renderer | |
23 | class wxDataViewWidgetImpl; // class used as a common interface for carbon and cocoa implementation | |
24 | ||
25 | // --------------------------------------------------------- | |
26 | // wxDataViewRenderer | |
27 | // --------------------------------------------------------- | |
28 | class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase | |
29 | { | |
30 | public: | |
31 | // | |
32 | // constructors / destructor | |
33 | // | |
34 | wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
03647350 | 35 | |
de40d736 | 36 | virtual ~wxDataViewRenderer(); |
e86edab0 RR |
37 | |
38 | // | |
39 | // inherited methods from wxDataViewRendererBase | |
40 | // | |
41 | virtual int GetAlignment() const | |
42 | { | |
de40d736 | 43 | return m_alignment; |
e86edab0 RR |
44 | } |
45 | virtual wxDataViewCellMode GetMode() const | |
46 | { | |
de40d736 | 47 | return m_mode; |
e86edab0 RR |
48 | } |
49 | virtual bool GetValue(wxVariant& value) const | |
50 | { | |
de40d736 | 51 | value = m_value; |
e86edab0 RR |
52 | return true; |
53 | } | |
54 | ||
55 | virtual void SetAlignment(int align); // carbon: is always identical to the header alignment; | |
56 | // cocoa: cell alignment is independent from header alignment | |
57 | virtual void SetMode(wxDataViewCellMode mode); | |
58 | virtual bool SetValue(wxVariant const& newValue) | |
59 | { | |
de40d736 | 60 | m_value = newValue; |
e86edab0 RR |
61 | return true; |
62 | } | |
63 | ||
c937bcac VZ |
64 | virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE); |
65 | virtual wxEllipsizeMode GetEllipsizeMode() const; | |
66 | ||
e86edab0 RR |
67 | // |
68 | // implementation | |
69 | // | |
70 | wxVariant const& GetValue() const | |
71 | { | |
de40d736 | 72 | return m_value; |
e86edab0 RR |
73 | } |
74 | ||
75 | wxDataViewRendererNativeData* GetNativeData() const | |
76 | { | |
de40d736 | 77 | return m_NativeDataPtr; |
e86edab0 RR |
78 | } |
79 | ||
8f2a8de6 | 80 | virtual bool MacRender() = 0; // a call to the native data browser function to render the data; |
e86edab0 RR |
81 | // returns true if the data value could be rendered, false otherwise |
82 | ||
83 | void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr); | |
84 | ||
0599fe19 VZ |
85 | |
86 | #if wxOSX_USE_COCOA | |
87 | // called when a value was edited by user | |
9461dd8c | 88 | virtual void OSXOnCellChanged(NSObject *value, |
0599fe19 VZ |
89 | const wxDataViewItem& item, |
90 | unsigned col); | |
91 | #endif // Cocoa | |
92 | ||
e86edab0 RR |
93 | private: |
94 | // | |
95 | // variables | |
96 | // | |
97 | int m_alignment; // contains the alignment flags | |
98 | ||
99 | wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown | |
100 | ||
101 | wxDataViewRendererNativeData* m_NativeDataPtr; // data used by implementation of the native renderer | |
102 | ||
103 | wxVariant m_value; // value that is going to be rendered | |
104 | ||
105 | // | |
106 | // wxWidget internal stuff | |
107 | // | |
108 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) | |
109 | }; | |
110 | ||
111 | // --------------------------------------------------------- | |
112 | // wxDataViewCustomRenderer | |
113 | // --------------------------------------------------------- | |
114 | class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer | |
115 | { | |
116 | public: | |
117 | // | |
118 | // constructors / destructor | |
119 | // | |
120 | wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
121 | ||
122 | virtual ~wxDataViewCustomRenderer(); | |
123 | ||
124 | void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ); | |
125 | ||
126 | // | |
127 | // methods handling render space | |
128 | // | |
129 | virtual wxSize GetSize() const = 0; | |
130 | ||
131 | // | |
132 | // methods handling user actions | |
133 | // | |
134 | virtual bool Render(wxRect cell, wxDC* dc, int state) = 0; | |
135 | ||
136 | virtual bool Activate( wxRect WXUNUSED(cell), | |
137 | wxDataViewModel *WXUNUSED(model), | |
138 | const wxDataViewItem & WXUNUSED(item), | |
139 | unsigned int WXUNUSED(col) ) | |
140 | { return false; } | |
141 | ||
142 | virtual bool LeftClick( wxPoint WXUNUSED(cursor), | |
143 | wxRect WXUNUSED(cell), | |
144 | wxDataViewModel *WXUNUSED(model), | |
145 | const wxDataViewItem & WXUNUSED(item), | |
146 | unsigned int WXUNUSED(col) ) | |
147 | { return false; } | |
148 | ||
149 | virtual bool StartDrag( wxPoint WXUNUSED(cursor), | |
150 | wxRect WXUNUSED(cell), | |
151 | wxDataViewModel *WXUNUSED(model), | |
152 | const wxDataViewItem & WXUNUSED(item), | |
153 | unsigned int WXUNUSED(col) ) | |
154 | { return false; } | |
155 | ||
156 | // | |
157 | // device context handling | |
158 | // | |
159 | virtual wxDC* GetDC(); // creates a device context and keeps it | |
160 | ||
161 | // | |
162 | // implementation | |
163 | // | |
8f2a8de6 | 164 | virtual bool MacRender(); |
e86edab0 RR |
165 | |
166 | void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer | |
167 | ||
168 | protected: | |
169 | private: | |
170 | // | |
171 | // variables | |
172 | // | |
173 | wxControl* m_editorCtrlPtr; // pointer to an in-place editor control | |
174 | ||
175 | wxDC* m_DCPtr; | |
176 | ||
177 | // | |
178 | // wxWidget internal stuff | |
179 | // | |
180 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) | |
181 | }; | |
182 | ||
183 | // --------------------------------------------------------- | |
184 | // wxDataViewTextRenderer | |
185 | // --------------------------------------------------------- | |
186 | ||
187 | class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer | |
188 | { | |
189 | public: | |
190 | // | |
191 | // constructors / destructor | |
192 | // | |
193 | wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
194 | ||
195 | // | |
196 | // inherited functions from wxDataViewRenderer | |
197 | // | |
8f2a8de6 | 198 | virtual bool MacRender(); |
e86edab0 | 199 | |
9461dd8c VZ |
200 | #if wxOSX_USE_COCOA |
201 | virtual void OSXOnCellChanged(NSObject *value, | |
202 | const wxDataViewItem& item, | |
203 | unsigned col); | |
204 | #endif // Cocoa | |
205 | ||
e86edab0 RR |
206 | private: |
207 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) | |
208 | }; | |
209 | ||
e86edab0 RR |
210 | // --------------------------------------------------------- |
211 | // wxDataViewBitmapRenderer | |
212 | // --------------------------------------------------------- | |
213 | ||
214 | class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer | |
215 | { | |
216 | public: | |
217 | // | |
218 | // constructors / destructor | |
219 | // | |
220 | wxDataViewBitmapRenderer(wxString const& varianttype=wxT("wxBitmap"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
221 | ||
222 | // | |
223 | // inherited functions from wxDataViewRenderer | |
224 | // | |
8f2a8de6 | 225 | virtual bool MacRender(); |
e86edab0 RR |
226 | |
227 | protected: | |
228 | private: | |
229 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) | |
230 | }; | |
231 | ||
232 | #if !defined(wxUSE_GENERICDATAVIEWCTRL) && defined(__WXOSX_COCOA__) | |
233 | ||
234 | // ------------------------------------- | |
235 | // wxDataViewChoiceRenderer | |
236 | // ------------------------------------- | |
237 | class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewRenderer | |
238 | { | |
239 | public: | |
240 | // | |
241 | // constructors / destructor | |
242 | // | |
243 | wxDataViewChoiceRenderer(wxArrayString const& choices, | |
244 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
245 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
246 | ||
247 | // | |
248 | // inherited functions from wxDataViewRenderer | |
249 | // | |
8f2a8de6 | 250 | virtual bool MacRender(); |
e86edab0 RR |
251 | |
252 | // | |
253 | // implementation | |
254 | // | |
255 | wxString GetChoice(size_t index) const | |
256 | { | |
de40d736 | 257 | return m_Choices[index]; |
e86edab0 | 258 | } |
de40d736 | 259 | wxArrayString const& GetChoices() const |
e86edab0 | 260 | { |
de40d736 | 261 | return m_Choices; |
e86edab0 RR |
262 | } |
263 | ||
264 | private: | |
265 | // | |
266 | // variables | |
267 | // | |
268 | wxArrayString m_Choices; | |
269 | ||
270 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewChoiceRenderer) | |
271 | }; | |
272 | ||
273 | #endif | |
274 | ||
275 | // --------------------------------------------------------- | |
276 | // wxDataViewIconTextRenderer | |
277 | // --------------------------------------------------------- | |
278 | class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer | |
279 | { | |
280 | public: | |
281 | wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
282 | ||
283 | // | |
284 | // inherited functions from wxDataViewRenderer | |
285 | // | |
8f2a8de6 | 286 | virtual bool MacRender(); |
e86edab0 | 287 | |
0599fe19 | 288 | #if wxOSX_USE_COCOA |
9461dd8c | 289 | virtual void OSXOnCellChanged(NSObject *value, |
0599fe19 VZ |
290 | const wxDataViewItem& item, |
291 | unsigned col); | |
292 | #endif // Cocoa | |
293 | ||
e86edab0 RR |
294 | protected: |
295 | private: | |
296 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) | |
297 | }; | |
298 | ||
299 | // --------------------------------------------------------- | |
300 | // wxDataViewToggleRenderer | |
301 | // --------------------------------------------------------- | |
302 | ||
303 | class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer | |
304 | { | |
305 | public: | |
306 | wxDataViewToggleRenderer(wxString const& varianttype = wxT("bool"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
307 | ||
308 | // | |
309 | // inherited functions from wxDataViewRenderer | |
310 | // | |
8f2a8de6 | 311 | virtual bool MacRender(); |
e86edab0 | 312 | |
9461dd8c VZ |
313 | #if wxOSX_USE_COCOA |
314 | virtual void OSXOnCellChanged(NSObject *value, | |
315 | const wxDataViewItem& item, | |
316 | unsigned col); | |
317 | #endif // Cocoa | |
318 | ||
e86edab0 RR |
319 | private: |
320 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) | |
321 | }; | |
322 | ||
323 | // --------------------------------------------------------- | |
324 | // wxDataViewProgressRenderer | |
325 | // --------------------------------------------------------- | |
326 | ||
327 | class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer | |
328 | { | |
329 | public: | |
330 | wxDataViewProgressRenderer(wxString const& label = wxEmptyString, wxString const& varianttype=wxT("long"), | |
331 | wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT); | |
332 | ||
333 | // | |
334 | // inherited functions from wxDataViewRenderer | |
335 | // | |
8f2a8de6 | 336 | virtual bool MacRender(); |
e86edab0 | 337 | |
9461dd8c VZ |
338 | #if wxOSX_USE_COCOA |
339 | virtual void OSXOnCellChanged(NSObject *value, | |
340 | const wxDataViewItem& item, | |
341 | unsigned col); | |
342 | #endif // Cocoa | |
343 | ||
e86edab0 RR |
344 | private: |
345 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) | |
346 | }; | |
347 | ||
348 | // --------------------------------------------------------- | |
349 | // wxDataViewDateRenderer | |
350 | // --------------------------------------------------------- | |
351 | ||
352 | class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer | |
353 | { | |
354 | public: | |
355 | wxDataViewDateRenderer(wxString const& varianttype=wxT("datetime"), wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int align=wxDVR_DEFAULT_ALIGNMENT); | |
356 | ||
357 | // | |
358 | // inherited functions from wxDataViewRenderer | |
359 | // | |
8f2a8de6 | 360 | virtual bool MacRender(); |
e86edab0 | 361 | |
9461dd8c VZ |
362 | #if wxOSX_USE_COCOA |
363 | virtual void OSXOnCellChanged(NSObject *value, | |
364 | const wxDataViewItem& item, | |
365 | unsigned col); | |
366 | #endif // Cocoa | |
367 | ||
e86edab0 RR |
368 | private: |
369 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) | |
370 | }; | |
371 | ||
372 | // --------------------------------------------------------- | |
373 | // wxDataViewColumn | |
374 | // --------------------------------------------------------- | |
375 | ||
376 | class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase | |
377 | { | |
378 | public: | |
379 | // constructors / destructor | |
380 | wxDataViewColumn(const wxString& title, | |
381 | wxDataViewRenderer* renderer, | |
382 | unsigned int model_column, | |
383 | int width = wxDVC_DEFAULT_WIDTH, | |
384 | wxAlignment align = wxALIGN_CENTER, | |
385 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
386 | wxDataViewColumn(const wxBitmap& bitmap, | |
387 | wxDataViewRenderer* renderer, | |
388 | unsigned int model_column, | |
389 | int width = wxDVC_DEFAULT_WIDTH, | |
390 | wxAlignment align = wxALIGN_CENTER, | |
391 | int flags = wxDATAVIEW_COL_RESIZABLE); | |
de40d736 | 392 | virtual ~wxDataViewColumn(); |
e86edab0 RR |
393 | |
394 | // implement wxHeaderColumnBase pure virtual methods | |
395 | virtual wxAlignment GetAlignment() const { return m_alignment; } | |
396 | virtual int GetFlags() const { return m_flags; } | |
397 | virtual int GetMaxWidth() const { return m_maxWidth; } | |
398 | virtual int GetMinWidth() const { return m_minWidth; } | |
399 | virtual wxString GetTitle() const { return m_title; } | |
d831e2db | 400 | virtual int GetWidth() const; |
e86edab0 RR |
401 | virtual bool IsHidden() const { return false; } // TODO |
402 | virtual bool IsSortOrderAscending() const { return m_ascending; } | |
403 | virtual bool IsSortKey() const; | |
404 | ||
405 | virtual void SetAlignment (wxAlignment align); | |
406 | virtual void SetBitmap (wxBitmap const& bitmap); | |
407 | virtual void SetFlags (int flags) { SetIndividualFlags(flags); } | |
408 | virtual void SetHidden (bool WXUNUSED(hidden)) { } // TODO | |
409 | virtual void SetMaxWidth (int maxWidth); | |
410 | virtual void SetMinWidth (int minWidth); | |
411 | virtual void SetReorderable(bool reorderable); | |
412 | virtual void SetResizeable (bool resizeable); | |
413 | virtual void SetSortable (bool sortable); | |
414 | virtual void SetSortOrder (bool ascending); | |
415 | virtual void SetTitle (wxString const& title); | |
416 | virtual void SetWidth (int width); | |
417 | virtual void SetAsSortKey (bool sort = true); | |
418 | ||
419 | // implementation only | |
de40d736 | 420 | wxDataViewColumnNativeData* GetNativeData() const |
e86edab0 | 421 | { |
de40d736 | 422 | return m_NativeDataPtr; |
e86edab0 | 423 | } |
03647350 | 424 | |
e86edab0 | 425 | void SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr); // class takes ownership of pointer |
d831e2db VZ |
426 | int GetWidthVariable() const |
427 | { | |
428 | return m_width; | |
429 | } | |
e86edab0 RR |
430 | void SetWidthVariable(int NewWidth) |
431 | { | |
432 | m_width = NewWidth; | |
433 | } | |
8ba01d35 RR |
434 | void SetSortOrderVariable(bool NewOrder) |
435 | { | |
436 | m_ascending = NewOrder; | |
437 | } | |
e86edab0 RR |
438 | |
439 | private: | |
440 | // common part of all ctors | |
441 | void InitCommon(int width, wxAlignment align, int flags) | |
442 | { | |
443 | m_ascending = true; | |
444 | m_flags = flags & ~wxDATAVIEW_COL_HIDDEN; // TODO | |
445 | m_maxWidth = 30000; | |
446 | m_minWidth = 0; | |
447 | m_width = width >= 0 ? width : wxDVC_DEFAULT_WIDTH; | |
448 | m_alignment = align; | |
449 | } | |
450 | ||
451 | bool m_ascending; // sorting order | |
452 | ||
453 | int m_flags; // flags for the column | |
454 | int m_maxWidth; // maximum width for the column | |
455 | int m_minWidth; // minimum width for the column | |
456 | int m_width; // column width | |
457 | ||
458 | wxAlignment m_alignment; // column header alignment | |
459 | ||
460 | wxDataViewColumnNativeData* m_NativeDataPtr; // storing environment dependent data for the native implementation | |
461 | ||
462 | wxString m_title; // column title | |
463 | }; | |
464 | ||
465 | // | |
466 | // type definitions related to wxDataViewColumn | |
467 | // | |
468 | WX_DEFINE_ARRAY(wxDataViewColumn*,wxDataViewColumnPtrArrayType); | |
469 | ||
470 | // --------------------------------------------------------- | |
471 | // wxDataViewCtrl | |
472 | // --------------------------------------------------------- | |
473 | class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase | |
474 | { | |
475 | public: | |
476 | // Constructors / destructor: | |
477 | wxDataViewCtrl() | |
478 | { | |
de40d736 | 479 | Init(); |
e86edab0 RR |
480 | } |
481 | wxDataViewCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, | |
482 | const wxValidator& validator = wxDefaultValidator) | |
483 | { | |
de40d736 VZ |
484 | Init(); |
485 | Create(parent, id, pos, size, style, validator ); | |
e86edab0 RR |
486 | } |
487 | ||
488 | ~wxDataViewCtrl(); | |
489 | ||
490 | // explicit control creation | |
491 | bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=0, | |
492 | const wxValidator& validator=wxDefaultValidator); | |
493 | ||
494 | virtual wxControl* GetMainWindow() // not used for the native implementation | |
495 | { | |
496 | return this; | |
497 | } | |
498 | ||
499 | // inherited methods from wxDataViewCtrlBase: | |
500 | virtual bool AssociateModel(wxDataViewModel* model); | |
501 | ||
502 | virtual bool AppendColumn (wxDataViewColumn* columnPtr); | |
de40d736 | 503 | virtual bool ClearColumns (); |
e86edab0 RR |
504 | virtual bool DeleteColumn (wxDataViewColumn* columnPtr); |
505 | virtual wxDataViewColumn* GetColumn (unsigned int pos) const; | |
de40d736 | 506 | virtual unsigned int GetColumnCount () const; |
e86edab0 | 507 | virtual int GetColumnPosition(const wxDataViewColumn* columnPtr) const; |
de40d736 | 508 | virtual wxDataViewColumn* GetSortingColumn () const; |
e86edab0 RR |
509 | virtual bool InsertColumn (unsigned int pos, wxDataViewColumn *col); |
510 | virtual bool PrependColumn (wxDataViewColumn* columnPtr); | |
511 | ||
512 | virtual void Collapse( const wxDataViewItem& item); | |
513 | virtual void EnsureVisible(const wxDataViewItem& item, const wxDataViewColumn* columnPtr=NULL); | |
514 | virtual void Expand(const wxDataViewItem& item); | |
515 | virtual bool IsExpanded(const wxDataViewItem & item) const; | |
516 | ||
517 | ||
518 | virtual unsigned int GetCount() const; | |
519 | virtual wxRect GetItemRect(const wxDataViewItem& item, const wxDataViewColumn* columnPtr) const; | |
520 | virtual wxDataViewItem GetSelection() const; | |
521 | virtual int GetSelections(wxDataViewItemArray& sel) const; | |
522 | ||
523 | virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const; | |
524 | ||
525 | virtual bool IsSelected(const wxDataViewItem& item) const; | |
526 | ||
527 | virtual void SelectAll(); | |
528 | virtual void Select(const wxDataViewItem& item); | |
529 | virtual void SetSelections(const wxDataViewItemArray& sel); | |
530 | ||
531 | virtual void Unselect(const wxDataViewItem& item); | |
532 | virtual void UnselectAll(); | |
533 | ||
534 | // | |
535 | // implementation | |
536 | // | |
537 | // returns a pointer to the native implementation | |
de40d736 | 538 | wxDataViewWidgetImpl* GetDataViewPeer() const; |
e86edab0 RR |
539 | |
540 | // adds all children of the passed parent to the control; if 'parentItem' is invalid the root(s) is/are added: | |
541 | void AddChildren(wxDataViewItem const& parentItem); | |
542 | ||
543 | // finishes editing of custom items; if no custom item is currently edited the method does nothing | |
de40d736 | 544 | void FinishCustomItemEditing(); |
e86edab0 RR |
545 | |
546 | // returns the n-th pointer to a column; | |
547 | // this method is different from GetColumn(unsigned int pos) because here 'n' is not a position in the control but the n-th | |
548 | // position in the internal list/array of column pointers | |
549 | wxDataViewColumn* GetColumnPtr(size_t n) const | |
550 | { | |
de40d736 | 551 | return m_ColumnPtrs[n]; |
e86edab0 RR |
552 | } |
553 | // returns the current being rendered item of the customized renderer (this item is only valid during editing) | |
554 | wxDataViewItem const& GetCustomRendererItem() const | |
555 | { | |
de40d736 | 556 | return m_CustomRendererItem; |
e86edab0 RR |
557 | } |
558 | // returns a pointer to a customized renderer (this pointer is only valid during editing) | |
559 | wxDataViewCustomRenderer* GetCustomRendererPtr() const | |
560 | { | |
de40d736 | 561 | return m_CustomRendererPtr; |
e86edab0 RR |
562 | } |
563 | ||
564 | // checks if currently a delete process is running | |
565 | bool IsDeleting() const | |
566 | { | |
de40d736 | 567 | return m_Deleting; |
e86edab0 RR |
568 | } |
569 | ||
570 | // with CG, we need to get the context from an kEventControlDraw event | |
571 | // unfortunately, the DataBrowser callbacks don't provide the context | |
572 | // and we need it, so we need to set/remove it before and after draw | |
573 | // events so we can access it in the callbacks. | |
574 | void MacSetDrawingContext(void* context) | |
575 | { | |
de40d736 | 576 | m_cgContext = context; |
e86edab0 RR |
577 | } |
578 | void* MacGetDrawingContext() const | |
579 | { | |
de40d736 | 580 | return m_cgContext; |
e86edab0 RR |
581 | } |
582 | ||
583 | // sets the currently being edited item of the custom renderer | |
584 | void SetCustomRendererItem(wxDataViewItem const& NewItem) | |
585 | { | |
de40d736 | 586 | m_CustomRendererItem = NewItem; |
e86edab0 RR |
587 | } |
588 | // sets the custom renderer | |
589 | void SetCustomRendererPtr(wxDataViewCustomRenderer* NewCustomRendererPtr) | |
590 | { | |
de40d736 | 591 | m_CustomRendererPtr = NewCustomRendererPtr; |
e86edab0 RR |
592 | } |
593 | // sets the flag indicating a deletion process: | |
594 | void SetDeleting(bool deleting) | |
595 | { | |
de40d736 | 596 | m_Deleting = deleting; |
e86edab0 RR |
597 | } |
598 | ||
599 | virtual wxVisualAttributes GetDefaultAttributes() const | |
600 | { | |
601 | return GetClassDefaultAttributes(GetWindowVariant()); | |
602 | } | |
603 | ||
604 | static wxVisualAttributes | |
605 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
606 | ||
607 | protected: | |
608 | // inherited methods from wxDataViewCtrlBase | |
609 | virtual void DoSetExpanderColumn(); | |
610 | virtual void DoSetIndent(); | |
611 | ||
ca6de8c0 RR |
612 | virtual wxSize DoGetBestSize() const; |
613 | ||
e86edab0 RR |
614 | // event handling |
615 | void OnSize(wxSizeEvent &event); | |
ca6de8c0 | 616 | void OnMouse(wxMouseEvent &event); |
e86edab0 RR |
617 | |
618 | private: | |
619 | // initializing of local variables: | |
620 | void Init(); | |
621 | ||
622 | // | |
623 | // variables | |
624 | // | |
625 | bool m_Deleting; // flag indicating if a delete process is running; this flag is necessary because the notifier indicating an item deletion in the model may be called | |
626 | // after the actual deletion of the item; then, native callback functions/delegates may try to update data of variables that are already deleted; | |
627 | // if this flag is set all native variable update requests will be ignored | |
628 | ||
629 | void* m_cgContext; // pointer to core graphics context | |
630 | ||
631 | wxDataViewCustomRenderer* m_CustomRendererPtr; // pointer to a valid custom renderer while editing; this class does NOT own the pointer | |
632 | ||
633 | wxDataViewItem m_CustomRendererItem; // currently edited item by the customrenderer; it is invalid while not editing a custom item | |
634 | ||
635 | wxDataViewColumnPtrArrayType m_ColumnPtrs; // all column pointers are stored in an array | |
636 | ||
637 | // wxWidget internal stuff: | |
638 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) | |
639 | DECLARE_NO_COPY_CLASS(wxDataViewCtrl) | |
640 | DECLARE_EVENT_TABLE() | |
641 | }; | |
642 | ||
643 | #endif // _WX_DATAVIEWCTRL_OSX_H_ | |
644 |