Use wxCompositeWindow for generic wxDataViewCtrl implementation

This makes several methods that didn't have any effect before work
correctly, including SetToolTip(), whose effect is now shown in the
sample, but also SetCursor() and SetLayoutDirection().

Some methods would now actually work too well: SetForegroundColour() and
SetBackgroundColour() implementations in wxCompositeWindow apply to all
sub-windows, but in wxDataViewCtrl they are only supposed to affect the
items, but not the header, so we need to override them to prevent the
base class version from being used. It is still preferable to explicitly
disable these two methods and inherit all the other ones (including any
possibly added in the future) from wxCompositeWindow to implementing all
the methods manually in wxDataViewCtrl itself.
This commit is contained in:
Vadim Zeitlin
2021-05-23 14:14:29 +01:00
parent fa00fd24f0
commit 3ed930c736
3 changed files with 51 additions and 10 deletions

View File

@@ -12,6 +12,7 @@
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/compositewin.h"
#include "wx/control.h"
#include "wx/scrolwin.h"
#include "wx/icon.h"
@@ -180,8 +181,9 @@ private:
// wxDataViewCtrl
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCtrl : public wxDataViewCtrlBase,
public wxScrollHelper
class WXDLLIMPEXP_CORE wxDataViewCtrl
: public wxCompositeWindow<wxDataViewCtrlBase>,
public wxScrollHelper
{
friend class wxDataViewMainWindow;
friend class wxDataViewHeaderWindowBase;
@@ -192,6 +194,8 @@ class WXDLLIMPEXP_CORE wxDataViewCtrl : public wxDataViewCtrlBase,
friend class wxDataViewCtrlAccessible;
#endif // wxUSE_ACCESSIBILITY
typedef wxCompositeWindow<wxDataViewCtrlBase> BaseType;
public:
wxDataViewCtrl() : wxScrollHelper(this)
{
@@ -264,6 +268,8 @@ public:
virtual void SetFocus() wxOVERRIDE;
virtual bool SetFont(const wxFont & font) wxOVERRIDE;
virtual bool SetForegroundColour(const wxColour& colour) wxOVERRIDE;
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
#if wxUSE_ACCESSIBILITY
virtual bool Show(bool show = true) wxOVERRIDE;
@@ -361,6 +367,9 @@ public: // utility functions not part of the API
#endif // wxUSE_ACCESSIBILITY
private:
// Implement pure virtual method inherited from wxCompositeWindow.
virtual wxWindowList GetCompositeWindowParts() const wxOVERRIDE;
virtual wxDataViewItem DoGetCurrentItem() const wxOVERRIDE;
virtual void DoSetCurrentItem(const wxDataViewItem& item) wxOVERRIDE;