
A Guided Tour of CLIM, Common Lisp Interface Manager 2006 Update Clemens Fruhwirth <[email protected]> The McCLIM Project Original article∗ Ramana Rao <[email protected]> Xerox Palo Alto Research Center William M. York <[email protected]> International Lisp Associates, Inc. Dennis Doughty <[email protected]> International Lisp Associates, Inc. October 14, 2019 Abstract Introduction Common Lisp is a language standard that has pro- The Common Lisp Interface Manager (clim) pro- vides a layered set of facilities for building user in- vided a broad range of functionality, and that has, terfaces. These facilities include a portable lay- to a large degree, successfully enabled the writing ers for basic windowing, input, output services, of truly portable Lisp programs. The emergence and mechanisms for constructing window types and of clos and the cleanup efforts of ANSI X3J13 user interface components; stream-oriented input have further enhanced the utility and portability and output facilities extended with presentations of Common Lisp. However, one major stumbling and context sensitive input;1 and a gadget-oriented block remains in the path of those endeavoring to toolkit similar to those found in the X world ex- write large portable applications. The Common tended with support for look and feel adaptiveness. Lisp community has not yet provided a standard interface for implementing user interfaces beyond In this article, we present an overview of clim's broad range of functionality and present a series of the most basic operations based on stream reading and printing.3 examples that illustrates clim's power. The arti- cle originally appeared in Lisp Pointers in 1991 and The Common Lisp Interface Manager addresses was updated in 2006 by Clemens Fruhwirth.2 All this problem by specifying an interface to a broad range of services necessary or useful for develop- examples in this article have been run with Mc- ing graphical user interfaces. These services in- CLIM[McC], a free clim implementation, as of January 2006. clude low level facilities such as geometry, graphics, event-oriented input, and windowing; intermediate level facilities such as support for Common Lisp ∗Published in Lisp Pointers 1991 stream operations, output recording, and advanced 1Similar to the work pioneered in the Genera UI system 2The CLIM 2 specification changed significant parts of output formatting; and high level facilities such as clim rendering legacy code unusable. Clemens Fruhwirth context sensitive input, an adaptive toolkit, and an has rewritten all examples and the corresponding text sec- application building framework. tions for the clim 2 specification. In addition, he has restruc- tured the whole article, adding sections to provide additional 3Notice that this sentence was written in 1991; it is still insights into clim concepts. true 15 years later. 1 clim implementations will eventually support a libraries that define and implement their own par- large number of window environments including ticular look and feel. For instance, the clim pro- X Windows, Mac OS X and Microsoft Windows. grammer can implement new gadget types on top clim is designed to exploit the functionality pro- of the drawing primitives and treat them equally to vided by the host environment to the degree that it the built-in gadget types. makes sense. For example, clim top level windows We will use the term CLIM implementor for the are typically mapped onto host windows, and input party implementing low-level and high-level parts and output operations are ultimately performed by according to the clim specification, CLIM pro- host window system code. clim supports the in- grammer for the party that will use the facilities corporation of toolkits written in other languages. provided by the implementor, and CLIM user for A uniform interface provided by clim allows Lisp the party that will use the programs provided by application programmers to deal only with Lisp ob- the programmer. jects and functions regardless of the operating plat- The next section presents an overview of the form. functionality provided by clim facilities. An important goal that has guided the design of clim was to layer the specification into a number of distinct facilities. Furthermore, the specification 1 Overview of Functionality does not distinguish the use of a facility by higher level clim facilities from its use by clim users. For Figure 1 shows the various aspects of a host envi- example, the geometry substrate, which includes ronment in which clim lives as well as the various transformations and regions, is designed for effi- elements provided by clim. Below we briefly de- cient use by the graphics and windowing substrates scribe a number of clim's areas of functionality. as well as by clim programmers. This means that, Later sections will illustrate many of these compo- in general, a clim programmer can reimplement nents. higher level clim facilities using the interfaces pro- vided by lower level facilities. Geometry clim provides points, rectangles, and This modular, layered design has a number of transformations; and functions for manipulating benefits. The clim architecture balances the goal these object types. of ease of use on one hand, and the goal of versa- tility on the other. High level facilities allow pro- Graphics substrate clim provides a portable grammers to build portable user interfaces quickly, interface to a broad set of graphics functions for whereas lower level facilities provide a useful plat- drawing complex geometric shapes. form for building toolkits or frameworks that better support the specific needs or requirements of a par- Windowing substrate clim provides a ticular application. portable layer for implementing sheets (windows For example, clim's application framework and and other window-like objects). adaptive toolkit allow programmers to develop ap- plications that automatically adopt the look and feel of the host's environment. We often call this Extended Streams clim integrates the Com- \adaptiveness," \look and feel independence," or mon Lisp Stream I/O functionality with the clim occasionally more picturesquely, \chameleon look graphics, windowing, and panes facilities. In addi- and feel". However, many users may need or want tion to ordinary text, the programmer can send a to define a particular look and feel that is constant button, a picture or any other arbitrary widget to a across all host environments (we call this \portable clim output stream and clim will display the wid- look and feel"). Such users can circumvent the get in the sheet associated with the output stream. look and feel adaptiveness provided by clim, while still using most of the application framework facil- Output Recording clim provides output ity and other high level clim facilities like context recording for capturing all output done to an sensitive input. Furthermore, using the lower level extended stream and automatically repainting it facilities of clim, they can develop portable toolkit when necessary. 2 Application Dialog Facilities PresentationsCommands Frames Formated Output Incremental Redisplay Layout Panes Application Panes Output Recording Gadget Panes Panes Extended Streams Standard Sheets Graphics Sheet Definition Geometry Ports Common Lisp Host Look & Feel Figure 1: An Overview of clim facilities Formatted Output clim provides a set of high- panes for displaying and allowing users to interact level macros that enable programs to produce with application data. neatly formatted tabular and graphical displays easily.4 Look and Feel Adaptiveness clim supports look and feel independence by specifying a set of Presentations clim provides the ability to asso- abstract gadget pane protocols. These protocols ciate semantics with output, such that Lisp objects define a gadget in terms of its function and not may be retrieved later via user gestures (e.g. mouse in terms of the details of its appearance or oper- clicks) on their displayed representation. This con- ation. Applications that use these gadget types text sensitive input is modularly layered on top of and related facilities will automatically adapt to the output recording facility and is integrated with use whatever toolkit is available on and appropri- the Common Lisp type system. A mechanism for ate for the host environment. In addition, portable type coercion is also included, providing the basis Lisp-based implementations of the abstract gadget for powerful user interfaces. pane protocols are provided.5 Panes clim provides panes that are analogous to the gadgets or widgets of toolkits like the X toolkit, Application Building clim provides a set of GTK or Mac OS X's toolkit. tools for defining application frames. These tools Supported pane types include layout panes for allow the programmer to specify all aspects of arranging other panes, gadget panes for present- an application's user interface, including pane lay- ing users with feedback information or mechanisms out, interaction style, look and feel, and command for invoking application behavior, and application menus and/or menu bars. 4This also includes Graph Formatting. Graph formatting 5McCLIM does not support look and feel adaptiveness is only partly implemented in McCLIM at this date (March at the moment. Hence, McCLIM mostly uses this portable 2006). Lisp-based implementation. 3 Commands clim supports the separation of provide pointers and references and hope that the command execution and command invocation. A interested reader starts to explore the surrounding clim user can invoke commands either via typing text sections on his own. it into an interactor, clicking on a menu entry or im- After loading a clim implementation, the pack- plicitly invoking a presentation-translator by click- age :clim-user is available to absorb user code. This ing on a presentation. Commands can also be in- package is a good start for experimentation and voked explicitly by the programmer. first steps. When proper packaging is required, sim- ply include the packages :clim and :clim-lisp in your Dialogs and Incremental Update/Redisplay new package's :use list. Incremental Redisplay goes a bit further than Out- The central element of clim application pro- put Recording.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages23 Page
-
File Size-