1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dataview.h
3 // Purpose: wxDataViewCtrl GTK+2 implementation header
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKDATAVIEWCTRLH__
11 #define __GTKDATAVIEWCTRLH__
14 #include "wx/object.h"
16 #include "wx/control.h"
18 // ---------------------------------------------------------
20 // ---------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxDataViewCtrl
;
25 // ---------------------------------------------------------
27 // ---------------------------------------------------------
29 class wxDataViewRenderer
: public wxDataViewRendererBase
32 wxDataViewRenderer( const wxString
&varianttype
,
33 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
36 void* GetGtkHandle() { return m_renderer
; }
39 // holds the GTK handle
43 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer
)
46 // ---------------------------------------------------------
47 // wxDataViewTextRenderer
48 // ---------------------------------------------------------
50 class wxDataViewTextRenderer
: public wxDataViewRenderer
53 wxDataViewTextRenderer( const wxString
&varianttype
= wxT("string"),
54 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
56 bool SetValue( const wxVariant
&value
);
57 bool GetValue( wxVariant
&value
);
60 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer
)
63 // ---------------------------------------------------------
64 // wxDataViewBitmapRenderer
65 // ---------------------------------------------------------
67 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
70 wxDataViewBitmapRenderer( const wxString
&varianttype
= wxT("wxBitmap"),
71 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
73 bool SetValue( const wxVariant
&value
);
74 bool GetValue( wxVariant
&value
);
77 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer
)
80 // ---------------------------------------------------------
81 // wxDataViewToggleRenderer
82 // ---------------------------------------------------------
84 class wxDataViewToggleRenderer
: public wxDataViewRenderer
87 wxDataViewToggleRenderer( const wxString
&varianttype
= wxT("bool"),
88 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
90 bool SetValue( const wxVariant
&value
);
91 bool GetValue( wxVariant
&value
);
94 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer
)
97 // ---------------------------------------------------------
98 // wxDataViewCustomRenderer
99 // ---------------------------------------------------------
101 class wxDataViewCustomRenderer
: public wxDataViewRenderer
104 wxDataViewCustomRenderer( const wxString
&varianttype
= wxT("string"),
105 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
106 bool no_init
= false );
107 virtual ~wxDataViewCustomRenderer();
110 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
) = 0;
111 virtual wxSize
GetSize() = 0;
113 virtual bool Activate( wxRect cell
,
114 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
117 virtual bool LeftClick( wxPoint cursor
, wxRect cell
,
118 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
120 virtual bool RightClick( wxPoint cursor
, wxRect cell
,
121 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
123 virtual bool StartDrag( wxPoint cursor
, wxRect cell
,
124 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
127 // Create DC on request
128 virtual wxDC
*GetDC();
134 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
137 // ---------------------------------------------------------
138 // wxDataViewProgressRenderer
139 // ---------------------------------------------------------
141 class wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
144 wxDataViewProgressRenderer( const wxString
&label
= wxEmptyString
,
145 const wxString
&varianttype
= wxT("long"),
146 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
147 virtual ~wxDataViewProgressRenderer();
149 bool SetValue( const wxVariant
&value
);
151 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
152 virtual wxSize
GetSize();
159 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
162 // ---------------------------------------------------------
163 // wxDataViewDateRenderer
164 // ---------------------------------------------------------
166 class wxDataViewDateRenderer
: public wxDataViewCustomRenderer
169 wxDataViewDateRenderer( const wxString
&varianttype
= wxT("datetime"),
170 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
172 bool SetValue( const wxVariant
&value
);
174 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
175 virtual wxSize
GetSize();
176 virtual bool Activate( wxRect cell
,
177 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
);
183 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
186 // ---------------------------------------------------------
188 // ---------------------------------------------------------
190 class WXDLLIMPEXP_CORE wxDataViewColumn
: public wxDataViewColumnBase
193 wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*renderer
,
194 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
195 wxAlignment align
= wxALIGN_CENTER
,
196 int flags
= wxDATAVIEW_COL_RESIZABLE
);
197 wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*renderer
,
198 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
199 wxAlignment align
= wxALIGN_CENTER
,
200 int flags
= wxDATAVIEW_COL_RESIZABLE
);
202 virtual ~wxDataViewColumn();
204 virtual void SetTitle( const wxString
&title
);
205 virtual void SetBitmap( const wxBitmap
&bitmap
);
207 virtual void SetOwner( wxDataViewCtrl
*owner
);
209 virtual void SetAlignment( wxAlignment align
);
211 virtual void SetSortable( bool sortable
);
212 virtual void SetSortOrder( bool ascending
);
214 virtual bool IsSortable() const;
215 virtual bool IsSortOrderAscending() const;
217 virtual int GetWidth() const;
219 virtual void SetFixedWidth( int width
);
220 virtual int GetFixedWidth() const;
223 void* GetGtkHandle() { return m_column
; }
226 // holds the GTK handle
229 // delayed connection to mouse events
230 friend class wxDataViewCtrl
;
231 void OnInternalIdle();
235 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn
)
238 // ---------------------------------------------------------
240 // ---------------------------------------------------------
242 class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxDataViewCtrlBase
250 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
251 const wxPoint
& pos
= wxDefaultPosition
,
252 const wxSize
& size
= wxDefaultSize
, long style
= 0,
253 const wxValidator
& validator
= wxDefaultValidator
)
255 Create(parent
, id
, pos
, size
, style
, validator
);
258 virtual ~wxDataViewCtrl();
262 bool Create(wxWindow
*parent
, wxWindowID id
,
263 const wxPoint
& pos
= wxDefaultPosition
,
264 const wxSize
& size
= wxDefaultSize
, long style
= 0,
265 const wxValidator
& validator
= wxDefaultValidator
);
267 virtual bool AssociateModel( wxDataViewListModel
*model
);
268 virtual bool AppendColumn( wxDataViewColumn
*col
);
270 virtual void SetSelection( int row
); // -1 for unselect
271 virtual void SetSelectionRange( unsigned int from
, unsigned int to
);
272 virtual void SetSelections( const wxArrayInt
& aSelections
);
273 virtual void Unselect( unsigned int row
);
275 virtual bool IsSelected( unsigned int row
) const;
276 virtual int GetSelection() const;
277 virtual int GetSelections(wxArrayInt
& aSelections
) const;
279 static wxVisualAttributes
280 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
283 friend class wxDataViewCtrlDC
;
284 friend class wxDataViewColumn
;
285 friend class wxGtkDataViewListModelNotifier
;
286 GtkWidget
*m_treeview
;
287 wxDataViewListModelNotifier
*m_notifier
;
289 virtual void OnInternalIdle();
292 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
293 DECLARE_NO_COPY_CLASS(wxDataViewCtrl
)
297 #endif // __GTKDATAVIEWCTRLH__