Class Fox::FXDC
In: FXDC.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_NONE::

STIPPLE_BLACK:All ones

STIPPLE_1:: STIPPLE_2:: STIPPLE_3:: STIPPLE_4:: STIPPLE_5:: STIPPLE_6:: STIPPLE_7:: STIPPLE_8::

STIPPLE_GRAY:50% gray

STIPPLE_9:: STIPPLE_10:: STIPPLE_11:: STIPPLE_12:: STIPPLE_13:: STIPPLE_14:: STIPPLE_15:: STIPPLE_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
clearClipMask    clearClipRectangle    clipChildren    drawArc    drawArcs    drawArea    drawBitmap    drawFocusRectangle    drawHashBox    drawIcon    drawIconShaded    drawIconSunken    drawImage    drawImageText    drawLine    drawLineSegments    drawLines    drawLinesRel    drawPoint    drawPoints    drawPointsRel    drawRectangle    drawRectangles    drawText    fillArc    fillArcs    fillComplexPolygon    fillComplexPolygonRel    fillConcavePolygon    fillConcavePolygonRel    fillPolygon    fillPolygonRel    fillRectangle    fillRectangles    new    readPixel    setClipMask    setClipRectangle    setClipRectangle    setDashes   
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]

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]

textFont  [RW] 

Font to draw text with [FXFont]

tile  [RW] 

Tile image [FXImage]

Public Class methods
new(app)

Construct dummy DC

Public Instance methods
readPixel(x, y)

Read back pixel at (x, y)

drawPoint(x, y)

Draw point at (x, y)

drawPoints(points)

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

drawPointsRel(points)

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

drawLine(x1, y1, x2, y2)

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

drawLines(points)

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

drawLinesRel(points)

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

drawLineSegments(segments)

Draw line segments, where segments is an array of FXSegment instances.

drawRectangle(x, y, w, h)

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

drawRectangles(rectangles)

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

drawArc(x, y, w, h, angle1, angle2)

Draw arcs. The argument angle1 specifies the start of the arc relative to the three-o'clock position from the center, in units of degrees*64. The argument angle2 specifies the path and extent of the arc relative to the start of the arc, in units of degrees*64. The arguments x, y, w, and h specify the bounding rectangle.

drawArcs(arcs)

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

fillRectangle(x, y, w, h)

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

fillRectangles(rectangles)

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

fillArc(x, y, w, h, angle1, angle2)

Draw filled arc (see documentation for drawArc).

fillArcs(arcs)

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

fillPolygon(points)

Filled polygon, where points is an array of FXPoint instances.

fillConcavePolygon(points)

Filled polygon, where points is an array of FXPoint instances.

fillComplexPolygon(points)

Filled polygon, where points is an array of FXPoint instances.

fillPolygonRel(points)

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

fillConcavePolygonRel(points)

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

fillComplexPolygonRel(points)

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

drawHashBox(x, y, w, h, borderWidth=1)

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

drawFocusRectangle(x, y, w, h)

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

drawArea(source, sx, sy, sw, sh, dx, dy)

Draw area from source.

drawImage(image, dx, dy)

Draw image.

drawBitmap(bitmap, dx, dy)

Draw bitmap.

drawIcon(icon, dx, dy)

Draw icon.

drawIconShaded(icon, dx, dy)

Draw icon shaded (used for disabled labels and buttons).

drawIconSunken(icon, dx, dy)

Draw icon sunken.

drawText(x, y, string)

Draw string at position (x, y).

drawImageText(x, y, string)

Draw string at position (x, y).

setDashes(dashOffset, dashPattern, dashLength)

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 is 32.

setClipRectangle(x, y, w, h)

Set clip rectangle

setClipRectangle(rectangle)

Change clip rectangle

clearClipRectangle()

Clear clipping

setClipMask(bitmap, dx=0, dy=0)

Set clip mask to bitmap.

clearClipMask()

Clear clip mask

clipChildren(yes)

Clip against child windows (where yes is either true or false)