Graphics Context Settings

This topic provides an introduction to the graphics context settings.

Drawing mode

This is used to determine the logical operation used to put pen or brush color onto the graphics device. The usual modes are: no effect; write color; and exclusive or. Other possible logical combinations are supported.

Pen color, line size and style

The pen is used for free line and shape outline drawing and also for text. The line styles include solid and various dot and dash combinations. Lines may be drawn in various sizes.

Brush color, style and origin

The brush is used for filling areas drawn with the shape primitives, and also for text background fills. You can specify a color, pattern and style. The brush also has an origin point for the pattern. The way the brush fills depends on the drawing mode. A bitmap pattern may be used and then discarded.

Text font and a justification mode

Font specification allows for a variety of typeface s and styles for sizes (bold, underline, italic, etc.). Text color (foreground) depends on the pen color and drawing mode. Text background fill depends on the brush settings. Text justification may be set for word justification, or full WYSIWYG with character justification. A font may be used and then discarded.

Co-ordinate origin

All GDI operations take place within a co-ordinate system. By default the pixel in the top left corner of the screen is the origin, and has co-ordinates (0,0). The co-ordinates of the pixel in the bottom right of the screen depend on the dimensions of the display in use.

There is a function to set the position of the origin of a graphics context: CGraphicsContext::SetOrigin(). All subsequent drawing operations are then done relative to this new origin.

Internal drawing position

A graphics context maintains an internal drawing position relative to its origin. This can be set, without drawing, by using:

  • CGraphicsContext::MoveTo()

  • CGraphicsContext::MoveBy()

The internal drawing position is also changed to the last point of the line(s) drawn by the operations:

  • CGraphicsContext::DrawLine()

  • CGraphicsContext::DrawLineTo()

  • CGraphicsContext::DrawLineBy()

  • CGraphicsContext::DrawPolyline()

The internal drawing position is used as the start point of the line drawn by:

  • CGraphicsContext::DrawLineTo()

  • CGraphicsContext::DrawLineBy()