2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wupdlock.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxWindowUpdateLocker
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxWindowUpdateLocker
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-27 06:27:44 -04:00
|
|
|
This tiny class prevents redrawing of a wxWindow during its lifetime by using
|
|
|
|
wxWindow::Freeze() and wxWindow::Thaw() methods.
|
|
|
|
|
|
|
|
It is typically used for creating automatic objects to temporarily suppress
|
|
|
|
window updates before a batch of operations is performed:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
|
|
|
void MyFrame::Foo()
|
|
|
|
{
|
|
|
|
m_text = new wxTextCtrl(this, ...);
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxWindowUpdateLocker noUpdates(m_text);
|
|
|
|
m_text-AppendText();
|
|
|
|
... many other operations with m_text...
|
|
|
|
m_text-WriteText();
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-27 06:27:44 -04:00
|
|
|
Using this class is easier and safer than calling wxWindow::Freeze() and
|
|
|
|
wxWindow::Thaw() because you don't risk to forget calling the latter.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-09-27 06:27:44 -04:00
|
|
|
@category{misc}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxWindowUpdateLocker
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
2020-05-23 20:38:13 -04:00
|
|
|
/**
|
|
|
|
Default constructor doesn't do anything.
|
|
|
|
|
|
|
|
Prefer using the non-default constructor if possible, this constructor
|
|
|
|
is only useful if Lock() must be called conditionally, i.e. if it may
|
|
|
|
or not be called depending on some run-time condition.
|
|
|
|
|
|
|
|
@since 3.1.4
|
|
|
|
*/
|
|
|
|
wxWindowUpdateLocker();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-09-27 06:27:44 -04:00
|
|
|
Creates an object preventing the updates of the specified @e win.
|
|
|
|
The parameter must be non-@NULL and the window must exist for longer than
|
2008-03-08 08:52:38 -05:00
|
|
|
wxWindowUpdateLocker object itself.
|
|
|
|
*/
|
2020-05-23 20:29:05 -04:00
|
|
|
explicit wxWindowUpdateLocker(wxWindow* win);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2020-05-23 20:38:13 -04:00
|
|
|
/**
|
|
|
|
Really lock window updates.
|
|
|
|
|
|
|
|
This method can only be called on an object initialized using the
|
|
|
|
default constructor.
|
|
|
|
|
|
|
|
@param win Non-@NULL window which must exist for longer than this object.
|
|
|
|
|
|
|
|
@since 3.1.4
|
|
|
|
*/
|
|
|
|
void Lock(wxWindow *win);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Destructor reenables updates for the window this object is associated with.
|
|
|
|
*/
|
|
|
|
~wxWindowUpdateLocker();
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|