|
||
class CGraphicsContext : public CBase;
Abstract base class for all graphics contexts.
Created by a CGraphicsDevice
.
Provides the 'context' in which you are drawing to an associated device, in the sense that it holds the settings for drawing, such as the pen and brush settings (e.g. color, line styles) and the font settings (e.g. bold, underline, italic). These settings are device-independent.
Also provides the clipping region (the visible drawing area).
The settings and clipping area can be updated while drawing.
This class also contains the main drawing functions, and all drawing is done through a CGraphicsContext.
The graphics context deals with pixels of device-dependent size and uses fonts with device-dependent size and representation.
The sizes and fonts to be passed to the class functions therefore need to be converted from size-independent units to size-dependent
units first. This is done by an MGraphicsDeviceMap
derived class. This may be a TZoomFactor
or the CGraphicsDevice
.
See CGraphicsContext::Reset()
for the default graphics context settings immediately after construction.
CBase
-
Base class for all classes to be instantiated on the heap.
CGraphicsContext
- Abstract base class for all graphics contexts.
Defined in CGraphicsContext
:
CancelClippingRect()
Cancels any clipping rectangle.CancelClippingRegion()
Cancels the current clipping region. Device()const
Gets a pointer to the graphics context's graphics device.DiscardBrushPattern()
Discards a non-built-in brush pattern.DiscardFont()
Discards a font.DrawArc(const TRect &,const TPoint &,const TPoint &)
Draws an arc.DrawBitmap(const TPoint &,const CFbsBitmap *)
Draws a bitmap at the specified point.DrawBitmap(const TRect &,const CFbsBitmap *)
Draws a bitmap to fit a given rectangle.DrawBitmap(const TRect &,const CFbsBitmap *,const TRect &)
Draws a specified rectangle of a source bitmap to fit into a given destination r...DrawBitmapMasked(const TRect &,const CFbsBitmap *,const TRect &,const CFbsBitmap *,TBool)
Draws a specified rectangle of a source bitmap to fit into a given rectangle usi...DrawBitmapMasked(const TRect &,const CWsBitmap *,const TRect &,const CWsBitmap *,TBool)
Draws a specified rectangle from a wserv bitmap and its mask into another rectan...DrawEllipse(const TRect &)
Draws and fills an ellipse.DrawLine(const TPoint &,const TPoint &)
Draws a straight line between two points.DrawLineBy(const TPoint &)
Draws a straight line relative to the current drawing point, using a vector.DrawLineTo(const TPoint &)
Draws a straight line from the current drawing point to a specified point.DrawPie(const TRect &,const TPoint &,const TPoint &)
Draws and fills a pie slice.DrawPolyLine(const CArrayFix< TPoint > *)
Draws a polyline from a set of points in an array.DrawPolyLine(const TPoint *,TInt)
Draws a polyline from a set of points in a list.DrawPolygon(const CArrayFix< TPoint > *,TFillRule)
Draws and fills a polygon defined using an array of points.DrawPolygon(const TPoint *,TInt,TFillRule)
Draws and fills a polygon defined using a list of points.DrawRect(const TRect &)
Draws and fills a rectangle.DrawRoundRect(const TRect &,const TSize &)
Draws and fills a rectangle with rounded corners.DrawText(const TDesC &,const TPoint &)
Draws text without a surrounding box.DrawText(const TDesC &,const TPoint &,const TDrawTextParam &)
Draws the specified text at the given position using the parameters supplied.DrawText(const TDesC &,const TRect &,TInt,TTextAlign,TInt)
Draws text inside a box.DrawTextExtended(const TDesC &,const TPoint &,const TDrawTextExtendedParam &)
Draws text, optionally changing its direction (right-to-left / left-to-right).DrawTextVertical(const TDesC &,const TPoint &,TBool)
Draws vertical text in the specified direction. DrawTextVertical(const TDesC &,const TRect &,TInt,TBool,TTextAlign,TInt)
Draws text vertically in the specified direction, within a box of the specified ...EAlternate
Only fill areas with odd winding numbers. EAnd
8 ECenter
Text is centred. EDashedPen
A dashed line. Screen pattern unit = 111000... EDiamondCrossHatchBrush
The brush fills with forward diagonal and rearward diagonal hatching lines going...EDotDashPen
A line of alternating dashes and dots. Screen pattern unit = 1111001100... EDotDotDashPen
A line of alternating single dashes and pairs of dots. Screen pattern unit = 111...EDottedPen
A dotted line. Screen pattern unit = 1000... EDrawModeAND
Bitwise ANDs the pen and brush colours with the screen colour. P=p&s, B=b&am...EDrawModeANDNOT
Inverts the screen colour before ANDing. P=p&(~s), B=b&(~s) EDrawModeNOTAND
Inverts the pen and brush colours before ANDing. P=(~p)&s, B=(~b)&s EDrawModeNOTANDNOT
Inverts the screen and pen and brush colours before ANDing. P=(~p)&(~s), B=(...EDrawModeNOTOR
Inverts the pen and brush colours before ORing. P=(~p)|s, B=(~b)|s EDrawModeNOTORNOT
NOT OR NOT mode. P=(~p)|(~s), B=(~b)|(~s) EDrawModeNOTPEN
Inverts the pen and brush colours. P=~p, B=~b EDrawModeNOTSCREEN
Inverts the colour of each pixel that is drawn over, (pen and brush attributes a...EDrawModeNOTXOR
Inverts the pen and brush colours before XORing. P=(~p)^s, B=(~b)^s EDrawModeOR
Bitwise ORs the pen and brush colours with the screen colour. P=p|s, B=b|s EDrawModeORNOT
Inverts the screen, pen and brush colours before ORing. P=p|(~s), B=b|(~s) EDrawModePEN
Uses both pen and brush colour as they are. P=p, B=b EDrawModeWriteAlpha
Writes alpha information in the source directly into the destination, rather tha...EDrawModeXOR
Bitwise XORs the pen and brush colours with the screen colour. P=p^s, B=b^s EForwardDiagonalHatchBrush
The brush fills with diagonal hatching lines going from bottom left to top right...EHorizontalHatchBrush
The brush fills with horizontal hatching lines going from left to right. EInvertPen
16 EInvertScreen
1 ELeft
Text is left-aligned. ELogicalOp
14 ENullBrush
The brush fill has no effect (default). ENullPen
The pen does not draw. Screen pattern unit = 00... EOr
4 EPatternedBrush
The brush fills with a selected bitmap pattern, set by CGraphicsContext::UseBrus...EPenmode
32 ERearwardDiagonalHatchBrush
The brush fills with rearward diagonal hatching lines going from top left to bot...ERight
Text is right-aligned. ESolidBrush
The brush fills with a solid single colour, determined by CGraphicsContext::SetB...ESolidPen
A solid line (default). Screen pattern unit = 11... ESquareCrossHatchBrush
The brush fills with horizontal and vertical hatching lines going from left to r...EVerticalHatchBrush
The brush fills with vertical hatching lines going from top to bottom. EWinding
Fill areas with winding numbers greater than zero. EWriteAlpha
64 EXor
2 GetShadowColor(TRgb &)
Get the font's shadow colour GetUnderlineMetrics(TInt &,TInt &)
JustificationInPixels(TInt &,TInt &)
Gets the amount of space in pixels by which to adjust the current letter or word...JustificationInPixels(TInt,TInt,TInt,TInt)
Gets the amount of space in pixels by which to adjust letter or word spacing, gi...MapColors(const TRect &,const TRgb *,TInt,TBool)
Maps pixels in the specified rectangle. The function tries to match the colour o...MoveBy(const TPoint &)
Sets the drawing point relative to the current co-ordinates.MoveTo(const TPoint &)
Sets the drawing point relative to the co-ordinate origin.Plot(const TPoint &)
Draws a single point. The point is drawn with the current pen settings using the...Reserved()
Reserved function for future use. Reserved_CGraphicsContext_2()
A reserved virtual function for future use.Reset()
Resets the graphics context to its default settings:SetBrushColor(const TRgb &)
Sets the brush colour.SetBrushOrigin(const TPoint &)
Sets the brush pattern origin.SetBrushStyle(TBrushStyle)
Sets the brush style.SetCharJustification(TInt,TInt)
Sets character justification.SetClippingRect(const TRect &)
Sets the clipping rectangle.SetClippingRegion(const TRegion &)
Sets the clipping region. SetDrawMode(TDrawMode)
Sets the drawing mode.SetOrigin(const TPoint &)
Sets the position of the co-ordinate origin.SetPenColor(const TRgb &)
Sets the pen colour.SetPenSize(const TSize &)
Sets the line drawing size for the pen.SetPenStyle(TPenStyle)
Sets the line drawing style for the pen.SetShadowColor(const TRgb &)
Set the font's shadow colour SetStrikethroughStyle(TFontStrikethrough)
Sets the strikethrough style.SetUnderlineStyle(TFontUnderline)
Sets the underline style.SetWordJustification(TInt,TInt)
Adjusts the spaces between words to stretch or squeeze to a certain width.TBrushStyle
Brush styles. TDrawMode
Drawing modes.TDrawModeComponents
Drawing mode components. This enum is not intended to be used directly, but prov...TDrawTextExtendedParam
Parameters for extended text drawing and measuring. It is used by CGraphicsConte...TDrawTextParam
Parameters to control the drawing of text. TFillRule
Rules used to fill self crossing polygons.TPenStyle
Pen styles. The screen pattern unit in each definition below describes the patte...TTextAlign
Text alignment. UseBrushPattern(const CFbsBitmap *)
Sets the brush pattern to the specified bitmap.UseFont(const CFont *)
Sets the device font to be used for text drawing.Inherited from CBase
:
Delete(CBase *)
Deletes the specified object.Extension_(TUint,TAny *&,TAny *)
Extension function operator new(TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TAny *)
Initialises the object to binary zeroes.operator new(TUint,TLeave)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TLeave,TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TUint)
Allocates the object from the heap and then initialises its contents to binary z...CBitmapContext
An abstract, device-independent, interface to bitmapped graphics contexts.virtual CGraphicsDevice* Device() const=0;
Gets a pointer to the graphics context's graphics device.
|
virtual void SetOrigin(const TPoint &aPos=TPoint(0, 0))=0;
Sets the position of the co-ordinate origin.
All subsequent drawing operations are done relative to this origin.
|
virtual void SetDrawMode(TDrawMode aDrawingMode)=0;
Sets the drawing mode.
The way that the pen and brush draw depends on the drawing mode. The drawing mode 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 many drawing modes, 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.
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:
ANDing with white gives the original colour
ANDing with black gives black
TDrawMode::EDrawModeOR gives a "colour boost" effect. For example:
ORing with black gives the original colour
ORing with white gives white
TDrawMode::EDrawModeXOR gives an "Exclusive OR" effect. For example:
white XOR black gives white
white XOR white gives black
black XOR black gives black
TDrawMode::EDrawModeWriteAlpha should not normally need to be used by client code. The following are exceptions:-
When a client side EColor16MA bitmap needs to have a transparent background (because you are intending to blend it onto something else), then you need to set EDrawModeWriteAlpha to Clear() it.
When you want to BitBlt() with an EColor16MA source bitmap that is opaque everywhere, then using EDrawModeWriteAlpha is more efficient than EDrawModePEN, because the bitmap does not need to be blended.
Note that if you have a transparent brush or source bitmap and you are drawing to a window, then it is a defect to use EDrawModeWriteAlpha.
|
CGraphicsContext::TDrawMode
Drawing modes.CGraphicsContext::TDrawModeComponents
Drawing mode components. This enum is not intended to be used directly, but prov...virtual void SetClippingRect(const TRect &aRect)=0;
Sets the clipping rectangle.
The area of visible drawing depends on the clipping region. The default clipping rectangle is the full device area.
|
virtual void CancelClippingRect()=0;
Cancels any clipping rectangle.
Clipping thus reverts to the full device area, the default.
CGraphicsContext::SetClippingRect(const TRect &)
Sets the clipping rectangle.virtual void Reset()=0;
Resets the graphics context to its default settings:
the drawing mode is TDrawMode::EDrawModePen (pen and brush colours used as they are)
there is no clipping rectangle
the pen settings are: black, solid, single pixel size
the brush style is null
no text font is selected
virtual void UseFont(const CFont *aFont)=0;
Sets the device font to be used for text drawing.
If the font is already in memory, then that copy is shared.
Notes:
The CFont* argument must have been previously initialised by calling MGraphicsDeviceMap::GetNearestFontInTwips(CFont *&,const TFontSpec &)
with the required font-specification. If the CFont* has not been initialised correctly, and therefore does not point to an
available font-bitmap, then a panic is raised.
When the font is no longer required, use CGraphicsContext::DiscardFont()
to free up the memory used. If CGraphicsContext::UseFont(const CFont *)
is used again without using CGraphicsContext::DiscardFont()
then the previous font is discarded automatically.
If no font has been selected, and an attempt is made to draw text with CGraphicsContext::DrawText(const TDesC &,const TPoint &)
, then a panic is raised.
|
MGraphicsDeviceMap::GetNearestFontInTwips(CFont *&,const TFontSpec &)
Gets the font which is the nearest to the given font specification.virtual void DiscardFont()=0;
Discards a font.
This frees up the memory used, if the font is not being shared.
The function can be called when no font is in use.
virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle)=0;
Sets the underline style.
This is applied to all subsequently drawn text.
|
virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)=0;
Sets the strikethrough style.
This is applied to all subsequently drawn text.
|
IMPORT_C static TInt JustificationInPixels(TInt aExcessPixels, TInt aTotalUnits, TInt aFirstUnit, TInt aNumUnits);
Gets the amount of space in pixels by which to adjust letter or word spacing, given the total number of words and spaces, a start space, and the number of units to be adjusted.
The first two arguments are the number of pixels (character groups) and the number of units (word spaces) over which justification is to occur. The third argument specifies the current character group or word space, while the final argument specifies the number of units that are to be adjusted.
A panic occurs if aExcessPixels is 0, aTotalUnits is not greater than 0, or aFirstUnit is not less than aTotalUnits.
|
|
CGraphicsContext::SetWordJustification(TInt,TInt)
Adjusts the spaces between words to stretch or squeeze to a certain width.CGraphicsContext::SetCharJustification(TInt,TInt)
Sets character justification.IMPORT_C static TInt JustificationInPixels(TInt &aExcessPixels, TInt &aTotalUnits);
Gets the amount of space in pixels by which to adjust the current letter or word spacing, and also retrieves the number of excess pixels and word spaces remaining after the adjustment is performed.
The arguments are the number of remaining pixels (character groups) and units (word spaces) over which justification is to occur. The function can be called repetitively until the number of units is zero, and hence justification is complete. A panic occurs if the number of units is less than one or the amount of pixels is zero.
|
|
CGraphicsContext::SetWordJustification(TInt,TInt)
Adjusts the spaces between words to stretch or squeeze to a certain width.CGraphicsContext::SetCharJustification(TInt,TInt)
Sets character justification.virtual void SetWordJustification(TInt aExcessWidth, TInt aNumGaps)=0;
Adjusts the spaces between words to stretch or squeeze to a certain width.
The function is required by the Text Views API, and is not intended for regular use by developers.
The text line that is to be justified has a certain number of gaps (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 the gaps between the words to achieve full justification of the text line. Spaces become fat spaces to keep underlining/strikethrough consistent. Pixels are distributed to the inter-word gaps starting from the left end of the string. The spacing between characters in each word remains unchanged.
After a call to CGraphicsContext::SetWordJustification(TInt,TInt)
, subsequent calls to either of the two CGraphicsContext::DrawText(const TDesC &,const TPoint &)
functions are affected until the number of spaces specified by aNumSpaces is used up.
The easiest way to find out the excess width and number of spaces is to call CFont::MeasureText(const TDesC &,const TMeasureTextInput *,TMeasureTextOutput *)const
. This function can also perform counting, which is finding how much of some text will fit into a given width.
Use CFont::TextCount(const TDesC &,TInt)const
to return the excess width.
For example, in the string "To be, or not to be", there are five inter-word gaps. If there are six excess pixels they will be distributed in the proportion 2, 1, 1, 1, 1 between the words. If there are nine excess pixels they will be distributed in the proportion 2, 2, 2, 2, 1 between the words.
Notes:
If the excess width is zero, then calling CGraphicsContext::SetWordJustification(TInt,TInt)
has no effect.
At first sight it may appear that CGraphicsContext::SetWordJustification(TInt,TInt)
is not required because you can simply call CGraphicsContext::DrawText(const TDesC &,const TPoint &)
for each word. However, underlined justified text does not work using this strategy you get a non-underlined gap between
the space and the beginning of the next word.
|
virtual void SetCharJustification(TInt aExcessWidth, TInt aNumChars)=0;
Sets character justification.
This function is required by the Text Views API, and is not intended for regular use by developers.
It affects the strings of text used in the calls to CGraphicsContext::DrawText(const TDesC &,const TPoint &)
that follow, until the number of characters drawn equals aNumChars.
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.
Use CFont::TextCount(const TDesC &,TInt)const
to return the excess width.
Notes:
This function is provided to allow simulation of printer fonts on screen. Due to the fact that fully-scalable fonts are not used before v5, large printer fonts can be simulated by using the nearest smaller font and widening it slightly.
If the excess width is zero, then calling CGraphicsContext::SetCharJustification(TInt,TInt)
has no effect.
CGraphicsContext::SetCharJustification(TInt,TInt)
is required for WYSIWYG where the layout uses printer font metrics but screen fonts have to be drawn on the screen. Because
continuously scalable typefaces (c.f. TrueType) are not used before v5 and because screen fonts are coarser and less numerous
in their variety than the printer fonts, the best matching smaller screen font must be used with character justification to
simulate the printer font on the screen.
There is also a situation where the gaps between characters on screen have to be reduced with character clipping. The screen font that best matches the printer font may have the required height, but has characters that are too wide. A line of text that works on the printer will then be too long on the screen, unless it is squashed horizontally. The number of pixels that overlap the end of the screen line must now be removed from the gaps between the characters, i.e. there is a negative excess width. This situation is especially important where adding a TAB on screen gives perfectly acceptable printout, but would push the last character of the line off the right hand side of the screen.
In practice what you do in printer layout mode is:
Calculate where the line breaks will come on the printer. To do this you use a printer font (which in practice means a table of character widths of the font that the printer will use).
Now change to use a screen font that is the closest font which is no taller that the printer font. In practice it will often be fatter maybe only for certain characters such as 'i'.
You have to recalculate the width of the characters using the screen fonts. You can do this using CFont::TextWidth() as you have already determined how many characters will fit on the line.
If, in the screen font, the characters are not as wide as the line then you can just use word justification to expand the line. You would only do this if the text is to be justified.
If, however, the characters are wider than the line then you would use character justification to clip each character. You would need to do this even if the line is not justified.
Thus, in practice, character justification will only very rarely be used to expand a line of characters.
|
virtual void SetPenColor(const TRgb &aColor)=0;
Sets the pen colour.
The effective pen colour depends on the drawing mode. The default pen colour is black.
Note:
The pen is used to draw lines, the outlines of filled shapes, and text. The class provides member functions to set the colour of the pen, the style of line and the line size drawn.
|
CGraphicsContext::SetDrawMode(TDrawMode)
Sets the drawing mode.virtual void SetPenStyle(TPenStyle aPenStyle)=0;
Sets the line drawing style for the pen.
There are 6 pen styles. If no pen style is set, then 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 Notes:
The pen is used to draw lines, the outlines of filled shapes, and text. CGraphicsContext member functions are provided to set the colour of the pen, the style of line and the line size drawn.
The TPenStyle::ENullPen style should be used if a border is not required around a filled shape.
Dotted and dashed pen styles have a device dependant implementation, always give single-pixel size lines on the screen whatever
the pen size set by CGraphicsContext::SetPenSize(const TSize &)
and can only be used for straight lines, polylines, non-rounded rectangles and polygons.
The dotted/dashed pattern is continued, without re-starting, for all consecutively drawn straight lines, i.e.
the outlines of rectangles the pattern starts in the top left corner. It is reset at the end of the function call.
the outlines of polygons the pattern starts at the first point. It is reset at the end of the function call.
polylines and straight lines the pattern starts at the first point initially. Consecutive calls to CGraphicsContext::DrawLine(const TPoint &,const TPoint &)
and/or CGraphicsContext::DrawPolyLine(const CArrayFix< TPoint > *)
, whether the lines are concatenated or not, continue the pattern. It can be reset by a further call to CGraphicsContext::SetPenStyle(TPenStyle)
using the same dotted/dashed style parameter.
|
CGraphicsContext::TPenStyle
Pen styles. The screen pattern unit in each definition below describes the patte...virtual void SetPenSize(const TSize &aSize)=0;
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).
are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode has been set using CGraphicsContext::SetDrawMode(TDrawMode)
.
Notes:
The pen is used to draw lines, the outlines of filled shapes, and text. The class provides member functions to set the colour of the pen, the style of line and the line size drawn.
Wide straight lines and arcs have rounded ends so that concatenated wide lines have smoothly rounded corners at the vertexes.
When lines are made wide, the extra strips of pixels are added equally to both sides of the line. This works precisely for lines of odd pixel size (3, 5, 7, etc.). Wide lines of even pixel size, (2, 4, 6, etc.), have the extra strip of pixels added to the right and/or below the line.
Wide outlines of ellipses and wide line arcs are drawn with the pixels distributed either side of a thin (single pixel wide) true ellipse constructed in the normal manner. Wide ellipses and arcs of even pixel size have the extra strip of pixels added to the right and/or below the curved line. This gives a slight asymmetry to ellipses.
If the pen style is dotted or dashed, the size specification is ignored: a single-pixel wide primitive is drawn, (this is device dependant).
A line size of zero is handled as if the pen style had been set to TPenStyle::ENullPen.
|
virtual void SetBrushColor(const TRgb &aColor)=0;
Sets the brush colour.
The effective brush colour depends on the drawing mode.
Notes:
The brush is used for filling shapes and the background of text boxes. The brush has colour, style, pattern and pattern origin parameters.
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.
|
CGraphicsContext::SetDrawMode(TDrawMode)
Sets the drawing mode.virtual void SetBrushStyle(TBrushStyle aBrushStyle)=0;
Sets the brush style.
Ten brush styles are provided, including six built-in hatching patterns. Note: The brush is used for filling shapes and the
background of text boxes. The brush has colour, style, pattern and pattern origin parameters. Note: Use TBrushStyle::ENullBrush
to draw the outline of a fillable shape on its own, without filling. Note: If the TBrushStyle::EPatternedBrush style is set,
but no bitmap pattern has been selected using CGraphicsContext::UseBrushPattern(const CFbsBitmap *)
, then the function panics. Note: Hatching lines are done in the current pen colour, set using CGraphicsContext::SetPenColor(const TRgb &)
. The hatching pattern starts at the brush origin, set using CGraphicsContext::SetBrushOrigin(const TPoint &)
.
|
CGraphicsContext::UseBrushPattern(const CFbsBitmap *)
Sets the brush pattern to the specified bitmap.CGraphicsContext::SetPenColor(const TRgb &)
Sets the pen colour.CGraphicsContext::SetBrushOrigin(const TPoint &)
Sets the brush pattern origin.virtual void SetBrushOrigin(const TPoint &aOrigin)=0;
Sets the brush pattern origin.
This specifies the top left-hand corner position for the pattern tile around which copies of the pattern are tiled.
The brush pattern may be a built-in style, or a bitmap. To use a bitmap, the brush must have a pattern set and the brush style must be set to TBrushStyle::EPatternedBrush.
Notes
The brush is used for filling shapes and the background of text boxes. The brush has colour, style, pattern and pattern origin parameters.
If CGraphicsContext::SetBrushOrigin(const TPoint &)
is not used, then the origin defaults to (0,0).
This brush origin remains in effect for all fillable shapes drawn subsequently, until a new brush origin is set. Shapes can thus be considered as windows onto a continuous pattern field (covering the whole clipping region of a screen device, or the whole device area of a printer).
|
CGraphicsContext::SetBrushStyle(TBrushStyle)
Sets the brush style.CGraphicsContext::UseBrushPattern(const CFbsBitmap *)
Sets the brush pattern to the specified bitmap.virtual void UseBrushPattern(const CFbsBitmap *aBitmap)=0;
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.
When the brush pattern is no longer required, use CGraphicsContext::DiscardBrushPattern()
to free up the memory used, if the bitmap is not being shared. If CGraphicsContext::UseBrushPattern(const CFbsBitmap *)
is used again without using CGraphicsContext::DiscardBrushPattern()
then the previous pattern is discarded automatically.
Notes:
The brush is used for filling shapes and the background of text boxes. The brush has colour, style, pattern and pattern origin parameters.
When loading a bitmap, the bitmap is checked to see if it is already in memory. If the bitmap is already there, then that copy is shared.
The brush does not need to have a pattern set at all. There are several built-in hatching patterns which can be selected using
CGraphicsContext::SetBrushStyle(TBrushStyle)
.
|
CGraphicsContext::SetBrushStyle(TBrushStyle)
Sets the brush style.virtual void DiscardBrushPattern()=0;
Discards a non-built-in brush pattern.
This frees up the memory used by the bitmap, if it is not being shared by another process.
Notes:
The brush is used for filling shapes and the background of text boxes. The brush has colour, style, pattern and pattern origin parameters.
If CGraphicsContext::DiscardBrushPattern()
is used, with no brush pattern set, then there is no effect.
virtual void MoveTo(const TPoint &aPoint)=0;
Sets the drawing point relative to the co-ordinate origin.
A subsequent call to CGraphicsContext::DrawLineTo(const TPoint &)
or CGraphicsContext::DrawLineBy(const TPoint &)
uses the new drawing point as the start point for the line drawn.
Notes
The operations CGraphicsContext::DrawLine(const TPoint &,const TPoint &)
, CGraphicsContext::DrawLineTo(const TPoint &)
, CGraphicsContext::DrawLineBy(const TPoint &)
and DrawPolyline() also change the internal drawing position to the last point of the drawn line(s).
The internal drawing position is set to the co-ordinate origin if no drawing or moving operations have yet taken place.
|
virtual void MoveBy(const TPoint &aVector)=0;
Sets the drawing point relative to the current co-ordinates.
A subsequent call to CGraphicsContext::DrawLineTo(const TPoint &)
or CGraphicsContext::DrawLineBy(const TPoint &)
uses the new drawing point as the start point for the line drawn.
Notes
The operations CGraphicsContext::DrawLine(const TPoint &,const TPoint &)
, CGraphicsContext::DrawLineTo(const TPoint &)
, CGraphicsContext::DrawLineBy(const TPoint &)
and DrawPolyline() also change the internal drawing position to the last point of the drawn line(s).
The internal drawing position is set to the co-ordinate origin if no drawing or moving operations have yet taken place.
|
virtual void Plot(const TPoint &aPoint)=0;
Draws a single point. The point is drawn with the current pen settings using the current drawing mode.
Note:
If the pen size is greater than one pixel, a filled circle of the current pen colour is drawn, with the pen size as the diameter and the plotted point as the centre. If the pen size is an even number of pixels, the extra pixels are drawn below and to the right of the centre.
|
CGraphicsContext::SetPenSize(const TSize &)
Sets the line drawing size for the pen.virtual void DrawArc(const TRect &aRect, const TPoint &aStart, const TPoint &aEnd)=0;
Draws an arc.
The arc is considered a portion of an ellipse. The ellipse is defined by the TRect
argument.
The pixels at both the start point and the end point are drawn.
The arc itself is the segment of the ellipse drawn in an anti-clockwise direction from the start point to the end point.
Notes:
A rectangle is used in the construction of the ellipse of which the arc is a segment. This rectangle is passed as an argument
of type TRect
.
A wide line arc is drawn with the pixels distributed either side of a true ellipse, in such a way that the outer edge of the line would touch the edge of the construction rectangle. In other words, the ellipse used to construct it is slightly smaller than that for a single pixel line size.
If the specified start or end point is at the centre of the ellipse, then the line that defines the start or end of the arc defaults to one extending vertically above the centre point.
If the start and end point are the same point or are points on the same line through the ellipse centre then a complete unfilled ellipse is drawn.
|
CGraphicsContext::DrawEllipse(const TRect &)
Draws and fills an ellipse.virtual void DrawLine(const TPoint &aPoint1, const TPoint &aPoint2)=0;
Draws a straight line between two points.
|
virtual void DrawLineTo(const TPoint &aPoint)=0;
Draws a straight line from the current drawing point to a specified point.
|
CGraphicsContext::MoveTo(const TPoint &)
Sets the drawing point relative to the co-ordinate origin.CGraphicsContext::MoveBy(const TPoint &)
Sets the drawing point relative to the current co-ordinates.virtual void DrawLineBy(const TPoint &aVector)=0;
Draws a straight line relative to the current drawing point, using a vector.
The start point of the line is the current drawing point. The specified vector is added to the drawing point to give the end point of the line
|
CGraphicsContext::MoveTo(const TPoint &)
Sets the drawing point relative to the co-ordinate origin.CGraphicsContext::MoveBy(const TPoint &)
Sets the drawing point relative to the current co-ordinates.virtual void DrawPolyLine(const CArrayFix< TPoint > *aPointList)=0;
Draws a polyline from a set of points in an array.
A polyline is a series of concatenated straight lines joining a set of points.
|
virtual void DrawPolyLine(const TPoint *aPointList, TInt aNumPoints)=0;
Draws a polyline from a set of points in a list.
A polyline is a series of concatenated straight lines joining a set of points.
|
virtual void DrawPie(const TRect &aRect, const TPoint &aStart, const TPoint &aEnd)=0;
Draws and fills a pie slice.
The pie slice is an area bounded by:
the arc of an ellipse drawn in an anticlockwise direction from the start point to the end point
the straight line drawn to the start point from the geometric centre of the ellipse.
the straight line to the end point from the geometric centre of the ellipse.
Notes:
A rectangle is used in the construction of the pie slice. This rectangle is passed as an argument of type TRect
. The curved edge of the pie slice is an arc of an ellipse constructed within the rectangle.
The line drawn by the pen goes inside the specified rectangle.
The pixels at the end point of the arc are not drawn.
A wide line edged pie slice has the arc drawn with the pixels distributed either side of a true ellipse. This is done in such a way that the outer edge of the line touches the edge of the construction rectangle. In other words, the ellipse used to construct it is slightly smaller than that for a single pixel line size.
If the specified start or end point is at the centre of the ellipse, then the line that defines the start or end of the arc defaults to one extending vertically above the centre point.
If the start and end point are the same point or are points on the same line through the ellipse centre then a complete filled ellipse is drawn. A line is also drawn from the edge to the ellipse centre.
|
virtual void DrawEllipse(const TRect &aRect)=0;
Draws and fills an ellipse.
The ellipse is drawn inside the rectangle defined by the TRect
argument. Any rectangle that has odd pixel dimensions, has the bottom right corner trimmed to give even pixel dimensions
before the ellipse is constructed.
Note:
A wide outline ellipse is drawn with the pixels distributed either side of a true ellipse, in such a way that the outer edge of the line touches the edge of the construction rectangle. In other words, the ellipse used to construct it is smaller than that for a single pixel line size.
|
virtual void DrawRect(const TRect &aRect)=0;
Draws and fills a rectangle.
|
virtual void DrawRoundRect(const TRect &aRect, const TSize &aCornerSize)=0;
Draws and fills a rectangle with rounded corners.
The rounded corners are each constructed as an arc of an ellipse.
The line drawn by the pen, if any, goes inside the specified rectangle.
Notes:
Dotted and dashed pen styles cannot be used for the outline of a rounded rectangle.
If either corner size dimension is greater than half the corresponding rectangle length, the corner size dimension is reduced to half the rectangle size.
|
virtual TInt DrawPolygon(const CArrayFix< TPoint > *aPointList, TFillRule aFillRule=EAlternate)=0;
Draws and fills a polygon defined using an array of points.
The first point in the array defines the start of the first side of the polygon. The second point defines the second vertex (the end point of the first side and the start point of the second side).
The final side of the polygon is drawn using the last point from the array, and the line is drawn to the start point of the first side.
Self-crossing polygons are filled according to the specified fill rule.
|
|
virtual TInt DrawPolygon(const TPoint *aPointList, TInt aNumPoints, TFillRule aFillRule=EAlternate)=0;
Draws and fills a polygon defined using a list of points.
The first point in the list defines the start of the first side of the polygon. The second point defines the second vertex (the end point of the first side and the start point of the second side).
The final side of the polygon is drawn using the last point from the list, and the line is drawn to the start point of the first side.
Self-crossing polygons are filled according to the specified fill rule.
|
|
virtual void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource)=0;
Draws a bitmap at the specified point.
The point specifies the top left hand corner of the bitmap. The bitmap is compressed or stretched based on its internally stored size in twips.
Notes:
This member function uses the bitmap's size in twips and does a stretch/compress blit using a linear DDA.
As this function scales the bitmap, it is unavoidably slow. Therefore, where possible, use CBitmapContext::BitBlt(const TPoint &,const CFbsBitmap *)
instead. If the bitmap has to be scaled, consider creating another bitmap along with an CFbsBitmapDevice etc, doing CGraphicsContext::DrawBitmap(const TPoint &,const CFbsBitmap *)
once and using BitBlt() subsequently.
Note that all bitmaps are clipped to the device boundaries.
|
TLinearDDA
Linear digital differential analyser.virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource)=0;
Draws a bitmap to fit a given rectangle.
The bitmap is compressed or stretched based on its internally stored size in pixels.
Notes:
This member function uses the bitmap's size in pixels and does a stretch/compress blit using a linear DDA.
As this function scales the bitmap, it is unavoidably slow. Therefore, where possible, use CBitmapContext::BitBlt(const TPoint &,const CFbsBitmap *)
instead. If the bitmap has to be scaled, consider creating another bitmap along with an CFbsBitmapDevice etc., doing CGraphicsContext::DrawBitmap(const TPoint &,const CFbsBitmap *)
once and using BitBlt() subsequently.
Note that all bitmaps are clipped to the device boundaries.
|
TLinearDDA
Linear digital differential analyser.virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource, const TRect &aSourceRect)=0;
Draws a specified rectangle of a source bitmap to fit into a given destination rectangle.
Notes:
This member function uses rectangle sizes in pixels and does a stretch/compress blit using a linear DDA.
As this function scales the bitmap, it is unavoidably slow. Therefore, where possible, use CBitmapContext::BitBlt(const TPoint &,const CFbsBitmap *)
instead. If the bitmap has to be scaled, consider creating another bitmap along with an CFbsBitmapDevice etc., doing CGraphicsContext::DrawBitmap(const TPoint &,const CFbsBitmap *)
once and using BitBlt() subsequently.
Note that all bitmaps are clipped to the device boundaries.
|
TLinearDDA
Linear digital differential analyser.virtual void DrawBitmapMasked(const TRect &aDestRect, const CFbsBitmap *aBitmap, const TRect &aSourceRect, const CFbsBitmap
*aMaskBitmap, TBool aInvertMask)=0;
Draws a specified rectangle of a source bitmap to fit into a given rectangle using a given mask.
Notes:
This member function uses rectangle sizes in pixels and does a stretch/compress blit using a linear DDA.
|
virtual void DrawBitmapMasked(const TRect &aDestRect, const CWsBitmap *aBitmap, const TRect &aSourceRect, const CWsBitmap
*aMaskBitmap, TBool aInvertMask)=0;
Draws a specified rectangle from a wserv bitmap and its mask into another rectangle.
The function compresses/stretches the specified rectangle from the bitmap to fit the destination rectangle. 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=EFalse, black pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle. With aInvertMask=ETrue, white pixels in the mask bitmap stop corresponding pixels in the source bitmap from being transferred to the destination rectangle.
Note: this member function uses rectangle sizes in pixels and does a stretch/compress blit using a linear DDA.
|
virtual void DrawText(const TDesC &aText, const TPoint &aPosition)=0;
Draws text without a surrounding box.
The text baseline is aligned with the y co-ordinate of the specified point, and the left end of the text is aligned with the x co-ordinate of the specified point.
Note:
Text drawing is done with the pen, and is subject to the pen colour. The effective text colour also depends on the drawing mode. The size and style of the text depends on the font used. The layout of the text depends on the justification mode set.
|
virtual void DrawText(const TDesC &aText, const TRect &aBox, TInt aBaselineOffset, TTextAlign aAlignment=ELeft, TInt aLeftMargin=0)=0;
Draws text inside a box.
The surrounding box is filled with the current brush colour (not a pattern) and is drawn without any outline. The effective box colour depends on the drawing mode - if a brush colour has not been set then the brush defaults to white. The brush may be set to TBrushStyle::ENullBrush if text positioning relative to a box is required, but the box should not be filled.
The font used is that set by CGraphicsContext::UseFont(const CFont *)
. If no font is in use then a panic occurs.
The alignment of the text within the box can be specified.
Text drawn within a box is also clipped to that box. Unless you intend to clip the top off the text, aBaselineOffset should be greater than or equal to the ascent of the current font.
Offsets:
If the offset is negative, zero, or less than font height this is handled as would be expected, i.e. no text will be seen in the box in the first two instances, and the top of the text will be clipped in the latter case.
Margins:
For the drawing of right-aligned text, aLeftMargin indicates the margin from the right of aBox - where a positive value results in a leftwards offset.
Negative margins can be used to display portions of the text string clipped by the box. A negative margin for left aligned text would clip the start of the text string. Similarly, a negative margin for right aligned text would clip the end of the text string.
If the margin is greater than the width of the box then no text will be visible.
The margin is still honoured for centred text - centred text will not be centred in the box, unless the margin is zero.
Note:
Text drawing is done with the pen, and is thus subject to the pen colour. The effective text colour also depends on the drawing mode. The size and style of the text depends on the used font. The layout of the text depends on the justification mode set.
|
IMPORT_C virtual void DrawText(const TDesC &aText, const TPoint &aPosition, const TDrawTextParam &aParam);
Draws the specified text at the given position using the parameters supplied.
|
IMPORT_C TInt DrawTextExtended(const TDesC &aText, const TPoint &aPosition, const TDrawTextExtendedParam &aParam);
Draws text, optionally changing its direction (right-to-left / left-to-right).
Apart from reordering the text, the function is the same as the two parameter variant of CGraphicsContext::DrawText(const TDesC &,const TPoint &)
, described above.
|
|
virtual void MapColors(const TRect &aRect, const TRgb *aColors, TInt aNumPairs, TBool aMapForwards)=0;
Maps pixels in the specified rectangle. The function tries to match the colour of a pixel with one of the RGB values in an array of RGB pairs. If there is a match, the colour is changed to the value specified in the other RGB in the RGB pair.
|
virtual TInt SetClippingRegion(const TRegion &aRegion)=0;
Sets the clipping region.
|
|
CGraphicsContext::CancelClippingRegion()
Cancels the current clipping region. virtual void CancelClippingRegion()=0;
Cancels the current clipping region.
CGraphicsContext::SetClippingRegion(const TRegion &)
Sets the clipping region. virtual void DrawTextVertical(const TDesC &aText, const TPoint &aPos, TBool aUp)=0;
Draws vertical text in the specified direction.
|
virtual void DrawTextVertical(const TDesC &aText, const TRect &aBox, TInt aBaselineOffset, TBool aUp, TTextAlign aVert=ELeft,
TInt aMargin=0)=0;
Draws text vertically in the specified direction, within a box of the specified size.
|
IMPORT_C TInt GetUnderlineMetrics(TInt &aTop, TInt &aBottom);
|
|
IMPORT_C TInt SetShadowColor(const TRgb &aShadowColor);
Set the font's shadow colour
|
|
IMPORT_C TInt GetShadowColor(TRgb &aShadowColor);
Get the font's shadow colour
|
|
protected: IMPORT_C virtual void Reserved_CGraphicsContext_2();
A reserved virtual function for future use.
struct TDrawTextParam;
Parameters to control the drawing of text.
Defined in CGraphicsContext::TDrawTextParam
:
TDrawTextParam()
Reserved for future use. iCharJustExcess
amount of space to be used for letterspacing iCharJustNum
number of glyph groups to be letterspaced iDirection
the direction in which to draw the text. iWordJustExcess
amount of space to be used for wordspacing iWordJustNum
number of spaces to be used for wordspacing TDrawTextParam()
inline TDrawTextParam();
Reserved for future use.
iDirection
CFont::TTextDirection iDirection;
the direction in which to draw the text.
iCharJustNum
TInt iCharJustNum;
number of glyph groups to be letterspaced
iCharJustExcess
TInt iCharJustExcess;
amount of space to be used for letterspacing
iWordJustNum
TInt iWordJustNum;
number of spaces to be used for wordspacing
iWordJustExcess
TInt iWordJustExcess;
amount of space to be used for wordspacing
struct TDrawTextExtendedParam : public CGraphicsContext::TDrawTextParam;
Parameters for extended text drawing and measuring. It is used by CGraphicsContext::DrawTextExtended(const TDesC &,const TPoint &,const TDrawTextExtendedParam &)
to indicate whether text should be drawn from right-to-left or left-to-right.
CGraphicsContext::TDrawTextParam
- Parameters to control the drawing of text.
CGraphicsContext::TDrawTextExtendedParam
- Parameters for extended text drawing and measuring. It is used by CGraphicsConte...
Defined in CGraphicsContext::TDrawTextExtendedParam
:
TDrawTextExtendedParam()
Constructor. Initialises iParRightToLeft to EFalse. iParRightToLeft
ETrue if the text direction is right-to-left (for scripts like Arabic and Hebrew...Inherited from CGraphicsContext::TDrawTextParam
:
iCharJustExcess
amount of space to be used for letterspacing iCharJustNum
number of glyph groups to be letterspaced iDirection
the direction in which to draw the text. iWordJustExcess
amount of space to be used for wordspacing iWordJustNum
number of spaces to be used for wordspacing TDrawTextExtendedParam()
inline TDrawTextExtendedParam();
Constructor. Initialises iParRightToLeft to EFalse.
iParRightToLeft
TBool iParRightToLeft;
ETrue if the text direction is right-to-left (for scripts like Arabic and Hebrew). EFalse if left-to-right.
TTextAlign
Text alignment.
|
TDrawModeComponents
Drawing mode components. This enum is not intended to be used directly, but provides components for the easy specification of drawing modes in the TDrawMode enum.
|
TDrawMode
Drawing modes.
This enum builds on the drawing mode components in the TDrawModeComponents enum.
If the pen colour is p, brush colour is b and screen colour is s, the effect of TDrawMode::EDrawModeAND is P=p&s and B=b&s. In other words, the effective colour of the pen on the screen, P, is that produced by the bitwise ANDing of the current screen colour and the current pen colour. The effect is similar for the effective brush colour, B.
The effective pen and brush colour are given in the table using the key Inputs: pen colour is p, brush colour is b and screen colour is s Outputs: effective brush colour is B, effective pen colour is P.
Some notes on using EDrawModeWriteAlpha:-
It is rare for client code to need to use this draw mode: see the documentation of CGraphicsContext::SetDrawMode(TDrawMode)
for more information.
EDrawModeWriteAlpha should only be used with CGraphicsContext::DrawRect(const TRect &)
, Clear(), BitBlt(), and BitBltMasked() with EGray2 mask (and CGraphicsContext::DrawBitmap(const TPoint &,const CFbsBitmap *)
and CGraphicsContext::DrawBitmapMasked(const TRect &,const CFbsBitmap *,const TRect &,const CFbsBitmap *,TBool)
). For other draw operations, it is not supported, and may have unintended effects.
EDrawModeWriteAlpha has the same effect as EDrawModePEN, unless the brush colour has transparency (CGraphicsContext::DrawRect(const TRect &)
, Clear()), or the source bitmap is EColor16MA (and has transparency) (BitBlt(), BitBltMasked())
EDrawModeWriteAlpha has the same effect as EDrawModePEN if the draw mode of the destination does not support alpha blending. (Blending is only supported in 24bpp and 32bpp colour i.e. EColor16M, EColor16MU, EColor16MA)
In these cases, EDrawModePEN does alpha blending, whereas EDrawModeWriteAlpha means don't do alpha blending.
CGraphicsContext::SetDrawMode(TDrawMode)
Sets the drawing mode.
|
TPenStyle
Pen styles. The screen pattern unit in each definition below describes the pattern drawn by the line 1 represents a pixel drawn, 0 represents a pixel that is not affected.
|
TBrushStyle
Brush styles.
|
TFillRule
Rules used to fill self crossing polygons.
The filling of a polygon proceeds as follows: for a given point in the polygon, then
if the rule is TFillRule::EAlternate (default) and it has an odd winding number, then fill the surrounding area.
if the rule is TFillRule::EWinding and it has a winding number greater than zero, then fill the surrounding area.
|