unit unitZiffer;
interface
uses
Classes, Graphics, ExtCtrls;
type
{-- Range --}
TValueRange = 0..9;
{-- Class: --}
TCustomZiffer =
class (TCustomPanel)
constructor Create (AOwner: TComponent);
override;
private
FNumerus: TValueRange;
FBarColor: TColor;
FFrameColor: TColor;
procedure SetNumerus(
const Value: TValueRange);
procedure SetBarColor(
const Value: TColor);
procedure SetFrameColor(
const Value: TColor);
protected
procedure Paint;
override;
property Numerus: TValueRange
read FNumerus
write SetNumerus;
property BarColor: TColor
read FBarColor
write SetBarColor;
property FrameColor: TColor
read FFrameColor
write SetFrameColor;
public
end;
{-- Class: --}
TZiffer=
class (TCustomZiffer)
public
published
property Numerus;
property BarColor;
property FrameColor;
// hier kann man weitere Eigenschaften, die man benötigt freigeben
end;
implementation
{ TCustomZiffer }
constructor TCustomZiffer.Create(AOwner: TComponent);
begin
inherited;
FNumerus := 0;
FBarColor := clRed;
FFrameColor := clYellow;
Width := 65;
Height := 105;
end;
procedure TCustomZiffer.Paint;
const
coBars:
array[TValueRange]
of Byte =
($7E,$18,$6D,$3D,$1B,
$37,$77,$1C,$7F,$3F);
coPos:
array[0..6,0..3]
of Integer = ((9,33,48,16),(33,9,16,8),(9,33,8,16),
(33,9,16,48),(33,9,56,48),(9,33,88,16),(33,9,56,8));
var
I,B: Byte;
begin
inherited;
B := 1;
Canvas.Brush.Color := FBarColor;
Canvas.Pen.Color := FFrameColor;
for I := 0
to 6
do
begin
if (B
and coBars[FNumerus])>0
then
begin
Canvas.Rectangle(coPos[I][3],coPos[I][2],
coPos[I][3]+coPos[I][1],
coPos[I][2]+coPos[I][0]);
end;
B := B
shl 1;
end;
end;
procedure TCustomZiffer.SetBarColor(
const Value: TColor);
begin
if Value<>FBarColor
then
begin
FBarColor := Value;
Invalidate;
end;
end;
procedure TCustomZiffer.SetFrameColor(
const Value: TColor);
begin
if FFrameColor<>Value
then
begin
FFrameColor := Value;
Invalidate;
end;
end;
procedure TCustomZiffer.SetNumerus(
const Value: TValueRange);
begin
if Value<>FNumerus
then
begin
FNumerus := Value;
Invalidate;
end;
end;
end.