]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dataview.h
adding measuring contexts, streamlining printing code
[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
6842a71a 24// ---------------------------------------------------------
baa9ebc4 25// wxDataViewRenderer
6842a71a
RR
26// ---------------------------------------------------------
27
baa9ebc4 28class wxDataViewRenderer: public wxDataViewRendererBase
6842a71a
RR
29{
30public:
baa9ebc4 31 wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
6842a71a
RR
32
33 // implementation
34 void* GetGtkHandle() { return m_renderer; }
35
36protected:
37 // holds the GTK handle
38 void* m_renderer;
39
40protected:
baa9ebc4 41 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
6842a71a
RR
42};
43
44// ---------------------------------------------------------
baa9ebc4 45// wxDataViewTextRenderer
6842a71a
RR
46// ---------------------------------------------------------
47
baa9ebc4 48class wxDataViewTextRenderer: public wxDataViewRenderer
6842a71a
RR
49{
50public:
baa9ebc4 51 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
6842a71a
RR
52 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
53
7b4fde82 54 bool SetValue( const wxVariant &value );
a7f61f76 55 bool GetValue( wxVariant &value );
7b4fde82 56
6842a71a 57protected:
baa9ebc4 58 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
6842a71a
RR
59};
60
cbc9145c 61// ---------------------------------------------------------
baa9ebc4 62// wxDataViewBitmapRenderer
cbc9145c
RR
63// ---------------------------------------------------------
64
baa9ebc4 65class wxDataViewBitmapRenderer: public wxDataViewRenderer
cbc9145c
RR
66{
67public:
baa9ebc4
RR
68 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
69 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
cbc9145c
RR
70
71 bool SetValue( const wxVariant &value );
72 bool GetValue( wxVariant &value );
73
74protected:
baa9ebc4 75 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
cbc9145c
RR
76};
77
605c2c4a 78// ---------------------------------------------------------
baa9ebc4 79// wxDataViewToggleRenderer
605c2c4a
RR
80// ---------------------------------------------------------
81
baa9ebc4 82class wxDataViewToggleRenderer: public wxDataViewRenderer
605c2c4a
RR
83{
84public:
baa9ebc4 85 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
605c2c4a
RR
86 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
87
88 bool SetValue( const wxVariant &value );
89 bool GetValue( wxVariant &value );
90
91protected:
baa9ebc4 92 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
605c2c4a
RR
93};
94
e152afc3 95// ---------------------------------------------------------
baa9ebc4 96// wxDataViewCustomRenderer
e152afc3
RR
97// ---------------------------------------------------------
98
baa9ebc4 99class wxDataViewCustomRenderer: public wxDataViewRenderer
e152afc3
RR
100{
101public:
baa9ebc4
RR
102 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
103 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
104 bool no_init = false );
105 virtual ~wxDataViewCustomRenderer();
ad63bf41 106 bool Init();
e152afc3
RR
107
108 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
109 virtual wxSize GetSize() = 0;
4d496ecb
RR
110
111 virtual bool Activate( wxRect cell,
0a71f9e9 112 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb
RR
113 { return false; }
114
115 virtual bool LeftClick( wxPoint cursor, wxRect cell,
0a71f9e9 116 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb
RR
117 { return false; }
118 virtual bool RightClick( wxPoint cursor, wxRect cell,
0a71f9e9 119 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb
RR
120 { return false; }
121 virtual bool StartDrag( wxPoint cursor, wxRect cell,
0a71f9e9 122 wxDataViewListModel *model, unsigned int col, unsigned int row )
4d496ecb 123 { return false; }
e152afc3
RR
124
125 // Create DC on request
126 virtual wxDC *GetDC();
127
128private:
129 wxDC *m_dc;
130
131protected:
baa9ebc4 132 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
e152afc3
RR
133};
134
ad63bf41 135// ---------------------------------------------------------
baa9ebc4 136// wxDataViewProgressRenderer
ad63bf41
RR
137// ---------------------------------------------------------
138
baa9ebc4 139class wxDataViewProgressRenderer: public wxDataViewCustomRenderer
ad63bf41
RR
140{
141public:
baa9ebc4
RR
142 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
143 const wxString &varianttype = wxT("long"),
144 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
145 virtual ~wxDataViewProgressRenderer();
ad63bf41
RR
146
147 bool SetValue( const wxVariant &value );
148
149 virtual bool Render( wxRect cell, wxDC *dc, int state );
150 virtual wxSize GetSize();
151
152private:
153 wxString m_label;
154 int m_value;
155
156protected:
baa9ebc4 157 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
ad63bf41
RR
158};
159
4d496ecb 160// ---------------------------------------------------------
baa9ebc4 161// wxDataViewDateRenderer
4d496ecb
RR
162// ---------------------------------------------------------
163
baa9ebc4 164class wxDataViewDateRenderer: public wxDataViewCustomRenderer
4d496ecb
RR
165{
166public:
baa9ebc4 167 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
4d496ecb
RR
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,
0a71f9e9 175 wxDataViewListModel *model, unsigned int col, unsigned int row );
4d496ecb
RR
176
177private:
178 wxDateTime m_date;
179
180protected:
baa9ebc4 181 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
4d496ecb
RR
182};
183
fa28826d
RR
184// ---------------------------------------------------------
185// wxDataViewColumn
186// ---------------------------------------------------------
187
188class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
189{
190public:
baa9ebc4 191 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
008b5a66 192 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
07a84e7b
RR
193 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
194 int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
fa28826d
RR
195 virtual ~wxDataViewColumn();
196
197 virtual void SetTitle( const wxString &title );
07a84e7b 198 virtual void SetBitmap( const wxBitmap &bitmap );
47cef10f 199
b94db696
RR
200 virtual void SetOwner( wxDataViewCtrl *owner );
201
47cef10f 202 virtual void SetAlignment( wxAlignment align );
31fb32e1
RR
203
204 virtual void SetSortable( bool sortable );
205 virtual bool GetSortable();
47cef10f 206 virtual void SetSortOrder( bool ascending );
31fb32e1 207 virtual bool IsSortOrderAscending();
47cef10f 208
533544f2
RR
209 virtual int GetWidth();
210
211 virtual void SetFixedWidth( int width );
212 virtual int GetFixedWidth();
213
fa28826d
RR
214 // implementation
215 void* GetGtkHandle() { return m_column; }
216
217private:
6842a71a 218 // holds the GTK handle
fa28826d 219 void* m_column;
31fb32e1
RR
220
221 // delayed connection to mouse events
222 friend class wxDataViewCtrl;
223 void OnInternalIdle();
224 bool m_isConnected;
225
fa28826d
RR
226protected:
227 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
228};
229
239eaa41
RR
230// ---------------------------------------------------------
231// wxDataViewCtrl
232// ---------------------------------------------------------
233
234class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase
235{
236public:
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
6e2e590f 259 virtual bool AssociateModel( wxDataViewListModel *model );
1a367564
RR
260 virtual bool AppendColumn( wxDataViewColumn *col );
261
6ff7eee7
RR
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);
fc211fe5 265 virtual void Unselect( unsigned int row );
6ff7eee7
RR
266
267 virtual bool IsSelected( unsigned int row ) const;
268 virtual int GetSelection() const;
269 virtual int GetSelections(wxArrayInt& aSelections) const;
b94db696
RR
270
271 static wxVisualAttributes
272 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
6ff7eee7 273
1a367564
RR
274private:
275 friend class wxDataViewCtrlDC;
31fb32e1 276 friend class wxDataViewColumn;
5d605a69 277 friend class wxGtkDataViewListModelNotifier;
8f850e28
RR
278 GtkWidget *m_treeview;
279 wxDataViewListModelNotifier *m_notifier;
239eaa41 280
31fb32e1
RR
281 virtual void OnInternalIdle();
282
239eaa41
RR
283private:
284 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
285 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
286};
287
288
289#endif // __GTKDATAVIEWCTRLH__