A typical method to draw a rectangle in a window called theWindow would be:
aMethod
{ aRec -> Rectangle new.
aRec movex 100 movey 150.
!! it is assumed that aMethod has access to the
!! variable theWindow which points to a Window widget
aRec drawIn theWindow.
}
All shapes can be moved and resized. In addition, their foreground and background colors can be set as well as their writing mode.
The shapes you can draw include: line, arc, polygon, rectangle, button, editor, icon, named icon, axis, backpage, painting and table.
new
Create a new shape and initialize the origin, height, width and decor.
selectEmbedsIn aWidget:Widget
Selects (i.e. highlights) any embedded figures in Shape. Type Text uses this method to select embedded figures in text.
animateTo aPoint:Point in aWindow:Window every msec:Integer
Moves me from my current position to aPoint in aWindow. The shape is moved using incremental, linear motion and pauses msec milliseconds each increment. Set msec to 0 for the fastest speed.
computeExtent
Recompute the width and height of me.
drop aFigure:Figure in aWidget:Widget with aMode:Shapemode
Embeds aFigure in me. AWidget and aMode are used to redisplay the shape.
hasText aString:String
REPLY Boolean
Reply TRUE if aString is contained in the shape.
unmanaged anEvent:Event
Handle anEvent which was not handled by any other object.
enterIn aWidget:Widget
Change the display of me because the user has clicked on the shape for the purpose of editing.
leaveIn aWidget:Widget
Change the display of me because the user has indicated that editing is no longer in effect for this shape.
motion anEvent:Event
Process a motion event for this shape.
buttonPress anEvent:Event
Process a buttonPress event for this shape.
buttonRelease anEvent:Event
Process a buttonRelease event for this shape.
keyPress anEvent:Event
Process a keyPress event for this shape.
keyRelease anEvent:Event
Process a keyRelease event for this shape.
isEmpty
REPLY Boolean
Reply TRUE if width and height are 0. This will be the case for objects like text which don't initially have text in them.
reset
Revert the shape back to some known state.
movex newx:Integer movey newy:Integer
Move the shape to newx@newy. Note that this does not change the display of the shape. Typically, you will erase the shape in a window, move it and then redisplay it in the new location.
shiftx dx:Integer shifty dy:Integer
Shift the origin by dx and dy. Note that this does not change the display of the shape.
resizeWidth aWidth:Integer resizeHeight aHeight:Integer
Change the width and height of the shape. Note that this does not change the display of the shape.
drawIn aWidget:Widget
Draw me in widget aWidget, typically a window.
eraseIn aWidget:Widget
This will set the foreground to the window background, draw the shape and then reset the foreground. This may not be the best way to erase it in cases when the shape overlays a colored background because it will leave a shadow.
contains pt:Point
REPLY Boolean
Reply TRUE if pt lies within the shape. By default, pt must lie within the extent rectangle. The minimum size of the rectangle is 10 by 10.
extentIn aRec:Rectangle
Set aRec to the extent rectangle of the shape.
foreground aColor:Integer
Set the foreground color of the shape to aColor. The value of aColor can be 0-black, 1-white, 2-red, 3-green, 4-blue, 5-yellow, 6-cyan, 7-magenta or a shade from 8-132.
Set the background color of the shape to aColor. The value of aColor can be 0-black, 1-white, 2-red, 3-green, 4-blue, 5-yellow, 6-cyan, 7-magenta or a shade from 8-132.
writeMode aMode:Integer
Set the writing mode to aMode. The value of aMode can be #replace or #overlay. Normally the writing mode should be #replace. Mode #overlay is used for dragging or animation when you don't want to disturb the background. The first time you draw a shape in #overlay mode it will appear. If you draw it again in the same position it will disappear without changing the background.
foreground
REPLY Integer
Reply with the foreground color.
background
REPLY Integer
Reply with the background color.
writeMode
REPLY Integer
Reply with the writing mode.
drawHandlesIn aWidget:Widget with aMode:ShapeMode
Draw the handles (i.e. small black squares) in aWidget using aMode. AWidget is usually a window and aMode contains the rectangles to draw. By default, draw the handles in the upper left and lower right corners of the extent rectangle.
selectIn aWidget:Widget
Highlight the shape to indicate that it is selected. By default, the shape is the extent rectangle.
motion anEvent:Event with aMode:ShapeMode
Process the motion event generated during editing. AMode will contain the information on the current status of the editing operation.
buttonPress anEvent:Event with aMode:ShapeMode
Process the buttonPress event generated during editing. AMode will contain the information on the current status of the editing operation.
buttonRelease anEvent:Event with aMode:ShapeMode
Process the buttonRelease event generated during editing. AMode will contain the information on the current status of the editing operation.
keyPress anEvent:Event with aMode:ShapeMode
Process the keyPress event generated during editing. AMode will contain the information on the current status of the editing operation.
keyRelease anEvent:Event with aMode:ShapeMode
Process the keyRelease event generated during editing. AMode will contain the information on the current status of the editing operation.
getValues db:Dialogbox
Set the dialogbox db to the current settings of me. The db may vary depending on the actual type of shape to set the various attributes of the shape.
setValues db:Dialogbox
Update the settings of me based on the dialogbox db.
from start:Point to end:Point
Set the line so that the origin is at start and the end point is at the lower right corner of the extent rectangle.
lineWidth
REPLY Integer
Reply with the line width.
lineStyle
REPLY Integer
Reply with the line style.
fillStyle
REPLY Integer
Reply with the fill style.
lineWidth aWidth:Integer
Set the line width to aWidth. It should be a number greater than 0.
lineStyle aStyle:Integer
Set the line style to aStyle. Valid values include #solid, #dot, #dash or #dotdash.
fillStyle aStyle:Integer
Set the line style to aStyle. The style is 0-none, 1-solid or 2 to 37 for other filling patterns.
Reply with an arc of width w, height h, starting angle of newstart and a degreesOfArc of newdegrees.
ellipseWithWidth w:Integer height h:Integer
Reply with an ellipse of the specified dimensions.
circleWithRadius r:Integer
Reply with a circle of the given radius.
new
Reply with a circle of radius 50.
contains pt:Point
REPLY Boolean
Reply TRUE if the arc contains pt, no matter whether the arc is filled or not.
asString
REPLY String
Reply with the string representation of the arc in the form ``x@y w:h:begin:degree''.
arcmode
REPLY Integer
Reply with the arc mode.
arcmode aMode:Integer
Set the arc mode. Valid values for aMode include #pieslice or #chord. Arc mode is used in drawing filled arcs which have degreesOfArc less than 360. With #pieslice, the filled area is bounded by a line from the center to the beginning of the arc and a line from the center to the end of the arc. With #chord, the area is bounded by the arc and a line drawn from the beginning to the end of the arc.
origin orgPt:Point points anArray:Array
Reply with polygon with origin at orgPt and endpoint in anArray.
new
Reply with new line from 0@0 to 100@0.
asString
REPLY String
Reply with a string of the form ``[(x1@y1)(x2@y2)...(xn@yn)]''.
arrowStyle
REPLY Integer
Reply with arrow style.
arrowStyle aMode:Integer
Set arrow style to aMode. Valid values for aMode include #none, #all, #beginall, #endall, #beginend, #begin and #end. The 'all' in #all, #beginall and #endall refers to all line segments. For example, #beginall would place arrow heads at the beginning of each line segment. Since ABC draws curves as very short line segments, it is recommended that you use an arrowStyle of #none for curves.
polyStyle
REPLY Integer
Reply with polygon style.
polyStyle aMode:Integer
Set the polygon style to aMode. Valid values for aMode include #openline, #closedline, #opencurve and #closedcurve.
x newx:Integer y newy:Integer width w:Integer height h:Integer
Reply with a rectangle of the given position and dimensions.
pixelsToMm
Convert the rectangle of the given width and height in pixels to a similar rectangle measured in millimeters.
recStyle aStyle:Integer
Set the rectangle style to aStyle. Values values for aStyle include #squared and #rounded.
recStyle
REPLY Integer
Reply with the rectangle style.
corner
REPLY Point
Reply with the corner point.
surrounds rec:Rectangle
REPLY Boolean
Reply TRUE if rec is fully contained in me.
intersects aRec:Rectangle
REPLY Boolean
Reply TRUE if me and aRec overlap.
asString
REPLY String
Reply with a string of the form ``x@y;w:h''.
new
Reply with an empty Text item.
newText anArray:Array
Reply a text item as specified in anArray.
selectEmbedsIn aWidget:Widget
Highlight any embedded figures which have behaviors associated with them.
embeddedFigureAt aName:String
REPLY Figure
Reply with the embedded figure named aName. Otherwise reply NIL.
reset
Reset any embedded figures.
embedCount
REPLY Integer
Reply with the number of embedded objects on row row.
findFigureAt aPoint:Point
REPLY Figure
Reply with the figure which contains aPoint. Otherwise reply NIL.
addFont aStyle:Integer in aWidget:Widget
Change or add an embedded font at row and col. If the font at row and col is #bold or #italics and aStyle is #italics or #bold, respectively, then change the embedded font to #bolditalics.
addEmbed anObject:PartsList
Add the embedded object at row and col. AnObject should be either a
font or a Figure or a signal will be generated.
SIGNAL "Bad text embed object"
WidthOf aRow:Integer to aCol:Integer
REPLY Integer
Reply with the width of the characters on aRow from 1 to aCol. This measurement account for variable sized fonts and embedded figures.
heightOf aRow:Integer
REPLY Integer
Reply with the maximum height of aRow. This measurement includes any embedded figures.
hasText aString:String
REPLY Boolean
Reply TRUE if any of the text in the text object includes aString (case-insensitive).
drawCursorIn aWidget:Widget with aMode:ShapeMode
Draw the text cursor at row and col. AMode contains the triangle used for the text cursor.
isEmpty
REPLY Boolean
Reply TRUE if there is not text in me.
drawHandlesIn aWidget:Widget with aMode:ShapeMode
The resize handle for text is display at the lower left corner rather than the lower right. Clicking on it in edit mode will cycle between the font sizes.
setTextTo anArray:Array
Change the text to that stored in anArray.
drawIn aWidget:Widget from start:Integer to finish:Integer
Draw the text from row start to row finish.
setFontTo aFont:Font
Change the font to aFont.
asString
REPLY String
Reply with a string of the text with lines separated by newline characters. Also note that embedded figures will not be included but that ASCII values of 1 and 2 will be present in the string where these figures were found.
new
Reply with a rounded and shadowed button.
newText anArray:Array
Reply with a button of the specified text in anArray.
drawBorderIn aWidget:Widget
Draw the border rectangle.
drawShadowIn aWidget:Widget
Draw the shadow if shadow is TRUE.
new
Reply with an editor of 1 line and 10 characters which cannot expand.
reset
Clear the text from the editor.
enterIn aWidget:Widget
Display the text cursor.
leaveIn aWidget:Widget
Remove the text cursor.
new
Reply with the Bitmap icon which looks like a tree.
bitmap aName:String
Set the bitmap to aName.
drawHandlesIn aWidget:Widget with aMode:ShapeMode
Draw only the drag handle since a bitmap cannot be resized.
new
Reply with a new icon named ``New Icon''.
centerTitle
Recompute location of title and center it.
named name:String
Rename icon with name.
Options are available for numbering on the #left or #right of a vertical axis (for horizontal axes, use #left for top and #right for bottom) by setting numPlacement to these values. Similarly, tic marks are positioned using #left, #middle or #right by setting ticPlacement.
The format of the number labels are controlled by specifying labelFormat. This is a string which uses a format string like ``%5.1f'' or ``X = %f'' to display the number. For integer values use a format like ``%5.0f'' to eliminate the decimal point.
The major tic marks are drawn by specifying the number of divisions to break the axis into. For example, if you want 4 equal divisions for a scale from 0 to 100, specify 4. Tics will be drawn at 0,25,50,75 and 100. Similarly, the minor tic marks are drawn by specifying the number of divisions to break each major interval into.
Methods are also available for converting between millimeters and scaled
units. These can be used to plot points or lines on a graph or for
determining where a user clicked in scaled coordinates.
For additional functionality, refer to Type Shape.
new
Reply with a horizontal axis from 0.0 to 100.0.
scale aValue:Integer
REPLY Real
Converts aValue from millimeters to scaled units.
SIGNAL "Axis value out of bounds"
locate aValue:Real
REPLY Integer
Reply with location of aValue in millimeters.
drawIn aWidget:Widget startingAt aPoint:Point
Draw a portion of the image in aWidget. The upper left portion begins at aPoint in the image and includes width by height pixels.
image aName:String
Set the image to aName. Note that the image is an ABC object which contains the file name of the actual data. The image name is an internal ABC name. Thus you can have several images which use the same file but may be of different dimensions.
new
Reply with a table of 3 rows and 3 columns with 5 characters per editor.
positionEditors
Realign editors after resetting spacing, sizes etc.
setFontTo aFont:Font
Change the font of all the editors.
row r:Integer col c:Integer
REPLY Editor
Reply with the editor located at row r and column c. Use this when you want to get the string stored at a particular cell.
rows Rows:Integer cols Cols:Integer
Change the size of me to rows by cols.
new
Reply with a times, normal, 14 point font.
typeface tface:String style aStyle:Integer pointSize aSize:Integer
Reply with a font of the given characteristics.
widthOf aString:String from start:Integer to end:Integer
REPLY Integer
Reply with the width of the given substring based on the characteristics of me.
widthOf aString:String
REPLY Integer
Reply with the width of aString.
ascent
REPLY Integer
Reply with the vertical distance above the base line for me.
descent
REPLY Integer
Reply with the vertical distance below the base line of me.
height
REPLY Integer
Reply with the sum of the ascent and descent.
at imgname:String
Reply with the image stored in the image directory under imgname. Reply NIL if not found.
newImage aFileName:String
Reply with an image with filename aFilename.
load
Load the image file from disk into memory. Images are buffered in memory and may need to be reloaded due to storage requirements. This method is a way of explicitly loading the file.
setImageTo aName:String
Change the image name.
extentIn aRec:Rectangle
Set aRec to the size of the image.
x newx:Integer y newy:Integer
Reply with a point at newx@newy.
new
Reply with a point at 0@0.
movex newx:Integer movey newy:Integer
Set the point to the new position.
shiftx dx:Integer shifty dy:Integer
Shift the point by dx,dy.
belowRightOf pt:Point
REPLY Boolean
Reply TRUE if me is below (i.e. larger y) and to the right (i.e. larger x) of pt.
aboveLeftOf pt:Point
REPLY Boolean
Reply TRUE if me is above (i.e. smaller y) and to the left (i.e. smaller x) of pt.
above pt:Point
REPLY Boolean
Reply TRUE if me is above pt.
below pt:Point
REPLY Boolean
Reply TRUE if me is below pt.
leftOf pt:Point
REPLY Boolean
Reply TRUE if me is to the left of pt.
rightOf pt:Point
REPLY Boolean
Reply TRUE ifme is to the right of pt.
+ pt:Point
Add pt's x and pt's y to me.
- pt:Point
Subtract pt's xy and pt's y from me.
asString
REPLY String
Reply with a string of the form ``x@y''.
squaredDistanceFrom aPoint:Point
REPLY Integer
Reply with distance of me from aPoint squared.
distanceFrom aPoint:Point
REPLY Real
Reply with the distance of me from aPoint.