]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dataview.h
preparation for allowing to use wxTimer in wxBase (heavily modified patch 1113088):
[wxWidgets.git] / include / wx / gtk / dataview.h
CommitLineData
239eaa41
RR
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
22class WXDLLIMPEXP_CORE wxDataViewCtrl;
23
87f0efe2 24
6842a71a 25// ---------------------------------------------------------
baa9ebc4 26// wxDataViewRenderer
6842a71a
RR
27// ---------------------------------------------------------
28
baa9ebc4 29class wxDataViewRenderer: public wxDataViewRendererBase
6842a71a
RR
30{
31public:
87f0efe2 32 wxDataViewRenderer( const wxString &varianttype,
9861f022
RR
33 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
34 int align = wxDVR_DEFAULT_ALIGNMENT );
6842a71a
RR
35
36 // implementation
9861f022
RR
37 GtkWidget* GetGtkHandle() { return m_renderer; }
38
39 virtual void SetMode( wxDataViewCellMode mode );
40 virtual wxDataViewCellMode GetMode() const;
41
42 virtual void SetAlignment( int align );
43 virtual int GetAlignment() const;
6842a71a
RR
44
45protected:
9861f022 46 GtkWidget *m_renderer;
6842a71a
RR
47
48protected:
baa9ebc4 49 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
6842a71a 50};
9861f022 51
6842a71a 52// ---------------------------------------------------------
baa9ebc4 53// wxDataViewTextRenderer
6842a71a
RR
54// ---------------------------------------------------------
55
baa9ebc4 56class wxDataViewTextRenderer: public wxDataViewRenderer
6842a71a
RR
57{
58public:
baa9ebc4 59 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
9861f022
RR
60 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
61 int align = wxDVR_DEFAULT_ALIGNMENT );
6842a71a 62
7b4fde82 63 bool SetValue( const wxVariant &value );
9861f022
RR
64 bool GetValue( wxVariant &value ) const;
65
66 void SetAlignment( int align );
67
6842a71a 68protected:
baa9ebc4 69 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
6842a71a
RR
70};
71
cbc9145c 72// ---------------------------------------------------------
baa9ebc4 73// wxDataViewBitmapRenderer
cbc9145c
RR
74// ---------------------------------------------------------
75
baa9ebc4 76class wxDataViewBitmapRenderer: public wxDataViewRenderer
cbc9145c
RR
77{
78public:
baa9ebc4 79 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
9861f022
RR
80 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
81 int align = wxDVR_DEFAULT_ALIGNMENT );
cbc9145c
RR
82
83 bool SetValue( const wxVariant &value );
9861f022 84 bool GetValue( wxVariant &value ) const;
cbc9145c
RR
85
86protected:
baa9ebc4 87 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
cbc9145c
RR
88};
89
605c2c4a 90// ---------------------------------------------------------
baa9ebc4 91// wxDataViewToggleRenderer
605c2c4a
RR
92// ---------------------------------------------------------
93
baa9ebc4 94class wxDataViewToggleRenderer: public wxDataViewRenderer
605c2c4a
RR
95{
96public:
baa9ebc4 97 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
9861f022
RR
98 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
99 int align = wxDVR_DEFAULT_ALIGNMENT );
605c2c4a
RR
100
101 bool SetValue( const wxVariant &value );
9861f022 102 bool GetValue( wxVariant &value ) const;
605c2c4a
RR
103
104protected:
baa9ebc4 105 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
605c2c4a
RR
106};
107
e152afc3 108// ---------------------------------------------------------
baa9ebc4 109// wxDataViewCustomRenderer
e152afc3
RR
110// ---------------------------------------------------------
111
baa9ebc4 112class wxDataViewCustomRenderer: public wxDataViewRenderer
e152afc3
RR
113{
114public:
baa9ebc4
RR
115 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
116 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
9861f022 117 int align = wxDVR_DEFAULT_ALIGNMENT,
baa9ebc4
RR
118 bool no_init = false );
119 virtual ~wxDataViewCustomRenderer();
9861f022
RR
120
121
e152afc3 122 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
9861f022
RR
123 virtual wxSize GetSize() const = 0;
124
4d496ecb 125 virtual bool Activate( wxRect cell,
0a71f9e9 126 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb 127 { return false; }
9861f022 128
4d496ecb 129 virtual bool LeftClick( wxPoint cursor, wxRect cell,
0a71f9e9 130 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb
RR
131 { return false; }
132 virtual bool RightClick( wxPoint cursor, wxRect cell,
0a71f9e9 133 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb
RR
134 { return false; }
135 virtual bool StartDrag( wxPoint cursor, wxRect cell,
0a71f9e9 136 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb 137 { return false; }
e152afc3
RR
138
139 // Create DC on request
140 virtual wxDC *GetDC();
141
9861f022
RR
142
143protected:
144
145 bool Init(wxDataViewCellMode mode, int align);
146
e152afc3
RR
147private:
148 wxDC *m_dc;
149
150protected:
baa9ebc4 151 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
e152afc3
RR
152};
153
ad63bf41 154// ---------------------------------------------------------
baa9ebc4 155// wxDataViewProgressRenderer
ad63bf41
RR
156// ---------------------------------------------------------
157
baa9ebc4 158class wxDataViewProgressRenderer: public wxDataViewCustomRenderer
ad63bf41
RR
159{
160public:
baa9ebc4
RR
161 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
162 const wxString &varianttype = wxT("long"),
9861f022
RR
163 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
164 int align = wxDVR_DEFAULT_ALIGNMENT );
baa9ebc4 165 virtual ~wxDataViewProgressRenderer();
ad63bf41
RR
166
167 bool SetValue( const wxVariant &value );
9861f022 168 bool GetValue( wxVariant &value ) const;
ad63bf41
RR
169
170 virtual bool Render( wxRect cell, wxDC *dc, int state );
9861f022 171 virtual wxSize GetSize() const;
ad63bf41
RR
172
173private:
174 wxString m_label;
175 int m_value;
176
177protected:
baa9ebc4 178 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
ad63bf41
RR
179};
180
4d496ecb 181// ---------------------------------------------------------
baa9ebc4 182// wxDataViewDateRenderer
4d496ecb
RR
183// ---------------------------------------------------------
184
baa9ebc4 185class wxDataViewDateRenderer: public wxDataViewCustomRenderer
4d496ecb
RR
186{
187public:
baa9ebc4 188 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
9861f022
RR
189 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
190 int align = wxDVR_DEFAULT_ALIGNMENT );
4d496ecb
RR
191
192 bool SetValue( const wxVariant &value );
9861f022 193 bool GetValue( wxVariant &value ) const;
4d496ecb
RR
194
195 virtual bool Render( wxRect cell, wxDC *dc, int state );
9861f022 196 virtual wxSize GetSize() const;
4d496ecb 197 virtual bool Activate( wxRect cell,
0a71f9e9 198 wxDataViewListModel *model, unsigned int col, unsigned int row );
4d496ecb
RR
199
200private:
201 wxDateTime m_date;
202
203protected:
baa9ebc4 204 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
4d496ecb
RR
205};
206
fa28826d
RR
207// ---------------------------------------------------------
208// wxDataViewColumn
209// ---------------------------------------------------------
210
211class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
212{
213public:
87f0efe2
RR
214 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer,
215 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
216 wxAlignment align = wxALIGN_CENTER,
217 int flags = wxDATAVIEW_COL_RESIZABLE );
218 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
219 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
220 wxAlignment align = wxALIGN_CENTER,
221 int flags = wxDATAVIEW_COL_RESIZABLE );
222
fa28826d
RR
223 virtual ~wxDataViewColumn();
224
9861f022
RR
225
226 // setters:
227
fa28826d 228 virtual void SetTitle( const wxString &title );
07a84e7b 229 virtual void SetBitmap( const wxBitmap &bitmap );
47cef10f 230
b94db696
RR
231 virtual void SetOwner( wxDataViewCtrl *owner );
232
47cef10f 233 virtual void SetAlignment( wxAlignment align );
31fb32e1
RR
234
235 virtual void SetSortable( bool sortable );
47cef10f
RR
236 virtual void SetSortOrder( bool ascending );
237
9861f022
RR
238 virtual void SetResizeable( bool resizeable );
239 virtual void SetHidden( bool hidden );
240
241 virtual void SetMinWidth( int minWidth );
242 virtual void SetWidth( int width );
243
244
245 // getters:
246
247 virtual wxString GetTitle() const;
248 virtual wxAlignment GetAlignment() const;
249
87f0efe2
RR
250 virtual bool IsSortable() const;
251 virtual bool IsSortOrderAscending() const;
9861f022
RR
252 virtual bool IsResizeable() const;
253 virtual bool IsHidden() const;
87f0efe2
RR
254
255 virtual int GetWidth() const;
9861f022
RR
256 virtual int GetMinWidth() const;
257
fa28826d 258 // implementation
9861f022 259 GtkWidget* GetGtkHandle() { return m_column; }
fa28826d
RR
260
261private:
6842a71a 262 // holds the GTK handle
9861f022 263 GtkWidget *m_column;
31fb32e1
RR
264
265 // delayed connection to mouse events
266 friend class wxDataViewCtrl;
267 void OnInternalIdle();
9861f022
RR
268 bool m_isConnected;
269
270 void Init(wxAlignment align, int flags, int width);
271
fa28826d
RR
272protected:
273 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
274};
275
239eaa41
RR
276// ---------------------------------------------------------
277// wxDataViewCtrl
278// ---------------------------------------------------------
279
280class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase
281{
282public:
283 wxDataViewCtrl()
284 {
285 Init();
286 }
287
288 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
289 const wxPoint& pos = wxDefaultPosition,
290 const wxSize& size = wxDefaultSize, long style = 0,
291 const wxValidator& validator = wxDefaultValidator )
292 {
293 Create(parent, id, pos, size, style, validator );
294 }
295
296 virtual ~wxDataViewCtrl();
297
298 void Init();
299
300 bool Create(wxWindow *parent, wxWindowID id,
301 const wxPoint& pos = wxDefaultPosition,
302 const wxSize& size = wxDefaultSize, long style = 0,
303 const wxValidator& validator = wxDefaultValidator );
304
6e2e590f 305 virtual bool AssociateModel( wxDataViewListModel *model );
1a367564
RR
306 virtual bool AppendColumn( wxDataViewColumn *col );
307
6ff7eee7
RR
308 virtual void SetSelection( int row ); // -1 for unselect
309 virtual void SetSelectionRange( unsigned int from, unsigned int to );
310 virtual void SetSelections( const wxArrayInt& aSelections);
fc211fe5 311 virtual void Unselect( unsigned int row );
6ff7eee7
RR
312
313 virtual bool IsSelected( unsigned int row ) const;
314 virtual int GetSelection() const;
315 virtual int GetSelections(wxArrayInt& aSelections) const;
b94db696
RR
316
317 static wxVisualAttributes
318 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
6ff7eee7 319
1e510b1e
RR
320 GtkWidget *GtkGetTreeView() { return m_treeview; }
321 wxWindow *GetMainWindow() { return (wxWindow*) this; }
322
1a367564
RR
323private:
324 friend class wxDataViewCtrlDC;
31fb32e1 325 friend class wxDataViewColumn;
5d605a69 326 friend class wxGtkDataViewListModelNotifier;
8f850e28
RR
327 GtkWidget *m_treeview;
328 wxDataViewListModelNotifier *m_notifier;
239eaa41 329
31fb32e1
RR
330 virtual void OnInternalIdle();
331
239eaa41
RR
332private:
333 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
334 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
335};
336
337
338#endif // __GTKDATAVIEWCTRLH__