• Aucun résultat trouvé

Getting a Window to Use

Dans le document 7 B Programming (Page 131-134)

Using the Window System

12. Window Flavors and Messages

12.2 Getting a Window to Use

12.2.1 Flavors of Basic Windows

l\Iany programs never need to create any new windows. Often, all you are interested in doing is sending messages to *standard-output* and

*standard-input* and performing the extended stream operations offered by windows to read and type characters, position the cursor (and other things that you do on display terminals), and draw graphics. Other programs want to create their own windows for various reasons; a common way to organize an interactive system on the Lisp Machine is to create a process that runs the command loop of the system, and have it use its own window or suite of windows to communicate with the user. This kind of system is what the editor and Zmail use, and it is very convenient to deal with.

Whichever of these you use, it is important for you to know what flavor of window you are getting. Some flavors accept certain messages that are not handled by others. The details of different flavors' responses to the same message may vary in accordance with what those flavors are supposed to be for. The following is a discussion of window flavors.

The most primitive flavor of window is called tv: minimum-window; it is the basic flavor on which all other window flavors are built, and it contains the absolute minimum amount of functionality that a window must have to work.

tv:minimum-window itself is built on a number of other flavors that provide the

"essential" attributes of windows. For reference, tv:minimum-window is defined as follows (ignoring defflavor options):

(defflavor tv:minimum-window ()

(tv:essential-expose tv:essential-activate tv:essential-set-edges tv:essential-mouse tv:essential-window»

tv: essential-window, in turn, is built on the base flavor for all windows, tv: sheet.

There is another flavor called tv:window, which is built on tv:minimum-window and has about six moons that do a variety of useful things. When you cold boot a Lisp Machine, the window you are talking to is of flavor tv:lisp-listener, which is built on tv:window and has three more moons. tv:window has what you need to do the normal things that are done with windows; tv:minimum-window is missing messages for character output and input, selection, borders, labels, and graphics, and so there isn't much you can do with it. Anything built on tv:window, including Lisp Listeners, will be able to accept all the basic messages.

Some programs may benefit from more carefully tailored mOOngs of flavors. For the benefit of programmers who want to do this, we specify below, with each message and init option, which flavor actually handles it. If you are just using

tv:window then you don't really care exactly what mixin specific features are in;

you just need to know which ones are in tv:window. With the discussion of each flavor or group of messages, we will say which relevant flavors are in tv:window and which are not. For reference, tv:window is defined (ignoring defflavor options) as follows:

(defflavor tv:window ()

(tv:stream-mixin tv:borders-mixin tv:label-mixin tv:select-mixin tv:graphics-mixin tv:minimum-window»

So, if you use tv:window then you have all the above mixins, and can take advantage of their features.

For information on Dynamic Window flavors: See the section "Overview of Window Substrate Facilities" in Programming the User Interface, Volume A.

12.2.2 Creating a Window

If you want to create your own window, static or dynamic, you use the

tv:make-window function. Never try to instantiate a window flavor yourself with make-instance; always use tv:make-window which takes care of a number of internal system issues.

tv:make-window flavor-name &rest init-options Function Create, initialize, and return a new window of the specified flavor.

The init-options argument is the init-plist (it is just like the &rest

argument of make-instance). The allowed initialization options depend on what flavor of window you are making. Each window flavor handles some init options; the options and what they mean are documented with the documentation of the flavor.

Example:

(defun make-window-example ()

(let «window (tv:make-window 'tv:window

:edges-from :mouse :expose-p t

:blinker-p t

:default-character-style '(:fix :bold :large) : save-bi ts t»)

(format window U-2%Note the character style"»)

The above function lets you specify the location of the upper-left and lower-right corners of the window with the mouse. Once the location is specified, the window is created and exposed. A blinker is visible; its size is that of the default character style for character output. Because the :save-bits

init option is t, the formatted output to the window will still be visible after the window is de-exposed and then re-exposed.

:init init-plist of tv:sheet Method

Sets initial characteristics of the window, processing options in init-plist.

This message is sent by the system; you might need to supply an :after daemon for it.

: blinker-p t-or-nil (for tv:sheet) Init Option

Boolean option specifying whether to provide a blinking cursor when the window is exposed; the default is t. For more information on blinkers: See the section "Blinkers", page 160.

:default-character-style character-style (for tv:sheet) Init Option Specifies the character style for character output to the window. The default style is inherited from the screen (and is settable via the Set Screen Options command); the initial default character style is (: fi x

: roman : normal). To change a window's default style, use the :set-default-style method: See the method (flavor:method :set-default-character-:set-default-style . tv: sheet) , page 126.

For more information on character styles: See the section "Character Styles" in Symbolics Common Lisp.

: save-bits t-or-nil (for tv:sheet) Init Option

Boolean option specifying whether output to the window is written to a bit-save array when the window is de-exposed; the default is nil. If t, the output is redisplayed following re-exposure of the window. For more information on bit-save arrays: See the section "Pixels and Bit-Save Arrays", page 88.

:superior superior (for tv:sheet) Init Option

Makes superior the superior window of the window being created.

:activate-p t-or-nil (for tv:essential-window) Init Option If this option is specified non-nil, the window is activated after it is

created. The default is to leave it deactivated.

:expose-p t-or-nil (for tv:essential-window) Init Option If this option is specified non-nil, the window is exposed after it is created.

The default is to leave it deexposed. If the value of the option is not t, it is used as the first argument to the :expose message (the turn-on-blinkers option).

tv:defwindow-resource name parameters &rest options Macro Defines a resource of windows. name is the name of the resource.

parameters is a lambda-list of parameters to defresource. options are alternating keywords and values:

Keyword : initial-copies :superior

: make-window

: constructor

:reusable-when

Value

Number of windows to be created during evaluation of defresource form. Default: 1.

A form to be evaluated when the resource is allocated to return the superior window of the desired window.

If this is not supplied, the superior is the value of tv: mouse-sheet.

List of flavor name and options to tv: make-window, which will be called to make new windows. One of the options can be : superior.

A form or the name of a function to make new windows. You must supply either :make-window or : constructor.

Either :deexposed or : deactivated. Specifies when a window can be reused. Supply this when you use allocate-resource instead of using-resource. to

allocate resources. Default: reusable when not locked and not in use.

Dans le document 7 B Programming (Page 131-134)