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.

Here is the first appearance of something that is specific to UIQ. Because this application is<br />

being written to run on a P800, I've derived this class from UIQ's CQikApplication rather<br />

than Uikon's CEikApplication class. In this case, however, it makes no difference to the<br />

implementation, which you'll find in HelloGui_Application.cpp:<br />

TUid CHelloGuiApplication::AppDllUid() const<br />

{<br />

return KUidHelloGui;<br />

}<br />

CApaDocument* CHelloGuiApplication::CreateDocumentL()<br />

{<br />

return new(ELeave) CHelloGuiDocument(*this);<br />

}<br />

Given the explanation above, there's nothing too surprising here. I defined the UID in my<br />

HelloGui_Application.h file:<br />

const TUid KUidHelloGui = { 0x101f74a8 };<br />

I use the same UID here as in my .mmp file: the APPARC verifies that this is the same as my<br />

DLL UID, as a final check on the integrity of my application DLL.<br />

In the code above, then, you can see that the application class has two purposes:<br />

� it conveys some information about the capabilities of the application, including its UID,<br />

� it acts as a factory for a default document.<br />

These are little things, but important. Pretty much every Symbian OS GUI application<br />

contains these two functions coded just as I've implemented them here, changing only the<br />

class names and the UID from one application to the next.<br />

The document<br />

The really interesting code starts with the document class. In a file-based application (that is,<br />

one that handles and modifies persistent data), the document essentially represents the data<br />

in the file. You can do several things with that data, each of which makes different demands:<br />

printing it, for example, doesn't require an application – but editing it does. We'll see more of<br />

this in <strong>Chapter</strong> 15.<br />

If your application handles modifiable data, the APPARC requires your document to create<br />

an application user interface (app UI), which is then used to 'edit' the document.<br />

In a nonfile-based application, you still have to code a function in the document class to<br />

create an app UI, since it's the app UI that does the real work. Apart from creating the app<br />

UI, then, the document class for such an application is trivial.<br />

The declaration of CHelloGuiDocument is as follows:<br />

class CHelloGuiDocument : public CQikDocument<br />

{<br />

public:<br />

// construct/destruct<br />

CHelloGuiDocument(CEikApplication& aApp);

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

Saved successfully!

Ooh no, something went wrong!