XEROX PULLDOWNMENUS 2 4 1 PullDownMenus 1 4 By: Mark Richer (Unsupported) INTRODUCTION The PULLDOWNMENUS package provides you with an easy way to create pull-down menus. A pull-down menu consists of a window with a string or a bitmap displayed in it, and a 'popup' menu which is displayed directly under the main window whenever you press the left or middle mouse button in the main window. The user then selects an item from the popup menu or releases the mouse button off of the popup menu (in the latter case nothing happens). The popup menu is displayed using MENU and the result of selecting an item is exactly the same as if you had called the menu with MENU yourself. Note that when you button in the main window it inverts and after releasing the mouse button it inverts back again. Therefore the user thinks the main window is acting much like a menu item. However, it is not an Interlisp-D menu but simply a window with its own special buttoneventfn, repaintfn and so on. The package does not support 'menu bars' where you would have more than one item in a main window and each would have its own pull-down menu. Also, you cannot display a pulldownmenu in an existing window. The package automatically creates a window, though you can control for width, height and font used. CREATING A PULL-DOWN MENU To create a pull-down menu you create a record specifying at least the thing to be displayed in the window that always shows and the menu that will be pulled down. The window is created automatically and at this time you cannot specify your own window. PULLDOWNMENU is a record with the following fields: (1) PDBITMAP if it's a bitmap then it will be displayed in the center of the window that's automatically created. (2) PDLABEL if PDBITMAP is not a bitmap then PDLABEL will be printed in the center of the window created. If PDBITMAP is a bitmap and PDLABEL is non-nil then PDLABEL will be used as the title of the window created. An attempt is made to center a title by adding leading spaces. If the width of the window is too small to get the full title printed or properly centered you will want to set the PDWIDTH yourself. (3) PDMENU This is the menu that will pull down (or popup) when you button the main window. The pulldownmenu is stored on the 'property list' of the window that's created so that the window's buttoneventfn can access it easily. The buttoneventfn simply calls the function MENU with the PDMENU of the pulldownmenu as an argument. The position is calculated dynamically so that it appears directly under the window and is lined up against the left border. If PDMENU is not a menu then nothing happens when you button the window. [the fields below all have defaults so they need not be set though you may want to set the position yourself (or pass it when you call ADDPULLDOWNMENU) ] (4) PDPOSITION This is used for the left and bottom coordinates of the window created. If nil then the current cursor position is used, otherwise it should be a legal POSITION. (5) PDFONT If there's no PDBITMAP then this is used as the font in which PDLABEL is printed. You can store a fontdescriptor or a list such as '(HELVETICA 12 BOLD). (6) PDHEIGHT If a number then it is used as the height of the window. (7) PDWIDTH If a number then it is used as the width of the window. (8) PDBORDER If a number then it is used as the border width of the window. The default is 1. (9) PDWINDOW Do not set this yourself; it's stored for your convenience in case you need it. DISPLAYING A PULL-DOWN MENU Use the function ADDPULLDOWNMENU to display a pull down menu, it is analogous to ADDMENU. It takes a PULLDOWNMENU as an argument and returns the window created. A second optional argument is the position where to display the main window. If nil then if PDPOSITION is a position it is used, otherwise the cursorposition is used. CHANGING THE PULL-DOWN MENU CHANGE.PULLDOWNMENU takes a PULLDOWNMENU and a MENU as arguments and replaces the PDMENU of PULLDOWNMENU with MENU. An Example (SETQ TEST.PDMENU (create PULLDOWNMENU PDLABEL<-"TEST" PDMENU <- (create MENU ITEMS <- '(1 2 3)) )) (ADDPULLDOWNMENU TEST.PDMENU) Notes If you supply PDBITMAP and PDLABEL the latter is assumed to be a title for the window created and it is centered even if you reshape the window. If you don't want the user to reshape or move the window set those window properties to DON'T (see Interlisp manual). If you don't want the titles centered then add a title yourself using WINDOWPROP. Eventually I'll make PULLDOWNMENU a datatype and add more fields to it to control these properties. Acknowledgements Of course I was inspired by the world's cutest computer and its predecessor. C.D. Lane helped with the implementation details of this version. (LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC ) STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC )) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC )) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))(È (È(ŠŠ8(ŠŠ8DÈÈ PAGEHEADING RUNNINGHEAD TERMINAL MODERN MODERN MODERN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) MODERN MODERN MODERNLOGO  HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN  ü4r£¡²¥FD_aT| …Α0Lzº