Hello
I am still having problems with CMUCL Mtoif Interface. I do not know
whether it is a problem of mine or whether there is a bug.
Here is the simple test I use (it is a modified version of the one
coming with the distribution). The problems come with the
"drawing-area" and with the "with-callback-event" function.
-----------------
;;; -*- Mode: CLtL -*-
;;; cdes-ui.lisp --
;;; Simple User Interface for building state machines and invoking the
;;; supervisory building routines.
;;;
;;; $Id$
;;; History:
;;; $Log$
(use-package "XT")
(use-package "XTI")
(defvar dw nil)
(defun my-callback (widget call-data quit)
(format t "Got callback on ~A~%" widget)
(format t "Callback reason was ~A~%" (any-callback-reason call-data))
(format t "Quit button is ~A~%" quit)
(format t "Window of drawing area ~S~%is ~S~%"
dw (widget-window dw))
)
(defun test-init ()
(let* ((shell (create-application-shell))
(rc (create-row-column shell "rowColumn"))
(quit (create-push-button-gadget rc "quitButton"
:label-string "Quit"))
(button (create-push-button-gadget rc "button"
:highlight-on-enter t
:shadow-thickness 0
:label-string "This is a button"))
(ebutton (create-push-button-gadget
rc "Ebutton"
:highlight-on-enter t
:shadow-thickness 0
:label-string "This is a funny button"))
(edialog (create-error-dialog rc "EDlg"
:dialog-title "ZUT!"
:message-string "ZOT!"
))
(fr (create-frame rc "FR"))
(draw-surface (create-drawing-area fr "DW"
:shadow-thickness 1
:width 300
:height 300))
)
(add-callback quit :activate-callback #'quit-application-callback)
(add-callback button :activate-callback 'my-callback quit)
(add-callback ebutton :activate-callback #'manage-callback edialog)
(add-callback edialog :ok-callback #'(lambda (w d &rest cd)
(declare (ignore w d cd))
(format t ">> Evviva!!!!~%")))
(add-callback edialog :cancel-callback
#'(lambda (w d &rest cd)
(declare (ignore w d cd))
(format t ">> L'e` dura!!!!!~%")))
(manage-child rc)
(manage-children quit button ebutton)
(manage-child fr)
(manage-children draw-surface)
(realize-widget shell)
;; Set up drwing area stuff
(setq dw draw-surface)
(let* ((dw-window (widget-window dw))
(display (xlib:window-display dw-window))
(screen (first (xlib:display-roots display)))
(gc (xlib:create-gcontext
:drawable dw-window
:foreground (xlib:screen-black-pixel screen)
:background (xlib:screen-white-pixel screen)
:line-width 0))
)
(add-callback dw
:input-callback #'drawing-fun
dw-window gc)
(format t ">> ~S~%" (widget-window dw))
)
))
(defun drawing-fun (dw dwa-cbs &rest client-data)
(let ((dw-window (first client-data))
(gc (second client-data))
)
(format t ">> dw = ~S~% dwa-cbs = ~S~%cd = ~S~%"
dw dwa-cbs client-data)
;(inspect dwa-cbs)
(with-callback-event (the-event dwa-cbs)
;;(let ((the-event (any-callback-event dwa-cbs)))
(case (any-callback-reason dwa-cbs)
(:cr-input
(format t ">> Button x ~S~%" (xti:button-event-x the-event)))
)
)
;;)
))
(defun test ()
(run-motif-application 'test-init))
;;; end of file -- cdes-ui.lisp
-------------------------------------
Here is what happens when I run the test:
-------------------------------------
Starting /usr/robotics/shared/cmu-cl/17e/bin/lisp ...
ILISP V5.5 Use M-x ilisp-bug for problems and suggestions.
; Loading #p"/robust.a/student/marcoxa/.cmucl-init.lisp".
;; Loading #p"/robust.a/student/marcoxa/cl/lisp-utilities/defsystem.bytef".
CMU Common Lisp 17e, running on graphics (Sparc2)
Send bug reports and questions to your local CMU CL maintainer,
Marco Antoniotti (·······@cs.nyu.edu), or to
··········@cs.cmu.edu.
Loaded subsystems:
Python 1.0, target SPARCstation/Sun 4
CLOS based on PCL version: September 16 92 PCL (f)
CLX X Library MIT R5.01
Motif toolkit and graphical debugger 1.0
*
* (load "cdes-ui.lisp")
; Loading #p"/robust.a/student/marcoxa/projects/robots/walking-des/cdes-ui.lisp".
T
* (test)
In: LAMBDA (DW DWA-CBS &REST CLIENT-DATA)
(LET ((DW-WINDOW #) (GC #))
(FORMAT T ">> dw = ~S~% dwa-cbs = ~S~%cd = ~S~%" DW DWA-CBS ...)
(WITH-CALLBACK-EVENT (THE-EVENT DWA-CBS) (CASE # #)))
Warning: Variable DW-WINDOW defined but never used.
Warning: Variable GC defined but never used.
;; The warnings can easily be removed.
>> #<XLIB:WINDOW butsomi:0 50331669>
#<X Toolkit Connection, fd=7>
;; Here you click in the "drawing area".
>> dw = #<X Toolkit Widget: DRAWING-AREA 1B4988>
dwa-cbs = #<Motif Callback -- CR-INPUT>
cd = (#<XLIB:WINDOW butsomi:0 50331669> #<XLIB:GCONTEXT butsomi:0 46137345>)
A Toolkit error has occurred.
Unsupported argument type -- BIGNUM for 4160747712
Restarts:
0: [CONTINUE] Ignore problem and continue.
1: [KILL-APP] Close current application.
2: [ABORT ] Return to Top-Level.
Debug (type H for help)
(TOOLKIT-ERROR #<unavailable-arg> #<unavaliable-rest-arg>)
Source: Error finding source:
Error in function C::DO-CALL: Source file no longer exists:
target:motif/lisp/internals.lisp.
0]
-------------------------------------------
The problem seems to be in the encoding of the event passed to the
callback which gets finally passed to the internal unexported function
toolkit::transport-event.
Please help!
I do not know what to do next.
Thanks
--
Marco Antoniotti - Resistente Umano
-------------------------------------------------------------------------------
Robotics Lab | room: 1219 - tel. #: (212) 998 3370
Courant Institute NYU | e-mail: ·······@cs.nyu.edu
...e` la semplicita` che e` difficile a farsi.
...it is simplicity that is difficult to make.
Bertholdt Brecht