wxWidgets/include/wx/generic/dvrenderer.h
Vadim Zeitlin 62265c2c67 Allow custom wxDataViewCtrl renderers to easily use attributes.
Set up the DC passed to wxDataViewCustomRenderer::Render() to use the font and
colour defined by the item attribute by default so that any calls to
RenderText() from it will use them automatically.

Also added public wxDataViewCustomRenderer::GetAttr() to allow retrieving the
attribute explicitly in Render().

The column using custom renderer in the dataview sample now works as expected
in the generic version; the native ones will be corrected in the upcoming
commits.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62590 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-11-10 17:41:11 +00:00

69 lines
2.6 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/dvrenderer.h
// Purpose: wxDataViewRenderer for generic wxDataViewCtrl implementation
// Author: Robert Roebling, Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/generic/dataview.h)
// RCS-ID: $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
// Copyright: (c) 2006 Robert Roebling
// (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DVRENDERER_H_
#define _WX_GENERIC_DVRENDERER_H_
// ----------------------------------------------------------------------------
// wxDataViewRenderer
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewCustomRendererBase
{
public:
wxDataViewRenderer( const wxString &varianttype,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewRenderer();
virtual wxDC *GetDC();
virtual void SetAlignment( int align );
virtual int GetAlignment() const;
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE)
{ m_ellipsizeMode = mode; }
virtual wxEllipsizeMode GetEllipsizeMode() const
{ return m_ellipsizeMode; }
virtual void SetMode( wxDataViewCellMode mode )
{ m_mode = mode; }
virtual wxDataViewCellMode GetMode() const
{ return m_mode; }
// implementation
// this is a replacement for dynamic_cast<wxDataViewCustomRenderer> in the
// code checking whether the renderer is interested in mouse events, it's
// overridden in wxDataViewCustomRenderer to return the object itself but
// intentionally returns NULL for all the other renderer classes as the
// user should _not_ be able to override Activate/LeftClick() when deriving
// from them for consistency with the other ports and while we can't
// prevent this from working at compile-time because all renderer are
// custom renderers in the generic implementation, we at least make sure
// that it doesn't work at run-time because Activate/LeftClick() would
// never be called
virtual wxDataViewCustomRenderer *WXGetAsCustom() { return NULL; }
private:
int m_align;
wxDataViewCellMode m_mode;
wxEllipsizeMode m_ellipsizeMode;
wxDC *m_dc;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
};
#endif // _WX_GENERIC_DVRENDERER_H_