unit fin_vid;
(**********************) interface (****************************)
TYPE
tipo_cornice=(singola,doppia);
finestra_vid=object
tipo_cor:tipo_cornice;
(*default cornice doppia*)
ombra:boolean;
(*d… ombra alla finestra. default false*)
posX,posY:byte;
(*posizione finestra angolo alto-sinistra; default 1-1*)
righe,lunghezza_stringa_max:byte;
(*exclusa cornice intorno, default 5-20*)
tc_int,tb_int:byte;
(*colore testo e colore sfondo interni, default 15-1/bianco-blu*)
tc_corn,tb_corn:byte;
(*colore testo e sfondo della cornice, default 0-1/nero-blu*)
procedure init;
(*inizializza default*)
procedure dai_corn(corn:tipo_cornice);
procedure dai_ombra;
procedure dai_posiz(x,y:byte);
(*angolo alto-sinistra*)
procedure dai_lunghezza(l:byte);
procedure dai_righe(r:byte);
procedure dai_col_int(tc,tb:byte);
(*interno alla cornice*)
procedure dai_col_corn(tc,tb:byte);
(*colore testo e sfondo della cornice*)
procedure colora;
(*scrive nella memoria video solo i colori, lascia le stringhe*)
procedure fai_cornice;
(*disegna la cornice nella memoria video*)
procedure disegna;
(*disegna tutta la finestra nella memoria video*)
procedure s_st(riga:byte; s:string);
(*scrivi stringa*)
procedure s_st_c(riga:byte;s:string);
(*scrivi stringa centrata*)
end;
finestra_iter=object(finestra_vid)
iterY:byte;
tc_iter,tb_iter:byte;
procedure init;
procedure cambia_iterY(y:byte);
(*cambia l'indice e ridisegna la riga con l'indice(solo colori)*)
procedure cambia_col_iter(tc,tb:byte);
(*cambia colori e ridisegna i colori*)
procedure dai_iterY(y:byte);
procedure dai_col_iter(tc,tb:byte);
procedure colora;
procedure disegna;
end;
(********************) IMPLEMENTATION (********************)
uses mem_vid;
procedure cornice(x1,x2,y1,y2,fg,bg:byte;s1,s2,s3,s4,s5,s6:char);
var
i:byte;
begin
for i:=x1+1 to x2-1 do
begin
fissa_car_col(i,y1,s5,fg,bg);
fissa_car_col(i,y2,s5,fg,bg);
end;
for i:=y1+1 to y2-1 do
begin
fissa_car_col(x1,i,s6,fg,bg);
fissa_car_col(x2,i,s6,fg,bg);
end;
fissa_car_col(x1,y1,s1,fg,bg);
fissa_car_col(x2,y1,s2,fg,bg);
fissa_car_col(x1,y2,s3,fg,bg);
fissa_car_col(x2,y2,s4,fg,bg);
end;
(********************INIZIO OGGETTO FINESTRA_VID**************************)
procedure finestra_vid.init;
begin
ombra:=false;
tipo_cor:=doppia;
lunghezza_stringa_max:=20; righe:=5;
posX:=1; posY:=1;
tc_int:=15; tb_int:=1;
tc_corn:=0; tb_corn:=1;
end;
procedure finestra_vid.dai_corn;
begin
tipo_cor:=corn;
end;
procedure finestra_vid.dai_ombra;
begin
ombra:=true;
end;
procedure finestra_vid.dai_posiz;
begin
posX:=x; posY:=y;
end;
procedure finestra_vid.dai_lunghezza;
begin
lunghezza_stringa_max:=l;
end;
procedure finestra_vid.dai_righe;
begin
righe:=r;
end;
procedure finestra_vid.dai_col_int;
begin
tc_int:=tc;
tb_int:=tb;
end;
procedure finestra_vid.dai_col_corn;
begin
tc_corn:=tc;
tb_corn:=tb;
end;
procedure finestra_vid.colora;
var b:boolean;
begin
if ombra
then b:=((posX+lunghezza_stringa_max+1) >=80)
else b:=((posX+lunghezza_stringa_max+1) >80);
if b then posX:=80-lunghezza_stringa_max-2;
pulisci_att(posX+1,posY+1,posX+lunghezza_stringa_max,posY+righe,tc_int,tb_int);
end;
procedure finestra_vid.fai_cornice;
var b:boolean;
begin
if ombra
then b:=((posX+lunghezza_stringa_max+1) >=80)
else b:=((posX+lunghezza_stringa_max+1) >80);
if b then posX:=80-lunghezza_stringa_max-2;
case tipo_cor of
singola:cornice(posX,posX+lunghezza_stringa_max+1,posY,posY+righe+1,
tc_corn,tb_corn,'Ú','¿','À','Ù','Ä','³');
doppia:cornice(posX,posX+lunghezza_stringa_max+1,posY,posY+righe+1,
tc_corn,tb_corn,'É','»','È','¼','Í','º');
end;
end;
procedure finestra_vid.disegna;
var i:byte;
begin
fai_cornice;
pulisci(posX+1,posY+1,posX+lunghezza_stringa_max,posY+righe,tc_int,tb_int);
if ombra then
begin
for i:=posX+1 to posX+lunghezza_stringa_max+2
do fissa_col_tb(i,posY+righe+2,0);
for i:=posY+1 to posY+righe+2
do fissa_col_tb(posX+lunghezza_stringa_max+2,i,0);
end;
end;
procedure finestra_vid.s_st;
begin
str_vid_car(posX+1,posY+riga,s);
end;
procedure finestra_vid.s_st_c;
var x:byte;
begin
x:=((lunghezza_stringa_max - length(s)) div 2)+1;
str_vid_car(posX+x,posY+riga,s);
end;
(*********************FINE OGGETTO FINESTRA_VID*******************)
(*******************INIZIO OGGETTO FINESTRA_ITER******************)
procedure finestra_iter.init;
begin
inherited init;
iterY:=1;
tc_iter:=15; tb_iter:=0;
end;
procedure finestra_iter.dai_iterY;
begin
iterY:=y;
end;
procedure finestra_iter.cambia_iterY;
begin
str_vid_att(posX+1,posY+iterY,lunghezza_stringa_max-1,tc_int,tb_int);
iterY:=y;
str_vid_att(posX+1,posY+iterY,lunghezza_stringa_max-1,tc_iter,tb_iter);
end;
procedure finestra_iter.dai_col_iter;
begin
tc_iter:=tc; tb_iter:=tb;
end;
procedure finestra_iter.colora;
begin
inherited colora;
str_vid_att(posX+1,posY+iterY,lunghezza_stringa_max-1,tc_iter,tb_iter);
end;
procedure finestra_iter.disegna;
begin
inherited disegna;
str_vid_att(posX+1,posY+iterY,lunghezza_stringa_max-1,tc_iter,tb_iter);
end;
procedure finestra_iter.cambia_col_iter;
begin
dai_col_iter(tc,tb);
str_vid_att(posX+1,posY+iterY,lunghezza_stringa_max-1,tc_iter,tb_iter);
end;
(*****************FINE OGGETTO FINESTRA_ITER*************************)
begin
end.