[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jan 21 16:56:50 2002 
Subject:Re: Colour Change 
From:A . Sloman 
Volume-ID:1020121.02 

Michael H Lees <mhl@Cs.Nott.AC.UK> wrote:

> --- I had posted this on comp.lang.pop
> --- I don't think it got through to pop-forum

I saw it but have been rushing around doing too many things. Otherwise
I'd have responded sooner. Sorry.

Actually having your code makes it clearer what you want to do:

> I have a sim_movable_agent which I would like to change the colour and
> label (the string in rc_pic_strings) of at runtime.  The slots
> rc_pic_lines and rc_pic_strings contain this information, I have written
> a procedure which changes these variables to change the colour and the
> label. The problem is when I change the colour or label it leaves the a
> 'residue' of the old colour/label on the background.

You have to undraw the old one before changing the label and drawing
the new one.

If you look at HELP rclib and search for

	rc_change_picture(pic:rc_linepic_movable, newx, newy, newlines, newstrings);

you will find a method which, I think, does what you want.

You may wish to copy the definition and edit it to make a specific one
for instances of sim_movable, though you don't need to if that does what
you want.

Another option is to use the fact that the RCLIB package allows the
filler of the slot rc_pic_lines or rc_pic_strings to be a procedure (or
a word which is the name of a procedure or method, to help with run-time
debugging).

Then you can make your rc_pic_strings drawing method look at some other
slot in the instance to see what string or what colour to use, and just
draw it. But it will have to undraw first if anything has changed
since the last time it was drawn.

Then any procedure or method can change the latter slot at any time, and
the next time the instance is moved or rotated the new string and or
colour will be used.

But it may be simpler, though possibly less elegant, to use a method
like rc_change_picture, which does what you want.

To see its definition, if you wish to copy and edit it, do
	showlib rc_change_picture

( It should be in $poplocal/local/rclib/auto/rc_change_picture.p )

I hope that helps.

It's important that the sim_movable stuff in LIB sim_picagent, inherits
lots of stuff from the RCLIB package.

(Thanks to objectclass and its multiple-inheritance facilities.)

Aaron