Re: surface ++= ? (was on widgets@)

Brian Alliet <[email protected]> Thu, 15 Apr 2004 18:47:28 -0400
Newsgroups gmane.comp.java.xwt.core
Message-ID <[email protected]>
On Apr 15, 2004, at 6:02 PM, Charles Goodwin wrote:

>> That is what I was saying. The problem is Box.java doesn't know what
>> the surface property is. All it can do is call the appropriate traps 
>> to
>> find it.
>
> That's what I'm advocating.
>
>> If those traps return a different object each time you can't
>> tell when the surface has actually changed.
>
> Arguably, that's a bad implementation of the surface object.

Yeah. Working around this "problem" will be way more work than it is 
worth.

Ok. Here is my final proposal for making this whole mess work. If 
anybody has any comments please post them.

When you *read* from the surface property the core simply returns 
parent.surface, or null if the get reaches the root box. To change the 
value of the surface property you have to trap it. (This is exactly how 
things work now).

When you *write* to the surface property the core puts the value to the 
surface property of every child of the box. When a child with no 
children is reached the put is simply a no-op. Again, to do anything 
useful with the put you have to trap it.

When a box's parent is going to change as a result of an add operation 
the core does a get on "surface" with the box still under its current 
parent, moves the box to the new parent, and does a get on "surface" 
again. If the old and new surface values differ it puts true to the 
surface property on the box (which in turn gets propagated to all its 
descendants).

Widgets that need to know when their surface changes just have to put a 
*write* trap on surface. When that is written to they reregister with 
the focusmanager or whatever.

-Brian