361c6357b4
wxOSX and wxGTK previously used their own methods for handling the enabled state and the attributes of the items being rendered, change them to reuse the same methods as the generic implementation, i.e. SetEnabled() and SetAttr() and remove the port-specific GtkSetAttr(), OSXApplyAttr() and so on. This has the advantage of ensuring that the logic is the same for all platforms (e.g. item enabled status wasn't handled in the same way in wxGTK as in the other ports previously) and hopefully makes the code simpler by cutting down on the number of virtual methods. Notice that GtkSupportsAttrs() optimization was removed as it didn't seem to be worth the bother (we basically saved a call to a virtual model method at a price of a virtual renderer method call) and preserving it would have complicated things needlessly.
223 lines
7.1 KiB
C++
223 lines
7.1 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/osx/dvrenderers.h
|
|
// Purpose: All OS X wxDataViewCtrl renderer classes
|
|
// Author: Vadim Zeitlin
|
|
// Created: 2009-11-07 (extracted from wx/osx/dataview.h)
|
|
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
// Licence: wxWindows licence
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_OSX_DVRENDERERS_H_
|
|
#define _WX_OSX_DVRENDERERS_H_
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewCustomRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer : public wxDataViewCustomRendererBase
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("string"); }
|
|
|
|
wxDataViewCustomRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual ~wxDataViewCustomRenderer();
|
|
|
|
|
|
// implementation only
|
|
// -------------------
|
|
|
|
virtual bool MacRender();
|
|
|
|
virtual wxDC* GetDC(); // creates a device context and keeps it
|
|
void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
|
|
|
|
private:
|
|
wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
|
|
|
|
wxDC* m_DCPtr;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer);
|
|
};
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewTextRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("string"); }
|
|
|
|
wxDataViewTextRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer);
|
|
};
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewBitmapRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("wxBitmap"); }
|
|
|
|
wxDataViewBitmapRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer);
|
|
};
|
|
|
|
#if wxOSX_USE_COCOA
|
|
|
|
// -------------------------------------
|
|
// wxDataViewChoiceRenderer
|
|
// -------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
wxDataViewChoiceRenderer(const wxArrayString& choices,
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
|
|
int alignment = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual bool MacRender();
|
|
|
|
wxString GetChoice(size_t index) const { return m_choices[index]; }
|
|
const wxArrayString& GetChoices() const { return m_choices; }
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxArrayString m_choices;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewChoiceRenderer);
|
|
};
|
|
|
|
#endif // wxOSX_USE_COCOA
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewIconTextRenderer
|
|
// ---------------------------------------------------------
|
|
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
|
|
|
|
wxDataViewIconTextRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer);
|
|
};
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewToggleRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("bool"); }
|
|
|
|
wxDataViewToggleRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer);
|
|
};
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewProgressRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("long"); }
|
|
|
|
wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
|
|
const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer);
|
|
};
|
|
|
|
// ---------------------------------------------------------
|
|
// wxDataViewDateRenderer
|
|
// ---------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
|
|
{
|
|
public:
|
|
static wxString GetDefaultType() { return wxS("datetime"); }
|
|
|
|
wxDataViewDateRenderer(const wxString& varianttype = GetDefaultType(),
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual bool MacRender();
|
|
|
|
#if wxOSX_USE_COCOA
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer);
|
|
};
|
|
|
|
#endif // _WX_OSX_DVRENDERERS_H_
|
|
|