03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

aFleet, aP1);<br />

CleanupStack::PushL(self);<br />

self->ConstructL();<br />

CleanupStack::Pop(self);<br />

return self;<br />

}<br />

CMyFleetView::CMyFleetView(CFleetViewData& aFleetViewData,<br />

TFleet& aFleet,<br />

TBool aP1)<br />

:CFleetView(aFleetViewData, aFleet)<br />

{<br />

if (aP1)<br />

iViewUid = KP1MyViewUID;<br />

else<br />

iViewUid = KP2MyViewUID;<br />

}<br />

Note CMyFleetView has no functions to handle pointer or keyboard input: the only thing<br />

that the user can do is to look at it.<br />

COppFleetView, the opposition fleet class, is similar, but has the functions, as defined in<br />

Solo Ships, to handle input events.<br />

We now have two concrete view classes, each of which will be instantiated twice, making<br />

four objects in all. These objects will need to share a significant amount of data: the zoom<br />

factor, and all the data calculated from it, for border areas, tile size, and so on will be the<br />

same. C++ would allow me to make these static (i.e. class) members, but Symbian OS does<br />

not allow such writable static data. The alternative that I adopted was to encapsulate the<br />

data in a class CFleetView-Data, and give each view a pointer to the same, single<br />

instance of that class.<br />

9.9.4 Hider View<br />

The final view in the application is the hider view, which is displayed between turns. I thought<br />

I'd display something prettier than a blank screen, and chose a bitmap of a real battleship in<br />

action. The second- phase constructor creates a bitmap object (CFbsBitmap), and loads<br />

the picture from the application's bitmap store (you'll see how to create such a store in<br />

<strong>Chapter</strong> 14). The view's Draw() function simply bit-blit's the bitmap to the view.<br />

Note<br />

Thanks to the U.S. Navy's Naval Historical Center for the 1906 photograph of<br />

the USS Connecticut.<br />

void CHiderView::ConstructL(const TRect& aRect)<br />

{<br />

CreateWindowL();<br />

SetRect(aRect);

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

Saved successfully!

Ooh no, something went wrong!