CLIM mail archive

[Prev][Next][Index][Thread]

CLIM seems to ignore WITH-TRANSLATION



    Date: Thu, 5 Nov 1992 10:35 EST
    From: Meir Laker <meir@watson.ibm.com>

    I have a function which draws a bar chart in a clim window...

    How can I move the bar chart up and to the right a fixed amount?

I'm guessing here, but if the bar-chart-drawer itself calls something
like with-room-for-graphics this could be causing the problem.  There is
an ambiguity in the description (and perhaps the contract) of
with-room-for-graphics (which I have previously reported to the CLIM
spec discussion).  

The problem is the precise definition of the relationship between the
local coordinate system (established by with-room-for-graphics) and the
extant coordinate system (usually the native window coordinate system).

Example:

(defun draw-chart (stream)
  (loop for x0 = 0 then x1
	for x1 in '(20 40 60 80 100)
	for y in '(12 29 62 53 17)
	do (draw-rectangle* stream x0 0 x1 y)))

This doesn't appear to move the chart:

(let ((s *standard-output*))
  (with-room-for-graphics (s)
    (with-translation (s 20 20)
      (draw-chart s))))

Here is a quick fix.  Put down some ink (it can be invisible) at the
origin of the with-room-for-graphics coordinate system.  Then w-r-f-g
has a different idea of your bounding box:

(let ((s *standard-output*))
  (with-room-for-graphics (s)
    (draw-point* s 0 0 :ink +background+)
    (with-translation (s 20 20)
      (draw-chart s))))

Discussion: There are at least two possible uses for with-room-for-graphics.

(1) I'm going to draw somewhere in the drawing plane.  I want to see all
my graphics placed near the current cursor.

(2) I'm going to draw somewhere in the drawing plane.  I want to see my
graphics located such that the origin of my drawing coordinates is
somewhere directly beneath the current cursor.  (Or, on the left margin
of the window, and below the y coordinate....)

Both these are legitimate uses.  Probably there are finer degrees of
control that some applications could use too.  The current behaviour of
w-r-f-g is closer to (1) than to (2), but it is insufficiently specified
to tell whether this is intended or not.

0,,

Follow-Ups: References:

Main Index | Thread Index