📄 qiscaleobject.pas
字号:
{*******************************************************}
{ }
{ TiScaleObject }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iScaleObject;{$endif}
{$ifdef iCLX}unit QiScaleObject;{$endif}
interface
uses
SysUtils, Classes,
{$IFDEF LINUX}
Xlib,
{$ENDIF}
{$IFDEF MSWINDOWS}
Windows, Messages,
{$ENDIF}
{$ifdef iCLX}
Qt, QGraphics, QControls, Types,
QiMath, QiTypes, QiGPFunctions;
{$else}
Graphics, Controls,
iMath, iTypes, iGPFunctions;
{$endif}
type
TiScaleObject = class(TObject)
private
FShowTicksMinor : Boolean;
FShowTicksMajor : Boolean;
FShowTickLabels : Boolean;
FTickMinorCount : Integer;
FTickMinorLength : Integer;
FTickMajorLength : Integer;
FTickMargin : Integer;
FTickMajorCount : Integer;
FTickLabelPrecision : Integer;
FTickLabelMargin : Integer;
FTickMinorColor : TColor;
FTickMajorColor : TColor;
FTickLabelFont : TFont;
FOnChange : TNotifyEvent;
FPositionMax : Double;
FPositionMin : Double;
FStart : Integer;
FStop : Integer;
FTickMinorAlignment : TiTickMinorAlignment;
FOrientation : TiOrientation;
FOrientationTickMarks : TiOrientationSide;
FEdge : Integer;
FTickMajorStyle : TiBevelStyle;
FTickMinorStyle : TiBevelStyle;
FShowTicksMajorFirstLast : Boolean;
FReverseTickMinorAlign : Boolean;
FReverseScale : Boolean;
FPrecisionStyle : TiPrecisionStyle;
FOnCustomizeTickLabel : TOnCustomizeTickLabel;
FAutoScaleEnabled : Boolean;
FAutoScaleMaxTicks : Integer;
FAutoScaleDesiredTicks : Integer;
FAutoScaleStyle : TiAutoScaleStyle;
FAutoScaleMinTick : Double;
FAutoScaleMaxTick : Double;
procedure SetShowTickLabels (const Value: Boolean);
procedure SetShowTicksMajor (const Value: Boolean);
procedure SetShowTicksMinor (const Value: Boolean);
procedure SetTickLabelFont (const Value: TFont);
procedure SetTickLabelMargin (const Value: Integer);
procedure SetTickLabelPrecision (const Value: Integer);
procedure SetTickMajorColor (const Value: TColor);
procedure SetTickMajorCount (const Value: Integer);
procedure SetTickMajorLength (const Value: Integer);
procedure SetTickMargin (const Value: Integer);
procedure SetTickMinorColor (const Value: TColor);
procedure SetTickMinorCount (const Value: Integer);
procedure SetTickMinorLength (const Value: Integer);
procedure SetTickMinorAlignment (const Value: TiTickMinorAlignment);
procedure SetTickMajorStyle (const Value: TiBevelStyle);
procedure SetTickMinorStyle (const Value: TiBevelStyle);
procedure SetShowTicksMajorFirstLast(const Value: Boolean);
procedure SetReverseScale (const Value: Boolean);
procedure SetPrecisionStyle (const Value: TiPrecisionStyle);
function GetDecimalPoints : Integer;
protected
procedure Change;
procedure FontChange(Sender : TObject);
function PositionToPixelsRelative(Value: Double): Integer;
function PositionToPixelsAbsolute(Value: Double): Integer;
public
constructor Create;
destructor Destroy; override;
procedure Draw(Canvas: TCanvas);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
property Start : Integer read FStart write FStart;
property Stop : Integer read FStop write FStop;
property Edge : Integer read FEdge write FEdge;
property PositionMax : Double read FPositionMax write FPositionMax;
property PositionMin : Double read FPositionMin write FPositionMin;
property Orientation : TiOrientation read FOrientation write FOrientation;
property OrientationTickMarks : TiOrientationSide read FOrientationTickMarks write FOrientationTickMarks;
property ReverseTickMinorAlign : Boolean read FReverseTickMinorAlign write FReverseTickMinorAlign;
property AutoScaleEnabled : Boolean read FAutoScaleEnabled write FAutoScaleEnabled;
property AutoScaleDesiredTicks : Integer read FAutoScaleDesiredTicks write FAutoScaleDesiredTicks;
property AutoScaleMaxTicks : Integer read FAutoScaleMaxTicks write FAutoScaleMaxTicks;
property AutoScaleStyle : TiAutoScaleStyle read FAutoScaleStyle write FAutoScaleStyle;
property AutoScaleMaxTick : Double read FAutoScaleMaxTick write FAutoScaleMaxTick;
property AutoScaleMinTick : Double read FAutoScaleMinTick write FAutoScaleMinTick;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
property ShowTicksMajor : Boolean read FShowTicksMajor write SetShowTicksMajor;
property ShowTicksMinor : Boolean read FShowTicksMinor write SetShowTicksMinor;
property ShowTickLabels : Boolean read FShowTickLabels write SetShowTickLabels;
property ShowTicksMajorFirstLast : Boolean read FShowTicksMajorFirstLast write SetShowTicksMajorFirstLast;
property TickMajorCount : Integer read FTickMajorCount write SetTickMajorCount;
property TickMajorColor : TColor read FTickMajorColor write SetTickMajorColor;
property TickMajorLength : Integer read FTickMajorLength write SetTickMajorLength;
property TickMajorStyle : TiBevelStyle read FTickMajorStyle write SetTickMajorStyle;
property TickMinorAlignment : TiTickMinorAlignment read FTickMinorAlignment write SetTickMinorAlignment;
property TickMinorCount : Integer read FTickMinorCount write SetTickMinorCount;
property TickMinorColor : TColor read FTickMinorColor write SetTickMinorColor;
property TickMinorLength : Integer read FTickMinorLength write SetTickMinorLength;
property TickMinorStyle : TiBevelStyle read FTickMinorStyle write SetTickMinorStyle;
property TickMargin : Integer read FTickMargin write SetTickMargin;
property TickLabelMargin : Integer read FTickLabelMargin write SetTickLabelMargin;
property TickLabelFont : TFont read FTickLabelFont write SetTickLabelFont;
property TickLabelPrecision : Integer read FTickLabelPrecision write SetTickLabelPrecision;
property ReverseScale : Boolean read FReverseScale write SetReverseScale;
property PrecisionStyle : TiPrecisionStyle read FPrecisionStyle write SetPrecisionStyle;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
property OnCustomizeTickLabel : TOnCustomizeTickLabel read FOnCustomizeTickLabel write FOnCustomizeTickLabel;
end;
implementation
//****************************************************************************************************************************************************
constructor TiScaleObject.Create;
begin
FTickMajorCount := 5;
FTickMajorLength := 7;
FTickMinorLength := 3;
FTickMinorCount := 4;
FTickLabelMargin := 5;
FTickLabelPrecision := 0;
FTickMargin := 5;
FShowTicksMajorFirstLast := True;
FTickLabelFont := TFont.Create; FTickLabelFont.OnChange := FontChange;
end;
//****************************************************************************************************************************************************
destructor TiScaleObject.Destroy;
begin
FTickLabelFont.Free;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.Change;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetShowTickLabels(const Value: Boolean);
begin
if FShowTickLabels <> Value then
begin
FShowTickLabels := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetShowTicksMajor(const Value: Boolean);
begin
if FShowTicksMajor <> Value then
begin
FShowTicksMajor := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetShowTicksMinor(const Value: Boolean);
begin
if FShowTicksMinor <> Value then
begin
FShowTicksMinor := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetShowTicksMajorFirstLast(const Value: Boolean);
begin
if FShowTicksMajorFirstLast <> Value then
begin
FShowTicksMajorFirstLast := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickLabelFont(const Value: TFont);
begin
FTickLabelFont.Assign(Value);
Change;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickLabelMargin(const Value: Integer);
begin
if FTickLabelMargin <> Value then
begin
FTickLabelMargin := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickLabelPrecision(const Value: Integer);
begin
if FTickLabelPrecision <> Value then
begin
FTickLabelPrecision := Value;
if FTickLabelPrecision < 0 then FTickLabelPrecision := 0;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMajorColor(const Value: TColor);
begin
if FTickMajorColor <> Value then
begin
FTickMajorColor := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMajorCount(const Value: Integer);
begin
if FTickMajorCount <> Value then
begin
FTickMajorCount := Value;
if FTickMajorCount < 2 then FTickMajorCount := 2;
if FTickMajorCount > 100 then FTickMajorCount := 100;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMajorLength(const Value: Integer);
begin
if FTickMajorLength <> Value then
begin
FTickMajorLength := Value;
if FTickMajorLength < 1 then FTickMajorLength := 1;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMajorStyle(const Value: TiBevelStyle);
begin
if FTickMajorStyle <> Value then
begin
FTickMajorStyle := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMargin(const Value: Integer);
begin
if FTickMargin <> Value then
begin
FTickMargin := Value;
Change;
end;
end;
//****************************************************************************************************************************************************
procedure TiScaleObject.SetTickMinorAlignment(const Value: TiTickMinorAlignment);
begin
if FTickMinorAlignment <> Value then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -