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

📄 teengine.pas

📁 Delphi TeeChartPro.6.01的源代码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    property Bevel;
    property BevelWidth;
    property Color default ChartMarkColor;
    property Font;
    property Gradient;
    property Shadow;
    property ShapeStyle;
    property Transparency;
    property Transparent;
  end;

  TMarksItems=class(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(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;
    FVertSize  : Integer;

    Procedure CheckPointerSize(Value:Integer);
    function GetColor: TColor;
    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 SetStyle(Value:TSeriesPointerStyle);
    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 PrepareCanvas; overload;
    Procedure PrepareCanvas(ACanvas:TCanvas3D; ColorValue:TColor); overload;
  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);

    property Color:TColor read GetColor write SetColor;
    property ParentSeries:TChartSeries read FSeries;
  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 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 SetLength(const Value:Integer);
  public
    constructor Create(AOwner: TChartSeries);
    Procedure Assign(Source:TPersistent); override;
  published
    property Length:Integer read FLength write SetLength;
    property Visible default False;
  end;

  TSeriesMarks=class(TTeeCustomShape)
  private
    FAngle       : Integer;
    FCallout     : TMarksCallout;
    FClip        : Boolean;
    FDrawEvery   : Integer;
    FItems       : TMarksItems;
    FMarkerStyle : TSeriesMarksStyle;
    FMultiLine   : Boolean;
    FParent      : TChartSeries;
    FPositions   : TSeriesMarksPositions;
    FZPosition   : Integer;

    function GetArrowLength: Integer;
    function GetArrowPen: TChartArrowPen;
    Function GetBackColor:TColor;
    function GetItem(Index:Integer):TMarksItem;
    Procedure InitShadow(AShadow:TTeeShadow);
    Procedure InternalDraw(Index:Integer; AColor:TColor; Const St:String; APosition:TSeriesMarkPosition);
    procedure ReadItems(Stream: TStream);
    Procedure SetAngle(Value:Integer);
    procedure SetCallout(const Value: TMarksCallout);
    Procedure SetArrowPen(const Value:TChartArrowPen);
    Procedure SetArrowLength(Value:Integer);
    Procedure SetBackColor(Value:TColor);
    Procedure SetClip(Value:Boolean);
    Procedure SetDrawEvery(Value:Integer);
    Procedure SetMultiline(Value:Boolean);
    Procedure SetStyle(Value:TSeriesMarksStyle);
    procedure WriteItems(Stream: TStream);
  protected
    Procedure AntiOverlap(First, ValueIndex:Integer; APosition:TSeriesMarkPosition);
    Procedure ConvertTo2D(APosition:TSeriesMarkPosition; var P:TPoint);
    procedure DefineProperties(Filer: TFiler); override;
    Function GetGradientClass:TChartGradientClass; override;
    Function MarkItem(ValueIndex:Integer):TTeeCustomShape;
    Function TextWidth(ValueIndex:Integer):Integer;
    Procedure UsePosition(Index:Integer; Var MarkPosition:TSeriesMarkPosition);
  public
    Constructor Create(AOwner:TChartSeries);
    Destructor Destroy; override;

    Procedure ApplyArrowLength(APosition:TSeriesMarkPosition);
    Procedure Assign(Source:TPersistent); override;
    procedure Clear;
    Function Clicked(X,Y:Integer):Integer;
    Procedure DrawText(Const R:TRect; Const St:String);

    property Item[Index:Integer]:TMarksItem read GetItem; default;
    property Items:TMarksItems read FItems;
    property ParentSeries:TChartSeries read FParent;
    property Positions:TSeriesMarksPositions read FPositions;
    procedure ResetPositions;
    property ZPosition : Integer read FZPosition write FZPosition;
  published
    property Angle:Integer read FAngle write SetAngle default 0;
    property Arrow:TChartArrowPen read GetArrowPen write SetArrowPen; // obsolete
    property ArrowLength:Integer read GetArrowLength write SetArrowLength; // obsolete
    property Callout:TMarksCallout read FCallout write SetCallout;  // 6.0
    property BackColor:TColor read GetBackColor write SetBackColor default ChartMarkColor;
    property Bevel;  { 5.01 }
    property BevelWidth;  { 5.01 }
    property Brush;
    property Clip:Boolean read FClip write SetClip default False;
    property Color default ChartMarkColor;
    property DrawEvery:Integer read FDrawEvery write SetDrawEvery default 1;
    property Font;
    property Frame;
    property Gradient;
    property MultiLine:Boolean read FMultiLine write SetMultiLine default False;
    property Shadow;
    property ShapeStyle;
    property Style:TSeriesMarksStyle read FMarkerStyle
                                     write SetStyle default smsLabel;
    property Transparency; { 5.01 }
    property Transparent;
    property Visible;
  end;

  TSeriesOnBeforeAdd=Function(Sender:TChartSeries):Boolean of object;
  TSeriesOnAfterAdd=Procedure(Sender:TChartSeries; ValueIndex:Integer) of object;
  TSeriesOnClear=Procedure(Sender:TChartSeries) of object;
  TSeriesOnGetMarkText=Procedure(Sender:TChartSeries; ValueIndex:Integer; Var MarkText:String) of object;

  TSeriesRecalcOptions=set of (rOnDelete, rOnModify, rOnInsert, rOnClear);

  TFunctionPeriodStyle=( psNumPoints, psRange );
  TFunctionPeriodAlign=( paFirst,paCenter,paLast );

  TTeeFunction=class(TComponent)
  private
    FPeriod      : Double;
    FPeriodStyle : TFunctionPeriodStyle;
    FPeriodAlign : TFunctionPeriodAlign;
    FParent      : TChartSeries;

    IUpdating    : Boolean;
    Procedure SetPeriod(Const Value:Double);
    Procedure SetParentSeries(AParent:TChartSeries);
    Procedure SetPeriodAlign(Value:TFunctionPeriodalign);
    Procedure SetPeriodStyle(Value:TFunctionPeriodStyle);
  protected
    CanUsePeriod     : Boolean;  // function uses Period property ?
    NoSourceRequired : Boolean;  // function requires source Series ?
    SingleSource     : Boolean;  // function allows more than one source ?
    HideSourceList   : Boolean;  // For single-source, allow select value-list ?

    Procedure AddFunctionXY(YMandatorySource:Boolean; const tmpX,tmpY:Double);
    Procedure CalculatePeriod( Source:TChartSeries;
                               Const tmpX:Double;
                               FirstIndex,LastIndex:Integer); virtual;
    Procedure CalculateAllPoints(Source:TChartSeries; NotMandatorySource:TChartValueList); virtual;
    Procedure CalculateByPeriod(Source:TChartSeries; NotMandatorySource:TChartValueList); virtual;
    Procedure DoCalculation( Source:TChartSeries;
                             NotMandatorySource:TChartValueList); virtual;
    class Function GetEditorClass:String; virtual;
    Procedure InternalSetPeriod(Const APeriod:Double);
    Function IsValidSource(Value:TChartSeries):Boolean; dynamic;
    class Procedure PrepareForGallery(Chart:TCustomAxisPanel); virtual;
    procedure SetParentComponent(Value: TComponent); override;
    Function ValueList(ASeries:TChartSeries):TChartValueList;
  public
    Constructor Create(AOwner: TComponent); override;
    Procedure Assign(Source:TPersistent); override;

    procedure AddPoints(Source:TChartSeries); dynamic;
    procedure BeginUpdate;
    Function Calculate(SourceSeries:TChartSeries; First,Last:Integer):Double; virtual;
    Function CalculateMany(SourceSeriesList:TList; ValueIndex:Integer):Double; virtual;
    procedure EndUpdate;
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    property ParentSeries:TChartSeries read FParent write SetParentSeries;
    Procedure ReCalculate;
  published
    property Period:Double read FPeriod write SetPeriod;
    property PeriodAlign:TFunctionPeriodAlign read FPeriodAlign
                                              write SetPeriodAlign default paCenter;
    property PeriodStyle:TFunctionPeriodStyle read FPeriodStyle
                                              write SetPeriodStyle default psNumPoints;
  end;

  TTeeMovingFunction=class(TTeeFunction)
  protected
    Procedure DoCalculation( Source:TChartSeries;
                             NotMandatorySource:TChartValueList); override;
  public
    Constructor Create(AOwner:TComponent); override;
  published
    property Period;
  end;

  TChartValueLists=class(TList)
  private
    Function Get(Index:Integer):TChartValueList;
  public
    Procedure Clear; override;
    property ValueList[Index:Integer]:TChartValueList read Get; default;
  end;

  TChartSeriesStyle=set of ( tssIsTemplate,
                             tssDenyChangeType,
                             tssDenyDelete,
                             tssDenyClone,
                             tssIsPersistent,
                             tssHideDataSource );

⌨️ 快捷键说明

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