CartoType API
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
CartoType::CGraphicsContext Class Reference

#include <cartotype_graphics.h>

Inheritance diagram for CartoType::CGraphicsContext:
CartoType::CBitmapGraphicsContext CartoType::COpenGlGraphicsContext CartoType::CPerspectiveGraphicsContext CartoType::TTestLabelGraphicsContext CartoType::TTestZGraphicsContext CartoType::C16BitColorBitmapGraphicsContext CartoType::C24BitColorBitmapGraphicsContext CartoType::C8BitMonoBitmapGraphicsContext CartoType::CLabelGraphicsContext CartoType::C32BitColorBitmapGraphicsContext CartoType::C8BitTwinBitmapGraphicsContext

List of all members.

Public Types

enum  { EDrawShapeAntiAlias = 1, EDrawShape6BitFractionalPixels = 2, EDrawShapeEvenOddFill = 4 }

Public Member Functions

virtual void Sync ()=0
virtual TResult DrawBitmap (const TBitmap &aBitmap, const TPoint &aTopLeft)=0
virtual TResult DrawShape (const MPath &aPath, uint32 aFlags)=0
virtual void Clear ()=0
virtual CT_IMPORT TResult DrawRect (const TRect &aRect)
virtual CT_IMPORT bool TransformsPoints ()
virtual CT_IMPORT TResult Transform (TPoint &aPoint, int32 aFractionalBits)
virtual CT_IMPORT void InverseTransform (TPoint &aPoint, int32 aFractionalBits)
virtual CT_IMPORT bool EnableTransform (bool aEnable)
virtual CT_IMPORT void OnViewResize (int32 aWidth, int32 aHeight)
virtual CT_IMPORT TBitmapBitmap ()
virtual CT_IMPORT TBitmapPushBitmap (TResult &aError)
virtual CT_IMPORT TResult PopBitmap (TBitmap *aBitmap)
virtual CT_IMPORT TBitmapDeleteButKeepBitmap (CGraphicsContext *&aGc)
virtual CT_IMPORT TResult DrawTexture (const CTexture &aTexture, const TPointFP &aTopLeft, const TTransformFP &aTransform)
virtual CT_IMPORT TResult DrawStroke (const MPath &aPath, uint32 aFlags, const TTransform *aTransform=NULL)
CT_IMPORT TResult DrawShapeAndStroke (const MPath &aPath, uint32 aFlags, const TPaint &aStrokePaint, const TTransform *aTransform=NULL)
CT_IMPORT void SetClip (const TRect &aClip)
CT_IMPORT void SetColor (TColor aColor)
CT_IMPORT void SetPaintServer (MPaintServer *aPaintServer)
CT_IMPORT void SetPaint (const TPaint &aPaint)
CT_IMPORT void SetAlpha (int32 aAlpha)
CT_IMPORT void SetCompositingOp (TCompositingOp aOp)
CT_IMPORT void SetTextureMask (TColor aColor)
CT_IMPORT void SetParam (TGraphicsParam &aParam)
CT_IMPORT void SetPen (const TCircularPen &aPen)
CT_IMPORT TResult DrawLoggedText (int32 aIndex)
CT_IMPORT void InverseTransformRect (TRect &aRect, int32 aFractionalBits)
CEngineEngine ()
const TRectClip () const
const TPaintPaint () const
TColor Color () const
int32 Alpha () const
const TRectBounds () const
MPaintServerPaintServer () const
void SetPalette (const MPalette *aPalette)
const MPalettePalette () const
const TCircularPenPen () const
void SetDashArray (const CDashArray *aDashArray)
const CDashArrayDashArray () const
const TGraphicsParamParam () const

Static Public Member Functions

static uint8 MultiplyIntensities (int aIntensity1, int aIntensity2)
static uint8 AlphaBlend (int aForeground, int aBackground, int aAlpha)

Protected Types

enum  {
  EClipChanged = 1, EPaintChanged = 2, EGlowColorChanged = 4, ECompositingOpChanged = 8,
  ETextureMaskChanged = 16, EAllChanged = -1
}

Protected Member Functions

TResult DrawDashedStroke (const MPath &aPath, uint32 aFlags, const TTransform *aTransform)
 CGraphicsContext (CEngine &aEngine, const TRect &aBounds)

Protected Attributes

CEngineiEngine
TGraphicsParam iParam
TRect iBounds
int32 iChangeFlags

Detailed Description

The base graphics context class. A graphics context draws to a raster drawing surface with square pixels.


Member Enumeration Documentation

anonymous enum

Flags used when drawing shapes.

Enumerator:
EDrawShapeAntiAlias 

Use 8-bit anti-aliasing when drawing a shape. The default is monochrome rendering.

EDrawShape6BitFractionalPixels 

Use 26.6 fixed-point pixel coordinates (i.e. 64ths of pixels) when drawing a shape. The default is whole-pixel coordinates.

EDrawShapeEvenOddFill 

Use the even-odd fill rule when drawing shape. the default is the non-zero winding rule.

anonymous enum [protected]

Bit values for iChangeFlags.

Enumerator:
EClipChanged 

The clip rectangle has changed.

EPaintChanged 

The paint has changed.

EGlowColorChanged 

The glow color, if any, has changed.

ECompositingOpChanged 

The compositing operation has changed.

ETextureMaskChanged 

The texture mask has changed.

EAllChanged 

All graphics parameters have changed; the internal state must be completely initialised.


Constructor & Destructor Documentation

CartoType::CGraphicsContext::CGraphicsContext ( CEngine aEngine,
const TRect aBounds 
) [inline, protected]

Construct a graphics context to draw into aBounds.


Member Function Documentation

int32 CartoType::CGraphicsContext::Alpha ( ) const [inline]

Return the current alpha (opacity) level as a number in the range 0 ... 255.

static uint8 CartoType::CGraphicsContext::AlphaBlend ( int  aForeground,
int  aBackground,
int  aAlpha 
) [inline, static]

Blend aForeground and aBackground in the proportion aAlpha. All three numbers are intensities in the range 0...255.

CT_EXPORT TBitmap * CGraphicsContext::Bitmap ( ) [virtual]

Return the bitmap drawn to by the graphics context, if any. If the graphics context does not draw to a bitmap return NULL. The default implementation returns null.

Reimplemented in CartoType::CBitmapGraphicsContext, and CartoType::CPerspectiveGraphicsContext.

const TRect& CartoType::CGraphicsContext::Bounds ( ) const [inline]

Return the rectangle that the graphics context draws to if no clipping is done.

virtual void CartoType::CGraphicsContext::Clear ( ) [pure virtual]
const TRect& CartoType::CGraphicsContext::Clip ( ) const [inline]

Return the clipping rectangle.

TColor CartoType::CGraphicsContext::Color ( ) const [inline]

Return the current color as an RGBA value including the alpha channel.

const CDashArray* CartoType::CGraphicsContext::DashArray ( ) const [inline]

Return the current dash array.

CT_EXPORT TBitmap * CGraphicsContext::DeleteButKeepBitmap ( CGraphicsContext *&  aGc) [virtual]

Delete the graphics context, setting the pointer aGc to null, but preserve and return its bitmap. Do nothing if the operation is impossible. The base implementation does nothing.

Reimplemented in CartoType::CBitmapGraphicsContext.

virtual TResult CartoType::CGraphicsContext::DrawBitmap ( const TBitmap aBitmap,
const TPoint aTopLeft 
) [pure virtual]
CT_EXPORT TResult CGraphicsContext::DrawLoggedText ( int32  aIndex)

Redraw previous characters at identical positions, starting at logged character aIndex.

CT_EXPORT TResult CGraphicsContext::DrawRect ( const TRect aRect) [virtual]
virtual TResult CartoType::CGraphicsContext::DrawShape ( const MPath aPath,
uint32  aFlags 
) [pure virtual]
CT_EXPORT TResult CGraphicsContext::DrawShapeAndStroke ( const MPath aPath,
uint32  aFlags,
const TPaint aStrokePaint,
const TTransform aTransform = NULL 
)

Fill and outline a shape. The shape is filled if the current paint is non-null, and outlined if aStrokePaint is non-null. Optionally apply a transform to the shape and the stroke envelope.

CT_EXPORT TResult CGraphicsContext::DrawStroke ( const MPath aPath,
uint32  aFlags,
const TTransform aTransform = NULL 
) [virtual]

Draw a stroke using the current circular pen.

Optionally apply a transform to the stroke envelope before drawing it. The offsets in the transform (the Tx and Ty components) are always in pixels, whether or not (aFlags & EDrawShape6BitFractionalPixels) is true.

CT_EXPORT TResult CGraphicsContext::DrawTexture ( const CTexture aTexture,
const TPointFP aTopLeft,
const TTransformFP aTransform 
) [virtual]

Draw a texture at aTopLeft, transforming it by aTransform. The baseimplementation returns KErrorUnimplemented.

Reimplemented in CartoType::C32BitColorBitmapGraphicsContext, and CartoType::TTestLabelGraphicsContext.

CT_EXPORT bool CGraphicsContext::EnableTransform ( bool  aEnable) [virtual]

Enable or disable any transformation applied by the graphics context. Return the previous state. The base implementation does nothing and returns false.

Reimplemented in CartoType::CPerspectiveGraphicsContext.

CEngine& CartoType::CGraphicsContext::Engine ( ) [inline]

Return a reference to the singleton graphics engine.

CT_EXPORT void CGraphicsContext::InverseTransform ( TPoint aPoint,
int32  aFractionalBits 
) [virtual]

Apply the inverse of the graphics context's current transformation to a point. See CGraphicsContext::Transform function for details.

Reimplemented in CartoType::CPerspectiveGraphicsContext.

CT_EXPORT void CGraphicsContext::InverseTransformRect ( TRect aRect,
int32  aFractionalBits 
)

Apply the inverse of the graphics context's current transformation to a rectangle and normalise the rectangle so that left < right and top < bottom.

static uint8 CartoType::CGraphicsContext::MultiplyIntensities ( int  aIntensity1,
int  aIntensity2 
) [inline, static]

Multiply two intensities, treated as fractions in the range 0...255.

CT_EXPORT void CGraphicsContext::OnViewResize ( int32  aWidth,
int32  aHeight 
) [virtual]

Do anything that is needed when the output view size is initially set or changed. For instance, the OpenGL graphics context needs to change its viewport and projection. The base implementation does nothing.

Reimplemented in CartoType::CPerspectiveGraphicsContext, and CartoType::COpenGlGraphicsContext.

const TPaint& CartoType::CGraphicsContext::Paint ( ) const [inline]

Return the current paint.

MPaintServer* CartoType::CGraphicsContext::PaintServer ( ) const [inline]

Return the current paint server, or null if no paint server is in use.

const MPalette* CartoType::CGraphicsContext::Palette ( ) const [inline]

Return the current palette, or null if no palette is in use. Palettes are used only when drawing bitmaps requiring them.

const TGraphicsParam& CartoType::CGraphicsContext::Param ( ) const [inline]

Return the current graphics parameters.

const TCircularPen& CartoType::CGraphicsContext::Pen ( ) const [inline]

Return the pen used for drawing strokes.

CT_EXPORT TResult CGraphicsContext::PopBitmap ( TBitmap aBitmap) [virtual]

Draw the current bitmap on top of aBitmap before deleting it and restoring aBitmap as the current bitmap. The base implementation does nothing.

Reimplemented in CartoType::CBitmapGraphicsContext, and CartoType::CPerspectiveGraphicsContext.

CT_EXPORT TBitmap * CGraphicsContext::PushBitmap ( TResult aError) [virtual]

Replace the current bitmap with a new one of the same type and size, returning the original one. The base implementation does nothing.

Reimplemented in CartoType::CBitmapGraphicsContext, and CartoType::CPerspectiveGraphicsContext.

CT_EXPORT void CGraphicsContext::SetAlpha ( int32  aAlpha)

Set the alpha (transparency) level, where 0 = transparent and 255 = opaque.

CT_EXPORT void CGraphicsContext::SetColor ( TColor  aColor)

Set the color used for painting and set the paint server to null.

CT_EXPORT void CGraphicsContext::SetCompositingOp ( TCompositingOp  aOp)

Set the compositing op. Note that most graphics contexts support only one compositing op, 'over' (EOverCompositingOp).

void CartoType::CGraphicsContext::SetDashArray ( const CDashArray aDashArray) [inline]

Set the array of dash and gap sizes used for dashed strokes.

CT_EXPORT void CGraphicsContext::SetPaint ( const TPaint aPaint)

Set the color and the paint server.

CT_EXPORT void CGraphicsContext::SetPaintServer ( MPaintServer aPaintServer)

Set the paint server. A value of null tells the graphics context not to use a paint server but to use the current color.

void CartoType::CGraphicsContext::SetPalette ( const MPalette aPalette) [inline]

Set the palette. A value of null tells the graphics context not to use a palette, in which case bitmaps requiring palettes cannot be drawn.

CT_EXPORT void CGraphicsContext::SetParam ( TGraphicsParam aParam)

Set the graphics parameters to the values in aParam.

CT_EXPORT void CGraphicsContext::SetPen ( const TCircularPen aPen)

Set the pen used for drawing strokes.

CT_EXPORT void CGraphicsContext::SetTextureMask ( TColor  aColor)

Set the texture mask color: the color that prevents texture pixels from being drawn in unwanted areas like the sea.

virtual void CartoType::CGraphicsContext::Sync ( ) [pure virtual]
CT_EXPORT TResult CGraphicsContext::Transform ( TPoint aPoint,
int32  aFractionalBits 
) [virtual]

Apply the graphics context's current transformation to a point. Graphics contexts that provide a non-identity overriding implementation of this function must also override TransformsPoints to return true. The base implementation is identity and thus does nothing. Although the transform does not change the points' representation, the number of fractional bits must be supplied so that the transform can use actual pixels consistently, as in a perpective transform.

Reimplemented in CartoType::CPerspectiveGraphicsContext.

CT_EXPORT bool CGraphicsContext::TransformsPoints ( ) [virtual]

Return true if the GC applies a further transformation to points before drawing them, as for example the perspective transformation. The base implementation returns false.

Reimplemented in CartoType::CPerspectiveGraphicsContext.


Member Data Documentation

The bounds, in pixels, of the device drawn into.

Flags that are set when graphics parameters are changed, allowing derived classes to synchronize their internal states if necessary.

A reference to the engine object, which provides the shape rendering engines and other shared resources.

The drawing parameters such as the color and clip rectangle.


The documentation for this class was generated from the following files: