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.
109 lines
3.1 KiB
C++
109 lines
3.1 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/osx/dvrenderer.h
|
|
// Purpose: wxDataViewRenderer for OS X wxDataViewCtrl implementations
|
|
// 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_DVRENDERER_H_
|
|
#define _WX_OSX_DVRENDERER_H_
|
|
|
|
class wxDataViewRendererNativeData;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// wxDataViewRenderer
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
|
|
{
|
|
public:
|
|
// constructors / destructor
|
|
// -------------------------
|
|
|
|
wxDataViewRenderer(const wxString& varianttype,
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
|
|
virtual ~wxDataViewRenderer();
|
|
|
|
// inherited methods from wxDataViewRendererBase
|
|
// ---------------------------------------------
|
|
|
|
virtual int GetAlignment() const
|
|
{
|
|
return m_alignment;
|
|
}
|
|
virtual wxDataViewCellMode GetMode() const
|
|
{
|
|
return m_mode;
|
|
}
|
|
virtual bool GetValue(wxVariant& value) const
|
|
{
|
|
value = m_value;
|
|
return true;
|
|
}
|
|
|
|
// NB: in Carbon this is always identical to the header alignment
|
|
virtual void SetAlignment(int align);
|
|
virtual void SetMode(wxDataViewCellMode mode);
|
|
virtual bool SetValue(const wxVariant& newValue)
|
|
{
|
|
m_value = newValue;
|
|
return true;
|
|
}
|
|
|
|
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
|
|
virtual wxEllipsizeMode GetEllipsizeMode() const;
|
|
|
|
// implementation
|
|
// --------------
|
|
|
|
const wxVariant& GetValue() const
|
|
{
|
|
return m_value;
|
|
}
|
|
|
|
wxDataViewRendererNativeData* GetNativeData() const
|
|
{
|
|
return m_NativeDataPtr;
|
|
}
|
|
|
|
// a call to the native data browser function to render the data;
|
|
// returns true if the data value could be rendered, false otherwise
|
|
virtual bool MacRender() = 0;
|
|
|
|
void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
|
|
|
|
|
|
#if wxOSX_USE_COCOA
|
|
// called when a value was edited by user
|
|
virtual void OSXOnCellChanged(NSObject *value,
|
|
const wxDataViewItem& item,
|
|
unsigned col);
|
|
|
|
protected:
|
|
virtual void SetAttr(const wxDataViewItemAttr& attr) wxOVERRIDE;
|
|
virtual void SetEnabled(bool enabled) wxOVERRIDE;
|
|
#endif // Cocoa
|
|
|
|
private:
|
|
// contains the alignment flags
|
|
int m_alignment;
|
|
|
|
// storing the mode that determines how the cell is going to be shown
|
|
wxDataViewCellMode m_mode;
|
|
|
|
// data used by implementation of the native renderer
|
|
wxDataViewRendererNativeData* m_NativeDataPtr;
|
|
|
|
// value that is going to be rendered
|
|
wxVariant m_value;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer);
|
|
};
|
|
|
|
#endif // _WX_OSX_DVRENDERER_H_
|
|
|