Add GetDefaultType() to all standard wxDataViewRenderer-derived classes.

This makes it possible to refer to the associated wxVariant types without hard
coding the string constants, i.e. instead of writing "string" (error prone as
typos are not detected) it is now possible to write wxDataViewTextRenderer::
GetDefaultType().

This will also make it simpler to write generic (in C++ templates sense) code
using renderers.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-12-20 21:51:54 +00:00
parent 4d9afe351a
commit 615b49692c
5 changed files with 134 additions and 33 deletions

View File

@ -18,7 +18,9 @@
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
{
public:
wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -46,7 +48,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -76,7 +80,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
static wxString GetDefaultType() { return wxS("wxBitmap"); }
wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -101,7 +107,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -131,8 +139,10 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
const wxString &varianttype = wxT("long"),
const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -157,7 +167,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );

View File

@ -25,7 +25,9 @@
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewTextRenderer( const wxString &varianttype = "string",
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -68,7 +70,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
wxDataViewBitmapRenderer( const wxString &varianttype = "wxBitmap",
static wxString GetDefaultType() { return wxS("wxBitmap"); }
wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -86,7 +90,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
wxDataViewToggleRenderer( const wxString &varianttype = "bool",
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -104,7 +110,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
{
public:
wxDataViewCustomRenderer( const wxString &varianttype = "string",
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT,
bool no_init = false );
@ -166,8 +174,10 @@ private:
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
const wxString &varianttype = "long",
const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewProgressRenderer();
@ -201,7 +211,9 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
{
public:
wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewIconTextRenderer();

View File

@ -17,7 +17,9 @@
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer : public wxDataViewCustomRendererBase
{
public:
wxDataViewCustomRenderer(const wxString& varianttype = "string",
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -51,7 +53,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewTextRenderer(const wxString& varianttype = "string",
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -74,7 +78,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
static wxString GetDefaultType() { return wxS("wxBitmap"); }
wxDataViewBitmapRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -122,7 +128,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -145,7 +153,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
wxDataViewToggleRenderer(const wxString& varianttype = "bool",
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -168,8 +178,10 @@ private:
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
const wxString& varianttype = "long",
const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -192,7 +204,9 @@ private:
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
{
public:
wxDataViewDateRenderer(const wxString& varianttype = "datetime",
static wxString GetDefaultType() { return wxS("datetime"); }
wxDataViewDateRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT);

View File

@ -15,7 +15,9 @@
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -32,7 +34,9 @@ public:
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
static wxString GetDefaultType() { return wxS("wxBitmap"); }
wxDataViewBitmapRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -47,7 +51,9 @@ public:
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
{
public:
wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
@ -62,7 +68,9 @@ public:
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
{
public:
wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT,
bool no_init = false );
@ -97,8 +105,10 @@ public:
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
const wxString &varianttype = wxT("long"),
const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewProgressRenderer();
@ -117,7 +127,9 @@ public:
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
{
public:
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
virtual ~wxDataViewIconTextRenderer();
@ -140,7 +152,9 @@ public:
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
{
public:
wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
static wxString GetDefaultType() { return wxS("datetime"); }
wxDataViewDateRenderer( const wxString &varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT );

View File

@ -1904,10 +1904,17 @@ protected:
class wxDataViewTextRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewTextRenderer(const wxString& varianttype = "string",
wxDataViewTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
};
@ -1930,10 +1937,17 @@ public:
class wxDataViewIconTextRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
wxDataViewIconTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
};
@ -1951,11 +1965,18 @@ public:
class wxDataViewProgressRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
const wxString& varianttype = "long",
const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
};
@ -1997,10 +2018,17 @@ public:
class wxDataViewToggleRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewToggleRenderer(const wxString& varianttype = "bool",
wxDataViewToggleRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
};
@ -2075,10 +2103,17 @@ public:
class wxDataViewDateRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewDateRenderer(const wxString& varianttype = "datetime",
wxDataViewDateRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT);
};
@ -2107,10 +2142,17 @@ public:
class wxDataViewCustomRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
Constructor.
*/
wxDataViewCustomRenderer(const wxString& varianttype = "string",
wxDataViewCustomRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
@ -2310,10 +2352,17 @@ protected:
class wxDataViewBitmapRenderer : public wxDataViewRenderer
{
public:
/**
Returns the wxVariant type used with this renderer.
@since 3.1.0
*/
static wxString GetDefaultType();
/**
The ctor.
*/
wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
wxDataViewBitmapRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
};