×
Namespaces

Variants
Actions

GDI Classes for Size and Target Independent Drawing

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: vasant21 (23 May 2007)
Last edited: hamishwillee (23 Jul 2012)

Graphical applications may need to support zooming and drawing to different targets. Possible targets are the screen or a printer. Different targets may also mean different types of smartphones, with different screen sizes. The classes that support size independence are the same for each target :


1) CGraphicsContext

2) MGraphicsDeviceMap

3) Mgraphics- Device

4) TZoomFactor


These have to be implemented differently for the different targets. They are a part of the Graphics Device Interface (GDI). Application drawing code uses the functions and settings of the GDI classes.


Contents

Class Description

CGraphicsContext

The abstract base class created by a graphics device, CGraphicsDevice. Contains the main drawing functions. Provides the 'context' in which you are drawing to the associated device in the sense that it holds the pen and brush settings (e.g. color, line styles) and font settings (e.g. bold, underline, italic) for drawing, and also the clipping region(the visible drawing area). These can all be updated while drawing.

Deals with pixels of device-dependent size and uses fonts with device-dependent size and representation. The sizes and fonts to be passed to CGraphicsContext functions therefore need to be converted from size-independent units to size dependent units beforehand. This is done by an MGraphicsDeviceMap derived class. This may be a TZoomFactor or the CGraphicsDevice.


MGraphicsDeviceMap

The abstract base class for both graphic devices and zoom factors. Defines the size-dependent functions in a graphics device. These functions convert between pixels and twips and perform font allocation and release. Font allocation involves finding the font supported by the device that is the closest to a deviceindependent font specification.


CGraphicsDevice

The abstract base class for all graphics devices that represents the medium being drawn to. Manufactures a graphics context suitable for drawing to itself (using CreateContext()), which takes into account the attributes of the device, such as the size and display mode. Allocates (and releases) fonts suitable for drawing to itself and converts between twips and pixels.

Important graphic devices are CScreenDevice,CBitmapDevice and CPrinterDevice.


TZoomFactor

Defines azoom factor and implements the MGraphicsDeviceMap interface. Allocates and releases device-dependent fonts and converts between twips and pixels.

Facilitates zooming, because it allows the size of the graphic to become independent of the target size.This class is recursive, because a TZoomFactor object can use an MGraphicsDeviceMap, which could be a TZoomFactor itself, as illustrated below. This allows a zoom factor object to contain another zoom factor object, multiplying the effect of the child zoom factor. The top-level zoom factor, however, uses a CGraphicsDevice (not another TZoomFactor).

This page was last modified on 23 July 2012, at 10:57.
38 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×