03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

� an old-style program that's not structured in an MVC manner, has no model, and so<br />

can't redraw, even if it can handle events;<br />

� a program that takes so long to redraw that it's desirable to avoid redraws if at all<br />

possible.<br />

A program in an old-style interpreted language such as OPL is likely to suffer from all these<br />

problems.<br />

In these cases, you can ask the window server to create a backed-up window; the window<br />

server creates a backup bitmap for the window and handles redraws from the backup bitmap<br />

without sending a redraw event to the client application.<br />

The backup bitmap consumes more RAM than the object required to represent a standard<br />

window. If the system is running short on memory, it's more likely that creation of a backedup<br />

window will fail, rather than creation of a standard window. If it does fail, the application<br />

will also fail, because requiring a backed-up window is a fairly fundamental property of a<br />

control. If you need backup, then you need it. If you can code proper redraw logic of<br />

sufficient performance, then you don't need backup.<br />

Code that is designed for drawing to backed-up windows usually won't work with standard<br />

windows because standard windows require redraws, which code written for a backup<br />

window won't be able to handle.<br />

On the other hand, code that is good for writing to a standard window is usually good for<br />

writing to a backed-up window; although the backed-up window won't call for redraws,<br />

there's no difference to the application- initiated draw code. The only technique that won't<br />

work for backed-up windows is to invalidate a window region in the hope of fielding a later<br />

redraw event – but this is a bad technique anyway.<br />

Standard controls such as the controls Uikon offers to application programmers are usually<br />

lodger controls that are designed to work in standard windows. Such lodger controls will also<br />

work properly in backed-up windows, unless they use invalidation in the hope of fielding a<br />

later redraw. All Uikon stock controls are designed to work in both windows.<br />

CCoeControl's DrawDeferred() function works on a standard window by invalidating the<br />

window region corresponding to the control. This causes a later redraw event. On a backedup<br />

window, this won't work, so in that case DrawDeferred() simply calls DrawNow():<br />

void CCoeControl::DrawDeferred() const<br />

{<br />

...<br />

if(IsBackedUp())<br />

else<br />

...<br />

}<br />

DrawNow();<br />

Window().Invalidate(Rect());<br />

11.6 CCoeControl's Support for Drawing<br />

Now is a good time to summarize the drawing-related features of CCoeControl that we've<br />

seen so far.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!