| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (14 out of 18)

Editing Icons Textually

An icon exists as a textual description of its appearance. This description is the value of the Icon-description attribute of the icon's class definition. The Icon Editor translates an icon's description into graphical form, and allows you to edit the icon definition graphically, as described earlier in this chapter.

Alternatively, you can edit an icon's definition textually, either creating it from scratch, or modifying it as desired. Textual icon editing can be useful, because the Icon Editor does not allow you to modify graphical elements once you have created them; textual editing allows any type of modification.

Thus you can use the Icon and Text Editors together to define an icon. The Icon Editor establishes the icon's overall properties and shows its current appearance; the Text Editor allows modifications that fine-tune the icon to have precisely the desired look.

Icon Description Language Example

A simple icon description consists of:

For example, the following figure shows the layers pad, icon viewer, and text description of the icon shown in the Icon Editor in the beginning of this chapter:


The following figure shows examples of many of the elements that an icon description can contain. Each element appears in both Icon Editor and textual form. Each layer belongs to a region whose name is the type of graphics drawn on the layer.


Icon Description Language Grammar

This section describes the grammar of the icon description language. You don't need to study this grammar unless you intend to edit icons textually. When studying the grammar, you can skip over any sections that do not relate specifically to your needs. See the preceding figure for help in interpreting this grammar.

The optional icon-background-layer section is described under Specifying an Icon Background Layer. The optional variables section is described in Animated Icons and subsequent sections.

	graphic-definition :=
point-definition |
line-definition |
segmented-line-definition |
arc-definition |
outlined-rectangle-definition | filled-rectangle-definition |
outlined-circle-definition | filled-circle-definition |
outlined-polygon-definition | filled-polygon-definition |
text-definition |
image-definition
The width and height can each be set to a maximum of 1000.

The various graphic-definitions are based on a small number of primitives which they use in ways that are sometimes nonobvious. The rest of this section gives details. All numeric coordinates (x, y) are integers (not integer expressions) in workspace units measured from the upper left corner of the icon, whose coordinates are (0,0).

Specifying Points

The coordinates specify the location of the point.

Specifying Lines

The two pairs of coordinates specify the beginning and end of the line.

Specifying Segmented Lines

Each coordinate pair specifies the location of one vertex of the segmented line.

Specifying Arcs

The first, second, and third coordinate pairs denote the first, second, and third points that you click to define an arc with the mouse. The arc is a circular section that extends from the first point through the second point to the third point.

Specifying Outlined Rectangles

The four coordinate pairs specify the four corners of the rectangle.

Specifying Filled Rectangles

The two coordinate pairs specify the upper left and lower right corners of the rectangle.

Specifying Outlined Circles

The three points denote an arc that, when completed, forms the circle. The same three points, given in order to an arc definition, would produce the underlying arc.

When you specify an outlined circle definition textually, you can give any three points on the circumference of the circle.

When the Icon Editor generates the three points of an outlined circle definition from graphical input (via the Circle or Filled Circle button), the points specify a semicircular arc that opens downwards. If the center of the circle is at (XC, YC) and the radius is R, the three points are (XC-R, YC) (XC, YC-R) (XC+R, YC). Inversely, if the three points are (X1, Y1), (X2, Y2), and (X3, Y3), the center of the circle is (X2, Y1) and the radius of the circle is (X3-X1)/2.

Specifying Filled Circles

The three points are the same as those in an outlined-circle-definition.

Specifying Outlined Polygons

Each point specifies the location of one vertex of the polygon.

Specifying Filled Polygons

Each point specifies the location of one vertex of the polygon.

Specifying Text Components

The elements of the definition are:

Including External Images

The image-name is a symbol that is the name of an image definition object. The coordinates give the offset of the upper left corner of the image from the upper left corner of the icon.

Using the Icon and Text Editors Together

To use the Icon and Text Editors together, invoke them both on the same icon description, and position them so that both are fully visible. You can now use either editor to examine and change the icon, and the other editor to see the effect of the changes.

The two editors function independently even when you use them on the same icon. Neither editor knows what happens in the other, or is aware of changes saved by the other. After you save changes made in either editor, you must close and reopen the other editor to show the changes there also.

Be careful not to make concurrent changes in both editors, or the changes saved by one editor will be overwritten when you save the changes made in the other.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (14 out of 18)

Copyright © 1997 Gensym Corporation, Inc.