]>
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 RightClick( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), |
154 | wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) ) | |
4d496ecb | 155 | { return false; } |
0e9cfa51 RR |
156 | virtual bool StartDrag( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell), |
157 | wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) ) | |
4d496ecb | 158 | { return false; } |
e152afc3 RR |
159 | |
160 | // Create DC on request | |
161 | virtual wxDC *GetDC(); | |
162 | ||
9861f022 RR |
163 | |
164 | protected: | |
165 | ||
166 | bool Init(wxDataViewCellMode mode, int align); | |
167 | ||
e152afc3 RR |
168 | private: |
169 | wxDC *m_dc; | |
f69c03de RR |
170 | |
171 | public: | |
172 | // Internal, temporay for RenderText. | |
173 | GtkCellRenderer *m_text_renderer; | |
174 | GdkWindow *window; | |
175 | GtkWidget *widget; | |
176 | void *background_area; | |
177 | void *cell_area; | |
178 | void *expose_area; | |
179 | int flags; | |
180 | ||
e152afc3 | 181 | protected: |
baa9ebc4 | 182 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) |
e152afc3 RR |
183 | }; |
184 | ||
ad63bf41 | 185 | // --------------------------------------------------------- |
baa9ebc4 | 186 | // wxDataViewProgressRenderer |
ad63bf41 RR |
187 | // --------------------------------------------------------- |
188 | ||
d350fbec | 189 | class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer |
ad63bf41 RR |
190 | { |
191 | public: | |
baa9ebc4 RR |
192 | wxDataViewProgressRenderer( const wxString &label = wxEmptyString, |
193 | const wxString &varianttype = wxT("long"), | |
9861f022 RR |
194 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
195 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 196 | virtual ~wxDataViewProgressRenderer(); |
ad63bf41 RR |
197 | |
198 | bool SetValue( const wxVariant &value ); | |
9861f022 | 199 | bool GetValue( wxVariant &value ) const; |
ad63bf41 RR |
200 | |
201 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 202 | virtual wxSize GetSize() const; |
ad63bf41 RR |
203 | |
204 | private: | |
205 | wxString m_label; | |
206 | int m_value; | |
207 | ||
208 | protected: | |
baa9ebc4 | 209 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) |
ad63bf41 RR |
210 | }; |
211 | ||
c9c13e70 RR |
212 | // --------------------------------------------------------- |
213 | // wxDataViewIconTextRenderer | |
214 | // --------------------------------------------------------- | |
215 | ||
d350fbec | 216 | class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer |
c9c13e70 RR |
217 | { |
218 | public: | |
219 | wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), | |
220 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
221 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
222 | virtual ~wxDataViewIconTextRenderer(); | |
223 | ||
224 | bool SetValue( const wxVariant &value ); | |
225 | bool GetValue( wxVariant &value ) const; | |
226 | ||
227 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
228 | virtual wxSize GetSize() const; | |
229 | ||
230 | virtual bool HasEditorCtrl() { return true; } | |
231 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
232 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
233 | ||
234 | private: | |
235 | wxDataViewIconText m_value; | |
236 | ||
237 | protected: | |
238 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) | |
239 | }; | |
240 | ||
4d496ecb | 241 | // --------------------------------------------------------- |
baa9ebc4 | 242 | // wxDataViewDateRenderer |
4d496ecb RR |
243 | // --------------------------------------------------------- |
244 | ||
d350fbec | 245 | class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer |
4d496ecb RR |
246 | { |
247 | public: | |
baa9ebc4 | 248 | wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"), |
9861f022 RR |
249 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
250 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
4d496ecb RR |
251 | |
252 | bool SetValue( const wxVariant &value ); | |
9861f022 | 253 | bool GetValue( wxVariant &value ) const; |
4d496ecb RR |
254 | |
255 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 256 | virtual wxSize GetSize() const; |
4d496ecb | 257 | virtual bool Activate( wxRect cell, |
e0062c04 | 258 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ); |
4d496ecb RR |
259 | |
260 | private: | |
261 | wxDateTime m_date; | |
262 | ||
263 | protected: | |
baa9ebc4 | 264 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) |
4d496ecb RR |
265 | }; |
266 | ||
fa28826d RR |
267 | // --------------------------------------------------------- |
268 | // wxDataViewColumn | |
269 | // --------------------------------------------------------- | |
270 | ||
d350fbec | 271 | class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase |
fa28826d RR |
272 | { |
273 | public: | |
87f0efe2 RR |
274 | wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, |
275 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
276 | wxAlignment align = wxALIGN_CENTER, | |
277 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
278 | wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
279 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
280 | wxAlignment align = wxALIGN_CENTER, | |
281 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
282 | ||
fa28826d RR |
283 | virtual ~wxDataViewColumn(); |
284 | ||
9861f022 RR |
285 | |
286 | // setters: | |
287 | ||
fa28826d | 288 | virtual void SetTitle( const wxString &title ); |
07a84e7b | 289 | virtual void SetBitmap( const wxBitmap &bitmap ); |
47cef10f | 290 | |
b94db696 RR |
291 | virtual void SetOwner( wxDataViewCtrl *owner ); |
292 | ||
47cef10f | 293 | virtual void SetAlignment( wxAlignment align ); |
31fb32e1 RR |
294 | |
295 | virtual void SetSortable( bool sortable ); | |
47cef10f RR |
296 | virtual void SetSortOrder( bool ascending ); |
297 | ||
9861f022 RR |
298 | virtual void SetResizeable( bool resizeable ); |
299 | virtual void SetHidden( bool hidden ); | |
300 | ||
301 | virtual void SetMinWidth( int minWidth ); | |
302 | virtual void SetWidth( int width ); | |
303 | ||
99c75ebc | 304 | virtual void SetReorderable( bool reorderable ); |
9861f022 RR |
305 | |
306 | // getters: | |
307 | ||
308 | virtual wxString GetTitle() const; | |
309 | virtual wxAlignment GetAlignment() const; | |
310 | ||
87f0efe2 RR |
311 | virtual bool IsSortable() const; |
312 | virtual bool IsSortOrderAscending() const; | |
9861f022 RR |
313 | virtual bool IsResizeable() const; |
314 | virtual bool IsHidden() const; | |
87f0efe2 RR |
315 | |
316 | virtual int GetWidth() const; | |
9861f022 | 317 | virtual int GetMinWidth() const; |
99c75ebc RR |
318 | |
319 | virtual bool IsReorderable() const; | |
9861f022 | 320 | |
fa28826d | 321 | // implementation |
9861f022 | 322 | GtkWidget* GetGtkHandle() { return m_column; } |
aed836f3 | 323 | GtkWidget* GetConstGtkHandle() const { return m_column; } |
fa28826d RR |
324 | |
325 | private: | |
6842a71a | 326 | // holds the GTK handle |
9861f022 | 327 | GtkWidget *m_column; |
31fb32e1 RR |
328 | |
329 | // delayed connection to mouse events | |
330 | friend class wxDataViewCtrl; | |
331 | void OnInternalIdle(); | |
9861f022 RR |
332 | bool m_isConnected; |
333 | ||
334 | void Init(wxAlignment align, int flags, int width); | |
335 | ||
fa28826d RR |
336 | protected: |
337 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn) | |
338 | }; | |
339 | ||
d350fbec VS |
340 | WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, |
341 | class WXDLLIMPEXP_ADV); | |
91a6c655 | 342 | |
239eaa41 RR |
343 | // --------------------------------------------------------- |
344 | // wxDataViewCtrl | |
345 | // --------------------------------------------------------- | |
346 | ||
d350fbec | 347 | class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase |
239eaa41 RR |
348 | { |
349 | public: | |
350 | wxDataViewCtrl() | |
351 | { | |
352 | Init(); | |
353 | } | |
354 | ||
355 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, | |
356 | const wxPoint& pos = wxDefaultPosition, | |
357 | const wxSize& size = wxDefaultSize, long style = 0, | |
358 | const wxValidator& validator = wxDefaultValidator ) | |
359 | { | |
360 | Create(parent, id, pos, size, style, validator ); | |
361 | } | |
362 | ||
363 | virtual ~wxDataViewCtrl(); | |
364 | ||
365 | void Init(); | |
366 | ||
367 | bool Create(wxWindow *parent, wxWindowID id, | |
368 | const wxPoint& pos = wxDefaultPosition, | |
369 | const wxSize& size = wxDefaultSize, long style = 0, | |
370 | const wxValidator& validator = wxDefaultValidator ); | |
371 | ||
e0062c04 | 372 | virtual bool AssociateModel( wxDataViewModel *model ); |
91a6c655 | 373 | |
736fe67c | 374 | virtual bool PrependColumn( wxDataViewColumn *col ); |
1a367564 | 375 | virtual bool AppendColumn( wxDataViewColumn *col ); |
91a6c655 RR |
376 | virtual unsigned int GetColumnCount() const; |
377 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; | |
378 | virtual bool DeleteColumn( wxDataViewColumn *column ); | |
379 | virtual bool ClearColumns(); | |
453091c2 | 380 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const; |
1e08ad10 | 381 | |
21f47fb9 RR |
382 | virtual wxDataViewColumn *GetSortingColumn() const; |
383 | ||
fbda518c | 384 | virtual wxDataViewItem GetSelection() const; |
e98351ec RR |
385 | virtual int GetSelections( wxDataViewItemArray & sel ) const; |
386 | virtual void SetSelections( const wxDataViewItemArray & sel ); | |
387 | virtual void Select( const wxDataViewItem & item ); | |
388 | virtual void Unselect( const wxDataViewItem & item ); | |
389 | virtual bool IsSelected( const wxDataViewItem & item ) const; | |
390 | virtual void SelectAll(); | |
391 | virtual void UnselectAll(); | |
392 | ||
fbda518c RR |
393 | virtual void EnsureVisible( const wxDataViewItem& item, |
394 | const wxDataViewColumn *column = NULL ); | |
66e09788 | 395 | virtual void HitTest( const wxPoint &point, |
fbda518c | 396 | wxDataViewItem &item, |
a87b466d | 397 | wxDataViewColumn *&column ) const; |
66e09788 | 398 | virtual wxRect GetItemRect( const wxDataViewItem &item, |
fbda518c | 399 | const wxDataViewColumn *column = NULL ) const; |
66e09788 | 400 | |
f71d3ba4 RR |
401 | virtual void Expand( const wxDataViewItem & item ); |
402 | virtual void Collapse( const wxDataViewItem & item ); | |
66e09788 | 403 | |
b94db696 RR |
404 | static wxVisualAttributes |
405 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
6ff7eee7 | 406 | |
1e510b1e | 407 | wxWindow *GetMainWindow() { return (wxWindow*) this; } |
55fbde12 RR |
408 | |
409 | GtkWidget *GtkGetTreeView() { return m_treeview; } | |
410 | wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; } | |
3b6280be | 411 | |
901a462f PC |
412 | virtual void OnInternalIdle(); |
413 | ||
3b6280be RR |
414 | protected: |
415 | virtual void DoSetExpanderColumn(); | |
416 | virtual void DoSetIndent(); | |
417 | ||
1a367564 | 418 | private: |
888dde65 | 419 | friend class wxDataViewCtrlDCImpl; |
31fb32e1 | 420 | friend class wxDataViewColumn; |
e0062c04 | 421 | friend class wxGtkDataViewModelNotifier; |
33ba5a05 RR |
422 | friend class wxDataViewCtrlInternal; |
423 | ||
e0062c04 RR |
424 | GtkWidget *m_treeview; |
425 | wxDataViewModelNotifier *m_notifier; | |
55fbde12 | 426 | wxDataViewCtrlInternal *m_internal; |
91a6c655 | 427 | wxDataViewColumnList m_cols; |
3b6280be | 428 | |
b086d55f RR |
429 | void GtkEnableSelectionEvents(); |
430 | void GtkDisableSelectionEvents(); | |
431 | ||
239eaa41 RR |
432 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) |
433 | DECLARE_NO_COPY_CLASS(wxDataViewCtrl) | |
434 | }; | |
435 | ||
436 | ||
901a462f | 437 | #endif // _WX_GTKDATAVIEWCTRL_H_ |