]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dataview.h
enabling alpha on msw colour
[wxWidgets.git] / include / wx / gtk / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dataview.h
3 // Purpose: wxDataViewCtrl GTK+2 implementation header
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKDATAVIEWCTRLH__
11 #define __GTKDATAVIEWCTRLH__
12
13 #include "wx/defs.h"
14 #include "wx/object.h"
15 #include "wx/list.h"
16 #include "wx/control.h"
17
18 // ---------------------------------------------------------
19 // classes
20 // ---------------------------------------------------------
21
22 class WXDLLIMPEXP_CORE wxDataViewCtrl;
23
24 // ---------------------------------------------------------
25 // wxDataViewCell
26 // ---------------------------------------------------------
27
28 class wxDataViewCell: public wxDataViewCellBase
29 {
30 public:
31 wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
32
33 // implementation
34 void* GetGtkHandle() { return m_renderer; }
35
36 protected:
37 // holds the GTK handle
38 void* m_renderer;
39
40 protected:
41 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell)
42 };
43
44 // ---------------------------------------------------------
45 // wxDataViewTextCell
46 // ---------------------------------------------------------
47
48 class wxDataViewTextCell: public wxDataViewCell
49 {
50 public:
51 wxDataViewTextCell( const wxString &varianttype = wxT("string"),
52 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
53
54 bool SetValue( const wxVariant &value );
55 bool GetValue( wxVariant &value );
56
57 protected:
58 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
59 };
60
61 // ---------------------------------------------------------
62 // wxDataViewBitmapCell
63 // ---------------------------------------------------------
64
65 class wxDataViewBitmapCell: public wxDataViewCell
66 {
67 public:
68 wxDataViewBitmapCell( const wxString &varianttype = wxT("wxBitmap"),
69 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
70
71 bool SetValue( const wxVariant &value );
72 bool GetValue( wxVariant &value );
73
74 protected:
75 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapCell)
76 };
77
78 // ---------------------------------------------------------
79 // wxDataViewToggleCell
80 // ---------------------------------------------------------
81
82 class wxDataViewToggleCell: public wxDataViewCell
83 {
84 public:
85 wxDataViewToggleCell( const wxString &varianttype = wxT("bool"),
86 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
87
88 bool SetValue( const wxVariant &value );
89 bool GetValue( wxVariant &value );
90
91 protected:
92 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell)
93 };
94
95 // ---------------------------------------------------------
96 // wxDataViewCustomCell
97 // ---------------------------------------------------------
98
99 class wxDataViewCustomCell: public wxDataViewCell
100 {
101 public:
102 wxDataViewCustomCell( const wxString &varianttype = wxT("string"),
103 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
104 bool no_init = false );
105 virtual ~wxDataViewCustomCell();
106 bool Init();
107
108 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
109 virtual wxSize GetSize() = 0;
110
111 virtual bool Activate( wxRect cell,
112 wxDataViewListModel *model, size_t col, size_t row )
113 { return false; }
114
115 virtual bool LeftClick( wxPoint cursor, wxRect cell,
116 wxDataViewListModel *model, size_t col, size_t row )
117 { return false; }
118 virtual bool RightClick( wxPoint cursor, wxRect cell,
119 wxDataViewListModel *model, size_t col, size_t row )
120 { return false; }
121 virtual bool StartDrag( wxPoint cursor, wxRect cell,
122 wxDataViewListModel *model, size_t col, size_t row )
123 { return false; }
124
125 // Create DC on request
126 virtual wxDC *GetDC();
127
128 private:
129 wxDC *m_dc;
130
131 protected:
132 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell)
133 };
134
135 // ---------------------------------------------------------
136 // wxDataViewProgressCell
137 // ---------------------------------------------------------
138
139 class wxDataViewProgressCell: public wxDataViewCustomCell
140 {
141 public:
142 wxDataViewProgressCell( const wxString &label = wxEmptyString,
143 const wxString &varianttype = wxT("long"),
144 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
145 virtual ~wxDataViewProgressCell();
146
147 bool SetValue( const wxVariant &value );
148
149 virtual bool Render( wxRect cell, wxDC *dc, int state );
150 virtual wxSize GetSize();
151
152 private:
153 wxString m_label;
154 int m_value;
155
156 protected:
157 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
158 };
159
160 // ---------------------------------------------------------
161 // wxDataViewDateCell
162 // ---------------------------------------------------------
163
164 class wxDataViewDateCell: public wxDataViewCustomCell
165 {
166 public:
167 wxDataViewDateCell( const wxString &varianttype = wxT("datetime"),
168 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
169
170 bool SetValue( const wxVariant &value );
171
172 virtual bool Render( wxRect cell, wxDC *dc, int state );
173 virtual wxSize GetSize();
174 virtual bool Activate( wxRect cell,
175 wxDataViewListModel *model, size_t col, size_t row );
176
177 private:
178 wxDateTime m_date;
179
180 protected:
181 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell)
182 };
183
184 // ---------------------------------------------------------
185 // wxDataViewColumn
186 // ---------------------------------------------------------
187
188 class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
189 {
190 public:
191 wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
192 int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
193 virtual ~wxDataViewColumn();
194
195 virtual void SetTitle( const wxString &title );
196
197 virtual int GetWidth();
198
199 virtual void SetFixedWidth( int width );
200 virtual int GetFixedWidth();
201
202 // implementation
203 void* GetGtkHandle() { return m_column; }
204
205 private:
206 // holds the GTK handle
207 void* m_column;
208
209 protected:
210 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
211 };
212
213 // ---------------------------------------------------------
214 // wxDataViewCtrl
215 // ---------------------------------------------------------
216
217 class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase
218 {
219 public:
220 wxDataViewCtrl()
221 {
222 Init();
223 }
224
225 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize, long style = 0,
228 const wxValidator& validator = wxDefaultValidator )
229 {
230 Create(parent, id, pos, size, style, validator );
231 }
232
233 virtual ~wxDataViewCtrl();
234
235 void Init();
236
237 bool Create(wxWindow *parent, wxWindowID id,
238 const wxPoint& pos = wxDefaultPosition,
239 const wxSize& size = wxDefaultSize, long style = 0,
240 const wxValidator& validator = wxDefaultValidator );
241
242 virtual bool AssociateModel( wxDataViewListModel *model );
243 virtual bool AppendColumn( wxDataViewColumn *col );
244
245 private:
246 friend class wxDataViewCtrlDC;
247 friend class wxGtkDataViewListModelNotifier;
248 GtkWidget *m_treeview;
249 wxDataViewListModelNotifier *m_notifier;
250
251 private:
252 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
253 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
254 };
255
256
257 #endif // __GTKDATAVIEWCTRLH__