From: Mike Thomas
Subject: GCL 2.5.2 Windows binary with Japi GUI binding
Date: 
Message-ID: <Veyea.25$KA.13464@nsw.nnrp.telstra.net>
Hi there.

To celebrate the recent continuation of debate over free software on this
list, a Windows "traditional CLtL1" build of the stable release of GNU
Common Lisp (GCL version 2.5.2) is now available from:

    ftp://ftp.gnu.org/pub/gnu/gcl/cvs/gcl_2.5.2.japi.20030321_mingw32.zip

It is suitable for building Maxima on Windows.

Furthermore, to celebrate and support Erann Gat's recent stand against war
on this newsgroup,  I have made the GCL icon for this release and hopefully
all future ones a white dove on a blue background.  I think that the
fundamental ideas behind free software and the pursuit of peace are the same
and deserve to be fostered.  Thank you Erann.  To quote "The Artist" from
his album at about the time of the last Kuwait/Iraq/US conflict:

   "So what if we control all of the oil, is it worth a child dying for?"

But Wait - There's More:

This also marks the first public appearance of an experimantal GCL binding
to the Japi Java based GUI library primitives from:

    http://www.japi.de/

I hope that this nifty little library will make it easier to do rough and
ready cross-platform graphics with GCL than with the traditional GCL-TK
package.

A test/example program follows to give you a feel for how to use just a few
of the Japi functions in GCL. If the formatting is too messed up you can
view it via the GCL CVS browser:


http://savannah.gnu.org/cgi-bin/viewcvs/gcl/gcl/japitest.lsp?rev=1.1&content
-type=text/vnd.viewcvs-markup

The primitives may be accessed by executing the following statement:

   (in-package :japi-primitives)

Note that "j_printer" and "j_print" seem to have troubles on my machine (in
fact GCL dies when I try to print). I'd be interested in hearing from you
about your own experiences.

Cheers

Mike Thomas

==========================================================================
;;;
;;; Japi is a cross-platform, easy to use (rough and ready)
;;; Java based GUI library
;;; Download a library and headers for your platform, and get the C examples
;;; and documentation from:
;;;
;;; http://www.japi.de/
;;;
;;; This file shows how to use some of the available functions. You may
assume
;;; that the only functions tested so far in the binding are those which
appear
;;; below, as this file doubles as the test program. The binding is so
simple
;;; however that so far no binding (APART FROM PRINTING) has gone
;;; wrong of those tested so far!
;;;
;;; Mike Thomas, 21 March 2003
;;;
;;; (load "c:/cvs/gcl/japitest.lsp")
;;;

(in-package :japi-primitives)

;; Turn Japi system debug tracing on
;(j_setdebug 2)

;; Start up the Japi server (needs to find either "java" or "jre" in your
path
(j_start)

;; Start up a Window frame and then show it
(setf frame (j_frame "GCL Japi binding Test and Demo Program"))
(j_show frame)

;; Simple message box, no buttons
(setf alert (j_messagebox frame "label1" "label2"))
(j_sleep 2000)
(j_dispose alert)

;; Message box variations with 1, 2 and 3 buttons
(setf alert (j_alertbox frame "label1" "label2" "OK"))
(setf alert (j_choicebox2 frame "label1" "label2" "Yes" "No"))
(setf alert (j_choicebox3 frame "label1" "label2" "Yes" "No" "Cancel"))

;; A graphics redraw function
(defun drawgraphics (drawable xmin ymin xmax ymax)
  (let* ((fntsize 10)
           (tmpstrx (format nil "XMax = ~D" xmax))
           (tmpstry (format nil "YMax = ~D" ymax))
           (tmpstrwidx (j_getstringwidth drawable tmpstrx))
           (tmpstrwidy (j_getstringwidth drawable tmpstry)))
   (j_setfontsize drawable fntsize)

   (j_setnamedcolor drawable J_RED)
   (j_drawline drawable xmin ymin (- xmax 1) (- ymax 1))
   (j_drawline drawable xmin (- ymax 1) (- xmax 1) ymin)
   (j_drawrect drawable xmin ymin (- xmax xmin 1) (- ymax xmin 1))

   (j_setnamedcolor drawable J_BLACK)
   (j_drawline drawable xmin (- ymax 30) (- xmax 1) (- ymax 30))
   (j_drawstring drawable (- (/ xmax 2) (/ tmpstrwidx 2)) (- ymax 40)
tmpstrx)
   (j_drawline drawable (+ xmin 30) ymin (+ xmin 30) (- ymax 1))
   (j_drawstring drawable (+ xmin 50) 40 tmpstry)

   (j_setnamedcolor drawable J_MAGENTA)
   (loop for i from 1 to 10
      do (j_drawoval drawable
               (+ xmin (/ (- xmax xmin) 2))
               (+ ymin (/ (- ymax ymin) 2))
              (* (/ (- xmax xmin) 20) i)
              (* (/ (- ymax ymin) 20) i)))

   (j_setnamedcolor drawable J_BLUE)
   (let ((y ymin)
          (teststr "JAPI Test Text"))
       (loop for i from 5 to 21 do
           (j_setfontsize drawable i)
           (let ((x (- xmax (j_getstringwidth drawable teststr))))
               (setf y (+ y (j_getfontheight drawable)))
               (j_drawstring drawable x y teststr))))))

;; Set up the canvas and menu items
   (j_setborderlayout frame)
   (setf menubar (j_menubar frame))
   (setf file (j_menu menubar "File"))
   (setf print (j_menuitem file "Print"))
   (setf save (j_menuitem file "Save BMP"))
   (setf quit (j_menuitem file "Quit"))

   (setf canvas (j_canvas frame 400 600))
   (j_pack frame)
   (j_show frame)

;; Initialise the canvas
   (drawgraphics canvas 0 0 (j_getwidth canvas) (j_getheight canvas))

;;
;; Run an event loop
;;
   (loop as obj = (j_nextaction)
      while (and (not (= obj frame)) (not (= obj quit)))
      do
         (when (= obj canvas)
            (j_setnamedcolorbg canvas J_WHITE)
            (drawgraphics canvas 10 10 (- (j_getwidth canvas) 10)
                                                        (- (j_getheight
canvas) 10)))
        (when (= obj print)
            (let ((printer (j_printer frame)))
        (when (> 0 printer)
            (drawgraphics printer 40 40 (- (j_getwidth printer) 80)
                                                       (- (j_getheight
printer) 80))
            (j_print printer))))
       (when (= obj save)
            (let ((image (j_image 600 800)))
               (drawgraphics image 0 0 600 800)
               (when (= 0 (j_saveimage image "test.bmp" J_BMP))
                  (j_alertbox frame "Problems" "Can't save the image"
"OK")))))


;; Kill the Japi GUI server
(j_quit)