Remove check for read only cells from IsCellEditControlEnabled()
This check was introduced back in283b7808d8
(added support for readonly cells and 3d border drawing, 2000-02-16), but was wrong even then and remained wrong ever since: we must not set m_cellEditCtrlEnabled to true when the current cell is read-only, so there is no need to check for the latter condition if m_cellEditCtrlEnabled is indeed true. Ensure that we really never erroneously set m_cellEditCtrlEnabled for the read-only cells by replacing an wxASSERT_MSG checking for this in EnableCellEditControl() with wxCHECK_RET(). Also explicitly document this function precondition, also added back inb54ba67107
([...] added CanEnableCellControl() and use it before calling EnableEC, 2000-02-17) but never documented so far.
This commit is contained in:
@@ -1504,7 +1504,7 @@ public:
|
|||||||
void EnableCellEditControl( bool enable = true );
|
void EnableCellEditControl( bool enable = true );
|
||||||
void DisableCellEditControl() { EnableCellEditControl(false); }
|
void DisableCellEditControl() { EnableCellEditControl(false); }
|
||||||
bool CanEnableCellControl() const;
|
bool CanEnableCellControl() const;
|
||||||
bool IsCellEditControlEnabled() const;
|
bool IsCellEditControlEnabled() const { return m_cellEditCtrlEnabled; }
|
||||||
bool IsCellEditControlShown() const;
|
bool IsCellEditControlShown() const;
|
||||||
|
|
||||||
bool IsCurrentCellReadOnly() const;
|
bool IsCurrentCellReadOnly() const;
|
||||||
|
@@ -3440,6 +3440,9 @@ public:
|
|||||||
currently show, otherwise the @c wxEVT_GRID_EDITOR_HIDDEN event is
|
currently show, otherwise the @c wxEVT_GRID_EDITOR_HIDDEN event is
|
||||||
generated but, unlike the "shown" event, it can't be vetoed and the
|
generated but, unlike the "shown" event, it can't be vetoed and the
|
||||||
in-place editor is dismissed unconditionally.
|
in-place editor is dismissed unconditionally.
|
||||||
|
|
||||||
|
Note that it is an error to call this function if the current cell is
|
||||||
|
read-only, use CanEnableCellControl() to check for this precondition.
|
||||||
*/
|
*/
|
||||||
void EnableCellEditControl(bool enable = true);
|
void EnableCellEditControl(bool enable = true);
|
||||||
|
|
||||||
|
@@ -7149,12 +7149,12 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
{
|
{
|
||||||
if ( enable )
|
if ( enable )
|
||||||
{
|
{
|
||||||
|
// this should be checked by the caller!
|
||||||
|
wxCHECK_RET( CanEnableCellControl(), wxT("can't enable editing for this cell!") );
|
||||||
|
|
||||||
if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 )
|
if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// this should be checked by the caller!
|
|
||||||
wxASSERT_MSG( CanEnableCellControl(), wxT("can't enable editing for this cell!") );
|
|
||||||
|
|
||||||
// do it before ShowCellEditControl()
|
// do it before ShowCellEditControl()
|
||||||
m_cellEditCtrlEnabled = enable;
|
m_cellEditCtrlEnabled = enable;
|
||||||
|
|
||||||
@@ -7181,13 +7181,6 @@ bool wxGrid::CanEnableCellControl() const
|
|||||||
!IsCurrentCellReadOnly();
|
!IsCurrentCellReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGrid::IsCellEditControlEnabled() const
|
|
||||||
{
|
|
||||||
// the cell edit control might be disable for all cells or just for the
|
|
||||||
// current one if it's read only
|
|
||||||
return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxGrid::IsCellEditControlShown() const
|
bool wxGrid::IsCellEditControlShown() const
|
||||||
{
|
{
|
||||||
bool isShown = false;
|
bool isShown = false;
|
||||||
|
Reference in New Issue
Block a user