home *** CD-ROM | disk | FTP | other *** search
- (* ICONTST1.PAS *)
- (* Demo of icons made by the ICON constructor *)
-
- uses crt, graph, drivers, iconmeu1;
-
- var ics : icon_array; {Defined in ICONMEU1.TPU - It is an array
- of bytes that reference the bit-mapped icons.
- Programmer defines these. Maximum usable is 5, to
- be displayed down from top left corner of screen.
- These can be selected from a maximum of 32 in a single icon file.}
- grdriver, grmode : integer;
- icon_selected, exit_icon : byte;
- x, y, button, xpos, ypos : word;
- across : boolean;
- icon_file_name, icon_conf : string;
- icon_dat : text;
- qq : char;
-
- procedure input_icon_menu_parameters;
- var t : byte;
- q : char;
- i : word;
- begin
- clrscr;
- writeln('Icon menu procedures require data input as follows:');
- writeln(' Path & file name of icons created by ICON-MK program.');
- writeln(' List of icon numbers from file to be used (an array of bytes).');
- writeln(' Maximum of 5 can be used.');
- writeln(' Icon position in display to be used as exit.');
- writeln(' (See details in ICONMEU1.DOC file.)');
- writeln('Source for above data can be:');
- write(' A: User input B: Text file C: Programmed (A/B/C) ? ');
- q:=' ';
- while not (q in ['A','B','C']) do q:=upcase(readkey);
- writeln(q);
- case q of
- 'A' : begin
- writeln('Careful. These data inputs are NOT bullet-proof.');
- write('Enter icon file name : ');
- readln(icon_file_name);
- write('Enter list of icon numbers to use (last should be 0) : ');
- i:=1;
- repeat
- read(ics[i]);
- inc(i);
- until (ics[i-1]=0) or (i>5);
- readln;
- write('Enter icon position number to use for exit : ');
- readln(exit_icon);
- end;
- 'B' : begin
- write('Enter file name with menu parameters : ');
- readln(icon_conf);
- assign(icon_dat,icon_conf);
- {$I-} reset(icon_dat); {$I+}
- if ioresult<>0 then
- begin
- write('No such file. Aborting program. Press any key .. ');
- q:=readkey;
- halt;
- end;
- readln(icon_dat,icon_file_name);
- t:=1;
- repeat
- read(icon_dat, ics[t]);
- write('@',ics[t]);
- inc(t);
- until (t>5) or (ics[t-1]=0);
- readln(icon_dat, exit_icon);
- close(icon_dat);
- end;
- 'C' : begin
- icon_file_name:='icon-dem.dat';
- ics[1]:=8; ics[2]:=1; ics[3]:=10; ics[4]:=20; ics[5]:=0;
- exit_icon:=1;
- end;
- end;
- end;
-
-
- BEGIN
- directvideo:=false;
- {Allows use of normal write/writeln while in graphics.}
-
- input_icon_menu_parameters;
-
- (* This program requires a DRIVERS.TPU file as described in BGI documentation.
- The alternative would be to omit the 'register.. ' statement below, and
- enter the path for the BGI files in the initgraph procedure. *)
-
- if registerBGIdriver(@EGAVGAdriverproc)<0 then
- begin writeln('Must have EGA or VGA graphics.'); exit; end;
- grdriver:=EGA; {if you use VGA, then grmode must be VGAMED.}
- grmode:=EGAHI;
- initgraph(grdriver, grmode, '');
-
- (* CRT must be in either EGA or VGA mode.
- Select desired icon to use, and order in which they will be displayed.
- The programmer must select existing icons in an existing file.
- The number of icons declared to be used must match the number defined.
- The display procedure just paints the icons. *)
-
- display_icons(icon_file_name, {file must exist in path}
- ics, blue, lightgreen);
-
- repeat
-
- (* The use procedure returns the mouse position and button state continuously.
- If left button is pressed when mouse is over icon, icon number is returned,
- else 0 is returned. Programmer can use icon selected, button number, and
- mouse cursor position. When over icon bar, mouse cursor becomes a hand. *)
-
- use_icon_menu(icon_selected, x, y, button);
-
- (* Any other routines, including those that use the mouse can be introduced
- here, and controlled by any or all of the returned values. *)
-
- gotoxy(20,10);
- write('Selected icon, coordinates, & button : ',
- icon_selected,' ',x,' ',y,' ',button,' ');
-
- until icon_selected=exit_icon;
-
- closegraph;
- END.