Adapt to grid activatable editors

Since wxWidgets uses an activable editor for wxGridCellBoolEditor,
wxGridEditorCreatedEvent is no longer emitted for such a column.

See https://trac.wxwidgets.org/ticket/19071

Using wxEVT_GRID_CELL_CHANGED to clear all checkboxes in preferred
column, instead of relying on the created editor pointer which can no
longer be referenced.
This commit is contained in:
SET
2021-02-05 12:14:39 +01:00
parent 0146542324
commit 472a3a8fd0
3 changed files with 10 additions and 25 deletions

View File

@@ -29,7 +29,6 @@ BaseGridPicker::BaseGridPicker(wxWindow *parent,
m_intentLabel = _T("Intent");
m_nbInsertRows = 3;
m_colTypeChoices = types;
m_PrefEditor = NULL;
wxButton * btn = static_cast<wxButton*> (GetPickerCtrl());
btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &BaseGridPicker::ShowPopup, this);
}
@@ -175,22 +174,13 @@ void BaseGridPicker::PrepareGrid()
m_stringTable->SetColLabelValue(1, _T("Type"));
m_stringTable->SetColLabelValue(2, _T("Preferred"));
m_stringTable->SetColLabelValue(3, _T("Notes"));
m_grid->Bind(wxEVT_GRID_EDITOR_CREATED, &BaseGridPicker::OnEditorCreated, this);
m_grid->Bind(wxEVT_GRID_EDITOR_HIDDEN, &BaseGridPicker::OnEditorHidden, this);
m_grid->Bind(wxEVT_GRID_CELL_CHANGED, &BaseGridPicker::OnPrefCellChanged, this);
}
void BaseGridPicker::OnEditorCreated(wxGridEditorCreatedEvent& evt)
void BaseGridPicker::OnPrefCellChanged(wxGridEvent& evt)
{
if (evt.GetCol() == 2)
{
m_PrefEditor = static_cast<wxCheckBox*> (evt.GetControl());
}
evt.Skip();
}
void BaseGridPicker::OnEditorHidden(wxGridEvent& evt)
{
if (evt.GetCol() == 2 && m_PrefEditor && m_PrefEditor->IsChecked())
if (evt.GetCol() == 2
&& m_stringTable->GetValue(evt.GetRow(), evt.GetCol()) == _T("1"))
{
for (uint row = 0; row < m_stringTable->GetRowsCount(); row++)
{