The EzWindows library

Reading: Ch. 3.9 and App. E as a reference

Please note:

The following notes were relatively incomplete as of classtime. Since this point in time, we have created more complete documentation for the EzWindows library. We strongly recommend that you use that documentation rather than the remainder of this page.

To continue developing our use of interesting objects, we will experiment a bit with a graphics library provided by the authors of our textbook. This library is known as EzWindows and has been installed on our department machines. Please note that this is not part of the standard C++ libraries but instead has been designed by the authors for instructional purposes. Programming Note: If you are trying to do any of your programming without use of your department account, you will not be able to use EzWindows (unless you install it yourself).

The EzWindows library is initially discussed, in part, in Chapter 3.9 of the text, and discussed in a variety of places later in the text as well. Appendix E of the text (starting at page 891) gives more complete and organized documentation of the entire package. Be warned that that documentation is more complete than we need; we will only be discussing a subset of the library functionality. But still it gives a nice overview if scanned.


Preliminaries

The graphical system is based on the use of a coordinate system for which the origin is at the top-left corner. The positive x-axis is to the right, and the positive y-axis is downward (note the difference in orientation between this common computer science convention and the common mathematics conventions).

The unit of measure is centimeters (or fractions thereof). Of course, this may be only approximate depending on the system.

A color type has been defined to include a palette of common colors, identified with the names: Black, White, Red, Green, Blue, Yellow, Cyan, Magenta


class SimpleWindow

The first class we will discuss is that of a SimpleWindow which is a window which can be placed on the screen. All of the other graphical primitives must be associated with such a window in order to be created or displayed.

attributes (i.e. data members)

type identifier semantics
string title title which appears at the top of the displayed window
float width the width of the window, measured in centimeters (approx)
float height the height of the window, measured in centimeters (approx)

actions (i.e. member functions, methods)

return type method name parameters semantics
SimpleWindow ( ) Default constructor. Creates an 8x8 window titled "Untitled"
SimpleWindow (string title, float width, float height) Alternate Constructor used to specify parameters
Open ( ) Opens the window on the system display
Close ( ) Closes the window from the system display

class RectangleShape

There are many different primitive shapes which can be created and displayed. One such example is that of a rectangle.

attributes (i.e. data members)

type identifier semantics
float Width the width of the rectangle, measured in centimeters (approx)
float Height the height of the rectangle, measured in centimeters (approx)
color Color the color of the rectangle, chosen from the available "color" type
bool Border a true/false value which is true if the border is on, and false if the border is off. By default, a newly constructor rectangle has a border on
Position center the (x,y) coordinates of the center of the rectangle

actions (i.e. member functions, methods)

return type method name parameters semantics
Draw ( ) Draw's the rectangle on the associated window based on its current settings. Please note, this does not explicitly remove any previous rendering of the rectangle
Erase ( ) Erase's the image of the rectangle from the associated window based on its current settings.

Last modified: Tuesday, 08 February 2005