Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to draw and redraw


Redrawing

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:

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();


Note

[Top]


Drawing


Non-backed-up windows

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();


Note

[Top]


Backed-up windows

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();

[Top]


Pre-emptive multi tasking

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.