Generic FunctionPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version

widget-device

Arguments: dialog-item dialog

Every dialog-item instance that is placed onto a parent window has an associated widget-window or lisp-widget-window instance for the actual window that appears on the screen for the dialog-item. This generic function returns the name of the widget-window class that should be instantiated automatically for a dialog-item. Typically this class is based solely on the class of the dialog-item argument, and the dialog argument is ignored. Here, for example, is the method for radio-button:

(defmethod widget-device ((item radio-button) dialog)
  (declare (ignore dialog))
  'radio-button-pane)

If a widget-window or lisp-widget-window class needs to be subclassed along with a dialog-item class, then a widget-device method should also be written to map the dialog-item subclass to the widget-window subclass.

Most applications are not expected to need to subclass widget-window or lisp-widget-window classes, since the standard behavior built into each dialog-item is provided via the dialog-item instance itself rather than its associated widget-window instance. But if it is necessary to customize a dialog-item by adding methods to low-level generic functions such as mouse-left-down or virtual-key-down, then the widget-window or lisp-widget-window class may be subclassed to provide an application-specific class on which to define these methods.

Here is a simple example that subclasses the standard single-item-list control and causes the numeric keypad keys zero through nine to select one of the first ten values (respectively) in the list. (The NumLock key must first be toggled on if it is off.) A call-next-method allows the arrow keys and first letters of items to move to items as usual.

(defclass berry-list (single-item-list)())

(defclass berry-list-pane (single-item-list-pane)())

(defmethod widget-device ((dialog-item berry-list) dialog)
  (declare (ignore dialog))
  'berry-list-pane)

(defmethod virtual-key-down ((window berry-list-pane)
                             buttons key-code)
  (declare (ignore buttons))
  (if* (<= vk-numpad0 key-code vk-numpad9)
    then (let* ((widget (dialog-item window)))
           (setf (value widget)(nth (- key-code vk-numpad0)
                                    (range widget))))
    else (call-next-method)))

(let* ((item-list (make-instance 'berry-list
                    :left 20 :top 20 :width 150 :height 200
                    :range (list 'blueberries 'raspberries 'strawberries
                                 'gooseberries 'huckleberries 'chuckberries
                                 'chuckleberries 'groanberries 'blackberries
                                 'cloudberries)
                    :value 'raspberries))
       (dialog (make-window :berry-list-test
                 :class 'dialog
                 :title "Berry List Test"
                 :width 300 :height 400
                 :dialog-items (list item-list))))
  (select-window dialog)
  dialog)

Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version