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: // from CEikDocument<br />

CEikAppUi* CreateAppUiL();<br />

};<br />

Again, because the application is intended to run on a P800, I'm deriving from a UIQ class.<br />

The implementation is as follows:<br />

CHelloGuiDocument::CHelloGuiDocument(CEikApplication& aApp)<br />

: CQikDocument(aApp)<br />

{<br />

}<br />

CEikAppUi* CHelloGuiDocument::CreateAppUiL()<br />

{<br />

return new(ELeave) CHelloGuiAppUi;<br />

}<br />

We start with a C++ constructor that simply calls CQikDocument's constructor, passing in<br />

the application as an argument. Next, there's the virtual CreateAppUiL() function which,<br />

to nobody's surprise, returns a new app UI. An application that is not UI-specific would<br />

simply replace the references to CQikDocument with ones to CEikDocument.<br />

Note carefully that CreateAppUiL() is responsible only for first- phase construction (which<br />

excludes any initialization that might fail). We'll see the second phase, to perform the<br />

possibly failure-prone initialization, shortly.<br />

The application UI<br />

The GUI action proper starts with the app UI, which has two main roles:<br />

� to get commands to the application,<br />

� to distribute keystrokes to controls, including the application's main view, which is<br />

owned by the app UI.<br />

A command is simply an instruction without any parameters, or any information about where<br />

it came from, which the program must execute. In any practical GUI program, you implement<br />

HandleCommandL(TIntaCommandId) in your derived app UI class. The command ID is<br />

simply a 32-bit integer.<br />

The definition is deliberately vague, since commands can originate from a variety of places.<br />

In UIQ applications, commands usually originate from an application's menu or – at least, in<br />

the emulator – from a shortcut key. (Applications may assign a shortcut key to any command<br />

ID – regardless of whether it is shown on the menus. The conventional shortcut key for the<br />

Close command, for instance, is Ctrl+E.)<br />

In other customized UIs, commands may originate from other sources. In the Series 80<br />

(Crystal) UI application, for example, which shows commonly used commands on a toolbar,<br />

commands may come from a toolbar button.<br />

A command may be available from any or all of these sources. It doesn't matter where it<br />

comes from, the app UI receives it as a 32-bit command ID in HandleCommandL() and<br />

simply executes the appropriate code to handle the command.

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

Saved successfully!

Ooh no, something went wrong!