📄 tecanvas.pas
字号:
FHorizSize : Integer;
FSmooth : Boolean;
FSmoothBlur : Integer;
FTransparency : TTeeTransparency;
FVertSize : Integer;
FVisible : Boolean;
IOnChange : TNotifyEvent;
IBlend : TTeeBlend;
procedure Changed;
procedure DrawSmooth(ACanvas:TCanvas3D; const Rect:TRect;
Ellipse,Polygon:Boolean;
RoundSize:Integer;
const P:TPointArray);
procedure FinishBlending(ACanvas:TTeeCanvas);
function GetSize: Integer;
function IsColorStored: Boolean;
function IsHorizStored: Boolean;
function IsVertStored: Boolean;
function IsVisibleStored: Boolean;
Function PrepareCanvas(ACanvas:TCanvas3D; const R:TRect;
Z:Integer=0):Boolean;
Procedure SetClip(const Value:Boolean);
Procedure SetColor(Value:TColor);
Procedure SetHorizSize(Value:Integer);
Procedure SetIntegerProperty(Var Variable:Integer; Const Value:Integer);
procedure SetSize(const Value: Integer);
procedure SetSmooth(const Value: Boolean);
procedure SetSmoothBlur(const Value: Integer);
procedure SetTransparency(Value: TTeeTransparency);
Procedure SetVertSize(Value:Integer);
Procedure SetVisible(Value:Boolean);
function ValidCanvas(ACanvas:TCanvas3D):Boolean;
{$IFDEF CLR}
public
{$ELSE}
protected
{$ENDIF}
DefaultColor : TColor;
DefaultSize : Integer;
DefaultVisible : Boolean;
FullDraw : Boolean;
procedure InitValues(AColor:TColor; ASize:Integer);
public
Constructor Create(AOnChange:TNotifyEvent);
Procedure Assign(Source:TPersistent); override;
procedure Draw(ACanvas:TCanvas3D; const P:{$IFDEF D5}Array of TPoint{$ELSE}TPointArray{$ENDIF}); overload;
procedure Draw(ACanvas:TCanvas3D; Const Rect:TRect); overload;
procedure Draw(ACanvas:TCanvas3D; Const Rect:TRect; Z:Integer; RoundSize:Integer=0); overload;
procedure DrawEllipse(ACanvas:TCanvas3D; Const Rect:TRect; Z:Integer=0);
property Size:Integer read GetSize write SetSize;
published
property Clip:Boolean read FClip write SetClip default False;
property Color:TColor read FColor write SetColor stored IsColorStored;
property HorizSize:Integer read FHorizSize write SetHorizSize stored IsHorizStored;
property Smooth:Boolean read FSmooth write SetSmooth default True;
property SmoothBlur:Integer read FSmoothBlur write SetSmoothBlur default 0;
property Transparency:TTeeTransparency read FTransparency write SetTransparency default 0;
property VertSize:Integer read FVertSize write SetVertSize stored IsVertStored;
property Visible:Boolean read FVisible write SetVisible stored IsVisibleStored;
end;
TFourPoints=Array[0..3] of TPoint;
TGradientDirection = (gdTopBottom, gdBottomTop,
gdLeftRight, gdRightLeft,
gdFromCenter, gdFromTopLeft,
gdFromBottomLeft, gdRadial,
gdDiagonalUp, gdDiagonalDown );
TSubGradient=class; // forward declared
TCustomTeeGradient=class(TPersistent)
private
FAngle : Integer;
FBalance : Integer;
FDirection : TGradientDirection;
FEndColor : TColor;
FMidColor : TColor;
FRadialX : Integer;
FRadialY : Integer;
FStartColor : TColor;
FSub : TSubGradient;
FVisible : Boolean;
IHasMiddle : Boolean;
Procedure DrawRadial(Canvas:TTeeCanvas; Rect:TRect);
procedure DrawRotated(Canvas:TTeeCanvas; const R:TRect);
procedure DrawSubGradient(Canvas:TTeeCanvas; Const Rect:TRect;
RoundRectSize:Integer=0);
Function GetMidColor:TColor;
function GetSub:TSubGradient;
Procedure SetAngle(Value:Integer);
Procedure SetBalance(Value:Integer);
Procedure SetColorProperty(Var Variable:TColor; const Value:TColor);
Procedure SetDirection(Value:TGradientDirection);
Procedure SetEndColor(Value:TColor);
Procedure SetIntegerProperty(Var Variable:Integer; Value:Integer);
Procedure SetMidColor(Value:TColor);
procedure SetRadialX(const Value: Integer);
procedure SetRadialY(const Value: Integer);
Procedure SetStartColor(Value:TColor);
procedure SetSub(const Value:TSubGradient);
Procedure SetVisible(Value:Boolean);
protected
IChanged : TNotifyEvent;
procedure DoChanged;
public
Constructor Create(ChangedEvent:TNotifyEvent); virtual;
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
Procedure Draw(Canvas:TTeeCanvas; Const Rect:TRect; RoundRectSize:Integer=0); overload;
Procedure Draw(Canvas:TTeeCanvas; var P:TFourPoints); overload;
Procedure Draw(Canvas:TCanvas3D; var P:TFourPoints; Z:Integer); overload;
procedure Draw(Canvas:TCanvas3D; var P:TPointArray; Z:Integer; Is3D:Boolean); overload;
property Changed:TNotifyEvent read IChanged write IChanged;
Procedure UseMiddleColor;
{ to be published }
property Angle:Integer read FAngle write SetAngle default 0;
property Balance:Integer read FBalance write SetBalance default 50;
property Direction:TGradientDirection read FDirection write SetDirection default gdTopBottom;
property EndColor:TColor read FEndColor write SetEndColor default clYellow;
property MidColor:TColor read GetMidColor write SetMidColor default clNone;
property RadialX:Integer read FRadialX write SetRadialX default 0;
property RadialY:Integer read FRadialY write SetRadialY default 0;
property StartColor:TColor read FStartColor write SetStartColor default clWhite;
property SubGradient:TSubGradient read GetSub write SetSub;
property Visible:Boolean read FVisible write SetVisible default False;
end;
TSubGradient=class(TCustomTeeGradient)
private
FTransparency : TTeeTransparency;
procedure SetTransparency(const Value:TTeeTransparency);
published
property Angle;
property Balance;
property Direction;
property EndColor;
property MidColor;
property RadialX;
property RadialY;
property StartColor;
property Transparency:TTeeTransparency read FTransparency
write SetTransparency default 50;
property Visible;
end;
TTeeGradient=class(TCustomTeeGradient)
published
property Angle;
property Balance;
property Direction;
property EndColor;
property MidColor;
property RadialX;
property RadialY;
property StartColor;
property SubGradient;
property Visible;
end;
TTeeFontGradient=class(TTeeGradient)
private
FOutline : Boolean;
Procedure SetBooleanProperty( Var Variable:Boolean;
Const Value:Boolean);
procedure SetOutline(const Value: Boolean);
published
property Outline:Boolean read FOutline write SetOutline default False;
end;
TTeeFont=class(TFont)
private
FGradient : TTeeFontGradient;
FInterCharSize : Integer;
FOutLine : TChartHiddenPen;
FPicture : TTeePicture;
FShadow : TTeeShadow;
ICanvas : TTeeCanvas;
procedure DoChanged(Sender:TObject);
function GetGradient: TTeeFontGradient;
function GetOutLine: TChartHiddenPen;
function GetPicture: TTeePicture;
Function GetShadow: TTeeShadow;
Function IsColorStored:Boolean;
Function IsHeightStored:Boolean;
Function IsNameStored:Boolean;
Function IsStyleStored:Boolean;
procedure SetGradient(const Value: TTeeFontGradient);
Procedure SetInterCharSize(Value:Integer);
Procedure SetOutLine(Value:TChartHiddenPen);
Procedure SetPicture(Value:TTeePicture);
Procedure SetShadow(Value:TTeeShadow);
protected
IDefColor : TColor;
IDefStyle : TFontStyles;
public
Constructor Create(ChangedEvent:TNotifyEvent);
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
published
{$IFNDEF CLX}
property Charset default DEFAULT_CHARSET;
{$ENDIF}
property Color stored IsColorStored;
property Gradient:TTeeFontGradient read GetGradient write SetGradient;
property Height stored IsHeightStored;
property InterCharSize:Integer read FInterCharSize
write SetInterCharSize default 0;
property Name stored IsNameStored;
property OutLine:TChartHiddenPen read GetOutLine write SetOutLine;
property Picture:TTeePicture read GetPicture write SetPicture;
{$IFDEF CLX}
property Pitch default fpVariable;
{$ENDIF}
property Shadow:TTeeShadow read GetShadow write SetShadow;
property Style stored IsStyleStored;
{$IFDEF CLX}
property Weight default 40;
{$ENDIF}
end;
TCanvasBackMode = ( cbmNone,cbmTransparent,cbmOpaque );
TCanvasTextAlign = Integer;
TTeeCanvasHandle={$IFDEF CLX}QPainterH{$ELSE}HDC{$ENDIF};
TTeeCanvas=class {$IFDEF CLR}abstract{$ENDIF}
private
FCanvas : TCanvas;
FFont : TFont;
FPen : TPen;
FBrush : TBrush;
FMetafiling : Boolean;
ITransp : Integer;
Function GetFontHeight:Integer; {$IFDEF D10}inline;{$ENDIF} // 7.0
Procedure InternalDark(Const AColor:TColor; Quantity:Byte);
protected
FBounds : TRect; // 7.0, moved from TeeCanvas3D
IFont : TTeeFont;
Procedure SetCanvas(ACanvas:TCanvas);
function GetBackColor:TColor; virtual; abstract;
Function GetBackMode:TCanvasBackMode; virtual; abstract;
Function GetHandle:TTeeCanvasHandle; virtual; abstract;
Function GetMonochrome:Boolean; virtual; abstract;
Function GetPixel(x,y:Integer):TColor; virtual; abstract;
Function GetSupportsFullRotation:Boolean; virtual; abstract;
Function GetTextAlign:TCanvasTextAlign; virtual; abstract;
Function GetUseBuffer:Boolean; virtual; abstract;
Procedure SetBackColor(Color:TColor); virtual; abstract;
Procedure SetBackMode(Mode:TCanvasBackMode); virtual; abstract;
Procedure SetMonochrome(Value:Boolean); virtual; abstract;
procedure SetPixel(X, Y: Integer; Value: TColor); virtual; abstract;
procedure SetTextAlign(Align:TCanvasTextAlign); virtual; abstract;
Procedure SetUseBuffer(Value:Boolean); virtual; abstract;
{$IFDEF TEEUNICODE}
function TextExtent(const Text:WideString):TSize;
{$ENDIF}
public
FontZoom : Double; // % of zoom of all font sizes
Procedure AssignBrush(ABrush:TChartBrush); overload; {$IFDEF D10}inline;{$ENDIF}
Procedure AssignBrush(ABrush:TChartBrush; ABackColor:TColor); overload; {$IFDEF D10}inline;{$ENDIF}
Procedure AssignBrush(ABrush:TChartBrush; AColor,ABackColor:TColor); overload;
Procedure AssignBrushColor(ABrush:TChartBrush;
AColor,ABackColor:TColor); {$IFDEF D11}deprecated 'Please use AssignBrush method.';{$ENDIF} // Do not localize
procedure AssignVisiblePen(APen:TPen); {$IFDEF D10}inline;{$ENDIF}
procedure AssignVisiblePenColor(APen:TPen; AColor:TColor); virtual; // 7.0
procedure AssignFont(AFont:TTeeFont);
Procedure ResetState;
Function BeginBlending(const R:TRect; Transparency:TTeeTransparency):TTeeBlend; virtual;
procedure EndBlending(Blend:TTeeBlend); virtual;
{ 2d }
procedure Arc(const Left, Top, Right, Bottom, StartX, StartY, EndX, EndY: Integer); overload; virtual; abstract;
procedure Arc(const Left, Top, Right, Bottom:Integer; StartAngle,EndAngle:Double); overload; virtual;
Procedure Arrow( Filled:Boolean; const ArrowPercent:Double;
const FromPoint,ToPoint:TPoint;
ArrowWidth,ArrowHeight:Integer); overload;
procedure Donut( XCenter,YCenter,XRadius,YRadius:Integer;
Const StartAngle,EndAngle,HolePercent:Double); virtual; abstract;
procedure Draw(X, Y: Integer; Graphic: TGraphic); virtual; abstract;
procedure Ellipse(const R:TRect); overload; {$IFDEF D9}inline;{$ENDIF}
procedure Ellipse(X1, Y1, X2, Y2: Integer); overload; virtual; abstract;
procedure FillRect(const Rect: TRect); virtual; abstract;
procedure Frame3D( var Rect: TRect; TopColor,BottomColor: TColor;
Width: Integer); virtual;
procedure LineTo(X,Y:Integer); overload; virtual; abstract;
procedure LineTo(const P:TPoint); overload;
procedure MoveTo(X,Y:Integer); overload; virtual; abstract;
procedure MoveTo(const P:TPoint); overload;
procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); virtual; abstract;
procedure Rectangle(const R:TRect); overload; {$IFDEF D9}inline;{$ENDIF}
procedure Rectangle(X0,Y0,X1,Y1:Integer); overload; virtual; abstract;
procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer); overload; virtual; abstract;
procedure RoundRect(Const R:TRect; X,Y:Integer); overload;
procedure StretchDraw(const Rect: TRect; Graphic: TGraphic); overload; virtual; abstract;
{$IFDEF AXUNICODE}
Procedure TextOut(X,Y:Integer; const Text:WideString); overload;
{$ENDIF}
Procedure TextOut(X,Y:Integer; const Text:String; AllowHtml:Boolean); overload;
Procedure TextOut(X,Y:Integer; const Text:String); overload; virtual; abstract;
Function TextWidth(Const St:String):Integer; overload; virtual;
Function TextHeight(Const St:String):Integer; overload; virtual;
{$IFDEF TEEUNICODE}
Function TextWidth(Const St:WideString):Integer; overload; virtual;
Function TextHeight(Const St:WideString):Integer; overload; virtual;
{$ENDIF}
{ 2d extra }
procedure ClipRectangle(Const Rect:TRect); overload; virtual; abstract;
Procedure ClipRectangle(Const Rect:TRect; RoundSize:Integer); overload; virtual;
Procedure ClipEllipse(Const Rect:TRect; Inverted:Boolean=False); virtual;
Procedure ClipPolygon(const Points:Array of TPoint; NumPoints:Integer;
DiffRegion:Boolean=False); virtual;
// Returns modified Points array with sorted points that define
// biggest convex polygon.
// Written by Peter Bone : peterbone@hotmail.com
function ConvexHull(var Points : TPointArray) : Boolean;
Procedure DoHorizLine(X0,X1,Y:Integer); virtual;
Procedure DoRectangle(Const Rect:TRect); {$IFDEF D11}deprecated 'Please use Rectangle method.';{$ENDIF} // Do not localize
Procedure DoVertLine(X,Y0,Y1:Integer); virtual;
procedure EraseBackground(const Rect: TRect); virtual; abstract;
Procedure GradientFill( Const Rect:TRect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -