Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

KURSOV~1 / MENUWORK

.PAS
Скачиваний:
3
Добавлен:
16.12.2013
Размер:
6.95 Кб
Скачать
unit MenuWork;
interface
uses Crt, Dos, Mouse,ffile;
type Mc=array[1..9] of string[16];
const Enter=13; Esc=27; Up=72; Down=80; Right=77; Left=75;
F1=59; F2=60; F3=61; F4=62; F5=63; F6=64; F7=65; F8=66; F9=67; F10=68;

s1:mc=(' ” ©« ',' ђҐ¤ Євop ',' ѓа дЁЄa ',' ’Ґбв¤ЁбЄ ',' ‚л室 ','','','', '');
s2:mc=(' ‘®§¤ вм ',' ЋвЄалвм ',' ” ©« а-в  ',' Ћв¬Ґ­  ','','','','','');
s3:mc=(' ‘ва ­  ',' Ќ ж.¤®е®¤ ',' ќЄбЇ®ав ',' €¬Ї®ав ',
' ќЄб-в(%) ',' €¬в/ќЄб ',' ќЄб-в(%) ',' €¬Ї-в(%) ',' Ћв¬Ґ­  ');
s4:mc=(' “Ўлў ­ЁҐ ',' ‚®§а бв ­ЁҐ ',' Ћв¬Ґ­  ','','','','','','');
s5:mc=(' ‘®авЁа®ўЄ  ',' Џа®б¬®ва ',' „®Ў ўЁвм ',' “¤ «Ёвм ',' ‘®еа ­Ёвм ',' Ћв¬Ґ­  ','',
'','');
s6:mc=(' „  ',' ЌҐв ','','','','','','','');
s7:mc=(' ЉагЈ®ў п ',' ‘в®«ЎЁЄ®ў п ','','','','','','','');
s8:mc=(' Ќ ж.¤®е®¤ ',' ќЄбЇ®ав ',' €¬Ї®ав ',
' ќЄб-в(%) ',' €¬в/ќЄб ',' ќЄб-в(%) ',' €¬Ї-в(%) ',' Ћв¬Ґ­  ','');

var Con:boolean;
function GetKey:byte;{‚®§ўа в зЁб«®ў®Ј® §­ зҐ­Ёп ­ ¦ в®© Є« ўЁиЁ}
procedure MakeGorMenu(x0, y0, n:byte; Mas:Mc);{Џ®Ёв஥­ЁҐ Ј®аЁ§®­в «м­®Ј® ¬Ґ­о}
procedure MakeVertMenu(x0, y0, n:byte; Mas:Mc);{‚ҐавЁЄ «м­®Ј®}
procedure Extra(x, y:byte; St:string);
procedure Norma(x, y:byte; St:string);
function PunktGor(x0, y0, N, NomVid:byte; Mas:Mc):byte;{‚лЎ®а Їг­Єв  ¬Ґ­о}
function PunktVert(x0, y0, N, NomVid, NomPunkt:byte; Mas:Mc):byte;{--}
function MouseGor(x1, x2, y1, N:byte; Mas:Mc):byte;{‚лЎ®а Їг­Єв  ¬Ґ­о ¬лиЄ®©}
function MouseVert(x1, y1, y2, N, NomPunkt:byte; Mas:Mc; Con:boolean):byte;

implementation

procedure Timer;
var H, M, S, MS:word;
x, y:byte;
AT:byte;
begin
x:=WhereX;
y:=WhereY;
AT:=$70;
TextAttr:=AT;
GetTime(H, M, S, MS);
Window(1,1,80,25);
GotoXY(74, 25);
Write(H);textcolor(0+128);write(':');textcolor(0);
if M<10 then Write('0',M) else Write(M);
GotoXY(x, y);
AT:=$15;
TextAttr:=AT;
end;

function GetKey:byte;
var Ch:char;
begin
Ch:=readkey;
if Ch=#0 then Ch:=readkey;
GetKey:=Ord(Ch);
end;

procedure MakeGorMenu(x0, y0, n:byte; Mas:Mc);
var x, y, i:byte;
begin
Timer;
Window(1, 1, 80, 25);
textattr:=$70;
for i:=1 to n do
begin
x:=x0+(i-1)*16;
y:=y0;
gotoxy(x, y);
write(mas[i]);
end;
end;

procedure MakeVertMenu(x0, y0, n:byte; Mas:Mc);
var x, y, i:byte;
begin
Timer;
Window(1, 1, 80, 25);
textattr:=$70;
for i:=1 to n do
begin
x:=x0;
y:=y0+(i-1);
gotoxy(x, y);
write(mas[i]);
end;
end;

procedure Extra(x, y:byte; st:string);
begin
textattr:=$20;
gotoxy(x, y);
write(st);
end;

procedure Norma(x, y:byte; St:string);
begin
textattr:=$70;
gotoxy(x, y);
write(st);
end;

function PunktGor(x0, y0, N, NomVid:byte; Mas:Mc):byte;
var Key, Pos:byte;
Choose:boolean;
begin
Timer;
Pos:=NomVid;
NomVid:=NomVid-1;
Extra(NomVid*16+x0, y0, Mas[Pos]);
Choose:=False;
while not(Choose) do begin
Key:=GetKey;
case Key of
Right:begin
Norma(x0+(Pos-1)*16, y0, mas[Pos]);
Pos:=Pos+1;
if Pos=N+1 then Pos:=1;
Extra(x0+(Pos-1)*16, y0, mas[Pos]);
end;
Left:begin
Norma(x0+(Pos-1)*16, y0, mas[Pos]);
Pos:=Pos-1;
if Pos=0 then Pos:=N;
Extra(x0+(Pos-1)*16, y0, mas[Pos]);
end;
Enter:Choose:=True;
f1:begin help;exit;end;
f2:begin save;exit;end;
f3:begin SelectF;exit;end;
f5:begin print;readkey;exit;end;
f10:halt;

end;
end;
PunktGor:=Pos;
end;

function PunktVert(x0, y0, N, NomVid, NomPunkt:byte; Mas:Mc):byte;
var Key, Pos:byte;
Choose:boolean;
begin
Timer;
Pos:=NomVid;
NomVid:=NomVid-1;
Extra(NomVid*16+x0, y0, Mas[Pos]);
Choose:=False;
while not(Choose) do begin
Key:=GetKey;
case Key of
Left:begin
Choose:=True;
Pos:=8;
end;
Right:begin
Choose:=True;
Pos:=9;
end;
Up:begin
norma(16*(NomPunkt-1)+1, 2+(Pos-1), mas[Pos]);
Pos:=Pos-1;
if Pos=0 then Pos:=n;
extra(16*(NomPunkt-1)+1, 2+(Pos-1), mas[Pos]);
end;
Down:begin
norma(16*(NomPunkt-1)+1, 2+(Pos-1), mas[Pos]);
gotoxy(20,10);
Pos:=Pos+1;
if Pos=n+1 then Pos:=1;
gotoxy(20,10);
extra(16*(NomPunkt-1)+1, 2+(Pos-1), mas[Pos]);
end;
Esc:begin
Pos:=13;
Choose:=True;
end;
Enter:Choose:=True;
f1:begin help;exit;end;
f2:begin save;exit;end;
f3:begin SelectF;exit;end;
f5:begin print;readkey;exit;end;
f10:halt;
end;
end;
PunktVert:=Pos;
end;


function MouseGor(x1, x2, y1, N:byte; Mas:Mc):byte;
var Choosed, Console:boolean;
Pole, Vid, x3, y3:byte;
begin
Timer;
Choosed:=False;
Console:=False;
while not Choosed do begin
while not(Click) and not(Console) do begin
X:=(MousePosX div 8) + 1;
Y:=(MousePosY div 8) + 1;
if (Y=y1) and (X>=x1) and (X<=x2) then
begin
y3:=((X-x1+1) div 16) + 1;
x3:=(y3-1)*16+x1;
if Vid<>y3 then begin
MakeGorMenu(x1, y1, N, Mas);
Extra(x3, y1, mas[y3]);
end;
Vid:=y3;
end;
if KeyPressed then Console:=True;
end;
if (Y=y1) and (X>=x1) and (X<=x2) then Choosed:=True;
if Console then Choosed:=True;
end;
if Console then MouseGor:=PunktGor(x1, y1, N, 1, Mas)
else begin
X:=X-1;
Pole:=(X div 16) + 1;
MouseGor:=Pole;
end;
end;

function MouseVert(x1, y1, y2, N, NomPunkt:byte; Mas:Mc; Con:boolean):byte;
var Choosed, Console:boolean;
Pole, Vid, x3, y3:byte;
begin
Extra(x1, y1, Mas[1]);
Timer;
Vid:=0;
Choosed:=False;
Console:=False;
if not(Con) then
begin
while not(Choosed) do
begin
while not(Click) and not(Console) do
begin
X:=(MousePosX div 8) + 1;
Y:=(MousePosY div 8) + 1;
if (Y>=y1) and (Y<=y2) and (X>=x1) and (X<=NomPunkt*16) then
begin
y3:=Y;
if Vid<>y3 then
begin
MakeVertMenu(x1, 2, N, Mas);
Extra(x1, y3, mas[y3-1]);
end;
Vid:=y3;
end;
if KeyPressed then Console:=True;
end;
if (Y>=y1) and (Y<=y2) and (X>=x1) and (X<=NomPunkt*16) then Choosed:=True;
if Console then Choosed:=True;
end;
if Console then MouseVert:=PunktVert(x1, y1, N, 1, NomPunkt, Mas);
if Y>1 then
begin
Pole:=Y-1;
MouseVert:=Pole;
end;
end
else MouseVert:=PunktVert(x1, y1, N, 1, NomPunkt, Mas);
end;

end.
Соседние файлы в папке KURSOV~1