The integrated cross-platform development tool for ANSI Common Lisp LispWorks logo

CAPI

A portable GUI toolkit

The Common Application Programming Interface (CAPI) is a portable GUI toolkit, supporting native look and feel on Microsoft Windows®, GTK+, Cocoa® and Motif®. The CAPI is included in LispWorks on all supported platforms. The LispWorks IDE is implemented using CAPI.

CAPI Features

  • Conceptually simple, CLOS-based model.
  • Standard set of elements including menus, buttons, toolbars, text panes, lists, graphs, scroll bars, tabs, dividers and so on.
  • Window-system specifics hidden from the programmer.
  • User-defined elements and interface classes.
  • Integrated with Graphics Ports drawing API.
  • Multiple-document interface (MDI) and docking supported on Microsoft Windows.
  • Comprehensive user guide and reference documentation.

Illustration

Using natural Lisp constructs, you can quickly build your own graphical interfaces with CAPI. Once your GUI runs on one platform, it is easily portable to another.

Here is simple CAPI interface running under the four supported window systems:

Example CAPI interface running under Cocoa Example CAPI interface running under GTK+
Example CAPI interface running under Windows Example CAPI interface running under Motif

The source code for this window is simple and elegant:


(capi:define-interface demo ()
  ()
  (:panes
      (page-up capi:push-button
               :text "Page Up"
               :selection-callback 'scroll-up)
      (page-down capi:push-button
                 :text "Page Down"
                 :selection-callback 'scroll-down)
      (open-file capi:push-button
                 :text "Open File"
                 :selection-callback 'file-choice)
      (viewer capi:editor-pane
              :title "File:"
              :text "No file selected."
              :visible-min-height '(:character 8)
              :reader viewer-pane))
   (:layouts
     (main-layout capi:column-layout 
                  '(row-of-buttons row-with-editor-pane))
     (row-of-buttons capi:row-layout
                     '(page-up page-down open-file))
     (row-with-editor-pane capi:row-layout
                           '(viewer)))
   (:menus 
     (file-menu "File"
                (("Open"))
                :selection-callback 'file-choice)
     (page-menu "Page"
                (("Page Up" 
                  :selection-callback 'scroll-up)
                 ("Page Down"
                  :selection-callback 'scroll-down))))
   (:menu-bar file-menu page-menu)
   (:default-initargs :title "Demo"))

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

You define functions file-choice etc to implement the callbacks.

You can try out the CAPI for yourself in the free LispWorks Personal Edition!

Top | Back