newton@cit-vax.Caltech.Edu (Mike Newton) (07/22/88)
Hi -- a CLX sample and an amw question:
'awm` question: i would like to use awm with borders. In particular, I would
like a single mouse click on the border (say, the left mouse button) to
iconify a window, while a mouse drag (also with the left button) should
resize the window. No matter how i've tried setting up the .awmrc this will
not work. Any hints would be appreciated!
CLX:
Recently someone asked for some CLX samples. Here is a very short one
that I use and enjoy. Please tell me if you come up with any nice additions.
(This has only been tried on Suns under SunOS3.4 and KCL)
;;; -*- Mode:Lisp; Package:XLIB; Syntax:COMMON-LISP; Base:10; Lowercase:T -*-
;;; CLX - Point Graphing demo program
;;; Copyright (C) 1988 Michael O. Newton (newton@csvax.caltech.edu)
;;; Permission is granted to any individual or institution to use, copy,
;;; modify, and distribute this software, provided that this complete
;;; copyright and permission notice is maintained, intact, in all copies and
;;; supporting documentation.
;;; The author provides this software "as is" without express or
;;; implied warranty.
;;; This routine plots the recurrance
;;; x <- y(1+sin(0.7x)) - 1.2(|x|)^.5
;;; y <- .21 - x
;;; As described in a ?? 1983 issue of the Mathematical Intelligencer
;;; It has ONLY been tested under X.V11R2 on a Sun3 running KCL
(in-package 'xlib :use '(lisp))
(export 'pict)
(defun pict (host &optional (point-count 100))
"Sets up X11 code for drawing a pretty picture"
(let* ((display (open-display host))
(width 800)
(height 800)
(screen (display-default-screen display))
(black (screen-black-pixel screen))
(white (screen-white-pixel screen))
(win (create-window
:parent (screen-root screen)
:background white
:border black :border-width 1
:colormap (screen-default-colormap screen)
:bit-gravity :center
:event-mask '(:exposure :key-press)
:x 20 :y 20
:width width :height height))
(gc (create-gcontext
:drawable win
:background white
:foreground black)))
(map-window win) ; Map the window
;; Handle events
(unwind-protect
(loop
(event-case (display :force-output-p t)
(exposure ;; Come here on exposure events
(window count)
(when (zerop count) ;; Ignore all but last exposure event
(clear-area window)
(draw-ppict win gc point-count 0.0 0.0 (* width 0.5)
(* height 0.5))
(draw-glyphs win gc 10 10 "Press any key to exit")
;; Returning non-nil causes event-case to exit
t))
;; ?? ADD CODE FOR RESIZE HERE!
(key-press () (return-from pict t))))
(close-display display))))
;;; Draw points. These should maybe be put into a an array so that they do
;;; not have to be recomputed on exposure. X assumes points are in the range
;;; of width x height, with 0,0 being upper left and 0,H being lower left.
;;; x <- y(1+sin(0.7x)) - 1.2(|x|)^.5
;;; y <- .21 - x
;;; hw and hh are half-width and half-height of screen
(defun draw-ppict (win gc count x y hw hh)
"Recursively draw pretty picture"
;;; (declare (type card16 xf yf))
(unless (zerop count)
(let ((xf (floor (* (+ 1.0 x) hw ))) ;These lines center the picture
(yf (floor (* (+ 0.7 y) hh ))))
(draw-point win gc xf yf)
(draw-ppict win gc (1- count)
(- (* y (1+ (sin (* 0.7 x)))) (* 1.2 (sqrt (abs x))))
(- 0.21 x)
hw
hh ))))
;;; (lines (make-array (* 500 4) :fill-pointer 0 :element-type 'card16))
;;; (curves (make-array (* 500 8) :fill-pointer 0 :element-type 'card16)))
--
newton@csvax.caltech.edu amdahl!cit-vax!newton
Caltech 256-80 818-356-6771 (afternoons,nights)
Pasadena CA 91125 Beach Bums Anonymous, Pasadena President
"Reality is a lie that hasn't been found out yet..."