Allow using wxWindowUpdateLocker conditionally
This can be useful if the window needs to be frozen only if some run-time condition holds true.
This commit is contained in:
@@ -19,12 +19,29 @@
|
||||
class wxWindowUpdateLocker
|
||||
{
|
||||
public:
|
||||
// Prefer using the ctor below if possible, this ctor is only useful if
|
||||
// Lock() must be called only conditionally.
|
||||
wxWindowUpdateLocker() : m_win(NULL) { }
|
||||
|
||||
// create an object preventing updates of the given window (which must have
|
||||
// a lifetime at least as great as ours)
|
||||
explicit wxWindowUpdateLocker(wxWindow *win) : m_win(win) { win->Freeze(); }
|
||||
|
||||
// May be called only for the object constructed using the default ctor.
|
||||
void Lock(wxWindow *win)
|
||||
{
|
||||
wxASSERT( !m_win );
|
||||
|
||||
m_win = win;
|
||||
win->Freeze();
|
||||
}
|
||||
|
||||
// dtor thaws the window to permit updates again
|
||||
~wxWindowUpdateLocker() { m_win->Thaw(); }
|
||||
~wxWindowUpdateLocker()
|
||||
{
|
||||
if ( m_win )
|
||||
m_win->Thaw();
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow *m_win;
|
||||
|
Reference in New Issue
Block a user