Up: W3Kit Class Reference

W3PostScript

Superclass: W3Input

An abstract W3Kit base class for 2D PostScript graphics. The main subclass methods are drawPostScript, mouseClick:, and mouseDrag:.

Conventions for Graphics and Events

If the image size is w-by-h pixels, then the initial coordinate system for PS drawing puts the corners at the following coordinates:
		(0,h)------(w,h)
		  |          |
		(0,0)------(w,0)
(These initial coordinates are not the same as raw device coordinates, which should be avoided since they are not consistent across DPS platforms.)

By default, a W3PostScript widget only receives mouse click events; these are the only events supported by the HTML 2.0 standard. In HTML 3.0, however, general pen input is supported, and such events can be enabled by including W3_MOUSEDRAG_MASK in the event mask.

#define W3_MOUSECLICK_MASK 0x0001
#define W3_MOUSEDRAG_MASK 0x0002
(Warning: The HTML 3.0 features are currently incompletely emulated, using non-standard, undocumented features of X Mosaic.)

Transforms

The "essential state" of the PostScript drawing area consists of the image size, and the user-to-device coordinate transform. (This user transform is a 3-by-2 matrix, forming the first two columns of a 3-by-3 matrix which acts on homogeneous row vectors by right multiplication; the implied third column is [0 0 1].)

The default user coordinate system is in pixel units, with the origin in the lower left corner, x-axis pointing right, and y-axis pointing up.

Note: setDrawOrigin:: moves the user point (x,y) to the lower left corner of the view, while setDrawSize:: scales the user coordinate system, fixing its origin, so as to make the view frame just fit into an x-by-y user rectangle. These two methods are not intended for use inside drawPostScript. Use PS operators there, protected by PSgsave() and PSgrestore().

- setIntSize:(const IntSize *)theSize;
- getIntSize:(IntSize *)theSize;
- transformUser:(float [6])moveUser;
- transformDevice:(float [6])moveDevice;
- convertPointUser:(const Point2 *)userPt toDevice:(Point2 *)devPt;
- convertPointDevice:(const Point2 *)devPt toUser:(Point2 *)userPt;
- getBounds:(Rect2 *)theRect;
- setDrawOrigin:(float)x :(float)y;
- setDrawSize:(float)width :(float)height;
- translate:(float)x :(float)y;
- scale:(float)x :(float)y;

Events and Display

Override these in your subclass to customize appearance and event response. Note that all event data is delivered in the PostScript user coordinates.
- drawPostScript;
- mouseClick:(const Point2 *)aPoint;
- mouseDrag:(const Path2 *)path;
- (unsigned int)eventMask;
- setEventMask:(unsigned int)mask;
Different ways to route the output of drawing.
- printHtml;           // print HTML for inlining the image
- display;             // send out-of-line image back to user and exit
- snapshotDocument;    // capture image in a W3Document (returned)
- postScriptDocument;  // capture PS code in a W3Document (returned)
This can be used at the beginning of -drawPostScript to clear the image to white, and set the drawing color to black.
- clearPostScript;
Subclasses can override this to adjust their alignment in the layout, relative to other widgets. The default value is "top".
- (const char *)htmlAlignment;
On some systems, it is possible to adjust the image depth.
- setImageBitDepth:(int)bits;
- takeImageBitDepthFrom:sender;

DPS Hit Detection and Incremental Drawing

If you need to perform DPS functions outside of drawPostScript, surround them with the matched pair of messages below. This can be useful e.g. if you want to use DPS for complicated hit detection inside mouseClick:.

(Note that the return value of lockFocus is NOT a success flag. It merely indicates whether focus has already been locked on this widget. The call to lockFocus should be balanced with an unlockFocus in any case.)

- (BOOL)lockFocus;
- unlockFocus;


Up: W3Kit Class Reference

[HOME] The Geometry Center Home Page

Author: Paul Burchard
Comments to: webmaster@geom.umn.edu
Created: Apr 18 1994 --- Last modified: Tue Jun 18 10:43:18 1996