unit SkinButton;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, Buttons, Graphics, Controls;
type TSkinBtn =  class(TSpeedButton)
 private
  FNormalColor, FHighlightColor, FClickColor: TColor;
  FTransparent: Boolean;
  FOnMouseDown: TMouseEvent;
  FOnMouseEnter, FOnMouseLeave: TNotifyEvent;
  protected
   procedure POnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
   procedure POnMouseEnter(Sender: TObject);
   procedure POnMouseLeave(Sender: TObject);
  public
   constructor Create(AOwner: TComponent);
   destructor Destroy;
  published
   property Transparent: Boolean read FTransparent;
   property NormalColor: TColor read FNormalColor write FNormalColor;
   property OnHighlightColor: TColor read FHighlightColor write FHighlightColor;
   property OnClickColor: TColor read FClickColor write FClickColor;
   property OnMouseDown: TMouseEvent read FOnMouseDown;
   property OnMouseEnter: TNotifyEvent read FOnMouseEnter;
   property OnMouseLeave: TNotifyEvent read FOnMouseLeave;
  end;
implementation
constructor TSkinBtn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FNormalColor:= clWhite;
FHighlightColor:= FNormalColor;
FClickColor:= FNormalColor;
FTransparent:= False;
inherited Transparent:= FTransparent;
inherited OnMouseEnter:= POnMouseEnter;
inherited OnMouseDown:= POnMouseDown;
inherited OnMouseLeave:= POnMouseLeave;
end;
destructor TSkinBtn.Destroy;
begin
inherited Destroy;
end;
procedure TSkinBtn.POnMouseEnter(Sender: TObject);
begin
(Sender as TSkinBtn).Color:= FHighlightColor;
inherited OnMouseEnter(Sender);
end;
procedure TSkinBtn.POnMouseLeave(Sender: TObject);
begin
(Sender as TSkinBtn).Color:= FNormalColor;
inherited OnMouseLeave(Sender);
end;
procedure TSkinBtn.POnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
 (Sender as TSkinBtn).Color:= FClickColor;
inherited OnMouseDown(Sender, Button, Shift, X, Y);
end;
end.
