📄 iledround.pas
字号:
{*******************************************************}
{ }
{ TiLedRound Component }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iLedRound;{$endif}
{$ifdef iCLX}unit QiLedRound;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, iClasses, iLed;{$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions, QiClasses, QiLed;{$ENDIF}
type
TiLedRound = class(TiLed)
private
FShowReflection : Boolean;
FOnAutoSize : TNotifyEvent;
procedure SetShowReflection(const Value: Boolean);
protected
procedure iPaintTo(Canvas: TCanvas); override;
public
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
property OnAutoSize : TNotifyEvent read FOnAutoSize write FOnAutoSize;
published
property ShowReflection : Boolean read FShowReflection write SetShowReflection default True;
property Active;
property ActiveColor;
property BevelStyle;
property BackGroundColor;
property Transparent;
property OnChange;
end;
implementation
//****************************************************************************************************************************************************
constructor TiLedRound.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FShowReflection := True;
end;
//****************************************************************************************************************************************************
procedure TiLedRound.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
if not (csLoading in componentState) then
begin
if AWidth <> Width then
begin
AHeight := AWidth;
AWidth := AWidth;
end
else if AHeight <> Height then
begin
AHeight := AHeight;
AWidth := AHeight;
end;
end;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiLedRound.SetShowReflection(const Value: Boolean);begin SetBooleanProperty(Value,FShowReflection,irtBackGround);end;
//****************************************************************************************************************************************************
procedure TiLedRound.iPaintTo(Canvas: TCanvas);
var
DrawRect : TRect;
begin
with Canvas, DrawRect do
begin
DrawBackGround(Canvas, BackGroundColor);
DrawRect := Rect(0, 0 ,Width, Height);
if Active then
begin
Brush.Color := ActiveColor;
Pen.Color := ActiveColor;
end
else
begin
if AutoInactiveColor then
begin
Brush.Color := DimColor(ActiveColor, 3);
Pen.Color := Brush.Color;
end
else
begin
Brush.Color := InactiveColor;
Pen.Color := Brush.Color;
end
end;
case BevelStyle of
ibsNone : Ellipse(Left, Top, Right, Bottom);
ibsLowered, ibsRaised : Ellipse(Left+2, Top+2, Right-2, Bottom-2);
end;
if FShowReflection then
begin
Pen.Color := clWhite;
Arc(Left+Width div 4, Top+Width div 4, Right-Width div 4, Bottom-Width div 4, Right div 2,Top,Left,Bottom div 2);
Arc(Left+Width div 4+1,Top+Width div 4+1,Right-Width div 4-1,Bottom-Width div 4-1,Right div 2,Top,Left,Bottom div 2);
end;
case BevelStyle of
ibsLowered : begin
Pen.Color := clBtnShadow;
{$ifdef iVCL}
Arc(Left, Top, Right, Bottom, Right, Top, Left, Bottom);
Arc(Left+1, Top+1, Right-1, Bottom-1, Right-1, Top+1, Left+1, Bottom-1);
{$endif}
{$ifdef iCLX}
Arc(Left, Top, Right-Left, Bottom-Top, 45*16, 180*16);
Arc(Left+1, Top+1, Right-Left-2, Bottom-Top-2, 45*16, 180*16);
{$endif}
Pen.Color := clBtnHighlight;
{$ifdef iVCL}
Arc(Left, Top, Right, Bottom, Left, Bottom, Right, Top);
Arc(Left+1, Top+1, Right-1, Bottom-1, Left+1, Bottom-1, Right-1, Top+1);
{$endif}
{$ifdef iCLX}
Arc(Left, Top, Right-Left, Bottom-Top, 225*16, 180*16);
Arc(Left+1, Top+1, Right-Left-2, Bottom-Top-2, 225*16, 180*16);
{$endif}
end;
ibsRaised : begin
Pen.Color := clBtnHighlight;
{$ifdef iVCL}
Arc(Left, Top, Right, Bottom, Right, Top, Left, Bottom);
Arc(Left+1, Top+1, Right-1, Bottom-1, Right-1, Top+1, Left+1, Bottom-1);
{$endif}
{$ifdef iCLX}
Arc(Left, Top, Right-Left, Bottom-Top, 45*16, 180*16);
Arc(Left+1, Top+1, Right-Left-2, Bottom-Top-2, 45*16, 180*16);
{$endif}
Pen.Color := clBtnShadow;
{$ifdef iVCL}
Arc(Left, Top, Right, Bottom, Left, Bottom, Right, Top);
Arc(Left+1, Top+1, Right-1, Bottom-1, Left+1, Bottom-1, Right-1, Top+1);
{$endif}
{$ifdef iCLX}
Arc(Left, Top, Right-Left, Bottom-Top, 225*16, 180*16);
Arc(Left+1, Top+1, Right-Left-2, Bottom-Top-2, 225*16, 180*16);
{$endif}
end;
end;
end;
end;
//****************************************************************************************************************************************************
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -