home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPPAN.ZIP / PICK.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-05-10  |  5.7 KB  |  221 lines

  1. {
  2.  
  3.     pick.pas
  4.     5-10-90
  5.  
  6.     Copyright 1990
  7.     John W. Small
  8.     All rights reserved
  9.  
  10.     PSW / Power SoftWare
  11.     P.O. Box 10072
  12.     McLean, Virginia 22102 8072
  13.  
  14. }
  15.  
  16. unit pick;
  17.  
  18. interface
  19.  
  20.     uses crt, panscrol, crtplus, flex;
  21.  
  22.     type
  23.  
  24.         PickAttrs = (PICK_TITLE_ATTR, PICK_BORDER_ATTR,
  25.                     PICK_SCROLL_ATTR, PICK_NORMAL_ATTR,
  26.                     PICK_SELECT_ATTR, PICK_HILITE_ATTR);
  27.         PickAttrsArray = array[PickAttrs] of byte;
  28.         PickAttrsA = ^PickAttrsArray;
  29.  
  30.     const
  31.  
  32.         PickColorAttrs : PickAttrsArray = (
  33.             BLACK + LIGHTGRAY * 16,
  34.             BLACK + LIGHTGRAY * 16,
  35.             RED   + LIGHTGRAY * 16,
  36.             BLACK + LIGHTGRAY * 16,
  37.             WHITE + BLACK     * 16,
  38.             RED   + LIGHTGRAY * 16);
  39.  
  40.         PickMonoAttrs : PickAttrsArray = (
  41.             BLACK + LIGHTGRAY * 16,
  42.             BLACK + LIGHTGRAY * 16,
  43.             WHITE + LIGHTGRAY * 16,
  44.             BLACK + LIGHTGRAY * 16,
  45.             WHITE + BLACK     * 16,
  46.             WHITE + LIGHTGRAY * 16);
  47.  
  48.     type
  49.  
  50.         PickList = object(FlexList)
  51.             color, mono, attrs : PickAttrsA;
  52.             ps : PanScroller;
  53.             finished : boolean;
  54.             title : string;
  55.             constructor init(PickFlexDataSize,
  56.                 PickRows, PickColumns : word;
  57.                 PickX, PickY, PickColumnWidth : byte;
  58.                 PickTitle : string);
  59.             procedure   showItem; virtual;
  60.             function    doItem : boolean; virtual;
  61.             procedure   query;
  62.             destructor  done; virtual;
  63.             end;
  64.  
  65. implementation
  66.  
  67.  
  68.     constructor PickList.init(PickFlexDataSize,
  69.                 PickRows, PickColumns : word;
  70.                 PickX, PickY, PickColumnWidth : byte;
  71.                 PickTitle : string);
  72.         begin
  73.             FlexList.init(PickFlexDataSize);
  74.             color := @PickColorAttrs;
  75.             mono := @PickMonoAttrs;
  76.             if TxtScr.ColorAttrs then
  77.                 attrs := color
  78.             else
  79.                 attrs := mono;
  80.             ps.init(0,PickColumns,PickRows,PickColumns);
  81.             ps.ScreenStartColumn := PickX;
  82.             ps.ScreenStartRow := PickY;
  83.             ps.ScreenColumnWidth := PickColumnWidth;
  84.             title := PickTitle
  85.         end;
  86.  
  87.     procedure   PickList.showItem;
  88.         begin
  89.         end;
  90.  
  91.     function    PickList.doItem : boolean;
  92.         begin
  93.         end;
  94.  
  95.     procedure   PickList.query;
  96.         var lp,wrow,wcols,scol : word;
  97.             p : pointer;
  98.             w : FramedTextWindow;
  99.         begin
  100.             if nodes = 0 then exit;
  101.             if TxtScr.ColorAttrs then
  102.                 attrs := color
  103.             else
  104.                 attrs := mono;
  105.             w.window(ps.ScreenStartColumn,
  106.                 ps.ScreenStartRow,
  107.                 ps.ScreenStartColumn +
  108.                     ps.WindowColumns *
  109.                     (ps.ScreenColumnWidth + 3),
  110.                 ps.ScreenStartRow + ps.WindowRows + 1);
  111.             cursor.Off;
  112.             w.frame(attrs^[PICK_BORDER_ATTR],svsh);
  113.             w.titleFooter(true,attrs^[PICK_TITLE_ATTR],title);
  114.             ps.ResizeImage(
  115.                 (nodes-1) div ps.ImageColumns + 1,
  116.                 ps.ImageColumns);
  117.             ps.CursorRC(1,1);
  118.             ps.UpdateWindow := true;
  119.             finished := false;
  120.             while not finished  do begin
  121.                 if ps.UpdateWindow or ps.UpdateCursor then begin
  122.                     if ps.UpdateWindow then begin
  123.                         crt.textAttr := attrs^[PICK_NORMAL_ATTR];
  124.                         clrscr;
  125.                         lp := word(ps.WindowStartLinearPosition);
  126.                         mkcur(lp);
  127.                         for wrow := 1 to ps.WindowRows do begin
  128.                             scol := 2;
  129.                             wcols := ps.WindowColumns;
  130.                             while ok and (wcols > 0) do begin
  131.                                 gotoxy(scol,wrow);
  132.                                 showItem;
  133.                                 if nextD(p) then;
  134.                                 dec(wcols);
  135.                                 inc(scol,ps.ScreenColumnWidth);
  136.                                 inc(scol,3);
  137.                                 end;
  138.                             inc(lp,ps.ImageColumns);
  139.                             mkcur(lp);
  140.                             end;
  141.                         ps.UpdateWindow := false
  142.                         end
  143.                     else begin    { Erase last hilite bar }
  144.                         TxtScr.windLightBar(
  145.                             ps.LastCursorWindowColumn,
  146.                             ps.LastCursorWindowRow,
  147.                             ps.ScreenColumnWidth+2,
  148.                             attrs^[PICK_NORMAL_ATTR]);
  149.                         gotoxy(ps.LastCursorWindowColumn+1,
  150.                             ps.LastCursorWindowRow);
  151.                         showItem
  152.                         end;
  153.                     mkcur(word(ps.CursorLinearPosition));
  154.                     ps.LastCursorWindowRow :=
  155.                         ps.CursorWindowRow;
  156.                     ps.LastCursorWindowColumn :=
  157.                         (ps.CursorWindowColumn-1) *
  158.                         (ps.ScreenColumnWidth+3)+1;
  159.                     TxtScr.windLightBar(
  160.                         ps.LastCursorWindowColumn,
  161.                         ps.LastCursorWindowRow,
  162.                         ps.ScreenColumnWidth+2,
  163.                         attrs^[PICK_SELECT_ATTR]);
  164.                     w.scrollBar(true,attrs^[PICK_BORDER_ATTR],svsh,
  165.                         attrs^[PICK_SCROLL_ATTR],
  166.                         ps.CursorImageRow,
  167.                         (nodes-1) div ps.ImageColumns + 1);
  168.                     ps.UpdateCursor := false;
  169.                     end;    { if update }
  170.                 case crtplus.readkey of
  171.                     #0: begin
  172.                         case char(hi(crtplus.asciiScan)) of
  173.                             DnArr: ps.CursorDown;
  174.                             UpArr: ps.CursorUp;
  175.                             RArr: ps.CursorRight;
  176.                             LArr: ps.CursorLeft;
  177.                             PgUp: ps.CursorPgUp;
  178.                             PgDn: ps.CursorPgDown;
  179.                             Home: ps.CursorRC(1,1);
  180.                             EndKey: ps.CursorRC(ps.ImageRows,1);
  181.                         end; { case hi(asciiScan) }
  182.                         end; { #0: }
  183.                     ESC: begin
  184.                         w.done;
  185.                         finished := true
  186.                         end;
  187.                     CR: if ps.CursorLinearPosition <= nodes
  188.                         then begin
  189.                         if doItem then
  190.                            finished := true
  191.                         else if nodes = 0 then
  192.                              finished := true
  193.                         else begin
  194.                             ps.ResizeImage(
  195.                                 (nodes-1) div ps.ImageColumns + 1,
  196.                                 ps.ImageColumns);
  197.                             ps.CursorRC(1,1);
  198.                             ps.UpdateWindow := true;
  199.                             w.frame(attrs^[PICK_BORDER_ATTR],svsh);
  200.                             w.titleFooter(true,attrs^[PICK_TITLE_ATTR],title)
  201.                             end;
  202.                         if finished then
  203.                            w.done;
  204.                         end;
  205.                 end { case crtplus.readkey }
  206.                 end { while not finished }
  207.         end;
  208.  
  209.     destructor  PickList.done;
  210.         begin
  211.             FlexList.done
  212.         end;
  213.  
  214.     begin
  215.  
  216.     end.
  217.  
  218.  
  219.  
  220.  
  221.