🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #571

Re: Unidraw Help - using combined components

#571
From: John Vlissides
Date: Wed, 02 Sep 1992 13:04
61 lines
3061 bytes
In article <epovazan.714660172@sun-4>, you write:

> 1) Is it a good idea to use this easy combining of components when I
>    will need to be able to move the component around interactively and
>    also be able to edit the text.

Your GraphicComps subclass will already know how to respond to the
MoveTool, so the ability to move the component interactively will
require no extra work (assuming you've defined its IsA operations
correctly; see below).  However, editing the text will require some
new code.  See how MessageView creates and interprets manipulators for
the Reshape tool in src/bin/ibuild/ibmessage.c for an example of how
to implement such interaction.

> 2) Can I make this node component a "GraphicCompTool".  Will it be
>    able to move itself with the move tool etc.  I'm doing something
>    wrong here as I keep getting a core dump just before the
>    application windows draws itself.

A GraphicCompTool creates a copy of the prototypical component you
give it, lets you place it interactively, and finally pastes the copy
into the drawing being edited.  It doesn't make sense to "make [the]
NodeComp a GraphicCompTool."

Your coredump is probably the result of creating graphics without
specifying a complete set of graphics state. For example, your
NodeComp constructor instantiates a PinGraphic and an SF_Circle
without setting their graphics state (either by passing them a graphic
like stdgraphic from which to copy graphics state or by calling
SetColors, SetBrush, etc. explicitly).

Also, your IsA operations should call the corresponding parent
operation.  For example, write

    virtual boolean NodeComp::IsA (ClassId id) {
        return NODE_COMP == id || GraphicComps::IsA(id);
    }

not

> virtual boolean NodeComp::IsA(ClassId id) {
>     return NODE_COMP==id;
> }
>

(This isn't causing the coredump, but it will keep predefined objects
from being able to interact with your NodeComp/NodeView.

> 3) Exactly how are the tool icons drawn.  I've looked at the Punidraw
>    example and I'm not sure how the icons are drawn.

PanelControls (the buttons in the tool palette) take a ControlInfo
object, which defines the button's appearance.  You can specify either
a string or a graphical component to define this appearance.  For
example, you might pass an instance of NodeComp to the ControlInfo if
it can serve as a satisfactory icon, or you might pass it a
StencilComp containing a special bitmap that better depicts the
NodeComp's function, etc.

--
John Vlissides / IBM T.J. Watson Research / vlis@watson.ibm.com
Technical Details
Message-ID: <9209021304.AA20345@aurora.watson.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!WATSON.IBM.COM!vlis

Show 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: Unidraw Help - using combined components
Message-ID: <9209021304.AA20345@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: Wed, 2 Sep 1992 13:04:47 GMT
Lines: 61