From: | Allan Odgaard |
Date: | 03 Aug 2000 at 00:23:00 |
Subject: | Re: BOOPSI again & again |
On 30-Jul-00, Gabriele Svelto wrote:
> So to be 'clean' I have to Set/GetAttrs() on the object pointer? Since
Yes. This allows notification, binary compatibility etc.
> I am deriving from gadgetclass do I have to use SetGadgetAttrs()
> instead of SetAttrs()?
Generally yes. I think using SetGadgetAttrs() supplies the receiving
object with enough info to do an ObtainGIRPort(), which some gadgets
need... I'm not really familiar with C='s BOOPSI gadgets, only MUI,
which doesn't have such problems ;-)
> BTW, when I redefine a method for my subclass I
> have always to call DoSuperMethod() before my own code or my subclass
> can stick with my code whithout executing the code of the previous
> classes?
This depends on wether (and when) you want the functionality of your
superclass. Imagine 3 different examples, where we've subclasses the
checkmark class.
1) you want checkmarks to have a blue background:
SetAPen(rp, ...);
RectFill(rp, ...);
DoSuperMethod(...);
2) you want checkmarks to have a glowing edge:
DoSuperMethod(...);
DrawGlowingEdge(rp, ...);
3) you want checkmarks to appear as in Windows:
DrawUglySquare(rp, ...);
Though two methods are important to get straigt.
OM_NEW: here you have no object (nor instance data) *before* you call
your superclass, so here you must call it before doing anything with
the object, including accessing the instance data.
OM_DISPOSE: here you have no object (nor instance data) *after* you call
your superclass.
A rule of thumb says you call your super class as the first thing in
setup methods and as the last thing in cleanup methods.
Regards Allan