|
unit T_Button;
interface
type
Button=object
private
w,h,bx,by:word;
t_c,b_c:byte;
text:string;
public
constructor Create(x,y:word;testo:string);
destructor Destroy(bk:byte);
procedure change_text(testo:string);
procedure set_color(t,b:byte);
procedure Draw;
function ClickOn:boolean;
function IsOn:boolean;
end;
implementation
uses crt,giobe;
constructor Button.Create;
begin
more;
bx:=x;
by:=y;
text:=testo;
t_c:=15;
b_c:=5;
w:=length(testo);
h:=0;
end;
destructor Button.Destroy;
var i,k:word;
begin
textcolor(bk);
for i:=bx to bx+w do
begin
for k:=by to by+h do
begin
gotoxy(i,k);
write('Û');
end;
end;
end;
procedure button.change_text;
begin
text:=testo;
end;
procedure button.set_color;
begin
t_c:=t;
b_c:=b;
end;
procedure button.draw;
var i,k:word;
begin
textcolor(b_c);
for i:=bx to bx+w do
for k:=by to by+h do
begin
gotoxy(i,k);
write('Û');
end;
gotoxy(bx,by);
textcolor(t_c);
textbackground(b_c);
write(text);
end;
function button.clickon;
begin
if chkclick(bx,bx+w,by)=true then
clickon:=true
else
clickon:=false;
end;
function button.ison;
begin
if ((colmou(false)>=bx) or (colmou(false)<=bx+w)) and (rigmou(false)=by) then
ison:=true
else
ison:=false;
end;
end.
|
|