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.

#define KRgbYellow TRgb(0x00ffff)<br />

#define KRgbBlue TRgb(0xff0000)<br />

#define KRgbMagenta TRgb(0xff00ff)<br />

#define KRgbCyan T Rgb(0xffff00)<br />

#define KRgbGray TRgb(0xaaaaaa)<br />

#define KRgbWhite TRgb(0xffffff)<br />

Note<br />

We use #define rather than (say) const TRgb KRgbWhite<br />

=TRgb(0xffffff) because GCC 2.7.2 didn't support build-time<br />

initialization of class constants. Plus initialization of any TRgb from one of<br />

these 'constants' is no more expensive than if 'proper' const<br />

TRgbs were used.<br />

Important<br />

All CGraphicsContextcolor specifications for pens and brushes use<br />

TRgbvalues. The graphics device then converts these into device-<br />

dependent color values internally.<br />

With measurements and fonts, you have to convert to device-dependent units (pixels and<br />

CFonts) before calling CGraphicsContext functions. The same approach could have<br />

been taken with colors but it wasn't, because the meaning of a color is less devicedependent<br />

than the size of a pixel or the bitmap for a font.<br />

Concrete color values such as KRgbBlack are useful in many situations. There are also<br />

some logical color values, defined in TLogicalColor that refer to colors used in the UI<br />

scheme, such as the colors used in menus, menu highlights, toolbar buttons, or window<br />

shadows. The choice of which physical colors these logical values correspond to belongs to<br />

the device OEM. The mapping is stored in a CColorList object. The color list<br />

� supports logical-to-RGB color mappings loaded from resource files or specified<br />

programmatically;<br />

� supports independent sections for the system and applications: a section is identified<br />

by a UID and a logical color by an enumerated constant;<br />

� supports mappings for both four-gray and 256-color schemes: the 256-color scheme<br />

will be used and will look good, if the screen mode supports 16 or more colors.<br />

Otherwise, the four-gray scheme will be used.<br />

An application can get the color list through CEikonEnv::Color List().<br />

A key thing you have to know about a device is how many colors it supports. Actually, the<br />

number of supported colors depends not only on the device, but also on the current display<br />

mode of the device. Most devices have a preferred display mode, and some support multiple<br />

display modes: you can check the display modes supported by a window server screen<br />

device and set your window to use a required display mode, if it's supported. Some display<br />

modes consume more power than others, so the window server will change the display<br />

mode in use, to the one with the minimum power requirement for any visible window.<br />

You can create bitmaps with any display mode. When you blit them onto another bitmap, or<br />

display them in a particular mode, the bitmap data is contracted or expanded as necessary,<br />

to match the display mode of the target bitmap.<br />

The display modes supported by Symbian OS are defined in the TDisplayMode<br />

enumeration in gdi.h. They are<br />

Mode Bits Type Comment

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

Saved successfully!

Ooh no, something went wrong!