[comp.sys.mac.programmer] Gophers and drawing objects

fjlim@garnet.berkeley.edu (09/23/89)

	[Discussion of how to organize a drawing program using
	the THINK Class Library (TCL)]

- Making drawn objects subclasses of CPane or CView

First of all, it is not possible (without overriding a lot of methods)
to place anything other than a Pane within another Pane. Thus drawn
objects can't be descendents of CView directly, they would have to be
subclassed off CPane.

Secondly, I strongly recommend againts making drawn objects subclasses
of CPane for performance reasons. The TCL uses a linear list for
storing the subviews of a Pane. It performs a linear search of this list
to determine which subview contains a mouse click. This could get
pretty slow with a lot of drawn objects. Also, each Pane has its own
drawing environment, coordinate system, and clipping region which
must be set up before displaying it. This takes time and is definitely
overkill for most drawn objects.

A good programmer will be able to devise a better way of handling
drawn objects. The choice will depend on how complicated the objects
are and what kind of manipulations can be performed on the objects.
In many ways, the situation is similar to a database. Just as
Technote #203 advises that the Resource Manager is not a database,
I advise that the subview management in the TCL should not be used
for handling graphical drawing objects.

- No real support for the CDirector::itsGopher variable

The TCL was designed to handle to the base case where there is only
one focus of attention in a window. The gGopher is set to the itsGopher
instance variable when a document is activated. The programmer has to
do more work to implement a window where different objects can be
active at different times.

- Suggestion to make the view clicked on the gGopher by default

This assumes that the click is somehow making the view active. This
won't always be the case. For example, a drawing window with a built-in
palette of patterns. Clicking on a pattern selects that pattern but
does not alter the currently selected drawing object.

- Suggestion to pass activate message to gGopher when a Document
is activated

This can't be done because the gGopher can be ANY Bureaucrat, not
just a view. Activate is not a Bureaucrat method, and it doesn't
make sense to me to add one.

---
Gregory Dow
Disclaimer: I wrote the TCL, but am not employed by Symantec.