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
······@surfsouth.com
Richard James Panturis Giuly <··@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
In article <···············@nerd-xing.mit.edu>, David Bakhash
<·····@alum.mit.edu> wrote:
> Richard James Panturis Giuly <··@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
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: ····················@ision.net WWW: http://www.ision.net/
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 ······@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
From: Richard James Panturis Giuly
Subject: Re: Need help with CLX.
Date:
Message-ID: <395913E1.71EAF100@spam.com>
Fred Gilham wrote:
>
> Something like this:
>
> ;;; A couple of utilities...
> (defun full-window-state (w)
Thanks Fred, that was extremely helpful.
······@surfsouth.com
ricky (······@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:
(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: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.
--
Fred Gilham ······@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
In article <··············@snapdragon.csl.sri.com>,
Fred Gilham <······@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
·······@mikemac.com
In article <··············@snapdragon.csl.sri.com>,
Fred Gilham <······@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
·······@mikemac.com
·······@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 ······@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