CS476/576
Assignment #2
Due Midnight,
Wednesday
Oct. 8, 2003
Write an X lib/Motif
program with the following descriptions:
NAME
drawPolygons -
A simple polygons drawing program
SYNOPSIS
drawPolygons [-n]
[-q]
DESCRIPTION
Initially, the
interface
looks like the one given in Fig. (A) with a drawing
area and a QUIT
button.
If the user clicks at position (x,y)
inside
the drawing area it draws:
- A solid circle (call
it node) centered
at
(x,y).
- A line
connecting the current node to the previous node as shown in Fig. (B).
- If the user clicks
back on the very first node, i.e., the ploygone is completed, the QUIT
button is replaced with two buttons: a QUIT
button and a Repeat
button as
shown in Fig. (C). During
that phase, if
the user clicks inside the drawing area, the program rings
a bell and does not draw as usual. If the user clicks on the Repeat
button, the
drawing area is cleared and the program returns back to the
normal operation as shown in
Fig. (A).
If
the user clicks on a QUIT
button, the program exits.
The program accepts two options*:
-n This will number
the nodes 1, 2, .... as shown in Fig. (D).
-q If the user clicks on
a QUIT button, it will be replaced with two
buttons:
OK
and Cancel
as shown in Fig. (F). During that phase, if
the user clicks inside
the drawing area, the program rings
a bell and does not draw as usual.
If the user clicks on the OK
button, the program exits.
If the user clicks on the
Cancel button the program returns back to the
previous state before clicking on the QUIT button.
*
For CS476 students: You
may not implement these two options.
See
sample solution under:
/home/cs476/public_html/fall03/assignments/a2/wahab/drawPolygons
Fig.
(F)