Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Pascal ad Oggetti - T_BUTTON.PAS

T_BUTTON.PAS

Caricato da: Totem
Scarica il programma completo

  1. unit T_Button;
  2.  
  3. interface
  4.  
  5. type
  6.    Button=object
  7.    private
  8.    w,h,bx,by:word;
  9.    t_c,b_c:byte;
  10.    text:string;
  11.  
  12.    public
  13.    constructor Create(x,y:word;testo:string);
  14.    destructor Destroy(bk:byte);
  15.  
  16.    procedure change_text(testo:string);
  17.    procedure set_color(t,b:byte);
  18.    procedure Draw;
  19.    function ClickOn:boolean;
  20.    function IsOn:boolean;
  21. end;
  22.  
  23. implementation
  24. uses crt,giobe;
  25.  
  26. constructor Button.Create;
  27. begin
  28.     more;
  29.     bx:=x;
  30.     by:=y;
  31.     text:=testo;
  32.     t_c:=15;
  33.     b_c:=5;
  34.     w:=length(testo);
  35.     h:=0;
  36. end;
  37.  
  38. destructor Button.Destroy;
  39. var i,k:word;
  40. begin
  41.     textcolor(bk);
  42.     for i:=bx to bx+w do
  43.       begin
  44.       for k:=by to by+h do
  45.         begin
  46.         gotoxy(i,k);
  47.         write('Û');
  48.         end;
  49.       end;
  50. end;
  51.  
  52. procedure button.change_text;
  53. begin
  54.     text:=testo;
  55. end;
  56.  
  57. procedure button.set_color;
  58. begin
  59.     t_c:=t;
  60.     b_c:=b;
  61. end;
  62.  
  63. procedure button.draw;
  64. var i,k:word;
  65. begin
  66.     textcolor(b_c);
  67.     for i:=bx to bx+w do
  68.       for k:=by to by+h do
  69.         begin
  70.         gotoxy(i,k);
  71.         write('Û');
  72.         end;
  73.     gotoxy(bx,by);
  74.     textcolor(t_c);
  75.     textbackground(b_c);
  76.     write(text);
  77. end;
  78.  
  79. function button.clickon;
  80. begin
  81.     if chkclick(bx,bx+w,by)=true then
  82.       clickon:=true
  83.     else
  84.       clickon:=false;
  85. end;
  86.  
  87. function button.ison;
  88. begin
  89.     if ((colmou(false)>=bx) or (colmou(false)<=bx+w)) and (rigmou(false)=by) then
  90.       ison:=true
  91.     else
  92.       ison:=false;
  93. end;
  94.  
  95. end.