]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dataview.h
replaced size_t with unsigned int in wxAnimation and related classes and a couple...
[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 // wxDataViewRenderer
26 // ---------------------------------------------------------
27
28 class wxDataViewRenderer: public wxDataViewRendererBase
29 {
30 public:
31 wxDataViewRenderer( 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(wxDataViewRenderer)
42 };
43
44 // ---------------------------------------------------------
45 // wxDataViewTextRenderer
46 // ---------------------------------------------------------
47
48 class wxDataViewTextRenderer: public wxDataViewRenderer
49 {
50 public:
51 wxDataViewTextRenderer( 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(wxDataViewTextRenderer)
59 };
60
61 // ---------------------------------------------------------
62 // wxDataViewBitmapRenderer
63 // ---------------------------------------------------------
64
65 class wxDataViewBitmapRenderer: public wxDataViewRenderer
66 {
67 public:
68 wxDataViewBitmapRenderer( 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(wxDataViewBitmapRenderer)
76 };
77
78 // ---------------------------------------------------------
79 // wxDataViewToggleRenderer
80 // ---------------------------------------------------------
81
82 class wxDataViewToggleRenderer: public wxDataViewRenderer
83 {
84 public:
85 wxDataViewToggleRenderer( 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(wxDataViewToggleRenderer)
93 };
94
95 // ---------------------------------------------------------
96 // wxDataViewCustomRenderer
97 // ---------------------------------------------------------
98
99 class wxDataViewCustomRenderer: public wxDataViewRenderer
100 {
101 public:
102 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
103 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
104 bool no_init = false );
105 virtual ~wxDataViewCustomRenderer();
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, unsigned int col, unsigned int row )
113 { return false; }
114
115 virtual bool LeftClick( wxPoint cursor, wxRect cell,
116 wxDataViewListModel *model, unsigned int col, unsigned int row )
117 { return false; }
118 virtual bool RightClick( wxPoint cursor, wxRect cell,
119 wxDataViewListModel *model, unsigned int col, unsigned int row )
120 { return false; }
121 virtual bool StartDrag( wxPoint cursor, wxRect cell,
122 wxDataViewListModel *model, unsigned int col, unsigned int 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(wxDataViewCustomRenderer)
133 };
134
135 // ---------------------------------------------------------
136 // wxDataViewProgressRenderer
137 // ---------------------------------------------------------
138
139 class wxDataViewProgressRenderer: public wxDataViewCustomRenderer
140 {
141 public:
142 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
143 const wxString &varianttype = wxT("long"),
144 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
145 virtual ~wxDataViewProgressRenderer();
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(wxDataViewProgressRenderer)
158 };
159
160 // ---------------------------------------------------------
161 // wxDataViewDateRenderer
162 // ---------------------------------------------------------
163
164 class wxDataViewDateRenderer: public wxDataViewCustomRenderer
165 {
166 public:
167 wxDataViewDateRenderer( 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, unsigned int col, unsigned int row );
176
177 private:
178 wxDateTime m_date;
179
180 protected:
181 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
182 };
183
184 // ---------------------------------------------------------
185 // wxDataViewColumn
186 // ---------------------------------------------------------
187
188 class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
189 {
190 public:
191 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
192 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
193 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
194 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
195 virtual ~wxDataViewColumn();
196
197 virtual void SetTitle( const wxString &title );
198 virtual void SetBitmap( const wxBitmap &bitmap );
199
200 virtual void SetOwner( wxDataViewCtrl *owner );
201
202 virtual void SetAlignment( wxAlignment align );
203
204 virtual void SetSortable( bool sortable );
205 virtual bool GetSortable();
206 virtual void SetSortOrder( bool ascending );
207 virtual bool IsSortOrderAscending();
208
209 virtual int GetWidth();
210
211 virtual void SetFixedWidth( int width );
212 virtual int GetFixedWidth();
213
214 // implementation
215 void* GetGtkHandle() { return m_column; }
216
217 private:
218 // holds the GTK handle
219 void* m_column;
220
221 // delayed connection to mouse events
222 friend class wxDataViewCtrl;
223 void OnInternalIdle();
224 bool m_isConnected;
225
226 protected:
227 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
228 };
229
230 // ---------------------------------------------------------
231 // wxDataViewCtrl
232 // ---------------------------------------------------------
233
234 class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase
235 {
236 public:
237 wxDataViewCtrl()
238 {
239 Init();
240 }
241
242 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
243 const wxPoint& pos = wxDefaultPosition,
244 const wxSize& size = wxDefaultSize, long style = 0,
245 const wxValidator& validator = wxDefaultValidator )
246 {
247 Create(parent, id, pos, size, style, validator );
248 }
249
250 virtual ~wxDataViewCtrl();
251
252 void Init();
253
254 bool Create(wxWindow *parent, wxWindowID id,
255 const wxPoint& pos = wxDefaultPosition,
256 const wxSize& size = wxDefaultSize, long style = 0,
257 const wxValidator& validator = wxDefaultValidator );
258
259 virtual bool AssociateModel( wxDataViewListModel *model );
260 virtual bool AppendColumn( wxDataViewColumn *col );
261
262 virtual void SetSelection( int row ); // -1 for unselect
263 virtual void SetSelectionRange( unsigned int from, unsigned int to );
264 virtual void SetSelections( const wxArrayInt& aSelections);
265 virtual void Unselect( unsigned int row );
266
267 virtual bool IsSelected( unsigned int row ) const;
268 virtual int GetSelection() const;
269 virtual int GetSelections(wxArrayInt& aSelections) const;
270
271 static wxVisualAttributes
272 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
273
274 private:
275 friend class wxDataViewCtrlDC;
276 friend class wxDataViewColumn;
277 friend class wxGtkDataViewListModelNotifier;
278 GtkWidget *m_treeview;
279 wxDataViewListModelNotifier *m_notifier;
280
281 virtual void OnInternalIdle();
282
283 private:
284 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
285 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
286 };
287
288
289 #endif // __GTKDATAVIEWCTRLH__