LispWorks CAPI User Guide > 9 Defining Interface Classes

NextPrevUpTopContentsIndex

9.2 An example interface

Here is a simple example of interface definition done with define-interface :

(define-interface demo ()
  ()
  (:panes
   (page-up push-button 
            :text "Page Up")
   (page-down push-button
              :text "Page Down")
   (open-file push-button
              :text "Open File"))
  (:layouts
   (row-of-buttons row-layout
                   '(page-up page-down open-file)))
  (:default-initargs :title "Demo"))

An instance of this interface can be displayed as follows:

(make-instance 'demo) (display *)

At the moment the buttons do nothing, but they will eventually do the following:

Figure 9.1 A demonstration of a CAPI interface

Later on, we will specify callbacks for these buttons to provide this functionality.

The (:default-initargs :title "Demo") part at the end is necessary to give the interface a title. If no title is given, the default name is "Untitled CAPI Interface".

Note: the define-interface form could be generated by the Interface Builder tool in the LispWorks IDE. See the LispWorks IDE User Guide for details. As the interface becomes more complex, you will find it more convenient to edit the definition by hand.

9.2.1 How the example works


LispWorks CAPI User Guide (Unix version) - 22 Dec 2009

NextPrevUpTopContentsIndex