home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ICONMN.ZIP / ICONTST1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-04-11  |  4.4 KB  |  125 lines

  1. (* ICONTST1.PAS *)
  2. (* Demo of icons made by the ICON constructor *)
  3.  
  4. uses crt, graph, drivers, iconmeu1;
  5.  
  6. var ics : icon_array;  {Defined in ICONMEU1.TPU - It is an array
  7.           of bytes that reference the bit-mapped icons.
  8.           Programmer defines these.  Maximum usable is 5, to
  9.           be displayed down from top left corner of screen.
  10.           These can be selected from a maximum of 32 in a single icon file.}
  11.     grdriver, grmode : integer;
  12.     icon_selected, exit_icon : byte;
  13.     x, y, button, xpos, ypos : word;
  14.     across : boolean;
  15.     icon_file_name, icon_conf : string;
  16.     icon_dat : text;
  17.     qq : char;
  18.  
  19.  procedure input_icon_menu_parameters;
  20.  var t : byte;
  21.      q : char;
  22.      i : word;
  23.  begin
  24.    clrscr;
  25.    writeln('Icon menu procedures require data input as follows:');
  26.    writeln('    Path & file name of icons created by ICON-MK program.');
  27.    writeln('    List of icon numbers from file to be used (an array of bytes).');
  28.    writeln('       Maximum of 5 can be used.');
  29.    writeln('    Icon position in display to be used as exit.');
  30.    writeln('       (See details in ICONMEU1.DOC file.)');
  31.    writeln('Source for above data can be:');
  32.    write('    A: User input    B: Text file    C: Programmed    (A/B/C) ? ');
  33.    q:=' ';
  34.    while not (q in ['A','B','C']) do q:=upcase(readkey);
  35.    writeln(q);
  36.    case q of
  37.      'A' : begin
  38.             writeln('Careful. These data inputs are NOT bullet-proof.');
  39.             write('Enter icon file name : ');
  40.             readln(icon_file_name);
  41.             write('Enter list of icon numbers to use (last should be 0) : ');
  42.             i:=1;
  43.             repeat
  44.               read(ics[i]);
  45.               inc(i);
  46.             until (ics[i-1]=0) or (i>5);
  47.             readln;
  48.             write('Enter icon position number to use for exit : ');
  49.             readln(exit_icon);
  50.           end;
  51.      'B' : begin
  52.             write('Enter file name with menu parameters : ');
  53.             readln(icon_conf);
  54.             assign(icon_dat,icon_conf);
  55.             {$I-} reset(icon_dat);  {$I+}
  56.             if ioresult<>0 then
  57.                begin
  58.                 write('No such file. Aborting program.  Press any key .. ');
  59.                 q:=readkey;
  60.                 halt;
  61.                end;
  62.             readln(icon_dat,icon_file_name);
  63.             t:=1;
  64.             repeat
  65.               read(icon_dat, ics[t]);
  66.               write('@',ics[t]);
  67.               inc(t);
  68.             until (t>5) or (ics[t-1]=0);
  69.             readln(icon_dat, exit_icon);
  70.             close(icon_dat);
  71.            end;
  72.      'C' : begin
  73.              icon_file_name:='icon-dem.dat';
  74.              ics[1]:=8; ics[2]:=1; ics[3]:=10; ics[4]:=20; ics[5]:=0;
  75.              exit_icon:=1;
  76.            end;
  77.         end;
  78. end;
  79.  
  80.  
  81. BEGIN
  82.    directvideo:=false;
  83.          {Allows use of normal write/writeln while in graphics.}
  84.  
  85.    input_icon_menu_parameters;
  86.  
  87. (* This program requires a DRIVERS.TPU file as described in BGI documentation.
  88.    The alternative would be to omit the 'register.. ' statement below, and
  89.     enter the path for the BGI files in the initgraph procedure. *)
  90.  
  91.  if registerBGIdriver(@EGAVGAdriverproc)<0 then
  92.       begin writeln('Must have EGA or VGA graphics.'); exit; end;
  93.   grdriver:=EGA;   {if you use VGA, then grmode must be VGAMED.}
  94.   grmode:=EGAHI;
  95.   initgraph(grdriver, grmode, '');
  96.  
  97. (* CRT must be in either EGA or VGA mode.
  98.    Select desired icon to use, and order in which they will be displayed.
  99.    The programmer must select existing icons in an existing file.
  100.    The number of icons declared to be used must match the number defined.
  101.    The display procedure just paints the icons. *)
  102.  
  103.   display_icons(icon_file_name,  {file must exist in path}
  104.      ics, blue, lightgreen);
  105.  
  106. repeat
  107.  
  108. (* The use procedure returns the mouse position and button state continuously.
  109.   If left button is pressed when mouse is over icon, icon number is returned,
  110.   else 0 is returned. Programmer can use icon selected, button number, and
  111.   mouse cursor position.  When over icon bar, mouse cursor becomes a hand. *)
  112.  
  113.   use_icon_menu(icon_selected, x, y, button);
  114.  
  115.   (* Any other routines, including those that use the mouse can be introduced
  116.      here, and controlled by any or all of the returned values. *)
  117.  
  118.   gotoxy(20,10);
  119.   write('Selected icon, coordinates, & button : ',
  120.             icon_selected,'  ',x,' ',y,' ',button,'   ');
  121.  
  122. until icon_selected=exit_icon;
  123.  
  124. closegraph;
  125. END.