7 Defining Interface Classes

7.2 An Example interface

Here is a simple example of interface definition done withdefine-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 7.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".

7.2.1 - How the example works

CAPI User Guide, Liquid Common Lisp Version 5.0 - 2 OCT 1997

Generated with Harlequin WebMaker