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

📄 teengine.pas

📁 BCB第三方组件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  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 }
                      smsSeriesTitle,       { Series1 }  // 8.0
                      smsPointIndex,        { 1..2..3... } // 8.0
                      smsPercentRelative    { 100%..90%..120%... } // 8.0
                      );

  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,
                        psHexagon );

  TSeriesPointer=class(TTeeCustomShapeBrushPen)
  private
    FDark3D    : Boolean;
    FDraw3D    : Boolean;
    FGradient  : TTeeGradient;
    FHorizSize : Integer;
    FInflate   : Boolean;
    FSeries    : TChartSeries;
    FShadow    : TTeeShadow; // 8.01
    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 SetShadow(const Value:TTeeShadow);
    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 Shadow:TTeeShadow read FShadow write SetShadow;
    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={$IFDEF LCL}class(TWhitePen){$ELSE}TWhitePen{$ENDIF};

  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,AMid,ATo:TPoint; Z:Integer; MidPoint:Boolean=False); 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;
    property BevelWidth;
    property Brush;
    property Frame;
    property Gradient;
    property Pen;
    property Picture;
    property Shadow;
    property ShapeStyle;
    property Transparency;
    property Visible default False;
  end;

  TMarginUnits=(maPercentFont, maPercentSize, maPixels);

  TMargins=class(TPersistent)
  private
    FLeft   : Integer;
    FTop    : Integer;
    FRight  : Integer;
    FBottom : Integer;
    FUnits  : TMarginUnits;

    DefaultHoriz : Integer;
    ILast   : TRect;
    IParent : TTeeCustomShapeBrushPen;

    function IsLeftStored:Boolean;
    function IsRightStored:Boolean;
    procedure SetBottom(const Value: Integer);
    procedure SetDefaultHoriz(const Value:Integer);
    procedure SetIntegerProperty(var Variable: Integer; const Value: Integer);
    procedure SetLeft(const Value: Integer);
    procedure SetRight(const Value: Integer);
    procedure SetTop(const Value: Integer);
    procedure SetUnits(const Value: TMarginUnits);
  public
    Constructor Create(AParent:TTeeCustomShapeBrushPen);

    procedure Assign(Source:TPersistent); override;
    procedure Calculate(const Width,Height,FontSize:Integer);
    function HorizSize:Integer;
    function VertSize:Integer;

    property Size:TRect read ILast;
  published
    property Left:Integer read FLeft write SetLeft stored IsLeftStored;
    property Top:Integer read FTop write SetTop default 5;
    property Right:Integer read FRight write SetRight stored IsRightStored;
    property Bottom:Integer read FBottom write SetBottom default 5;
    property Units:TMarginUnits read FUnits write SetUnits default maPercentFont;
  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;
    FMargins     : TMargins;
    FMarkerStyle : TSeriesMarksStyle;
    FMultiLine   : Boolean;
    FSeries      : TChartSeries;
    FPositions   : TSeriesMarksPositions;
    FSymbol      : TSeriesMarksSymbol;
    FTextAlign   : TAlignment;
    FZPosition   : Integer;

    function GetArrowLength: Integer;
    function GetArrowPen: TChartArrowPen;
    Function GetBackColor:TColor;
    Function GetCallout:TMarksCallout;
    function GetItem(Index:Integer):TMarksItem;
    Function GetSymbol: TSeriesMarksSymbol;
    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 SetMargins(const Value:TMargins);
    Procedure SetMultiline(Value:Boolean);
    Procedure SetStyle(Value:TSeriesMarksStyle);
    procedure SetSymbol(const Value: TSeriesMarksSymbol);
    procedure SetTextAlign(const Value: TAlignment);
    procedure WriteItems(Stream: TStream);
  protected
    Procedure AntiOverlap(First, ValueIndex:Integer; APosition:TSeriesMarkPosition);
    function ConvertTo2D(Point,P:TPoint):TPoint;
    procedure DefineProperties(Filer: TFiler); override;
    Function GetGradientClass:TChartGradientClass; override;
    procedure InitShadow(AShadow:TTeeShadow); override;
    Function MarkItem(ValueIndex:Integer):TTeeCustomShape;
    procedure SetParent(Value:TCustomTeePanel); override;
    Function TextWidth(ValueIndex:Integer):Integer;
    Procedure UsePosition(Index:Integer; var MarkPosition:TSeriesMarkPosition);
  public
    Constructor Create(AOwner:TChartSeries); overload;
    Destructor Destroy; override;

    Procedure ApplyArrowLength(APosition:TSeriesMarkPosition);
    Procedure Assign(Source:TPersistent); override;
    procedure Clear;
    Function Clicked(X,Y:Integer):Integer;
    Procedure DrawItem(Shape:TTeeCustomShape; AColor:TColor;
                       const Text:String; APosition:TSeriesMarkPosition);
    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 FSeries;
    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 stored False; // obsolete
    property Callout:TMarksCallout read GetCallout write SetCallout;
    property BackColor:TColor read GetBackColor write SetBackColor default ChartMarkColor;
    property Bevel;
    property BevelWidth;
    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 Margins:TMargins read FMargins write SetMargins;
    property MultiLine:Boolean read FMultiLine write SetMultiLine default False;
    property Picture;
    property Shadow;
    property ShapeStyle;
    property Style:TSeriesMarksStyle read FMarkerStyle
                                     write SetStyle default smsLabel;
    property Symbol:TSeriesMarksSymbol read GetSymbol write SetSymbol;
    property TextAlign:TAlignment read FTextAlign write SetTextAlign default taCenter;
    property Transparency;
    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 );

  {$IFDEF CLR}
  [ToolBoxItem(False)]
  {$ENDIF}
  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

⌨️ 快捷键说明

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