Anonymous user
Simple windowed application: Difference between revisions
→{{header|Common Lisp}}: improved version using commands
(→Common Lisp: new example) |
(→{{header|Common Lisp}}: improved version using commands) |
||
Line 181:
{{works with|McCLIM}}
<lang
(:use #:clim #:clim-lisp))
(in-package #:rcswa)</lang>
This version uses CLIM's command system:
(define-application-frame simple-windowed-application ()▼
▲<lang lisp>(define-application-frame simple-windowed-application ()
((clicks :initform 0
:accessor clicks-of))
(:menu-bar t)
(:pane
(make-pane 'application-pane
:width '(40 :character)
:height '(3 :character)
:display-time :command-loop
:display-function
(lambda (pane stream)
(declare (ignore pane))
(format stream "~[There have been no clicks yet.~
~:;~:*There ~[have~;has~:;have~]~:* been ~R click~:P.~]"
(clicks-of *application-frame*))))))
(define-simple-windowed-application-command (com-click-me :menu t)
()
(incf (clicks-of *application-frame*)))</lang>
This version uses an explicit pushbutton gadget, and may be used if more direct control over the UI layout and behavior is needed:
<lang lisp>(define-application-frame simple-windowed-application ()
((clicks :initform 0
:accessor clicks-of))
(:panes
(the-label :
:
:
:
:
(lambda (pane stream)
(declare (ignore pane))
(format stream "~[There have been no clicks yet.~
~:;~:*There ~[have~;has~:;have~]~:* been ~R click~:P.~]"
(clicks-of *application-frame*))))
(the-button :push-button
:label "Click Me"
Line 200 ⟶ 229:
(declare (ignore button))
(incf (clicks-of *application-frame*))
(
(:layouts (default
(vertically (:equalize-width nil :align-x :center)
the-label
(spacing (:thickness 10) the-button)))))</lang>
In either case, the window is opened with:
<lang lisp>(run-frame-top-level (make-application-frame 'simple-windowed-application))</lang>
=={{header|D}}==
|