[comp.lang.smalltalk] Smalltalk coordinates to screen coordinates

dik@comp.lancs.ac.uk (Mr R. M. Bentley) (10/31/90)

I am trying to implement a C-program which displays a colored raster
image on the screen as a Smalltalk method. The point to position the
image is passed to the C function as parameters to the primitive method.

I am having trouble mapping the local co-ordinates used in Smalltalk to
refer to the Smalltalk display within the Sunview window to absolute 
display coordinates. 

What I really want to be able to do is position a colored image within a
View. I can get the local origin of the View (using insetDisplayBox) but
I need to be able to translate this to global screen co-ordinates for the
primitive function. 

As far as I can see, I have two options: 

	1. Modify the co-ordinates in Smalltalk before passing to the
	   primitive.

        2. Use SunView to locate the Smalltalk window origin and add this
	   as a constant in the C function to the parameters passed from
	   Smalltalk.

Currently we're using pixrect onto the frame buffer, opening ("/dev/fb").
I'm told that this problem can be resolved if anyone knows if smalltalk
provides a handle to its pixrect. (I am using Smalltalk 2.5).

If anyone knows if either of the two approaches is feasible and how to go
about it, I would be very grateful for advice/assistance.

laukee@canon.co.uk (David Lau-Kee) (11/02/90)

dik@comp.lancs.ac.uk (Mr R. M. Bentley) writes:

[ stuff about displaying colour images in PPS 2.5
  Q. does one get st's pixrect or frig a window offset, and how? ]

Well, what you ought to do is grab Smalltalk's window offsets direct and use
those.  You also need the colour map info to hand.  When I did something
similar I couldn't figure out how do this properly, so I frigged it (your
option 1).  Note that you'll also need to replicate the standard bitblt
(since Smalltalk will assume it can just toggle LSB for black/white), *and*
set up the colour map to have every other entry black (to get the cursor
functioning over the deep parts).  I'm sure there's an easier way, still
this was just a "design as you type" exercise .

I'll mail you some code to get you started.

-------------
David Lau-Kee
Canon Research Centre Europe,
17/20 Frederick Sanger Rd, Surrey Research Park, Guildford, Surrey, GU25YD, UK.
NRS: laukee@uk.co.canon, INET: laukee%canon@nsfnet-relay.ac.uk
UUCP: laukee@canon.uucp, PATH: ..!mcsun!ukc!uos-ee!canon!laukee
Tel: +44 (0) 483 574325 Fax: +44 (0) 483 574360