1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/qt/dvrenderers.h
3 // Author:      Peter Most
4 // Copyright:   (c) Peter Most
5 // Licence:     wxWindows licence
6 ///////////////////////////////////////////////////////////////////////////////
7 
8 #ifndef _WX_QT_DVRENDERERS_H_
9 #define _WX_QT_DVRENDERERS_H_
10 
11 // ---------------------------------------------------------
12 // wxDataViewTextRenderer
13 // ---------------------------------------------------------
14 
15 class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
16 {
17 public:
GetDefaultType()18     static wxString GetDefaultType() { return wxS("string"); }
19 
20     wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
21                             wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
22                             int align = wxDVR_DEFAULT_ALIGNMENT );
23 
24     bool SetValue( const wxVariant &value );
25     bool GetValue( wxVariant &value ) const;
26 
27     void SetAlignment( int align );
28 };
29 
30 // ---------------------------------------------------------
31 // wxDataViewBitmapRenderer
32 // ---------------------------------------------------------
33 
34 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
35 {
36 public:
GetDefaultType()37     static wxString GetDefaultType() { return wxS("wxBitmap"); }
38 
39     wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
40                               wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
41                               int align = wxDVR_DEFAULT_ALIGNMENT );
42 
43     bool SetValue( const wxVariant &value );
44     bool GetValue( wxVariant &value ) const;
45 };
46 
47 // ---------------------------------------------------------
48 // wxDataViewToggleRenderer
49 // ---------------------------------------------------------
50 
51 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
52 {
53 public:
GetDefaultType()54     static wxString GetDefaultType() { return wxS("bool"); }
55 
56     wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
57                               wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
58                               int align = wxDVR_DEFAULT_ALIGNMENT );
59 
60     bool SetValue( const wxVariant &value );
61     bool GetValue( wxVariant &value ) const;
62 };
63 
64 // ---------------------------------------------------------
65 // wxDataViewCustomRenderer
66 // ---------------------------------------------------------
67 
68 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
69 {
70 public:
GetDefaultType()71     static wxString GetDefaultType() { return wxS("string"); }
72 
73     wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
74                               wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
75                               int align = wxDVR_DEFAULT_ALIGNMENT,
76                               bool no_init = false );
77     virtual ~wxDataViewCustomRenderer();
78 
79 
80     virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
81 
82     void RenderText( const wxString &text, int xoffset,  wxRect cell, wxDC *dc, int state );
83 
84     virtual wxSize GetSize() const = 0;
85 
Activate(wxRect WXUNUSED (cell),wxDataViewModel * WXUNUSED (model),const wxDataViewItem & WXUNUSED (item),unsigned int WXUNUSED (col))86     virtual bool Activate( wxRect WXUNUSED(cell),
87                            wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
88                            { return false; }
89 
LeftClick(wxPoint WXUNUSED (cursor),wxRect WXUNUSED (cell),wxDataViewModel * WXUNUSED (model),const wxDataViewItem & WXUNUSED (item),unsigned int WXUNUSED (col))90     virtual bool LeftClick( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
91                            wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
92                            { return false; }
StartDrag(wxPoint WXUNUSED (cursor),wxRect WXUNUSED (cell),wxDataViewModel * WXUNUSED (model),const wxDataViewItem & WXUNUSED (item),unsigned int WXUNUSED (col))93     virtual bool StartDrag( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
94                            wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
95                            { return false; }
96 
97     // Create DC on request
98     virtual wxDC *GetDC();
99 };
100 
101 // ---------------------------------------------------------
102 // wxDataViewProgressRenderer
103 // ---------------------------------------------------------
104 
105 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
106 {
107 public:
GetDefaultType()108     static wxString GetDefaultType() { return wxS("long"); }
109 
110     wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
111                                 const wxString &varianttype = GetDefaultType(),
112                                 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
113                                 int align = wxDVR_DEFAULT_ALIGNMENT );
114     virtual ~wxDataViewProgressRenderer();
115 
116     bool SetValue( const wxVariant &value );
117     bool GetValue( wxVariant &value ) const;
118 
119     virtual bool Render( wxRect cell, wxDC *dc, int state );
120     virtual wxSize GetSize() const;
121 };
122 
123 // ---------------------------------------------------------
124 // wxDataViewIconTextRenderer
125 // ---------------------------------------------------------
126 
127 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
128 {
129 public:
GetDefaultType()130     static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
131 
132     wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
133                                 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
134                                 int align = wxDVR_DEFAULT_ALIGNMENT );
135     virtual ~wxDataViewIconTextRenderer();
136 
137     bool SetValue( const wxVariant &value );
138     bool GetValue( wxVariant &value ) const;
139 
140     virtual bool Render( wxRect cell, wxDC *dc, int state );
141     virtual wxSize GetSize() const;
142 
HasEditorCtrl()143     virtual bool HasEditorCtrl() const { return true; }
144     virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
145     virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
146 };
147 
148 // ---------------------------------------------------------
149 // wxDataViewDateRenderer
150 // ---------------------------------------------------------
151 
152 class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
153 {
154 public:
GetDefaultType()155     static wxString GetDefaultType() { return wxS("datetime"); }
156 
157     wxDataViewDateRenderer( const wxString &varianttype = GetDefaultType(),
158                             wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
159                             int align = wxDVR_DEFAULT_ALIGNMENT );
160 
161     bool SetValue( const wxVariant &value );
162     bool GetValue( wxVariant &value ) const;
163 
164     virtual bool Render( wxRect cell, wxDC *dc, int state );
165     virtual wxSize GetSize() const;
166     virtual bool Activate( wxRect cell,
167                            wxDataViewModel *model, const wxDataViewItem &item, unsigned int col );
168 
169 };
170 
171 // -------------------------------------
172 // wxDataViewChoiceRenderer
173 // -------------------------------------
174 
175 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
176 {
177 public:
178     wxDataViewChoiceRenderer( const wxArrayString &choices,
179                             wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
180                             int alignment = wxDVR_DEFAULT_ALIGNMENT );
181     virtual bool Render( wxRect rect, wxDC *dc, int state );
182     virtual wxSize GetSize() const;
183     virtual bool SetValue( const wxVariant &value );
184     virtual bool GetValue( wxVariant &value ) const;
185 
186     void SetAlignment( int align );
187 };
188 
189 #endif // _WX_QT_DVRENDERERS_H_
190 
191