From fa1b3a43cc2ef3b6e3c1f437527bb9f879cf65c7 Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Tue, 18 Apr 2000 10:51:38 +0000 Subject: [PATCH] Added IsCellEditControlDisplayed() and use it from SetCellValue. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 1 + src/generic/grid.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 95f688ed6c..d349fd9d78 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1068,6 +1068,7 @@ public: void DisableCellEditControl() { EnableCellEditControl(FALSE); } bool CanEnableCellControl() const; bool IsCellEditControlEnabled() const; + bool IsCellEditControlDisplayed() const; bool IsCurrentCellReadOnly() const; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6f9b958a4f..fa2ba8e649 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5945,6 +5945,23 @@ bool wxGrid::IsCellEditControlEnabled() const return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : FALSE; } +bool wxGrid::IsCellEditControlDisplayed() const +{ + if (m_cellEditCtrlEnabled) + { + int row = m_currentCellCoords.GetRow(); + int col = m_currentCellCoords.GetCol(); + wxGridCellAttr* attr = GetCellAttr(row, col); + wxGridCellEditor* editor = attr->GetEditor(this, row, col); + if ( editor && editor->IsCreated() ) + { + wxWindow *control = editor->GetControl(); + return control->IsShown(); + } + } + return FALSE; +} + void wxGrid::ShowCellEditControl() { if ( IsCellEditControlEnabled() ) @@ -7693,7 +7710,10 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s ) if ( m_currentCellCoords.GetRow() == row && m_currentCellCoords.GetCol() == col && - IsCellEditControlEnabled()) + IsCellEditControlDisplayed()) + // Note: If we are using IsCellEditControlEnabled, + // this interacts badly with calling SetCellValue from + // an EVT_GRID_CELL_CHANGE handler. { HideCellEditControl(); ShowCellEditControl(); // will reread data from table