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

@@ -39,6 +39,7 @@ All:
- Fixed crashes in helpview when opening a file.
- Added wxMutex::LockTimeout() (Aleksandr Napylov)
- Set locale to the default in all ports, not just wxGTK
- Added wxGridUpdateLocker helper class (Evgeniy Tarassov)
wxGTK:

View File

@@ -188,6 +188,7 @@
\input gridrend.tex
\input gridtbl.tex
\input gridsizr.tex
\input gupdlock.tex
\input hashmap.tex
\input hashset.tex
\input hash.tex

View File

@@ -253,6 +253,10 @@ the grid is suppressed. Each call to BeginBatch must be matched by a later call
modification can be enclosed between BeginBatch and EndBatch calls to avoid
screen flicker. The final EndBatch will cause the grid to be repainted.
\wxheading{See also}
\helpref{wxGridUpdateLocker}{wxgridupdatelocker}
\membersection{wxGrid::BlockToDeviceRect}\label{wxgridblocktodevicerect}
@@ -514,6 +518,10 @@ EndBatch. Code that does a lot of grid modification can be enclosed between
BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will
cause the grid to be repainted.
\wxheading{See also}
\helpref{wxGridUpdateLocker}{wxgridupdatelocker}
\membersection{wxGrid::Fit}\label{wxgridfit}

View File

@@ -0,0 +1,81 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: gupdlock.tex
%% Purpose: wxGridUpdateLocker documentation
%% Author: Evgeniy Tarassov
%% Created: 2007-03-15
%% RCS-ID: $Id$
%% Copyright: (c) 2007 TT-Solutions SARL
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxGridUpdateLocker}}\label{wxgridupdatelocker}
This small class can be used to prevent \helpref{wxGrid}{wxgrid} from redrawing
during its lifetime by calling \helpref{wxGrid::BeginBatch}{wxgridbeginbatch}
in its constructor and \helpref{wxGrid::EndBatch}{wxgridendbatch} in its
destructor. It is typically used in a function performing several operations
with a grid which would otherwise result in flicker. For example:
{\small
\begin{verbatim}
void MyFrame::Foo()
{
m_grid = new wxGrid(this, ...);
wxGridUpdateLocker noUpdates(m_grid);
m_grid->AppendColumn();
... many other operations with m_grid...
m_grid->AppendRow();
// destructor called, grid refreshed
}
\end{verbatim}
}
Using this class is easier and safer than calling
\helpref{BeginBatch}{wxgridbeginbatch} and \helpref{EndBatch}{wxgridendbatch}
because you don't risk not to call the latter (due to an exception for example).
\wxheading{Derived from}
None.
\wxheading{Include files}
<wx/grid.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxGridUpdateLocker::wxGridUpdateLocker}\label{wxgridupdatelockerctor}
\func{}{wxGridUpdateLocker}{\param{wxGrid *}{grid = \NULL}}
Creates an object preventing the updates of the specified \arg{grid}. The
parameter could be \NULL in which case nothing is done. If \arg{grid} is
non-\NULL then the grid must exist for longer than wxGridUpdateLocker object
itself.
The default constructor could be followed by a call to
\helpref{wxGridUpdateLocker::Create}{wxgridupdatelockercreate} to set the
grid object later.
\membersection{wxGridUpdateLocker::\destruct{wxGridUpdateLocker}}\label{wxgridupdatelockerdtor}
\func{}{\destruct{wxGridUpdateLocker}}{\void}
Destructor reenables updates for the grid this object is associated with.
\membersection{wxGridUpdateLocker::Create}\label{wxgridupdatelockercreate}
\func{void}{Create}{\param{wxGrid* }{grid}}
This method can be called if the object had been constructed using the default
constructor. It must not be called more than once.