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.

RESOURCE MENU_PANE r_hellogui_hello_menu<br />

{<br />

items =<br />

}<br />

{<br />

MENU_ITEM<br />

{<br />

command = EHelloGuiCmd0;<br />

txt = "Item 0";<br />

},<br />

MENU_ITEM<br />

};<br />

{<br />

command = EEikCmdExit;<br />

txt = "Close (debug)";<br />

}<br />

As you can see, each of the two menu items only specifies two of the nine elements – the<br />

remaining seven take the default values that are specified in the declaration.<br />

A hex dump of the resource file gives the following result:<br />

The highlighted bytes represent the data for the menu pane resource. The most obviously<br />

recognizable parts of this resource are the strings, "Item 0" and "Close (Debug)".<br />

However, on reflection, you might be slightly puzzled: I have said that Symbian OS<br />

applications use a Unicode build, whereas these strings appear to be plain ASCII text.<br />

Furthermore, if you count through the resource, identifying items on the way, you will find<br />

that there is an occasional extra byte here and there – for example, each of the strings<br />

appears to be preceded by two identical count bytes, instead of the expected single byte.<br />

The answer to these puzzles is that the compiled resource is compressed in order to save<br />

space in Unicode string data. The content of the resource is divided into a sequence of runs,<br />

alternating between compressed data and uncompressed data. Each run is preceded by a<br />

count of the characters in that run, with the count being held in a single byte, provided that

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

Saved successfully!

Ooh no, something went wrong!