⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teengine.pas

📁 TeeChart Pro v7.04,Delphi图表专用控件,可以生成多种图表
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    procedure DoOnBeforeDrawAxes; virtual;
    procedure DoOnBeforeDrawChart; virtual;
    procedure DoOnBeforeDrawSeries; virtual;
    procedure DrawTitlesAndLegend(BeforeSeries:Boolean); virtual; abstract;
    Function DrawBackWallAfter(Z:Integer):Boolean; virtual;
    Procedure DrawWalls; virtual; abstract;
    Procedure InternalDraw(Const UserRectangle: TRect); override;
    Function IsAxisVisible(Axis:TChartAxis):Boolean;
    Function MultiLineTextWidth(S:String; Var NumLines:Integer):Integer;
    procedure RemovedDataSource( ASeries: TChartSeries;
                                 AComponent: TComponent ); dynamic;
    Procedure SetPage(Value:Integer);

    {$IFNDEF CLR}
    Procedure GetChildren(Proc:TGetChildProc; Root:TComponent); override;
    {$ENDIF}

    {$IFNDEF CLX}
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    {$ELSE}
    procedure MouseLeave(AControl: TControl); override;
    {$ENDIF}
  public
    { Public declarations }
    Designer : TTeeCustomDesigner; { used only at Design-Time }
    ColorPalette : TColorArray;

    Constructor Create(AOwner: TComponent); override;
    Destructor Destroy; override;

    { public methods }
    procedure Assign(Source:TPersistent); override;
    Function ActiveSeriesLegend(ItemIndex:Integer):TChartSeries;
    Function AddSeries(const ASeries:TChartSeries):TChartSeries; overload;  { 5.01 }
    Function AddSeries({$IFNDEF BCB}const{$ENDIF} ASeriesClass:TChartSeriesClass):TChartSeries; overload;

    {$IFNDEF BCB}
    procedure AddSeries(const SeriesArray:Array of TChartSeries); overload;
    {$ENDIF}

    Procedure CalcSize3DWalls;
    Procedure CheckDatasource(ASeries:TChartSeries); virtual;
    Function CountActiveSeries:Integer;
    Procedure ExchangeSeries(a,b:Integer); overload;
    Procedure ExchangeSeries(a,b:TCustomChartSeries); overload;
    Function FormattedValueLegend(ASeries:TChartSeries; ValueIndex:Integer):String; virtual;
    Procedure FreeAllSeries( SeriesClass:TChartSeriesClass=nil );
    Function GetAxisSeries(Axis:TChartAxis):TChartSeries;

    {$IFDEF CLR}
    Procedure GetChildren(Proc:TGetChildProc; Root:TComponent); override;
    {$ENDIF}

    Function GetDefaultColor(Index:Integer):TColor;
    Function GetFreeSeriesColor(CheckBackground:Boolean=True; Series:TChartSeries=nil):TColor;
    Function GetMaxValuesCount:Integer;
    Function IsFreeSeriesColor(AColor: TColor; CheckBackground: Boolean;
                               Series:TChartSeries=nil):Boolean; virtual; abstract;
    Function IsValidDataSource(ASeries: TChartSeries; AComponent: TComponent):Boolean; dynamic;
    Function MaxXValue(AAxis: TChartAxis):Double;
    Function MaxYValue(AAxis: TChartAxis):Double;
    Function MinXValue(AAxis: TChartAxis):Double;
    Function MinYValue(AAxis: TChartAxis):Double;
    Function MaxMarkWidth:Integer;
    Function MaxTextWidth:Integer;
    Function NumPages:Integer; dynamic;
    procedure PrintPages(FromPage: Integer=1; ToPage: Integer=0);
    Procedure RemoveSeries(ASeries: TCustomChartSeries); overload;
    Procedure RemoveSeries(SeriesIndex: Integer); overload;

    property Series[Index: Integer]:TChartSeries read GetSeries; default;
    Function SeriesCount:Integer; //{$IFDEF D9}inline;{$ENDIF}

    Function SeriesLegend(ItemIndex: Integer; OnlyActive: Boolean):TChartSeries;
    Function SeriesTitleLegend(SeriesIndex: Integer; OnlyActive: Boolean=False):String;

    { public properties }
    property Axes:TChartAxes read FAxes;
    property AxesList:TChartAxes read FAxes; // compatibility v4
    property CustomAxes:TChartCustomAxes read FCustomAxes write SetCustomAxes stored IsCustomAxesStored;
    property MaxZOrder:Integer read FMaxZOrder write FMaxZOrder;
    property SeriesWidth3D:Integer read FSeriesWidth3D;
    property SeriesHeight3D:Integer read FSeriesHeight3D;

    { to be published properties }
    property AxisBehind:Boolean read FAxisBehind write SetAxisBehind default True;
    property AxisVisible:Boolean read FAxisVisible write SetAxisVisible default True;
    property BottomAxis:TChartAxis read FBottomAxis write SetBottomAxis;
    property Chart3DPercent:Integer read F3DPercent write Set3DPercent
                                    default TeeDef3DPercent;  // obsolete;
    property ClipPoints:Boolean read FClipPoints write SetClipPoints default True;
    property Color;
    property DepthAxis:TChartDepthAxis read FDepthAxis write SetDepthAxis;
    property DepthTopAxis:TChartDepthAxis read FDepthTopAxis write SetDepthTopAxis; // 7.0
    property LeftAxis:TChartAxis read FLeftAxis write SetLeftAxis;
    property MaxPointsPerPage:Integer read FMaxPointsPerPage write SetMaxPointsPerPage default 0;
    property Page:Integer read FPage write SetPage default 1;
    property RightAxis:TChartAxis read FRightAxis write SetRightAxis;
    property ScaleLastPage:Boolean read FScaleLastPage write SetScaleLastPage default True;
    property SeriesList:TChartSeriesList read FSeriesList;
    property Tools:TChartTools read FTools;
    property TopAxis:TChartAxis read FTopAxis write SetTopAxis;
    property View3DWalls:Boolean read FView3DWalls write SetView3DWalls default True;

    { to be published events }
    property OnBeforeDrawChart: TNotifyEvent read FOnBeforeDrawChart write FOnBeforeDrawChart;
    property OnBeforeDrawAxes:TNotifyEvent read FOnBeforeDrawAxes write FOnBeforeDrawAxes;
    property OnBeforeDrawSeries:TNotifyEvent read FOnBeforeDrawSeries write FOnBeforeDrawSeries;
    property OnGetAxisLabel:TAxisOnGetLabel read FOnGetAxisLabel write FOnGetAxisLabel;
    property OnGetNextAxisLabel:TAxisOnGetNextLabel read FOnGetNextAxisLabel
                                                    write FOnGetNextAxisLabel;
    property OnPageChange:TNotifyEvent read FOnPageChange write FOnPageChange;
  end;

  TSeriesMarkPosition=class
  public
    ArrowFrom : TPoint;
    ArrowFix  : Boolean;
    ArrowTo   : TPoint;
    Custom    : Boolean;
    Height    : Integer;
    LeftTop   : TPoint;
    Width     : Integer;
    Procedure Assign(Source:TSeriesMarkPosition);
    Function Bounds:TRect;
  end;

  TSeriesMarksPositions=class {$IFDEF CLR}sealed{$ENDIF} (TList)
  private
    Function Get(Index:Integer):TSeriesMarkPosition;
    Procedure Put(Index:Integer; APosition:TSeriesMarkPosition);
  public
    Procedure Automatic(Index:Integer);
    procedure Clear; override;
    Function ExistCustom:Boolean;
    property Position[Index:Integer]:TSeriesMarkPosition read Get
                                    write Put; default;
  end;

  TMarksItem=class {$IFDEF CLR}sealed{$ENDIF} (TTeeCustomShape)
  published
    property Bevel;
    property BevelWidth;
    property Color default ChartMarkColor;
    property Font;
    property Gradient;
    property Shadow;
    property ShapeStyle;
    property Transparency;
    property Transparent;
  end;

  TMarksItems=class {$IFDEF CLR}sealed{$ENDIF} (TList)
  private
    IMarks : TTeeCustomShape;
    ILoadingCustom : Boolean;
    function Get(Index:Integer):TMarksItem;
  public
    Procedure Clear; override;
    property Format[Index:Integer]:TMarksItem read Get; default;
  end;

  TSeriesMarksStyle=( smsValue,             { 1234 }
                      smsPercent,           { 12 % }
                      smsLabel,             { Cars }
                      smsLabelPercent,      { Cars 12 % }
                      smsLabelValue,        { Cars 1234 }
                      smsLegend,            { (Legend.Style) }
                      smsPercentTotal,      { 12 % of 1234 }
                      smsLabelPercentTotal, { Cars 12 % of 1234 }
                      smsXValue,            { 1..2..3.. or 21/6/1996 }
                      smsXY                 { 123 456 }
                      );

  TSeriesMarksGradient=class {$IFDEF CLR}sealed{$ENDIF} (TChartGradient)
  public
    Constructor Create(ChangedEvent:TNotifyEvent); override;
  published
    property Direction default gdRightLeft;
    property EndColor default clWhite;
    property StartColor default clSilver;
  end;

  TSeriesPointerStyle=( psRectangle,psCircle,psTriangle,psDownTriangle,
                        psCross,psDiagCross,psStar,psDiamond,psSmallDot,
                        psNothing,psLeftTriangle,psRightTriangle );

  TSeriesPointer=class(TTeeCustomShapeBrushPen)
  private
    FDark3D    : Boolean;
    FDraw3D    : Boolean;
    FGradient  : TTeeGradient;
    FHorizSize : Integer;
    FInflate   : Boolean;
    FSeries    : TChartSeries;
    FStyle     : TSeriesPointerStyle;
    FTransparency : TTeeTransparency; // 6.02
    FVertSize  : Integer;

    Procedure CheckPointerSize(Value:Integer);
    function GetColor: TColor;
    function GetSize:Integer; // 7.01
    function GetStartZ:Integer;   // 6.01
    function GetMiddleZ:Integer;  // 6.01
    function GetEndZ:Integer;     // 6.01
    procedure SetColor(const Value: TColor);
    Procedure SetDark3D(Value:Boolean);
    Procedure SetDraw3D(Value:Boolean);
    procedure SetGradient(const Value: TTeeGradient);
    Procedure SetHorizSize(Value:Integer);
    Procedure SetInflate(Value:Boolean);
    procedure SetSize(const Value:Integer); // 7.01
    Procedure SetStyle(Value:TSeriesPointerStyle);
    procedure SetTransparency(const Value: TTeeTransparency);
    Procedure SetVertSize(Value:Integer);
  protected
    AllowChangeSize : Boolean;
    FullGradient    : Boolean;
    Procedure CalcHorizMargins(Var LeftMargin,RightMargin:Integer);
    Procedure CalcVerticalMargins(Var TopMargin,BottomMargin:Integer);
    Procedure Change3D(Value:Boolean);
    Procedure ChangeHorizSize(NewSize:Integer);
    Procedure ChangeStyle(NewStyle:TSeriesPointerStyle);
    Procedure ChangeVertSize(NewSize:Integer);
    Procedure Prepare;
  public
    Constructor Create(AOwner:TChartSeries);
    Destructor Destroy; override;

    Procedure Assign(Source:TPersistent); override;

    Procedure Draw(P:TPoint); overload;
    Procedure Draw(X,Y:Integer); overload;
    Procedure Draw(px,py:Integer; ColorValue:TColor; AStyle:TSeriesPointerStyle); overload;
    Procedure DrawPointer( ACanvas:TCanvas3D;
                           Is3D:Boolean; px,py,tmpHoriz,tmpVert:Integer;
                           ColorValue:TColor; AStyle:TSeriesPointerStyle);
    Procedure PrepareCanvas(ACanvas:TCanvas3D; ColorValue:TColor);

    property Color:TColor read GetColor write SetColor;
    property ParentSeries:TChartSeries read FSeries;
    property Size:Integer read GetSize write SetSize;  // do not move to published
  published
    property Brush;
    property Dark3D:Boolean read FDark3D write SetDark3D default True;
    Property Draw3D:Boolean read FDraw3D write SetDraw3D default True;
    property Gradient:TTeeGradient read FGradient write SetGradient; // 6.0
    Property HorizSize:Integer read FHorizSize write SetHorizSize default 4;
    property InflateMargins:Boolean read FInflate write SetInflate;
    property Pen;
    property Style:TSeriesPointerStyle read FStyle write SetStyle;
    property Transparency:TTeeTransparency read FTransparency write SetTransparency default 0;
    Property VertSize:Integer read FVertSize write SetVertSize default 4;
    Property Visible;
  end;

  TArrowHeadStyle=(ahNone,ahLine,ahSolid);

  TChartArrowPen=TWhitePen;

  TCallout=class(TSeriesPointer)
  private
    FArrow     : TChartArrowPen;
    FArrowHead : TArrowHeadStyle;
    FDistance  : Integer;
    FArrowHeadSize: Integer;

    procedure SetDistance(const Value: Integer);
    procedure SetArrow(const Value: TChartArrowPen);
    procedure SetArrowHead(const Value: TArrowHeadStyle);
    procedure SetArrowHeadSize(const Value: Integer);
  protected
    procedure Draw(AColor:TColor; AFrom,ATo:TPoint; Z:Integer); overload;
  public
    Constructor Create(AOwner:TChartSeries);
    Procedure Assign(Source:TPersistent); override;
    destructor Destroy; override;
  published
    property Arrow:TChartArrowPen read FArrow write SetArrow;
    property ArrowHead:TArrowHeadStyle read FArrowHead write SetArrowHead default ahNone;
    property ArrowHeadSize:Integer read FArrowHeadSize write SetArrowHeadSize default 8;
    property Distance:Integer read FDistance write SetDistance default 0;
    property Draw3D default False;
    property InflateMargins default True;
    property Style default psRectangle;
    property Visible default True;
  end;

  TMarksCallout=class(TCallout)
  private
    FLength : Integer;

    procedure ApplyArrowLength(APosition:TSeriesMarkPosition);
    Function IsLengthStored:Boolean;
    procedure SetLength(const Value:Integer);
  protected
    DefaultLength : Integer;
  public
    Constructor Create(AOwner: TChartSeries);
    Procedure Assign(Source:TPersistent); override;
  published
    property Length:Integer read FLength write SetLength stored IsLengthStored;
    property Visible default False;
  end;

  TSeriesMarksSymbol=class {$IFDEF CLR}sealed{$ENDIF} (TTeeCustomShape)
  private
    Function ShouldDraw:Boolean;
  public
    Constructor Create(AOwner:TCustomTeePanel); override;
  published
    property Bevel;  { 5.01 }
    property BevelWidth;  { 5.01 }
    property Brush;
    property Frame;
    property Gradient;
    property Pen;
    property Shadow;
    property ShapeStyle;
    property Transparency; { 5.01 }
    property Visible default False;
  end;

  // CLR Note: This class cannot be marked as "sealed"
  // due to required cast access tricks.
  TSeriesMarks=class(TTeeCustomShape)
  private
    FAngle       : Integer;
    FCallout     : TMarksCallout;
    FClip        : Boolean;
    FDrawEvery   : Integer;
    FItems       : TMarksItems;
    FMarkerStyle : TSeriesMarksStyle;
    FMultiLine   : Boolean;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -