Adobe InDesign CS4 (6.0) Object Model JS: ScriptUIGraphics

InDesign CS4

Class

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
backgroundColorScriptUIBrush r/wThe background color for containers; for non-containers, the parent background color.
The paint color and style is defined in this brush object.
currentPathScriptUIPath readonlyThe current drawing path, encapsulated in a path object.
currentPointPoint readonlyThe current position in the current drawing path.
disabledBackgroundColorScriptUIBrush r/wThe 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.
disabledForegroundColorScriptUIPen r/wThe text color when the element is disabled or inactive.
The paint color and style is defined in this pen object.
fontScriptUIFont r/wThe default font to use for displaying text.
foregroundColorScriptUIPen r/wThe text color.
The paint color and style is defined in this pen object.

Class

PropertyTypeAccessDescription
BrushTypeObject readonlyContains the enumerated constants for the type argument of newBrush().
Type constants are: SOLID_COLOR, THEME_COLOR.
PenTypeObject readonlyContains the enumerated constants for the type argument of newPen().
Type constants are: SOLID_COLOR, THEME_COLOR.

Methods

Events

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.

Instances

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
leftNumberThe left coordinate of the region.
Value is relative to the origin of this element.
topNumberThe 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
imageScriptUIImageThe 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. (Optional)
heightNumberThe height in pixels. If provided, the image is stretched or shrunk to fit. If omitted, uses the original image height. (Optional)

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. (Optional)

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. (Optional)

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. (Optional)
boundingWidthNumberThe bounding width. (Optional)

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
typeNumberThe brush type, solid or theme.
One of the constants ScriptUIGraphics.BrushType.SOLID_COLOR or ScriptUIGraphics.BrushType.THEME_COLOR.
colorArray of Number | StringThe 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
typeNumberThe pen type, solid or theme.
One of the constants ScriptUIGraphics.PenType.SOLID_COLOR or ScriptUIGraphics.PenType.THEME_COLOR.
colorArray of Number | StringThe 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.

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. (Optional)

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

Jongware, 20-Jun-2010 v3.0.3dContents :: Index