All Manuals > CAPI User Guide > 7 Laying Out CAPI Panes > 7.5 Advanced pane layouts

NextPrevUpTopContentsIndex

7.5.2 Tab layouts

In its simplest mode, a tab layout is similar to a switchable layout, except that each pane is provided with a labelled tab, like the tabs on filing cabinet folders or address books. If the tab is clicked on by the user, the pane it is attached to is pulled to the front. Don't forget to close the switchable layout window created in the last example before displaying this:

(make-instance 'tab-layout
               :items (list (list "one" red-pane)
                            (list "two" green-pane)
                            (list "three" blue-pane))
               :print-function 'car
               :visible-child-function 'second)
(contain *)

Figure 7.7 A tab layout

The example needs the :print-function to be car , or else the tabs will be labelled with the object numbers of the panes as well as the title provided in the list.

However, a tab layout can also be used in a non-switchable manner, with each tab responding with a callback to alter the appearance of only one pane. In this mode the :description keyword is used to describe the main layout of the tab pane. In the following example the tabs alter the choice of starting node for one graph pane, by using a callback to the graph-pane-roots accessor:

(defun tab-graph (items)
  (let* ((gp (make-instance 'graph-pane))
         (tl (make-instance 'tab-layout
               :description (list gp)
               :items items
               :visible-child-function nil
               :key-function nil
               :print-function (lambda (x) (format nil "~R" x))
               :callback-type :data
               :selection-callback #'(lambda (data)
                                       (setf (graph-pane-roots gp)
                                             (list data))))))
  (contain tl)))
(tab-graph '(1 2 4 5 7))

CAPI User Guide (Macintosh version) - 30 Aug 2011

NextPrevUpTopContentsIndex