Use RAII SelectionEventsSuppressor in wxGTK wxDataViewCtrl code

This is simpler and safer than always remembering to call
GtkDisableSelectionEvents() and GtkEnableSelectionEvents() in pairs.

No real changes.
This commit is contained in:
Vadim Zeitlin
2018-01-24 18:18:22 +01:00
parent 3b22d9a56b
commit 0cea0a67f1
2 changed files with 24 additions and 15 deletions

View File

@@ -188,6 +188,25 @@ public:
int GTKGetUniformRowHeight() const { return m_uniformRowHeight; }
// Simple RAII helper for disabling selection events during its lifetime.
class SelectionEventsSuppressor
{
public:
explicit SelectionEventsSuppressor(wxDataViewCtrl* ctrl)
: m_ctrl(ctrl)
{
m_ctrl->GtkDisableSelectionEvents();
}
~SelectionEventsSuppressor()
{
m_ctrl->GtkEnableSelectionEvents();
}
private:
wxDataViewCtrl* const m_ctrl;
};
protected:
virtual void DoSetExpanderColumn() wxOVERRIDE;
virtual void DoSetIndent() wxOVERRIDE;