[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defining drawings as objec

Irfan and friends,
Getting objects to draw themselves is a very old OOP trick, and the nicest
(IMHO) implementation for the Mac is in MacApp, in either Object Pascal (for
MacApp 2.x) or C++ (for MacApp 3.x, currently in beta).
The general principle is that a given window is a 'view' which can then in turn
have 'sub-views'.  When the window is redrawn, it calls the chain of views to
redraw using their draw methods, in Pascal Draw(area: Rect).  This is passed
down the line to the objects which make up the views, which in turn each has a
Draw() method, which simply draws such of the object as is in the given area.
There are of course many matters of detail which can refine this scheme.  For
instance, it is useful to have a field in each class which contains is
rectangular extent, so that there can be a quick check of rectangular inclusion
for each draw, to save wasted method calls.
I am sure that this sort of approach could suit your instance very nicely.  I
have used it in Pascal applications very extensively, and will also be using it
in our MCL work.
Regards, Howard.