Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Graphics Overview


Purpose

Provides an abstract interface for drawing to devices, such as screens and printers.

[Top]


Architectural relationships

The Bitmaps API and Printing API provide concrete implementations of the abstract drawing interfaces defined in this API, for screens and printers respectively. The Window Server Client Side API extends the Bitmaps API's classes in turn for drawing in windows (the normal case). For some applications, this polymorphism can be important, as it allows shared code for screen drawing and printing.

Most drawing takes place within a control, as defined in the UI Control Framework. That API provides support functions for using graphics contexts.

[Top]


Description

The API has five key concepts: basic geometry classes, graphics device (CGraphicsDevice), graphics context (CGraphicsContext), colour (TRgb), and units conversion (TPoint, TSize and MGraphicsDeviceMap) and zooming (TZoomFactor).


Basic geometry classes

Point: a pair of (x,y) co-ordinates. It is provided by TPoint.

Size: a width and height. It is provided by TSize.

Rectangle: described by the co-ordinates of its top-left and bottom-right corners, or by its top-left hand corner and its size. It is provided by TRect.

Region: defines an area made up a collection of rectangles. They are handled by a family of classes derived from TRegion.


Graphics device

A graphics device represents the medium being drawn to. It is the provider of graphics contexts through which drawing is done.

The base class for graphics devices is CGraphicsDevice. Concrete devices implement derived classes.


Graphics context

A graphics context provides a large number of drawing operations, with some state settings defining how the drawing is performed. The settings are:

Operations include drawing shapes (points, lines, polylines, arcs, rectangles, polygons, ellipses, rounded rectangles and pie slices), text, and bitmaps.

The base class for graphics contexts is CGraphicsContext. Concrete devices provide derived classes that can provide additional operations suitable to the device.


Colour

A colour is specified by a 24-bit colour value. The system then maps these values into device-level values. The colour class is TRgb.


Units conversion and zooming

Graphics code can be written in a device-independent way by handling lengths/positions using twips (1/1440th inch), and only converting into pixels when actually drawing. Graphic devices implement a twips/pixels mapping interface for this conversion. The interface is defined by MGraphicsDeviceMap.

You might want drawing code to draw at different possible levels of magnification (zoom). In that case, the mapping is performed by a TZoomFactor, which also implements MGraphicsDeviceMap.

[Top]


See also

Bitmaps Overview

Printing Overview

UI Control Framework Overview

Window Server Client Side Overview