Contents Up Previous Next

Device context

Overview

A device context is an abstraction of a surface that can be drawn onto.

The following functions can be used with any device context identifier, with the exception of dc-blit which must not be used with a PostScript device context, and dc-get-text-extent-width, dc-get-text-extent-height which do not function correctly on PostScript or metafile device contexts.

dc-begin-drawing
dc-blit
dc-clear
dc-delete
dc-destroy-clipping-region
dc-draw-ellipse
dc-draw-line
dc-draw-lines
dc-draw-point
dc-draw-polygon
dc-draw-rectangle
dc-draw-rounded-rectangle
dc-draw-text
dc-draw-spline
dc-end-doc
dc-end-drawing
dc-end-page
dc-get-min-x
dc-get-min-y
dc-get-max-x
dc-get-max-y
dc-get-text-extent-height
dc-get-text-extent-width
dc-ok
dc-start-doc
dc-start-page
dc-set-background
dc-set-background-mode
dc-set-brush
dc-set-colourmap
dc-set-clipping-region
dc-set-font
dc-set-logical-function
dc-set-pen
dc-set-text-foreground
dc-set-text-background


dc-begin-drawing

long ( dc-begin-drawing long id)

Bracket a series of drawing primitives in dc-begin-drawing and dc-end-drawing to optimize drawing under Windows, and also if drawing to a panel or dialog box context, for which these calls are mandatory. The calls may be nested.


dc-blit

long ( dc-blit long dest-dc-id double dest-x double dest-y double width double height long source-dc-id double source-x double source-y optional string logical-op = "wxCOPY")

Block-copies the given area from a source device context to a destination device context. This operation is not available to PostScript and Windows Metafile destination device contexts.

The argument logical-op sets the current logical function for the canvas. This determines how a source pixel from the source device context combines with a destination pixel in the current device context.

The possible values and their meaning in terms of source and destination pixel values are as follows:

wxAND                 src AND dst
wxAND_INVERT          (NOT src) AND dst
wxAND_REVERSE         src AND (NOT dst)
wxCLEAR               0
wxCOPY                src
wxEQUIV               (NOT src) XOR dst
wxINVERT              NOT dst
wxNAND                (NOT src) OR (NOT dst)
wxNOR                 (NOT src) AND (NOT dst)
wxNO_OP               dst
wxOR                  src OR dst
wxOR_INVERT           (NOT src) OR dst
wxOR_REVERSE          src OR (NOT dst)
wxSET                 1
wxSRC_INVERT          NOT src
wxXOR                 src XOR dst
The default is wxCOPY, which simply draws with the current colour. The others combine the current colour and the background using a logical operation. wxXOR is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour.


dc-clear

long ( dc-clear long dc-id)

Clears the device context using the background colour.


dc-delete

long ( dc-delete long dc-id)

Deletes a device context that has been explicitly created (so not a canvas DC).


dc-destroy-clipping-region

long ( dc-destroy-clipping-region long dc-id)

Destroys the current clipping region.


dc-draw-ellipse

long ( dc-draw-ellipse long dc-id
double x double y double width double height)

Draws an ellipse. The outline and filling attributes are determined by the pen and brush settings respectively.


dc-draw-line

long ( dc-draw-line long dc-id
double x1 double y1 double x2 double y2)

Draws a line between the given points.


dc-draw-lines

long ( dc-draw-lines long dc-id multifield list)

Draws lines between the given points. list is a multifield, which can be created by a call to mv-append and a list of arguments. The list must contain an even number of floating-point values, interpreted in pairs as the points determining the multiline.


dc-draw-point

long ( dc-draw-point long dc-id double x double y)

Draws a point.


dc-draw-polygon

long ( dc-draw-polygon long dc-id multifield list)

Draws a (possibly filled) polygon. list is a multifield, which can be created by a call to mv-append and a list of arguments. The list must contain an even number of floating-point values, interpreted in pairs as the points determining the polygon. The outline and filling attributes are determined by the pen and brush settings respectively.


dc-draw-rectangle

long ( dc-draw-rectangle long dc-id
double x double y double width double height)

Draws a rectangle. The outline and filling attributes are determined by the pen and brush settings respectively.


dc-draw-rounded-rectangle

long ( dc-draw-rounded-rectangle long dc-id
double x double y double width double height double radius)

Draws a rounded rectangle, with corners with a specified radius (optional). The outline and filling attributes are determined by the pen and brush settings respectively.


dc-draw-text

long ( dc-draw-text long dc-id
string text double x double y)

Draw text at the given position, using the font set by dc-set-font, and using the colours set by dc-set-text-foreground and dc-set-text-background respectively.


dc-draw-spline

long ( dc-draw-spline long dc-id multifield list)

Draws a spline curve. list is a multifield, which can be created by a call to mv-append and a list of arguments. The list must contain an even number of floating-point values, interpreted in pairs as the points determining the spline shape.


dc-end-doc

long ( dc-end-doc long dc-id)

Ends a document (such as a PostScript or Windows printer document).


dc-end-drawing

long ( dc-end-drawing long id)

Bracket a series of drawing primitives in dc-begin-drawing and dc-end-drawing to optimize drawing under Windows, and also if drawing to a panel or dialog box context, for which these calls are mandatory. The calls may be nested.


dc-end-page

long ( dc-end-page long dc-id)

Ends a page.


dc-get-min-x

double ( dc-get-min-x long dc-id)

Returns the minimum X value drawn so far on the device context.


dc-get-min-y

double ( dc-get-min-y long dc-id)

Returns the minimum Y value drawn so far on the device context.


dc-get-max-x

double ( dc-get-max-x long dc-id)

Returns the maximum X value drawn so far on the device context.


dc-get-max-y

double ( dc-get-max-y long dc-id)

Returns the maximum Y value drawn so far on the device context.


dc-get-text-extent-height

double ( dc-get-text-extent-height long dc-id string text)

Returns the height of the text as drawn on this device context, in logical units.


dc-get-text-extent-width

double ( dc-get-text-extent-width long dc-id string text)

Returns the width of the text as drawn on this device context, in logical units.


dc-ok

long ( dc-ok long id)

Returns 1 if the device context is OK (usually meaning, it has been initialised correctly), and 0 otherwise.


dc-start-doc

long ( dc-start-doc long dc-id string message)

Starts a document (such as a PostScript or Windows printer document) using the given string for any associated message box (the message is not in fact currently used).


dc-start-page

long ( dc-start-page long dc-id)

Starts a page.


dc-set-background

long ( dc-set-background long dc-id long brush)

Sets the background brush.


dc-set-background-mode

long ( dc-set-background-mode long dc-id string mode)

Sets the mode for drawing text background.

mode may be wxSOLID (use the text background colour) or wxTRANSPARENT (do not fill the background).


dc-set-brush

long ( dc-set-brush long dc-id long brush-id)

Sets the current brush for the device context. brush-id is an ID returned from a call to brush-create, or zero to select any existing brush out of the device context.


dc-set-colourmap

long ( dc-set-colourmap long dc-id long cmap-id)

Sets the colourmap for the device context. If cmap-id is zero, the original colourmap is restored so that it is safe to delete the device context (or colourmap).


dc-set-clipping-region

long ( dc-set-clipping-region long dc-id
double x1 double y1 double x2 double y2)

Sets a rectangular clipping region, outside which drawing operations have no effect.


dc-set-font

long ( dc-set-font long dc-id long font-id)

Sets the current font for the device context. font-id is an ID returned from a call to font-create, or zero to select any existing font out of the device context.


dc-set-logical-function

long ( dc-set-logical-function long dc-id string logical-function)

Sets the current logical function for the device context. The logical function determines how pixels are changed by the drawing functions, and may be one of wxCOPY, wxXOR, wxINVERT, wxOR_REVERSE and wxAND_REVERSE.


dc-set-pen

long ( dc-set-pen long dc-id long pen-id)

Sets the current pen for the device context. pen-id is an ID returned from a call to pen-create, or zero to select any existing pen out of the device context.


dc-set-text-foreground

long ( dc-set-text-foreground long dc-id string colour)

Sets the colour for the text foreground, effective when dc-draw-text is used. colour is a capitalized name from the list defined in the wxWindows manual.


dc-set-text-background

long ( dc-set-text-background long dc-id string colour)

Sets the colour for the text background, effective when dc-draw-text is used. colour is a capitalized name from the list defined in the wxWindows manual.