how does code works
Rainer Joswig
joswig at lisp.de
Fri Nov 20 22:59:26 UTC 2020
(with-slots (own-window-p) ; the slot and then conceptually a variable of the same name
frame ; the object from which to use the slot
own-window-p) ; the variable
so
(with-slots (own-window-p)
frame
(foo :bar own-window-p))
calls the function FOO and passes the value of OWN-WINDOW-P to the keyword arg BAR
> Am 20.11.2020 um 23:33 schrieb igor denisov <saufesma at gmail.com>:
>
>> It's a good idea to check the documentation of the used CLIM functions and CLIM macros in a CLIM reference.
>
> You have no idea how hard I check on that but my understanding of the
> hole is going really slow. And it is not so obvious to me.
>
>> It gets called with keyword arg :OW and its value is the value of the slot value of the application frame.
>
> This is slot value of the application frame?
> ((own-window-p :initform nil))
>
> if so, I do not understand how that value was passed to keyword arg :OW
> Can you show me how it was passed?
>
> Whatever input I have to pass to app, I am being forced to use
> accepting-values macro or there are some other options?
>
> I would really appreciate any code on input and output of any app.
> More is better.
>
> Looking forward your reply.
>
> On 11/20/20, Rainer Joswig <joswig at lisp.de> wrote:
>> The application frame has a slot OWN-WINDOW-P . This should control whether
>> the reset clock UI uses its own dialog window for resetting the clock
>> values.
>>
>> if one uses the command :RESET CLOCK 1, then the reset-clock-1 function gets
>> called.
>> It gets called with keyword arg :OW and its value is the value of the slot
>> value of the application frame.
>>
>> Inside the function RESET-CLOCK-1 there is use of the macro
>> CLIM:ACCEPTING-VALUES.
>> The value of the variable OW is used as a value for the keyword option
>> :OWN-WINDOW.
>> At runtime this macro then will either
>>
>> :own-window nil -> create the UI for resetting the clock inline
>>
>> or
>>
>> :own-window t -> create a new window dialog for resetting the clock
>>
>>
>> It's a good idea to check the documentation of the used CLIM functions and
>> CLIM macros in a CLIM reference.
>>
>>
>>
>>> Am 20.11.2020 um 01:19 schrieb igor denisov <saufesma at gmail.com>:
>>>
>>> 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