[comp.windows.x] Widget subclass that just changes superclass values

dce@smsc.sony.com (David Elliott) (08/25/90)

I need a widget that looks like a label that has multiple states.  For
example, you can have 2 states and each state could have a different
label string, foreground, background, pixmap, and so forth.

I thought that I should be able to subclass Label and change the Label
widget resources using the subclass resources.  The problem is that to
do so I either have to copy a bunch of code from Label to recalculate
the size and bitmap information, or I have to be able to call the Label
initialize and setvalues routines (initialize and setvalues go from
superclass to subclass).  I don't like copying code that may get
changed out from under me, and I find that I can't call the Label
initialize routine, and wasn't sure it was kosher to call setvalues
from initialize (it would be messy anyway).

In general, it seems like there should be a way for a programmer to
register some new resources for a widget, and register a routine
to be called whenever these resources are changed, thus allowing
the programmer to "wedge" in between a widget and the resource
manager.  Also, it seems like it would be useful to allow the
programmer to change the class of a widget to allow for cases
where a given type of widget is used a lot but in different ways
(like a box with 50 boxes inside of it, where the inner boxes
have different general behavior than the outer).

For now, I'm going to use application resources like s0RefLabel,
s0RefForeground, and so forth, but it would be better if I could use
"normal" resources like "*ref*s0Foreground" and so forth.  (I know
there's not much difference, but it seems like the hierarchy is there
and is applicable in this case.)

-- 
...David Elliott
...dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
...(408)944-4073
...Krusty says: Give a hoot, read a book!