|
unit T_Window;
interface
Const Close = 0;
Resiz = 1;
type
point=record
x,y:word;
end;
type
(*Oggetto finestra*)
window=object
private
(*Ascissa, ordinata, larghezza, altezza*)
x,y,w,h:word;
(*Colore del testo, colore della sfondo*)
t_c,b_c:byte;
(*Locazione del pulsante close e resize*)
close_b:point;
resiz_b:point;
(*Testo del titolo e del window caption*)
title:string;
text:string;
public
default_bk_destroy:byte;
(*Crea l'oggetto finestra*)
constructor Create(wx,wy,ww,wh:word;titolo,testo:string);
(*Distrugge l'ggetto finestra*)
destructor Destroy(bk:byte);
(*Cambia le dimensioni*)
procedure change_size(ww,wh:word);
(*Cambia la posizione*)
procedure change_loc(wx,wy:word);
(*Cambia i colori*)
procedure change_col(wc,wb:byte);
(*Disegna la finsetra*)
procedure Draw;
(*Muove la finestra*)
procedure Move;
(*Ingrandisce la finestra*)
procedure Max;
(*Verifica la pressione di un tasto su un pulsante della finestra*)
function ClickOn(option:byte):boolean;
end;
implementation
uses crt,giobe;
constructor window.create;
begin
salva(3);
x:=wx;
y:=wy;
w:=ww;
h:=wh;
t_c:=15;
b_c:=5;
title:=titolo;
text:=testo;
close_b.x:=wx+ww-1;
close_b.y:=wy;
resiz_b.x:=wx+ww-4;
resiz_b.y:=wy;
default_bk_destroy:=0;
end;
destructor window.Destroy;
var i,k:word;
begin
textcolor(bk);
for i:=x to x+w do
for k:=y to y+h do
begin
gotoxy(i,k);
write('Û');
end;
end;
procedure window.change_size;
begin
destroy(default_bk_destroy);
w:=ww;
h:=wh;
close_b.x:=x+w-1;
close_b.y:=y;
resiz_b.x:=x+w-4;
resiz_b.y:=y;
end;
procedure window.change_loc;
begin
destroy(default_bk_destroy);
x:=wx;
y:=wy;
close_b.x:=x+w-1;
resiz_b.x:=x+w-4;
close_b.y:=y;
resiz_b.y:=y;
end;
procedure window.change_col;
begin
t_c:=wc;
b_c:=wb;
end;
procedure window.Draw;
var i,k:word;
begin
(*Sfondo*)
textcolor(b_c);
for i:=x to x+w do
for k:=y to y+h do
begin
gotoxy(i,k);
write('Û');
end;
(*Cornice*)
textcolor(t_c);
textbackground(b_c);
gotoxy(x,y);
write('Ì');
gotoxy(x+w,y);
write('»');
gotoxy(x,y+h);
write('È');
gotoxy(x+w,y+h);
write('¼');
for i:=x+1 to x+w-1 do
begin
gotoxy(i,y);
write('Í');
gotoxy(i,y+h);
write('Í');
end;
for i:=y+1 to y+h-1 do
begin
gotoxy(x,i);
write('º');
gotoxy(x+w,i);
write('º');
end;
(*Titolo*)
gotoxy(x+1,y);
write(title);
(*Pulsanti*)
gotoxy(close_b.x,close_b.y);
write('ž');
gotoxy(resiz_b.x,resiz_b.y);
write('[]');
(*Testo*)
gotoxy(x+1,y+1);
textcolor(t_c);
textbackground(b_c);
write(text);
end;
procedure window.move;
begin
while SinistMou=true do
begin
if (x<>colmou(false)) and (y<>rigmou(false)) then
destroy(default_bk_destroy);
change_loc(colmou(false),rigmou(false));
draw;
end;
end;
procedure window.max;
begin
change_size(80,25);
change_loc(1,1);
end;
function window.ClickOn;
begin
if option=Close then
if chkclick(y,close_b.x,close_b.x) then
clickon:=true
else
clickon:=false
else
if chkclick(y,resiz_b.x,resiz_b.x+1) then
clickon:=true
else
clickon:=false;
end;
end.
|
|