📄 qislidingscale.pas
字号:
{*******************************************************}
{ }
{ TiSlidingScale Component }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iSlidingScale;{$endif}
{$ifdef iCLX}unit QiSlidingScale;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, iMath, iCustomComponent;{$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions, QiMath, QiCustomComponent;{$ENDIF}
type
TiSlidingScale = class(TiCustomComponent)
private
FCenterPoint : TPoint;
FScaleRect : TRect;
FScaleStartPosition : Double;
FScaleStopPosition : Double;
FRangePixels : Integer;
FTickMajorStepValue : Double;
FTickMajorLabelMarginPixels : Integer;
FTickMinorStepValue : Double;
FTickMidLabelMarginPixels : Integer;
FMidTicksEnabled : Boolean;
FMidTickNumber : Integer;
FHalfMajorLength : Integer;
FHalfMidLength : Integer;
FHalfMinorLength : Integer;
FTickMajorLength : Integer;
FPosition : Double;
FTickMidLength : Integer;
FPointerSize : Integer;
FTickMajorLabelMargin : Double;
FScaleSpan : Double;
FTickMidLabelMargin : Double;
FTickMidWidth : Integer;
FTickMajorWidth : Integer;
FTickMajorCount : Integer;
FPointerLineWidth : Integer;
FTickMinorCount : Integer;
FTickMajorLabelPrecision : Integer;
FTickMinorWidth : Integer;
FTickMajorColor : TColor;
FPointerColor : TColor;
FScaleBackgroundColor : TColor;
FTickMinorColor : TColor;
FTickMidColor : TColor;
FPointerLineColor : TColor;
FTickMajorLabelFont : TFont;
FTickMidLabelFont : TFont;
FPointerStyle : TiSlidingScalePointerStyle;
FScaleAlignStyle : TiScaleAlignStyle;
FTickMinorLength : Integer;
FTickMidLabelPrecision : Integer;
FShowMidTickLabels : Boolean;
FShowMidTicks : Boolean;
FReverseScale : Boolean;
FOrientation : TiOrientation;
FScaleOrientation : TiOrientationSide;
FScaleAntiAliasEnabled : Boolean;
FScaleShadowEnabled : Boolean;
FScaleShadowColor : TColor;
FPointerOrientation : TiOrientationSide;
FOuterMarginTop : Integer;
FOuterMarginLeft : Integer;
FOuterMarginRight : Integer;
FOuterMarginBottom : Integer;
FTitleText : String;
FTitleFont : TFont;
FTitleAlignment : TiAlignmentSideVertical;
FTitleMargin : Double;
FOnAutoSize : TNotifyEvent;
procedure SetPointerColor (const Value: TColor);
procedure SetPointerLineColor (const Value: TColor);
procedure SetPointerLineWidth (const Value: Integer);
procedure SetPointerSize (const Value: Integer);
procedure SetPointerStyle (const Value: TiSlidingScalePointerStyle);
procedure SetPosition (const Value: Double);
procedure SetScaleBackgroundColor (const Value: TColor);
procedure SetScaleSpan (const Value: Double);
procedure SetScaleAlignStyle (const Value: TiScaleAlignStyle);
procedure SetTickMajorColor (const Value: TColor);
procedure SetTickMajorCount (const Value: Integer);
procedure SetTickMajorLabelFont (const Value: TFont);
procedure SetTickMajorLabelMargin (const Value: Double);
procedure SetTickMajorLabelPrecision(const Value: Integer);
procedure SetTickMajorLength (const Value: Integer);
procedure SetTickMajorWidth (const Value: Integer);
procedure SetTickMidColor (const Value: TColor);
procedure SetTickMidLabelFont (const Value: TFont);
procedure SetTickMidLabelMargin (const Value: Double);
procedure SetTickMidLength (const Value: Integer);
procedure SetTickMidWidth (const Value: Integer);
procedure SetTickMinorColor (const Value: TColor);
procedure SetTickMinorCount (const Value: Integer);
procedure SetTickMinorWidth (const Value: Integer);
procedure SetTickMinorLength (const Value: Integer);
procedure SetTickMidLabelPrecision (const Value: Integer);
procedure SetShowMidTickLabels (const Value: Boolean);
procedure SetShowMidTicks (const Value: Boolean);
procedure SetReverseScale (const Value: Boolean);
procedure SetOrientation (const Value: TiOrientation);
procedure SetScaleOrientation (const Value: TiOrientationSide);
procedure SetScaleAntiAliasEnabled (const Value: Boolean);
procedure SetScaleShadowEnabled (const Value: Boolean);
procedure SetScaleShadowColor (const Value: TColor);
procedure SetPointerOrientation (const Value: TiOrientationSide);
procedure SetOuterMarginBottom (const Value: Integer);
procedure SetOuterMarginLeft (const Value: Integer);
procedure SetOuterMarginRight (const Value: Integer);
procedure SetOuterMarginTop (const Value: Integer);
procedure SetTitleText (const Value: String);
procedure SetTitleAlignment (const Value: TiAlignmentSideVertical);
procedure SetTitleFont (const Value: TFont);
procedure SetTitleMargin (const Value: Double);
protected
procedure CalcPoints(Canvas: TCanvas);
procedure iPaintTo(Canvas: TCanvas); override;
function GetPositionToPixels(Value : Double) : Integer;
procedure DrawScaleBackGround (Canvas : TCanvas);
procedure DrawTitle (Canvas : TCanvas);
procedure DrawPointer (Canvas : TCanvas);
procedure DrawPointerDualArrow(Canvas : TCanvas);
procedure DrawPointerArrow (Canvas : TCanvas);
procedure DrawPointerPointer (Canvas : TCanvas);
procedure DrawScale (Canvas : TCanvas);
property OnAutoSize : TNotifyEvent read FOnAutoSize write FOnAutoSize;
public
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
published
property Position : Double read FPosition write SetPosition;
property Orientation : TiOrientation read FOrientation write SetOrientation default ioHorizontal;
property ReverseScale : Boolean read FReverseScale write SetReverseScale default False;
property ScaleSpan : Double read FScaleSpan write SetScaleSpan;
property ScaleBackgroundColor : TColor read FScaleBackgroundColor write SetScaleBackgroundColor default clWhite;
property ScaleAlignStyle : TiScaleAlignStyle read FScaleAlignStyle write SetScaleAlignStyle default itasSide;
property ScaleAntiAliasEnabled : Boolean read FScaleAntiAliasEnabled write SetScaleAntiAliasEnabled default True;
property ScaleShadowEnabled : Boolean read FScaleShadowEnabled write SetScaleShadowEnabled default True;
property ScaleShadowColor : TColor read FScaleShadowColor write SetScaleShadowColor default clBlack;
property ScaleOrientation : TiOrientationSide read FScaleOrientation write SetScaleOrientation default iosTopLeft;
property TickMajorCount : Integer read FTickMajorCount write SetTickMajorCount default 5;
property TickMajorWidth : Integer read FTickMajorWidth write SetTickMajorWidth default 2;
property TickMajorLength : Integer read FTickMajorLength write SetTickMajorLength default 9;
property TickMajorColor : TColor read FTickMajorColor write SetTickMajorColor default clBlack;
property TickMajorLabelFont : TFont read FTickMajorLabelFont write SetTickMajorLabelFont;
property TickMajorLabelPrecision : Integer read FTickMajorLabelPrecision write SetTickMajorLabelPrecision default 0;
property TickMajorLabelMargin : Double read FTickMajorLabelMargin write SetTickMajorLabelMargin;
property TickMidWidth : Integer read FTickMidWidth write SetTickMidWidth default 2;
property TickMidLength : Integer read FTickMidLength write SetTickMidLength default 7;
property TickMidColor : TColor read FTickMidColor write SetTickMidColor default clBlack;
property TickMidLabelFont : TFont read FTickMidLabelFont write SetTickMidLabelFont;
property TickMidLabelPrecision : Integer read FTickMidLabelPrecision write SetTickMidLabelPrecision default 1;
property TickMidLabelMargin : Double read FTickMidLabelMargin write SetTickMidLabelMargin;
property TickMinorCount : Integer read FTickMinorCount write SetTickMinorCount default 4;
property TickMinorWidth : Integer read FTickMinorWidth write SetTickMinorWidth default 1;
property TickMinorLength : Integer read FTickMinorLength write SetTickMinorLength default 5;
property TickMinorColor : TColor read FTickMinorColor write SetTickMinorColor default clBlack;
property PointerStyle : TiSlidingScalePointerStyle read FPointerStyle write SetPointerStyle default isspsDualArrow;
property PointerColor : TColor read FPointerColor write SetPointerColor default clYellow;
property PointerSize : Integer read FPointerSize write SetPointerSize default 10;
property PointerOrientation : TiOrientationSide read FPointerOrientation write SetPointerOrientation default iosTopLeft;
property PointerLineColor : TColor read FPointerLineColor write SetPointerLineColor default clBlue;
property PointerLineWidth : Integer read FPointerLineWidth write SetPointerLineWidth default 2;
property ShowMidTicks : Boolean read FShowMidTicks write SetShowMidTicks default False;
property ShowMidTickLabels : Boolean read FShowMidTickLabels write SetShowMidTickLabels default False;
property TitleText : String read FTitleText write SetTitleText;
property TitleMargin : Double read FTitleMargin write SetTitleMargin;
property TitleFont : TFont read FTitleFont write SetTitleFont;
property TitleAlignment : TiAlignmentSideVertical read FTitleAlignment write SetTitleAlignment default iasvTop;
property OuterMarginLeft : Integer read FOuterMarginLeft write SetOuterMarginLeft default 0;
property OuterMarginTop : Integer read FOuterMarginTop write SetOuterMarginTop default 0;
property OuterMarginRight : Integer read FOuterMarginRight write SetOuterMarginRight default 0;
property OuterMarginBottom : Integer read FOuterMarginBottom write SetOuterMarginBottom default 0;
property BackGroundColor;
property BorderStyle;
property Transparent;
property CachedDrawing;
property Width default 250;
property Height default 60;
end;
implementation
//****************************************************************************************************************************************************
constructor TiSlidingScale.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 250;
Height := 60;
FOrientation := ioHorizontal;
FScaleAntiAliasEnabled := True;
FScaleSpan := 100;
FScaleAlignStyle := itasSide;
FScaleBackgroundColor := clWhite;
FScaleOrientation := iosTopLeft;
FScaleShadowEnabled := True;
FTickMajorCount := 5;
FTickMinorCount := 4;
FTickMajorLength := 9;
FTickMidLength := 7;
FTickMinorLength := 5;
FTickMajorWidth := 2;
FTickMidWidth := 2;
FTickMinorWidth := 1;
FTickMidColor := clBlack;
FTickMinorColor := clBlack;
FTickMajorColor := clBlack;
FTickMajorLabelMargin := 0.25;
FTickMidLabelMargin := 0.25;
FTickMajorLabelPrecision := 0;
FTickMidLabelPrecision := 1;
FPointerSize := 10;
FPointerOrientation := iosTopLeft;
FPointerStyle := isspsDualArrow;
FPointerLineWidth := 2;
FPointerColor := clYellow;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -