Copyright (c) 1986 Xerox Corporation. All rights reserved. 28.6.4 Window Properties Of Attached Windows 1 Windows that are involved in a collection either as a main window or as an attached window have properties stored on them. The only properties that are intended to be set be set by the user are the MINSIZE, MAXSIZE, PASSTOMAINCOMS, and REJECTMAINCOMS window properties. The other properties should be considered read only. MINSIZE [Window Property] 1 MAXSIZE [Window Property] 1 Each of these window properties should be a dotted pair (WIDTH . HEIGHT) or a function to apply to the window that returns a dotted pair. The numbers are used when the main window is reshaped. The MINSIZE is used to determine the size of the smallest region acceptable during reshaping. Any amount greater than the collective minimum is spread evenly among the windows until each reaches MAXSIZE. Any excess is given to the main window. Note: If you give the main window of an attached window group a MINSIZE or MAXSIZE property, its value is moved to the MAINWINDOWMINSIZE or MAINWINDOWMAXSIZE property, so that the main window can be given a size function that computes the minimum or maximum size of the entire group. Thus, if you want to change the main window's minimum or maximum size after attaching windows to it, you should change the MAINWINDOWMINSIZE or MAINWINDOWMAXSIZE property instead. Note: This doesn't address the hard problem of overlapping attached windows side to side, for example if window A was attached as [TOP, LEFT] and B as [TOP, RIGHT]. Currently, the attached window functions do not worry about the overlap. The default MAXSIZE is NIL, which will let the region grow indefinitely. 1 MAINWINDOW [Window Property] 1 Pointer from attached windows to the main window of the group. This link is not available if the main window is closed. The function MAINWINDOW (("MAINWINDOW" . Function)) is the preferred way to access this property. 1 ATTACHEDWINDOWS [Window Property] 1 Pointer from a window to its attached windows. The function ATTACHEDWINDOWS (("ATTACHEDWINDOWS" . Function)) is the preferred way to access this property. 1 WHEREATTACHED [Window Property] 1 For attached windows, a dotted pair (EDGE . POSITIONONEDGE) giving the edge and position on the edge that determine how the attached window is placed relative to its main window. 1 The TOTOPFN window property on attached windows and the properties TOTOPFN, DOSHAPEFN, MOVEFN, CLOSEFN, OPENFN, SHRINKFN, EXPANDFN and CALCULATEREGIONFN on main windows contain functions that implement the attached window manipulation facilities. Care should be used in modifying or replacing these properties.  (ЬЬј(ЬЬј)KKјT/KЬјјT(ЬЬј(ј.ј (1ЬјКЬ(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) / HRULE.GETFNMODERN ЧJ HRULE.GETFNMODERN  HRULE.GETFNMODERN 8Й+A%ћqM / HRULE.GETFNMODERN   HRULE.GETFNMODERN ‡  IRM.GET.CREF0 HRULE.GETFNMODERN  HRULE.GETFNMODERN = IRM.GET.CREF0 HRULE.GETFNMODERN   HRULE.GETFNMODERN $x HRULE.GETFNMODERN 8   “‘zК 28.6.3 Window Operations And Attached Windows 1 When a window operation, such as moving or clearing, is performed on a window, there is a question about whether or not that operation should also be performed on the windows attached to it or performed on the window it is attached to. The "right" thing to do depends on the window operation: it makes sense to independently redisplay a single window in a collection of windows, whereas moving a single window usually implies moving the whole group of windows. The interpretation of window operations also depends on the application that the window group is used for. For some applications, it may be desirable to have a window group where individual windows can be moved away from the group, but still be conceptually attached to the group for other operations. The attached window facility is flexible enough to allow all of these possibilities. The operation of window operations can be specified by each attached window, by setting the following two window properties: PASSTOMAINCOMS [Window Property] 1 Value is a list of window commands (e.g. CLOSEW, MOVEW) which, when selected from the attached window's right-button menu, are actually applied to the central window in the group, instead of being applied to the attached window itself. The "central window" is the first window up the "main window" chain that is not attached to any other window. If PASSTOMAINCOMS is NIL, all window operations are directly applied to the attached window. If PASSTOMAINCOMS is T, all window operations are passed to the central window. Note: ATTACHWINDOW (("ATTACHWINDOW" . Function)) allows this window property to be set to commonly-used values by using its WINDOWCOMACTION argument. ATTACHWINDOW always sets this window property, so users must modify it directly only after attaching the window to another window. 1 REJECTMAINCOMS [Window Property] 1 Value is a list of window commands that the attached window will not allow the main window to apply to it. This is how a window can say "leave me out of this group operation." If REJECTMAINCOMS is NIL, all window commands may be applied to this attached window. If REJECTMAINCOMS is T, no window commands may be applied to this attached window. 1 Note: The PASSTOMAINCOMS and REJECTMAINCOMS window properties affect right-button menu operations applied to main windows or attached windows, and the action of programmatic window functions (SHAPEW, MOVEW, etc.) applied to main windows. However, these window properties do not affect the action of window functions applied to attached windows. The following list describes the behavior of main and attached windows under the window operations, assuming that all attached windows have their REJECTMAINCOMS window property set to NIL and PASSTOMAINCOMS set to (CLOSEW MOVEW SHAPEW SHRINKW BURYW) (the default if ATTACHWINDOW is called with WINDOWCOMACTION=NIL, see ("ATTACHWINDOW" . Function)). The behavior for any particular operation can be changed for particular attached windows by setting the standard window properties (e.g., MOVEFN or CLOSEFN) of the attached window. An exception is the TOTOPFN property of an attached window, that is set to bring the whole window group to the top and should not be set by the user (although users can add functions to the TOTOPFN window property). Move If the main window moves, all attached windows move with it, and the relative positioning between the main window and the attached windows is maintained. If the region is determined interactively, the prompt region for the move is the union of the extent of the main window and all attached windows (excluding those with MOVEW in their REJECTMAINCOMS window property). If an attached window is moved by calling the function MOVEW, it is moved without affecting the main window. If the right-button window menu command Move is called on an attached window, it is passed on to the main window, so that all windows in the group move. Reshape If the main window is reshaped, the minimum size of it and all of its attached windows is used as the minimum of the space for the result. Any space greater than the minimum is distributed among the main window and its attached windows. Attached windows with SHAPEW on their REJECTMAINCOMS window property are ignored when finding the minimum size, creating a "ghost" region, or distributing space after a reshape. If an attached window is reshaped by calling the function SHAPEW, it is reshaped independently. If the right-button window menu command Shape is called on an attached window, it is passed on to the main window, so the whole group is reshaped. Note: Reshaping the main window will restore the conditions established by the call to ATTACHWINDOW, whereas moving the main window does not. Thus, if A is attached to the top of B and then moved by the user, its new position relative to B will be maintained if B is moved. If B is reshaped, A will be reshaped to the top of B. Additionally, if, while A is moved away from the top of B, C is attached to the top of B, C will position itself above where A used to be. Close If the main window is closed, all of the attached windows are closed also and the links from the attached windows to the main window are broken. This is necessary for the windows to be garbage collected. If an attached window is closed by calling the function CLOSEW, it is closed without affecting the main window. If the right-button window menu command Close is called on an attached window, it is passed on to the main window. Note that closing an attached window detaches it. Open If the main window is opened, it opens all attached windows and reestablishes links from them to the main window. Attached windows can be opened independently and this does not affect the main window. Note that it is possible to reopen a closed attached window and not have it linked to its main window. Shrink The collection of windows shrinks as a group. The SHRINKFNs of the attached windows are evaluated but the only icon displayed is the one for the main window. Redisplay The main or attached windows can be redisplayed independently. Totop If any main or attached window is brought to the top, all of the other windows are brought to the top also. Expand Expanding any of the windows expands the whole collection. Scrolling All of the windows involved in the group scroll independently. Clear All windows clear independently of each other.  1ЬјКЬ(ЬЬј)KKјT/KЬјјT(ЬЬј(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) 0 HRULE.GETFNMODERN U} HRULE.GETFNMODERN )&I:  IRM.GET.CREFM  I) HRULE.GETFNMODERN  HRULE.GETFNMODERN БB= HRULE.GETFNMODERN  •FD’#  IRM.GET.CREFŠ/ŽH 7Zm :IfX 5: " д8[yxП;dJsCJ6,dПzК 28.6.2 Attached Prompt Windows 1 Many packages have a need to display status information or prompt for small amounts of user input in a place outside their standard window. A convenient way to do this is to attach a small window to the top of the program's main window. The following functions do so in a uniform way that can be depended on among diverse applications. (GETPROMPTWINDOW MAINWINDOW #LINES FONT DONTCREATE) [Function] 1 Returns the attached prompt window associated with MAINWINDOW, creating it if necessary. The window is always attached to the top of MAINWINDOW, has DSPSCROLL set to T, and has a PAGEFULLFN of NILL to inhibit page holding. The window is at least #LINES lines high (default 1); if a pre-existing window is shorter than that, it is reshaped to make it large enough. FONT is the font to give the prompt window (defaults to the font of MAINWINDOW), and applies only when the window is first created. If DONTCREATE is true, returns the window if it exists, otherwise NIL without creating any prompt window. 1 (REMOVEPROMPTWINDOW MAINWINDOW) [Function] 1 Detaches the attached prompt window associated with MAINWINDOW (if any), and closes it. 1 (ЬЬј)KKјT/KЬјјT(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) ! HRULE.GETFNMODERN R! HRULE.GETFNMODERN 3 I    2q@ : 5% HRULE.GETFNMODERN   HRULE.GETFNMODERN 4  HRULE.GETFNMODERN :y;zК 28.6.1 Attaching Menus To Windows 1 The following functions are provided to associate menus to windows. (MENUWINDOW MENU VERTFLG) [Function] 1 Returns a closed window that has the menu MENU in it. If MENU is a list, a menu is created with MENU as its ITEMS menu field (see ("ITEMS" . MenuField)). Otherwise, MENU should be a menu. The returned window has the appropriate RESHAPEFN, MINSIZE and MAXSIZE window properties to allow its use in a window group. If both the MENUROWS and MENUCOLUMNS fields of MENU are NIL, VERTFLG is used to set the default menu shape. If VERTFLG is non-NIL, the MENUCOLUMNS field of MENU will be set to 1 (the menu items will be listed vertically); otherwise the MENUROWS field of MENU will be set to 1 (the menu items will be listed horizontally). 1 (ATTACHMENU MENU MAINWINDOW EDGE POSITIONONEDGE NOOPENFLG) [Function] 1 Creates a window that contains the menu MENU (by calling MENUWINDOW) and attaches it to the window MAINWINDOW on edge EDGE at position POSITIONONEDGE. The menu window is opened unless MAINWINDOW is closed, or NOOPENFLG is T. If EDGE is either LEFT or RIGHT, MENUWINDOW will be called with VERTFLG=T, so the menu items will be listed vertically; otherwise the menu items will be listed horizontally. These defaults can be overridden by specifying the MENUROWS or MENUCOLUMNS fields in MENU. 1 (CREATEMENUEDWINDOW MENU WINDOWTITLE LOCATION WINDOWSPEC) [Function] 1 Creates a window with an attached menu and returns the main window. MENU is the only required argument, and may be a menu or a list of menu items. WINDOWTITLE is a string specifying the title of the main window. LOCATION specifies the edge on which to place the menu; the default is TOP. WINDOWSPEC is a region specifying a region for the aggregate window; if NIL, the user is prompted for a region. 1 Examples: (SETQ MENUW (MENUWINDOW (create MENU ITEMS _ '(smaller LARGER) MENUFONT _ '(MODERN 12) TITLE _ "zoom controls" CENTERFLG _ T WHENSELECTEDFN _ (FUNCTION ZOOMMAINWINDOW)))) creates (but does not open) a menu window that contains the two items "smaller" and "LARGER" with the title "zoom controls" and that calls the function ZOOMMAINWINDOW when an item is selected. Note that the menu items will be listed horizontally, because MENUWINDOW is called with VERTFLG=NIL, and the menu does not specify either a MENUROWS or MENUCOLUMNS field. (ATTACHWINDOW MENUW (CREATEW '(50 50 150 50)) 'TOP 'JUSTIFY) creates a window on the screen and attaches the above created menu window to its top: –KџџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџќџџџџџџџџџџџпўџџџџџќџџџџџУ<щ?žtŠЮуџџџџќџџџџџілdПmВиЖпџџџџќџџџџџюлmП}ЖлЖчџџџџќџџџџџолmПmЖлЖћџџџџќџџџџџУ<эПžvЫЮЧџџџџќџџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџќ€€$€$<>x€$"! D€Г$q`"@ D€ Ь$‰€<@"A D€ˆ“$A"! D€8ˆ$yA!>B€€€€џџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџќР Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р Р џџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџќ (CREATEMENUEDWINDOW (create MENU ITEMS _ '(smaller LARGER) MENUFONT _ '(MODERN 12) TITLE _ "zoom controls" CENTERFLG _ T WHENSELECTEDFN _ (FUNCTION ZOOMMAINWINDOW)))) creates the same sort of window in one step, prompting the user for a region.  (ЬЬј(ЬЬј(ЬЬј)KKјT/KЬјјT(ЬЬј(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))  $ HRULE.GETFNMODERN D   HRULE.GETFNMODERN  * # IRM.GET.CREF< 7   ,  L @  HRULE.GETFNMODERN  - HRULE.GETFNMODERN  (      $    ™    HRULE.GETFNMODERN $ HRULE.GETFNMODERN  EL 7? >%  HRULE.GETFNMODERN   "  6G Z )  Vш BMOBJ.GETFN3MODERN  4NPЭzК 2 28.6 Attached Windows 1 The attached window facility makes it easy to manipulate a group of window as a unit. Standard window operations like moving, reshaping, opening, and closing can be done so that it appears to the user as if the windows are a single entity. Each collection of attached windows has one main window and any number of other windows that are "attached" to it. Moving or reshaping the main window causes all of the attached windows to be moved or reshaped as well. Moving or reshaping an attached window does not affect the main window. Attached windows can have other windows attached to them. Thus, it is possible to attach window A to window B when B is already attached to window C. Similarly, if A has other windows attached to it, it can still be attached to B. (ATTACHWINDOW WINDOWTOATTACH MAINWINDOW EDGE POSITIONONEDGE WINDOWCOMACTION) [Function] 1 Associates WINDOWTOATTACH with MAINWINDOW so that window operations done to MAINWINDOW are also done to WINDOWTOATTACH (the exact set of window operations passed between main windows and attached windows is described on ("PASSTOMAINCOMS" . WindowProperty)). ATTACHWINDOW moves WINDOWTOATTACH to the correct position relative to MAINWINDOW. Note: A window can be attached to only one other window. Attaching a window to a second window will detach it from the first. Attachments can not form loops. That is, a window cannot be attached to itself or to a window that is attached to it. ATTACHWINDOW will generate an error if this is attempted. EDGE determines which edge of MAINWINDOW the attached window is positioned along: it should be one of TOP, BOTTOM, LEFT, or RIGHT. If EDGE is NIL, it defaults to TOP. POSITIONONEDGE determines where along EDGE the attached window is positioned. It should be one of the following: LEFT The attached window is placed on the left (of a TOP or BOTTOM edge). RIGHT The attached window is placed on the right (of a TOP or BOTTOM edge). BOTTOM The attached window is placed on the bottom (of a LEFT or RIGHT edge). TOP The attached window is placed on the top (of a LEFT or RIGHT edge). CENTER The attached window is placed in the center of the edge. JUSTIFY or NIL The attached window is placed to fill the entire edge. ATTACHWINDOW reshapes the window if necessary. Note: The width or height used to justify an attached window includes any other windows that have already been attached to MAINWINDOW. Thus (ATTACHWINDOW BBB AAA 'RIGHT 'JUSTIFY) followed by (ATTACHWINDOW CCC AAA 'TOP 'JUSTIFY) will put CCC across the top of both BBB and AAA: xKџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџќ8pџџџџџџџџџџџџћзЏџџџџџџџџџџџћїяџџџџџџџџџџџџћїяџџџџџџџџџџџџћзЏџџџџџџџџџџџќ8pџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџРРРРРРРРРРРРРРРРРРРРРРРРџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџў§ћџџџџјpсџџџџџ§zѕџџџџћЗnџџџџџ§zѕџџџџјpсџџџџџћЗnџџџџћЗnџџџџџј0`џџџџћЗnџџџџџїЯŸџџџјpсџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ WINDOWCOMACTION provides a convenient way of specifying how WINDOWTOATTACH responds to right button menu commands. The window property PASSTOMAINCOMS determines which right button menu commands are directly applied to the attached window, and which are passed to the main window (see ("PASSTOMAINCOMS" . WindowProperty)). Depending on the value of WINDOWCOMACTION, the PASSTOMAINCOMS window property of WINDOWTOATTACH is set as follows: NIL PASSTOMAINCOMS is set to (CLOSEW MOVEW SHAPEW SHRINKW BURYW), so right button menu commands to close, move, shape, shrink, and bury are passed to the main window, and all others are applied to the attached window. LOCALCLOSE PASSTOMAINCOMS is set to (MOVEW SHAPEW SHRINKW BURYW), which is the same as when WINDOWCOMACTION is NIL, except that the attached window can be closed independently. HERE PASSTOMAINCOMS is set to NIL, so all right button menu commands are applied to the attached window. MAIN PASSTOMAINCOMS is set to T, so all right button menu commands are passed to the main window. Note: If the user wants to set the PASSTOMAINCOMS window property of an attached window to something else, it must be done after the window is attached, since ATTACHWINDOW modifies this window property. 1 (DETACHWINDOW WINDOWTODETACH) [Function] 1 Detaches WINDOWTODETACH from its main window. Returns a dotted pair (EDGE . POSITIONONEDGE) if WINDOWTODETACH was an attached window, NIL otherwise. This does not close WINDOWTODETACH. 1 (DETACHALLWINDOWS MAINWINDOW) [Function] 1 Detaches and closes all windows attached to MAINWINDOW. 1 (FREEATTACHEDWINDOW WINDOW) [Function] 1 Detaches the attached window WINDOW. In addition, other attached windows above (in the case of a TOP attached window) or below (in the case of a BOTTOM attached window) are moved closer to the main window to fill the gap. Note: Attached windows that "reject" the move operation (see REJECTMAINCOMS, ("REJECTMAINCOMS" . WindowProperty)) are not moved. Note: FREEATTACHEDWINDOW currently doesn't handle LEFT or RIGHT attached windows. 1 (REMOVEWINDOW WINDOW) [Function] 1 Closes WINDOW, and calls FREEATTACHEDWINDOW to move other attached windows to fill any gaps. 1 (REPOSITIONATTACHEDWINDOWS WINDOW) [Function] 1 Repositions every window attached to WINDOW, in the order that they were attached. This is useful as a RESHAPEFN for main windows with attached window that don't want to be reshaped, but do want to keep their position relative to the main window when the main window is reshaped. Note: Attached windows that "reject" the move operation (see REJECTMAINCOMS, ("REJECTMAINCOMS" . WindowProperty)) are not moved. 1 (MAINWINDOW WINDOW RECURSEFLG) [Function] 1 If WINDOW is not a window, it generates an error. If WINDOW is closed, it returns WINDOW. If WINDOW is not attached to another window, it returns WINDOW itself. If RECURSEFLG is NIL and WINDOW is attached to a window, it returns that window. If RECURSEFLG is T, it returns the first window up the "main window" chain starting at WINDOW that is not attached to any other window. 1 (ATTACHEDWINDOWS WINDOW COM) [Function] 1 Returns the list of windows attached to WINDOW. If COM is non-NIL, only those windows attached to WINDOW that do not reject the window operation COM are returned (see REJECTMAINCOMS, ("REJECTMAINCOMS" . WindowProperty)). 1 (ALLATTACHEDWINDOWS WINDOW) [Function] 1 Returns a list of all of the windows attached to WINDOW or attached to a window attached to it. 1 (WINDOWREGION WINDOW COM) [Function] 1 Returns the screen region occupied by WINDOW and its attached windows, if it has any. If COM is non-NIL, only those windows attached to WINDOW that do not reject the window operation COM are considered in the calculation (see REJECTMAINCOMS, ("REJECTMAINCOMS" . WindowProperty)). 1 (WINDOWSIZE WINDOW) [Function] 1 Returns the size of WINDOW and its attached windows (if any), as a dotted pair (WIDTH . HEIGHT). 1 (MINATTACHEDWINDOWEXTENT WINDOW) [Function] 1 Returns the minimum size that WINDOW and its attached windows (if any) will accept, as a dotted pair (WIDTH . HEIGHT). 1  1ЬјКЬ2ЬјКЬT1ЬјКЬ(ЬЬј)KKјT/KЬјјT(ј.ј((ј7(ЬЬј(MODERN MODERN MODERNMODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))    HRULE.GETFNMODERN  HRULE.GETFNMODERN   ъ= HRULE.GETFNMODERN   # f# IRM.GET.CREF %  љ .  > H1230:9 # | & $  М BMOBJ.GETFN3MODERN  ->‡# IRM.GET.CREF #š  ? H C $J   HRULE.GETFNMODERN  HRULE.GETFNMODERN  .! HRULE.GETFNMODERN   HRULE.GETFNMODERN ,  HRULE.GETFNMODERN  HRULE.GETFNMODERN ?-G ># IRM.GET.CREF  HRULE.GETFNMODERN  HRULE.GETFNMODERN  2 HRULE.GETFNMODERN  HRULE.GETFNMODERN %= Ј ># IRM.GET.CREF HRULE.GETFNMODERN   HRULE.GETFNMODERN -/  6 E+ HRULE.GETFNMODERN   HRULE.GETFNMODERN ( !)# IRM.GET.CREF HRULE.GETFNMODERN  HRULE.GETFNMODERN 1) HRULE.GETFNMODERN   HRULE.GETFNMODERN &* !)(# IRM.GET.CREF HRULE.GETFNMODERN   HRULE.GETFNMODERN 5 HRULE.GETFNMODERN  HRULE.GETFNMODERN A HRULE.GETFNMODERN ylЪzК 28.5.3 Examples of Menu Use 1 Example: A simple menu: (MENU (create MENU ITEMS _ '((YES T) (NO (QUOTE NIL))) )) Creates a menu with items YES and NO in a single vertical column: џџџў€€Oутˆˆˆˆ…УТ‚"‚‚‚ут€€€€CР˜D ”H’H’H‘HФ CР€€џџџў If YES is selected, T will be returned. Otherwise, NIL will be returned. Example: A simple menu, with centering: (MENU (create MENU TITLE _ "Foo?" ITEMS _ '((YES T "Adds the Foo feature.") (NO 'NO "Removes the Foo feature.")) CENTERFLG _ T)) Creates a menu with a title Foo? and items YES and NO centered in a single vertical column: #џџџўџџџўќџž§љчnќ6ло§ілО§ілО§љчўџџџОџџџў€€Oутˆˆˆˆ…УТ‚"‚‚‚ут€€€€<„BD$$ B<€€џџџў The strings following the YES and NO are help strings and will be printed if the cursor remains over one of the items for a period of time. This menu differs from the one above in that it distinquishes the NO case from the case where the user clicked outside of the menu. If the user clicks outside of the menu, NIL is returned. Example: A multi-column menu: (create MENU ITEMS _ '(1 2 3 4 5 6 7 8 9 * 0 #) CENTERFLG _ T MENUCOLUMNS _ 3 MENUFONT _ (FONTCREATE 'MODERN 10 'BOLD) ITEMHEIGHT _ 15 ITEMWIDTH _ 15 CHANGEOFFSETFLG _ T) Creates a touch-tone-phone number pad with the items in 15 by 15 boxes printed in Modern 10 bold font: />џџџџџў€€€€€рР‚р`Т``Т€`Р‚€`€Т€`Т€`р‚€€€€€€€€€pрТ€№€А‚АРТ№`Т€0`Т€0Р‚€€€€€€€€№Р‚€0`Т€``Т€`РТ€Р`Т€Р`Т€Р‚€€€€€€€€@№Рb€р`b€р`тА`Т€`т€` ‚€Р ‚€€€€џџџџџў If used in pop up mode, its first use will have the cursor in the middle. Subsequent use will have the cursor in the same relative location as the previous selection. Example: A program using a previously-saved menu: (SELECTQ [MENU (COND ((type? MENU FOOMENU) (* use previously computed menu.) FOOMENU) (T (* create and save the menu) (SETQ FOOMENU (create MENU ITEMS _ '((A 'A-SELECTED "prompt string for A") (B 'B-SELECTED "prompt string for B"] (A-SELECTED (* if A is selected) (DOATHING)) (B-SELECTED (* if B is selected) (DOBTHING)) (PROGN (* user selected outside the menu) NIL))) This expression displays a pop up menu with two items, A and B, and waits for the user to select one. If A is selected, DOATHING is called. If B is selected, DOBTHING is called. If neither of these is selected, the form returns NIL. The purpose of this example is to show some good practices to follow when using menus. First, the menu is only created once, and saved in the variable FOOMENU. This is more efficient if the menu is used more than once. Second, all of the information about the menu is kept in one place, which makes it easy to understand and edit. Third, the forms evaluated as a result of selecting something from the menu are part of the code and hence will be known to masterscope (as opposed to the situation if the forms were stored as part of the items). Fourth, the items in the menu have help strings for the user. Finally, the code is commented (always worth the trouble). (ЬЬј(ЬЬј(ЬЬј1ЬјКЬ(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))  HRULE.GETFNMODERN :t BMOBJ.GETFN3MODERN )"5D '˜ BMOBJ.GETFN3MODERN Ћi06"g€ BMOBJ.GETFN3MODERN Ј3&!!#II  "7,?˜ŠzК 28.5.2 Miscellaneous Menu Functions 1 (MAXMENUITEMWIDTH MENU) [Function] 1 Returns the width of the largest menu item label in the menu MENU. 1 (MAXMENUITEMHEIGHT MENU) [Function] 1 Returns the height of the largest menu item label in the menu MENU. 1 (MENUREGION MENU) [Function] 1 Returns the region covered by the image of MENU in its window. 1 (WFROMMENU MENU) [Function] 1 Returns the window MENU is located in, if it is in one; NIL otherwise. 1 (DOSELECTEDITEM MENU ITEM BUTTON) [Function] 1 Calls MENU's WHENSELECTEDFN on ITEM and BUTTON. It provides a programmatic way of making a selection. It does not change the display. 1 (MENUITEMREGION ITEM MENU) [Function] 1 Returns the region occupied by ITEM in MENU. 1 (SHADEITEM ITEM MENU SHADE DS/W) [Function] 1 Shades the region occupied by ITEM in MENU. If DS/W is a display stream or a window, it is assumed to be where MENU is displayed. Otherwise, WFROMMENU is called to locate the window MENU is in. Shading is persistent, and is reapplied when the window the menu is in gets redisplayed. To unshade an item, call with a SHADE of 0. 1 (PUTMENUPROP MENU PROPERTY VALUE) [Function] 1 Stores the property PROPERTY with the value VALUE on a property list in the menu MENU. The user can use this property list for associating arbitrary data with a menu object. 1 (GETMENUPROP MENU PROPERTY) [Function] 1 Returns the value of the PROPERTY property of the menu MENU. 1 )KKјT/KЬјјT(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) & HRULE.GETFNMODERN  HRULE.GETFNMODERN = HRULE.GETFNMODERN  HRULE.GETFNMODERN > HRULE.GETFNMODERN   HRULE.GETFNMODERN + HRULE.GETFNMODERN   HRULE.GETFNMODERN !  HRULE.GETFNMODERN  HRULE.GETFNMODERN Z HRULE.GETFNMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN <  ƒ HRULE.GETFNMODERN   HRULE.GETFNMODERN  Z HRULE.GETFNMODERN    HRULE.GETFNMODERN  HRULE.GETFNMODERN ЊbЊzК 28.5.1 Menu Fields 1 A menu is a datatype with the following fields: ITEMS [Menu Field] 1 The list of items to appear in the menu. If an item is a list, its CAR will appear in the menu. If the item (or its CAR) is a bitmap, the bitmap will be displayed in the menu. The default selection functions interpret each item as a list of three elements: a label, a form whose value is returned upon selection, and a help string that is printed in the prompt window when the user presses a mouse key with the cursor pointing to this item. The default subitem function interprets the fourth element of the list. If it is a list whose CAR is the litatom SUBITEMS , the CDR is taken as a list of subitems. 1 SUBITEMFN [Menu Field] 1 A function to be called to determine if an item has any subitems. If an item has subitems and the user rolls the cursor out the right of that item, a submenu with that item's subitems in it pops up. If the user selects one of the items from the submenu, the selected subitem is handled as if it were selected from the main menu. If the user rolls out of the submenu to the left, the submenu is taken down and selection resumes from the main menu. An item with subitems is marked in the menu by a grey, right pointing triangle following the label. The function is called with two arguments: (1) the menu and (2) the item. It should return a list of the subitems of this item if any. (Note: it is called twice to compute the menu image and each time the user rolls out of the item box so it should be moderately efficient. The default SUBITEMFN, DEFAULTSUBITEMFN, checks to see if the item is a list whose fourth element is a list whose CAR is the litatom SUBITEMS and if so, returns the CDR of it. For example: (create MENU ITEMS _ '(AAAA (BBBB 'BBBB "help string for BBBB" (SUBITEMS BBBB1 BBBB2 BBBB3)))) will create a menu with items A and B in which B will have subitems B1, B2 and B3. The following picture below shows this menu as it first appears: .џџџџџќ€€‚€@‚€@…@ …@ ˆ„B!‡Ус№H$H$€€€€ŸЧу№„H$ DH$ЄŸЧуёTH$ЄH$ DH$„ŸЧуё€€џџџџџќ The following picture shows the submenu, with the item BBBB3 selected by the cursor (€Рр№јќў№и˜ ): [2џџџџџр  јќ~? ‚A † ‚A ž јќ~? ‚A ‚ џџџџџљ‚A ‚ € ‚A ‚ € јќ~? ‚€@ ‚€@ …@  …@  ˆ„B! јќ~? ‡Ус№ ‚A ‘ H$ ‚A  H$ јќ~? € ‚A † € ‚A ˆ џџџџџљ‚A  џџџџўљјќ~? рp8x яЗлэіИ яЗлэї_џџџџџррp8ЏџџџџџряЗлэї^РёряЗлэіОћ}ОпnряЗлэї~ћ}Оп~ррp8ўРљрџџџџџўћ}Оп~рџџџџџўћ}Оп~рџџџџџўћ}ОпnрРёрџџџџџрџџџџџрџџџџџр€Р€€РР`` 1 WHENSELECTEDFN [Menu Field] 1 A function to be called when an item is selected. The function is called with three arguments: (1) the item selected, (2) the menu, and (3) the mouse key that the item was selected with (LEFT, MIDDLE, or RIGHT). The default function DEFAULTWHENSELECTEDFN evaluates and returns the value of the second element of the item if the item is a list of at least length 2. If the item is not a list of at least length 2, DEFAULTWHENSELECTEDFN returns the item. Note: If the menu is added to a window with ADDMENU, the default WHENSELECTEDFN is BACKGROUNDWHENSELECTEDFN, which is the same as DEFAULTWHENSELECTEDFN except that EVAL.AS.PROCESS (("EVAL.AS.PROCESS" . Function)) is used to evaluate the second element of the item, instead of tying up the mouse process. 1 WHENHELDFN [Menu Field] 1 The function which is called when the user has held a mouse key on an item for MENUHELDWAIT milliseconds (initially 1200). The function is called with three arguments: (1) the item selected, (2) the menu, and (3) the mouse key that the item was selected with (LEFT, MIDDLE, or RIGHT). WHENHELDFN is intended for prompting users. The default is DEFAULTMENUHELDFN which prints (in the prompt window) the third element of the item or, if there is not a third element, the string "This item will be selected when the button is released." 1 WHENUNHELDFN [Menu Field] 1 If WHENHELDFN was called, WHENUNHELDFN will be called: (1) when the cursor leaves the item, (2) when a mouse key is released, or (3) when another key is pressed. The function is called with the same three argument values used to call WHENHELDFN. The default WHENUNHELDFN is the function CLRPROMPT (("CLRPROMPT" . Function)), which just clears the prompt window. 1 MENUPOSITION [Menu Field] 1 The position of the menu to be used if the call to MENU or ADDMENU does not specify a position. For popup menus, this is in screen coordinates. For fixed menus, it is in the coordinates of the window the menu is in. The point within the menu image that is placed at this position is determined by MENUOFFSET. If MENUPOSITION is NIL, the menu will be brought up at the cursor position. 1 MENUOFFSET [Menu Field] 1 The position in the menu image that is to be located at MENUPOSITION. The default offset is (0,0). For example, to bring up a menu with the cursor over a particular menu item, set its MENUOFFSET to a position within that item and set its MENUPOSITION to NIL. 1 MENUFONT [Menu Field] 1 The font in which the items will be appear in the menu. Default is the value of MENUFONT. 1 TITLE [Menu Field] 1 If non-NIL, the value of this field will appear as a title in a line above the menu. 1 MENUTITLEFONT [Menu Field] 1 The font in which the title of the menu will be appear. If this is NIL, the title will be in the same font as window titles. If it is T, it will be in the same font as the menu items. 1 CENTERFLG [Menu Field] 1 If non-NIL, the menu items are centered; otherwise they are left-justified. 1 MENUROWS [Menu Field] 1 MENUCOLUMNS [Menu Field] 1 These fields control the shape of the menu in terms of rows and columns. If MENUROWS is given, the menu will have that number of rows. If MENUCOLUMNS is given, the menu will have that number of columns. If only one is given, the other one will be calculated to generate the minimal rectangular menu. (Normally only one of MENUROWS or MENUCOLUMNS is given.) If neither is given, the items will be in one column. 1 ITEMHEIGHT [Menu Field] 1 The height of each item box in the menu. If not specified, it will be the maximum of the height of the MENUFONT and the heights of any bitmaps appearing as labels. 1 ITEMWIDTH [Menu Field] 1 The width of each item box in the menu. If not specified, it will be the width of the largest item in the menu. 1 MENUBORDERSIZE [Menu Field] 1 The size of the border around each item box. If not specified, 0 (no border) is used. 1 MENUOUTLINESIZE [Menu Field] 1 The size of the outline around the entire menu. If not specified, a maximum of 1 and the MENUBORDERSIZE is used. 1 CHANGEOFFSETFLG [Menu Field] 1 (popup menus only) If CHANGEOFFSETFLG is non-NIL, the position of the menu offset is set each time a selection is confirmed so that the menu will come up next time in the same position relative to the cursor. This will cause the menu to reappear in the same place on the screen if the cursor has not moved since the last selection. This is implemented by changing the MENUOFFSET field on each use. If CHANGEOFFSETFLG is the atom X or the atom Y, only the X or the Y coordinate of the MENUOFFSET field will be changed. For example, by setting the MENUOFFSET position to (-1,0) and setting CHANGEOFFSETFLG to Y, the menu will pop up so that the cursor is just to the left of the last item selected. This is the setting of the window command menus. 1 The following fields are read only. IMAGEHEIGHT [Menu Field] 1 Returns the height of the entire menu. 1 IMAGEWIDTH [Menu Field] 1 Returns the width of the entire menu. 1  (ЬЬј(ЬЬј(ЬЬј)KKјT/KЬјјT(ЬЬј(ј.ј ((ЬЬј(MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))   HRULE.GETFNMODERN 0 HRULE.GETFNMODERN  D/Ѓ!  HRULE.GETFNMODERN   HRULE.GETFNMODERN  Тd! K   88 DЈ BMOBJ.GETFN3MODERN 7, BMOBJ.GETFN3d BMOBJ.GETFN3MODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN  М -  IRM.GET.CREF^  HRULE.GETFNMODERN   HRULE.GETFNMODERN  O Њ 2­  HRULE.GETFNMODERN   HRULE.GETFNMODERN     Х    IRM.GET.CREF(  HRULE.GETFNMODERN   HRULE.GETFNMODERN  3ъ  6  HRULE.GETFNMODERN   HRULE.GETFNMODERN  8 v ,   HRULE.GETFNMODERN  HRULE.GETFNMODERN  P  HRULE.GETFNMODERN  HRULE.GETFNMODERN  K  HRULE.GETFNMODERN   HRULE.GETFNMODERN  DA2  HRULE.GETFNMODERN   HRULE.GETFNMODERN  B  HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN  M7 Ў C  HRULE.GETFNMODERN   HRULE.GETFNMODERN  h5  HRULE.GETFNMODERN   HRULE.GETFNMODERN  q  HRULE.GETFNMODERN  HRULE.GETFNMODERN  W  HRULE.GETFNMODERN  HRULE.GETFNMODERN  Z   HRULE.GETFNMODERN  HRULE.GETFNMODERN  B   ( 5  ‹  HRULE.GETFNMODERN $  HRULE.GETFNMODERN  '  HRULE.GETFNMODERN   HRULE.GETFNMODERN  &  HRULE.GETFNMODERN г”ˆzК 2 28.5 Menus 1 A menu is basically a means of selecting from a list of items. The system provides common layout and interactive user selection mechanisms, then calls a user-supplied function when a selection has been confirmed. The two major constituents of a menu are a list of items and a "when selected function." The label that appears for each item is the item itself for non-lists, or its CAR џџif the item is a list. In addition, there are a multitude of different formatting parameters for specifying font, size, and layout. When a menu is created, its unspecified fields are filled with defaults and its screen image is computed and saved. Menus can be either pop up or fixed. If fixed menus are used, the menu must be included in a window. (MENU MENU POSITION RELEASECONTROLFLG я%) [Function] 1 џThis function provides menus that pop up when they are used. It displays MENU at POSITION (in screen coordinates) and waits for the user to select an item with a mouse key. Before any mouse key is pressed, the item the mouse is over is boxed. After any key is down, the selected menu item is video reversed. When all keys are released, MENU's WHENSELECTEDFN field is called with four arguments: (1) the item selected, (2) the menu, (3) the last mouse key released (LEFT, MIDDLE, or RIGHT), and (4) the reverse list of superitems rolled through when selecting the item and MENU returns its value. If no item is selected, MENU returns NIL. If POSITION is NIL, the menu is brought up at the value from MENU's MENUPOSITION field, if it is a POSITION, or at the current cursor position. The orientation of MENU with respect to the specified position is determined by its MENUOFFSET field. If RELEASECONTROLFLG is NIL, this process will retain control of the mouse. In this case, if the user lets the mouse key up outside of the menu, MENU return NIL. (Note: this is the standard way of allowing the user to indicate that they do not want to make the offered choice.) If RELEASECONTROLFLG is non-NIL, this process will give up control of the mouse when it is outside of the menu so that other processes can be run. In this case, clicking outside the menu has no effect on the call to MENU. If the menu is closed (for example, by right buttoning in it and selecting "Close" from the window menu), MENU returns NIL. Programmers are encouraged to provide a menu item such as "cancel" or "abort" which gives users a positive way of indicating "no choice". Note: A "released" menu will stay visible (on top of the window stack) until it is closed or an item is selected. 1 (ADDMENU MENU WINDOW POSITION DONTOPENFLG) [Function] 1 This function provides menus that remain active in windows. ADDMENU displays MENU at POSITION (in window coordinates) in WINDOW. If the window is too small to display the entire menu, the window is made scrollable. When an item is selected, the value of the WHENSELECTEDFN field of MENU is called with three arguments: (1) the item selected, (2) the menu, and (3) the mouse key that the item was selected with (LEFT, MIDDLE, or RIGHT). More than one menu can be put in a window, but a menu can only be added to one window at a time. ADDMENU returns the window into which MENU is placed. If WINDOW is NIL, a window is created at the position specified by POSITION (in screen coordinates) that is the size of MENU. If a window is created, it will be opened unless DONTOPENFLG is non-NIL. If POSITION is NIL, the menu is brought up at the value of MENU's MENUPOSITION field (in window coordinates), if it is a position, or else in the lower left corner of WINDOW. If both WINDOW and POSITION are NIL, a window is created at the current cursor position. Warning: ADDMENU resets several of the window properties of WINDOW. The CURSORINFN, CURSORMOVEDFN, and BUTTONEVENTFN window properties are replaced with MENUBUTTONFN, so that MENU will be active. MENUREPAINTFN is added to the REPAINTFN window property to update the menu image if the window is redisplayed. The SCROLLFN window property is changed to SCROLLBYREPAINTFN if the window is too small for the menu, to make the window scroll. 1 (DELETEMENU MENU CLOSEFLG FROMWINDOW) [Function] 1 This function removes MENU from the window FROMWINDOW. If MENU is the only menu in the window and CLOSEFLG is non-NIL, its window will be closed (by CLOSEW). If FROMWINDOW is NIL, the list of currently open windows is searched for one that contains MENU. If none is found, DELETEMENU does nothing. 1  (ЬЬј)KKјT/KЬјјT(ЬЬј(ј.ј((ј7(ЬЬј(MODERN MODERNMODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))  HRULE.GETFNMODERN   HRULE.GETFNMODERN їЬ B HRULE.GETFNMODERN LњlU- + 9= w{КO s HRULE.GETFNMODERN    HRULE.GETFNMODERN = … }f 3-4 ) Y 6 ,   %    ME HRULE.GETFNMODERN   HRULE.GETFNMODERN  $  G  HRULE.GETFNMODERN ћЄдzК 28.4.15 Example: A Scrollable Window 1 The following is a simple example showing how one might create a scrollable window. CREATE.PPWINDOW creates a window that displays the pretty printed expression EXPR. The window properties PPEXPR, PPORIGX, and PPORIGY are used for saving this expression, and the initial window position. Using this information, REPAINT.PPWINDOW simply reinitializes the window position, and prettyprints the expression again. Note that the whole expression is reformatted every time, even if only a small part actually lies within the window. If this window was going to be used to display very large structures, it would be desirable to implement a more sophisticated REPAINTFN that only redisplays that part of the expression within the window. However, this scheme would be satisfactory if most of the items to be displayed are small. RESHAPE.PPWINDOW resets the window (and stores the initial window position), calls REPAINT.PPWINDOW to display the window's expression, and then sets the EXTENT property of the window so that SCROLLBYREPAINTFN will be able to handle scrolling and "thumbing" correctly. (DEFINEQ (CREATE.PPWINDOW [LAMBDA (EXPR) (* rrb " 4-OCT-82 12:06") (* creates a window that displays a pretty printed expression.) (PROG (WINDOW) (* ask the user for a piece of the screen and make it into a window.) (SETQ WINDOW (CREATEW NIL "PP window")) (* put the expression on the property list of the window so that the repaint and reshape functions can access it.) (WINDOWPROP WINDOW (QUOTE PPEXPR) EXPR) (* set the repaint and reshape functions.) (WINDOWPROP WINDOW (QUOTE REPAINTFN) (FUNCTION REPAINT.PPWINDOW)) (WINDOWPROP WINDOW (QUOTE RESHAPEFN) (FUNCTION RESHAPE.PPWINDOW)) (* make the scroll function SCROLLBYREPAINTFN, a system function that uses the repaint function to do scrolling.) (WINDOWPROP WINDOW (QUOTE SCROLLFN) (FUNCTION SCROLLBYREPAINTFN)) (* call the reshape function to initially print the expression and calculate its extent.) (RESHAPE.PPWINDOW WINDOW) (RETURN WINDOW]) (REPAINT.PPWINDOW [LAMBDA (WINDOW REGION) (* rrb " 4-OCT-82 11:52") (* the repainting function for a window with a pretty printed expression. This repainting function ignores the region to be repainted and repaints the entire window.) (* set the window position to the beginning of the pretty printing of the expression.) (MOVETO (WINDOWPROP WINDOW (QUOTE PPORIGX)) (WINDOWPROP WINDOW (QUOTE PPORIGY)) WINDOW) (PRINTDEF (WINDOWPROP WINDOW (QUOTE PPEXPR)) 0 NIL NIL NIL WINDOW]) (RESHAPE.PPWINDOW [LAMBDA (WINDOW) (* rrb " 4-OCT-82 12:01") (* the reshape function for a window with a pretty printed expression.) (PROG (BTM) (* set the position of the window so that the first character appears in the upper left corner and save the X and Y for the repaint function.) (DSPRESET WINDOW) (WINDOWPROP WINDOW (QUOTE PPORIGX) (DSPXPOSITION NIL WINDOW)) (WINDOWPROP WINDOW (QUOTE PPORIGY) (DSPYPOSITION NIL WINDOW)) (* call the repaint function to pretty print the expression in the newly cleared window.) (REPAINT.PPWINDOW WINDOW) (* save the region actually covered by the pretty printed expression so that the scrolling routines will know where to stop. The pretty printing of the expression does a carriage return after the last piece of the expression printed so that the current position is the base line of the next line of text. Hence the last visible piece of the expression (BTM) is the ending position plus the height of the font above the base line (its ASCENT).) (WINDOWPROP WINDOW (QUOTE EXTENT) (create REGION LEFT _ 0 BOTTOM _ [SETQ BTM (IPLUS (DSPYPOSITION NIL WINDOW) (FONTPROP WINDOW (QUOTE ASCENT] WIDTH _(WINDOWPROP WINDOW (QUOTE WIDTH)) HEIGHT _(IDIFFERENCE (WINDOWPROP WINDOW (QUOTE HEIGHT)) BTM]) ) (ЬЬј(ЬЬј(ЬЬј(ј.ј ((ЬЬј(MODERN MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) ' HRULE.GETFNMODERN V>`G ЁC7 < ##!%:#"%"2#%#%!%2#% /3/3#%%%.4#%"%$# . + +  #!% %001%##%%  - 0 /-1-1#%%$ 1 1 0 / 0 2 - 0 5,/HN>*Q4с