Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: w32std.h
Link against: ws32.lib

Class CWindowGc

CWindowGc

Support

Supported from 5.0

Description

Window graphics context.

Most window graphics context drawing functions map to equivalent CFbsBitGc functions — they are implemented on the screen with any co-ordinates being relative to the top left corner of the window. However extra clipping is applied. The drawing will always be clipped to the visible part of the window, in addition it will be clipped to the non-invalid part if you are not doing a redraw and to the region being validated if you are doing a redraw.

Note:

Derivation

CBaseBase class for all classes to be instantiated on the heap
CBitmapContextAn abstract, device-independent, interface to bitmapped graphics contexts
CGraphicsContextAbstract, device independent, interface to graphics contexts
CWindowGcWindow graphics context
MWsClientClassBase class for all classes whose objects are clients of the window server engine

Defined in CWindowGc:
Activate(), BitBlt(), BitBltMasked(), CWindowGc(), CancelClippingRect(), CancelClippingRegion(), Clear(), Construct(), CopyRect(), Deactivate(), Device(), DiscardBrushPattern(), DiscardFont(), DrawArc(), DrawBitmap(), DrawEllipse(), DrawLine(), DrawLineBy(), DrawLineTo(), DrawPie(), DrawPolyLine(), DrawPolygon(), DrawRect(), DrawRoundRect(), DrawText(), DrawTextVertical(), MapColors(), MoveBy(), MoveTo(), Plot(), Reset(), SetBrushColor(), SetBrushOrigin(), SetBrushStyle(), SetCharJustification(), SetClippingRect(), SetClippingRegion(), SetDitherOrigin(), SetDrawMode(), SetFaded(), SetFadingParameters(), SetOrigin(), SetPenColor(), SetPenSize(), SetPenStyle(), SetStrikethroughStyle(), SetUnderlineStyle(), SetWordJustification(), UseBrushPattern(), UseFont(), ~CWindowGc()

Inherited from CBase:
operator new()

Inherited from CGraphicsContext:
EAlternate, EAnd, ECenter, EDashedPen, EDiamondCrossHatchBrush, EDotDashPen, EDotDotDashPen, EDottedPen, EDrawModeAND, EDrawModeANDNOT, EDrawModeNOTAND, EDrawModeNOTANDNOT, EDrawModeNOTOR, EDrawModeNOTORNOT, EDrawModeNOTPEN, EDrawModeNOTSCREEN, EDrawModeNOTXOR, EDrawModeOR, EDrawModeORNOT, EDrawModePEN, EDrawModeXOR, EForwardDiagonalHatchBrush, EHorizontalHatchBrush, EInvertPen, EInvertScreen, ELeft, ELogicalOp, ENullBrush, ENullPen, EOr, EPatternedBrush, EPenmode, ERearwardDiagonalHatchBrush, ERight, ESolidBrush, ESolidPen, ESquareCrossHatchBrush, EVerticalHatchBrush, EWinding, EXor, JustificationInPixels(), TBrushStyle, TDrawMode, TDrawModeComponents, TDrawTextParam, TFillRule, TPenStyle, TTextAlign

Inherited from MWsClientClass:
WsHandle()

See also:


Construction and destruction


CWindowGc()

CWindowGc(CWsScreenDevice *aDevice);

Description

Constructor which creates, but does not initialise a graphics context.

Parameters

CWsScreenDevice *aDevice

Any screen device owned by the same session. Its life time should be at least as long as the gc itself.

See also:


Construct()

virtual TInt Construct();

Description

Completes construction.

Return value

TInt

KErrNone if successful, otherwise a leave error.


~CWindowGc()

virtual ~CWindowGc();

Description

Destructor.

[Top]


Activation and deactivation


Activate()

virtual void Activate(RDrawableWindow &aWindow);

Description

Activates the context for a given window.

When drawing is complete, the code using the context should call Deactivate(). Draw methods invoked after an Activate() will affect the window specified. A graphics context can only be active for one window at a time.

Parameters

RDrawableWindow &aWindow

The window for which the graphics context is to be activated.

Panic codes

 

Calling the Draw function before calling this function.

 

Calling this function twice without an intervening Deactivate().


Deactivate()

virtual void Deactivate();

Description

Frees the graphics context to be used with another window.

This method should be called when the application has completed drawing to the window.

[Top]


The clipping region


CancelClippingRegion()

virtual void CancelClippingRegion();

Description

Cancels the current clipping region.


SetClippingRegion()

virtual TInt SetClippingRegion(const TRegion& aClippingRegion);

Description

Sets the clipping region.

Note:

Parameters

const TRegion& aClippingRegion

New clipping region.

Return value

TInt

KErrNone if successful, KErrNoMemory if there is insufficient memory to create the region on the server side, otherwise another leave error.


CancelClippingRect()

virtual void CancelClippingRect();

Description

Cancel the clipping rectangle.

See also:


SetClippingRect()

virtual void SetClippingRect(const TRect& aRect);

Description

Sets a clipping rectangle.

Graphics drawn to the window are clipped, so that only items which fall within the rectangle are displayed.

Note:

Clipping is additive. If a clipping regions has been set using SetClippingRegion() then clipping will be to the intersection of that region and this rectangle.

Parameters

const TRect& aRect

The clipping rectangle.

See also:

[Top]


Text drawing functions


DrawText()

virtual void DrawText(const TDesC &aString,const TPoint &aPosition);

Description

Draws horizontal text with no surrounding box.

Text drawing is subject to drawing mode, the current font, pen colour, drawing mode, word justification and character justification.

Parameters

const TDesC &aString

String to write.

const TPoint &aPosition

The point specifying the position of the baseline at the left end of the text

Panic codes

 

If this function is called when there is not font — see UseFont().

See also:


DrawText()

virtual void DrawText(const TDesC &aString, const TRect &aBox, TInt aBaselineOffset, TTextAlign aHoriz=ELeft, TInt aLeftMrg=0);

Description

Draws horizontal text within a cleared box.

Text drawing is subject to drawing mode, the current font, pen colour, word justification and character justification. It is also subject to the background brush (set brush to ENullBrush for no effect on background).

Note:

Parameters

const TDesC &aString

String to write.

const TRect &aBox

The box to draw the text in.

TInt aBaselineOffset

An offset from the top of the box to the text baseline. NB the baseline is the line on which letters sit — e.g. below r, s, t, and above the tail of q, and y.

TTextAlign aHoriz=ELeft

The text alignment mode (default is left, rather than centre or right).

TInt aLeftMrg=0

The left margin for left-aligned text, or the right margin for right-aligned text (default is zero).

Panic codes

 

If this function is called when there is not font — see UseFont().

See also:


DrawTextVertical()

virtual void DrawTextVertical(const TDesC& aText, const TPoint& aPosition, TBool aUp);

Description

Draws vertical text in the specified direction.

Parameters

const TDesC& aText

Text to be drawn.

const TPoint& aPosition

Point of origin of the text baseline.

TBool aUp

Direction. ETrue for up, EFalse for down.

Panic codes

 

If this function is called when there is not font — see UseFont().


DrawTextVertical()

virtual void DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset, TBool aUp, TTextAlign aVert=ELeft, TInt aMargin=0);

Description

Draws text vertically in the specified direction, within a box of the specified size.

Parameters

const TDesC& aText

Text to be drawn.

const TRect& aBox

Bounding box within which the text should be drawn, and which it is clipped to.

TInt aBaselineOffset

Height of top of the characters from their text baseline.

TBool aUp

Direction. ETrue for up, EFalse for down.

TTextAlign aVert=ELeft

Text alignment.

TInt aMargin=0

Margin.

Panic codes

 

If this function is called when there is not font — see UseFont().


UseFont()

virtual void UseFont(const CFont *aFont);

Description

Sets this context's current font.

The font is used for text drawing. If the font is already in the font and bitmap server's memory the GDI will share that copy.

Note that this function must be called prior to drawing text or the calling thread will panic.

Parameters

const CFont *aFont

A device font.

See also:

[Top]


Other drawing functions


BitBlt()

virtual void BitBlt(const TPoint &aPos, const CFbsBitmap *aDevice);

Description

Performs a bitmap block transfer.

Parameters

const TPoint &aPos

The position for the top left corner of the bitmap.

const CFbsBitmap *aDevice

A memory-resident bitmap.

See also:


BitBlt()

virtual void BitBlt(const TPoint &aPos, const CFbsBitmap *aDevice, const TRect &aRect);

Description

Performs a bitmap block transfer of a rectangular piece of a bitmap.

Notes:

Parameters

const TPoint& aPos

The position for the top left corner of the bitmap.

const CFbsBitmap* aDevice

A memory-resident bitmap

const TRect& aRect

A rectangle defining the piece of the bitmap to be drawn, with co-ordinates relative to the top left corner of the bitmap

See also:


BitBlt()

virtual void BitBlt(const TPoint &aPos, const CWsBitmap* aDevice);

Description

Performs a bitmap block transfer on a bitmap to which the window server already has a handle.

This function should be used in preference to the CFbsBitmap overload if the bitmap is to be used more than once, as it is a lot quicker.

Parameters

const TPoint& aPos

The position for the top left corner of the bitmap.

const CWsBitmap* aDevice

A window server bitmap.

See also:


BitBlt()

virtual void BitBlt(const TPoint& aPos, const CWsBitmap* aDevice, const TRect &aRect);

Description

Performs a bitmap block transfer of a rectangular piece of a bitmap to which the window server already has a handle.

This function should be used in preference to the CFbsBitmap overload if the bitmap is to be used more than once, as it is a lot quicker.

Notes:

Parameters

const TPoint& aPos

The position for the top left corner of the bitmap.

const CWsBitmap* aDevice

A window server bitmap.

const TRect& aRect

A rectangle defining the piece of the bitmap to be drawn, with co-ordinates relative to the top left corner of the bitmap

See also:


BitBltMasked()

virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);

Description

Performs a masked bitmap block transfer of a memory resident source bitmap.

The mask bitmap can be used as either a positive or negative mask. Masked pixels are not mapped to the destination rectangle.

A black and white (binary) mask bitmap is used. With aInvertMask=ETrue, black pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle. With aInvertMask=EFalse, white pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle.

Parameters

const TPoint& aPoint

A position for the top left corner of the bitmap.

const CFbsBitmap* aBitmap

A memory-resident source bitmap.

const TRect& aSourceRect

A rectangle defining the piece of the bitmap to be drawn, with co-ordinates relative to the top left corner of the bitmap

const CFbsBitmap* aMaskBitmap

A mask bitmap.

TBool aInvertMask

If true, a source pixel that is masked by a black pixel is not transferred to the destination rectangle. If false, then a source pixel that is masked by a white pixel is not transferred to the destination rectangle.

See also:


BitBltMasked()

virtual void BitBltMasked(const TPoint& aPoint,const CWsBitmap *aBitmap,const TRect& aSourceRect,const CWsBitmap *aMaskBitmap,TBool aInvertMask);

Description

Performs a masked bitmap block transfer of a window server bitmap.

The mask bitmap can be used as either a positive or negative mask. Masked pixels are not mapped to the destination rectangle.

A black and white (binary) mask bitmap is used. With aInvertMask=ETrue, black pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle. With aInvertMask=EFalse, white pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle.

This function should be used in preference to the CFbsBitmap overload if the bitmap is to be used more than once, as it is a lot quicker.

Parameters

const TPoint& aPoint

A position for the top left corner of the bitmap.

const CWsBitmap *aBitmap

A window server bitmap.

const TRect& aSourceRect

A rectangle defining the piece of the bitmap to be drawn, with co-ordinates relative to the top left corner of the bitmap.

const CWsBitmap *aMaskBitmap

A window server mask bitmap.

TBool aInvertMask

If true, a source pixel that is masked by a black pixel is not transferred to the destination rectangle. If false, then a source pixel that is masked by a white pixel is not transferred to the destination rectangle.

See also:


Clear()

virtual void Clear();

Description

Clears the whole window.

The cleared area is filled with the current brush colour.

See also:


Clear()

virtual void Clear(const TRect &aRect);

Description

Clears a rectangular area of a window.

The cleared area is filled with the current brush colour.

Parameters

const TRect &aRect

The rectangle to clear.

See also:


CopyRect()

virtual void CopyRect(const TPoint& aOffset,const TRect& aRect);

Description

Copies a rectangle from any part of the screen into the window that the gc is active on.

The copy part of the operation applies to the whole rectangle, irrespective of whether or not it within the window, however the "paste" is clipped to the drawing area.

The rectangle is specified in window coordinates (if the top-left of the rectangle is (0,0) then the area of the screen it specifies has it's top-left at the top left corner of the window, if it is (-10,-10) then it start 10 pixels above and to the left of the window.)

Note:

Parameters

const TPoint& aOffset

The offset from the original position to the point where the rectangle is copied.

const TRect& aRect

The rectangular area to be copied. This is in window co-ordinates, e.g. the top left corner of the window is position (0,0) with respect to the the rectangle.

See also:


Device()

virtual CGraphicsDevice* Device() const;

Description

Gets a pointer to the current graphics device.

This is the device that was passed into the constructor, and is therefore a CWsScreenDevice.

Return value

CGraphicsDevice*

A pointer to the current graphics device.


DiscardBrushPattern()

virtual void DiscardBrushPattern();

Description

Discards a non-built-in brush pattern.

This frees up the memory used for the bitmap, if it is not being shared by another process.

Notes

See also:


DiscardFont()

virtual void DiscardFont();

Description

Discards a font.

This frees up the memory used (if the font is not being shared with some other process).

Notes

See also:


DrawArc()

virtual void DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);

Description

Draws an arc. An arc is a portion of an ellipse.

The point aStart is used to define one end of a line from the geometric centre of the ellipse. The point of intersection between this line and the ellipse defines the start point of the arc. The point aEnd is used to define one end of a second line from the geometric centre of the ellipse. The point of intersection between this line and the ellipse defines the end point of the arc. The pixels at both the start point and the end point are drawn.

The arc itself is the segment of the ellipse in an anti-clockwise direction from the start point to the end point.

Notes

Parameters

const TRect& aRect

A rectangle in which to draw the ellipse (of which the arc is a segment)

const TPoint& aStart

A point to define the start the arc

const TPoint& aEnd

A point to define the end the arc

See also:


DrawBitmap()

virtual void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource);

Description

Draws a bitmap at a specified point.

The function does a compress/stretch based on its internally stored size in twips. Note that if the twips value of the bitmap is not set then nothing is drawn (this is the default situation).

Note:

Parameters

const TPoint& aTopLeft

The point where the top left pixel of the bitmap is to be drawn

const CFbsBitmap* aSource

A source bitmap.

See also:


DrawBitmap()

virtual void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource);

Description

Draws a bitmap in a rectangle.

The bitmap is compressed/stretched to fit the specified rectangle. Note that if the twips value of the bitmap is not set then nothing is drawn (this is the default situation).

Notes:

Parameters

const TRect& aDestRect

The rectangle within which the bitmap is to be drawn.

const CFbsBitmap* aSource

A source bitmap.

See also:


DrawBitmap()

virtual void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource, const TRect& aSourceRect);

Description

Draws a specified rectangle from a bitmap into another rectangle.

The function compresses/stretches the specified rectangle from the bitmap to fit the destination rectangle. Note that if the twips value of the bitmap is not set then nothing is drawn (this is the default situation).

Note:

Parameters

const TRect& aDestRect

The rectangle within which the bitmap is to be drawn.

const CFbsBitmap* aSource

A source bitmap.

const TRect& aSourceRect

The rectangle in the source bitmap that is copied to the destination rectangle.

See also:


DrawEllipse()

virtual void DrawEllipse(const TRect& aRect);

Description

Draws and fills an ellipse.

The ellipse is drawn inside the rectangle defined by the aRect argument. Any TRect that has odd pixel dimensions, has the bottom right corner trimmed to give even pixel dimensions before the ellipse is constructed.

The column and row of pixels containing the bottom right co-ordinate of the aRect argument are not part of the rectangle (see Arguments of type TRect).

Notes

Parameters

const TRect& aRect

A rectangle in which to draw the ellipse

See also:


DrawLine()

virtual void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2);

Description

Draws a straight line between two points.

Parameters

const TPoint& aPoint1

The point at the start of the line.

const TPoint& aPoint2

The point at the end of the line.

See also:


DrawLineBy()

virtual void DrawLineBy(const TPoint& aVector);

Description

Draws a straight line relative to the current internal drawing position, using a vector.

The start point of the line is the current internal drawing position. The vector aVector is added to the internal drawing position to give the end point of the line

Parameters

const TPoint& aVector

The vector to add to the current internal drawing position, giving the end point of the line.

See also:


DrawLineTo()

virtual void DrawLineTo(const TPoint& aPoint);

Description

Draws a straight line from the current internal drawing position to a point.

Parameters

const TPoint& aPoint

The point at the end of the line.

See also:


DrawPie()

virtual void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd);

Description

Draws and fills a pie-shaped slice of an ellipse.

Outlines are subject to the current pen colour, width, style and draw mode. Set the pen to ENullPen for no outline. The fill is subject to brush style (colour, hash or pattern), the origin and the current drawing mode. set the brush to ENullBrush for no fill.

The point aStart is used to define one end of a line to the centre of the ellipse. The point of intersection between this line and the ellipse defines the start point of the arc bounding the pie slice. The point aEnd is used to define one end of a second line to the centre of the ellipse. The point of intersection between this line and the ellipse defines the end point of the arc bounding the pie slice. The pixels at the end point are not drawn.

The pie slice itself is the area bounded by:

The line drawn by the pen goes inside the rectangle given by the aRect argument.

Notes

Parameters

const TRect& aRect

A rectangle in which to draw the ellipse bounding the pie slice

const TPoint& aStart

A point to define the start of the pie slice

const TPoint& aEnd

A point to define the end of the pie slice

See also:


DrawPolyLine()

virtual void DrawPolyLine(const CArrayFix<TPoint>* aPointList);

Description

Draws a polyline using points in an array.

A polyline is a series of concatenated straight lines joining a set of points.

Parameters

const CArrayFix<TPoint>* aPointList

An array containing the points on the polyline.

See also:


DrawPolyLine()

virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);

Description

Draws a polyline using points in a list.

A polyline is a series of concatenated straight lines joining a set of points.

Parameters

const TPoint* aPointList

Pointer to list of points on the polyline.

TInt aNumPoints

Number of points in the point list.

See also:


DrawPolygon()

virtual TInt DrawPolygon(const CArrayFix<TPoint> *aPointList,TFillRule aFillRule=EAlternate);

Description

Draws and fills a polygon using points defined in an array.

The first TPoint in the array defines the start of the first side of the polygon. The second TPoint defines the second vertex (the end point of the first side and the start point of the second side) and so on. The final side of the polygon is drawn using the last TPoint from the array or list, and the line drawn to the start point of the first side.

Self-crossing polygons can be filled according to one of two rules, TFillRule::EAlternate (the default), or TFillRule::EWinding. To explain the difference between these rules, the concept of a winding number needs to be introduced. The area outside any of the loops of the polygon has a winding number of zero, and is never filled. An inside a loop which is bounded by an area with winding number 0 has a winding number of 1. If an area is within a loop that is bounded by an area with winding number 1, e.g. a loop within a loop, has a winding number of 2, and so on.

The filling of a polygon proceeds according to this algorithm:

Parameters

const CArrayFix<TPoint>* aPointList

An array of points, specifying the vertices of the polygon.

TFillRule aFillRule=EAlternate

Either TFillRule::EAlternate (the default) or TFillRule::Ewinding.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also:


DrawPolygon()

virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate);

Description

Draws and fills a polygon using points defined in a list.

The first TPoint in the list defines the start of the first side of the polygon. The second TPoint defines the second vertex (the end point of the first side and the start point of the second side) and so on. The final side of the polygon is drawn using the last TPoint from the array or list, and the line drawn to the start point of the first side.

Self-crossing polygons can be filled according to one of two rules, TFillRule::EAlternate (the default), or TFillRule::EWinding. To explain the difference between these rules, the concept of a winding number needs to be introduced. The area outside any of the loops of the polygon has a winding number of zero, and is never filled. An inside a loop which is bounded by an area with winding number 0 has a winding number of 1. If an area is within a loop that is bounded by an area with winding number 1, e.g. a loop within a loop, has a winding number of 2, and so on.

The filling of a polygon proceeds according to this algorithm:

Parameters

const TPoint* aPointList

Pointer to list of points, specifying the vertices of the polygon.

TInt aNumPoints

The number of points in the vertex list

TFillRule aFillRule=EAlternate

Either TFillRule::EAlternate (the default) or TFillRule::EWinding.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also:


DrawRect()

virtual void DrawRect(const TRect& aRect);

Description

Draws and fills a rectangle.

The rectangle's border is drawn with the pen, and it is filled using the brush.

Parameters

const TRect& aRect

The rectangle to be drawn.

See also:


DrawRoundRect()

virtual void DrawRoundRect(const TRect& aRect,const TSize& aEllipse);

Description

Draws and fills a rectangle with rounded corners.

The rounded corners are each constructed as an arc of an ellipse. The dimensions of each corner (corner size and corner height) are given by aEllipse. See DrawArc() for a description of arc construction.

The line drawn by the pen (if any) goes inside the rectangle given by the TRect argument.

Notes

Parameters

const TRect& aRect

The rectangle to be drawn.

const TSize& aEllipse

The dimensions of each corner.

See also:


MapColors()

virtual void MapColors(const TRect& aRect, const TRgb* aColors, TInt aNumPairs=2, TBool aMapForwards=ETrue);

Description

Re-maps pixel colours within a rectangle.

aColors is an array of paired colour values. The rectangle is scanned and the colour value of each pixel is looked up in the array, and if found is replaced by the value with which it is paired. The arguments specify the rectangle, the array of pairs, the number of pairs in the array, and the 'direction' of lookup. If no entry is found for the colour value of a given pixel it remains unchanged.

This function was designed for cursor display. A cursor is normally displayed as the XOR of the background against which it appears. However in some graphics modes, certain colours XOR to very similar shades. MapColors() allows more pleasing maps to be specified.

Parameters

const TRect& aRect

Rectangle to be mapped.

const TRgb* aColors

Array of colour value pairs, one value in a pair is the lookup value and the other is the replacement value.

TInt aNumPairs=2

Number of pairs in the array. aColors must have twice this number of elements. By default the aColors array is assumed to specify 2 colours — a single mapping.

TBool aMapForwards=ETrue

Direction of lookup. ETrue to map forwards, i.e. treat the first value in the pair as the lookup value and the second as the replacement value; EFalse does the opposite.


MoveBy()

virtual void MoveBy(const TPoint &aVector);

Description

Moves the internal drawing position by a vector, without drawing a line.

The internal drawing position is moved relative to its current co-ordinates.

Parameters

const TPoint &aVector

The vector to move the internal drawing position by.

See also:


MoveTo()

virtual void MoveTo(const TPoint& aPoint);

Description

Moves the internal drawing position relative to the co-ordinate origin, without drawing a line.

A subsequent call to DrawLineTo() or DrawLineBy() will then use the new internal drawing position as the start point for the line drawn.

Notes

Parameters

const TPoint& aPoint

The point to move the internal drawing position to.

See also:


Plot()

virtual void Plot(const TPoint& aPoint);

Description

Draws a single point.

The point is drawn with the current pen settings using the current drawing mode.

Note:

Parameters

const TPoint& aPoint

The point to be drawn.

See also:


Reset()

virtual void Reset();

Description

Resets the graphics context to its default settings.

These are:

See also:


SetBrushColor()

virtual void SetBrushColor(const TRgb &aColor);

Description

Sets the brush colour.

The effective brush colour depends on the drawing mode (see SetDrawMode()). If no brush colour has been set, it defaults to white. However the default brush style is null, so when drawing to a window the default appears to be the window's background colour.

Parameters

const TRgb &aColor

An RGB colour for the brush.

See also:


SetBrushOrigin()

virtual void SetBrushOrigin(const TPoint& aOrigin);

Description

Sets the brush pattern origin.

This specifies the position of the pixel in the top left corner of a reference pattern tile, (in absolute device co-ordinates). Other copies of the pattern file are then tiled around the reference one. Thus the brush origin can be set as the top left corner of a shape.

The brush pattern may be a built-in style (see SetBrushStyle()), or a bitmap. To use a bitmap, the brush must have a pattern set (see UseBrushPattern()) and the brush style must be set to TBrushStyle::EPatternedBrush.

Notes:

Parameters

const TPoint& aOrigin

The origin point for the brush.

See also:


SetBrushStyle()

virtual void SetBrushStyle(TBrushStyle aBrushStyle);

Description

Sets the line drawing style for the brush.

The GDI provides ten brush styles, including six built-in hatching patterns (see CGraphicsContext::TBrushStyle enum).

Notes

Parameters

TBrushStyle aBrushStyle

The brush style.

See also:


SetCharJustification()

virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars);

Description

Sets the character justification. This function is used primarily to get accurate WYSIWYG, and is not intended for regular use by developers.

The text line that is to be justified has a certain number of characters (this includes the spaces between the words). It also has a distance (in pixels) between the end of the last word and the actual end of the line (right hand margin, usually). These excess width pixels are distributed amongst all the characters, increasing the gaps between them, to achieve full justification of the text line.

This function is particularly useful for WYSIWYG underlining or strikethrough, as it ensures that the lines extend into the gaps between characters.

See the linked function for more information.

Parameters

TInt aExcessWidth

The excess width (in pixels) to be distributed between the specified number of characters.

TInt aNumChars

The number of characters involved

See also:


SetDitherOrigin()

virtual void SetDitherOrigin(const TPoint& aPoint);

Description

Sets the origin used for colour dithering.

Parameters

const TPoint& aPoint

New dither origin.


SetDrawMode()

virtual void SetDrawMode(TDrawMode aDrawingMode);

Description

Sets the drawing mode.

This affects the colour that is actually drawn, because it defines the way that the current screen colour logically combines with the current pen colour and brush colour.

There are 13 drawing modes (see CGraphicsContext::TDrawMode enum), each giving different logical combinations of pen, brush and screen colours. Each mode is produced by ORing together different combinations of seven drawing mode components (see CGraphicsContext::TDrawModeComponents enum).

The three most important modes are TDrawMode::EDrawModePEN, TDrawMode::EDrawModeNOTSCREEN and TDrawMode::EDrawModeXOR. The default drawing mode is TDrawMode::EDrawModePEN.

The drawing mode is over-ridden for line and shape drawing functions when a wide pen line has been selected. It is forced to TDrawMode::EDrawModePEN. This is to prevent undesired effects at line joins (vertexes).

Notes:

TDrawMode::EDrawModeAND gives a "colour filter" effect. For example:

TDrawMode::EDrawModeOR gives a "colour boost" effect. For example:

TDrawMode::EDrawModeXOR gives an "Exclusive OR" effect. For example:

Parameters

TDrawMode aDrawingMode

A drawing mode.

See also:


SetFaded()

void SetFaded(TBool aFaded);

Description

Sets whether the graphics context is faded.

Fading is used to change the colour of a window to make other windows stand out. For example, you would fade all other windows when displaying a dialogue.

Parameters

TBool aFaded

ETrue to fade the GC, EFalse to unfade it.


SetFadingParameters()

void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);

Support

Supported from 6.0

Description

Set fading parameters.

This function allows you to override the map used when drawing with a faded GC. However if you draw to a faded window with a faded GC, then fading on the GC is ignored and it will use the fading of the window.

Fading is used to change the colour of a window to make other windows stand out. For example, you would fade all other windows when displaying a dialogue. Fading can either make a faded window closer to white or closer to black. The fading map allows you to over-ride the default fading parameters set in RWsSession::SetDefaultFadingParameters().

Fading re-maps colours in the faded gc to fall between the specified black and white map values. If aBlackMap=0 and aWhiteMap=255 then the colours are mapped unchanged. As the values converge the colours are mapped to a smaller range — so the differences between colours in the faded gc decrease. If the values are reversed then the colours are inverted (i.e. where the gc would be black, it is now white).

Parameters

TUint8 aBlackMap

Black map fading parameter. Unfaded this is 0.

TUint8 aWhiteMap

White map fading parameter. Unfaded this is 255.

See also:


SetOrigin()

virtual void SetOrigin(const TPoint &aPos=TPoint(0,0));

Description

Sets the position of the co-ordinate origin.

All subsequent drawing operations are then done relative to this origin. The default origin is (0,0), the top left corner of the window.

Parameters

const TPoint &aPos=TPoint(0,0)

A point for the origin, default (0,0).

See also:


SetPenColor()

virtual void SetPenColor(const TRgb &aColor);

Description

Sets the pen colour. The effective pen colour depends on the drawing mode (see SetDrawMode()).

The default pen colour is black.

Parameters

const TRgb &aColor

An RGB colour for the pen.

See also:


SetPenSize()

virtual void SetPenSize(const TSize& aSize);

Description

Sets the line drawing size for the pen.

Lines of size greater than one pixel are drawn with rounded ends that extend beyond the end points, (as if the line is drawn using a circular pen tip of the specified size). Rounded ends of lines drawn with a wide pen are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode has been set using SetDrawMode().

See the linked topic below for more information.

Parameters

const TSize& aSize

A line size, the default being 1 pixel.

See also:


SetPenStyle()

virtual void SetPenStyle(TPenStyle aPenStyle);

Description

Sets the line drawing style for the pen.

The pen is used when drawing lines and for the outline of filled shapes. There are 6 pen styles (see CGraphicsContext::TPenStyle enum). If no pen style is set the default is TPenStyle::ESolidPen.

To use a pen style its full context must be given, e.g. for a null pen: CGraphicsContext::TPenStyle::ENullPen.

For more information see the linked topic below.

Parameters

TPenStyle aPenStyle

A pen style.

See also:


SetStrikethroughStyle()

virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);

Description

Sets the strikethrough style for all subsequently drawn text.

Parameters

TFontStrikethrough aStrikethroughStyle

The strikethrough style — either on or off.

See also:


SetUnderlineStyle()

virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle);

Description

Sets the underline style for all subsequently drawn text.

Parameters

TFontUnderline aUnderlineStyle

The underline style — either on or off.

See also:


SetWordJustification()

virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);

Description

Sets word justification. This function is not intended for regular use by developers.

This function is particularly useful for doing WYSIWYG underlining or strikethrough, as it ensures that the lines extend correctly into the gaps between words.

See the linked topic below for more information.

Parameters

TInt aExcessWidth

The excess width (in pixels) to be distributed between the specified number of gaps (starting immediately)

TInt aNumGaps

The number of gaps between words

See also:


UseBrushPattern()

virtual void UseBrushPattern(const CFbsBitmap *aBitmap);

Description

Sets the brush pattern to the specified bitmap.

For the brush to actually use the bitmap, TBrushStyle::EPatternedBrush must be used to set the brush style (see SetBrushStyle()). When the brush pattern is no longer required, use DiscardBrushPattern() to free up the memory used, (if the bitmap is not being shared). If UseBrushPattern() is used again without using DiscardBrushPattern() then the previous pattern is discarded automatically.

Notes:

Parameters

const CFbsBitmap *aBitmap

A bitmap pattern for the brush

See also: