wDC

A wDC is a "device context" onto which graphics and text can be drawn. wDC is an abstract base class and cannot be created directly. Use wPaintDC, wClientDC, wWindowDC, wScreenDC, or wMemoryDC.

Notice that device contexts which are associated with windows (i.e. wClientDC, wWindowDC and wPaintDC) use the window font and colors by default. But the other device context classes use system-default values so you always must set the appropriate fonts and colours before using them.

In wNim, wDC and it's subclasses are defined as object instead ref object. So they need nim's destructors to release the resource.

Subclasses:wPaintDC wClientDC wWindowDC wScreenDC wMemoryDC
Seealso:wGdiObject
Consts:Used in logical function and blit.
ConstsDescription
wClear0
wXorsrc XOR dst
wInvertNOT dst
wOrReversesrc OR (NOT dst)
wAndReversesrc AND (NOT dst)
wCopysrc
wAndsrc AND dst
wAndInvert(NOT src) AND dst
wNopdst
wNor(NOT src) AND (NOT dst)
wEquivNOT src) XOR dst
wSrcInvert(NOT src)
wOrInvert(NOT src) OR dst
wNand(NOT src) OR (NOT dst)
wOrsrc OR dst
wSet1

Polygon filling mode, used in drawPolygon and drawPolyPolygon.

ConstsDescription
wOddevenRulefills the area between odd-numbered and even-numbered polygon sides on each scan line
wWindingRulefills any region that has a nonzero winding value

Consts

wClear = 1
wXor = 7
wInvert = 6
wOrReverse = 14
wAndReverse = 5
wCopy = 13
wAnd = 9
wAndInvert = 3
wNop = 11
wNor = 2
wEquiv = 10
wSrcInvert = 4
wOrInvert = 12
wNand = 8
wOr = 15
wSet = 16
wOddevenRule = 1
wWindingRule = 2

Procs

proc drawPoint(self: wDC; x, y: int) {...}{.raises: [], tags: [].}
Draws a point using the color of the current pen.
proc drawPoint(self: wDC; point: wPoint) {...}{.raises: [], tags: [].}
Draws a point using the color of the current pen.
proc drawLine(self: wDC; x1, y1, x2, y2: int) {...}{.raises: [], tags: [].}
Draws a line from the first point to the second.
proc drawLine(self: wDC; point1, point2: wPoint) {...}{.raises: [], tags: [].}
Draws a line from the first point to the second.
proc drawRectangle(self: wDC; x, y, width, height: int) {...}{.raises: [], tags: [].}
Draws a rectangle with the given corner coordinate and size.
proc drawRectangle(self: wDC; point: wPoint; size: wSize) {...}{.raises: [], tags: [].}
Draws a rectangle with the given corner coordinate and size.
proc drawRectangle(self: wDC; rect: wRect) {...}{.raises: [], tags: [].}
Draws a rectangle with the given corner coordinate and size.
proc drawEllipse(self: wDC; x, y, width, height: int) {...}{.raises: [], tags: [].}
Draws an ellipse contained in the rectangle.
proc drawEllipse(self: wDC; point: wPoint; size: wSize) {...}{.raises: [], tags: [].}
Draws an ellipse contained in the rectangle.
proc drawEllipse(self: wDC; rect: wRect) {...}{.raises: [], tags: [].}
Draws an ellipse contained in the rectangle.
proc drawCircle(self: wDC; x, y, radius: int) {...}{.raises: [], tags: [].}
Draws a circle with the given center and radius.
proc drawCircle(self: wDC; point: wPoint; radius: int) {...}{.raises: [], tags: [].}
Draws a circle with the given center and radius.
proc drawText(self: wDC; text: string; x, y: int = 0) {...}{.raises: [], tags: [].}
Draws a text string at the specified point, using the current text font, and the current text foreground and background colors. The text can contain multiple lines separated by the new line ('n') characters.
proc drawText(self: wDC; text: string; point: wPoint) {...}{.raises: [], tags: [].}
Draws a text string at the specified point, using the current text font, and the current text foreground and background colors. The text can contain multiple lines separated by the new line ('n') characters.
proc drawRotatedText(self: wDC; text: string; x, y: int = 0; angle: float = 0) {...}{.raises: [],
    tags: [].}
Draws the text rotated by angle degrees (positive angles are counterclockwise; the full angle is 360 degrees). The text can contain multiple lines separated by the new line ('n') characters.
proc drawRotatedText(self: wDC; text: string; point: wPoint; angle: float = 0) {...}{.
    raises: [], tags: [].}
Draws the text rotated by angle degrees (positive angles are counterclockwise; the full angle is 360 degrees). The text can contain multiple lines separated by the new line ('n') characters.
proc drawLabel(self: wDC; text: string; rect: wRect; align = 0x00000010 or 0x00000040) {...}{.
    raises: [], tags: [].}
Draw the text into the given rectangle and aligns it as specified by alignment parameter. align can be combine of wRight, wCenter, wLeft, wUp, wMiddle, wDown.
proc drawCheckMark(self: wDC; x, y, width, height: int) {...}{.raises: [], tags: [].}
Draws a check mark inside the given rectangle.
proc drawCheckMark(self: wDC; point: wPoint; size: wSize) {...}{.raises: [], tags: [].}
Draws a check mark inside the given rectangle.
proc drawCheckMark(self: wDC; rect: wRect) {...}{.raises: [], tags: [].}
Draws a check mark inside the given rectangle.
proc drawArc(self: wDC; x1, y1, x2, y2, xc, yc: int) {...}{.raises: [], tags: [].}
Draws an arc from the given start to the given end point.
proc drawArc(self: wDC; point1, point2, center: wPoint) {...}{.raises: [], tags: [].}
Draws an arc from the given start to the given end point.
proc drawRoundedRectangle(self: wDC; x, y, width, height: int; radius: float) {...}{.
    raises: [], tags: [].}
Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius. The current pen is used for the outline and the current brush for filling the shape. If radius is positive, the value is assumed to be the radius of the rounded corner. If radius is negative, the absolute value is assumed to be the proportion of the smallest dimension of the rectangle.
proc drawRoundedRectangle(self: wDC; point: wPoint; size: wSize; radius: float) {...}{.
    raises: [], tags: [].}
Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius.
proc drawRoundedRectangle(self: wDC; rect: wRect; radius: float) {...}{.raises: [], tags: [].}
Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius.
proc drawLines(self: wDC; points: openArray[wPoint]; xoffset: int = 0; yoffset: int = 0) {...}{.
    raises: [], tags: [].}
Draws lines using an array of points, adding the optional offset coordinate.
proc drawLines(self: wDC; xoffset: int; yoffset: int; points: varargs[wPoint]) {...}{.
    raises: [], tags: [].}
Draws lines using an array of points, adding the optional offset coordinate. Varargs version.
proc drawPolygon(self: wDC; points: openArray[wPoint]; xoffset: int = 0;
                yoffset: int = 0; style = wOddevenRule) {...}{.raises: [], tags: [].}
Draws a filled polygon using an array of points, adding the optional offset coordinate.
proc drawPolygon(self: wDC; xoffset: int; yoffset: int; style: int;
                points: varargs[wPoint]) {...}{.raises: [], tags: [].}
Draws a filled polygon using an array of points, adding the optional offset coordinate. Varargs version.
proc drawPolyPolygon(self: wDC; counts: openArray[int]; points: openArray[wPoint];
                    xoffset: int = 0; yoffset: int = 0; style = wOddevenRule) {...}{.raises: [],
    tags: [].}
Draws two or more filled polygons using an array of points, adding the optional offset coordinates.
proc drawPolyPolygon(self: wDC; points: openArray[seq[wPoint]]; xoffset: int = 0;
                    yoffset: int = 0; style = wOddevenRule) {...}{.raises: [], tags: [].}
Draws two or more filled polygons using an array of points, adding the optional offset coordinates.
proc drawPolyPolygon(self: wDC; xoffset: int; yoffset: int; style: int;
                    points: varargs[seq[wPoint], `@`]) {...}{.raises: [], tags: [].}
Draws two or more filled polygons using an array of points, adding the optional offset coordinates. Varargs version.
proc drawSpline(self: wDC; points: varargs[wPoint]) {...}{.raises: [], tags: [].}
Draws a spline between all given points using the current pen. There are at least 3 points in the openarray. Hint: points is varargs so it can be array, seq, or list of points.
proc drawRegion(self: wDC; region: wRegion; border = 0; borderBrush: wBrush = nil) {...}{.
    raises: [], tags: [].}
Draws a region. A custom border size and brush can be specified to draws the border.
proc gradientFillLinear(self: wDC; rect: wRect; initialColor: wColor;
                       destColor: wColor; direction = wRight) {...}{.
    raises: [wPenError, wBrushError, Exception], tags: [RootEffect].}
Fill the area specified by rect with a linear gradient, starting from initialColor and eventually fading to destColor. The direction can be one of wUp, wDown, wLeft, wRight.
proc gradientFillConcentric(self: wDC; rect: wRect; initialColor: wColor;
                           destColor: wColor; center: wPoint) {...}{.raises: [], tags: [].}
Fill the area specified by rect with a radial gradient, starting from initialColor at the center of the circle and fading to destColor on the circle outside.
proc gradientFillConcentric(self: wDC; rect: wRect; initialColor: wColor;
                           destColor: wColor) {...}{.raises: [], tags: [].}
Fill the area specified by rect with a radial gradient, starting from initialColor at the center of the circle and fading to destColor on the circle outside. The circle is placed at the center of rect.
proc getHandle(self: wDC): HANDLE {...}{.inline, raises: [], tags: [].}
Returns a value that can be used as a handle to the native drawing context.
proc getHdc(self: wDC): HANDLE {...}{.inline, raises: [], tags: [].}
Returns a value that can be used as a handle to the native drawing context.
proc getDepth(self: wDC): int {...}{.inline, raises: [], tags: [].}
Returns the depth (number of bits/pixel) of this DC.
proc getPixel(self: wDC; x: int; y: int): wColor {...}{.inline, raises: [], tags: [].}
Gets the color at the specified location.
proc getPpi(self: wDC): wSize {...}{.inline, raises: [], tags: [].}
Returns the resolution of the device in pixels per inch.
proc getLogicalFunction(self: wDC): int {...}{.inline, raises: [], tags: [].}
Gets the current logical function.
proc getPen(self: wDC): wPen {...}{.inline, raises: [], tags: [].}
Gets the current pen.
proc getBrush(self: wDC): wBrush {...}{.inline, raises: [], tags: [].}
Gets the current brush.
proc getFont(self: wDC): wFont {...}{.inline, raises: [], tags: [].}
Gets the current font.
proc getRegion(self: wDC): wRegion {...}{.inline, raises: [], tags: [].}
Gets the current region.
proc getTextForeground(self: wDC): wColor {...}{.inline, raises: [], tags: [].}
Gets the current text foreground color.
proc getTextBackground(self: wDC): wColor {...}{.inline, raises: [], tags: [].}
Gets the current text background color.
proc getBackground(self: wDC): wColor {...}{.inline, raises: [], tags: [].}
Gets the color used for painting the background.
proc getBackgroundMode(self: wDC): int {...}{.inline, raises: [], tags: [].}
Returns the current background mode: wPenStyleSolid or wPenStyleTransparent.
proc getBackgroundTransparent(self: wDC): bool {...}{.inline, raises: [], tags: [].}
Returns ture if the current background mode is transparent.
proc getOrigin(self: wDC): wPoint {...}{.raises: [], tags: [].}
Returns the current origin.
proc getScale(self: wDC): tuple[x, y: float] {...}{.inline, raises: [], tags: [].}
Gets the current scale factor.
proc setLogicalFunction(self: var wDC; mode: int) {...}{.inline, raises: [], tags: [].}
Sets the current logical function for the device context.
proc setPen(self: var wDC; pen: wPen) {...}{.inline, raises: [wNilAccess], tags: [].}
Sets the current pen for the DC.
proc setBrush(self: var wDC; brush: wBrush) {...}{.inline, raises: [wNilAccess], tags: [].}
Sets the current brush for the DC.
proc setFont(self: var wDC; font: wFont) {...}{.inline, raises: [wNilAccess], tags: [].}
Sets the current font for the DC.
proc setRegion(self: var wDC; region: wRegion) {...}{.inline, raises: [wNilAccess], tags: [].}
Sets the current region for the DC.
proc setTextBackground(self: var wDC; color: wColor) {...}{.inline, raises: [], tags: [].}
Sets the current text background color for the DC.
proc setTextForeground(self: var wDC; color: wColor) {...}{.inline, raises: [], tags: [].}
Sets the current text foreground color for the DC.
proc setBackground(self: var wDC; color: wColor) {...}{.inline, raises: [], tags: [].}
Sets the current background color for the DC.
proc setBackground(self: var wDC; brush: wBrush) {...}{.inline, raises: [wNilAccess], tags: [].}
Sets the current background color by a sold brush for the DC.
proc setBackgroundMode(self: var wDC; mode: int) {...}{.inline, raises: [], tags: [].}
mode may be one of wPenStyleSolid and wPenStyleTransparent. This setting determines whether text will be drawn with a background color or not.
proc setBackgroundTransparent(self: var wDC; flag: bool) {...}{.inline, raises: [], tags: [].}
This setting determines whether text will be drawn with a background color or not.
proc setOrigin(self: var wDC; x: int; y: int) {...}{.inline, raises: [], tags: [].}
Sets the origin.
proc setOrigin(self: var wDC; point: wPoint) {...}{.inline, raises: [], tags: [].}
Sets the origin.
proc setScale(self: var wDC; x: float; y: float) {...}{.raises: [], tags: [].}
Sets the scaling factor.
proc setScale(self: var wDC; scale: (float, float)) {...}{.inline, raises: [], tags: [].}
Sets the scaling factor.
proc crossHair(self: var wDC; x: int; y: int) {...}{.raises: [], tags: [].}
Displays a cross hair using the current pen.
proc crossHair(self: var wDC; point: wPoint) {...}{.raises: [], tags: [].}
Displays a cross hair using the current pen.
proc clear(self: var wDC; brush: wBrush = nil) {...}{.raises: [], tags: [].}
Clears the device context using the current background color. A custom brush can be use to fill the background.
proc blit(self: wDC; xdest, ydest, width, height: int = 0; source: wDC; xsrc, ysrc: int = 0;
         rop: int = wCopy) {...}{.raises: [], tags: [].}
Copy from a source DC to this DC. rop is the raster operation.
proc stretchBlit(self: wDC; xdest, ydest, dstWidth, dstHeight: int = 0; source: wDC;
                xsrc, ysrc, srcWidth, srcHeight: int = 0; rop: int = wCopy) {...}{.raises: [],
    tags: [].}
Copy from a source DC to this DC possibly changing the scale. rop is the raster operation.
proc stretchBlitQuality(self: wDC; xdest, ydest, dstWidth, dstHeight: int = 0;
                       source: wDC; xsrc, ysrc, srcWidth, srcHeight: int = 0;
                       rop: int = wCopy) {...}{.raises: [], tags: [].}
Copy from a source DC to this DC possibly changing the scale. rop is the raster operation. Using halftone mode for higher quality.
proc alphaBlit(self: wDC; xdest, ydest, dstWidth, dstHeight: int = 0; source: wDC;
              xsrc, ysrc, srcWidth, srcHeight: int = 0; alpha: int = 255) {...}{.raises: [],
    tags: [].}
Copy from a source DC to this DC transparently. The bitmap selected in the source DC must have a transparency mask.
proc transparentBlit(self: wDC; xdest, ydest, dstWidth, dstHeight: int = 0; source: wDC;
                    xsrc, ysrc, srcWidth, srcHeight: int = 0; transparent = wWhite) {...}{.
    raises: [], tags: [].}
Copy from a source DC to this DC and treat a RGB color as transparent.
proc drawBitmap(self: wDC; bmp: wBitmap; x, y: int = 0; transparent = true) {...}{.
    raises: [wNilAccess], tags: [].}
Draw a bitmap on the device context at the specified point. If transparent is true and the bitmap has a transparency mask, the bitmap will be drawn transparently.
proc drawBitmap(self: wDC; bmp: wBitmap; pos: wPoint; transparent = true) {...}{.
    raises: [wNilAccess], tags: [].}
Draw a bitmap on the device context at the specified point.
proc drawImage(self: wDC; image: wImage; x, y: int = 0) {...}{.
    raises: [wNilAccess, wBitmapError], tags: [].}
Draw a image on the device context at the specified point.
proc drawImage(self: wDC; image: wImage; pos: wPoint) {...}{.
    raises: [wNilAccess, wBitmapError], tags: [].}
Draw a image on the device context at the specified point.
proc drawIcon(self: wDC; icon: wIcon; x, y: int = 0) {...}{.raises: [wNilAccess], tags: [].}
Draw an icon at the specified point.
proc getCharHeight(self: wDC): int {...}{.raises: [], tags: [].}
Gets the character height of the currently set font.
proc getCharWidth(self: wDC): int {...}{.raises: [], tags: [].}
Gets the average character width of the currently set font.
proc getFontMetrics(self: wDC): tuple[height, ascent, descent, internalLeading,
                                   externalLeading, averageWidth: int] {...}{.
    raises: [], tags: [].}
Returns the various font characteristics.
proc init(self: var wDC; fgColor: wColor = wBlack; bgColor: wColor = wWhite;
         font = wDefaultFont; pen = wDefaultPen; brush = wDefaultBrush;
         background = wWhite) {...}{.raises: [wNilAccess, IndexDefect, wFontError,
                                     wPenError, wBrushError], tags: [RootEffect].}
Initializer.

Methods

method getSize(self: wDC): wSize {...}{.base, raises: [], tags: [].}
Gets the size of the device context.