unit ButtonA;

interface

uses
  ButtonBase, Classes, LCLIntf, LCLType, ScreenTools, Types,
  {$IFDEF DPI}Dpi.Graphics{$ELSE}Graphics{$ENDIF};

type
  TButtonA = class(TButtonBase)
    constructor Create(AOwner: TComponent); override;
  private
    FCaption: string;
    procedure SetFont(const Font: TFont);
  protected
    procedure SetCaption(Text: string);
    procedure Paint; override;
  public
    property Font: TFont write SetFont;
  published
    property Visible;
    property Caption: string read FCaption write SetCaption;
    property OnClick;
  end;

procedure Register;


implementation

procedure Register;
begin
  RegisterComponents('C-evo', [TButtonA]);
end;

constructor TButtonA.Create(AOwner: TComponent);
begin
  inherited;
  FCaption := '';
  SetBounds(0, 0, 100, 25);
end;

procedure TButtonA.Paint;
var
  TextSize: TSize;
begin
  with Canvas do
    if FGraphic <> nil then begin
      BitBltCanvas(Canvas, 0, 0, 100, 25, Graphic.Canvas, 195,
        243 + 26 * Byte(Down));
      Canvas.Brush.Style := TBrushStyle.bsClear;
      TextSize := TextExtent(FCaption);
      TextOut(50 - (TextSize.Width + 1) div 2,
        12 - TextSize.Height div 2, FCaption);
    end else begin
      Brush.Color := $0000FF;
      FrameRect(Rect(0, 0, 100, 25));
    end;
end;

procedure TButtonA.SetCaption(Text: string);
begin
  if Text <> FCaption then begin
    FCaption := Text;
    Invalidate;
  end;
end;

procedure TButtonA.SetFont(const Font: TFont);
begin
  Canvas.Font.Assign(Font);
  Canvas.Font.Color := $000000;
end;

end.
