how does code works
igor denisov
saufesma at gmail.com
Fri Nov 20 00:19:34 UTC 2020
There are places marked with question marks where I do not understand
what is going on. Can you explain them?
(in-package :common-lisp-user)
(defpackage :first-app
(:use :clim :clim-lisp)
(:export first-app))
(in-package :first-app)
(defun av-test-display-screen (frame pane)
(declare (ignore frame))
(with-text-size (pane :large)
(fresh-line pane)
(present '(com-reset-clock-1) 'command :stream pane)
(fresh-line pane)))
(define-application-frame av-test ()
((own-window-p :initform nil)) ;; These slots will typically hold
;; any per-instance frame state.
(:menu-bar t)
(:panes
(screen :application
:display-time t
:display-function #'av-test-display-screen
:text-style (make-text-style :sans-serif :roman :normal))
(interactor :interactor :min-width 600)
(doc :pointer-documentation))
(:layouts
(defaults
(vertically ()
screen
interactor
doc))))
;; default-frame-top-level will also establish a simple restart
;; for abort, and bind the standard stream variables. *query-io* will be bound
;; to the value returned by frame-query-io
(defun reset-clock-1 (&key (stream *query-io*) (ow t))
;; ^^^ ^^^ ^ ^
;; keyword-name var k-n v
(multiple-value-bind (second minute hour day month)
(decode-universal-time (get-universal-time))
(declare (ignore second)) ;; self explanatory, var second is not used
;; anywhere
(restart-case
;; restartable-form
(progn
;; For instance, an accepting-values whose fields consist of
;; gadgets may appear in an ordinary CLIM
;; stream pane.
;; For example, accepting-values dialogs can be implemented by
;; using an encapsulating stream that tailors calls to accept and
;; prompt-for-accept in such a way that the output is captured and
;; formatted into a dialog that contains prompts and fields
;; that can be clicked on and modified by the user.
;; (For example, the behavior of accepting-values can be implemented
;; by creating a special class of stream that turns calls to
;; accept into fields of a dialog.) ????????????? HOW TO???
;; accepting-values (&optional stream &key own-window exit-boxes
;; initially-select-query-identifier modify-initial-query
;; resynchronize-every-pass resize-frame align-prompts label
;; scroll-bars x-position y-position width height command-table
;; frame-class) &body body [Macro]
(clim:accepting-values (stream :own-window ow)
;; (accepting-values (stream :own-window ow)
;; same as?????
;; (accepting-values
;; (&optional stream
;; &key own-window
;; what is ow) ??????????
(format stream "Enter the time~%")
(setq month (clim:accept 'integer :stream stream
:default month :prompt "Month"))
(terpri stream)
(setq day (clim:accept 'integer :stream stream
:default day :prompt "Day"))
(terpri stream)
(setq hour (clim:accept 'integer :stream stream
:default hour :prompt "Hour"))
(terpri stream)
(setq minute (clim:accept 'integer :stream stream
:default minute :prompt "Minute")))
;; This could be code to reset the time, but instead
;; we’re just printing it out
(format nil "New values: Month: ~D, Day: ~D, Time: ~D:~2,'0D."
month day hour minute))
;; case-name is abort, it names this restart.
(abort () (format nil "Time not set")))))
(define-av-test-command (com-reset-clock-1 :name t :menu nil) ()
(with-slots (own-window-p) clim:*application-frame*
(format t "Result: ~S~%" (multiple-value-list
;; (defun reset-clock-1
;; (&key (stream *query-io*) (ow t)) ...)
(reset-clock-1 :ow own-window-p))))
(finish-output *standard-output*)) ;; ^ ^
;; |
av-test slot
;; no idea???
(defun first-app ()
(run-frame-top-level (make-application-frame 'av-test)))
Regards,
Igor.
More information about the mcclim-devel
mailing list