All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Chapter 9 Defining Application Frames > 9.2 Defining CLIM Application Frames

NextPrevUpTopContentsIndex

9.2.5 Examples of the :panes and :layout Options to define-application-frame

Here are some examples of how to use the :panes and :layouts options of define-application-frame to describe the appearance of your application.

We begin by showing Figure 18., an example of how CLIM supplies a default layout when you don't explicitly specify one in your frame definition. The default layout is a single column of panes, in the order (top to bottom) that you specified them in the :panes option. Command menus are allocated only enough space to display their contents, while the remaining space is divided among the other types of panes equally.

(define-application-frame test () ()
  (:panes
   (main :application
         :incremental-redisplay NIL
         :display-function 'display-main)
   (test-menu :command-menu)
   (listener :interactor))
  (:layouts 
   (:default
    (vertically () main test-menu listener))) 
  (:command-table
   (test-menu
    :inherit-from (user-command-table)
    :menu
    (("EXIT" :command cmd-exit)))))

 

Figure 18. The Default Layout for the Graphic-Demo Example
When No Explicit :layout Is Specified

Now we take the same example as before and in Figure 19. add an explicit :layout option to the frame definition. The pane named explanation occupies the bottom sixth of the screen. The remaining five-sixths are occupied by the demo and commands panes, which lie side by side, with the command pane to the right. The commands pane is only as wide as is needed to display the command menu.

(define-application-frame graphics-demo () ()
  (:menu-bar nil)
  (:panes
   (commands :command-menu)
   (demo :application)
   (explanation :application :scroll-bars nil))
  (:layouts
   (:default (vertically ()
                         (:fill
                          (horizontally ()
                                        (:fill demo)
                                        (1/5 commands)))
                         (1/6 explanation)))))

 

Figure 19. The Layout for the Graphic-Demo Example With an Explicit :layout

Finally, here is a stripped-down version of the application frame definition for the CAD demo (in the file <release-directory>/demo/new-cad-demo.lisp ) which implements an extremely simplistic computer-aided logic circuit design tool.

There are four panes defined for the application. The pane named title displays the string "Mini-CAD" and serves to remind the user which application is running. The pane named menu provides a menu of commands for the application. The pane named design-area is the actual "work surface" of the application on which various objects (logic gates and wires) can be manipulated. A pane named documentation is provided to inform the user about what actions can be performed using the pointing device (typically the mouse) and is updated based on what object is currently being pointed to.

The application has two layouts, one named main and one named other . Both layouts have their panes arranged in vertical columns. At the top of both layouts is the title pane, which is of the smallest height necessary to display the title string "Mini-CAD." Both layouts have the documentation pane at the bottom.

The two layouts differ in the arrangement of the menu and design-area panes. In the layout named main , the menu pane appears just below the title pane and extends for the width of the screen. Its height will be computed so as to be sufficient to hold all the items in the menu. The design-area pane occupies the remaining screen real estate, extending from the bottom of the menu pane to the top of the documentation pane, and is as wide as the screen.

To see the layout named other , enter (setf (frame-current-layout *application-frame*) :other) . This differs from the main layout in the shape of the design-area pane. Here the implementor of the CAD demo realized that, depending on what was being designed, either a short, wide area or a narrower but taller area might be more appropriate. The other layout provides the narrower, taller alternative by rearranging the menu and design-area panes to be side by side (forming a row of the two panes). The menu and design-area panes occupy the space between the bottom of the title pane and the top of the documentation pane, with the menu pane to the left and occupying as much width as is necessary to display all the items of the menu and the design-area occupying the remaining width.

(define-application-frame cad-demo () () 
  (:menu-bar nil)
  (:panes 
   (title :title :display-string "Mini-CAD") 
   (menu :command-menu) 
   (design-area :application) 
   (documentation :pointer-documentation))
  (:layouts 
   (:main (vertically ()
                      (1/8 title)
                      (1/8 menu)
                      (:fill design-area)
                      (1/8 documentation))) 
   (:other (vertically ()
                       (1/8 title)    
                       (:fill
                        (horizontally ()
                                      (1/4 menu)
                                      (:fill design-area)))  
                       (1/8 documentation)))))

 

 
Figure 20. The Two Layouts of the Mini-CAD Demo

Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017

NextPrevUpTopContentsIndex