As described above, the responsibility for the contents of an instance of window relies on the programmer. To aid the programmer in making graphics, Guienv defines a number of patterns for drawing lines, rectangles (with sharp or round corners), ovals, wedges and polygons.
FigureItem is a subpattern of windowItem and inherits as such all its functionality (including the event handling possibilities) and defines the basic properties that are shared by all figure items. A figure item have a pen to be used for drawing the item. The pen defines attributes for defining the drawing pattern, the foreground and background colors, and the size of the pen (a rectangle).
Line is a straight line and defines the attributes start and end for accessing and changing the end-points of the line.
Shape is used as superpattern to all figure items that are defined by means of a rectangle and can be filled. Shape contains a fill attribute which defines the facilities for filling the shape (i.e. the tile pattern and the foreground and background colors to be used for the fill).
Rect is a real figure item in the sense that it is extending all figureItem procedures such that an instance of rect can be properly drawn in a window. |
||
RoundRect is like rect, except that it also defines roundness to takes two integers, defining the round corners by defining the width and height of the oval in the corners. If R is an instance of roundRect, then
defines the rectangle seen here. |
||
Oval is also like rect except that an oval is drawn. |
||
Wedge is like oval, except that it also defines startAngle and endAngle which takes one integers, defining the start and end angles of the arc. If A is an instance of wedge, then
defines the wedge seen here. |
||
Polygon is a figure item that consists of a collection of connected line segments. The points defining the polygon is specified by:
|
Drawing using figure items is as simple as:
ORIGIN '~beta/guienv/guienv'; INCLUDE '~beta/guienv/figureitems' --- program: descriptor --- guienv (# aWindow: @window (# go: @oval (# open:: (# do (100, 100)->position; (50, 100)->size; 7->pen.size #) #); eventhandler:: (# onAboutToClose:: (# do terminate #) #); open:: (# do (100, 100)->position; (300, 300)->size; 'oval'->title; go.open #) #) do aWindow.open #)
This creates a window with an oval, positioned in (100, 100) and with the oval drawn using a 7x7 sized pen.
Lidskjalv: User Interface Framework - Tutorial | © 1995-2004 Mjølner Informatics |
[Modified: Friday October 27th 2000 at 14:56]
|