9.7.1 Defining a CLIM Application Frame

Here is an example of an application frame. This frame has three slots:
pathname
,
integer
, and
member
. It has two panes, an
:accept-values
pane named
avv
and an
:application
pane named
display
. It uses a command table named
dingus
, which will automatically be defined for it (see
define-command-table
) and which inherits from the
accept-values-pane
command table so that the accept-values pane will function properly.

(clim:define-application-frame

dingus ()

((pathname :initform #p"foo")

(integer :initform 10)

(member :initform :one))

(:panes

(avv :accept-values

:display-function '(clim:accept-values-pane-displayer

:displayer display-avv))

(display :application :display-function 'draw-display

:display-after-commands :no-clear))

(:command-table (dingus :inherit-from (clim:accept-values-pane)))) (:command-table (dingus :inherit-from (clim:accept-values-pane))))The following is the display function for the
display
pane of the "dingus" application. It just prints out the values of the three slots defined for the application.

(defmethod draw-display ((frame dingus) stream)

(with-slots (pathname integer member) frame

(fresh-line stream)

(clim:present pathname 'pathname :stream stream)

(write-string ", " stream)

(clim:present integer 'integer :stream stream)

(write-string ", " stream)

(clim:present member '(member :one :two :three)

:stream stream)

(write-string "." stream)))

The following is the display function for the
avv
pane. It invokes
accept
for each of the application's slots so that the user can alter their values in the
avv
pane.

(defmethod display-avv ((frame dingus) stream)

(with-slots (pathname integer member) frame

(fresh-line stream)

(setq pathname

(clim:accept 'pathname :prompt "A pathname"

:default pathname :stream stream))

(fresh-line stream)

(setq integer

(clim:accept 'integer :prompt "An integer"

:default integer :stream stream))

(fresh-line stream)

(setq member

(clim:accept '(member :one :two :three)

:prompt "One, Two, or Three"

:default member :stream stream))

(fresh-line stream)

(clim:accept-values-command-button

(stream :documentation "You wolf")

(write-string "Wolf whistle" stream)

(beep))))

The following function will start up a new "dingus" application.

(defun run-dingus (root)

(let ((dingus (clim:make-application-frame

'dingus :width 400 :height 400)))

(clim:run-frame-top-level dingus)))

All this application does is allow the user to alter the values of the three application slots,
pathname
,
integer
, and
member,
using the
avv
pane. The new values will automatically be reflected in the
display
pane.