Extensions to the canvas interface
The Slate adds a number of new methods to the canvas interface.
Some of these methods deal exclusively with complex items; others work
with both primitive and complex items. Here is an overview.
- 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.)
- call id method ?val? ...
- Call the "method" method on a complex item. All additional
arguments are passed to the method.
- component id ?component? ?method? ?val? ...
- Access components of a complex item. With just the id
argument, return a list of components of this item. If component
is supplied, return that component. If additional arguments are supplied,
call method on the component and return the result.
- 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.
- focusin
- Apply the focus to the canvas inside the slate.
- interact mode item ?val? ...
- This method is the switchboard for a number of interaction
commands. The structure of the interaction interface
will probably change, but the current set of commands is:
- create interactorclass ?val? ... : Create a new
interactor of the specified class.
- click id x y ?option? ... : Start a move interaction
sequence. If the options include the
-ghost
flag, create
a ghost of the item.
- drag id x y: Continue a move interaction sequence.
id does not have to be the same as the id specified in the
most recent click (this allows interaction to propagate to other
items if and when I ever get around to properly implementing a constraint
system). If id has a ghost, move the ghost; if not, move the
item.
- release id: Terminate a move interaction
sequence.id does not have to be the same as the id
specified in the most recent drag. If id has a ghost,
move the picture to the ghost's position and delete ghost; if not, just
clean up internal variables.
- 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.
- picture command ?val? ...
- This method is a switchboard for a bunch of commands related to
managing the item hierarchy. The set of commands is currently in flux.
- 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.
- region id canvas slate ?x0 y0 x1 y1?
- Get or set the region of an item. This is the same as
coords
, except that it treats every item as though
it were rectangular.
Back up
Tycho Home Page
Copyright © 1996, The Regents of the University of California.
All rights reserved.
Last updated: 96/12/11,
comments to: johnr@eecs.berkeley.edu