Confused about wxWindow::Update() vs Refresh()
Paul Melis
paul at science.uva.nl
Fri Feb 15 02:31:27 PST 2008
Hello,
I have a situation in which an event handler (File -> Open) starts the
processing of some data by an external library. The library provides
progress callbacks which I'm using to drive a progress bar.
But how can I force redrawing of the progress bar immediately without
using Yield()? Is this possible at all?
From the description of wxWindow::Update() and wxWindow::Refresh() in
the 2.8 docs (see below) I get a confused picture of what to do.
For Refresh() it says
"Causes this window, and all of its children recursively [...], to be
repainted. Note that repainting doesn't happen immediately but only
during the next event loop iteration, if you need to update the window
immediately you should use Update instead."
So this would seem to suggest that calling Update() would force an
immediate update (repaint), but for Update() it reads:
"Calling this method immediately repaints the invalidated area of the
window and all of its children recursively while this would usually only
happen when the flow of control returns to the event loop. Notice that
this function doesn't refresh the window and does nothing if the window
hadn't been already repainted. Use Refresh first if you want to
immediately redraw the window unconditionally."
The second part of the sentence "Notice that this function doesn't
refresh the window and does nothing if the window hadn't been already
repainted." is extremely confusing. Update() does nothing if there has
NOT already been a repaint?? Should I actually read this as "This
function doesn't _refresh_ the window (call Refresh() for that first).
This function does nothing if the window already has been repainted"?
It seems that calling Refresh() on the progress first, to force it to
repaint, followed by a call to Update() would do the trick but it
doesn't (i.e. no redrawing takes place).
This is with wxGTK (2.6) b.t.w.
Paul
More information about the wx-users
mailing list