[comp.windows.news] Canvases and /Damaged, a beginners question

andy@ecrcvax.UUCP (Andrew Dwelly) (02/23/88)

I am using NeWS version 1.0 on a Colour Sun 3, and am having a problem with
damage events.

The program below is supposed to put a gray square on the lower left hand
side of the screen, with the word "Hello" written on it. Whenever the
canvas is damaged, it is supposed to recreate itself.

Unfortunately, it doesn't work. The first gray square is written in response
to the initial damage event, but it never seems to receive any others, even
when a litewindow stops obscuring it, or another canvas is plonked on top and
removed.

On the other hand if the canvas is made retained, everything works fine, it
still doesn't receive any more damage events, but the server recreates it from
the stored bitmap.

Is there a problem in the way I have expressed my interest in damage events ?
Are litewindows doing something odd with events that prevents my process
seeing them ? is there (heaven forbid) a problem in the server ?

Please send your answers and comments to

andy@ecrcvax.UUCP or mcvax!unido!ecrcvax!andy

I will post them here if there are enough. Thanks in advance, Andy.

----Snip----Snip----Snip----Snip----Snip----Snip----Snip----Snip----Snip----

% Make path

newpath
0 0 moveto
100 100 translate 200 200 rect

% Make a canvas

/can framebuffer newcanvas def

% express an interest for the canvas

createevent dup begin
	/Name /RightMouseButton def
	/Action /DownTransition def
	/Canvas can def
end expressinterest

createevent dup begin
	/Name /Damaged def
	/Canvas can def
end expressinterest

% Shape the canvas according to the current path

can reshapecanvas

% With the next line uncommented, everything works, but not in the right way
% can /Retained true put

% Put the canvas on the display

can /Mapped true put

% Draw something in the canvas

/Hello  {
	gsave
	can setcanvas
	.5 fillcanvas
	20 20 moveto
	/Helvetica-Bold findfont 30 scalefont setfont
	1 setgray
	(Hello) show
	grestore
	} def

% Conk out until one of my interests shows up
% if the event is damaged, redraw the canvas (Hello) and loop else exit

{awaitevent /Name get /Damaged eq 
   {Hello}
   {exit} 
ifelse} loop
------------------------------------------------------------------------------

....Andy

andy@ecrcvax.UUCP (Andrew Dwelly) (02/29/88)

I should have cleared the damage path after each /Damaged event was
received. This allows me to receive further /Damaged events.

The command "damagepath" will do this, setting the current path to
the damaged portion of the canvas. 

....Thanks to Mark Callow of SGI and Alan Dewar at the University of 
Calgary for their help.

			      Andy