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.

private to the app UI, so they were not given their own header.<br />

The C++ constructor takes whatever parameter is necessary to connect the dialog to the<br />

outside world – in this case, my app UI, since it's this dialog's job to set its iFileName and<br />

iText members.<br />

class CExampleWriteFileDialog : public CEikDialog<br />

{<br />

public:<br />

CExampleWriteFileDialog(CExampleAppUi* aAppUi);<br />

private:<br />

// From CEikDialog<br />

void PreLayoutDynInitL(); // Initialization<br />

TBool OkToExitL(TInt aKeycode); // Termination<br />

private:<br />

CExampleAppUi* iAppUi;<br />

};<br />

Note<br />

On reflection, this isn't actually a very good encapsulation of the interface: I<br />

should really have passed references to the iFileName and iText<br />

members to make it clear that the dialog is intended to alter them and<br />

nothing else.<br />

Initialization is performed by PreLayoutDynInitL().The 'prelayout' part of the name<br />

means that the data you put into the dialog here will influence its layout – dialogs are laid out<br />

automatically to incorporate the optimum size of controls for the initialization data supplied.<br />

Here's PreLayoutDynInitL():<br />

void CExampleWriteFileDialog::PreLayoutDynInitL()<br />

{<br />

CEikFileNameEditor* fnamed=STATIC_CAST(CEikFileNameEditor*,<br />

Control<br />

(EExampleControlIdFileName));<br />

fnamed->SetTextL(iAppUi->iFileName);<br />

CEikEdwin* edwin=STATIC_CAST(CEikEdwin*, Control<br />

(EExampleControlIdText));<br />

edwin->SetTextL(iAppUi->iText);<br />

}<br />

This simply sets the edit windows to the existing values in iFile-Name and iText.<br />

Controls are identified by their ID, as specified in the id= line in the resource file definition.<br />

Control() returns a CCoeControl* type and this must be cast to the actual control type<br />

that it represents.

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

Saved successfully!

Ooh no, something went wrong!