Class Fox::FXDC
In: rdoc-sources/FXDC.rb
lib/fox16/core.rb
Parent: Object

A device context is used to maintain the state of the graphics drawing system. Defining your drawing code in terms of the Abstract Device Context allows the drawing commands to be rendered on different types of surfaces, such as windows and images (FXDCWindow), or on paper (FXDCPrint). WYSYWYG may be obtained by using the same identical drawing code in your application regardless of the actual device surface being utilized.

Drawing (BITBLT) functions

BLT_CLR:D := 0
BLT_SRC_AND_DST:D := S & D
BLT_SRC_AND_NOT_DST:D := S & ~D
BLT_SRC:D := S
BLT_NOT_SRC_AND_DST:D := ~S & D
BLT_DST:D := D
BLT_SRC_XOR_DST:D := S ^ D
BLT_SRC_OR_DST:D := S | D
BLT_NOT_SRC_AND_NOT_DST:D := ~S & ~D == D := ~(S | D)
BLT_NOT_SRC_XOR_DST:D := ~S ^ D
BLT_NOT_DST:D := ~D
BLT_SRC_OR_NOT_DST:D := S | ~D
BLT_NOT_SRC:D := ~S
BLT_NOT_SRC_OR_DST:D := ~S | D
BLT_NOT_SRC_OR_NOT_DST:D := ~S | ~D == ~(S & D)
BLT_SET:D := 1

Line Styles

LINE_SOLID:Solid lines
LINE_ONOFF_DASH:On-off dashed lines
LINE_DOUBLE_DASH:Double dashed lines

Line Cap Styles

CAP_NOT_LAST:Don‘t include last end cap
CAP_BUTT:Butting line end caps
CAP_ROUND:Round line end caps
CAP_PROJECTING:Projecting line end caps

Line Join Styles

JOIN_MITER:Mitered or pointy joints
JOIN_ROUND:Round line joints
JOIN_BEVEL:Beveled or flat joints

Fill Styles

FILL_SOLID:Fill with solid color
FILL_TILED:Fill with tiled bitmap
FILL_STIPPLED:Fill where stipple mask is 1
FILL_OPAQUESTIPPLED:Fill with foreground where mask is 1, background otherwise

Fill Rules

RULE_EVEN_ODD:Even odd polygon filling
RULE_WINDING:Winding rule polygon filling

Stipple/dither patterns

STIPPLE_0:Stipple pattern 0
STIPPLE_NONE:Stipple pattern 0
STIPPLE_BLACK:All ones
STIPPLE_1:Stipple pattern 1
STIPPLE_2:Stipple pattern 2
STIPPLE_3:Stipple pattern 3
STIPPLE_4:Stipple pattern 4
STIPPLE_5:Stipple pattern 5
STIPPLE_6:Stipple pattern 6
STIPPLE_7:Stipple pattern 7
STIPPLE_8:Stipple pattern 8
STIPPLE_GRAY:50% gray
STIPPLE_9:Stipple pattern 9
STIPPLE_10:Stipple pattern 10
STIPPLE_11:Stipple pattern 11
STIPPLE_12:Stipple pattern 12
STIPPLE_13:Stipple pattern 13
STIPPLE_14:Stipple pattern 14
STIPPLE_15:Stipple pattern 15
STIPPLE_16:Stipple pattern 16
STIPPLE_WHITE:All zeroes
STIPPLE_HORZ:Horizontal hatch pattern
STIPPLE_VERT:Vertical hatch pattern
STIPPLE_CROSS:Cross-hatch pattern
STIPPLE_DIAG:Diagonal // hatch pattern
STIPPLE_REVDIAG:Reverse diagonal \ hatch pattern
STIPPLE_CROSSDIAG:Cross-diagonal hatch pattern

Methods

Attributes

app  [R]  Application [FXApp]
background  [RW]  Background drawing color [FXColor]
clipHeight  [R]  Height of clip rectangle, in pixels [Integer]
clipRectangle  [R]  Clip rectangle [FXRectangle]
clipRegion  [W]  Clip region [FXRegion]
clipWidth  [R]  Width of clip rectangle, in pixels [Integer]
clipX  [R]  X-coordinate of clip rectangle [Integer]
clipY  [R]  Y-coordinate of clip rectangle [Integer]
dashLength  [R]  Dash length [Integer]
dashOffset  [R]  Dash offset [Integer]
dashPattern  [R]  Dash pattern [String]
fillRule  [RW]  Fill rule, one of RULE_EVEN_ODD or RULE_WINDING [Integer]
fillStyle  [RW]  Fill style, one of FILL_SOLID, FILL_TILED, FILL_STIPPLED or FILL_OPAQUESTIPPLED [Integer]
font  [RW]  Font to draw text with [FXFont]
foreground  [RW]  Foreground drawing color [FXColor]
function  [RW]  Raster op function, one of BLT_CLR, BLT_SRC, BLT_DST, etc. (see list above) [Integer]
lineCap  [RW]  Line cap style, one of CAP_NOT_LAST, CAP_BUTT, CAP_ROUND or CAP_PROJECTING [Integer]
lineJoin  [RW]  Line join style, one of JOIN_MITER, JOIN_ROUND or JOIN_BEVEL [Integer]
lineStyle  [RW]  Line style, one of LINE_SOLID, LINE_ONOFF_DASH or LINE_DOUBLE_DASH [Integer]
lineWidth  [RW]  Line width; a line width of zero means thinnest and fastest possible [Integer]
stipple  [RW]  Stipple pattern [FXBitmap or Integer]
tile  [RW]  Tile image [FXImage]

Public Class methods

Construct dummy DC

Public Instance methods

Clear clip mask.

Clear clipping.

When you call clipChildren with the argument true, anything that you draw into this window will be clipped by its child windows. In other words, the child windows "obscure" the parent window. This is the default behavior. If you call clipChildren with false, anything that you draw into this window will be visible in its child windows (i.e. the drawing will not be clipped).

Parameters:

yes:if true, drawing is clipped against child windows [Boolean]

Draw an arc. The argument start specifies the start of the arc relative to the three-o‘clock position from the center, in units of degrees*64. The argument extent specifies the path and extent of the arc, relative to the start of the arc (also in units of degrees*64). The arguments x, y, w, and h specify the bounding rectangle of the arc.

Parameters:

x:x-coordinate of the upper left corner of the bounding rectangle [Integer]
y:y-coordinate of the upper left corner of the bounding rectangle [Integer]
w:width of the bounding rectangle, in pixels [Integer]
h:height of the bounding rectangle, in pixels [Integer]
start:starting angle of the arc, in 64ths of a degree [Integer]
extent:the path and extent of the arc, relative to the start of the arc (in 64ths of a degree) [Integer]

See also drawArcs, fillArc and fillArcs.

Draw arcs, where arcs is an array of FXArc instances.

Parameters:

arcs:an array of FXArc instances [Array]

See also drawArc, fillArc and fillArcs.

Copy some rectangular area from source into the drawable attached to this device context, stretching it to width dw and height dh.

Parameters:

source:the source drawable from which to copy [FXDrawable]
sx:x-coordinate of the upper left corner of the source rectangle [Integer]
sy:y-coordinate of the upper left corner of the source rectangle [Integer]
sw:width of the source rectangle, in pixels [Integer]
sh:height of the source rectangle, in pixels [Integer]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]
dw:destination width, in pixels [Integer]
dh:destination height, in pixels [Integer]

Copy some rectangular area from source into the drawable attached to this device context.

Parameters:

source:the source drawable from which to copy [FXDrawable]
sx:x-coordinate of the upper left corner of the source rectangle [Integer]
sy:y-coordinate of the upper left corner of the source rectangle [Integer]
sw:width of the source rectangle, in pixels [Integer]
sh:height of the source rectangle, in pixels [Integer]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw bitmap into the drawable attached to this device context.

Parameters:

bitmap:bitmap to draw [FXBitmap]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw a circle centered at (x, y), with specified radius.

Parameters:

x:x-coordinate of the circle‘s center [Integer]
y:y-coordinate of the circle‘s center [Integer]
r:radius of the circle, in pixels [Integer]

See also fillCircle.

Draw an ellipse.

Draw focus rectangle with upper-left corner at (x, y) and with width and height (w, h).

Parameters:

x:x-coordinate of the upper left corner [Integer]
y:y-coordinate of the upper left corner [Integer]
width:width of the rectangle, in pixels [Integer]
height:height of the rectangle, in pixels [Integer]

Draw hashed box with upper-left corner at (x, y) and with width and height (w, h).

Parameters:

x:x-coordinate of the upper left corner [Integer]
y:y-coordinate of the upper left corner [Integer]
width:width of the box, in pixels [Integer]
height:height of the box, in pixels [Integer]
b:border width, in pixels [Integer]

Draw icon into the drawable attached to this device context.

Parameters:

icon:icon to draw [FXIcon]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw a shaded version of an icon into the drawable attached to this device context. This is typically used for drawing disabled labels and buttons.

Parameters:

icon:icon to draw [FXIcon]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw a sunken version of an icon into the drawable attached to this device context.

Parameters:

icon:icon to draw [FXIcon]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw image into the drawable attached to this device context.

Parameters:

image:image to draw [FXImage]
dx:x-coordinate of the the destination point in this drawable [Integer]
dy:y-coordinate of the the destination point in this drawable [Integer]

Draw string at position (x, y).

Parameters:

x:x-coordinate of the upper left corner [Integer]
y:y-coordinate of the upper left corner [Integer]
string:the text string to draw [String]

See also drawText.

Draw the line from (x1, y1) to (x2, y2).

Parameters:

x1:x-coordinate of the starting point [Integer]
y1:y-coordinate of the starting point [Integer]
x2:x-coordinate of the ending point [Integer]
y2:y-coordinate of the ending point [Integer]

See also drawLines and drawLinesRel.

Draw mutiple, unconnected lines (i.e. line segments), where segments is an array of FXSegment instances.

Parameters:

segments:an array of FXSegment instances [Array]

Draw connected lines, where points is an array of FXPoint instances. The number of lines drawn is equal to the size of the points array minus one. Treats all points’ coordinates as relative to the origin.

Parameters:

points:array of FXPoint instances that defines all points on the line [Array]

See also drawLine and drawLinesRel.

Draw connected lines, where points is an array of FXPoint instances. The number of lines drawn is equal to the size of the points array minus one. Treats each point‘s coordinates (after the first) as relative to the previous point.

Parameters:

points:array of FXPoint instances that defines all points on the line [Array]

See also drawLine and drawLines.

Draw a point at (x, y) in the current foreground drawing color.

Parameters:

x:x-coordinate of the point [Integer]
y:y-coordinate of the point [Integer]

See also drawPoints and drawPointsRel.

Draw multiple points, where points is an array of FXPoint instances.

Parameters:

points:array of FXPoint instances [Array]

See also drawPoint and drawPointsRel.

Draw multiple points, where points is an array of FXPoint instances. Unlike drawPoints, where each of the points is drawn relative to the origin, drawPointsRel treats all coordinates after the first as relative to the previous point.

Parameters:

points:array of FXPoint instances [Array]

See also drawPoint and drawPoints.

Draw rectangle with upper-left corner at (x, y) and with width and height (w, h).

Parameters:

x:x-coordinate of upper-left corner of the rectangle [Integer]
y:y-coordinate of upper-left corner of the rectangle [Integer]
width:width of the rectangle, in pixels [Integer]
height:height of the rectangle, in pixels [Integer]

See also drawRectangles, fillRectangle and fillRectangles.

Draw multiple rectangles, where rectangles is an array of FXRectangle instances.

Parameters:

rectangles:an array of FXRectangle instances [Array]

See also drawRectangle, fillRectangle and fillRectangles.

Draw a rounded rectangle with ellipse width ew and ellipse height eh.

Parameters:

x:x-coordinate of the upper left corner of the bounding rectangle [Integer]
y:y-coordinate of the upper left corner of the bounding rectangle [Integer]
w:width of the bounding rectangle, in pixels [Integer]
h:height of the bounding rectangle, in pixels [Integer]

Draw string at position (x, y).

Parameters:

x:x-coordinate of the upper left corner [Integer]
y:y-coordinate of the upper left corner [Integer]
string:the text string to draw [String]

See also drawImageText.

Draw filled arc (see documentation for drawArc).

Parameters:

x:x-coordinate of the upper left corner of the bounding rectangle [Integer]
y:y-coordinate of the upper left corner of the bounding rectangle [Integer]
w:width of the bounding rectangle, in pixels [Integer]
h:height of the bounding rectangle, in pixels [Integer]
start:starting angle of the arc, in 64ths of a degree [Integer]
extent:the path and extent of the arc, relative to the start of the arc (in 64ths of a degree) [Integer]

See also drawArc, drawArcs and fillArcs.

Draw filled arcs, where arcs is an array of FXArc instances.

Parameters:

arcs:an array of FXArc instances [Array]

See also drawArc, drawArcs and fillArc.

Draw a filled circle centered at (x, y), with specified radius.

Parameters:

x:x-coordinate of the circle‘s center [Integer]
y:y-coordinate of the circle‘s center [Integer]
r:radius of the circle, in pixels [Integer]

See also drawCircle.

Draw filled polygon, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw filled polygon with relative points, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw filled polygon, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw filled polygon with relative points, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw a filled ellipse.

Draw filled polygon, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw filled polygon with relative points, where points is an array of FXPoint instances.

Parameters:

points:an array of FXPoint instances [Array]

Draw filled rectangle with upper-left corner at (x, y) and with width and height (w, h).

Parameters:

x:x-coordinate of the upper left corner of the rectangle [Integer]
y:y-coordinate of the upper left corner of the rectangle [Integer]
width:width of the rectangle, in pixels [Integer]
height:height of the rectangle, in pixels [Integer]

See also drawRectangle, drawRectangles and fillRectangles.

Draw filled rectangles, where rectangles is an array of FXRectangle instances.

Parameters:

rectangles:an array of FXRectangle instances [Array]

See also drawRectangle, drawRectangles and fillRectangle.

Draw a filled rounded rectangle with ellipse width ew and ellipse height eh.

Parameters:

x:x-coordinate of the upper left corner of the bounding rectangle [Integer]
y:y-coordinate of the upper left corner of the bounding rectangle [Integer]
w:width of the bounding rectangle, in pixels [Integer]
h:height of the bounding rectangle, in pixels [Integer]

Returns a color value (i.e. an FXColor) for the pixel at (x, y).

Parameters:

x:x-coordinate of the pixel of interest [Integer]
y:y-coordinate of the pixel of interest [Integer]

Set clip mask to bitmap.

Parameters:

bitmap:a bitmap to use for clipping [FXBitmap]
dx:[Integer]
dy:[Integer]

See also setClipRectangle.

Set clip rectangle.

Parameters:

x:x-coordinate of the upper left corner of the clip rectangle [Integer]
y:y-coordinate of the upper left corner of the clip rectangle [Integer]
width:width of the clip rectangle, in pixels [Integer]
height:height of the clip rectangle, in pixels [Integer]

See also setClipMask.

Set clip rectangle.

Parameters:

rectangle:a rectangle that defines the clipping region [Integer]

See also setClipMask.

Set dash pattern and dash offset. A dash pattern of [1, 2, 3, 4] is a repeating pattern of 1 foreground pixel, 2 background pixels, 3 foreground pixels, and 4 background pixels. The offset is where in the pattern the system will start counting. The maximum length of the dash pattern array is 32 elements.

Parameters:

dashOffset:indicates which element of the dash pattern to start with (zero for the beginning) [Integer]
dashPattern:array of integers indicating the dash pattern [Array]

[Validate]