📄 teetools.pas
字号:
{ This variable can be used to set the default "DrawLine" class used by
TDrawLineTool when creating new lines }
TDrawLineClass=class of TDrawLine;
var
TeeDrawLineClass:TDrawLineClass=TDrawLine; { 5.02 }
type
TMarkToolMouseAction = (mtmMove, mtmClick);
TMarksTipTool=class;
TMarksTipGetText=procedure(Sender:TMarksTipTool; var Text:String) of object;
// Marks tip tool, use it to display "tips" or "hints" when the end-user
// moves or clicks the mouse over a series point.
TMarksTipTool=class(TTeeCustomToolSeries)
private
FMouseAction : TMarkToolMouseAction;
FOnCancel : TNotifyEvent;
FOnGetText : TMarksTipGetText;
FStyle : TSeriesMarksStyle;
procedure DoCancelHint;
function GetHideDelay: Integer;
function GetMouseDelay: Integer;
procedure SetHideDelay(const Value: Integer);
Procedure SetMouseAction(Value:TMarkToolMouseAction);
procedure SetMouseDelay(const Value: Integer);
protected
Function Chart:TCustomChart;
Procedure ChartEvent(AEvent:TChartToolEvent); override;
Procedure ChartMouseEvent( AEvent: TChartMouseEvent;
Button:TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
class function GetEditorClass: String; override;
Procedure SetActive(Value:Boolean); override;
public
Constructor Create(AOwner:TComponent); override;
procedure Assign(Source:TPersistent); override; // 7.07
class Function Description:String; override;
class Function LongDescription:String; override;
published
property Active;
property HideDelay:Integer read GetHideDelay
write SetHideDelay default 2500; // 8.0
property MouseAction:TMarkToolMouseAction read FMouseAction
write SetMouseAction default mtmMove;
property MouseDelay:Integer read GetMouseDelay
write SetMouseDelay default 500; { 5.02 }
property Series;
property Style:TSeriesMarksStyle read FStyle write FStyle default smsLabel;
property OnCancelHint:TNotifyEvent read FOnCancel write FOnCancel; // 7.07
property OnGetText:TMarksTipGetText read FOnGetText write FOnGetText;
end;
TNearestToolStyle=(hsNone,hsCircle,hsRectangle,hsDiamond,hsSeries);
// Nearest tool, use it to display a graphical signal when the mouse is
// moving near a series point.
TNearestTool=class(TTeeCustomToolSeries)
private
FFullRepaint: Boolean;
FLinePen : TChartPen;
FSize : Integer;
FStyle : TNearestToolStyle;
FOnChange : TNotifyEvent;
IMouse : TPoint;
Function GetDrawLine:Boolean;
procedure PaintHint;
procedure SetDrawLine(const Value: Boolean);
procedure SetLinePen(const Value: TChartPen);
procedure SetSize(const Value: Integer);
procedure SetStyle(const Value: TNearestToolStyle);
function ZAxisCalc(const Value:Double):Integer;
protected
procedure ChartEvent(AEvent: TChartToolEvent); override;
Procedure ChartMouseEvent( AEvent: TChartMouseEvent;
Button:TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
class function GetEditorClass: String; override;
public
Point : Integer;
Constructor Create(AOwner:TComponent); override;
Destructor Destroy; override;
procedure Assign(Source:TPersistent); override; // 7.07
class Function GetNearestPoint(Series:TChartSeries; X,Y:Integer):Integer; overload;
class Function GetNearestPoint(Series:TChartSeries; X,Y:Integer; IncludeNulls:Boolean):Integer; overload;
class Function Description:String; override;
class Function LongDescription:String; override;
published
property Active;
property Brush;
property DrawLine:Boolean read GetDrawLine write SetDrawLine default True;
property FullRepaint:Boolean read FFullRepaint write FFullRepaint default True;
property LinePen:TChartPen read FLinePen write SetLinePen; // 7.0
property Pen;
property Series;
property Size:Integer read FSize write SetSize default 20;
property Style:TNearestToolStyle read FStyle write SetStyle default hsCircle;
property OnChange:TNotifyEvent read FOnChange write FOnChange;
end;
TColorLineTool=class;
// Color band tool, use it to display a coloured rectangle (band)
// at the specified axis and position.
TColorBandTool=class(TTeeCustomToolAxis)
private
FColor : TColor;
FCursor : TCursor;
FDrawBehind : Boolean;
FDrawBehindAxes: Boolean;
FEnd : Double;
FGradient : TChartGradient;
FOnClick : TMouseEvent;
FOnResized : TNotifyEvent;
FPicture : TTeePicture;
FStart : Double;
FTransparency : TTeeTransparency;
FLineEnd : TColorLineTool;
FLineStart : TColorLineTool;
procedure PictureChanged(Sender:TObject);
procedure DragLine(Sender:TColorLineTool);
procedure EndDragLine(Sender:TColorLineTool);
function GetEndLinePen: TChartPen;
function GetPicture: TTeePicture;
function GetResizeEnd: Boolean;
function GetResizeStart: Boolean;
function GetStartLinePen: TChartPen;
Function NewColorLine:TColorLineTool;
procedure PaintBand;
Procedure SetColor(Value:TColor);
procedure SetDrawBehind(const Value: Boolean);
procedure SetDrawBehindAxes(const Value: Boolean);
procedure SetEnd(const Value: Double);
procedure SetEndLinePen(const Value: TChartPen);
procedure SetGradient(const Value: TChartGradient);
procedure SetLines;
procedure SetPicture(const Value: TTeePicture);
procedure SetResizeEnd(const Value: Boolean);
procedure SetResizeStart(const Value: Boolean);
procedure SetStart(const Value: Double);
procedure SetStartLinePen(const Value: TChartPen);
procedure SetTransparency(const Value: TTeeTransparency);
protected
procedure ChartEvent(AEvent: TChartToolEvent); override;
Procedure ChartMouseEvent( AEvent: TChartMouseEvent;
Button:TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
class function GetEditorClass: String; override;
procedure Loaded; override;
procedure SetAxis(const Value: TChartAxis); override;
procedure SetParentChart(const Value: TCustomAxisPanel); override;
Function ZPosition:Integer;
public
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Assign(Source:TPersistent); override;
Function BoundsRect:TRect;
Function Clicked(X,Y:Integer):Boolean;
class Function Description:String; override;
class Function LongDescription:String; override;
property StartLine:TColorLineTool read FLineStart;
property EndLine:TColorLineTool read FLineEnd;
published
property Active;
property Axis;
property Brush;
property Color:TColor read FColor write SetColor default clWhite;
property Cursor:TCursor read FCursor write FCursor default crDefault;
property DrawBehind:Boolean read FDrawBehind write SetDrawBehind default True;
property DrawBehindAxes:Boolean read FDrawBehindAxes write SetDrawBehindAxes default False;
property EndLinePen:TChartPen read GetEndLinePen write SetEndLinePen;
property EndValue:Double read FEnd write SetEnd;
property Gradient:TChartGradient read FGradient write SetGradient;
property Pen;
property Picture:TTeePicture read GetPicture write SetPicture;
property ResizeEnd:Boolean read GetResizeEnd write SetResizeEnd default False;
property ResizeStart:Boolean read GetResizeStart write SetResizeStart default False;
property StartLinePen:TChartPen read GetStartLinePen write SetStartLinePen;
property StartValue:Double read FStart write SetStart;
property Transparency:TTeeTransparency read FTransparency
write SetTransparency default 0;
// Events
property OnClick:TMouseEvent read FOnClick write FOnClick;
property OnResized:TNotifyEvent read FOnResized write FOnResized;
end;
TGridBandBrush=class(TChartBrush)
private
FGradient : TTeeGradient;
FTransp : TTeeTransparency;
procedure SetGradient(const Value: TTeeGradient);
procedure SetTransp(const Value: TTeeTransparency);
public
Constructor Create(OnChangeEvent:TNotifyEvent); override;
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
published
property BackColor default clNone;
property Gradient:TTeeGradient read FGradient write SetGradient;
property Transparency:TTeeTransparency read FTransp write SetTransp default 0;
end;
// TGridBandTool
// Draws alternate color bands on axis grid space.
TGridBandTool=class(TTeeCustomToolAxis)
private
FBand1 : TGridBandBrush;
FBand2 : TGridBandBrush;
Procedure DrawGrids(Sender:TChartAxis);
Procedure SetBand1(Value:TGridBandBrush);
Procedure SetBand2(Value:TGridBandBrush);
protected
StartPos : Integer;
EndPos : Integer;
class function GetEditorClass: String; override;
procedure SetAxis(const Value: TChartAxis); override;
public
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Assign(Source:TPersistent); override;
Function BandBackColor(ABand:TGridBandBrush):TColor;
class Function Description:String; override;
class Function LongDescription:String; override;
published
property Active;
property Axis;
property Band1:TGridBandBrush read FBand1 write SetBand1;
property Band2:TGridBandBrush read FBand2 write SetBand2;
end;
TColorLineStyle=(clCustom,clMaximum,clCenter,clMinimum);
TColorLineToolOnDrag=procedure(Sender:TColorLineTool) of object;
// Color line tool, use it to display a vertical or horizontal line
// at the specified axis and position.
// The line can be optionally dragged at runtime.
TColorLineTool=class(TTeeCustomToolAxis)
private
FAllowDrag : Boolean;
FDragRepaint : Boolean;
FDraw3D : Boolean;
FDrawBehind : Boolean;
FNoLimitDrag : Boolean;
FOnBeginDragLine: TColorLineToolOnDrag;
FOnDragLine : TColorLineToolOnDrag;
FOnEndDragLine : TColorLineToolOnDrag;
FStyle : TColorLineStyle;
FValue : Double;
IDragging : Boolean;
IParent : TCustomAxisPanel;
InternalOnEndDragLine : TColorLineToolOnDrag;
Function Chart:TCustomAxisPanel;
Procedure DrawColorLine(Back:Boolean);
procedure SetDraw3D(const Value: Boolean);
procedure SetDrawBehind(const Value: Boolean);
procedure SetStyle(const Value: TColorLineStyle);
procedure SetValue(const AValue: Double);
protected
Function CalcValue:Double;
procedure ChartEvent(AEvent: TChartToolEvent); override;
Procedure ChartMouseEvent( AEvent: TChartMouseEvent;
Button:TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
procedure DoEndDragLine; virtual;
class function GetEditorClass: String; override;
procedure InternalDrawLine(Back:Boolean);
procedure SetParent(Value:TCustomAxisPanel); virtual;
public
Constructor Create(AOwner:TComponent); override;
Procedure Assign(Source:TPersistent); override;
Function Clicked(x,y:Integer):Boolean;
class Function Description:String; override;
class Function LongDescription:String; override;
Function LimitValue(const AValue:Double):Double; // 7.0 moved from private
published
property Active;
property Axis;
property AllowDrag:Boolean read FAllowDrag write FAllowDrag default True;
property DragRepaint:Boolean read FDragRepaint write FDragRepaint default False;
property Draw3D:Boolean read FDraw3D write SetDraw3D default True;
property DrawBehind:Boolean read FDrawBehind write SetDrawBehind default False;
property NoLimitDrag:Boolean read FNoLimitDrag write FNoLimitDrag default False;
property Pen;
property Style:TColorLineStyle read FStyle write SetStyle default clCustom;
property Value:Double read FValue write SetValue;
property OnBeginDragLine:TColorLineToolOnDrag read FOnBeginDragLine write FOnBeginDragLine;
property OnDragLine:TColorLineToolOnDrag read FOnDragLine write FOnDragLine;
property OnEndDragLine:TColorLineToolOnDrag read FOnEndDragLine write FOnEndDragLine;
end;
// Rotate tool, use it to allow the end-user to do 3D rotation of the chart
// at runtime by dragging the chart using the specified mouse button.
TRotateToolStyles = ( rsAll, rsRotation, rsElevation );
TRotateTool=class(TTeeCustomTool)
private
FButton : TMouseButton;
FCursor : TCursor;
FInertia : Integer;
FInverted : Boolean;
FOnRotate : TNotifyEvent;
FSpeed : Integer;
FStyle : TRotateToolStyles;
IDragging : Boolean;
IFirstTime : Boolean;
IOldRepaint: Boolean;
IOldX : Integer;
IOldY : Integer;
ITimer : TTimer;
IDifX : Double;
IDifY : Double;
IOldCursor : TCursor;
procedure DoTimer(Sender: TObject);
procedure DoRotation(const IDifX,IDifY:Double);
protected
procedure ChartEvent(AEvent: TChartToolEvent); override;
Procedure ChartMouseEvent( AEvent: TChartMouseEvent;
AButton:TMouseButton;
AShift: TShiftState; X, Y: Integer); override;
class function GetEditorClass: String; override;
public
Constructor Create(AOwner:TComponent); override;
Destructor Destroy; override;
procedure Assign(Source:TPersistent); override;
class Function Description:String; override;
class Function LongDescription:String; override;
class function ElevationChange(FullRotation:Boolean; const AAngle,AChange:Double):Double;
procedure Rotate(const RotationDegrees,ElevationDegrees:Double);
class function RotationChange(FullRotation:Boolean; const AAngle,AChange:Double):Double;
published
property Active;
property Button:TMouseButton read FButton write FButton default mbLeft;
property Cursor:TCursor read FCursor write FCursor default crTeeHand;
property Inertia:Integer read FInertia write FInertia default 0;
property Inverted:Boolean read FInverted write FInverted default False;
property Pen;
property Speed:Integer read FSpeed write FSpeed default 50; { % }
property Style:TRotateToolStyles read FStyle write FStyle default rsAll;
property OnRotate:TNotifyEvent read FOnRotate write FOnRotate;
end;
// Chart Image tool, use it to display a picture using the specified
// Series axes as boundaries. When the axis are zoomed or scrolled,
// the picture will follow the new boundaries.
TChartImageTool=class(TTeeCustomToolSeries)
private
FPicture : TTeePicture;
procedure SetPicture(const Value: TTeePicture);
protected
procedure ChartEvent(AEvent: TChartToolEvent); override;
class function GetEditorClass: String; override;
procedure SetSeries(const Value: TChartSeries); override;
public
Constructor Create(AOwner:TComponent); override;
Destructor Destroy; override;
procedure Assign(Source:TPersistent); override;
class Function Description:String; override;
class Function LongDescription:String; override;
published
property Active;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -