Next Prev Up Top Contents Index

toolbar-button

Class
Summary

This class is used to create instances of toolbar buttons.

 
Superclasses

item
toolbar-object

Initargs

:callback

A function that is called when the toolbar button is pressed.

:image

A slot specifying the image to use for the toolbar button.

:tooltip

An optional string which is displayed when the mouse moves over the button.

:help-key

An object used for lookup of help. Default value t .

:remapped

Links the button to a menu item.

Readers

help-key

Description

Toolbar buttons may be placed within toolbars and toolbar components. However, there is usually no need to create toolbar buttons explicitly; instead, the callbacks , images and tooltips arguments to toolbar or toolbar-component can be used.

image may be one of the following:

A pathname or string

This specifies the filename of a file suitable for loading with load-image. Currently this must be a bitmap file.

A symbol

The symbol must either have been previously registered by means of a call to register-image-translation, or be one of the following symbols, which map to standard images: :std-cut , :std-copy , :std-paste , :std-undo , :std-redo , :std-delete , :std-file-new , :std-file-open , :std-file-save , :std-print , :std-print-pre , :std-properties , :std-help , :std-find and :std-replace

An image object, as returned by load-image.

An image locator object

This allows a single bitmap to be created which contains several button images side by side. See make-image-locator for more information. On Windows, this also allows access to bitmaps stored as resources in a DLL.

An integer

This is a zero-based index into the default-image-set of the toolbar or toolbar component in which the toolbar button is used.

The image should be of the correct size for the toolbar. By default, this is 16 pixels wide and 16 pixels high.

help-key is interpreted as described for element.

remapped , if non- nil , should match the name of a menu-item in the same interface as the button. Then, the action of pressing the button is remapped to selecting that menu-item and calling its callback . The default value of remapped is nil .

Example

A callback function:

(defun do-redo (data interface)
  (declare (ignorable data interface))
  (capi:display-message "Doing Redo"))

A simple interface:

(capi:define-interface redo ()
  ()
  (:panes
   (toolbar
    capi:toolbar
    :items
    (list
     (make-instance
      'capi:toolbar-component
      :items 
      (list (make-instance
             'capi:toolbar-button
             ;; remap it to the menu item
             :remapped  'redo-menu-item
             :image :std-redo))))))
  (:menu-bar a-menu)
  (:menus
   (a-menu
    "A menu"
    (("Redo" :name 'redo-menu-item
             :selection-callback 'do-redo
             :accelerator #\control-\y))))
  (:layouts
   (main
    capi:row-layout
    '(toolbar)))
  (:default-initargs
   :title "Redo"))

In this interface, pressing the toolbar button invokes the menu item callback:

(capi:display (make-instance 'redo))
See also

make-image-locator
menu-item
toolbar
toolbar-component


LispWorks CAPI Reference Manual - 13 Mar 2003

Next Prev Up Top Contents Index