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
;
24 // ---------------------------------------------------------
26 // ---------------------------------------------------------
28 class wxDataViewRenderer
: public wxDataViewRendererBase
31 wxDataViewRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
34 void* GetGtkHandle() { return m_renderer
; }
37 // holds the GTK handle
41 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer
)
44 // ---------------------------------------------------------
45 // wxDataViewTextRenderer
46 // ---------------------------------------------------------
48 class wxDataViewTextRenderer
: public wxDataViewRenderer
51 wxDataViewTextRenderer( const wxString
&varianttype
= wxT("string"),
52 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
54 bool SetValue( const wxVariant
&value
);
55 bool GetValue( wxVariant
&value
);
58 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer
)
61 // ---------------------------------------------------------
62 // wxDataViewBitmapRenderer
63 // ---------------------------------------------------------
65 class wxDataViewBitmapRenderer
: public wxDataViewRenderer
68 wxDataViewBitmapRenderer( const wxString
&varianttype
= wxT("wxBitmap"),
69 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
71 bool SetValue( const wxVariant
&value
);
72 bool GetValue( wxVariant
&value
);
75 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer
)
78 // ---------------------------------------------------------
79 // wxDataViewToggleRenderer
80 // ---------------------------------------------------------
82 class wxDataViewToggleRenderer
: public wxDataViewRenderer
85 wxDataViewToggleRenderer( const wxString
&varianttype
= wxT("bool"),
86 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
88 bool SetValue( const wxVariant
&value
);
89 bool GetValue( wxVariant
&value
);
92 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer
)
95 // ---------------------------------------------------------
96 // wxDataViewCustomRenderer
97 // ---------------------------------------------------------
99 class wxDataViewCustomRenderer
: public wxDataViewRenderer
102 wxDataViewCustomRenderer( const wxString
&varianttype
= wxT("string"),
103 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
104 bool no_init
= false );
105 virtual ~wxDataViewCustomRenderer();
108 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
) = 0;
109 virtual wxSize
GetSize() = 0;
111 virtual bool Activate( wxRect cell
,
112 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
115 virtual bool LeftClick( wxPoint cursor
, wxRect cell
,
116 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
118 virtual bool RightClick( wxPoint cursor
, wxRect cell
,
119 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
121 virtual bool StartDrag( wxPoint cursor
, wxRect cell
,
122 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
125 // Create DC on request
126 virtual wxDC
*GetDC();
132 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
135 // ---------------------------------------------------------
136 // wxDataViewProgressRenderer
137 // ---------------------------------------------------------
139 class wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
142 wxDataViewProgressRenderer( const wxString
&label
= wxEmptyString
,
143 const wxString
&varianttype
= wxT("long"),
144 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
145 virtual ~wxDataViewProgressRenderer();
147 bool SetValue( const wxVariant
&value
);
149 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
150 virtual wxSize
GetSize();
157 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
160 // ---------------------------------------------------------
161 // wxDataViewDateRenderer
162 // ---------------------------------------------------------
164 class wxDataViewDateRenderer
: public wxDataViewCustomRenderer
167 wxDataViewDateRenderer( const wxString
&varianttype
= wxT("datetime"),
168 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
);
170 bool SetValue( const wxVariant
&value
);
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
);
181 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
184 // ---------------------------------------------------------
186 // ---------------------------------------------------------
188 class WXDLLIMPEXP_CORE wxDataViewColumn
: public wxDataViewColumnBase
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();
197 virtual void SetTitle( const wxString
&title
);
198 virtual void SetBitmap( const wxBitmap
&bitmap
);
200 virtual void SetAlignment( wxAlignment align
);
202 virtual void SetSortable( bool sortable
);
203 virtual bool GetSortable();
204 virtual void SetSortOrder( bool ascending
);
205 virtual bool IsSortOrderAscending();
207 virtual int GetWidth();
209 virtual void SetFixedWidth( int width
);
210 virtual int GetFixedWidth();
213 void* GetGtkHandle() { return m_column
; }
216 // holds the GTK handle
219 // delayed connection to mouse events
220 friend class wxDataViewCtrl
;
221 void OnInternalIdle();
225 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn
)
228 // ---------------------------------------------------------
230 // ---------------------------------------------------------
232 class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxDataViewCtrlBase
240 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
241 const wxPoint
& pos
= wxDefaultPosition
,
242 const wxSize
& size
= wxDefaultSize
, long style
= 0,
243 const wxValidator
& validator
= wxDefaultValidator
)
245 Create(parent
, id
, pos
, size
, style
, validator
);
248 virtual ~wxDataViewCtrl();
252 bool Create(wxWindow
*parent
, wxWindowID id
,
253 const wxPoint
& pos
= wxDefaultPosition
,
254 const wxSize
& size
= wxDefaultSize
, long style
= 0,
255 const wxValidator
& validator
= wxDefaultValidator
);
257 virtual bool AssociateModel( wxDataViewListModel
*model
);
258 virtual bool AppendColumn( wxDataViewColumn
*col
);
260 virtual void SetSelection( int row
); // -1 for unselect
261 virtual void SetSelectionRange( unsigned int from
, unsigned int to
);
262 virtual void SetSelections( const wxArrayInt
& aSelections
);
263 virtual void Unselect( unsigned int row
);
265 virtual bool IsSelected( unsigned int row
) const;
266 virtual int GetSelection() const;
267 virtual int GetSelections(wxArrayInt
& aSelections
) const;
270 friend class wxDataViewCtrlDC
;
271 friend class wxDataViewColumn
;
272 friend class wxGtkDataViewListModelNotifier
;
273 GtkWidget
*m_treeview
;
274 wxDataViewListModelNotifier
*m_notifier
;
276 virtual void OnInternalIdle();
279 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
280 DECLARE_NO_COPY_CLASS(wxDataViewCtrl
)
284 #endif // __GTKDATAVIEWCTRLH__