An Overview of Slate Methods

The Slate class builds on the complex item support of the IncrCanvas class, to add more complex forms of item manipulation and support for user interaction. This document is an overview of its methods.

Auxiliary items

This set of methods creates and deletes "auxiliary" items for purposes like highlighting.

ghost tag ?tag?...
Create a "ghost" item for use when moving items. If the first argument is a tag representing multiple items, a complex item containing a ghost for each item is produced. Complex items can provide a ghost method to override the default behaviour.

highlight tag ?tag?...
Create a "highlight" item around the specified item or items. If the first argument is a tag representing multiple items, a highlight item is created for each item of those items. Complex items can provide a highlight method to override the default behaviour. Each created item is tagged with "highlight" and "highlight.id", where id is the item it highlights, and any additional arguments to this method.

unhighlight tag
Delete the highlight items of all items matching the argument.

Shape

This set of methods deals with the "shape" of an item. The shape of a canvas item is generally the same as its type (rectangle, oval, polygon, line). The shape of a complex item is given by the value it sets for its internal common variable called "shape."

aspect id ?aspect? ... ?-region?
Return aspect coordinates as a flat x-y list. An aspect is a named point on an item, such as origin or center or ne. The aspects of an item depend on its type. If the -region flag is supplied, treat the item as a rectangular item regardless of its real shape. To query legal aspects, call with no argument, and a list of legal aspects will be returned. (Note that the legal aspects are not necessarily constant over the lifetime of an item -- for example, adding a vertex to a polygon will also add an aspect.)

region tag ?x0 y0 x1 y1?
Get or set the region of an item. If the first argument is a tag, use the first matching item. This is the same as coords, except that it treats every item as though it were rectangular.

shape id ?method? ?region?
Get the shape of an item. The following arguments are intended only for the Slate's internal use.

Moving items

This set of methods moves items.

align where ?tagOrID ... ?
Align items. The where argument specifies the alignment, and can be one of left, center, right, top, middle, or bottom. Not implemented.

move tag x y
Move an item or items the specified amount. Any highlights created with the highlight method are also moved.

moveclick tag x y ?args?
Start a move interaction sequence at coordinates (x, y). Additional arguments include various flags that may be supplied by the interactors that the slate uses to affect the behavior of items, such as -ghost, which says that an item is to be moved or reshaped using a "ghost" outline.

movedrag tag x y
Continue a move interaction sequence with (x, y) as the new cursor position.

moverelease tag x y
Terminate the interaction sequence at coordinates (x, y), x and y will usually be the same as the last coordinates passed to the drag mode.

moveto tag x y ?aspect?
Move the point of an item denoted by aspect to the absolute location (x, y). If tag denotes more than one item, treat the set of items as a rectangle. (In this case, aspect must of course be legal for rectangles.) If aspect is omitted, it defaults to center.

Reshaping items

This set of methods reshapes items.

reshape id x y ?-region? ?aspect ...?
Reshape an item. All listed aspects are moved the distance given by x and y. If the -region flag is present, the item is treated as a rectangle regardless of its actual shape.

reshapeclick id x y ?aspect? ...
Start a reshape interaction sequence at coordinates (x, y). Additional arguments include various flags that may be supplied by the interactors that the slate uses to affect the behavior of items, such as -ghost, which says that an item is to be moved or reshaped using a "ghost" outline.

reshapedrag id x y
Continue a reshape interaction sequence with (x, y) as the new cursor position.

reshaperelease id x y
Terminate the interaction sequence at coordinates (x, y). x and y will usually be the same as the last coordinates passed to the "drag" mode.

reshapeto tag x y aspect
Reshape an aspect of an item to the given absolute coordinates.

Interactor support

This set of methods supports the Interactor classes.

interactor class ?args? ...
Create an interactor of the given class and return it. This is just a convenient interface to the interactor constructors.

select tagOrIDid ?id ...?
This method extends the select method of the IncrCanvas superclass, adding some modes to allow multiple items to be in the selection. (The superclass method only allows a region of a single text item to be in the selection.) Each selected item is tagged sel. The new modes are:

selector ?method? ?arg ...?
Access the slate's default Selector interactor, creating one if it does not exist. With no arguments, return the selector interactor; with arguments, call method on selector with the given arguments.

Cloning

This set of methods deals with describing and reproducing items on the slate. They are still experimental.

describe id
Return a string that "describes" an item. This string can be given back to the recreate command to re-create or clone the item.

recreate description ?-move x y? ?-at x y? ?-coords x0 y0 ... ? ?-in id?
Re-create an item from a string returned by the describe method. The various options allow the item to be created at a different position on the canvas, or as a child of some other item.

Back up
Tycho Home Page


Copyright © 1996-1998, The Regents of the University of California. All rights reserved.
Last updated: 06/08/98, comments to: johnr@eecs.berkeley.edu