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
|
class wxWindowUpdateLocker
|
||||||
{
|
{
|
||||||
public:
|
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
|
// create an object preventing updates of the given window (which must have
|
||||||
// a lifetime at least as great as ours)
|
// a lifetime at least as great as ours)
|
||||||
explicit wxWindowUpdateLocker(wxWindow *win) : m_win(win) { win->Freeze(); }
|
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
|
// dtor thaws the window to permit updates again
|
||||||
~wxWindowUpdateLocker() { m_win->Thaw(); }
|
~wxWindowUpdateLocker()
|
||||||
|
{
|
||||||
|
if ( m_win )
|
||||||
|
m_win->Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow *m_win;
|
wxWindow *m_win;
|
||||||
|
@@ -35,6 +35,17 @@
|
|||||||
class wxWindowUpdateLocker
|
class wxWindowUpdateLocker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
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();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates an object preventing the updates of the specified @e win.
|
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
|
The parameter must be non-@NULL and the window must exist for longer than
|
||||||
@@ -42,6 +53,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
explicit wxWindowUpdateLocker(wxWindow* win);
|
explicit wxWindowUpdateLocker(wxWindow* win);
|
||||||
|
|
||||||
|
/**
|
||||||
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor reenables updates for the window this object is associated with.
|
Destructor reenables updates for the window this object is associated with.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user