Implement macOS-specific wxDataViewCheckIconTextRenderer

This implementation suffers at least from 2 problems:

1. It doesn't support icons at all.
2. It toggles the checkbox when clicking on the text and not just on the
   checkbox itself, as would be expected.

but it's still better than the current version which simply doesn't work
at all, i.e. can't be toggled in any way (and also doesn't draw itself
correctly when using dark mode under macOS 10.14+), so use it for now.

A better solution would be to fix the problem with ActivateCell() not
working at all (see #17746) and update the code to respect drawing in
dark mode.

Closes #17473.

Closes https://github.com/wxWidgets/wxWidgets/pull/904
This commit is contained in:
Stefan Csomor
2019-10-21 02:04:35 +02:00
committed by Vadim Zeitlin
parent fa3c0b1808
commit 235e61c311
4 changed files with 177 additions and 34 deletions

View File

@@ -184,6 +184,40 @@ private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCheckIconTextRenderer
: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxDataViewCheckIconText"); }
explicit wxDataViewCheckIconTextRenderer
(
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT
);
// This renderer can always display the 3rd ("indeterminate") checkbox
// state if the model contains cells with wxCHK_UNDETERMINED value, but it
// doesn't allow the user to set it by default. Call this method to allow
// this to happen.
void Allow3rdStateForUser(bool allow = true);
virtual bool MacRender() wxOVERRIDE;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) wxOVERRIDE;
private:
bool m_allow3rdStateForUser;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCheckIconTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------