Next Prev Up Top Contents Index

button-panel

Class
Summary

The class button-panel is a pane containing a number of buttons that are laid out in a particular style, and that have group behavior.

Superclasses

choice
titled-object
simple-pane

Subclasses

push-button-panel
radio-button-panel
check-button-panel

Slots

layout-class

The type of layout for the buttons.

layout-args

Initialization arguments for the layout.

callbacks

The selection callbacks for each button.

Description

The class button-panel inherits most of its behavior from choice , which is an abstract class providing support for handling items and selections. By default, a button panel is single selection (meaning that only one of the buttons can be selected at any one time), but this can be changed by specifying an interaction.

The subclasses push-button-panel , radio-button-panel and check-button-panel are provided as convenience classes, but they are just button panels with different interactions ( :no-selection , :single-selection and :multiple-selection respectively).

The layout of the buttons is controlled by a layout of class layout-class (which defaults to row-layout ) but this can be changed to be any other CAPI layout. When the layout is created, the list of keyword arguments layout-args is passed to the make-instance .

Each button uses the callbacks specified for the button panel itself, unless the argument callbacks is specified. This should be a list of callbacks (one per button) which if non- nil will be used for the selection-callback .

For button-panel and its subclasses, the items supplied to the :items initarg and (setf collection-items) function can contain button objects. In this case, the button is used directly in the button panel rather than a button being created by the CAPI.

This allows button size and spacing to be controlled explicitly. Note that the button must be of the appropriate type for the subclass of button-panel being used, as shown in the following table:

 

Button and panel classes

Button panel class

Button class

push-button-panel push-button
radio-button-panel radio-button
check-button-panel check-button

For example,

(let ((button1 (make-instance `capi:push-button
                              :text "button1"
                              :internal-border 20
                              :visible-min-width 200))
      (button2 (make-instance `capi:push-button
                              :text "button2"
                              :internal-border 20
                              :visible-min-width 200)))
  (capi:contain (make-instance `capi:push-button-panel
                           :items (list button1 button2)
                           :layout-args `(:x-gap 30))))
Compatibility Note

Button panels now default to having a maximum size constrained to their minimum size as this is useful when attempting to layout button panels into arbitrary spaces without them changing size. To get the old behavior, specify :visible-max-width nil in the make-instance .

Example
(capi:contain (make-instance
               'capi:button-panel
               :items '(:red :green :blue)
               :print-function 'string-capitalize)
              :process nil)
(setq buttons (capi:contain
               (make-instance
                'capi:button-panel
                :items '(:red :green :blue)
                :print-function 'string-capitalize
                :interaction :multiple-selection)))
(setf (capi:choice-selected-items buttons)
       '(:red :green))
(capi:contain (make-instance
               'capi:button-panel
               :items '(1 2 3 4 5 6 7 8 9)
               :layout-class 'capi:grid-layout
               :layout-args '(:columns 3)))
See also

radio-button
check-button
push-button
set-button-panel-enabled-items


LispWorks CAPI Reference Manual - 14 Dec 2001

Next Prev Up Top Contents Index