[comp.sys.amiga.programmer] Problem with gadget refresh.

mfg@castle.ed.ac.uk (M Gordon) (06/24/91)

I'm currently writing a program in which I need to disable and later
re-enable some gadgets.  The disable works fine - I do a
RemoveGList(), set gadget->Flags to gadget->Flags | GADGDISABLED for
each one, AddGList() and RefreshGList().  I don't use OffGadget()
because this refreshes the entire list - far too slow when this
happens for each gadget I'm disabling.  The problem appears when I
try to re-enable them, using the same method but setting the flags to
flags & ~GADGDISABLED.  The gadgets are selectable again but there is
a small part of the pattern that covers them when they are inactive
left around the edges, outside the actual gadget but inside the
border drawn around it.  Any ideas as to what I might be doing
wrong?

Thanks

-- 
							 _   _   _    _   _	
Michael Gordon - mfg@castle.ed.ac.uk OR ee.ed.ac.uk	| |_| |_| |__| |_| |   
							| . . . .      . . |    
I spilt spot remover on my dog and now he's gone! 	|_________|~~|_____|    

peter@cbmvax.commodore.com (Peter Cherna) (06/25/91)

In article <11251@castle.ed.ac.uk> mfg@castle.ed.ac.uk (M Gordon) writes:
>I'm currently writing a program in which I need to disable and later
>re-enable some gadgets. ... The problem appears when I
>try to re-enable them, using the same method but setting the flags to
>flags & ~GADGDISABLED.  The gadgets are selectable again but there is
>a small part of the pattern that covers them when they are inactive
>left around the edges, outside the actual gadget but inside the
>border drawn around it.  Any ideas as to what I might be doing
>wrong?

Strangely enough, Intuition knows how to draw dots over a gadget,
but it doesn't explicitly know how to erase them.  What it does is
redraws the gadget over whatever is there (dots in your case).  A
gadget that is made up of text and borders, or any other imagery
that doesn't fully cover the select-box area, will be left with a sprinkling
of dots.  So one approach is to use GADGIMAGE gadgets whose image covers
the entire select area.

Alternately, you can physically erase the bits while the gadget is
removed, i.e.

	RemoveGadget();
	gad->Flags &= GADGDISABLED;
	RectFill(win->RPort, gad->LeftEdge, gad->TopEdge,
		gad->LeftEdge+gad->Width-1,
		gad->TopEdge+gad->Height-1);
	AddGadget();
	RefreshGadget();

(I left out the details of the Remove/Add/RefreshGadget calling).
Of course, if your gadget is GRELWIDTH/HEIGHT/RIGHT/BOTTOM, your
calculation for the RectFill() is more complex.

>Michael Gordon - mfg@castle.ed.ac.uk OR ee.ed.ac.uk	| |_| |_| |__| |_| |   

     Peter
--
Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
{uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"Gosh, didn't he have anything positive to say at all?"