CS3 JS: ScriptUIGraphics

CS3 ScriptUI

ScriptUIGraphics

 

An object used to draw custom graphics, found in the graphics property of window, container, and control objects.

Allows a script to customize aspects of the element’s appearance, such as the color and font. Use an onDraw callback function to set these properties or call the functions.All measurements are in pixels.

QuickLinks

closePath, drawFocusRing, drawImage, drawOSControl, drawString, ellipsePath, fillPath, lineTo, measureString, moveTo, newBrush, newPath, newPen, onDraw, rectPath, strokePath

Properties

PropertyTypeAccessDescription
BrushTypeObjectreadonly

Contains the enumerated constants for the type argument of newBrush().

Type constants are: SOLID_COLOR, THEME_COLOR.

PenTypeObjectreadonly

Contains the enumerated constants for the type argument of newPen().

Type constants are: SOLID_COLOR, THEME_COLOR.

backgroundColorScriptUIBrushr/w

The background color for containers; for non-containers, the parent background color.

The paint color and style is defined in this brush object.

currentPathScriptUIPathreadonlyThe current drawing path, encapsulated in a path object.
currentPointPointreadonlyThe current position in the current drawing path.
disabledBackgroundColorScriptUIBrushr/w

The background color for containers when disabled or inactive; for non-containers, the parent background color.

The paint color and style is defined in this brush object.

disabledForegroundColorScriptUIPenr/w

The text color when the element is disabled or inactive.

The paint color and style is defined in this pen object.

fontScriptUIFontr/wThe default font to use for displaying text.
foregroundColorScriptUIPenr/w

The text color.

The paint color and style is defined in this pen object.

Methods

void closePath ()
Closes the current path.

Defines a line from the current postion (currentPoint) to the start point of the current path (the value of currentPath).

void drawFocusRing (left:Number, top:Number, width:Number, height:Number)
Draws a focus ring within a region of this element.

ParameterTypeDescription
leftNumber

The left coordinate of the region.

Value is relative to the origin of this element.

topNumber

The top coordinate of the region.

Value is relative to the origin of this element.

widthNumberThe width of the region in pixels.
heightNumberThe height of the region in pixels.

void drawImage (image:ScriptUIImage, left:Number, top:Number, width:Number, height:Number)
Draws an image within a given region of the element.

Uses the version of the image that is appropriate to the element's current state.

ParameterTypeDescription
imageScriptUIImage

The image to draw.

This object contains different versions of an image appropriate to various element states, such as a dimmed version for the disabled state.

leftNumberThe left coordinate of the region, relative to the origin of this element.
topNumberThe top coordinate of the region, relative to the origin of this element.
widthNumberThe width in pixels. If provided, the image is stretched or shrunk to fit. If omitted, uses the original image width.
heightNumberThe height in pixels. If provided, the image is stretched or shrunk to fit. If omitted, uses the original image height.

void drawOSControl ()
Draw the platform-specific control associated with this element.

void drawString (text:String, pen:ScriptUIPen, x:Number, y:Number, font:ScriptUIFont)
Draw a string of text starting at a given point in this element, using a given drawing pen and font.

ParameterTypeDescription
textStringThe text string.
penScriptUIPenThe drawing pen to use.
xNumberThe left coordinate, relative to the origin of this element.
yNumberThe top coordinate, relative to the origin of this element.
fontScriptUIFontThe font to use. Default is the  font value in this object.

Point ellipsePath (left:Number, top:Number, width:Number, height:Number)
Defines an elliptical path within a given rectangular area in the currentPath object, which can be filled using fillPath() or stroked using strokePath().

Returns a Point object for the upper left corner of the area, which is the new currentPoint.

ParameterTypeDescription
leftNumberThe left coordinate of the region, relative to the origin of this element.
topNumberThe top coordinate of the region, relative to the origin of this element.
widthNumberThe width of the region in pixels.
heightNumberThe height of the region in pixels.

void fillPath (brush:ScriptUIBrush, path:ScriptUIPath)
Fills a path using a given painting brush.

ParameterTypeDescription
brushScriptUIBrushThe brush object that defines the fill color.
pathScriptUIPathThe path object. Default is the currentPath.

Point lineTo (x:Number, y:Number)
Adds a path segment to the currentPath.

The line is defined from the currentPoint to the specified destination point. Returns the Point object for the destination point, which becomes the new value of currentPoint.

ParameterTypeDescription
xNumberThe X coordinate for the destination point, relative to the origin of this element.
yNumberThe Y coordinate for the destination point, relative to the origin of this element.

Dimension measureString (text:String, font:ScriptUIFont, boundingWidth:Number)
Calculates the size needed to display a string using the given font.

Returns a Dimension object that contains the height and width of the string in pixels.

ParameterTypeDescription
textStringThe text string to measure.
fontScriptUIFont The font to use. Default is the font value in this object.
boundingWidthNumberThe bounding width.

Point moveTo (x:Number, y:Number)
Adds a given point to the currentPath, and makes it the current drawing position.

Returns the Point object which is the new value of currentPoint.

ParameterTypeDescription
xNumberThe X coordinate for the new point, relative to the origin of this element.
yNumberThe Y coordinate for the new point, relative to the origin of this element.

ScriptUIBrush newBrush (type:Number, color: Array of Number String)
Creates a new painting brush object.

ParameterTypeDescription
typeNumber

The brush type, solid or theme.

One of the constants ScriptUIGraphics.BrushType.SOLID_COLOR or ScriptUIGraphics.BrushType.THEME_COLOR.

colorArray of Number String

The brush color.

- If type is SOLID_COLOR, the color expressed as an array of three or four values, in the form [R, B, G, A] specifying the red, green, and blue values of the color and, optionally, the opacity (alpha channel). All values are numbers in the range [0.0..1.0]. An opacity of 0 is fully transparent, and an opacity of 1 is fully opaque.

- If the type is THEME_COLOR, the name string of the theme. Theme colors are defined by the host application.

ScriptUIPath newPath ()
Creates a new, empty path object.

Replaces any existing path in currentPath.

ScriptUIPen newPen (type:Number, color: Array of Number String)
Creates a new drawing pen object.

ParameterTypeDescription
typeNumber

The pen type, solid or theme.

One of the constants ScriptUIGraphics.PenType.SOLID_COLOR or ScriptUIGraphics.PenType.THEME_COLOR.

colorArray of Number String

The pen color.

- If type is SOLID_COLOR, the color expressed as an array of three or four values, in the form [R, B, G, A] specifying the red, green, and blue values of the color and, optionally, the opacity (alpha channel). All values are numbers in the range [0.0..1.0]. An opacity of 0 is fully transparent, and an opacity of 1 is fully opaque.

- If the type is THEME_COLOR, the name string of the theme. Theme colors are defined by the host application.

void onDraw (drawState:DrawState)
A function that is called when the element needs to be drawn.

ParameterTypeDescription
drawStateDrawStateOn object containing information about the current mouse button and modifier key states.

Point rectPath (left:Number, top:Number, width:Number, height:Number)
Defines a rectangular path in the currentPath object.

The rectangle can be filled using fillPath() or stroked using strokePath().Returns the Point object for the upper left corner of the rectangle, which becomes the new value of currentPoint.

ParameterTypeDescription
leftNumberThe left coordinate relative to the origin of this element.
topNumberThe top coordinate relative to the origin of this element.
widthNumberThe width in pixels.
heightNumberThe height in pixels.

void strokePath (pen:ScriptUIPen, path:ScriptUIPath)
Strokes the path segments of a path with a given drawing pen.

ParameterTypeDescription
penScriptUIPenThe drawing pen that defines the color and line width.
pathScriptUIPathThe path object. Default is the currentPath.

Element of

Button.graphics

Checkbox.graphics

DropDownList.graphics

EditText.graphics

Group.graphics

IconButton.graphics

Image.graphics

ListBox.graphics

Panel.graphics

Progressbar.graphics

RadioButton.graphics

Scrollbar.graphics

Slider.graphics

StaticText.graphics

TreeView.graphics

Window.graphics

Contents :: Index