add-to-component-toolbar

Function

Package: common-graphics

Arguments: component-class-name pixmap-or-title &key after tooltip help-string

This function allows developers to extend the IDE to include there own classes. It adds a new button to the IDE's Component Toolbar to allow a specified control class to be interactively instantiated onto a form. The control class is also added to the list of component classes presented by the Form | Add Component menubar command. If the class is already represented on the Component Toolbar, then no button is added.

The new button will remain on the toolbar only as long as the current invocation of Allegro is still running, rather than being added back automatically the next time that Allegro starts up. If a project defines a custom control class, you may want to add a call to add-to-component-toolbar to the project's source code (i.e. the project .lpr file) as a top-level form --- then the control class will be added to the toolbar if needed whenever the project is loaded.

component-class-name is either the name of a control class to be added or the symbol :gap. Specifying :gap inserts a small gap (with a thin bar drawn in it) between groups of buttons, as usual with a multi-picture-button range. A multi-picture-button will automatically filter out multiple contiguous gaps, so an application does not have to worry about whether a gap is already where one is desired.

pixmap-or-title is either a pixmap object to display on the toolbar's button for the control, or a string to display instead.

after may be the name of a control class that may already be on the toolbar, or the symbol :last, or nil. If it is a class name and there is a button on the toolbar for that class, then the new button is placed just to the right of the specified button. If it is the symbol :last, then the new button is placed after the last (rightmost) button. Otherwise the new button is placed at the left end of the toolbar.

tooltip is a string to display in a tooltip when the mouse cursor pauses over the button. Defaults to the name of the class, except with spaces in place of dashes, and each word capitalized.

help-string is a string to display in the IDE's status bar to indicate what the button will do if clicked. Defaults to a standard message about adding the particular type of control.

See remove-from-component-toolbar, which removes components (either your own or standard ones) from the toolbar.

Example:

;; Define a custom single-item-list.
(defclass pretty-item-list (single-item-list)()
  (:default-initargs
   :background-color cyan))

;; Define a pixmap to represent the custom control class.
(cache-pixmap
 (make-instance 'pixmap
   :name 'pretty-item-list
   :bits-per-pixel 4
   :colors (default-palette-vector *system*)
   :contents
   '(( 7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7)
     ( 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0)
     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)

     ( 0 14  0 14  0 14  0 14 14 14 14 14 14 14 14  0)
     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)
     ( 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0)
     ( 0  0 14  0 14  0 14  0 14  0  0  0  0  0  0  0)
     ( 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0)
     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)
     ( 0 14  0 14  0 14  0 14 14 14 14 14 14 14 14  0)
     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)
     ( 0  8  8  8  8  8  8  8  8  8  8  8  8  8  8  0)

     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)
     ( 0 14  0 14  0 14  0 14 14 14 14 14 14 14 14  0)
     ( 0 14 14 14 14 14 14 14 14 14 14 14 14 14 14  0)
     ( 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0))))

;;; Add a button using the above pixmap to instantiate the custom control.
(devel:add-to-component-toolbar 'pretty-item-list
 (find-pixmap 'pretty-item-list) :after 'single-item-list)

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.