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:
@@ -6,6 +6,10 @@
|
||||
</data>
|
||||
<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">
|
||||
<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>
|
||||
</project-private>
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -138,7 +138,6 @@ private:
|
||||
wxArrayString m_colTypeChoices;
|
||||
wxString m_intentLabel;
|
||||
uint m_nbInsertRows;
|
||||
wxCheckBox * m_PrefEditor;
|
||||
/**
|
||||
* Configures the Preferred column for editing and rendering using a
|
||||
* checkbox.
|
||||
@@ -155,20 +154,12 @@ private:
|
||||
* Binds the grid to editor creation and hidden events.
|
||||
*/
|
||||
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
|
||||
* the other rows are unchecked.
|
||||
* @param evt
|
||||
*/
|
||||
void OnEditorHidden(wxGridEvent& evt);
|
||||
void OnPrefCellChanged(wxGridEvent& evt);
|
||||
/**
|
||||
* Just calls BasePicker::DoShowPopup().
|
||||
* @param evt
|
||||
|
||||
Reference in New Issue
Block a user