The functions in this section can be used for plotting data on an Xwindow display. The basic idea of these functions is that you create a window with the w_make_window command and then can add various features to the window. The most important features are boxes and buttons. A scale box can be used to create a virtual coordinate system on the window on which points, lines, rectangles and polygons can be drawn. A text box can be used to create a box in which text can be written. A button can be used along with the input functions to get information back from the window. In all the functions in this section colors are specified by one of w_black, w_white, w_red, w_blue, w_green, w_cyan, w_yellow, w_magenta, w_pink, w_light_green, w_light_blue, w_purple, w_gray, w_dark_gray, or w_orange.
display {[char]}
The display variable inherited from your environment.
w_make_window((offset, size), title, background_color, display)
{(((int, int), int, int), [char], int, [char], stream) w_window}
Makes an X window on the specified display with the given offset,
size, title, and background color.
Note that windows get automatically closed when you return to top-level. This means that you cannot return a window to top-level and then use it--you must create it and use it within a single top-level call.
w_kill_window(win) {w_window bool}
Kills a window created by w_make_window.
w_add_box((offset, size),
(voffset, vsize), name, color, window)
{(((int, int), int, int), ((float, float), float, float), [char], int, w_window) (w_window, w_box)}
Creates a scaled box on the specified window, which can be used to
draw into using the various drawing commands. The position and size
of the box within the window are specifed by offset and size. The
virtual coordinates of the box are specified by the virtual offset
(voffset) and the virtual size (vsize). The color specifies
the background color. The function returns a pair whose first element
in the modified window structure and whose second element is the newly
created box. Technically this box is not necessary since it can be
retrieved with w_get_named_box.
w_add_text_box((offset, size), name, color, window)
{(((int, int), int, int), [char], int, w_window) (w_window, w_box)}
Create a text box on the specified window with the given offset, size
and color. Such a box can be used in conjunction w_write_paragraph,
w_write_text_centered or w_write_text_left. These will
all write text into a text box.
w_add_button((offset, size), name, color, window)
{(((int, int), int, int), [char], int, w_window) w_window}
Adds a button to a window. The name is printed across the button
and is also the name that is returned by w_get_input and
related functions if the button is pressed.
w_add_button_stack((offset, size, separation), names, color, window)
{(((int, int), (int, int), int, int), [[char]], int, w_window) w_window}
Adds a stack of buttons. The separation is specified as an x and y
distance (e.g. if the x distance is 0, then the buttons will vertical).
names is an array of button names.
w_add_text(position, text, color, window)
{((int, int), [char], int, w_window) w_window}
Adds a single text string to a window at the specified position. The
function w_add_text_box is often more convenient.
w_get_named_box(name, window) {([char], w_window) w_box}
Returns the box of the specified name from a window.
w_reset_box_size(boxname, (voffset, vsize), window)
{([char], ((float, float), float, float), w_window) (w_window, w_box)}
Resets the virtual coordinates of a scaled box inside of a window.
You need to pass this command the name of the box rather than the box itself.
Like w_make_box, it returns both the new window structure and a new box.
This command does not clear the current contents of the box.
w_clear_box(box) {w_box bool}
Clears the contents of a box.
w_bounds_from_box(box) {w_box ((float, float), float, float)}
Returns the virtual coordinates of a scale box.
w_box_scale(box) {w_box float}
Returns the ratio of the size of a box in pixels to the size in
the virtual coordinate system.
w_bounding_box(points) {[(a, a)] ((a, a), a, a) :: (a in number)}
For a set of points this function returns a bounding box (the smallest box
that contains them all). The bounding box is specified as a pair in
which the first element is the (x,y) coordinate of the lower left corner
and the second element is a pair with the width and height.
w_draw_point(point, color, box) {((float, float), int, w_box) bool}
Draws a point in a box based on the virtual coordinates.
w_draw_big_point(point, size, color, box) {((float, float), int, int, w_box) bool}
Draws a big point in a box based on the virtual coordinates.
The point size is specified by an integer (pixels).
w_draw_points(points, color, box) {([(float, float)], int, w_box) [bool]}
Draws a sequence of points in a box based on the virtual coordinates.
w_draw_segments(endpoints, width, color, box)
{([((float, float), float, float)], int, int, w_box) bool}
Draws a sequence of line segments in a box based on virtual coordinates.
Each line-segment is specified as a pair of points.
The width argument specifies the width of the lines in pixels.
All segments that go ouside of the box are clipped.
w_draw_string(point, string, color, box) {((float, float), [char], int, w_box) bool}
Draws a text string in a box at the position specified by point
in virtual coordinates.
w_draw_rectangle((offset, size), width, color, box)
{(((float, float), b, a), int, int, w_box) bool :: (a in number; b in number)}
Draws a rectangle in a box based on the virtual coordinates.
This function clips any part of the rectangle that goes outside the box.
The width specified the width of the lines.
w_shade_rectangle((offset, size), color, box)
{(((float, float), b, a), int, w_box) bool :: (a in number; b in number)}
Shades a rectangle in a box based on the virtual coordinates.
This function clips any part of the rectangle that goes outside the box.
w_shade_polygon(points, color, box) {([(float, float)], int, w_box) bool}
Shades a polygon in a box based on the virtual coordinates.
The polygon is specified as a sequence of points.
This function clips any part of the polygon that goes outside of the box.
w_write_text_centered(text, color, text_box) {([char], int, w_box) bool}
Writes text into a text box such that the text is centered
both horizontally and vertically.
w_write_text_left(text, color, text_box) {([char], int, w_box) bool}
Writes text into a text box such that it is against the left end of
the box and centered vertically.
w_write_paragraph(text, color, text_box) {([char], int, w_box) bool}
Writes a paragraph into a text box starting at the top left hand corner
of the box and does line wrapping so the text will not go outside of the
right margin of the box. Line breaks are ignored although the @ character
can be used to force a line break.
w_get_input(window) {w_window ([char], [char], (float, float), (int, int), char)}
Gets input from a window. It returns a tuple of the form
(event_type,name,position,flags,char). The event_type
is one of "button","key","box", or "none" depending on the event.
The "box" event in evoked if you click the mouse inside of a box.
The name is the name of the box or button on which the event took place.
The position specifies the the virtual coordinate on which a "box"
event took place.
The flags specify whether control and shift keys were pressed.
The character specifies the key pressed in the case of a "key" event.
This function blocks until an event takes place.
w_get_input_noblock(window)
{w_window (bool, [char], [char], (float, float), (int, int), char)}
This is the same as w_get_input but does not block. It returns
an additional flag at the begining, which specifies if
an event was found.
w_get_button_input(window) {w_window [char]}
This function only picks up button events and throws away all other
events. It returns the button name.
w_get_zoom_box(pt, width, box)
{((float, float), a, w_box) ((float, float), float, float) :: (a in any)}
This function allows to to use an elastic band to pick out a region
of a box. It is typically used in conjunction with w_get_input. In
particular, if the input returned by w_get_input is a mouse click on a
particular box (down click) the position of the click and the box can
be passed to this function which will then return the other corner
(the corner on which the user lets go of the mouse). This function
actually returns the lower left and upper right corners of the region.
The width specifies the width in pixels of the elastic band.