Common Lisp Interface Manager (CLIM) PREFACE
Total Page:16
File Type:pdf, Size:1020Kb
Common Lisp Interface Manager (CLIM) PREFACE This book documents how to develop programs using the Common Lisp Interface Manager (CLIM), Release 2.0. It is intended for use by programmers who are expe rienced with Common Lisp and CLOS programming concepts. This book is useful for a programmer writing CLIM 2.0 applications on any Lisp platform, but includes some material that is specific to CLIM on Genera and Cloe. Organization This document has these major parts: "What is CLIM?" Describes the roots of CLIM 2.0, gives a technical overview of it, and compares it to Genera’s Dynamic Win dows. "CLIM Tutorial" Gets you started developing programs in CLIM with ex tended examples that you can run. This section introduces the important concepts of CLIM via these examples. "CLIM User’s Guide" Provides conceptoriented reference documentation cover ing topics in more detail than the Tutorial. The chapters in the User’s Guide also include summaries of functions, classes, macros, etc., which are documented more fully in the Dictionary. "CLIM Dictionary" Provides detailed reference documentation of CLIM func tions, classes, macros, and so forth, in alphabetic order. You can use the CLIM Dictionary when you need to know the syntax and semantics of a particular CLIM operator. "Glossary of CLIM Terminology" Provides a description of many CLIM terms. How to Use This Book Start with "What is CLIM?" for background information and a technical overview of CLIM. When you are ready to start programming, proceed to the "CLIM Tutorial", and experiment with the examples. Code for these examples can be found in the direc tory SYS:CLIM;REL2;TUTORIAL;. The directory SYS:CLIM;REL2;DEMO; is also a rich source of example code. When you want to learn about a topic in more detail, you can use the "CLIM User’s Guide" and the "CLIM Dictionary"). Page 1140 Documentation Conventions This documentation uses the following notation conventions: cond, clim:accept Printed representation of Lisp objects in running text. Return, Abort, control-F Keys on the keyboard. SPACE or Space The space bar. login Literal typein. (makesymbol "foo") Lisp code examples. (myfind item list &optional test &key :start :end) Syntax description of the invocation of the function myfind. item, list, test Arguments to the function myfind, usually expressed as a word that reflects the type of argument (for ex ample, string). :start, :end Keyword arguments to the function myfind. &optional, &key Introduces optional or keyword argument(s). Show File, Start Command processor command names appear with the initial letter of each word capitalized. mX Insert File, Insert File (mX) Extended command names in Zmacs, Zmail, and Sym bolics Concordia appear with the m-X notation either preceding the command name, or following it in parentheses. Both versions mean press m-X and then type the command name. [Map Over] Menu items. Click Left to select a menu item, unless other operations are indicated. (See the section "Mouse Command Conventions".) Left, Middle, Right Pointer gestures (also known as mouse clicks). shift-Right, c-m-Middle Modified mouse clicks. For example, shift-Right means hold down the SHIFT key while clicking Right on the mouse, and c-m-Middle means hold down the CONTROL and META keys while clicking Middle. Modifier Key Conventions Modifier keys are designed to be held down while pressing other keys. They do not themselves transmit characters. A combined keystroke like Meta-X is pronounced "meta x" and written as m-X. This notation means that you press the META key and, while holding it down, press the X key. Modifier keys are abbreviated as follows: CONTROL c- or control Page 1141 META m- or meta SUPER s- or super HYPER h- or hyper SHIFT sh- or shift These modifier key names are based on the labels on a Symbolics keyboard, and most keyboards do not label their modifier key names the same way. This is just a convention; nonSymbolics machines will simply use differently labelled keys on the keyboard. Modifier keys can be used in combination, as well as singly. For example, the nota tion c-m-Y indicates that you should hold down both the CONTROL and the META keys while pressing Y. Modifier keys can also be used, both singly and in combination, to modify mouse commands. For example, the notation sh-Left means hold down the SHIFT key while clicking Left on the mouse and c-m-Middle means hold down CONTROL and META while clicking Middle. The keys with white lettering (like X or SELECT) all transmit characters. Combina tions of these keys should be pressed in sequence, one after the other (for exam ple, SELECT L). This notation means that you press the SELECT key, release it, and then press the L key. Trademarks CLIM is a registered trademark of International Lisp Associates (ILA). Microsoft and MSDOS are registered trademarks of Microsoft Corporation. Windows, Windows/286 and Windows/386 are trademarks of Microsoft Corporation. Intel and 386 are trademarks of Intel Corporation. Adobe and PostScript are registered trademarks of Adobe Systems Inc. What is CLIM? Technical Overview of CLIM CLIM is an acronym for the Common Lisp Interface Manager. It is a portable, powerful, highlevel user interface management system toolkit intended for Com mon Lisp software developers. The important things to understand about CLIM are: • How it helps you achieve a portable user interface how it fits into an existing host system; how you can achieve the look and feel of the target host system without implementing it directly, and without using the lowlevel implementa tion language of the host system. • The power inherent in its presentation model the advantages of having the vi sual representation of an object linked directly to its semantics. Page 1142 • The set of high-level programming techniques it provides capabilities that en able you to develop a user interface conveniently, including formatted output, graphics, windowing, and commands that are invoked by typing text or clicking a mouse (or ``pointer’’) button, among other techniques. CLIM 2.0 does not currently provide any highlevel user interface building tools, nor does it provide any sort of highlevel graphical or text editing substrate. These are areas into which future releases of CLIM may extend. CLIM is also not suitable for high performance, very high quality graphics of the sort needed for sophisticated paint, animation, or video postproduction applications. Of course, it is possible to write the bulk of such an application’s user interface using CLIM, and use lower level facilities for drawing in the main ``canvas’’ of the application. Introduction to CLIM’s Presentation Model A software application typically needs to interact with the person using it. The user interface is responsible for managing the interaction between the user and the application program. The user interface gets information from the user (com mands, which might be entered by typing text or by clicking a mouse), gives that information to the application, and later presents information (the program’s re sults) to the user. Figure 25 shows this common paradigm. Input Computation Output Figure 46. Cycle of Input/Computation/Output We might describe one conventional approach to the input/computation/output cycle as follows. Invisibly to the user, the application takes the commands and interprets them in terms the program can handle. For example, if the application uses object oriented techniques, it might build objects based on information garnered from the command and arguments, then manipulate those objects internally, finish its com putation, and finally translate from the resulting objects to the appropriate re sponse which is then given to the user. Figure 26 depicts this sequence of events. The conventional approach uses objectoriented techniques within the computation phase, but the objects do not surface to the user interface. The program performs two translations: from user input to objects, and later from objects to output in Page 1143 Input User enters command and arguments Program interprets command and arguments Program builds objects based on commands Computation Program manipulates its internal objects Program translates objects to visible results Program discards objects Output User sees results of the program Figure 47. Conventional Approach to the Input/Computation/Output Cycle tended for the user. CLIM revolutionizes the cycle by bringing the power of object oriented programming to the surface, all the way up to the user interface. CLIM recognizes that many applications manipulate internal objects which we call application objects and they have display objects, which are presented to the user. A display object can appear as text or a graphic picture. CLIM supports a direct linking between application objects and display objects. CLIM automatically main tains the association between application objects and display objects, so there is no need for the application to do any translation. Figure 27 shows how CLIM views the cycle of input/computation/output. In effect, CLIM replaces some of the tedious and errorprone steps of the conven tional userinterface model with higherlevel objectoriented techniques. The advan tages of the objectoriented user interface are subtle but extremely powerful (in fact, you might not recognize them at first glance, but they will grow on you grad ually as you develop your CLIM applications): • A command is structured so that the user interface understands something of the semantics of its arguments. That is, each argument must be an object of a specified type. This helps the user in several ways: ° The user is prevented from entering invalid input, because the user interface automatically enforces the validity of each argument. ° The user can get online help or prompting from the user interface, based on the type of the argument. ° The user can enter input in creative and convenient ways, such as by clicking on object displayed on the screen by a previous command.