2009-11-10 12:40:58 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gtk/dvrenderers.h
|
|
|
|
// Purpose: All GTK wxDataViewCtrl renderer classes
|
|
|
|
// 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_DVRENDERERS_H_
|
|
|
|
#define _WX_GTK_DVRENDERERS_H_
|
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
|
|
|
|
typedef cairo_rectangle_int_t GdkRectangle;
|
|
|
|
#else
|
|
|
|
typedef struct _GdkRectangle GdkRectangle;
|
|
|
|
#endif
|
2009-11-10 12:41:28 -05:00
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewTextRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("string"); }
|
|
|
|
|
|
|
|
wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
2016-06-04 19:30:46 -04:00
|
|
|
#if wxUSE_MARKUP
|
|
|
|
void EnableMarkup(bool enable = true);
|
|
|
|
#endif // wxUSE_MARKUP
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual bool SetValue( const wxVariant &value ) wxOVERRIDE
|
2009-11-10 12:40:58 -05:00
|
|
|
{
|
|
|
|
return SetTextValue(value);
|
|
|
|
}
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual bool GetValue( wxVariant &value ) const wxOVERRIDE
|
2009-11-10 12:40:58 -05:00
|
|
|
{
|
|
|
|
wxString str;
|
|
|
|
if ( !GetTextValue(str) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
value = str;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:50:34 -04:00
|
|
|
virtual void GtkUpdateAlignment() wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual GtkCellRendererText *GtkGetTextRenderer() const wxOVERRIDE;
|
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;
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
// implementation of Set/GetValue()
|
|
|
|
bool SetTextValue(const wxString& str);
|
|
|
|
bool GetTextValue(wxString& str) const;
|
|
|
|
|
2016-06-04 19:30:46 -04:00
|
|
|
// Return the name of the GtkCellRendererText property to use: "text" or
|
|
|
|
// "markup".
|
|
|
|
const char* GetTextPropertyName() const;
|
|
|
|
|
|
|
|
#if wxUSE_MARKUP
|
|
|
|
// True if we should interpret markup in our text.
|
|
|
|
bool m_useMarkup;
|
|
|
|
#endif // wxUSE_MARKUP
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewBitmapRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("wxBitmap"); }
|
|
|
|
|
|
|
|
wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
protected:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewToggleRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("bool"); }
|
|
|
|
|
|
|
|
wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
2018-07-10 19:13:22 -04:00
|
|
|
void ShowAsRadio();
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
protected:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewCustomRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("string"); }
|
|
|
|
|
|
|
|
wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT,
|
|
|
|
bool no_init = false );
|
|
|
|
virtual ~wxDataViewCustomRenderer();
|
|
|
|
|
|
|
|
|
|
|
|
// Create DC on request
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual wxDC *GetDC() wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2009-11-10 12:41:11 -05:00
|
|
|
// override the base class function to use GTK text cell renderer
|
|
|
|
virtual void RenderText(const wxString& text,
|
|
|
|
int xoffset,
|
|
|
|
wxRect cell,
|
|
|
|
wxDC *dc,
|
2015-09-06 20:20:42 -04:00
|
|
|
int state) wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2012-01-09 01:31:07 -05:00
|
|
|
struct GTKRenderParams;
|
|
|
|
|
2009-11-10 12:41:50 -05:00
|
|
|
// store GTK render call parameters for possible later use
|
2012-01-09 01:31:07 -05:00
|
|
|
void GTKSetRenderParams(GTKRenderParams* renderParams)
|
2009-11-10 12:41:50 -05:00
|
|
|
{
|
2012-01-09 01:31:07 -05:00
|
|
|
m_renderParams = renderParams;
|
2009-11-10 12:41:50 -05:00
|
|
|
}
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual GtkCellRendererText *GtkGetTextRenderer() const wxOVERRIDE;
|
2016-02-28 12:03:35 -05:00
|
|
|
virtual GtkWidget* GtkGetEditorWidget() const wxOVERRIDE;
|
2009-11-10 20:50:06 -05:00
|
|
|
|
2016-10-21 11:50:34 -04:00
|
|
|
virtual void GtkUpdateAlignment() wxOVERRIDE;
|
|
|
|
|
2012-10-02 11:57:03 -04:00
|
|
|
private:
|
2009-11-10 12:40:58 -05:00
|
|
|
bool Init(wxDataViewCellMode mode, int align);
|
|
|
|
|
2011-07-21 09:50:22 -04:00
|
|
|
// Called from GtkGetTextRenderer() to really create the renderer if
|
|
|
|
// necessary.
|
|
|
|
void GtkInitTextRenderer();
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDC *m_dc;
|
|
|
|
|
2009-11-10 12:41:58 -05:00
|
|
|
GtkCellRendererText *m_text_renderer;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2009-11-10 12:41:50 -05:00
|
|
|
// parameters of the original render() call stored so that we could pass
|
|
|
|
// them forward to m_text_renderer if our RenderText() is called
|
2012-01-09 01:31:07 -05:00
|
|
|
GTKRenderParams* m_renderParams;
|
2009-11-10 12:41:50 -05:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewProgressRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("long"); }
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
|
2014-12-20 16:51:54 -05:00
|
|
|
const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual ~wxDataViewProgressRenderer();
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state ) wxOVERRIDE;
|
|
|
|
virtual wxSize GetSize() const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
private:
|
2011-07-04 05:03:00 -04:00
|
|
|
void GTKSetLabel();
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
wxString m_label;
|
|
|
|
int m_value;
|
|
|
|
|
2011-07-04 05:03:00 -04:00
|
|
|
#if !wxUSE_UNICODE
|
|
|
|
// Flag used to indicate that we need to set the label because we were
|
|
|
|
// unable to do it in the ctor (see comments there).
|
|
|
|
bool m_needsToSetLabel;
|
|
|
|
#endif // !wxUSE_UNICODE
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
protected:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewIconTextRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
|
|
|
|
{
|
|
|
|
public:
|
2014-12-20 16:51:54 -05:00
|
|
|
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
|
|
|
|
|
|
|
|
wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
|
2009-11-10 12:40:58 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual ~wxDataViewIconTextRenderer();
|
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column) wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
protected:
|
2018-02-04 18:01:52 -05:00
|
|
|
virtual wxVariant GtkGetValueFromString(const wxString& str) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewIconText m_value;
|
|
|
|
|
|
|
|
// we use the base class m_renderer for the text and this one for the icon
|
|
|
|
GtkCellRenderer *m_rendererIcon;
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer);
|
2009-11-10 12:40:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// wxDataViewChoiceRenderer
|
|
|
|
// -------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewChoiceRenderer(const wxArrayString &choices,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
|
|
|
|
int alignment = wxDVR_DEFAULT_ALIGNMENT );
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual bool Render( wxRect rect, wxDC *dc, int state ) wxOVERRIDE;
|
|
|
|
virtual wxSize GetSize() const wxOVERRIDE;
|
|
|
|
virtual bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
virtual bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2016-10-21 11:50:34 -04:00
|
|
|
virtual void GtkUpdateAlignment() wxOVERRIDE;
|
2009-11-10 12:40:58 -05:00
|
|
|
|
2010-05-16 11:29:35 -04:00
|
|
|
wxString GetChoice(size_t index) const { return m_choices[index]; }
|
|
|
|
const wxArrayString& GetChoices() const { return m_choices; }
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
private:
|
|
|
|
wxArrayString m_choices;
|
|
|
|
wxString m_data;
|
|
|
|
};
|
|
|
|
|
2010-05-21 16:13:49 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewChoiceByIndexRenderer
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewChoiceByIndexRenderer: public wxDataViewChoiceRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
|
|
|
|
int alignment = wxDVR_DEFAULT_ALIGNMENT );
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2015-09-06 20:20:42 -04:00
|
|
|
virtual bool SetValue( const wxVariant &value ) wxOVERRIDE;
|
|
|
|
virtual bool GetValue( wxVariant &value ) const wxOVERRIDE;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-05-21 16:13:49 -04:00
|
|
|
private:
|
2018-02-06 07:29:32 -05:00
|
|
|
virtual wxVariant GtkGetValueFromString(const wxString& str) const wxOVERRIDE;
|
2010-05-21 16:13:49 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
#endif // _WX_GTK_DVRENDERERS_H_
|
|
|
|
|