type
TMyComp = class(TPanel)
ButLeftFast: TRepeatBtn; //bottone '<<'
ButLeft: TRepeatBtn; //" ' <'
ButRight: TRepeatBtn; //" ' >'
ButRightFast: TRepeatBtn; //" '>>'
private
FEnabled : boolean; //Se abilitato o no
FOnClick_ButLeftFast: TNotifyEvent; //Click '<<'
FOnClick_ButLeft: TNotifyEvent; //Click ' <'
FOnClick_ButRight: TNotifyEvent; //Click ' >'
FOnClick_ButRightFast: TNotifyEvent; //Click '>>'
procedure Click_ButLeftFastTrans(Sender : TObject); //Click '<<'
procedure Click_ButLeftTrans(Sender : TObject); //Click ' <'
procedure Click_ButRightTrans(Sender : TObject); //Click ' >'
procedure Click_ButRightFastTrans(Sender : TObject); //Click '>>'
procedure SetCaption_ButLeftFast(newValue: TCaption);//"
function GetCaption_ButLeftFast: TCaption; //"
procedure SetCaption_ButLeft(newValue: TCaption); //Caption 'Set'
function GetCaption_ButLeft: TCaption; //Caption 'Get'
procedure SetCaption_ButRight(newValue: TCaption); //"
function GetCaption_ButRight: TCaption; //"
procedure SetCaption_ButRightFast(newValue: TCaption);//"
function GetCaption_ButRightFast: TCaption; //"
procedure SetButtons;
protected
procedure SetEnabled(newValue : boolean); override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure Resize; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Caption_ButLeftFast: TCaption read GetCaption_ButLeftFast write SetCaption_ButLeftFast;
property Caption_ButLeft: TCaption read GetCaption_ButLeft write SetCaption_ButLeft;
property Caption_ButRight: TCaption read GetCaption_ButRight write SetCaption_ButRight;
property Caption_ButRightFast: TCaption read GetCaption_ButRightFast write SetCaption_ButRightFast;
property OnClick_ButLeftFast: TNotifyEvent read FOnClick_ButLeftFast write FOnClick_ButLeftFast;
property OnClick_ButLeft: TNotifyEvent read FOnClick_ButLeft write FOnClick_ButLeft;
property OnClick_ButRight: TNotifyEvent read FOnClick_ButRight write FOnClick_ButRight;
property OnClick_ButRightFast: TNotifyEvent read FOnClick_ButRightFast write FOnClick_ButRightFast;
property Enabled : boolean read FEnabled write SetEnabled;
end;
procedure Register;
implementation
destructor TMyComp.Destroy;
begin
ButLeft.Free;
ButRight.Free;
ButLeftFast.Free;
ButRightFast.Free;
inherited Destroy;
end;
procedure TMyComp.SetEnabled(newValue : boolean);
begin
inherited;
FEnabled:=newValue;
ButLeft.Enabled:=newValue;
ButRight.Enabled:=newValue;
ButRightFast.Enabled:=newValue;
ButLeftFast.Enabled:=newValue;
end;
procedure TMyComp.Click_ButLeftFastTrans(Sender : TObject);
begin
if Assigned(FOnClick_ButLeftFast) then begin
FOnClick_ButLeftFast(Self);
end;
end;
procedure TMyComp.Click_ButRightFastTrans(Sender : TObject);
begin
if Assigned(FOnClick_ButRightFast) then begin
FOnClick_ButRightFast(Self);
end;
end;
procedure TMyComp.Click_ButLeftTrans(Sender : TObject);
begin
if Assigned(FOnClick_ButLeft) then begin
FOnClick_ButLeft(Self);
end;
end;
procedure TMyComp.Click_ButRightTrans(Sender : TObject);
begin
if Assigned(FOnClick_ButRight) then begin
FOnClick_ButRight(Self);
end;
end;
procedure TMyComp.Resize;
begin
inherited Resize;
SetButtons;
end;
constructor TMyComp.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width:=60;
Height:=18;
ControlStyle:=ControlStyle-[csSetCaption];
with Constraints do begin
minHeight:=18;
minWidth:=60;
end;
TabOrder:=0;
ButLeftFast:=TRepeatBtn.Create(Self);
ButLeftFast.Parent:=Self;
ButLeft:=TRepeatBtn.Create(Self);
ButLeft.Parent:=Self;
ButRight:=TRepeatBtn.Create(Self);
ButRight.Parent:=Self;
ButRightFast:=TRepeatBtn.Create(Self);
ButRightFast.Parent:=Self;
end;
procedure TMyComp.SetCaption_ButLeft(newValue: TCaption);
begin
ButLeft.Caption:=newValue;
end;
function TMyComp.GetCaption_ButLeft: TCaption;
begin
Result:= ButLeft.Caption;
end;
procedure TMyComp.SetCaption_ButLeftFast(newValue: TCaption);
begin
ButLeftFast.Caption:=newValue;
end;
function TMyComp.GetCaption_ButLeftFast: TCaption;
begin
Result:=ButLeftFast.Caption;
end;
procedure TMyComp.SetCaption_ButRight(newValue: TCaption);
begin
ButRight.Caption:=newValue;
end;
function TMyComp.GetCaption_ButRight: TCaption;
begin
Result:= ButRight.Caption;
end;
procedure TMyComp.SetCaption_ButRightFast(newValue: TCaption);
begin
ButRightFast.Caption:=newValue;
end;
function TMyComp.GetCaption_ButRightFast: TCaption;
begin
Result:=ButRightFast.Caption;
end;
procedure TMyComp.SetButtons;
begin
with ButLeftFast do begin
Left:=0;
Top:=0;
Width:=(Self.Width)div(4);
Height:=Self.Height;
TabOrder:=0;
OnClick:=Click_ButLeftFastTrans;
end;
with ButLeft do begin
Left:=(Self.Width)div(4);
Top:=0;
Width:=(Self.Width)div(4);
Height:=Self.Height;
TabOrder:=1;
OnClick:=Click_ButLeftTrans;
end;
with ButRight do begin
Left:=(Self.Width)div(2);
Top:=0;
Width:=(Self.Width)div(4);
Height:=Self.Height;
TabOrder:=2;
OnClick:=Click_ButRightTrans;
end;
with ButRightFast do begin
Left:=3*(Self.Width)div(4);
Top:=0;
Width:=(Self.Width)div(4);
Height:=Self.Height;
TabOrder:=4;
OnClick:=Click_ButRightFastTrans;
end;
end;
procedure TMyComp.CreateWindowHandle(const Params: TCreateParams);
begin
inherited CreateWindowHandle(Params);
SetButtons;
end;
procedure Register;
begin
RegisterComponents('Testing Library',[TMyComp]);
end;
end.