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.

Scale to use when calculating drawing stuff<br />

TInt iZoomFactor;<br />

// Precalculated drawing stuff<br />

CFont* iBorderFont;<br />

CFont* iTileFont;<br />

TRect iBoardRect; // Board area<br />

TRect iTopBorder; // All of top border<br />

TRect iBottomBorder; // All bottom border<br />

TRect iLeftBorder; // Left border, excluding top and bottom<br />

TRect iRightBorder; // Right border, excluding top and bottom<br />

TInt iTileSize; // Side of tile (1/8th board area)<br />

TInt iBorderSize; // Size of border<br />

};<br />

The first group of public functions (commented as 'Construct/destruct/ setup') is called by the<br />

app UI to create the view. The remaining public functions are for use by the controller, to tell<br />

the view to respond to user commands or engine data changes.<br />

The first group of private functions (commented as 'From CcoeControl') overrides the control<br />

base class functions to draw the view, and to handle pointer and key events, respectively.<br />

The remaining private functions implement various parts of drawing the view.<br />

The private data stores parameters passed into the view when it is set up, and data, such as<br />

fonts and coordinates, is required to draw the view. iFleet is the model and iCmdHandler<br />

is the controller in the MVC sense. So this control works as the V part of a well-structured<br />

MVC trio. The fleet view allows a cursor to be displayed, controlled by iCursorOn and (x, y)<br />

coordinates. Finally, the view can be zoomed to a size that is (iZoomFactor/1000) times<br />

the default size (more on this later).<br />

9.4.1 View Construction<br />

The view's main setup function is ConstructL():<br />

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

{<br />

// window setup<br />

CreateWindowL();<br />

SetRect(aRect);<br />

// set cursor<br />

SetCursor(0,0);<br />

// set zoom factor<br />

SetZoomL(1000);<br />

// activate control as ready for drawing<br />

ActivateL();<br />

}

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

Saved successfully!

Ooh no, something went wrong!