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.

Figure 11.1<br />

As it happens, this screen includes two windows – the app view and the button bar. The app<br />

view is a single control, while the button bar comprises several controls such as<br />

� a container for the whole button bar, which is a compound control;<br />

� component controls, including the four buttons.<br />

This application already allows us to make some generalizations about controls:<br />

� For an application, a control is the basic unit of GUI interaction: a control can do any<br />

sensible combination of drawing, pointer handling, and key handling.<br />

� A window is the basic unit of interaction for the system: controls always use all or part<br />

of a window.<br />

� Controls can be compound: that is, they can contain component controls. A compound<br />

control is sometimes known as a container.<br />

In this chapter, we'll see the role that controls (and windows) play in drawing. We'll continue<br />

to use the hellogui and Battleships applications as examples. In the next chapter, we'll<br />

look more closely at keyand pointer-based interaction.<br />

11.1.2 Walking through Draw()<br />

In Symbian OS, all drawing is done through a graphics context (GC). In this section, we'll<br />

take a closer look at the example function CHelloGuiAppView::Draw() to see how the<br />

GC is used.<br />

Getting the graphics context<br />

The CHelloGuiAppView::Draw() function begins by getting hold of a GC using<br />

SystemGc(), a function in CCoeControl:<br />

CWindowGc& gc = SystemGc();<br />

All graphics context classes are derived from CGraphicsContext. Each derived class –<br />

such as CWindowGc here – is used for drawing on a particular graphics device (in our<br />

example, a window) and implements all the functionality specified by the base class, plus<br />

(and optionally) some extra functionality appropriate for the device in question. Therefore,<br />

we can clear the screen through the graphics context:<br />

gc.Clear();

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

Saved successfully!

Ooh no, something went wrong!