[comp.windows.x] How do I make a cross-hair cursor in X windows?

peter@cm.deakin.oz.au (Peter Horan) (05/28/91)

I wish to use a vertical cursor line to mark a given point in
time on a series of graphs. I wish to be able to drag the
vertical line across the graphs at will, rather in the manner
of using the grips for sizing sub-windows. However, the
vertical line moves across the image non-destructively and has
nothing to do with sizing. I have mentioned the phrase
"cross-hair cursor" because this is what Tektronix call their
screen cursor. It is not to be confused with the mouse cursor,
which tracks the mouse and does not fully cover the screen or in
X windows, the (sub-)window. However, I want to be able to use the
mouse to position my vertical cursor line and leave it at some
given place.

I will be very grateful for any pointers, code, etc.

Peter Horan
--
Peter Horan
peter@cm.deakin.oz.au

aipdc@castle.ed.ac.uk (Paul Crowley) (05/28/91)

There are two ways of doing this I can think of.  The standard technique
is to XOR the lines you want onto the screen;  when you want rid of
them, XOR them again.  You should be warned that this patented, despite
being fairly damn obvious:  I independently re-invented it when I was
12.  The only alternative I can think of is to redraw the stuff behind
the cursor when you remove them, or to draw the cursor as two windows
arranged in a cross shape in the hope that backing store will do its
stuff.  Backing store is _also_ patented, in the US at least.

I didn't mean to do this, but since I'm here I shall: if you think this
is a little silly, talk to the League for Programming Freedom: 
league@prep.ai.mit.edu.
                                         ____
\/ o\ Paul Crowley aipdc@castle.ed.ac.uk \  /
/\__/ Part straight. Part gay. All queer. \/
"I say we kill him and eat his brain."
"That's not the solution to _every_ problem, you know!" -- Rudy Rucker

pmartz@undies.dsd.es.com (Paul Martz) (05/28/91)

Personally, I'd like to see a cross-hair cursor extension to X, which
vendors can then port to their own hardware. Implementing this as a
software cursor will perform quite lamely...
-- 

   -paul	pmartz@dsd.es.com
		Evans & Sutherland

pete@iris49.biosym.COM (Pete Ware) (05/29/91)

Basically, create a tall, narrow window with save-under set and move that to
follow the mouse.

A reasonable way to do this is to write your own composite widget that
understands how to layout your series of graphs.  Then include a
resource that indicates where the vertical cursor should be placed and
possiblly another resource if it should be displayed.  This composite
widget can then insure the "vertical cursor" window is properly placed
above all the others.

You can even implement the "vertical cursor" as a widget which
simplifies setting things such as color.

--pete