Use wxDataViewRenderer::PrepareForItem() in all ports
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.
This commit is contained in:
@@ -115,10 +115,6 @@ public:
|
||||
virtual bool SetValue(const wxVariant& value) = 0;
|
||||
virtual bool GetValue(wxVariant& value) const = 0;
|
||||
|
||||
virtual void SetAttr(const wxDataViewItemAttr& WXUNUSED(attr)) { }
|
||||
|
||||
virtual void SetEnabled(bool WXUNUSED(enabled)) { }
|
||||
|
||||
wxString GetVariantType() const { return m_variantType; }
|
||||
|
||||
// Prepare for rendering the value of the corresponding item in the given
|
||||
@@ -128,22 +124,12 @@ public:
|
||||
// it is only passed to this method because the existing code already has
|
||||
// it and should probably be removed in the future.
|
||||
//
|
||||
// Returns false if the value is missing (or invalid, i.e. has a wrong type
|
||||
// differing from GetVariantType() of this renderer, in which case a debug
|
||||
// error is also logged as it indicates an error in the user code).
|
||||
bool PrepareValue(const wxDataViewModel* model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned column);
|
||||
|
||||
// Prepare for rendering the given item by both calling PrepareValue() and
|
||||
// setting up the attributes.
|
||||
//
|
||||
// This is currently only used in the generic version but should really be
|
||||
// used everywhere, i.e. SetEnabled() and SetAttr() should be overridden in
|
||||
// the native versions instead of adding platform-specific equivalents for
|
||||
// them as it's done currently.
|
||||
void PrepareForItem(const wxDataViewModel *model,
|
||||
const wxDataViewItem& item, unsigned column);
|
||||
// Return true if this cell is non-empty or false otherwise (and also if
|
||||
// the model returned a value of the wrong, i.e. different from our
|
||||
// GetVariantType(), type, in which case a debug error is also logged).
|
||||
bool PrepareForItem(const wxDataViewModel *model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned column);
|
||||
|
||||
// renderer properties:
|
||||
virtual void SetMode( wxDataViewCellMode mode ) = 0;
|
||||
@@ -195,11 +181,17 @@ public:
|
||||
int GetEffectiveAlignment() const;
|
||||
|
||||
protected:
|
||||
// These methods are called from PrepareForItem() and should do whatever is
|
||||
// needed for the current platform to ensure that the item is rendered
|
||||
// using the given attributes and enabled/disabled state.
|
||||
virtual void SetAttr(const wxDataViewItemAttr& attr) = 0;
|
||||
virtual void SetEnabled(bool enabled) = 0;
|
||||
|
||||
// Called from {Cancel,Finish}Editing() to cleanup m_editorCtrl
|
||||
void DestroyEditControl();
|
||||
|
||||
// Helper of PrepareValue() also used in StartEditing(): returns the value
|
||||
// checking that its type matches our GetVariantType().
|
||||
// Helper of PrepareForItem() also used in StartEditing(): returns the
|
||||
// value checking that its type matches our GetVariantType().
|
||||
wxVariant CheckedGetValue(const wxDataViewModel* model,
|
||||
const wxDataViewItem& item,
|
||||
unsigned column) const;
|
||||
@@ -318,7 +310,7 @@ public:
|
||||
|
||||
// Store the enabled state of the item so that it can be accessed from
|
||||
// Render() via GetEnabled() if needed.
|
||||
virtual void SetEnabled(bool enabled) { m_enabled = enabled; }
|
||||
virtual void SetEnabled(bool enabled);
|
||||
bool GetEnabled() const { return m_enabled; }
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user