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)
|
2010-04-25 17:33:16 -04:00
|
|
|
// RCS-ID: $Id$
|
2009-11-10 12:40:58 -05:00
|
|
|
// 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_
|
|
|
|
|
2009-11-10 12:41:28 -05:00
|
|
|
typedef struct _GdkRectangle GdkRectangle;
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewTextRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewTextRenderer( const wxString &varianttype = "string",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
|
|
|
virtual bool SetValue( const wxVariant &value )
|
|
|
|
{
|
|
|
|
return SetTextValue(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool GetValue( wxVariant &value ) const
|
|
|
|
{
|
|
|
|
wxString str;
|
|
|
|
if ( !GetTextValue(str) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
value = str;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetAlignment( int align );
|
|
|
|
|
2009-11-10 12:41:22 -05:00
|
|
|
virtual bool GtkSupportsAttrs() const { return true; }
|
2009-11-10 12:41:58 -05:00
|
|
|
virtual bool GtkSetAttr(const wxDataViewItemAttr& attr);
|
2009-11-10 12:41:22 -05:00
|
|
|
|
2009-11-10 20:50:06 -05:00
|
|
|
virtual GtkCellRendererText *GtkGetTextRenderer() const;
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
protected:
|
|
|
|
// implementation of Set/GetValue()
|
|
|
|
bool SetTextValue(const wxString& str);
|
|
|
|
bool GetTextValue(wxString& str) const;
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewBitmapRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewBitmapRenderer( const wxString &varianttype = "wxBitmap",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewToggleRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewToggleRenderer( const wxString &varianttype = "bool",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewCustomRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCustomRenderer( const wxString &varianttype = "string",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT,
|
|
|
|
bool no_init = false );
|
|
|
|
virtual ~wxDataViewCustomRenderer();
|
|
|
|
|
|
|
|
|
|
|
|
// Create DC on request
|
|
|
|
virtual wxDC *GetDC();
|
|
|
|
|
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,
|
|
|
|
int state);
|
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
|
|
|
|
2009-11-10 12:41:58 -05:00
|
|
|
// we may or not support attributes, as we don't know it, return true to
|
|
|
|
// make it possible to use them
|
|
|
|
virtual bool GtkSupportsAttrs() const { return true; }
|
|
|
|
|
|
|
|
virtual bool GtkSetAttr(const wxDataViewItemAttr& attr)
|
|
|
|
{
|
|
|
|
SetAttr(attr);
|
|
|
|
return !attr.IsDefault();
|
|
|
|
}
|
|
|
|
|
2009-11-10 20:50:06 -05:00
|
|
|
virtual GtkCellRendererText *GtkGetTextRenderer() const;
|
|
|
|
|
2009-11-10 12:41:50 -05:00
|
|
|
protected:
|
2009-11-10 12:40:58 -05:00
|
|
|
bool Init(wxDataViewCellMode mode, int align);
|
|
|
|
|
|
|
|
private:
|
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
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewProgressRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
|
|
|
|
const wxString &varianttype = "long",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual ~wxDataViewProgressRenderer();
|
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
virtual wxSize GetSize() const;
|
|
|
|
|
|
|
|
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:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewIconTextRenderer
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual ~wxDataViewIconTextRenderer();
|
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void GtkOnCellChanged(const wxVariant& value,
|
|
|
|
const wxDataViewItem& item,
|
|
|
|
unsigned col);
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewIconText m_value;
|
|
|
|
|
|
|
|
// we use the base class m_renderer for the text and this one for the icon
|
|
|
|
GtkCellRenderer *m_rendererIcon;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// wxDataViewChoiceRenderer
|
|
|
|
// -------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewChoiceRenderer(const wxArrayString &choices,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
|
|
|
|
int alignment = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual bool Render( wxRect rect, wxDC *dc, int state );
|
|
|
|
virtual wxSize GetSize() const;
|
|
|
|
virtual bool SetValue( const wxVariant &value );
|
|
|
|
virtual bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
void SetAlignment( int align );
|
|
|
|
|
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
|
|
|
|
2010-05-21 16:13:49 -04:00
|
|
|
virtual bool SetValue( const wxVariant &value );
|
|
|
|
virtual bool GetValue( wxVariant &value ) const;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-05-21 16:13:49 -04:00
|
|
|
private:
|
2011-09-07 12:56:50 -04:00
|
|
|
virtual void GtkOnTextEdited(const char *itempath, const wxString& str);
|
2010-05-21 16:13:49 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-10 12:40:58 -05:00
|
|
|
#endif // _WX_GTK_DVRENDERERS_H_
|
|
|
|
|