To define a gadget pane implementation, first define the appearance and layout behavior of the gadget, next define the callbacks, and last define the specific user interactions that trigger the callbacks.
For example, to define an odd new kind of button that displays itself as a circle and is activated whenever the mouse is moved over it, proceed as follows:
;; A new kind of button
(defclass sample-button-pane (gadget-pane) ())
;; An arbitrary size parameter
(defparameter *sample-button-radius* 10)
;; Define the sheet's repaint method to draw the button.
(defmethod handle-repaint ((button sample-button-pane) region
&key medium &allow-other-keys)
(let ((radius *sample-button-radius*)
(half (round *sample-button-radius* 2)))
;; Larger circle with small one in the center.
(draw-circle* medium radius radius radius :filled nil)
(draw-circle* medium radius radius half :filled t)))
;;; Define the pane's compose-space method to always request the
;;; fixed size of the pane.
(defmethod compose-space ((pane sample-button-pane))
(make-space-requirement :width (* 2 *sample-button-radius*)
:height (* 2 *sample-button-radius*)))
The previous code is enough to allow you to instantiate the button pane in an application frame. It will fit in with the space composition protocol of, for example, an hbox-pane . It will display itself as two nested circles.
The next step is to define the callbacks supported by this gadget, and the user interaction that triggers them. The resulting pane is a leaf pane .
;; This default method is defined so that the callback can be invoked
;; on an arbitrary client value without error.
(defmethod value-change-callback
((button sample-button-pane) client id value)
(declare (ignore client id value)))
;; This event processing method defines the rather odd interaction
;; style of this button, to wit: it triggers the activate callback
;; whenever the mouse moves into it.
(defmethod enter-region
((pane sample-button-pane) &key &allow-other-keys)
(value-change-callback pane
(gadget-client pane) (gadget-id pane) nil))
Common Lisp Interface Manager 2.0 User's Guide - 3 Mar 2015