{SuperGauge - Komponente für Delphi 2-5
 dies ist nur eine Test - Komponente
 by Dipl.-Ing. Thomas Speiser Copyright MMIX

 KKTU Comp [SuperGauge]
 Version 1.0}

unit SuperGauge;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TSuperGauge = class(TGraphicControl)
  private
      FFront, FBackGround, TmpBit: TBitmap;
      FTransBackGround, FTransFront, FAutoSize: Boolean;
      FPosition, X_Pos, Y_Pos, fx: integer;
      procedure SetBackGround(Value: TBitmap);
      procedure SetFront(Value: TBitmap);
      procedure SetPosition(Value: integer);
      procedure SetTransBackGround(Value: Boolean);
      procedure SetTransFront(Value: Boolean);
    { Private-Deklarationen }
  protected
      procedure Paint; override;
      procedure SetAutoSize(Value: Boolean); virtual;
    { Protected-Deklarationen }
  public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
    { Public-Deklarationen }
  published
      property AutoSize: Boolean read FAutoSize write SetAutoSize default False;
      property Align;
      property BackGround: TBitmap read FBackGround write SetBackGround;
      property Front: TBitmap read FFront write SetFront;
      property Position: integer read FPosition write SetPosition;
      property TransBackGround: Boolean read FTransBackground write SetTransBackGround default False;
      property TransFront: Boolean read FTransFront write SetTransFront default False;
      property ShowHint;
      property Visible;
    { Published-Deklarationen }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('KKTU Comp', [TSuperGauge]);
end;

constructor TSuperGauge.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   SetBounds(Left, Top, 76, 17);
   FFront := TBitmap.Create;
   FBackGround := TBitmap.Create;
   TmpBit := TBitmap.Create;
   FAutoSize := False;
   ShowHint := True;
   Width:= 76;
   Height:= 17;
end;

destructor TSuperGauge.Destroy;
begin
   FFront.Free;
   FBackGround.Free;
   TmpBit.Free;
   inherited Destroy;
end;

procedure TSuperGauge.Paint;
begin
{Transparente Schrift}
  Canvas.Brush.Style := bsClear;
 X_Pos := (Width - Canvas.TextWidth(Caption)) div 2;
 Y_Pos := (Height - Canvas.TextHeight(Caption)) div 2;
 Canvas.Font.Color:=clBlack;
 Canvas.TextOut(X_Pos,Y_Pos,Caption);
if FBackGround.Empty = false then begin
 Width:=FBackGround.Width;
 Height:=FBackGround.Height; end;

 FFront.Transparent:=FTransFront;
 FBackGround.Transparent:=FTransBackGround;

 X_Pos := (Width - FBackGround.Width) div 2;
 Y_Pos := (Height - FBackGround.Height) div 2;
 Canvas.Draw(X_Pos,Y_Pos,FBackGround);

{Posberechnung}
fx:=(FPosition * Width) div 100;
TmpBit.Assign(FFront);
TmpBit.Width:=fx;

 X_Pos := (Width - FFront.Width) div 2;
 Y_Pos := (Height - FFront.Height) div 2;
 Canvas.Draw(X_Pos,Y_Pos,TmpBit);
end;

procedure TSuperGauge.SetPosition(Value: integer);
begin
  FPosition:=Value;
  Paint;
end;

procedure TSuperGauge.SetFront(Value: TBitmap);
begin
  FFront.Assign(Value);
  Paint;
end;

procedure TSuperGauge.SetBackGround(Value: TBitmap);
begin
  FBackGround.Assign(Value);
  Paint;
end;

procedure TSuperGauge.SetAutoSize(Value: Boolean);
begin
  FAutoSize:= Value;
  if FAutoSize then
  SetBounds(Left, Top, FBackGround.Width,FBackGround.Height)
end;

procedure TSuperGauge.SetTransBackGround(Value: Boolean);
begin
 FTransBackGround:=Value;
 FBackGround.Transparent:=FTransBackGround;
 Paint;
end;

procedure TSuperGauge.SetTransFront(Value: Boolean);
begin
 FTransFront:=Value;
 FFront.Transparent:=FTransFront;
 Paint;
end;

end.