Using the :panes and :layouts Options
panes
- are rectangular objects
- divide up the application frame's screen space
- are similar to the gadgets or widgets of other toolkits
- can be used to compose the top-level user interface of applications
- can be used to compose auxiliary components such as menus and dialogs
- can be structurally classified according to their location in pane hierarchies
- are implemented as special sheet classes
Kinds of Panes
- composite panes
- are used to provide a mechanism for spatially organizing ("laying out") other panes
- leaf panes
- may implement gadgets that have some appearance and react to user input by invoking application code
- extended stream pane
- provides an area of the application's screen real estate for the presentation of text and graphics
- abstract panes
- are panes that are defined only in terms of their programmer interface or behavior
- have a protocol (that is, the specified set of initialization
options, accessors, and callbacks) that is designed to specify the
pane in terms of its overall purpose, rather then in terms of its
specific appearance or particular interactive details
- allow multiple implementations to define their own specific look
and feel individually
- adaptive panes
- have been defined to integrate well across all CLIM operating platforms
Constructing Panes
- use make-pane of an abstract class name
- results in more portable code
- invokes the "look and feel" realization process to select and
construct a pane
- invoked using an abstract pane class name, which by convention is
a symbol in the CLIM package that doesn't include the -pane suffix
- however, you are allowed to pass any pane class name to make-pane
- use make-instance to create a concrete pane
- requires the application programmer to know the name of the
specific pane implementation class that is desired, and so is
inherently less portable
- By convention, all of the concrete pane class names, including
those of the implementations of abstract pane protocol
specifications, end in -pane
Using the :panes
and :layouts
options within define-application-frame
(defun press (button) (accepting-values (*query-io* :own-window t) (format *query-io* "~A" arg)))
(defun squeeze (button) (accepting-values (*query-io* :own-window t) (format *query-io* "~A" arg)))
(define-application-frame buttons ;name
() ;superclasses
() ;slots
;; options
(:panes (button
(horizontally ()
(make-pane 'push-button :label "squeeze" :activate-callback #'squeeze)
(make-pane 'push-button :label "press" :activate-callback #'press)))
(application ;pane name
:application)) ;pane type ... :application is an extended-stream-pane
(:layouts (default ;layout name
(vertically () ;layout macros
(1/8 button) (7/8 application)))
(alternate ;layout name
(horizontally () ;layout macros
(1/8 button) (7/8 application)))))
Laying Out Panes
You can change between layouts with something like this:
(let* ((layouts (frame-all-layouts *application-frame*))
(old-layout (frame-current-layout *application-frame*))
(new-layout (or (second (member old-layout layouts))
(car layouts))))
(setf (frame-current-layout *application-frame*) new-layout))
Exercises