Skip to content

Instantly share code, notes, and snippets.

Created October 10, 2013 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6917842 to your computer and use it in GitHub Desktop.
Save anonymous/6917842 to your computer and use it in GitHub Desktop.
TPanelTouchInteger Componente delphi para el manejo de número integer en pantallas Táctil
unit MiPanelTouchInteger;
//***************************************************
// JLGT 09/10/2013 Para Integer en pantallas tactil
//***************************************************
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Stdctrls, Windows, Graphics, Math, Forms, Buttons, Dialogs;
type //Creamos los Tipos necesarios
TSeparation = 0..5;
TNumbersDigit = 1..10;
TPanelTouchInteger = class(TPanel)
private
FSpace : TSeparation; //Espacio de separación entre contadores y botones
FValue : String; //Valor que devuelve
FRound : Integer;
FNumberIn : Integer;
FNumbersDigit : TNumbersDigit;
FImagenUp : TPicture;
FImagenDown : TPicture;
FAllTransparent : Boolean;
FOnChange : TNotifyEvent;
FOnButonUpClick : TNotifyEvent;
FOnButtonDownClick : TNotifyEvent;
FColorFondoNumbers : TColor;
//Variables de uso
FN1,FN2,Fn3,FN4,Fn5,Fn6,Fn7,Fn8,fn9,fn10: TLabel; //Corresponden a 88:88:88
Fbutup1,Fbutup2,Fbutup3,Fbutup4,Fbutup5,Fbutup6,Fbutup7,Fbutup8,Fbutup9,Fbutup10:TImage; //Botones para subir
FButDown1,FButDown2,FButDown3,FButDown4,FButDown5,FButDown6,FButDown7,FButDown8,FButDown9,FButDown10: TImage; //Botones para bajar
procedure setSpace(const Value:TSeparation);
procedure setValue(const Value:String);
procedure setNumbersDigit(const value:TNumbersDigit);
procedure setImagenUp(const Value:TPicture);
procedure setImagenDown(const Value:TPicture);
procedure setNumberIn(const Value:Integer);
procedure setAllTransparent(const Value:Boolean);
procedure Change(Sender : TObject); virtual;
procedure setColorFondoNumbers(const Value:TColor);
procedure setRound(const Value:Integer);
protected
{ Protected declarations }
//////////////////////////////////////////////////////////////
procedure Paint();override; //Sobre escribe el pintado del panel
procedure UpClick (Sender: TObject); virtual;
procedure DownClick (Sender: TObject); virtual;
procedure Validar;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
published
property OnButtonUpClick :TNotifyEvent read FOnButonUpClick write FOnButonUpClick;
property OnButtonDownClick :TNotifyEvent read FOnButtonDownClick write FOnButtonDownClick;
property Space :TSeparation read FSpace write SetSpace;
property Value :String read FValue write SetValue;
property ImagenUp :TPicture read FImagenUp write SetImagenUp;
property ImagenDown :TPicture read FImagenDown write SetImagenDown;
property NumberIn :Integer read FNumberIn write setNumberIn;
property AllTransparent :Boolean read FAllTransparent write setAllTransparent;
property OnChange :TNotifyEvent read FOnChange write FOnChange;
property ColorFondoNumbers :TColor read FColorFondoNumbers write SetColorFondoNumbers;
property NumbersDigit :TNumbersDigit read FNumbersDigit write setNumbersDigit;
property Round :Integer read FRound write SetRound;
end;
procedure Register;
var VarCambio:Boolean;
implementation
procedure Register;
begin
RegisterComponents('Touch', [TPanelTouchInteger]);
end;
{ TPanelTouchTime }
Function XCeros(text:string;Cant:integer):string;
var
valor,x:integer;
dev,con:string;
begin
con:='';
valor:=length(text);
if valor<Cant then
begin
for x:=1 to (cant-valor) do
begin
con:=con+'0';
end;
dev:=con+text;
end
else
dev:=text;
result:=dev;
end;
constructor TPanelTouchInteger.Create(AOwner: TComponent);
var Spacelat,SpaceVert:Integer;
begin
inherited;
FSpace :=1;
FValue :='';
FImagenUp :=TPicture.Create;
FImagenDown :=TPicture.Create;
FNumberIn :=0;
VarCambio :=false;
Caption :=' ';
FAllTransparent :=True;
FNumbersDigit :=5;
FColorFondoNumbers :=clBtnFace;
FRound :=40;
Fbutup1 :=TImage.Create(Self);
Spacelat:=11;
SpaceVert:=11;
with Fbutup1 do begin
Parent:=Self;
Left:=Spacelat;
Width:=FRound;
Height:=FRound;
Top:=SpaceVert;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=True;
end;
FN1 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with FN1 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+FRound+FSpace+1; //
Left := Spacelat; ///
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
ParentFont:=False;
Ctl3D:=false;
Alignment:=taCenter;
Layout:=tlCenter;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),1,1); //
Visible:=True;
end;
FButDown1 :=TImage.Create(Self);
with FButDown1 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2; //
Left := Spacelat; ///
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=True;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup2 :=TImage.Create(Self);
with Fbutup2 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=True;
end;
FN2 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn2 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+FRound+FSpace+1; //
Left := Spacelat; ///
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),2,1); //
Visible:=True;
end;
FButDown2 :=TImage.Create(Self);
with FButDown2 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=True;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup3 :=TImage.Create(Self);
with Fbutup3 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=True;
end;
Fn3 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn3 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),3,1); //
Visible:=True;
end;
FButDown3 :=TImage.Create(Self);
with FButDown3 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=True;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup4 :=TImage.Create(Self);
with Fbutup4 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=True;
end;
FN4 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with FN4 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+2;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),4,1); //
Visible:=True;
end;
FButDown4 :=TImage.Create(Self);
with FButDown4 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=True;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup5 :=TImage.Create(Self);
with Fbutup5 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=True;
end;
Fn5 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn5 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),5,1); //
Visible:=True;
end;
FButDown5 :=TImage.Create(Self);
with FButDown5 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=True;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup6 :=TImage.Create(Self);
with Fbutup6 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=False;
end;
Fn6 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn6 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption :='';
Visible:=False;
end;
FButDown6 :=TImage.Create(Self);
with FButDown6 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup7 :=TImage.Create(Self);
with Fbutup7 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=False;
end;
Fn7 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn7 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption :='';
Visible:=False;
end;
FButDown7 :=TImage.Create(Self);
with FButDown7 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup8 :=TImage.Create(Self);
with Fbutup8 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=False;
end;
Fn8 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn8 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption :='';
Visible:=False;
end;
FButDown8 :=TImage.Create(Self);
with FButDown8 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup9 :=TImage.Create(Self);
with Fbutup9 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=False;
end;
Fn9 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn9 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption :='';
Visible:=False;
end;
FButDown9 :=TImage.Create(Self);
with FButDown9 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
Fbutup10 :=TImage.Create(Self);
with Fbutup10 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Picture:=FImagenUp;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=UpClick;
Visible:=False;
end;
Fn10 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente
with Fn10 do begin
Parent := self; //Lo emparentamos al panel
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Font := Self.Font;
ParentColor:=False;
Transparent:=FAllTransparent;
AutoSize:=False;
Alignment:=taCenter;
Layout:=tlCenter;
Caption :='';
Visible:=False;
end;
FButDown10 :=TImage.Create(Self);
with FButDown10 do begin
Parent:=Self;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Picture:=FImagenDown;
Center:=True;
Proportional:=True;
Transparent:=FAllTransparent;
Stretch:=True;
OnClick:=DownClick;
Visible:=False;
end;
end;
procedure TPanelTouchInteger.Change(Sender: TObject);
//------------------------------------------------------------------------------
//*****************************************************************[ Chage ]****
//------------------------------------------------------------------------------
begin
if Assigned(FOnChange) then FOnChange(Sender);
end;
destructor TPanelTouchInteger.Destroy;
begin
FImagenUp.Free;
FImagenDown.Free;
Fn1.Free;
FN2.Free;
Fn3.Free;
FN4.Free;
Fn5.Free;
Fn6.Free;
Fn7.Free;
Fn8.Free;
Fn9.Free;
fn10.Free;
Fbutup1.Free;
Fbutup2.Free;
Fbutup3.Free;
Fbutup4.Free;
Fbutup5.Free;
Fbutup6.Free;
Fbutup7.Free;
Fbutup8.Free;
Fbutup9.Free;
Fbutup10.Free;
FButDown1.Free;
FButDown2.Free;
FButDown3.Free;
FButDown4.Free;
FButDown5.Free;
FButDown6.Free;
FButDown7.Free;
FButDown8.Free;
FButDown9.Free;
FButDown10.Free;
inherited;
end;
function XSoloInteger(cadena:string):Integer;
var VarSCadena,VarSCaracter:String;
VarIContadorFor:Integer;
begin
VarSCadena:='';
for VarIContadorFor := 1 to Length(cadena) do
begin
VarSCaracter:=Copy(cadena,VarIContadorFor,1);
if VarSCaracter='0' then VarSCadena:=VarSCadena+'0';
if VarSCaracter='1' then VarSCadena:=VarSCadena+'1';
if VarSCaracter='2' then VarSCadena:=VarSCadena+'2';
if VarSCaracter='3' then VarSCadena:=VarSCadena+'3';
if VarSCaracter='4' then VarSCadena:=VarSCadena+'4';
if VarSCaracter='5' then VarSCadena:=VarSCadena+'5';
if VarSCaracter='6' then VarSCadena:=VarSCadena+'6';
if VarSCaracter='7' then VarSCadena:=VarSCadena+'7';
if VarSCaracter='8' then VarSCadena:=VarSCadena+'8';
if VarSCaracter='9' then VarSCadena:=VarSCadena+'9';
end;
if VarSCadena='' then VarSCadena:='0';
Result:=StrToInt(VarSCadena);
end;
procedure TPanelTouchInteger.Paint;
//------------------------------------------------------------------------------
//*****************************************************************[ PAINT ]****
//------------------------------------------------------------------------------
var imagen:TImage;
n1,n2,n3,n4,n5,n6,n7,n8,n9,n10:Integer; //posiciones horzontales
a1,a2,a3:Integer; //Altos
SpaceVert,Spacelat:Integer;
ValorNumero:string;
begin
inherited;
if VarCambio=false then
begin
SpaceVert:=11;
Spacelat:=11;
with Fbutup1 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
Visible:=True;
end;
with FN1 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
Visible:=True;
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),1,1); //
end;
with FButDown1 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
Visible:=True;
Caption
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup2 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=2 then Visible:=True else Visible:=False;
end;
with Fn2 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=2 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),2,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown2 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=2 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup3 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=3 then Visible:=True else Visible:=False;
end;
with Fn3 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=3 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),3,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown3 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=3 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup4 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=4 then Visible:=True else Visible:=False;
end;
with Fn4 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=4 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),4,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown4 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=4 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup5 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=5 then Visible:=True else Visible:=False;
end;
with Fn5 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=5 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),5,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown5 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=5 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup6 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=6 then Visible:=True else Visible:=False;
end;
with Fn6 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=6 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),6,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown6 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=6 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup7 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=7 then Visible:=True else Visible:=False;
end;
with Fn7 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=7 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),7,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown7 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=7 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup8 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=8 then Visible:=True else Visible:=False;
end;
with Fn8 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=8 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),8,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown8 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=8 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup9 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=9 then Visible:=True else Visible:=False;
end;
with Fn9 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=9 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),9,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown9 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=9 then Visible:=True else Visible:=False;
end;
Spacelat:=Spacelat+FRound+FSpace+1;
with Fbutup10 do begin
Picture:=FImagenUp;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert;
Left := Spacelat;
if FNumbersDigit>=10 then Visible:=True else Visible:=False;
end;
with Fn10 do begin
Transparent:=FAllTransparent;
Color:=FColorFondoNumbers;
Font:=Self.Font;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound)+(FSpace)+1;
Left := Spacelat;
if FNumbersDigit>=10 then
begin
Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),10,1); //
Visible:=True;
end else
begin
Caption:='';
Visible:=False;
end;
end;
with FButDown10 do begin
Picture:=FImagenDown;
Transparent:=FAllTransparent;
Width:=FRound;
Height:=FRound;
Top := SpaceVert+(FRound*2)+(FSpace*2)+2;
Left := Spacelat;
if FNumbersDigit>=10 then Visible:=True else Visible:=False;
end;
Validar;
Self.Width:=20+(FRound*FNumbersDigit)+(FSpace*FNumbersDigit)+FNumbersDigit;
Self.Height:=SpaceVert+(FRound*3)+(FSpace*2)+12;
VarCambio:=True;
end;
end;
procedure TPanelTouchInteger.setSpace(const Value: TSeparation);
//------------------------------------------------------------------------------
//*****************************************************************[ SPACE ]****
//------------------------------------------------------------------------------
begin
if FSpace<>value then FSpace:=Value;
VarCambio:=False;
Invalidate;
End;
procedure TPanelTouchInteger.SetValue(const Value: String);
//------------------------------------------------------------------------------
//*****************************************************************[ VALUE ]****
//------------------------------------------------------------------------------
begin
if FValue<>value then FValue:=Value;
VarCambio:=False;
Invalidate;
End;
function Numerovalido(Mvalue,tipo:Integer;up:Boolean=True):string;
//------------------------------------------------------------------------------
//**********************************************************[ Numerovalido ]****
//------------------------------------------------------------------------------
begin //0:= para 0-2 (dias) 1:=0..1 (meses) 2:=0..9 (Para el resto)
if up then
begin
case tipo of
0:if Mvalue>=2 then Mvalue:=0 else Mvalue:=Mvalue+1;
1:if Mvalue>=5 then Mvalue:=0 else Mvalue:=Mvalue+1;
2:if Mvalue>=9 then Mvalue:=0 else Mvalue:=Mvalue+1;
end;
end;
if up=false then
begin
case tipo of
0:if Mvalue<=0 then Mvalue:=2 else Mvalue:=Mvalue-1;
1:if Mvalue<=0 then Mvalue:=5 else Mvalue:=Mvalue-1;
2:if Mvalue<=0 then Mvalue:=9 else Mvalue:=Mvalue-1;
end;
end;
Result:=IntToStr(Mvalue);
end;
procedure TPanelTouchInteger.UpClick(Sender: TObject);
//------------------------------------------------------------------------------
//*************************************************************[ UPCLICK ]****
//------------------------------------------------------------------------------
begin
if Sender=Fbutup1 then FN1.Caption:=Numerovalido(StrToInt(FN1.Caption),2);
if Sender=Fbutup2 then FN2.Caption:=Numerovalido(StrToInt(FN2.Caption),2);
if Sender=Fbutup3 then Fn3.Caption:=Numerovalido(StrToInt(Fn3.Caption),2);
if Sender=Fbutup4 then FN4.Caption:=Numerovalido(StrToInt(FN4.Caption),2);
if Sender=Fbutup5 then Fn5.Caption:=Numerovalido(StrToInt(Fn5.Caption),2);
if Sender=Fbutup6 then Fn6.Caption:=Numerovalido(StrToInt(Fn6.Caption),2);
if Sender=Fbutup7 then Fn7.Caption:=Numerovalido(StrToInt(Fn7.Caption),2);
if Sender=Fbutup8 then Fn8.Caption:=Numerovalido(StrToInt(Fn8.Caption),2);
if Sender=Fbutup9 then Fn9.Caption:=Numerovalido(StrToInt(Fn9.Caption),2);
if Sender=Fbutup10 then Fn10.Caption:=Numerovalido(StrToInt(Fn10.Caption),2);
if Assigned(FOnButonUpClick) then FOnButonUpClick(Sender);
Validar;
Change(Self);
end;
procedure TPanelTouchInteger.Validar;
var ValorNumero:string;
begin
case FNumbersDigit of
1:ValorNumero:=fn1.Caption;
2:ValorNumero:=fn1.Caption+fn2.Caption;
3:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption;
4:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption;
5:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption;
6:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption+fn6.Caption;
7:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption+fn6.Caption+fn7.Caption;
8:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption+fn6.Caption+fn7.Caption+fn8.Caption;
9:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption+fn6.Caption+fn7.Caption+fn8.Caption+fn9.Caption;
10:ValorNumero:=fn1.Caption+fn2.Caption+fn3.Caption+fn4.Caption+fn5.Caption+fn6.Caption+fn7.Caption+fn8.Caption+fn9.Caption+fn10.Caption;
end;
FValue:=IntToStr(XSoloInteger(ValorNumero));
end;
procedure TPanelTouchInteger.DownClick(Sender: TObject);
//------------------------------------------------------------------------------
//***********************************************************[ DownClick ]****
//------------------------------------------------------------------------------
begin
if Sender=FButDown1 then FN1.Caption:=Numerovalido(StrToInt(FN1.Caption),2, False);
if Sender=FButDown2 then FN2.Caption:=Numerovalido(StrToInt(FN2.Caption),2, False);
if Sender=FButDown3 then Fn3.Caption:=Numerovalido(StrToInt(Fn3.Caption),2, False);
if Sender=FButDown4 then FN4.Caption:=Numerovalido(StrToInt(FN4.Caption),2, False);
if Sender=FButDown5 then Fn5.Caption:=Numerovalido(StrToInt(Fn5.Caption),2, False);
if Sender=FButDown6 then Fn6.Caption:=Numerovalido(StrToInt(Fn6.Caption),2, False);
if Sender=FButDown7 then Fn7.Caption:=Numerovalido(StrToInt(Fn7.Caption),2, False);
if Sender=FButDown8 then Fn8.Caption:=Numerovalido(StrToInt(Fn8.Caption),2, False);
if Sender=FButDown9 then Fn9.Caption:=Numerovalido(StrToInt(Fn9.Caption),2, False);
if Sender=FButDown10 then Fn10.Caption:=Numerovalido(StrToInt(Fn10.Caption),2, False);
if Assigned(FOnButtonDownClick) then FOnButtonDownClick(Sender);
Validar;
Change(Self);
end;
procedure TPanelTouchInteger.setNumberIn(const Value: Integer);
//------------------------------------------------------------------------------
//****************************************************************[ TimeIn ]****
//------------------------------------------------------------------------------
begin
if FNumberIn<>Value then
begin
FNumberIn:=Value;
if FNumbersDigit>=1 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),1,1); //
if FNumbersDigit>=2 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),2,1); //
if FNumbersDigit>=3 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),3,1); //
if FNumbersDigit>=4 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),4,1); //
if FNumbersDigit>=5 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),5,1); //
if FNumbersDigit>=6 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),6,1); //
if FNumbersDigit>=7 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),7,1); //
if FNumbersDigit>=8 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),8,1); //
if FNumbersDigit>=9 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),9,1); //
if FNumbersDigit>=10 then FN1.Caption := Copy(XCeros(IntToStr(FNumberIn),FNumbersDigit),10,1); //
Validar;
VarCambio:=False;
Invalidate;
end;
end;
procedure TPanelTouchInteger.setNumbersDigit(const value: TNumbersDigit);
//------------------------------------------------------------------------------
//**********************************************************[ NumbersDigit ]****
//------------------------------------------------------------------------------
begin
if FNumbersDigit<>value then FNumbersDigit:=Value;
VarCambio:=False;
Invalidate;
End;
procedure TPanelTouchInteger.SetAllTransparent(const Value: Boolean);
//------------------------------------------------------------------------------
//***********************************************************[ TRANSPARENT ]****
//------------------------------------------------------------------------------
begin
if FAllTransparent<>value then FAllTransparent:=Value;
VarCambio:=False;
Invalidate;
End;
procedure TPanelTouchInteger.SetImagenUp(const Value: TPicture);
//------------------------------------------------------------------------------
//**************************************************************[ IMAGENUP ]****
//------------------------------------------------------------------------------
begin
FImagenUp.Assign(Value);
VarCambio:=False;
Invalidate;
End;
procedure TPanelTouchInteger.SetImagenDown(const Value: TPicture);
//------------------------------------------------------------------------------
//************************************************************[ IMAGENDOWN ]****
//------------------------------------------------------------------------------
begin
FImagenDown.Assign(Value);
VarCambio:=False;
Invalidate;
End;
procedure TPanelTouchInteger.SetColorFondoNumbers(const Value: TColor);
//------------------------------------------------------------------------------
//*****************************************************[ COLORFONDONUMBERS ]****
//------------------------------------------------------------------------------
begin
if FColorFondoNumbers<>value then FColorFondoNumbers:=Value;
VarCambio:=False;
Invalidate
End;
procedure TPanelTouchInteger.SetRound(const Value: Integer);
//------------------------------------------------------------------------------
//*****************************************************************[ ROUND ]****
//------------------------------------------------------------------------------
begin
if FRound<>value then FRound:=Value;
VarCambio:=False;
Invalidate
End;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment