📄 iangularloggauge.pas
字号:
{*******************************************************}
{ }
{ TiAngularLogGauge Component }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iAngularLogGauge;{$endif}
{$ifdef iCLX}unit QiAngularLogGauge;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, iMath, iGaugeComponent, iGaugePointer;{$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions, QiMath, QiGaugeComponent, QiGaugePointer;{$ENDIF}
type
TiAngularLogGauge = class(TiGaugeComponent)
private
FArcRangeDegrees : Integer;
FArcRadius : Integer;
FArcStartDegrees : Integer;
FPointerStyle : TiAngularGaugePointerStyle;
FShowInnerArcRadius : Boolean;
FPointerSize : Integer;
FShowHub : Boolean;
FHubSize : Integer;
FHubColor : TColor;
FShowOuterArcRadius : Boolean;
FMinMaxPointerStyle : TiAngularGaugePointerStyle;
FShowLabel2 : Boolean;
FShowLabel1 : Boolean;
FLabel1OffsetX : Integer;
FLabel2OffsetY : Integer;
FLabel1OffsetY : Integer;
FLabel2OffsetX : Integer;
FLabel2Text : String;
FLabel1Text : String;
FLabel1Font : TFont;
FLabel2Font : TFont;
FLabel1AlignHorizontal : TiAlignmentHorizontal;
FLabel2AlignHorizontal : TiAlignmentHorizontal;
FLabel1AlignVertical : TiAlignmentVertical;
FLabel2AlignVertical : TiAlignmentVertical;
FTickLabelStyle : TiLogLabelStyle;
FMouseDownX : Integer;
FMouseDownY : Integer;
FMouseDownDegrees : Double;
FOldCurrentValue : Double;
FCenterPoint : TPoint;
FMinPointer : TiGaugePointer;
FMaxPointer : TiGaugePointer;
procedure SetArcRadius (const Value: Integer);
procedure SetArcRangeDegrees (const Value: Integer);
procedure SetArcStartDegrees (const Value: Integer);
procedure SetPointerMargin (const Value: Integer);
procedure SetPointerStyle (const Value: TiAngularGaugePointerStyle);
procedure SetMinMaxPointerStyle (const Value: TiAngularGaugePointerStyle);
procedure SetShowInnerArcRadius (const Value: Boolean);
procedure SetPointerColor (const Value: TColor);
procedure SetPointerSize (const Value: Integer);
procedure SetHubSize (const Value: Integer);
procedure SetShowHub (const Value: Boolean);
procedure SetShowOuterArcRadius (const Value: Boolean);
procedure SetLabel1Text (const Value: String);
procedure SetLabel1AlignHorizontal(const Value: TiAlignmentHorizontal);
procedure SetLabel1AlignVertical (const Value: TiAlignmentVertical);
procedure SetLabel1OffsetX (const Value: Integer);
procedure SetLabel1OffsetY (const Value: Integer);
procedure SetLabel1Font (const Value: TFont);
procedure SetLabel2Text (const Value: String);
procedure SetLabel2AlignHorizontal(const Value: TiAlignmentHorizontal);
procedure SetLabel2AlignVertical (const Value: TiAlignmentVertical);
procedure SetLabel2OffsetX (const Value: Integer);
procedure SetLabel2OffsetY (const Value: Integer);
procedure SetLabel2Font (const Value: TFont);
procedure SetShowLabel1 (const Value: Boolean);
procedure SetShowLabel2 (const Value: Boolean);
procedure SetTickLabelStyle (const Value: TiLogLabelStyle);
procedure SetHubColor (const Value: TColor);
function GetPointerColor : TColor;
function GetPointerMargin: Integer;
function GetPointerSize : Integer;
function GetPointerStyle : TiAngularGaugePointerStyle;
protected
procedure SetPositionMin(const Value : Double); override;
function GetCenterPoint(Canvas: TCanvas): TPoint; override;
procedure DrawTicks (Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawSections (Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawArcRadius(Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawIndicator(Canvas: TCanvas; const OffsetPoint: TPoint; APointer: TiGaugePointer);
procedure DrawHub (Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawMinMax (Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawLimits (Canvas: TCanvas; const OffsetPoint: TPoint);
procedure DrawLabels (Canvas: TCanvas; const CenterPoint: TPoint);
procedure iPaintTo(Canvas: TCanvas); override;
procedure iMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure iMouseUp (Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure iMouseMove( Shift: TShiftState; X, Y: Integer); override;
procedure InitializePointer(iGaugePointer : TiGaugePointer); override;
function PositionToDegrees(Value: Double): Double;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetPointersMargin(Index: Integer): Integer;
function GetPointersStyle (Index: Integer): TiAngularGaugePointerStyle;
procedure SetPointersMargin(Index: Integer; Value: Integer);
procedure SetPointersStyle(Index: Integer; Value: TiAngularGaugePointerStyle);
published
property ArcRadius : Integer read FArcRadius write SetArcRadius default 60;
property ArcRangeDegrees : Integer read FArcRangeDegrees write SetArcRangeDegrees default 90;
property ArcStartDegrees : Integer read FArcStartDegrees write SetArcStartDegrees default 180;
property Label1Text : String read FLabel1Text write SetLabel1Text;
property Label1Font : TFont read FLabel1Font write SetLabel1Font;
property Label1AlignVertical : TiAlignmentVertical read FLabel1AlignVertical write SetLabel1AlignVertical default iavCenter;
property Label1AlignHorizontal : TiAlignmentHorizontal read FLabel1AlignHorizontal write SetLabel1AlignHorizontal default iahCenter;
property Label1OffsetX : Integer read FLabel1OffsetX write SetLabel1OffsetX default -15;
property Label1OffsetY : Integer read FLabel1OffsetY write SetLabel1OffsetY default -35;
property Label2Text : String read FLabel2Text write SetLabel2Text;
property Label2Font : TFont read FLabel2Font write SetLabel2Font;
property Label2AlignVertical : TiAlignmentVertical read FLabel2AlignVertical write SetLabel2AlignVertical default iavCenter;
property Label2AlignHorizontal : TiAlignmentHorizontal read FLabel2AlignHorizontal write SetLabel2AlignHorizontal default iahCenter;
property Label2OffsetX : Integer read FLabel2OffsetX write SetLabel2OffsetX default -15;
property Label2OffsetY : Integer read FLabel2OffsetY write SetLabel2OffsetY default -25;
property HubSize : Integer read FHubSize write SetHubSize default 14;
property HubColor : TColor read FHubColor write SetHubColor default clBlack;
property MinMaxPointerStyle : TiAngularGaugePointerStyle read FMinMaxPointerStyle write SetMinMaxPointerStyle default iagpsArrowLine;
property PointerMargin : Integer read GetPointerMargin write SetPointerMargin default 0;
property PointerColor : TColor read GetPointerColor write SetPointerColor default clBlack;
property PointerSize : Integer read GetPointerSize write SetPointerSize default 10;
property PointerStyle : TiAngularGaugePointerStyle read GetPointerStyle write SetPointerStyle default iagpsTriangle;
property ShowInnerArcRadius : Boolean read FShowInnerArcRadius write SetShowInnerArcRadius default False;
property ShowOuterArcRadius : Boolean read FShowOuterArcRadius write SetShowOuterArcRadius default False;
property ShowHub : Boolean read FShowHub write SetShowHub default True;
property ShowLabel1 : Boolean read FShowLabel1 write SetShowLabel1 default False;
property ShowLabel2 : Boolean read FShowLabel2 write SetShowLabel2 default False;
property TickLabelStyle : TiLogLabelStyle read FTickLabelStyle write SetTickLabelStyle default illsValue;
property OffsetX;
property OffsetY;
property BackGroundColor;
property BorderStyle;
property BackGroundPicture;
property CachedDrawing;
property Transparent;
property TickMajorColor;
property TickMajorLength;
property TickMinorAlignment;
property TickMinorColor;
property TickMinorLength;
property TickMargin;
property TickLabelMargin default 15;
property TickLabelFont;
property TickLabelPrecision;
property OnCustomizeTickLabel;
property SectionColor1;
property SectionColor2;
property SectionColor3;
property SectionColor4;
property SectionColor5;
property SectionCount;
property SectionEnd1;
property SectionEnd2;
property SectionEnd3;
property SectionEnd4;
property ShowMaxPointer;
property ShowMinPointer;
property MinMaxPointerSize;
property MinMaxPointerMargin;
property MaxPointerColor;
property MinPointerColor;
property MinMaxUserCanMove;
end;
implementation
//****************************************************************************************************************************************************
constructor TiAngularLogGauge.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 150;
Height := 150;
TickLabelMargin := 15;
PositionMin := 1;
FArcRadius := 60;
FArcRangeDegrees := 90;
FArcStartDegrees := 180;
FPointerSize := 10;
FPointerStyle := iagpsTriangle;
FShowHub := True;
FHubSize := 14;
FLabel1OffsetX := -15;
FLabel1OffsetY := -35;
FLabel2OffsetX := -15;
FLabel2OffsetY := -20;
FLabel1Font := TFont.Create; FLabel1Font.OnChange := BackGroundChangeEvent;
FLabel2Font := TFont.Create; FLabel2Font.OnChange := BackGroundChangeEvent;
FMinPointer := TiGaugePointer.Create(nil);
FMaxPointer := TiGaugePointer.Create(nil);
CreateBackGroundPicture;
end;
//****************************************************************************************************************************************************
destructor TiAngularLogGauge.Destroy;
begin
FMinPointer.Free;
FMaxPointer.Free;
FLabel1Font.Free;
FLabel2Font.Free;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetArcRadius (const Value:Integer);begin SetIntegerProperty(Value,FArcRadius, irtBackGround);end;
procedure TiAngularLogGauge.SetArcStartDegrees (const Value:Integer);begin SetIntegerProperty(Value,FArcStartDegrees, irtBackGround);end;
procedure TiAngularLogGauge.SetShowInnerArcRadius(const Value:Boolean);begin SetBooleanProperty(Value,FShowInnerArcRadius,irtBackGround);end;
procedure TiAngularLogGauge.SetShowOuterArcRadius(const Value:Boolean);begin SetBooleanProperty(Value,FShowOuterArcRadius,irtBackGround);end;
procedure TiAngularLogGauge.SetHubSize (const Value:Integer);begin SetIntegerProperty(Value,FHubSize, irtBackGround);end;
procedure TiAngularLogGauge.SetHubColor (const Value:TColor); begin SetColorProperty (Value,FHubColor, irtBackGround);end;
procedure TiAngularLogGauge.SetShowHub (const Value:Boolean);begin SetBooleanProperty(Value,FShowHub, irtBackGround);end;
procedure TiAngularLogGauge.SetShowLabel1 (const Value:Boolean);begin SetBooleanProperty(Value,FShowLabel1, irtBackGround);end;
procedure TiAngularLogGauge.SetShowLabel2 (const Value:Boolean);begin SetBooleanProperty(Value,FShowLabel2, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel1Text (const Value:String); begin SetStringProperty (Value,FLabel1Text, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel1OffsetX (const Value:Integer);begin SetIntegerProperty(Value,FLabel1OffsetX, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel1OffsetY (const Value:Integer);begin SetIntegerProperty(Value,FLabel1OffsetY, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel2Text (const Value:String); begin SetStringProperty (Value,FLabel2Text, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel2OffsetX (const Value:Integer);begin SetIntegerProperty(Value,FLabel2OffsetX, irtBackGround);end;
procedure TiAngularLogGauge.SetLabel2OffsetY (const Value:Integer);begin SetIntegerProperty(Value,FLabel2OffsetY, irtBackGround);end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetLabel1Font (const Value:TFont); begin FLabel1Font.Assign(Value); end;
procedure TiAngularLogGauge.SetLabel2Font (const Value:TFont); begin FLabel2Font.Assign(Value); end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetMinMaxPointerStyle(const Value: TiAngularGaugePointerStyle);
begin
if FMinMaxPointerStyle <> Value then
begin
FMinMaxPointerStyle := Value;
BackGroundChange;
end;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetLabel1AlignHorizontal(const Value: TiAlignmentHorizontal);
begin
if FLabel1AlignHorizontal <> Value then
begin
FLabel1AlignHorizontal := Value;
BackGroundChange;
end;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetLabel1AlignVertical(const Value: TiAlignmentVertical);
begin
if FLabel1AlignVertical <> Value then
begin
FLabel1AlignVertical := Value;
BackGroundChange;
end;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetLabel2AlignHorizontal(const Value: TiAlignmentHorizontal);
begin
if FLabel2AlignHorizontal <> Value then
begin
FLabel2AlignHorizontal := Value;
BackGroundChange;
end;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetLabel2AlignVertical(const Value: TiAlignmentVertical);
begin
if FLabel2AlignVertical <> Value then
begin
FLabel2AlignVertical := Value;
BackGroundChange;
end;
end;
//****************************************************************************************************************************************************
procedure TiAngularLogGauge.SetTickLabelStyle(const Value: TiLogLabelStyle);
begin
if FTickLabelStyle <> Value then
begin
FTickLabelStyle := Value;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -