Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with CLX.

11 views
Skip to first unread message

Richard James Panturis Giuly

unread,
Jun 25, 2000, 3:00:00 AM6/25/00
to
I need to draw a filled rectangle on the screen, that's all. Can
someone show me an example of a lisp program that will do that
with CLX (the X interface for Common Lisp). I'm using Allegro CL.

--
ricky
rgi...@surfsouth.com

David Bakhash

unread,
Jun 25, 2000, 3:00:00 AM6/25/00
to
Richard James Panturis Giuly <n...@spam.com> writes:

> I need to draw a filled rectangle on the screen, that's all. Can
> someone show me an example of a lisp program that will do that
> with CLX (the X interface for Common Lisp). I'm using Allegro CL.

do you know about this one?

FILL-POLYGON [function] (DRAWABLE GCONTEXT POINTS RELATIVE-P SHAPE)

dave

Rainer Joswig

unread,
Jun 25, 2000, 3:00:00 AM6/25/00
to
In article <c29k8fd...@nerd-xing.mit.edu>, David Bakhash
<ca...@alum.mit.edu> wrote:

How about XLIB:DRAW-RECTANGLE ? It has an optional FILL-P argument.

--
Rainer Joswig, BU Partner,
ISION Internet AG, Steinhöft 9, 20459 Hamburg, Germany
Tel: +49 40 3070 2950, Fax: +49 40 3070 2999
Email: mailto:rainer...@ision.net WWW: http://www.ision.net/

Fred Gilham

unread,
Jun 26, 2000, 3:00:00 AM6/26/00
to

Something like this:


;;; A couple of utilities...
(defun full-window-state (w)
(xlib:with-state (w)
(values (xlib:drawable-width w) (xlib:drawable-height w)
(xlib:drawable-x w) (xlib:drawable-y w)
(xlib:window-map-state w))))

(defun wait-for-mapping (display win)
(xlib:display-finish-output display)
(multiple-value-bind (width height x y mapped) (full-window-state win)
(declare (ignore width height x y))
(if (eq mapped :viewable)
t
(wait-for-mapping display win))))

(defun simple ()
(let* ((display (xlib:open-display
#+allegro (short-site-name)
#-allegro (machine-instance)))
(screen (xlib:display-default-screen display))
(root (xlib:screen-root screen))
(fg-pixel (xlib:screen-black-pixel screen))
(bg-pixel (xlib:screen-white-pixel screen))
(window (xlib:create-window :parent root
:event-mask '(:visibility-change)
:x 100 :y 100
:width 100 :height 100
;; :override-redirect :on
:background bg-pixel
:border fg-pixel
:border-width 2))
(gc (xlib:create-gcontext :drawable window
:background bg-pixel
:foreground fg-pixel)))

(xlib:set-wm-properties window
:name "Simple"
:x 100 :y 100 :width 100 :height 100
:user-specified-position-p t
:user-specified-size-p t
:min-width 100 :min-height 100
:width-inc nil :height-inc nil)
(xlib:map-window window)
;; Wait until we get mapped before doing anything.
(wait-for-mapping display window)

(xlib:draw-rectangle window gc 10 10 10 10 t)
(xlib:display-force-output display)))


Running this you should wind up with a small window with a small black
rectangle in it.

--
Fred Gilham gil...@csl.sri.com
I have over the years been viewed as a man of the left and a man of
the right, and the truth is that I've never put much stake in such
labels. But this I have learned: the left patrols its borders and
checks membership credentials ever so much more scrupulously, even
ruthlessly, than does the right. -- Richard John Neuhaus

Fred Gilham

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to

ricky (rgi...@surfsouth.com) writes:
>I need to draw a filled rectangle on the screen, that's all. Can
>someone show me an example of a lisp program that will do that with
>CLX (the X interface for Common Lisp). I'm using Allegro CL.

I'm not sure my first attempt at this got through, so here it is
again:

(xlib:map-window window)
;; Wait until we get mapped before doing anything.
(wait-for-mapping display window)

(xlib:draw-rectangle window gc 10 10 10 10 t)
(xlib:display-force-output display)))


This will give you a small window and a small filled rectangle in the
window.

To figure out what's going on, look up the various functions and
macros (the ones in the XLIB package) in the CLX manual.

Mike McDonald

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to
In article <u7wvjby...@snapdragon.csl.sri.com>,
Fred Gilham <gil...@snapdragon.csl.sri.com> writes:

> To figure out what's going on, look up the various functions and
> macros (the ones in the XLIB package) in the CLX manual.

And then, never, ever write a CLX program in this style! Chapter 1 of the
CLX manual has an example of how to write a correct program. (Hint: recursive
polling is NOT the way to handle the expose event!)

Mike McDonald
mik...@mikemac.com

Mike McDonald

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to

Richard James Panturis Giuly

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to
Fred Gilham wrote:
>
> Something like this:
>
> ;;; A couple of utilities...
> (defun full-window-state (w)

Thanks Fred, that was extremely helpful.

rgi...@surfsouth.com

Fred Gilham

unread,
Jun 28, 2000, 3:00:00 AM6/28/00
to

mik...@mikemac.com (Mike McDonald) writes:
> And then, never, ever write a CLX program in this style! Chapter 1
> of the CLX manual has an example of how to write a correct
> program. (Hint: recursive polling is NOT the way to handle the
> expose event!)
>

I guess I can see what Mike's getting at. I should probably look
closer at the code I steal. :-)

You can try the following instead:


(defun wait-for-mapping (display window)
(xlib:display-force-output display)
(xlib:event-case (display :discard-p nil :peek-p t)
(:map-notify (event-window)
(eq event-window window))))


(defun simple ()
(let* ((display (xlib:open-display
#+allegro (short-site-name)
#-allegro (machine-instance)))
(screen (xlib:display-default-screen display))
(root (xlib:screen-root screen))
(fg-pixel (xlib:screen-black-pixel screen))
(bg-pixel (xlib:screen-white-pixel screen))
(window (xlib:create-window :parent root

:event-mask '(:structure-notify)

:x 100 :y 100
:width 100 :height 100
;; :override-redirect :on
:background bg-pixel
:border fg-pixel
:border-width 2))
(gc (xlib:create-gcontext :drawable window
:background bg-pixel
:foreground fg-pixel)))


(xlib:map-window window)
;; Wait until we get mapped before doing anything.
(wait-for-mapping display window)

(xlib:draw-rectangle window gc 10 10 10 10 t)
(xlib:display-force-output display)))

--
Fred Gilham gil...@csl.sri.com
[My tutors] got bored sooner than I, and laid down a general rule
that all statements about languages had to be in a higher level
language. I thereupon asked in what level of language that rule was
formulated. I got a very bad report. -- J. R. Lucas

0 new messages