1 CAPI Reference Entries

define-interface

Macro

Summary

Thedefine-interface macro defines subclasses ofinterface.

Syntax

define-interface name superclasses slots &rest options

Description

The macrodefine-interface is used to define subclasses ofinterface, which when created withmake-instance has the specified panes, layouts and menus created automatically. The macro is essentially a version ofdefclass which accepts the following extra options:

:panes
Descriptions of the interface's panes.

:layouts
Descriptions of the interface's layouts.

:menus
Descriptions of the interface's menus.

:menu-bar
A list of menus for the interface's menu bar.

:definition
Options to alterdefine-interface.

The options:panes,:layouts and:menus add extra slots to the class that will contain the CAPI object described in their description. Within the scope of the extra options, the slots themselves are available by referencing the name of the slot, and the interface itself is available with the variablecapi:interface. Each of the slots can be made to have readers, writers or accessors by passing the appropriatedefclass keyword as one of the optional arguments in the description.

The:panes option is a list of pane descriptions of the following form

(:panes
  (slot-name pane-class initargs)
  ...
  (slot-name pane-class initargs)
)

where slot-name is a name for the slot, pane-class is the class of the pane being included in the interface, and initargs are the initialization arguments for the pane.

The:layouts option is a list of layout descriptions of the following form

(:layouts
  (slot-name layout-class children initargs)
  ...
  (slot-name layout-class children initargs)
)

where slot-name is a name for the slot, layout-class specifies the type of layout, children is a list of children for the layout, and initargs are the initialization arguments for the layout. The primary layout for the interface defaults to the first layout described, but can be specified as the:layout initarg to the interface. If no layouts are specified, then the CAPI will place all of the defined panes into a column layout and make that the primary layout.

The:menus option is a list of menu and menu component descriptions of the following form

(:menus
  (slot-name title descriptions initargs)
  ...
  (slot-name title descriptions initargs)
)

where slot-name is the slot name for each menu or menu component, title is the menu's title or the keyword:component, descriptions is a list of menu item descriptions, and initargs is a list of the initialization arguments for the menu. Each item description is either a title, or a list of items containing a title and a list of initialization arguments for the item.

The:menu-bar option is a list of slot names, where each slot referred to contains a menu that should appear on the menu bar.

The:definition option is a property list of arguments whichdefine-interface uses to change the way that it behaves. Currently there is only one definition option:

:interface-variable

The name of the variable containing the interface.

Compatibility Note

The variable that was bound to the interface itself was calledcapi::self in LispWorks 3.1, and has been kept for compatibility. However, it is recommended that you usecapi:interface or specify your own name using:interface-variable.

Examples

Firstly, a couple of pane examples:

(capi:define-interface test1 ()
  ()
  (:panes
    (text capi:text-input-pane))
  (:default-initargs :title "Test1"))

(capi:display (make-instance 'test1))

(capi:define-interface test2 () () (:panes (text capi:text-input-pane) (buttons capi:button-panel :items '(1 2 3))) (:layouts (main-layout capi:column-layout '(text buttons))) (:default-initargs :title "Test2"))

(capi:display (make-instance 'test2))

Here are a couple of menu examples:

(capi:define-interface test3 ()
  ()
  (:menus
    (color-menu "Colors" (:red :green :blue)
       :print-function 'string-capitalize))
  (:menu-bar color-menu)
  (:default-initargs :title "Test3"))

(capi:display (make-instance 'test3))

(capi:define-interface test4 () () (:menus (color-menu "Colors" ((:component (:red :green :blue) :interaction :single-selection :print-function 'string-capitalize)))) (:menu-bar color-menu) (:default-initargs :title "Test4"))

(capi:display (make-instance 'test4))

Example Files

capi/elements/graph-pane.lisp
capi/tools/pathname-selector.lisp

See Also

interface
layout
menu


CAPI Reference Manual, Liquid Common Lisp Version 5.0 - 3 OCT 1997

Generated with Harlequin WebMaker