home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:37:50-MDT,3191;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:37:44 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22530; Sat, 18 Jun 88 14:37:45 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24715; Sat, 18 Jun 88 14:37:42 MDT
- Date: Sat, 18 Jun 88 14:37:42 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182037.AA24715@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: PopupMenu-XCMD.p
-
- {$R- }
- {$S PopUpMenu }
-
-
- { PopUpMenu( MenuItems, CheckedItem, Top, Left );
-
- This HyperCard external function returns the selection from a popup
- menu created from a hypercard item list (the first parameter). The
- menu is placed on the screen so that the checked item is at the
- position (global) top,left.
-
- To compile and link using Macintosh Programmer's Workshop 2.0 execute
- the following:
-
- pascal -w PopUp.p
- link -o HyperCommands -rt XFCN=0 -sn Main=PopUpMenu PopUp.p.o
-
- I wish to thank Dewi Williams and Larry Rosenstein for thier initial
- information and example.
-
- Andrew Gilmartin
- Brown University
- }
-
-
- unit PopUpUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, HyperXCmd;
-
- procedure EntryPoint( paramPtr: XCmdPtr );
-
- implementation
-
- procedure PopUpMenu( paramPtr: XCmdPtr ); forward;
-
-
- procedure EntryPoint( paramPtr: XCmdPtr );
- begin
- PopUpMenu( paramPtr )
- end{ entrypoint };
-
-
- procedure PopUpMenu;
-
- const MenuID = 128;
-
- var Menu : MenuHandle;
- MenuItems : Str255;
- CheckedItem ,
- SelectedItem,
- Top ,
- Left : LongInt;
-
-
- {$I XCmdGlue.inc}
-
-
- procedure ParamToMenuItems( Param: Handle; var MenuItems: Str255 );
- var Index: integer;
- begin
-
- ZeroToPas( Param^, MenuItems );
-
- for Index := 1 to length( MenuItems )
- do
- if MenuItems[ Index ] = ',' then
- MenuItems[ Index ] := ';';
-
- end{ ParamToMenuItems };
-
-
- function ParamToNum( Param: Handle ): LongInt;
- var Str: Str255;
- begin
- ZeroToPas( Param^, Str );
- ParamToNum := StrToNum( Str );
- end{ ParamToNum };
-
-
- function NumToParam( Num: LongInt ): Handle;
- var Str: Str31;
- begin
- Str := NumToStr( Num );
- NumToParam := PasToZero( Str )
- end{ NumToParam };
-
-
- begin
-
- with paramPtr^ do
- begin
-
- { Create the PopUp menu }
- ParamToMenuItems( Params[1], MenuItems );
- CheckedItem := ParamToNum( Params[2] );
- Menu := NewMenu( MenuID, '' );
- AppendMenu( Menu, MenuItems );
- CheckItem( Menu, CheckedItem, true );
- InsertMenu( Menu, -1 );
-
- { Get Menu Position }
- Top := ParamToNum( Params[3] );
- Left := ParamToNum( Params[4] );
-
- { Get Menu Selection }
- SelectedItem := PopUpMenuSelect( Menu, Top, Left, CheckedItem );
-
- { Tidy up }
- DeleteMenu( MenuID );
- DisposeMenu( Menu );
-
- { Return the selection }
- returnValue := NumToParam( LoWord( SelectedItem ) )
-
- end
-
- end{ PopUpMenu };
-
- end.{ PopUp Unit }
-