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

@@ -6,6 +6,10 @@
</data> </data>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/> <group>
<file>file:/home/user/Documents/published/L7/L7/LBoundGrid.cpp</file>
<file>file:/home/user/Documents/published/L7/L7/special/BaseGridPicker.h</file>
<file>file:/home/user/Documents/published/L7/L7/special/BaseGridPicker.cpp</file>
</group>
</open-files> </open-files>
</project-private> </project-private>

View File

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

View File

@@ -138,7 +138,6 @@ private:
wxArrayString m_colTypeChoices; wxArrayString m_colTypeChoices;
wxString m_intentLabel; wxString m_intentLabel;
uint m_nbInsertRows; uint m_nbInsertRows;
wxCheckBox * m_PrefEditor;
/** /**
* Configures the Preferred column for editing and rendering using a * Configures the Preferred column for editing and rendering using a
* checkbox. * checkbox.
@@ -155,20 +154,12 @@ private:
* Binds the grid to editor creation and hidden events. * Binds the grid to editor creation and hidden events.
*/ */
void PrepareGrid(); void PrepareGrid();
/**
* References the wxCheckBox editor.
* <br/>
* Does nothing for the other columns.
*
* @param evt
*/
void OnEditorCreated(wxGridEditorCreatedEvent& evt);
/** /**
* Concerns the Preferred column only. When the editor is checked, ensures * Concerns the Preferred column only. When the editor is checked, ensures
* the other rows are unchecked. * the other rows are unchecked.
* @param evt * @param evt
*/ */
void OnEditorHidden(wxGridEvent& evt); void OnPrefCellChanged(wxGridEvent& evt);
/** /**
* Just calls BasePicker::DoShowPopup(). * Just calls BasePicker::DoShowPopup().
* @param evt * @param evt