|
||
To redraw to an RWindow
, an application starts the
sequence by activating a CWindowGc
to use a particular window for
drawing. The RWindow::BeginRedraw()
function is a significant part of
redrawing. The BeginRedraw()
function:
marks the rectangle passed as its argument as valid — i.e., removes it from the invalid region of the window
sets the clipping region to the intersection of the invalid region and the rectangle passed as its argument
Because the window server clips drawing to the newly validated region, anything drawn in a redraw must exactly match what was drawn originally. The sequence is as follows:
gc->Activate(iWindow);
iWindow.BeginRedraw(rect);
DoDraw(rect);
iWindow.EndRedraw();
gc->Deactivate();
In the context of a normal redraw, the rectangle passed to
BeginRedraw()
will be the bounding rectangle of the invalid
region. Therefore, after this sequence, the entire window will be valid again.
If, however, the rectangle drawn in response to a redraw event did not cover
the entire invalid region, the window server will generate another redraw event
specifying the bounding rectangle of the region that is still invalid. This
will continue until the entire window is valid.
Because the window server only allows an application to draw to the valid area, it is a good idea to invalidate the whole region and do a redraw, otherwise when you do the draw any invalid areas will remain unchanged. You may use code as follows:
gc->Activate(iWindow);
iWindow.Invalidate(rect);
iWindow.BeginRedraw(rect);
DoDraw(rect);
iWindow.EndRedraw();
gc->Deactivate();
If desired, an application may simply invalidate the area to be redrawn, and then allow the window server to generate a redraw event. This technique is not recommended for general use, because it produces a rather sluggish effect and requires more client/server context switches. It is useful when user input may take precedence over redrawing.
Because backed-up windows are redrawn by the window server, not by
the application, they have no RWindow::Invalidate()
,
RWindow::BeginRedraw()
or RWindow::EndRedraw()
member functions. The
sequence for drawing to backed-up windows is therefore as follows:
gc->Activate(iWindow);
DoDraw(rect);
gc->Deactivate();
Because the Symbian OS is a pre-emptive system, another application — or the window server itself — may pre-empt the application
that is drawing, or redrawing. The result is that the DoDraw()
may be partially complete when pre-emption occurs; then, when the DoDraw()
receives control again, it is drawing to an area which has been invalidated without its knowledge.
For this reason, the window server marks a window region as valid at RWindow::BeginRedraw()
time, not at RWindow::EndRedraw()
time. Then, any regions which become invalid because of a pre-empting application’s activity will correctly be added to
the invalid region. The DoDraw()
will complete, but the window server will in any case generate another redraw event and the application must start the redraw
again.