]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/dataview.h
suppress (harmless) gcc warning about non-virtual dtor in a class with virtual functions
[wxWidgets.git] / include / wx / mac / carbon / dataview.h
CommitLineData
c0a66d92
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/mac/carbon/dataview.h
3// Purpose: wxDataViewCtrl native implementation header
4// Author:
5// Id: $Id$
6// Copyright: (c) 2007
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
34b1fdeb
PC
10#ifndef _WX_MACCARBONDATAVIEWCTRL_H_
11#define _WX_MACCARBONDATAVIEWCTRL_H_
c0a66d92 12
34b1fdeb 13typedef void* DataBrowserItemDataRef;
f53c8638 14typedef unsigned long WXDataBrowserPropertyType;
34b1fdeb 15typedef wxUint32 WXDataBrowserPropertyID;
c0a66d92
RR
16
17// ---------------------------------------------------------
18// wxDataViewRenderer
19// ---------------------------------------------------------
20
21class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
22{
23public:
24//
25// constructors / destructor
26//
27 wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
28
29//
30// inherited methods from wxDataViewRendererBase
31//
32 virtual int GetAlignment(void) const
33 {
34 return this->m_alignment;
35 }
36 virtual wxDataViewCellMode GetMode(void) const
37 {
38 return this->m_mode;
39 }
40 virtual bool GetValue(wxVariant& value) const
41 {
42 value = this->m_value;
43 return true;
44 }
45
46 virtual void SetAlignment(int WXUNUSED(align)) // is always identical to the header alignment
47 {
48 }
49 virtual void SetMode(wxDataViewCellMode mode);
50 virtual bool SetValue(wxVariant const& newValue)
51 {
52 this->m_value = newValue;
53 return true;
54 }
55
56//
57// implementation
58//
59 DataBrowserItemDataRef GetDataReference(void) const
60 {
61 return this->m_dataReference;
62 }
63 wxVariant const& GetValue(void) const
64 {
65 return this->m_value;
66 }
67
34b1fdeb 68 virtual WXDataBrowserPropertyType GetPropertyType() const = 0;
c0a66d92
RR
69
70 virtual bool Render(void) = 0; // a call to the appropriate data browser function filling the data reference with the stored datum;
71 // returns 'true' if the data value could be rendered, 'false' otherwise
72
73 void SetDataReference(DataBrowserItemDataRef const& newDataReference)
74 {
75 this->m_dataReference = newDataReference;
76 }
77
78private:
79//
80// variables
81//
82 DataBrowserItemDataRef m_dataReference; // data reference of the data browser; the data will be assigned to this reference during rendering
83
84 int m_alignment; // contains the alignment flags
85
86 wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown
87
88 wxVariant m_value; // value that is going to be rendered
89
90//
91// wxWidget internal stuff
92//
93 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
94};
95
96// ---------------------------------------------------------
97// wxDataViewCustomRenderer
98// ---------------------------------------------------------
99
100class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
101{
102public:
103//
104// constructors / destructor
105//
106 wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
107
108 virtual ~wxDataViewCustomRenderer(void);
109
52e750fc
RR
110 void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
111
c0a66d92
RR
112//
113// methods handling render space
114//
115 virtual wxSize GetSize() const = 0;
116
117//
118// methods handling user actions
119//
120 virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
121
194027ac 122 virtual bool Activate(wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
c0a66d92
RR
123 {
124 return false;
125 }
126
194027ac 127 virtual bool LeftClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
c0a66d92
RR
128 {
129 return false;
130 }
131
194027ac 132 virtual bool RightClick(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
c0a66d92
RR
133 {
134 return false;
135 }
136
194027ac 137 virtual bool StartDrag(wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), wxDataViewModel *WXUNUSED(model), unsigned int WXUNUSED(col), unsigned int WXUNUSED(row))
c0a66d92
RR
138 {
139 return false;
140 }
141
142//
143// in-place editing
144//
145 virtual void CancelEditing()
146 {
147 }
148
149 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), wxRect WXUNUSED(labelRect), const wxVariant& WXUNUSED(value))
150 {
151 return NULL;
152 }
153
154 virtual bool FinishEditing()
155 {
156 return false;
157 }
158
159 wxControl* GetEditorCtrl(void) const
160 {
161 return this->m_editorCtrlPtr;
162 }
163 virtual bool GetValueFromEditorCtrl(wxControl* WXUNUSED(editor), wxVariant& WXUNUSED(value))
164 {
165 return false;
166 }
167
168 virtual bool HasEditorCtrl(void)
169 {
170 return false;
171 }
172
6d9ecc87 173 virtual bool StartEditing(wxDataViewItem const& WXUNUSED(item), wxRect WXUNUSED(labelRect))
c0a66d92
RR
174 {
175 return false;
176 }
177
178//
179// device context handling
180//
181 virtual wxDC* GetDC(void); // creates a device context and keeps it
182
183//
184// implementation
185//
186 virtual bool Render(void); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
c17b2e31 187 // return 'true' without having done anything
c0a66d92 188
34b1fdeb 189 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
190
191 void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
192
193protected:
194private:
195//
196// variables
197//
198 wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
199
200 wxDC* m_DCPtr;
201
202//
203// wxWidget internal stuff
204//
205 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
206};
207
208// ---------------------------------------------------------
209// wxDataViewTextRenderer
210// ---------------------------------------------------------
211
212class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
213{
214public:
215//
216// constructors / destructor
217//
218 wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
219
220//
221// inherited functions from wxDataViewRenderer
222//
223 virtual bool Render(void);
224
225//
226// implementation
227//
34b1fdeb 228 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
229
230protected:
231private:
232 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
233};
234
235// ---------------------------------------------------------
236// wxDataViewBitmapRenderer
237// ---------------------------------------------------------
238
239class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
240{
241public:
242//
243// constructors / destructor
244//
245 wxDataViewBitmapRenderer(wxString const& varianttype=wxT("wxBitmap"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
246
247//
248// inherited functions from wxDataViewRenderer
249//
250 virtual bool Render(void);
251
252//
253// implementation
254//
34b1fdeb 255 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
256
257protected:
258private:
259 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
260};
261
262// ---------------------------------------------------------
263// wxDataViewToggleRenderer
264// ---------------------------------------------------------
265
c17b2e31
RR
266class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
267{
268public:
269 wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
270
271//
272// inherited functions from wxDataViewRenderer
273//
274 virtual bool Render(void);
275
276//
277// implementation
278//
34b1fdeb 279 virtual WXDataBrowserPropertyType GetPropertyType() const;
c17b2e31
RR
280
281protected:
282private:
283 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
284};
285
286// ---------------------------------------------------------
287// wxDataViewToggleRenderer
288// ---------------------------------------------------------
289
c0a66d92
RR
290class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
291{
292public:
293 wxDataViewToggleRenderer(wxString const& varianttype = wxT("bool"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
294
295//
296// inherited functions from wxDataViewRenderer
297//
298 virtual bool Render(void);
299
300//
301// implementation
302//
34b1fdeb 303 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
304
305protected:
306private:
307 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
308};
309
310// ---------------------------------------------------------
311// wxDataViewProgressRenderer
312// ---------------------------------------------------------
313
314class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
315{
316public:
317 wxDataViewProgressRenderer(wxString const& label = wxEmptyString, wxString const& varianttype=wxT("long"),
318 wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
319
320//
321// inherited functions from wxDataViewRenderer
322//
323 virtual bool Render(void);
324
325//
326// implementation
327//
34b1fdeb 328 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
329
330protected:
331private:
332 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
333};
334
335// ---------------------------------------------------------
336// wxDataViewDateRenderer
337// ---------------------------------------------------------
338
339class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
340{
341public:
342 wxDataViewDateRenderer(wxString const& varianttype=wxT("datetime"), wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int align=wxDVR_DEFAULT_ALIGNMENT);
343
344//
345// inherited functions from wxDataViewRenderer
346//
347 virtual bool Render(void);
348
349//
350// implementation
351//
34b1fdeb 352 virtual WXDataBrowserPropertyType GetPropertyType() const;
c0a66d92
RR
353
354protected:
355private:
356 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
357};
358
359// ---------------------------------------------------------
360// wxDataViewColumn
361// ---------------------------------------------------------
362
363class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
364{
365public:
366//
367// constructors / destructor
368//
369 wxDataViewColumn(wxString const& title, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
370 int flags=wxDATAVIEW_COL_RESIZABLE);
371 wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
372 int flags=wxDATAVIEW_COL_RESIZABLE);
373
374//
375// inherited methods from wxDataViewColumnBase
376//
377 virtual wxAlignment GetAlignment(void) const
378 {
379 return this->m_alignment;
380 }
381 virtual int GetFlags(void) const
382 {
383 return this->m_flags;
384 }
385 virtual int GetMaxWidth(void) const
386 {
387 return this->m_maxWidth;
388 }
389 virtual int GetMinWidth(void) const
390 {
391 return this->m_minWidth;
392 }
393 virtual wxString GetTitle(void) const
394 {
395 return this->m_title;
396 }
397 virtual int GetWidth(void) const
398 {
399 return this->m_width;
400 }
401
402 virtual bool IsHidden(void) const
403 {
404 return false; // not implemented
405 }
406 virtual bool IsResizeable(void) const
407 {
408 return ((this->m_flags & wxDATAVIEW_COL_RESIZABLE) != 0);
409 }
410 virtual bool IsSortable(void) const
411 {
412 return ((this->m_flags & wxDATAVIEW_COL_SORTABLE) != 0);
413 }
414 virtual bool IsSortOrderAscending(void) const
415 {
416 return this->m_ascending;
417 }
418
419 virtual void SetAlignment(wxAlignment align);
420 virtual void SetBitmap (wxBitmap const& bitmap);
421 virtual void SetFlags (int flags);
422 virtual void SetHidden(bool WXUNUSED(hidden))
423 {
424 }
425 virtual void SetMaxWidth (int maxWidth);
426 virtual void SetMinWidth (int minWidth);
427 virtual void SetResizeable(bool resizeable);
428 virtual void SetSortable (bool sortable);
429 virtual void SetSortOrder (bool ascending);
430 virtual void SetTitle (wxString const& title);
431 virtual void SetWidth (int width);
432
433//
434// implementation
435//
34b1fdeb 436 WXDataBrowserPropertyID GetPropertyID() const
c0a66d92
RR
437 {
438 return this->m_propertyID;
439 }
440
34b1fdeb 441 void SetPropertyID(WXDataBrowserPropertyID newID)
c0a66d92
RR
442 {
443 this->m_propertyID = newID;
444 }
6d9ecc87
RR
445 void SetWidthVariable(int NewWidth)
446 {
447 this->m_width = NewWidth;
448 }
c0a66d92
RR
449
450protected:
451private:
452//
453// variables
454//
455 bool m_ascending; // sorting order
456
34b1fdeb 457 WXDataBrowserPropertyID m_propertyID; // each column is identified by its unique property ID (NOT by the column index)
c0a66d92
RR
458
459 int m_flags; // flags for the column
460 int m_maxWidth; // maximum width for the column
461 int m_minWidth; // minimum width for the column
462 int m_width; // column width
463
464 wxAlignment m_alignment; // column header alignment
465
466 wxString m_title; // column title
467
468 // wxWidget internal stuff:
469 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
470};
471
472// ---------------------------------------------------------
473// wxDataViewCtrl
474// ---------------------------------------------------------
c0a66d92
RR
475class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
476{
477public:
478 // Constructors / destructor:
194027ac
RR
479 wxDataViewCtrl()
480 {
481 this->Init();
482 }
483 wxDataViewCtrl(wxWindow *parent, wxWindowID id, wxPoint const& pos = wxDefaultPosition, wxSize const& size = wxDefaultSize, long style = 0,
484 wxValidator const& validator = wxDefaultValidator)
485 {
486 this->Init();
487 this->Create(parent, id, pos, size, style, validator );
488 }
489
490 // explicit control creation
491 bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
492 wxValidator const& validator=wxDefaultValidator);
493
194027ac
RR
494 virtual wxControl* GetMainWindow(void) // should disappear as it is not of any use for the native implementation
495 {
496 return this;
497 }
498
c17b2e31
RR
499 // inherited methods from 'wxDataViewCtrlBase':
500 virtual bool AssociateModel(wxDataViewModel* model);
501
502 virtual bool AppendColumn(wxDataViewColumn* columnPtr);
503 virtual bool ClearColumns(void);
504 virtual bool DeleteColumn(wxDataViewColumn* columnPtr);
505 virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
506 virtual unsigned int GetColumnCount(void) const;
6d9ecc87 507 virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const;
21f47fb9 508
c17b2e31 509 virtual void Collapse(wxDataViewItem const& item);
07c51ff1 510 virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr=NULL);
c17b2e31 511 virtual void Expand(wxDataViewItem const& item);
07c51ff1 512
6d9ecc87
RR
513 virtual wxDataViewColumn* GetSortingColumn(void) const;
514
b741dd40 515 virtual unsigned int GetCount(void) const;
07c51ff1
RR
516 virtual wxRect GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const;
517 virtual wxDataViewItem GetSelection(void) const;
518 virtual int GetSelections(wxDataViewItemArray& sel) const;
519
520 virtual void HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
521
522 virtual bool IsSelected(wxDataViewItem const& item) const;
523
524 virtual void SelectAll(void);
525 virtual void Select(wxDataViewItem const& item);
526 virtual void SetSelections(wxDataViewItemArray const& sel);
c0a66d92 527
07c51ff1
RR
528 virtual void Unselect(wxDataViewItem const& item);
529 virtual void UnselectAll(void);
c17b2e31 530
c0a66d92
RR
531//
532// implementation
533//
534
07c51ff1 535 // adds all children of the passed parent to the control; if 'parentItem' is invalid the root(s) is/are added:
194027ac
RR
536 void AddChildrenLevel(wxDataViewItem const& parentItem);
537
c17b2e31
RR
538 // returns a pointer to a column;
539 // in case the pointer cannot be found NULL is returned:
34b1fdeb 540 wxDataViewColumn* GetColumnPtr(WXDataBrowserPropertyID propertyID) const;
c17b2e31 541
07c51ff1
RR
542 // checks if currently a delete process is running:
543 bool IsDeleting(void) const
544 {
545 return this->m_Deleting;
546 }
547
c0a66d92
RR
548 // with CG, we need to get the context from an kEventControlDraw event
549 // unfortunately, the DataBrowser callbacks don't provide the context
550 // and we need it, so we need to set/remove it before and after draw
551 // events so we can access it in the callbacks.
552 void MacSetDrawingContext(void* context)
553 {
554 this->m_cgContext = context;
555 }
556 void* MacGetDrawingContext(void) const
557 {
558 return this->m_cgContext;
559 }
560
07c51ff1
RR
561 /// sets the flag indicating a deletion process:
562 void SetDeleting(bool deleting)
563 {
564 this->m_Deleting = deleting;
565 }
566
c0a66d92 567protected:
194027ac
RR
568 // inherited methods from wxDataViewCtrlBase:
569 virtual void DoSetExpanderColumn(void);
570 virtual void DoSetIndent(void);
571
c0a66d92
RR
572 // event handling:
573 void OnSize(wxSizeEvent &event);
574
575private:
c17b2e31 576 // type definitions:
34b1fdeb 577 WX_DECLARE_HASH_MAP(WXDataBrowserPropertyID,wxDataViewColumn*,wxIntegerHash,wxIntegerEqual,ColumnPointerHashMapType);
c17b2e31 578
c0a66d92
RR
579 // initializing of local variables:
580 void Init(void);
581
582///
583// variables
584//
585
07c51ff1
RR
586 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
587 // after the actual deletion of the item; then, the callback function "wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc" may
588 // try to update data into variables that are already deleted; this flag will ignore all variable update requests during item deletion
c0a66d92
RR
589
590 void* m_cgContext; // pointer to core graphics context
07c51ff1 591
c17b2e31 592 ColumnPointerHashMapType m_ColumnPointers; // all column pointers are stored in a hash map with the property ID as a key
c0a66d92
RR
593
594 // wxWidget internal stuff:
595 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
596 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
597 DECLARE_EVENT_TABLE()
598};
599
600
34b1fdeb 601#endif // _WX_MACCARBONDATAVIEWCTRL_H_