]>
Commit | Line | Data |
---|---|---|
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 | ||
901a462f PC |
10 | #ifndef _WX_GTKDATAVIEWCTRL_H_ |
11 | #define _WX_GTKDATAVIEWCTRL_H_ | |
239eaa41 | 12 | |
239eaa41 | 13 | #include "wx/list.h" |
239eaa41 RR |
14 | |
15 | // --------------------------------------------------------- | |
16 | // classes | |
17 | // --------------------------------------------------------- | |
18 | ||
d350fbec VS |
19 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; |
20 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal; | |
239eaa41 | 21 | |
87f0efe2 | 22 | |
6842a71a | 23 | // --------------------------------------------------------- |
baa9ebc4 | 24 | // wxDataViewRenderer |
6842a71a RR |
25 | // --------------------------------------------------------- |
26 | ||
d350fbec | 27 | class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase |
6842a71a RR |
28 | { |
29 | public: | |
87f0efe2 | 30 | wxDataViewRenderer( const wxString &varianttype, |
9861f022 RR |
31 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
32 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 33 | |
9861f022 RR |
34 | virtual void SetMode( wxDataViewCellMode mode ); |
35 | virtual wxDataViewCellMode GetMode() const; | |
36 | ||
37 | virtual void SetAlignment( int align ); | |
38 | virtual int GetAlignment() const; | |
6842a71a | 39 | |
f71d3ba4 RR |
40 | // implementation |
41 | GtkCellRenderer* GetGtkHandle() { return m_renderer; } | |
42 | void GtkInitHandlers(); | |
4264606e | 43 | virtual bool GtkHasAttributes() { return false; } |
f71d3ba4 | 44 | |
6842a71a | 45 | protected: |
ed38aa55 | 46 | GtkCellRenderer *m_renderer; |
6842a71a RR |
47 | |
48 | protected: | |
baa9ebc4 | 49 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) |
6842a71a | 50 | }; |
9861f022 | 51 | |
6842a71a | 52 | // --------------------------------------------------------- |
baa9ebc4 | 53 | // wxDataViewTextRenderer |
6842a71a RR |
54 | // --------------------------------------------------------- |
55 | ||
d350fbec | 56 | class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer |
6842a71a RR |
57 | { |
58 | public: | |
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 | 68 | protected: |
baa9ebc4 | 69 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) |
6842a71a RR |
70 | }; |
71 | ||
4264606e RR |
72 | // --------------------------------------------------------- |
73 | // wxDataViewTextRendererAttr | |
74 | // --------------------------------------------------------- | |
75 | ||
76 | class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer | |
77 | { | |
78 | public: | |
79 | wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"), | |
80 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
81 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
82 | ||
83 | // implementation | |
84 | bool GtkHasAttributes() { return true; } | |
85 | ||
86 | protected: | |
87 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr) | |
88 | }; | |
89 | ||
cbc9145c | 90 | // --------------------------------------------------------- |
baa9ebc4 | 91 | // wxDataViewBitmapRenderer |
cbc9145c RR |
92 | // --------------------------------------------------------- |
93 | ||
d350fbec | 94 | class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer |
cbc9145c RR |
95 | { |
96 | public: | |
baa9ebc4 | 97 | wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"), |
9861f022 RR |
98 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
99 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
cbc9145c RR |
100 | |
101 | bool SetValue( const wxVariant &value ); | |
9861f022 | 102 | bool GetValue( wxVariant &value ) const; |
cbc9145c RR |
103 | |
104 | protected: | |
baa9ebc4 | 105 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) |
cbc9145c RR |
106 | }; |
107 | ||
605c2c4a | 108 | // --------------------------------------------------------- |
baa9ebc4 | 109 | // wxDataViewToggleRenderer |
605c2c4a RR |
110 | // --------------------------------------------------------- |
111 | ||
d350fbec | 112 | class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer |
605c2c4a RR |
113 | { |
114 | public: | |
baa9ebc4 | 115 | wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"), |
9861f022 RR |
116 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
117 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
605c2c4a RR |
118 | |
119 | bool SetValue( const wxVariant &value ); | |
9861f022 | 120 | bool GetValue( wxVariant &value ) const; |
605c2c4a RR |
121 | |
122 | protected: | |
baa9ebc4 | 123 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) |
605c2c4a RR |
124 | }; |
125 | ||
e152afc3 | 126 | // --------------------------------------------------------- |
baa9ebc4 | 127 | // wxDataViewCustomRenderer |
e152afc3 RR |
128 | // --------------------------------------------------------- |
129 | ||
d350fbec | 130 | class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer |
e152afc3 RR |
131 | { |
132 | public: | |
baa9ebc4 RR |
133 | wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"), |
134 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
9861f022 | 135 | int align = wxDVR_DEFAULT_ALIGNMENT, |
baa9ebc4 RR |
136 | bool no_init = false ); |
137 | virtual ~wxDataViewCustomRenderer(); | |
9861f022 RR |
138 | |
139 | ||
e152afc3 | 140 | virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0; |
52e750fc RR |
141 | |
142 | void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ); | |
143 | ||
9861f022 RR |
144 | virtual wxSize GetSize() const = 0; |
145 | ||
0e9cfa51 RR |
146 | virtual bool Activate( wxRect WXUNUSED(cell), |
147 | wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) ) | |
4d496ecb | 148 | { return false; } |
9861f022 | 149 | |
0e9cfa51 RR |
150 | virtual bool LeftClick( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), |
151 | wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) ) | |
4d496ecb | 152 | { return false; } |
0e9cfa51 RR |
153 | virtual bool StartDrag( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), |
154 | wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) ) | |
4d496ecb | 155 | { return false; } |
e152afc3 RR |
156 | |
157 | // Create DC on request | |
158 | virtual wxDC *GetDC(); | |
159 | ||
9861f022 RR |
160 | |
161 | protected: | |
162 | ||
163 | bool Init(wxDataViewCellMode mode, int align); | |
164 | ||
e152afc3 RR |
165 | private: |
166 | wxDC *m_dc; | |
f69c03de RR |
167 | |
168 | public: | |
169 | // Internal, temporay for RenderText. | |
170 | GtkCellRenderer *m_text_renderer; | |
171 | GdkWindow *window; | |
172 | GtkWidget *widget; | |
173 | void *background_area; | |
174 | void *cell_area; | |
175 | void *expose_area; | |
176 | int flags; | |
177 | ||
e152afc3 | 178 | protected: |
baa9ebc4 | 179 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) |
e152afc3 RR |
180 | }; |
181 | ||
ad63bf41 | 182 | // --------------------------------------------------------- |
baa9ebc4 | 183 | // wxDataViewProgressRenderer |
ad63bf41 RR |
184 | // --------------------------------------------------------- |
185 | ||
d350fbec | 186 | class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer |
ad63bf41 RR |
187 | { |
188 | public: | |
baa9ebc4 RR |
189 | wxDataViewProgressRenderer( const wxString &label = wxEmptyString, |
190 | const wxString &varianttype = wxT("long"), | |
9861f022 RR |
191 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
192 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 193 | virtual ~wxDataViewProgressRenderer(); |
ad63bf41 RR |
194 | |
195 | bool SetValue( const wxVariant &value ); | |
9861f022 | 196 | bool GetValue( wxVariant &value ) const; |
ad63bf41 RR |
197 | |
198 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 199 | virtual wxSize GetSize() const; |
ad63bf41 RR |
200 | |
201 | private: | |
202 | wxString m_label; | |
203 | int m_value; | |
204 | ||
205 | protected: | |
baa9ebc4 | 206 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) |
ad63bf41 RR |
207 | }; |
208 | ||
c9c13e70 RR |
209 | // --------------------------------------------------------- |
210 | // wxDataViewIconTextRenderer | |
211 | // --------------------------------------------------------- | |
212 | ||
d350fbec | 213 | class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer |
c9c13e70 RR |
214 | { |
215 | public: | |
216 | wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), | |
217 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
218 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
219 | virtual ~wxDataViewIconTextRenderer(); | |
220 | ||
221 | bool SetValue( const wxVariant &value ); | |
222 | bool GetValue( wxVariant &value ) const; | |
223 | ||
224 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
225 | virtual wxSize GetSize() const; | |
226 | ||
227 | virtual bool HasEditorCtrl() { return true; } | |
228 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
229 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
230 | ||
231 | private: | |
232 | wxDataViewIconText m_value; | |
233 | ||
234 | protected: | |
235 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) | |
236 | }; | |
237 | ||
4d496ecb | 238 | // --------------------------------------------------------- |
baa9ebc4 | 239 | // wxDataViewDateRenderer |
4d496ecb RR |
240 | // --------------------------------------------------------- |
241 | ||
d350fbec | 242 | class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer |
4d496ecb RR |
243 | { |
244 | public: | |
baa9ebc4 | 245 | wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"), |
9861f022 RR |
246 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
247 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
4d496ecb RR |
248 | |
249 | bool SetValue( const wxVariant &value ); | |
9861f022 | 250 | bool GetValue( wxVariant &value ) const; |
4d496ecb RR |
251 | |
252 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 253 | virtual wxSize GetSize() const; |
4d496ecb | 254 | virtual bool Activate( wxRect cell, |
e0062c04 | 255 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ); |
4d496ecb RR |
256 | |
257 | private: | |
258 | wxDateTime m_date; | |
259 | ||
260 | protected: | |
baa9ebc4 | 261 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) |
4d496ecb RR |
262 | }; |
263 | ||
fa28826d RR |
264 | // --------------------------------------------------------- |
265 | // wxDataViewColumn | |
266 | // --------------------------------------------------------- | |
267 | ||
d350fbec | 268 | class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase |
fa28826d RR |
269 | { |
270 | public: | |
87f0efe2 RR |
271 | wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, |
272 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
273 | wxAlignment align = wxALIGN_CENTER, | |
274 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
275 | wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
276 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
277 | wxAlignment align = wxALIGN_CENTER, | |
278 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
279 | ||
fa28826d RR |
280 | virtual ~wxDataViewColumn(); |
281 | ||
9861f022 RR |
282 | |
283 | // setters: | |
284 | ||
fa28826d | 285 | virtual void SetTitle( const wxString &title ); |
07a84e7b | 286 | virtual void SetBitmap( const wxBitmap &bitmap ); |
47cef10f | 287 | |
b94db696 RR |
288 | virtual void SetOwner( wxDataViewCtrl *owner ); |
289 | ||
47cef10f | 290 | virtual void SetAlignment( wxAlignment align ); |
31fb32e1 RR |
291 | |
292 | virtual void SetSortable( bool sortable ); | |
47cef10f RR |
293 | virtual void SetSortOrder( bool ascending ); |
294 | ||
9861f022 RR |
295 | virtual void SetResizeable( bool resizeable ); |
296 | virtual void SetHidden( bool hidden ); | |
297 | ||
298 | virtual void SetMinWidth( int minWidth ); | |
299 | virtual void SetWidth( int width ); | |
300 | ||
99c75ebc | 301 | virtual void SetReorderable( bool reorderable ); |
9861f022 RR |
302 | |
303 | // getters: | |
304 | ||
305 | virtual wxString GetTitle() const; | |
306 | virtual wxAlignment GetAlignment() const; | |
307 | ||
87f0efe2 RR |
308 | virtual bool IsSortable() const; |
309 | virtual bool IsSortOrderAscending() const; | |
9861f022 RR |
310 | virtual bool IsResizeable() const; |
311 | virtual bool IsHidden() const; | |
87f0efe2 RR |
312 | |
313 | virtual int GetWidth() const; | |
9861f022 | 314 | virtual int GetMinWidth() const; |
99c75ebc RR |
315 | |
316 | virtual bool IsReorderable() const; | |
9861f022 | 317 | |
fa28826d | 318 | // implementation |
9861f022 | 319 | GtkWidget* GetGtkHandle() { return m_column; } |
aed836f3 | 320 | GtkWidget* GetConstGtkHandle() const { return m_column; } |
fa28826d RR |
321 | |
322 | private: | |
6842a71a | 323 | // holds the GTK handle |
9861f022 | 324 | GtkWidget *m_column; |
31fb32e1 RR |
325 | |
326 | // delayed connection to mouse events | |
327 | friend class wxDataViewCtrl; | |
328 | void OnInternalIdle(); | |
9861f022 RR |
329 | bool m_isConnected; |
330 | ||
331 | void Init(wxAlignment align, int flags, int width); | |
332 | ||
fa28826d RR |
333 | protected: |
334 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn) | |
335 | }; | |
336 | ||
d350fbec VS |
337 | WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, |
338 | class WXDLLIMPEXP_ADV); | |
91a6c655 | 339 | |
239eaa41 RR |
340 | // --------------------------------------------------------- |
341 | // wxDataViewCtrl | |
342 | // --------------------------------------------------------- | |
343 | ||
d350fbec | 344 | class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase |
239eaa41 RR |
345 | { |
346 | public: | |
347 | wxDataViewCtrl() | |
348 | { | |
349 | Init(); | |
350 | } | |
351 | ||
352 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, | |
353 | const wxPoint& pos = wxDefaultPosition, | |
354 | const wxSize& size = wxDefaultSize, long style = 0, | |
355 | const wxValidator& validator = wxDefaultValidator ) | |
356 | { | |
357 | Create(parent, id, pos, size, style, validator ); | |
358 | } | |
359 | ||
360 | virtual ~wxDataViewCtrl(); | |
361 | ||
362 | void Init(); | |
363 | ||
364 | bool Create(wxWindow *parent, wxWindowID id, | |
365 | const wxPoint& pos = wxDefaultPosition, | |
366 | const wxSize& size = wxDefaultSize, long style = 0, | |
367 | const wxValidator& validator = wxDefaultValidator ); | |
368 | ||
e0062c04 | 369 | virtual bool AssociateModel( wxDataViewModel *model ); |
91a6c655 | 370 | |
736fe67c | 371 | virtual bool PrependColumn( wxDataViewColumn *col ); |
1a367564 | 372 | virtual bool AppendColumn( wxDataViewColumn *col ); |
91a6c655 RR |
373 | virtual unsigned int GetColumnCount() const; |
374 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; | |
375 | virtual bool DeleteColumn( wxDataViewColumn *column ); | |
376 | virtual bool ClearColumns(); | |
453091c2 | 377 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const; |
1e08ad10 | 378 | |
21f47fb9 RR |
379 | virtual wxDataViewColumn *GetSortingColumn() const; |
380 | ||
fbda518c | 381 | virtual wxDataViewItem GetSelection() const; |
e98351ec RR |
382 | virtual int GetSelections( wxDataViewItemArray & sel ) const; |
383 | virtual void SetSelections( const wxDataViewItemArray & sel ); | |
384 | virtual void Select( const wxDataViewItem & item ); | |
385 | virtual void Unselect( const wxDataViewItem & item ); | |
386 | virtual bool IsSelected( const wxDataViewItem & item ) const; | |
387 | virtual void SelectAll(); | |
388 | virtual void UnselectAll(); | |
389 | ||
fbda518c RR |
390 | virtual void EnsureVisible( const wxDataViewItem& item, |
391 | const wxDataViewColumn *column = NULL ); | |
66e09788 | 392 | virtual void HitTest( const wxPoint &point, |
fbda518c | 393 | wxDataViewItem &item, |
a87b466d | 394 | wxDataViewColumn *&column ) const; |
66e09788 | 395 | virtual wxRect GetItemRect( const wxDataViewItem &item, |
fbda518c | 396 | const wxDataViewColumn *column = NULL ) const; |
66e09788 | 397 | |
f71d3ba4 RR |
398 | virtual void Expand( const wxDataViewItem & item ); |
399 | virtual void Collapse( const wxDataViewItem & item ); | |
66e09788 | 400 | |
b94db696 RR |
401 | static wxVisualAttributes |
402 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
6ff7eee7 | 403 | |
1e510b1e | 404 | wxWindow *GetMainWindow() { return (wxWindow*) this; } |
55fbde12 RR |
405 | |
406 | GtkWidget *GtkGetTreeView() { return m_treeview; } | |
407 | wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; } | |
3b6280be | 408 | |
901a462f PC |
409 | virtual void OnInternalIdle(); |
410 | ||
3b6280be RR |
411 | protected: |
412 | virtual void DoSetExpanderColumn(); | |
413 | virtual void DoSetIndent(); | |
414 | ||
1a367564 | 415 | private: |
888dde65 | 416 | friend class wxDataViewCtrlDCImpl; |
31fb32e1 | 417 | friend class wxDataViewColumn; |
e0062c04 | 418 | friend class wxGtkDataViewModelNotifier; |
33ba5a05 RR |
419 | friend class wxDataViewCtrlInternal; |
420 | ||
e0062c04 RR |
421 | GtkWidget *m_treeview; |
422 | wxDataViewModelNotifier *m_notifier; | |
55fbde12 | 423 | wxDataViewCtrlInternal *m_internal; |
91a6c655 | 424 | wxDataViewColumnList m_cols; |
3b6280be | 425 | |
b086d55f RR |
426 | void GtkEnableSelectionEvents(); |
427 | void GtkDisableSelectionEvents(); | |
428 | ||
239eaa41 RR |
429 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) |
430 | DECLARE_NO_COPY_CLASS(wxDataViewCtrl) | |
431 | }; | |
432 | ||
433 | ||
901a462f | 434 | #endif // _WX_GTKDATAVIEWCTRL_H_ |