Appendix D. The Icon Description Language
Prev |  | Next

## Appendix D. The Icon Description Language

Use IconSmith to draw your icons. To learn how to use IconSmith, see Chapter 12, “Using IconSmith”. After you draw your icon, include it in the FTR file using the ICON rule described in Chapter 13, “File Typing Rules”. IconSmith writes the ICON rule for you using the icon description language. This appendix describes the icon description language that IconSmith uses to write the ICON rule. This information is provided for completeness. Do not try to write the ICON rule directly in the icon description language.

The icon description language is a restricted subset of the C programming language. It includes line and polygon drawing routines from the IRIS Graphics Library™ (GL), as well as some additional routines that are not in the GL. The description routine for a given icon is similar in structure to a C subroutine without the subroutine and variable declarations. The valid symbols and functions in the icon description language are described below.

## Operators

You can use these C language operators in an icon description routine:

    +
    -
    *
    /
    &
    |
    ^
    !
    %
    =
    ( )
    { }

You can use these C language conditional operators in an icon description routine:

    &&
    ||
    ==
    !=
    <
    >
    <=
    >=

## Constants

You can use these logical constants in an icon description routine:

    true false

## Variables

The following icon status variables are set by the Desktop. You can use them in an icon description routine:

    opened located selected current disabled

These variables have values of either true or false. You can use them in a conditional statement to alter the appearance of an icon when it has been manipulated in various ways from the Desktop.

You can use other legal C variables in an icon description routine, without a declaration; all variables are represented as type float. Any variable name is acceptable, provided it does not collide with any of the predefined constants, variables, or function names in the icon description language.

## Functions

The icon description functions comprise, for the most part, a very restricted subset of the C language version of the IRIS Graphics Library, modified for 2-D drawing. Table D-1 for a list of all the icon description functions.

Table D-1. Icon Description Functions

Function | Definition
--- | ---
arc(x, y, r, startang, endang) | Draw an arc starting at icon coordinates x, y; with radius r; starting at angle startang; ending at angle endang. Angle measures are in tenths of degrees.
arcf(x, y, r, startang, endang) | Like arc, but filled with the current pen color.
bclos(color) | Like pclos, but uses color for the border (outline) color of the polygon.
bgnclosedline() | Begin drawing a closed, unfilled figure drawn in the current pen color. Used in conjunction with vertex and endclosedline.
bgnline() | Like bgnclosedline, except the figure is not closed. Used in conjunction with vertex and endline.
bgnoutlinepolygon | Begin drawing a polygon filled with the current pen color. The polygon is outlined with a color specified by endoutlinepolygon. Also used in conjunction with vertex.
bgnpoint() | Begin drawing a series of unconnected points defined using calls to vertex. Used in conjunction with vertex and endpoint.
bgnpolygon() | Like bgnoutlinepolygon except the polygon is not outlined. Used in conjunction with vertex and endpolygon.
color(n) | Set current pen color to color index n.
draw(x, y) | Draw a line in the current color from the current pen location to x, y.
endclosedline() | Finish a closed, unfilled figure started with bgnclosedline.
endline() | Finish an open, unfilled figure started with bgnline.
endoutlinepolygon(color) | Finish a filled polygon started with bgnoutlinepolygon and outline it with color.
endpoint() | Finish a series of points started with bgnpoint.
endpolygon() | Finish a filled, unoutlined polygon started with bgnpolygon.
for (expr; expr; expr) expr | Note that shorthand operators such as ++ and -- are not part of the icon description language, so longer hand expressions must be used.
if (expr) expr [ else expr ] | Standard C language if-statement.
include("path") | Tell the Desktop to find the icon geometry in the file with pathname path.
move(x, y) | Move current pen location to x, y.
pclos() | Draw a line in the current pen color that closes the current polygon, and fill the polygon with the current color.
pdr(x, y) | Draw the side of a filled polygon in the current pen color, from the current pen location to x, y.
pmv(x, y) | Begin a filled polygon at location x, y.
print(expr or "string") | Print the value of the expression expr or string to stdout; used for debugging.
vertex(x,y) | Specify a coordinate used for drawing points, lines and polygons by bgnpoint, bgnline, bgnpolygon, and so forth.

Prev | Table of Contents | Next
Appendix C. Online Help Examples |  | Appendix E. Predefined File Types