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:
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user