DIRECTORY Buttons USING [Button], Rope USING [ROPE], VFonts USING [defaultFont, Font], ViewerClasses USING [Viewer]; ChoiceButtons: CEDAR DEFINITIONS IMPORTS Buttons, VFonts = BEGIN EnumTypeRef: TYPE = REF EnumTypeRec; EnumTypeRec: TYPE = RECORD [ proc: SelectionNotifierProc _ NIL, -- procedure called everytime a button's selected(optional) permission: EnumPermissionProc _ NIL, --(optional)permission proc called before doing anything namesOfButtons: ButtonList _ NIL, -- list of names of buttons in this Enumerated type nextx: CARDINAL, -- next x position in container that client may begin -- displaying info so that it wont overwrite the buttons nexty: CARDINAL, -- same as nextx type: DisplayStyle, buttonOn: Buttons.Button _ NIL, -- The button currently on for a given enumerated type flipLabel: ViewerClasses.Viewer _ NIL, -- Points to the Viewer to re-label clientdata: REF ANY _ NIL -- optional data provided by the client and used when the -- selection notifier procedure is called. ]; ButtonList: TYPE = LIST OF Rope.ROPE; StyleChoice: TYPE = {menuSelection, flipThru}; DisplayStyle: TYPE = {menuStyle, flipThruWithTitle, flipThruNoTitle}; BuildEnumTypeSelection: PROCEDURE [viewer: ViewerClasses.Viewer, x, y: CARDINAL _ 0, title: Rope.ROPE _ NIL, buttonNames: ButtonList, default: Rope.ROPE _ NIL, borderOnButtons: BOOL _ TRUE, notifyClientProc: SelectionNotifierProc _ NIL, permit: EnumPermissionProc _ NIL, clientdata: REF ANY _ NIL, style: StyleChoice, allInOneRow: BOOL _ TRUE, maxWidth: INTEGER _ LAST[INTEGER]] RETURNS [EnumTypeRef]; GetSelectedButton: PROCEDURE [handle: EnumTypeRef] RETURNS [Rope.ROPE]; UpdateChoiceButtons: PROCEDURE [viewer: ViewerClasses.Viewer, enumTypeInfo: EnumTypeRef, newName: Rope.ROPE]; SelectionNotifierProc: TYPE = PROCEDURE [name: Rope.ROPE, clientdata: REF ANY]; EnumPermissionProc: TYPE = PROC [handle: EnumTypeRef] RETURNS [BOOL]; ThreeStateRef: TYPE = REF ThreeState; ThreeState: TYPE = RECORD [ button: Buttons.Button _ NIL, state: StateType _ off ]; StateType: TYPE = {off, on, default}; BuildTriStateButton: PROCEDURE [viewer: ViewerClasses.Viewer, x,y: INTEGER _ 0, name: Rope.ROPE] RETURNS [stateInfo: ThreeStateRef, nextX: INTEGER]; SetButtonState: PROCEDURE [buttonSelected: Buttons.Button, state: StateType]; PromptDataRef: TYPE = REF PromptDataRec; PromptDataRec: TYPE = RECORD [ promptButton: Buttons.Button, textViewer: ViewerClasses.Viewer, newy, newx: CARDINAL, clientdata: REF ANY _ NIL, permission: PromptPermissionProc, notify: SelectionNotifierProc ]; PromptPermissionProc: TYPE = PROCEDURE [handle: PromptDataRef] RETURNS [BOOL]; BuildTextPrompt: PROCEDURE [viewer: ViewerClasses.Viewer, x,y: CARDINAL _ 0, title: Rope.ROPE, default: Rope.ROPE _ NIL, font: VFonts.Font _ VFonts.defaultFont, textViewerWidth: INTEGER _ LAST[INTEGER], clientdata: REF ANY _ NIL, notify: SelectionNotifierProc _ NIL, permit: PromptPermissionProc _ NIL] RETURNS [promptData: PromptDataRef]; DefaultDoesntExist: SIGNAL; ChoiceDoesntExist: SIGNAL; ButtonsCannotBeUpdated: SIGNAL; END. € ChoiceButtons.mesa; Written by Linda Gass on August 20, 1982 2:36 pm Last Edit by Linda Gass September 24, 1982 2:26 pm Last Edited by: Maxwell, December 17, 1982 10:08 am Last Edited by: McGregor, July 21, 1983 10:59 am ********************* For diplaying Enumerated Types ****************************** (NOTE: It would have seemed natural to make the above record a variant record but because of language constraints, it would have been more trouble than it was worth to implement it) A ButtonList is a list of the names of the buttons to be displayed as Choices. SIGNALS DefaultDoesntExist See documentation below Using the handle, it returns the currently selected button SIGNALS ChoiceDoesntExist and ButtonsCannotBeUpdated client returns true if "giving permission", false otherwise. ********************* For diplaying Three state buttons ****************************** ********************* For diplaying Text Prompts ****************************** See documentation below **** BuildEnumTypeSelection **** Takes an enumerated type in the form of a list and displays it either as a menu selection of buttons or a sequence of labels displayed when a button is selected. "container" is the Container that this selection of buttons is to be displayed in "x, y" are the x and y positions in the Container at which this menu is to be displayed "title" is the name to be displayed before the selection. It can be left empty. "buttonNames" is the list of names to appear in the buttons "default" is the button which will originally be turned "on" when this menu is first displayed. NOTE: Signals "DefaultDoesntExist" if specified default wasn't found in button list "borderOnButtons" indicates if a border should be placed around the buttons in the enumerated type selection. NOTE: the labels will never have a border. "permit" is a procedure which is called when a button is selected. It is intended to be some sort of "permission" which enables the button switching procedure to continue with its task. There are times when the client may want to prevent anything from happening when a button is selected "notifyClientProc" is a procedure which is called when a button is selected. It makes available to the client a rope containing the name associated with that button. "clientdata" optional information for use by the client. Returned when the notifyClientProc is called. "style" allows the user to choose different display styles for the EnumTypeSelection menuSelection - displays all the different button names but only one button can be "on" at a given point in time. flipThru - displays only one button name at a time, "flipping through" all the different possibilities. Optional title preceding it. "allInOneRow - optional. When menu selection is used, tell whether all should be in one row. "maxWidth - optional. When menu selection is used and allInOneRow is FALSE. Tells how wide to make each row of the menu. Returns a SelectionRef which contains information about the button which is currently "on" This Ref may be used in conjunction with the "GetSelectedButton" procedure to find out which button is currently "on" rather than using the notifyClientProc everytime a new button is selected. (i.e. - the client actually has two options for using BuildEnumType- Selection: (1) The client can be notified everytime a new button is selected by providing a notifyClientProc or (2) The client can save the SelectionRef returned from BuildEnum- TypeSelection and use this Ref and GetSelectedButton to inquire which button is on at a given time. NOTE: the SelectionRef.buttonOn returned by BuildEnumTypeSelection initially is the default value provided, it does NOT necessarily contain the CURRENT button on. **** BuildTriStateButton **** Builds a button which cycles through three states. The states are indicated by different color backgrounds. The state may be initialized by using the procedure "SetButtonState" **** BuildTextPrompt **** Builds a "label" and a corresponding text viewer. The "label" is really a button such that when the "label" is selected it forces the selection into the corresponding text field. If the "label" was selected with red mouse button then this causes the text viewer to become pending delete. Otherwise displays the default if one was specified initially. If no default was specified initially then sets contents of text viewer to NIL. "container" is the parent container that this text prompt will be displayed in "x, y" are the x and y positions in the container at which this text prompt is to be displayed "title" is the text displayed on the "label" "default" (optional) text to be displayed initially and when text prompt is selected with yellow or blue mouse button "font" is the font that the "label" will be displayed in "textViewerWidth" is how wide to make the text viewer. If not specified then will make the text viewer as wide as the container. Κi– "cedar" style˜IprocšΟcE™EKšœ2™2J™3J™0K˜šΟk œ˜ Kš œ žœžœžœ žœ$žœ ˜l—K˜Kšœžœžœžœ˜AKšU™UKšœ žœžœ ˜$š-œ žœžœ"žœ<œ"žœ9œžœ4œžœ6œ 9œžœœ1žœ7œ#žœ%œ žœžœžœ:œ +œ˜ΌKš½™½—š œ žœžœžœžœ˜'KšO™O—Kšœ žœ˜/Kšœžœ4˜Fš(Οnœž œ&žœžœžœ)žœžœžœžœ,žœžœžœžœžœ#žœžœ žœžœžœžœ˜‘KšΠik,™3—šŸœž œžœžœ˜HKš;™;—šŸœž œIžœ˜mKš4™4—Kš Ÿœžœž œ žœžœžœ˜Pš Ÿœžœžœžœžœ˜EKš=™=—KšXœ™YKšœžœžœ ˜%Kšœ žœžœžœ!˜[Kšœ žœ˜&Kš Ÿœž œ%žœžœžœ#žœ˜•KšŸœž œ6˜PKšQœ™RKšœžœžœ˜(Kš œžœžœRžœžœžœžœH˜ΪKš Ÿœžœž œžœžœ˜PšŸœž œ%žœžœžœžœ;žœžœžœžœžœžœ"žœ!žœžœ˜ΣKšœ™—Kšœžœ˜Kšœžœ˜Kšœžœ˜!Kšžœ˜š*™*KšΏ™Ώ—š'™'Kš΅™΅—šœ$™$KšΔ™Δ——…— <#I