added wxGridUpdateLocker helper class wrapping Begin/EndBatch() calls in a more convenient and safe way

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-03-15 17:25:15 +00:00
parent 7660b85c31
commit b62f94ff48
8 changed files with 143 additions and 19 deletions

View File

@@ -2007,6 +2007,47 @@ protected:
};
// ----------------------------------------------------------------------------
// wxGridUpdateLocker prevents updates to a grid during its lifetime
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGridUpdateLocker
{
public:
// if the pointer is NULL, Create() can be called later
wxGridUpdateLocker(wxGrid *grid = NULL)
{
Init(grid);
}
// can be called if ctor was used with a NULL pointer, must not be called
// more than once
void Create(wxGrid *grid)
{
wxASSERT_MSG( !m_grid, _T("shouldn't be called more than once") );
Init(grid);
}
~wxGridUpdateLocker()
{
if ( m_grid )
m_grid->EndBatch();
}
private:
void Init(wxGrid *grid)
{
m_grid = grid;
if ( m_grid )
m_grid->BeginBatch();
}
wxGrid *m_grid;
DECLARE_NO_COPY_CLASS(wxGridUpdateLocker)
};
// ----------------------------------------------------------------------------
// Grid event class and event types
// ----------------------------------------------------------------------------