Article View: comp.windows.interviews
Article #799Re: defining a new graphic shape
From: John Vlissides
Date: Fri, 06 Nov 1992 13:56
Date: Fri, 06 Nov 1992 13:56
40 lines
2199 bytes
2199 bytes
In article <zen.721007140@texas>, you write:
> In Unidraw, there are pre-defined graphic shapes, such as rectangular
> and so on. Where are they defined? How can I define a new shape?
Unidraw defines such shapes both at the structured graphics level (in
include/Unidraw/Graphic) and at the component level
(include/Unidraw/Components). The structured graphics classes rely on
Painter's immediated mode interface to draw themselves, and the
components rely on structured graphics to define their appearance.
To define a new structured graphic, you basically subclass from Graphic
(or a subclass thereof) and redefine its draw and getExtent methods.
You must also redefine the graphics state setting and getting operations
(e.g., SetBrush) for graphics state that your subclass cares about. If
you want fine-grain hit detection, then you must also redefine the
contains and intersects operations. The Line class (in
include/Unidraw/Graphic/lines.h) provides a good example of what you
must do.
To define a new graphical component, you must
1. Define a subject by subclassing from GraphicComp (or a subclass
thereof).
2. Define a view by subclassing from GraphicView (or a subclass
thereof).
3. Define class identifiers for the new component subject and view
(see include/Unidraw/classes.h for an example).
4. Define a Creator subclass that can create instances of the new
component subject and view given their class identifiers (see
lib/Unidraw/creator.c for an example).
For more details, see the definition of LineComp and LineView in
include/Unidraw/Components/lines.h and lib/Unidraw/lines.h.
--
John Vlissides / IBM T.J. Watson Research / vlis@watson.ibm.com
Technical Details
Message-ID:
<9211061356.AA23278@aurora.watson.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!WATSON.IBM.COM!vlisShow Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!WATSON.IBM.COM!vlis From: vlis@WATSON.IBM.COM (John Vlissides) Subject: Re: defining a new graphic shape Message-ID: <9211061356.AA23278@aurora.watson.ibm.com> Sender: news@shelby.stanford.edu (USENET News System) Reply-To: vlis@watson.ibm.com Organization: Internet-USENET Gateway at Stanford University Date: Fri, 6 Nov 1992 13:56:05 GMT Lines: 40