home *** CD-ROM | disk | FTP | other *** search
-
- program GraphicMenuDemo;
- uses tpcrt,
- graph,
- gpmenu,
- gxmenu;
- {frame,header,body,select,key,help}
- const color1 : menucolorarray = ($07, $07, $03, $1E, $0B, $0E);
- frame1 : framearray=#201#200#187#188#205#186;
- frame2 : framearray=#203#200#203#188#205#186;
- frameL : framearray=#255#255#255#255#255#255;
-
- var ch : char;
- main : menu;
- key : menukey;
- f1, f2 : framearray;
- ii, i : integer;
- grdriver, grmode, errcode : integer;
- SolidF : Boolean;
-
- {------------------------------}
- {--- define the menu system ---}
- procedure initmenu(var M:menu);
-
- Begin
- M:= Newmenu([],nil);
- submenu(1,2,1,horizontal,f1,color1,'GDMENU');
- menuitem('Frame',2,1,1,'Select framing mode');
- submenu(2,4,1,vertical,f2,color1,'Mode');
- menuitem('Framed ',1,1,11,'I''ve been framed!');
- menuitem('Plain',2,1,12,'No frames here Boss');
- menuitem('Graph',3,1,13,'Graphics mode');
- menuitem('Text',4,1,14,'Text mode');
- menuitem('Hatch',5,1,15,'Draw hatched background');
- menuitem('Solid',6,1,16,'Draw solid background');
- popsublevel;
- menuitem('Disposition',12,1,2,'What to do');
- submenu(11,4,1,vertical,f2,color1,'Action');
- menuitem('Ignore',1,1,255,'Do nothing');
- menuitem('Exit',2,1,50,'Exit from GMDemo');
- popsublevel;
- popsublevel;
- resetmenu(m);
- end;
-
- {-------------------------------------}
- {misc support procedures}
- function fstr(i:integer):string;
- var stemp:string;
- begin
- str(i,stemp);
- fstr:=stemp;
- end;
-
- procedure DoHatch(C:byte);
- begin
- if GraphOn then
- begin
- SetColor(C);
- if SolidF then
- SetFillStyle(SolidFill,C)
- else
- SetFillStyle(XHatchFill,C);
- bar(0,0,GetMaxX,GetMaxY);
- rectangle(0,0,GetMaxX,GetMaxY);
- end
- else
- begin
- for ii := 1 to 25 do
- begin
- For i := 1 to 79 do
- if SolidF then
- GTWrite(#219, ii, i, C)
- else
- GTWrite(#176, ii, i, C);
- end;
- end;
- GTWrite(' ', 16, 1, 7);
- for i := 1 to 15 do {show all the colors available}
- GTWrite(fstr(i)+' ', 16, (i*2)+1, i);
- end;
-
- {++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
- { Here we go! }
-
- begin
- grdriver := Detect; { init for Borland graphics }
- { grdriver := cga; grmode := cgac2; } {forced overrides}
- { grdriver := hercmono; grmode := hercmonohi; }
-
- initgraph(grdriver, grmode,'');
- Errcode := GraphResult;
- if errcode <> Grok then
- begin
- writeln('Error ',grapherrormsg(errcode),' - Graphic driver not properly installed');
- halt;
- end;
- GraphOn := true; {Mark that we are now in graph mode}
-
- SolidF := false;
- DoHatch(Blue); {put a back drop out there}
-
- {-------------------}
-
- f1 := frame1; {initialize stuff}
- f2 := frame2;
- initmenu(main);
-
- repeat {if menu not visible MenuChoice will draw it first}
- key := menuchoice(main,ch); {pick something from the menu}
- GTWrite('Selection='+fstr(key)+' with keystroke code of '+fstr(ord(ch)),24,1,white);
- {delay 1000}
- erasemenu(main, false);
- if (Key > 10) and (Key < 100) then
- begin
- case Key of
- 11 : begin
- f1 := frame1; {use frames}
- f2 := frame2;
- end;
- 12 : begin
- f1 := frameL; {don't use frames}
- f2 := frameL;
- end;
- 13 : begin
- if not(GraphOn) then {go to graph mode}
- SetGraphMode(grMode);
- GraphOn := true;
- end;
- 14 : begin
- if GraphOn then {go to text mode}
- RestoreCrtMode;
- GraphOn := false;
- end;
- 15 : begin
- SolidF := false;
- DoHatch(Blue); {show a hatched backdrop}
- end;
- 16 : begin
- SolidF := true; {show a solid backdrop}
- DoHatch(Blue);
- end;
- end; {case Key of}
- initmenu(main);
- end;
- until (ch=^M) and (key=50);
-
- {---------------------}
- {That's all folks!}
-
- If GraphOn then
- CloseGraph;
-
- end.
-