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.

destroyed frequently in application use, so these optimizations make a significant<br />

difference.<br />

� Reduced overheads: Lodgers also reduce the overheads associated with complex<br />

entities such as a dialog because controls are much more compact in memory than<br />

windows.<br />

� Less processing : Lodgers have less demanding processing requirements. Windows<br />

may move, change z order, and overlap arbitrarily. Lodgers at peer level on the same<br />

window never intersect and they only occupy a subregion of their owning window or<br />

control. This makes the logic for detecting intersections much easier than that required<br />

for the arbitrarily complex regions managed by the window server.<br />

When you need a window<br />

All these factors improve the system efficiency of Symbian OS, compared to a scenario with<br />

no lodger controls. In order to take advantage of these features, most controls should be<br />

coded as lodgers, but there are a few circumstances in which you need a window:<br />

� When there is no window to lodge in – this is the case for the application view.<br />

� When you need shadows, as described later in this chapter. Shadows are used by<br />

dialogs, popup menus, popup list-boxes, menu panes, and the menu bar.<br />

� When you need a backed-up window – we'll come back to these later.<br />

� When you need to overlap peer controls in an arbitrary way – not according to lodger<br />

controls' stricter nesting rules.<br />

� When you need the backup-behind property (see below), which is used by dialogs and<br />

menu panes to hold a bitmap of the window behind them.<br />

Being window-owning is a fairly fundamental property of a control. There isn't much point in<br />

coding a control bimodally – that is, to be either a lodger or to be window-owning. Decide<br />

which it should be and commit to it.<br />

On the other hand, only small parts of your control's code will be affected by the decision.<br />

So, if you find out later that (for instance) your control that was previously a stand-alone app<br />

view now has a window to lodge in, then you should be able to modify your control quite<br />

easily.<br />

For instance, in the drawing example in <strong>Chapter</strong> 15, the CExample-HelloControl class<br />

adapts hellogui's CHelloGuiAppView to turn it into a lodger. The class declaration<br />

changes from:<br />

class CHelloGuiAppView : public CCoeControl<br />

{<br />

public:<br />

static CHelloGuiAppView* NewL(const TRect& aRect);<br />

~CHelloGuiAppView();<br />

void ConstructL(const TRect& /*aRect*/);<br />

private:<br />

void Draw(const TRect& /* aRect */) const;<br />

private:<br />

HBufC* iHelloText;<br />

};<br />

to:<br />

class CExampleHelloControl : public CCoeControl

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

Saved successfully!

Ooh no, something went wrong!