Created
October 10, 2013 12:44
-
-
Save anonymous/6917736 to your computer and use it in GitHub Desktop.
TPanelTouchDate Componente delphi para el manejo de fechas en pantallas Táctil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit MiPanelTouchDate; | |
//*************************************************** | |
// JLGT 08/10/2013 Para fechas en pantallas tactil | |
//*************************************************** | |
interface | |
uses | |
SysUtils, Classes, Controls, ExtCtrls, Stdctrls, Windows, Graphics, Math, Forms, Buttons, Dialogs; | |
type //Creamos los Tipos necesarios | |
TSeparation = 0..2; | |
TPanelTouchDate = class(TPanel) | |
private | |
FSpace : TSeparation; //Espacio de separación entre contadores y botones | |
FValue : String; //Valor que devuelve | |
FImagenUp : TPicture; | |
FImagenDown : TPicture; | |
FDateIn : TDate; | |
FAllTransparent : Boolean; | |
FValidar : Boolean; | |
FOnDateChange : TNotifyEvent; | |
FOnButonUpClick : TNotifyEvent; | |
FOnButtonDownClick : TNotifyEvent; | |
FColorFondoNumbers : TColor; | |
//Variables de uso | |
FDay1,Fday2,FSeparador1,FMonth1,Fmonth2,Fyear1,Fseparador2,Fyear2,Fyear3,Fyear4: TLabel; //Corresponden a 88/88/8888 | |
Fbutup1,Fbutup2,Fbutup3,Fbutup4,Fbutup5,Fbutup6,Fbutup7,Fbutup8:TImage; //Botones para subir | |
FButDown1,FButDown2,FButDown3,FButDown4,FButDown5,FButDown6,FButDown7,FButDown8: TImage; //Botones para bajar | |
procedure setSpace(const Value:TSeparation); | |
procedure setValue(const Value:String); | |
procedure setImagenUp(const Value:TPicture); | |
procedure setImagenDown(const Value:TPicture); | |
procedure setDateIn(const Value:TDate); | |
procedure setAllTransparent(const Value:Boolean); | |
procedure setValidar(const Value:Boolean); | |
procedure DateChange(Sender : TObject); virtual; | |
procedure setColorFondoNumbers(const Value:TColor); | |
protected | |
{ Protected declarations } | |
////////////////////////////////////////////////////////////// | |
procedure Paint();override; //Sobre escribe el pintado del panel | |
procedure UpClick (Sender: TObject); virtual; | |
procedure DownClick (Sender: TObject); virtual; | |
procedure validarfecha(Fecha:string); | |
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 DateIn :TDate read FDateIn write SetDateIn; | |
property AllTransparent :Boolean read FAllTransparent write setAllTransparent; | |
property Validar :Boolean read FValidar write SetValidar; | |
property OnDateChange :TNotifyEvent read FOnDateChange write FOnDateChange; | |
property ColorFondoNumbers :TColor read FColorFondoNumbers write SetColorFondoNumbers; | |
end; | |
procedure Register; | |
var VarCambio:Boolean; | |
implementation | |
procedure Register; | |
begin | |
RegisterComponents('Touch', [TPanelTouchDate]); | |
end; | |
{ TPanelTouchDate } | |
constructor TPanelTouchDate.Create(AOwner: TComponent); | |
begin | |
inherited; | |
FSpace :=1; | |
FValue :=''; | |
FImagenUp :=TPicture.Create; | |
FImagenDown :=TPicture.Create; | |
Width :=389; | |
Height :=130; | |
FDateIn :=Now; | |
VarCambio :=false; | |
Caption :=' '; | |
FAllTransparent :=True; | |
FValidar :=True; | |
FColorFondoNumbers :=clBtnFace; | |
//-------------------------------------[ D I A S ]--------------------------------- | |
//Días decenas ----------------------------------------------------------- | |
Fbutup1 :=TImage.Create(Self); | |
with Fbutup1 do begin | |
Parent:=Self; | |
Left:=11; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
FDay1 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with FDay1 do begin | |
Parent := self; //Lo emparentamos al panel | |
Width:=35; | |
Height:=35; | |
Top := 47; // | |
Left := 11; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
ParentFont:=False; | |
Ctl3D:=false; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),1,1); // | |
end; | |
FButDown1 :=TImage.Create(Self); | |
with FButDown1 do begin | |
Parent:=Self; | |
Left:=11; | |
Width:=35; | |
Height:=35; | |
Top:=85; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin días decenas | |
//Días unidades ------------------------------------------------------ | |
Fbutup2 :=TImage.Create(Self); | |
with Fbutup2 do begin | |
Parent:=Self; | |
Left:=48; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
FDay2 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with FDay2 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 48; // | |
Width:=35; | |
Height:=35; | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Left := 48; /// | |
Caption := Copy(DateToStr(FDateIn),2,1); // | |
end; | |
FButDown2 :=TImage.Create(Self); | |
with FButDown2 do begin | |
Parent:=Self; | |
Left:=48; | |
Width:=35; | |
Height:=35; | |
Top:=85; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin dias unidades | |
//-------------------------------------[ P R I M E R S E P A R A D O R ]--------------------------------- | |
// primer separador | |
FSeparador1 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with FSeparador1 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 48; // | |
Width:=35; | |
Height:=35; | |
Left :=85 ; /// | |
ParentColor:=False; | |
Font := Self.Font; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),3,1); // | |
end; //-------------------------------------------Fin primer separador | |
//-------------------------------------[ M E S E S ]--------------------------------- | |
//Mes decenas ----------------------------------------------------------- | |
Fbutup3 :=TImage.Create(Self); | |
with Fbutup3 do begin | |
Parent:=Self; | |
Left:=122; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
FMonth1 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with FMonth1 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 48; // | |
Width:=35; | |
Height:=35; | |
Left := 122; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),4,1); // | |
end; | |
FButDown3 :=TImage.Create(Self); | |
with FButDown3 do begin | |
Parent:=Self; | |
Left:=122; | |
Width:=35; | |
Height:=35; | |
Top:=85; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin Mes decenas | |
//Mes unidades ------------------------------------------------------ | |
Fbutup4 :=TImage.Create(Self); | |
with Fbutup4 do begin | |
Parent:=Self; | |
Left:=159; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
Fmonth2 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fmonth2 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 48; // | |
Width:=35; | |
Height:=35; | |
Left := 159; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),5,1); // | |
end; | |
FButDown4 :=TImage.Create(Self); | |
with FButDown4 do begin | |
Parent:=Self; | |
Left:=159; | |
Width:=35; | |
Height:=35; | |
Top:=85; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin dias unidades | |
//-------------------------------------[ S E G U N D O S E P A R A D O R ]--------------------------------- | |
// Segundo separador | |
Fseparador2 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fseparador2 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 48; // | |
Width:=35; | |
Height:=35; | |
Left := 196; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),6,1); // | |
end; //-------------------------------------------Fin segundo separador | |
//-------------------------------------[ A Ñ O S ]--------------------------------- | |
//Año millar ----------------------------------------------------------- | |
Fbutup5 :=TImage.Create(Self); | |
with Fbutup5 do begin | |
Parent:=Self; | |
Left:=233; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
Fyear1 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fyear1 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 47; // | |
Width:=35; | |
Height:=35; | |
Left := 233; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),7,1); // | |
end; | |
FButDown5 :=TImage.Create(Self); | |
with FButDown5 do begin | |
Parent:=Self; | |
Left:=233; | |
Width:=35; | |
Height:=35; | |
Top:=83; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin año millar | |
//Año centena ----------------------------------------------------------- | |
Fbutup6 :=TImage.Create(Self); | |
with Fbutup6 do begin | |
Parent:=Self; | |
Left:=270; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
Fyear2 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fyear2 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 47; // | |
Width:=35; | |
Height:=35; | |
Left := 270; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),8,1); // | |
end; | |
FButDown6 :=TImage.Create(Self); | |
with FButDown6 do begin | |
Parent:=Self; | |
Left:=270; | |
Width:=35; | |
Height:=35; | |
Top:=83; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin año centena | |
//Año decena ----------------------------------------------------------- | |
Fbutup7 :=TImage.Create(Self); | |
with Fbutup7 do begin | |
Parent:=Self; | |
Left:=307; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
Fyear3 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fyear3 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 47; // | |
Width:=35; | |
Height:=35; | |
Left := 307; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),9,1); // | |
end; | |
FButDown7 :=TImage.Create(Self); | |
with FButDown7 do begin | |
Parent:=Self; | |
Left:=307; | |
Width:=35; | |
Height:=35; | |
Top:=83; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin año decena | |
//Año unidad ----------------------------------------------------------- | |
Fbutup8 :=TImage.Create(Self); | |
with Fbutup8 do begin | |
Parent:=Self; | |
Left:=344; | |
Width:=35; | |
Height:=35; | |
Top:=11; | |
Picture:=FImagenUp; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=UpClick; | |
end; | |
Fyear4 :=TLabel.Create(self); //Creamos un label dentro de nuestro componente | |
with Fyear4 do begin | |
Parent := self; //Lo emparentamos al panel | |
Top := 47; // | |
Width:=35; | |
Height:=35; | |
Left := 344; /// | |
Font := Self.Font; | |
ParentColor:=False; | |
Transparent:=FAllTransparent; | |
AutoSize:=False; | |
Alignment:=taCenter; | |
Layout:=tlCenter; | |
Caption := Copy(DateToStr(FDateIn),10,1); // | |
end; | |
FButDown8 :=TImage.Create(Self); | |
with FButDown8 do begin | |
Parent:=Self; | |
Left:=344; | |
Width:=35; | |
Height:=35; | |
Top:=83; | |
Picture:=FImagenDown; | |
Center:=True; | |
Proportional:=True; | |
Transparent:=FAllTransparent; | |
Stretch:=True; | |
OnClick:=DownClick; | |
end; //-------------------------------------------Fin año unidad | |
end; | |
procedure TPanelTouchDate.DateChange(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************************[ OnDateChage ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if Assigned(FOnDateChange) then FOnDateChange(Sender); | |
end; | |
destructor TPanelTouchDate.Destroy; | |
begin | |
FImagenUp.Free; | |
FImagenDown.Free; | |
FDay1.Free; | |
Fday2.Free; | |
FSeparador1.Free; | |
FMonth1.Free; | |
Fmonth2.Free; | |
Fyear1.Free; | |
Fseparador2.Free; | |
Fyear2.Free; | |
Fyear3.Free; | |
Fyear4.Free; | |
Fbutup1.Free; | |
Fbutup2.Free; | |
Fbutup3.Free; | |
Fbutup4.Free; | |
Fbutup5.Free; | |
Fbutup6.Free; | |
Fbutup7.Free; | |
Fbutup8.Free; | |
FButDown1.Free; | |
FButDown2.Free; | |
FButDown3.Free; | |
FButDown4.Free; | |
FButDown5.Free; | |
FButDown6.Free; | |
FButDown7.Free; | |
FButDown8.Free; | |
inherited; | |
end; | |
procedure TPanelTouchDate.Paint; | |
//------------------------------------------------------------------------------ | |
//*****************************************************************[ PAINT ]**** | |
//------------------------------------------------------------------------------ | |
var imagen:TImage; | |
dd,du,s1,md,mu,s2,am,ac,ad,au:Integer; //posiciones horzontales | |
a1,a2,a3:Integer; //Altos | |
ElCaption:string; | |
begin | |
inherited; | |
if VarCambio=false then | |
begin | |
dd:=11; | |
a1:=11; | |
case Space of | |
0:begin | |
du:=47; | |
s1:=83; | |
md:=119; | |
mu:=155; | |
s2:=191; | |
am:=227; | |
ac:=263; | |
ad:=299; | |
au:=335; | |
a2:=47; | |
a3:=83; | |
Width:=379; | |
Height:=128; | |
end; | |
1:begin | |
du:=48; | |
s1:=85; | |
md:=122; | |
mu:=159; | |
s2:=196; | |
am:=233; | |
ac:=270; | |
ad:=307; | |
au:=344; | |
a2:=48; | |
a3:=85; | |
Width:=389; | |
Height:=130; | |
end; | |
2:begin | |
du:=49; | |
s1:=87; | |
md:=125; | |
mu:=163; | |
s2:=201; | |
am:=239; | |
ac:=277; | |
ad:=315; | |
au:=353; | |
a2:=49; | |
a3:=87; | |
Width:=398; | |
Height:=132; | |
end; | |
end; | |
with Fbutup1 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=dd | |
end; | |
with FDay1 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=dd; | |
end; | |
with FButDown1 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=dd | |
end; | |
with Fbutup2 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=du | |
end; | |
with FDay2 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=du; | |
end; | |
with FButDown2 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=du | |
end; | |
with FSeparador1 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=s1; | |
end; | |
with Fbutup3 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=md; | |
end; | |
with FMonth1 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=md; | |
end; | |
with FButDown3 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=md; | |
end; | |
with Fbutup4 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=mu; | |
end; | |
with FMonth2 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=mu; | |
end; | |
with FButDown4 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=mu; | |
end; | |
with FSeparador2 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=s2; | |
end; | |
with Fbutup5 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=am; | |
end; | |
with Fyear1 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=am; | |
end; | |
with FButDown5 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=am; | |
end; | |
with Fbutup6 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=ac; | |
end; | |
with Fyear2 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=ac; | |
end; | |
with FButDown6 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=ac; | |
end; | |
with Fbutup7 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=ad; | |
end; | |
with Fyear3 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=ad; | |
end; | |
with FButDown7 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=ad; | |
end; | |
with Fbutup8 do begin | |
Picture:=FImagenUp; | |
Transparent:=FAllTransparent; | |
Top:=a1; | |
Left:=au; | |
end; | |
with Fyear4 do begin | |
Transparent:=FAllTransparent; | |
Color:=FColorFondoNumbers; | |
Font:=Self.Font; | |
Top:=a2; | |
Left:=au; | |
end; | |
with FButDown8 do begin | |
Picture:=FImagenDown; | |
Transparent:=FAllTransparent; | |
Top:=a3; | |
Left:=au; | |
end; | |
VarCambio:=True; | |
end; | |
end; | |
procedure TPanelTouchDate.setSpace(const Value: TSeparation); | |
//------------------------------------------------------------------------------ | |
//*****************************************************************[ SPACE ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if FSpace<>value then FSpace:=Value; | |
VarCambio:=False; | |
Invalidate; | |
End; | |
procedure TPanelTouchDate.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-3 (dias) 1:=0..1 (meses) 2:=0..9 (Para el resto) | |
if up then | |
begin | |
case tipo of | |
0:if Mvalue>=3 then Mvalue:=0 else Mvalue:=Mvalue+1; | |
1:if Mvalue>=1 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:=3 else Mvalue:=Mvalue-1; | |
1:if Mvalue<=0 then Mvalue:=1 else Mvalue:=Mvalue-1; | |
2:if Mvalue<=0 then Mvalue:=9 else Mvalue:=Mvalue-1; | |
end; | |
end; | |
Result:=IntToStr(Mvalue); | |
end; | |
procedure TPanelTouchDate.UpClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************************[ UPCLICK ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if Sender=Fbutup1 then FDay1.Caption:=Numerovalido(StrToInt(FDay1.Caption),0); | |
if Sender=Fbutup2 then FDay2.Caption:=Numerovalido(StrToInt(FDay2.Caption),2); | |
if Sender=Fbutup3 then FMonth1.Caption:=Numerovalido(StrToInt(FMonth1.Caption),1); | |
if Sender=Fbutup4 then Fmonth2.Caption:=Numerovalido(StrToInt(Fmonth2.Caption),2); | |
if Sender=Fbutup5 then Fyear1.Caption:=Numerovalido(StrToInt(Fyear1.Caption),2); | |
if Sender=Fbutup6 then Fyear2.Caption:=Numerovalido(StrToInt(Fyear2.Caption),2); | |
if Sender=Fbutup7 then Fyear3.Caption:=Numerovalido(StrToInt(Fyear3.Caption),2); | |
if Sender=Fbutup8 then Fyear4.Caption:=Numerovalido(StrToInt(Fyear4.Caption),2); | |
validarfecha(FDay1.Caption+Fday2.Caption+FSeparador1.Caption+ | |
FMonth1.Caption+Fmonth2.Caption+Fseparador2.Caption+ | |
Fyear1.Caption+Fyear2.Caption+Fyear3.Caption+Fyear4.Caption); | |
if Assigned(FOnButonUpClick) then FOnButonUpClick(Sender); | |
end; | |
procedure TPanelTouchDate.validarfecha(Fecha: string); | |
//------------------------------------------------------------------------------ | |
//**********************************************************[ validarfecha ]**** | |
//------------------------------------------------------------------------------ | |
var xFecha:TDate; | |
begin | |
if FValidar then | |
begin | |
try | |
xFecha:=StrToDate(fecha); | |
FValue:=DateToStr(xFecha); | |
DateChange(Self); | |
except | |
Case Application.MessageBox(pchar( 'La fecha introducida no es valida'+#13#10 | |
+#13#10+'¿Desea usar la fecha actual?' +#13#10),pchar('Fecha no valida'),4+16+0)of | |
6:begin | |
FValue:=DateToStr(Now); //Si | |
FDay1.Caption:=Copy(DateToStr(now),1,1); | |
Fday2.Caption:=Copy(DateToStr(now),2,1); | |
FSeparador1.Caption:=Copy(DateToStr(now),3,1); | |
FMonth1.Caption:=Copy(DateToStr(now),4,1); | |
Fmonth2.Caption:=Copy(DateToStr(now),5,1); | |
Fseparador2.Caption:=Copy(DateToStr(now),6,1); | |
Fyear1.Caption:=Copy(DateToStr(now),7,1); | |
Fyear2.Caption:=Copy(DateToStr(now),8,1); | |
Fyear3.Caption:=Copy(DateToStr(now),9,1); | |
Fyear4.Caption:=Copy(DateToStr(now),10,1); | |
DateChange(Self); | |
end; | |
end; | |
end; | |
end else DateChange(Self); | |
end; | |
procedure TPanelTouchDate.DownClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************************[ DownClick ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if Sender=FButDown1 then FDay1.Caption:=Numerovalido(StrToInt(FDay1.Caption),0, False); | |
if Sender=FButDown2 then FDay2.Caption:=Numerovalido(StrToInt(FDay2.Caption),2, False); | |
if Sender=FButDown3 then FMonth1.Caption:=Numerovalido(StrToInt(FMonth1.Caption),1, False); | |
if Sender=FButDown4 then Fmonth2.Caption:=Numerovalido(StrToInt(Fmonth2.Caption),2, False); | |
if Sender=FButDown5 then Fyear1.Caption:=Numerovalido(StrToInt(Fyear1.Caption),2, False); | |
if Sender=FButDown6 then Fyear2.Caption:=Numerovalido(StrToInt(Fyear2.Caption),2, False); | |
if Sender=FButDown7 then Fyear3.Caption:=Numerovalido(StrToInt(Fyear3.Caption),2, False); | |
if Sender=FButDown8 then Fyear4.Caption:=Numerovalido(StrToInt(Fyear4.Caption),2, False); | |
validarfecha(FDay1.Caption+Fday2.Caption+FSeparador1.Caption+ | |
FMonth1.Caption+Fmonth2.Caption+Fseparador2.Caption+ | |
Fyear1.Caption+Fyear2.Caption+Fyear3.Caption+Fyear4.Caption); | |
if Assigned(FOnButtonDownClick) then FOnButtonDownClick(Sender); | |
end; | |
procedure TPanelTouchDate.setDateIn(const Value: TDate); | |
//------------------------------------------------------------------------------ | |
//****************************************************************[ DateIn ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if FDateIn<>Value then | |
begin | |
FDateIn:=Value; | |
FDay1.Caption:=Copy(DateToStr(FDateIn),1,1); | |
Fday2.Caption:=Copy(DateToStr(FDateIn),2,1); | |
FSeparador1.Caption:=Copy(DateToStr(FDateIn),3,1); | |
FMonth1.Caption:=Copy(DateToStr(FDateIn),4,1); | |
Fmonth2.Caption:=Copy(DateToStr(FDateIn),5,1); | |
Fseparador2.Caption:=Copy(DateToStr(FDateIn),6,1); | |
Fyear1.Caption:=Copy(DateToStr(FDateIn),7,1); | |
Fyear2.Caption:=Copy(DateToStr(FDateIn),8,1); | |
Fyear3.Caption:=Copy(DateToStr(FDateIn),9,1); | |
Fyear4.Caption:=Copy(DateToStr(FDateIn),10,1); | |
validarfecha(FDay1.Caption+Fday2.Caption+FSeparador1.Caption+ | |
FMonth1.Caption+Fmonth2.Caption+Fseparador2.Caption+ | |
Fyear1.Caption+Fyear2.Caption+Fyear3.Caption+Fyear4.Caption); | |
VarCambio:=False; | |
Invalidate; | |
end; | |
end; | |
procedure TPanelTouchDate.SetAllTransparent(const Value: Boolean); | |
//------------------------------------------------------------------------------ | |
//***********************************************************[ TRANSPARENT ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if FAllTransparent<>value then FAllTransparent:=Value; | |
VarCambio:=False; | |
Invalidate; | |
End; | |
procedure TPanelTouchDate.SetImagenUp(const Value: TPicture); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ IMAGENUP ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
FImagenUp.Assign(Value); | |
VarCambio:=False; | |
Invalidate; | |
End; | |
procedure TPanelTouchDate.SetImagenDown(const Value: TPicture); | |
//------------------------------------------------------------------------------ | |
//************************************************************[ IMAGENDOWN ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
FImagenDown.Assign(Value); | |
VarCambio:=False; | |
Invalidate; | |
End; | |
procedure TPanelTouchDate.SetValidar(const Value: Boolean); | |
//------------------------------------------------------------------------------ | |
//***************************************************************[ VALIDAR ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if FValidar<>value then FValidar:=Value; | |
VarCambio:=False; | |
Invalidate; | |
End; | |
procedure TPanelTouchDate.SetColorFondoNumbers(const Value: TColor); | |
//------------------------------------------------------------------------------ | |
//*****************************************************************[ COLORFONDONUMBERS ]**** | |
// | |
//------------------------------------------------------------------------------ | |
begin | |
if FColorFondoNumbers<>value then FColorFondoNumbers:=Value; | |
VarCambio:=False; | |
Invalidate | |
End; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment