home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TJOCKREF.ZIP / PULLTTT.TXT < prev    next >
Encoding:
Text File  |  1988-08-22  |  4.8 KB  |  131 lines

  1. !SHORT:Pull_Menu         Display a pulldown menu
  2. Pull_Menu                                                      PullTTT
  3.      
  4.  
  5.  
  6. Purpose   To display a pulldown menu.
  7.  
  8. Declaration    Pull_menu(M: MenuDesc; var PickM, PickS: byte);
  9.                
  10.           M is the MenuDesc array containing all the topics
  11.                
  12.           PickM is returned with the main heading selected, this is
  13.           set to 0 if the user pressed Esc and PM.AllowEsc is true.
  14.                
  15.           PickS is returned with the sub-topic selected
  16.  
  17. Uses Crt, FastTTT, DOS, WinTTT, KeyTTT, PullTTT.
  18.  
  19. Remarks   Modify the contents of the PM record to alter display
  20.           format.
  21.                
  22.           The PickM and PickS variables should be initialized to the
  23.           default values that should be highlighted when the menu is
  24.           first displayed. If PickS is set to 0, the submenu will not
  25.           be initially displayed.
  26.  
  27.  
  28.  
  29. Example    Program Illustrating_The_PullDown_Menu_Kit;
  30.  
  31.            Uses Crt, FastTTT, DOS, WinTTT, KeyTTT, PullTTT;
  32.  
  33.            { Notes:   1) The MenuDesc Type is an array of strings holding the
  34.            description of the menu titles.
  35.            2) The main headings of each pull down option must start
  36.            with a '\'.
  37.            3) The last choice in the array must be followed by a
  38.            string '\\'.
  39.            Thats all there is to it.}
  40.            var
  41.            TheMenu : MenuDesc;   {Array holding the menu definitions}
  42.  
  43.            Procedure Define_Demo_Menu;
  44.            begin
  45.              Fillchar(Themenu,sizeof(Themenu),#0);
  46.              TheMenu[1] := '\File';      {menu definition for pull down menu}
  47.              TheMenu[2] := 'Load        ';
  48.              TheMenu[3] := 'New         ';
  49.              TheMenu[4] := 'Save        ';
  50.              TheMenu[5] := 'Write to    ';
  51.              TheMenu[6] := 'Directory   ';
  52.              TheMenu[7] := 'Change dir  ';
  53.              TheMenu[8] := 'OS shell    ';
  54.              TheMenu[9] := 'Quit        ';
  55.              TheMenu[10] :=  '\Edit ';
  56.              TheMenu[11] :=  '\Run ';
  57.              TheMenu[12] := '\Compile     ';
  58.              TheMenu[13] := 'Make         ';
  59.              TheMenu[14] := 'Build        ';
  60.              TheMenu[15] := 'Destination  ';
  61.              TheMenu[16] := 'Find Error   ';
  62.              TheMenu[17] := 'Primary file ';
  63.              TheMenu[18] := 'Find         ';
  64.              TheMenu[19] := 'find/Replace ';
  65.              TheMenu[20] := 'find Next    ';
  66.              TheMenu[21] := 'Get Info     ';
  67.              TheMenu[22] := '\Options';
  68.              TheMenu[23] := 'Compiler    ';
  69.              TheMenu[24] := 'Environment ';
  70.              TheMenu[25] := 'Directories ';
  71.              TheMenu[26] := 'Parameters  ';
  72.              TheMenu[27] := 'Load Options';
  73.              TheMenu[28] := 'Save Options';
  74.              TheMenu[29] := '\\';
  75.              end; {Proc Define demo menu}
  76.            Procedure Fill_Screen_With_Junk;
  77.            var I,J : integer;
  78.            begin
  79.              ClrScr;
  80.              Fillscreen(1,1,80,23,15,0,chr(001));
  81.              WriteCenter(24,15,0,'ESC to exit Menu or F1 for Help');
  82.            end;
  83.            {$F+}
  84.            Procedure Menu_Help(Var ChM:Char;PickM,PickS : byte);
  85.            {an example of how to hook other procedures into the menu system}
  86.            var Ch : char;
  87.            begin
  88.              If ChM = #187 then
  89.              begin
  90.                MkWin(20,7,60,15,white,red,1);
  91.                WriteAT(22,9,white,red,'This could be context sensitive');
  92.                WriteAT(22,10,white,red,'about the highlighted pick:');
  93.                GotoXY(25,12);Write('Main Pick ',PickM);
  94.                GotoXY(25,13);Write('Sub  Pick ',PickS);
  95.                Ch := GetKey;
  96.                RmWin;
  97.               end;
  98.              end;
  99.              {$F-}
  100.  
  101.  
  102.            var
  103.            Major,Minor : byte;
  104.            Ch : char;
  105.            begin   {main demo program}
  106.              Define_Demo_Menu;
  107.              Fill_Screen_With_Junk;
  108.              Major := 1;
  109.              Minor := 4;
  110.              PM_UserHook := @Menu_Help;
  111.              With PM do
  112.                begin
  113.                  Style := 0;  {0 no border, 1 single border, 2 double border}
  114.                  TopX :=  1;
  115.                  TopY := 2;
  116.                  ScreenNo := 3;
  117.                  Gap :=  5;
  118.                 end; {With}
  119.              Pull_Menu(TheMenu,Major,Minor);
  120.              GotoXY(1,20);
  121.              If Major = 0 then
  122.                write('You escaped')
  123.              else
  124.                write('You selected main menu ',Major,' and sub-topic ',Minor);
  125.                WriteAT(1,22,white,black,'Run DemoTTT.exe for the main demo program');
  126.                WriteAT(1,23,white,black,'Technojocks Turbo Toolkit v4.0');
  127.                Ch := Readkey;
  128.            end.
  129.  
  130. !SEEALSO:Menuttt.ngo:DisplayMenu
  131.