oster@dewey.soe.berkeley.edu (David Phillip Oster) (09/23/87)
The way the problem of non-square buttons is solved on the Macintosh is two-fold. First, there is a collection of subroutines for manipulating arbitrary sets of polygons (drawing them, rescaling them, checking if a point is inside, doing union, intersection, set difference.) The internal representation is a Ycoordinate sorted list of Xcoordinate sorted list of pixels that are inside the set of polygons. However, some shapes (like those of icons) are too jagged for this representation to be efficient. In these cases, a bit map (called a "mask") is used to give the shape of the object against the icon. Now, suppose you want to see if a mouse coordinate point is inside one of these little monsters. 1.) check to see if the point is inside the bounding rectangle. 2.) if it is, check to see if it is inside the actual object. In the case of the set of polygons, the way you do this is obvious given the internal representation. In the case of a bitmap, you just translate the point into the local coordiantes of the bitmap, and see if that bit is on. In either case, if the mouse point is in the widget, you consume the mouse point. If it is not in this widget, you pass the point on to any object that may be under you. --- David Phillip Oster --My Good News: "I'm a perfectionist." Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour." Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu
jg@jumbo.dec.com (Jim Gettys) (09/23/87)
Note that the V11 X library comes with a set of region code; your application can use it for computing if a mouse hit is in a region or for computing regions for later graphics output. GC's on V11 also support region clipping; you can restrict output to an arbitrary region on the screen. These regions can be computed by your application, and set into a GC, or can be generated by graphics operations to a single plane pixmap (bitmap) and set into the GC. Once set, all graphics operations using that GC will be clipped to the region. -, g1