[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jan 21 16:36:42 2002 
Subject:Colour Change 
From:mhl 
Volume-ID:1020121.01 

--- I had posted this on comp.lang.pop 
--- I don't think it got through to pop-forum
--- Hopefully someone can help...

Hi,

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. I've been looking
for a standard procedure which updates these variables but can't find
one. I don't want to redraw the whole background is there another way of
preventing the residue?

The following code is a simple example of my problem, If you try and drag
the testpic with the mouse it leaves a red square at the original
location. (or it leaves a red square where the colour was changed).
 
;;;----------------Code starts here ------------------
uses rclib;
uses simlib;
uses sim_picagent;


;;; The class is taken from the example in sim_picagent
define :class testpic;
    is sim_movable;
    slot rc_mouse_limit = 10;
enddefine;

define newpic(x, y, label, color, w,windows) -> pic;
    instance testpic;
        sim_x = x;
        sim_y = y;
        rc_pic_lines =[COLOUR ^color WIDTH ^w SQUARE {0 0 1}];
        rc_pic_strings = [{-4 0 ^label}];
    endinstance -> pic;
    rc_add_containers(pic, windows);
enddefine;


;;;Create the window
vars
    win1 = rc_new_window_object(20, 5, 250, 250, true,'win1',newsim_picagent_window),
    windows = [^win1],
;

;;; Create the testpic instance
vars
    p1 = newpic(50, 50, 'p1', 'blue' , 50, windows),
;

;;; Change the colour of the instance p1
[COLOUR 'green' WIDTH 50 SQUARE {0 0 1}]->rc_pic_lines(p1);

;;; Change the label
 [{-4 0 'P2'}]->rc_pic_strings(p1);

;;;---------Code ends here------------------

Is it possible to change the colour/label without changing the background?

Thanks

Mike