Adobe GoLive CS2 Programmer's Manual page 85

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
// define the drawBox handler to create visual representation of box
function drawMyBox(paintEvt) {
var box = paintEvt.target;
var drawObj = paintEvt.draw;
if (box.element.color != undefined)
else
// paint a white background and frame it in black, before
// drawing the custom placeholder graphic on top of the background
// Inset the drawing by 1 px to leave room for the selection border
// Get picture dimensions from box
// draw the image
}
// register the drawBox handler for the box object
function initializeModule() {
var myBox = boxes[myboxname];
myBox.addEventListener( 'drawBox', drawMyBox);
}
The handler uses the draw object (passed in the paintEvent object) to paint a white background and
black frame before drawing the custom placeholder graphic on top of this background. It then sets the
width and height of the picture object for the placeholder graphic to the values specified by the custom
box. Finally, it calls the draw function of the picture object to redraw the visual representation of the
custom box.
The draw object's setColor method specifies the color used for drawing. It accepts color values
specified as any valid HTML color name, such as "red" , "#FF0000" , or "#F00" . The method also accepts
integer triplets specifying red, green, and blue values from 0 to 255. These all set a color to red:
setColor ("#FF0000")
setColor ("red")
setColor (255, 0, 0)
For additional examples of the use of the draw object, see the Custom Box and Multiple
Inspectors sample extensions and the custom drawing functions in the Dialog Editor sample code
that the SDK provides.
drawObj.setColor(box.element.color);
drawObj.setColor("white");
drawObj.fillRect(1, 1, box.width-2, box.height-2);
drawObj.setColor("black");
drawObj.frameRect(1, 1, box.width-2, box.height-2);
placeholderGraphic.width = box.width;
placeholderGraphic.height = box.height;
placeholderGraphic.draw(1, 1);
Adobe GoLive CS2 SDK
Custom Elements
85

Advertisement

Table of Contents
loading

Table of Contents