The macro define-interface is used to define subclasses of interface, the superclass of all CAPI interface classes.
It is an extension to defclass, which provides the functionality of that macro as well as the specification of the panes, layouts, and menus from which an interface is composed. It takes the same arguments as defclass, and supports the additional options :panes
, :layouts
, :menus
, and :menu-bar
.
If you specify :panes
but no :layouts
, then on creating your interface the CAPI will create a column-layout and arrange the panes in it in the order they are defined. For real applications you will need some control over how the panes are laid out, and this is supplied via the :layouts
option.
Each component of the interface is named in the code, and a slot of that name is added to the class created. When an instance of the class is made, each component is created automatically and placed in its slot.
To access a pane, layout or menu in an instance of your interface class you can define an accessor, like the viewer
pane in 11.3 Adapting the example, or simply use with-slots.
When defining a component, you can use other components within the definition simply by giving its name. You can refer to the interface itself by the special name capi:interface.
There are examples using define-interface in:
(example-edit-file "capi/applications/pong")
(example-edit-file "capi/applications/othello")
CAPI User Guide and Reference Manual (Unix version) - 01 Dec 2021 19:32:37