]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dvrenderer.h
Fix bug with using invalid date in wxMSW wxCalendarCtrl.
[wxWidgets.git] / include / wx / gtk / dvrenderer.h
CommitLineData
6eec70b9
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/dvrenderer.h
3// Purpose: wxDataViewRenderer for GTK wxDataViewCtrl implementation
4// Author: Robert Roebling, Vadim Zeitlin
5// Created: 2009-11-07 (extracted from wx/gtk/dataview.h)
b1153ed6 6// RCS-ID: $Id$
6eec70b9
VZ
7// Copyright: (c) 2006 Robert Roebling
8// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GTK_DVRENDERER_H_
13#define _WX_GTK_DVRENDERER_H_
14
17cbc244 15typedef struct _GtkCellRendererText GtkCellRendererText;
6eec70b9
VZ
16typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
17
18// ----------------------------------------------------------------------------
19// wxDataViewRenderer
20// ----------------------------------------------------------------------------
21
22class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
23{
24public:
25 wxDataViewRenderer( const wxString &varianttype,
26 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
27 int align = wxDVR_DEFAULT_ALIGNMENT );
28
29 virtual void SetMode( wxDataViewCellMode mode );
30 virtual wxDataViewCellMode GetMode() const;
31
32 virtual void SetAlignment( int align );
33 virtual int GetAlignment() const;
34
35 virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
36 virtual wxEllipsizeMode GetEllipsizeMode() const;
37
38 // GTK-specific implementation
39 // ---------------------------
40
41 // pack the GTK cell renderers used by this renderer to the given column
42 //
43 // by default only a single m_renderer is used but some renderers use more
44 // than one GTK cell renderer
45 virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
46
47 // called when the cell value was edited by user with the new value
48 //
49 // it validates the new value and notifies the model about the change by
50 // calling GtkOnCellChanged() if it was accepted
29e461a2 51 virtual void GtkOnTextEdited(const char *itempath, const wxString& value);
6eec70b9
VZ
52
53 GtkCellRenderer* GetGtkHandle() { return m_renderer; }
54 void GtkInitHandlers();
3e81bbbf 55 void GtkUpdateAlignment() { GtkApplyAlignment(m_renderer); }
6eec70b9 56
c2a738e3
VZ
57 // should be overridden to return true if the renderer supports properties
58 // corresponding to wxDataViewItemAttr field, see wxGtkTreeCellDataFunc()
59 // for details
60 virtual bool GtkSupportsAttrs() const { return false; }
61
c80cde00
VZ
62 // if GtkSupportsAttrs() returns true, this function will be called to
63 // effectively set the attribute to use for rendering the next item
64 //
65 // it should return true if the attribute had any non-default properties
66 virtual bool GtkSetAttr(const wxDataViewItemAttr& WXUNUSED(attr))
67 { return false; }
68
69
c2a738e3
VZ
70 // these functions are only called if GtkSupportsAttrs() returns true and
71 // are used to remember whether the renderer currently uses the default
72 // attributes or if we changed (and not reset them)
6eec70b9
VZ
73 bool GtkIsUsingDefaultAttrs() const { return m_usingDefaultAttrs; }
74 void GtkSetUsingDefaultAttrs(bool def) { m_usingDefaultAttrs = def; }
75
17cbc244
VZ
76 // return the text renderer used by this renderer for setting text cell
77 // specific attributes: can return NULL if this renderer doesn't render any
78 // text
79 virtual GtkCellRendererText *GtkGetTextRenderer() const { return NULL; }
9fc221aa
RR
80
81 wxDataViewCellMode GtkGetMode() { return m_mode; }
17cbc244 82
6eec70b9
VZ
83protected:
84 virtual void GtkOnCellChanged(const wxVariant& value,
85 const wxDataViewItem& item,
86 unsigned col);
87
3e81bbbf
VZ
88 // Apply our effective alignment (i.e. m_alignment if specified or the
89 // associated column alignment by default) to the given renderer.
90 void GtkApplyAlignment(GtkCellRenderer *renderer);
6eec70b9 91
9fc221aa
RR
92 GtkCellRenderer *m_renderer;
93 int m_alignment;
94 wxDataViewCellMode m_mode;
6eec70b9
VZ
95
96 // true if we hadn't changed any visual attributes or restored them since
97 // doing this
98 bool m_usingDefaultAttrs;
99
100protected:
101 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
102};
103
104#endif // _WX_GTK_DVRENDERER_H_
105