2009-11-10 12:40:58 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gtk/dvrenderer.h
|
|
|
|
// Purpose: wxDataViewRenderer for GTK wxDataViewCtrl implementation
|
|
|
|
// Author: Robert Roebling, Vadim Zeitlin
|
|
|
|
// Created: 2009-11-07 (extracted from wx/gtk/dataview.h)
|
|
|
|
// Copyright: (c) 2006 Robert Roebling
|
|
|
|
// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GTK_DVRENDERER_H_
|
|
|
|
#define _WX_GTK_DVRENDERER_H_
|
|
|
|
|
2009-11-10 20:50:06 -05:00
|
|
|
typedef struct _GtkCellRendererText GtkCellRendererText;
|
2009-11-10 12:40:58 -05:00
|
|
|
typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewRenderer
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewRenderer( const wxString &varianttype,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void SetMode( wxDataViewCellMode mode ) wxOVERRIDE;
|
|
|
|
virtual wxDataViewCellMode GetMode() const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void SetAlignment( int align ) wxOVERRIDE;
|
|
|
|
virtual int GetAlignment() const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) wxOVERRIDE;
|
|
|
|
virtual wxEllipsizeMode GetEllipsizeMode() const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-04-26 14:01:44 -04:00
|
|
|
virtual bool FinishEditing() wxOVERRIDE;
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
// GTK-specific implementation
|
|
|
|
// ---------------------------
|
|
|
|
|
|
|
|
// pack the GTK cell renderers used by this renderer to the given column
|
|
|
|
//
|
|
|
|
// by default only a single m_renderer is used but some renderers use more
|
|
|
|
// than one GTK cell renderer
|
|
|
|
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
|
|
|
|
|
|
|
|
// called when the cell value was edited by user with the new value
|
|
|
|
//
|
2018-02-04 18:01:52 -05:00
|
|
|
// it uses GtkGetValueFromString() to parse the new value, then validates
|
|
|
|
// it by calling Validate() and notifies the model about the change if it
|
|
|
|
// passes validation
|
|
|
|
void GtkOnTextEdited(const char *itempath, const wxString& value);
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
|
|
|
void GtkInitHandlers();
|
2016-10-21 11:50:34 -04:00
|
|
|
virtual void GtkUpdateAlignment() { GtkApplyAlignment(m_renderer); }
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2009-11-10 20:50:06 -05:00
|
|
|
// return the text renderer used by this renderer for setting text cell
|
|
|
|
// specific attributes: can return NULL if this renderer doesn't render any
|
|
|
|
// text
|
|
|
|
virtual GtkCellRendererText *GtkGetTextRenderer() const { return NULL; }
|
2015-02-10 18:14:48 -05:00
|
|
|
|
2016-02-28 12:03:35 -05:00
|
|
|
// return the widget actually used by the renderer for editing, this may be
|
|
|
|
// different from the editor control widget for the custom renderers
|
|
|
|
virtual GtkWidget* GtkGetEditorWidget() const;
|
|
|
|
|
2016-11-21 12:07:32 -05:00
|
|
|
void GtkSetCurrentItem(const wxDataViewItem& item) { m_itemBeingRendered = item; }
|
|
|
|
|
2015-08-28 19:03:42 -04:00
|
|
|
private:
|
2015-02-10 18:14:48 -05:00
|
|
|
// Change the mode at GTK level without touching m_mode, this is useful for
|
|
|
|
// temporarily making the renderer insensitive but does mean that GetMode()
|
|
|
|
// may return a value different from the actual GTK renderer mode.
|
|
|
|
void GtkSetMode(wxDataViewCellMode mode);
|
2009-11-10 20:50:06 -05:00
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
protected:
|
2015-08-28 19:03:42 -04:00
|
|
|
virtual void SetAttr(const wxDataViewItemAttr& attr) wxOVERRIDE;
|
|
|
|
virtual void SetEnabled(bool enabled) wxOVERRIDE;
|
|
|
|
|
2016-11-21 12:07:32 -05:00
|
|
|
virtual bool IsHighlighted() const wxOVERRIDE;
|
|
|
|
|
2011-07-21 09:50:22 -04:00
|
|
|
// Apply our effective alignment (i.e. m_alignment if specified or the
|
|
|
|
// associated column alignment by default) to the given renderer.
|
|
|
|
void GtkApplyAlignment(GtkCellRenderer *renderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2018-02-04 18:01:52 -05:00
|
|
|
// This method is used to interpret the string entered by user and by
|
|
|
|
// default just uses it as is, but can be overridden for classes requiring
|
|
|
|
// special treatment.
|
|
|
|
virtual wxVariant GtkGetValueFromString(const wxString& str) const;
|
|
|
|
|
|
|
|
|
2010-12-19 14:43:46 -05:00
|
|
|
GtkCellRenderer *m_renderer;
|
|
|
|
int m_alignment;
|
2015-02-10 18:14:48 -05:00
|
|
|
|
|
|
|
// We store the renderer mode at wx level as it can differ from the mode of
|
|
|
|
// the corresponding GTK+ renderer as explained above.
|
2010-12-19 14:43:46 -05:00
|
|
|
wxDataViewCellMode m_mode;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
// true if we hadn't changed any visual attributes or restored them since
|
|
|
|
// doing this
|
|
|
|
bool m_usingDefaultAttrs;
|
|
|
|
|
2016-11-21 12:07:32 -05:00
|
|
|
// the item currently being rendered
|
|
|
|
wxDataViewItem m_itemBeingRendered;
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
protected:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_GTK_DVRENDERER_H_
|
|
|
|
|