cxgridchartview.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,502 行 · 第 1/5 页

PAS
1,502
字号
  end;

  TcxGridChartDiagramValueViewInfoClass = class of TcxGridChartDiagramValueViewInfo;

  TcxGridChartDiagramValueViewInfo = class(TcxCustomGridViewCellViewInfo)
  private
    FCaptionViewInfo: TcxGridChartDiagramValueCaptionViewInfo;
    FDiagramViewInfo: TcxGridChartDiagramViewInfo;
    FSeriesIndex: Integer;
    FVisibleValueIndex: Integer;
    function GetController: TcxGridChartController;
    function GetDiagram: TcxGridChartDiagram;
    function GetGridView: TcxGridChartView;
    function GetSeries: TcxGridChartSeries;
    function GetValueIndex: Integer;
  protected
    function CalculateCaptionBounds: TRect; virtual; abstract;
    function CanShowHint: Boolean; override;
    function CustomDraw(ACanvas: TcxCanvas): Boolean; override;
    function GetCaptionViewInfoClass: TcxGridChartDiagramValueCaptionViewInfoClass; virtual;
    function GetCaptionText: string; virtual;
    procedure GetCaptionViewParams(var AParams: TcxViewParams); virtual;
    function GetCellBoundsForHint: TRect; override;
    function GetHintText: string; override;
    function GetHintTextRect(const AMousePos: TPoint): TRect; override;
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
    function GetHotTrack: Boolean; override;
    function GetIsDesignSelected: Boolean; override;
    procedure GetViewParams(var AParams: TcxViewParams); override;
    function HasCaption: Boolean; virtual;
    function HasCaptionVisualCompensation: Boolean; virtual;
    function HasCustomDraw: Boolean; override;
    function HasHintPoint(const P: TPoint): Boolean; override;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;
    function IsHintForText: Boolean; override;
    function IsHintMultiLine: Boolean; override;
    procedure StateChanged(APrevState: TcxGridCellState); override;

    property Controller: TcxGridChartController read GetController;
    property Diagram: TcxGridChartDiagram read GetDiagram;
  public
    constructor Create(ADiagramViewInfo: TcxGridChartDiagramViewInfo;
      ASeriesIndex, AVisibleValueIndex: Integer); reintroduce; virtual;
    destructor Destroy; override;
    procedure Calculate(ALeftBound, ATopBound: Integer; AWidth: Integer = -1;
      AHeight: Integer = -1); override;
    function MouseDown(AHitTest: TcxCustomGridHitTest; AButton: TMouseButton;
      AShift: TShiftState): Boolean; override;
    property CaptionViewInfo: TcxGridChartDiagramValueCaptionViewInfo read FCaptionViewInfo;
    property DiagramViewInfo: TcxGridChartDiagramViewInfo read FDiagramViewInfo;
    property GridView: TcxGridChartView read GetGridView;
    property Series: TcxGridChartSeries read GetSeries;
    property SeriesIndex: Integer read FSeriesIndex;
    property ValueIndex: Integer read GetValueIndex;
    property VisibleValueIndex: Integer read FVisibleValueIndex;
  end;

  TcxGridChartDiagramViewInfoClass = class of TcxGridChartDiagramViewInfo;

  TcxGridChartDiagramViewInfo = class(TcxCustomGridViewCellViewInfo)
  private
    FDiagram: TcxGridChartDiagram;
    FValueViewInfos: TList;
    function GetCategory(AIndex: Integer): string;
    function GetGridView: TcxGridChartView;
    function GetSeries(AIndex: Integer): TcxGridChartSeries;
    function GetSeriesCount: Integer;
    function GetValueCount: Integer;
    function GetValueViewInfoValue(Index: Integer): TcxGridChartDiagramValueViewInfo;
    function GetValueViewInfoCount: Integer;
    function GetViewData: TcxGridChartViewData;
  protected
    procedure GetViewParams(var AParams: TcxViewParams); override;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;

    function CreateValueViewInfo(ASeriesIndex, AVisibleValueIndex: Integer): TcxGridChartDiagramValueViewInfo;
    function GetValue(ASeriesIndex, AIndex: Integer): Variant; virtual;
    function GetValueCaption(ASeriesIndex, AVisibleValueIndex: Integer): string; virtual;
    function GetValueIndex(AVisibleValueIndex: Integer): Integer; virtual;
    class function GetValueViewInfoClass: TcxGridChartDiagramValueViewInfoClass; virtual;  // abstract; - because of CLR, BCB
    function GetValueViewInfoIndex(ASeriesIndex, AVisibleIndex: Integer): Integer; virtual; abstract;
    function GetVisibleCategory(AIndex: Integer): string; virtual;
    function GetVisibleValue(ASeriesIndex, AIndex: Integer): Variant; virtual;
    function GetVisibleValueCount: Integer; virtual;

    property Categories[AIndex: Integer]: string read GetCategory;
    property Values[ASeriesIndex, AIndex: Integer]: Variant read GetValue;
    property Series[AIndex: Integer]: TcxGridChartSeries read GetSeries;
  public
    constructor Create(AGridViewInfo: TcxCustomGridViewInfo; ADiagram: TcxGridChartDiagram); reintroduce; virtual;
    destructor Destroy; override;
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; override;
    function GetValueViewInfo(ASeriesIndex, AVisibleIndex: Integer): TcxGridChartDiagramValueViewInfo;
    property Diagram: TcxGridChartDiagram read FDiagram;
    property GridView: TcxGridChartView read GetGridView;
    property SeriesCount: Integer read GetSeriesCount;
    property ValueCount: Integer read GetValueCount;
    property ValueViewInfoCount: Integer read GetValueViewInfoCount;
    property ValueViewInfos[Index: Integer]: TcxGridChartDiagramValueViewInfo read GetValueViewInfoValue;
    property ViewData: TcxGridChartViewData read GetViewData;
    property VisibleCategories[AIndex: Integer]: string read GetVisibleCategory;
    property VisibleValueCount: Integer read GetVisibleValueCount;
    property VisibleValues[ASeriesIndex, AIndex: Integer]: Variant read GetVisibleValue;
  end;

  // histogram legend

  TcxGridChartHistogramLegendViewInfo = class(TcxGridChartLegendViewInfo)
  private
    function GetDiagram: TcxGridChartHistogram;
  protected
    function GetItemObjectIndex(AIndex: Integer): Integer; override;
    function GetItemsInReverseOrder: Boolean; virtual;
    function GetKind: TcxGridChartLegendKind; override;
    property ItemsInReverseOrder: Boolean read GetItemsInReverseOrder;
  public
    property Diagram: TcxGridChartHistogram read GetDiagram;
  end;

  // histogram

  TcxGridChartHistogramValueViewInfo = class(TcxGridChartDiagramValueViewInfo)
  private
    function GetCategoryDirection: TcxDirection;
    function GetDiagramViewInfo: TcxGridChartHistogramViewInfo;
    function GetValueDirection: TcxDirection;
  public
    property CategoryDirection: TcxDirection read GetCategoryDirection;
    property DiagramViewInfo: TcxGridChartHistogramViewInfo read GetDiagramViewInfo;
    property ValueDirection: TcxDirection read GetValueDirection;
  end;

  TcxGridChartHistogramAxisTitleViewInfoClass = class of TcxGridChartHistogramAxisTitleViewInfo;

  TcxGridChartHistogramAxisTitleViewInfo = class(TcxCustomGridChartTitleViewInfo)
  private
    FContainer: TcxGridChartHistogramTickMarkLabelsViewInfo;
    function GetTitle: TcxGridChartHistogramAxisTitle;
  protected
    procedure GetViewParams(var AParams: TcxViewParams); override;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;
  public
    constructor Create(AContainer: TcxGridChartHistogramTickMarkLabelsViewInfo;
      ATitle: TcxCustomGridChartTitle); reintroduce; virtual;
    property Container: TcxGridChartHistogramTickMarkLabelsViewInfo read FContainer;
    property Title: TcxGridChartHistogramAxisTitle read GetTitle;
  end;

  TcxGridChartAxisPosition = cppLeft..cppBottom;

  TcxGridChartHistogramTickMarkLabelsViewInfo = class(TcxCustomGridViewCellViewInfo)
  private
    FCaptionBounds: TRectArray;
    FCaptionHeight: Integer;
    FCaptionWidths: array of Integer;
    FDiagramViewInfo: TcxGridChartHistogramViewInfo;
    FIsTwoRowLayout: Boolean;
    FTitleViewInfo: TcxGridChartHistogramAxisTitleViewInfo;
    function GetCaptionBounds(Index: Integer): TRect;
    function GetCaptionHeight: Integer;
    function GetCaptionWidth(Index: Integer): Integer;
    function GetDiagram: TcxGridChartHistogram;
    function GetIsVertical: Boolean;
    procedure SetCaptionBounds(Index: Integer; const Value: TRect);
  protected
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function GetTitleViewInfoClass: TcxGridChartHistogramAxisTitleViewInfoClass; virtual;

    function GetCaption(Index: Integer): string; virtual;
    function GetCount: Integer; virtual; abstract;
    function GetIsReverseOrder: Boolean; virtual; abstract;
    function GetValue(Index: Integer): Variant; virtual; abstract;

    function CalculateCaptionBounds(AIndex: Integer): TRect; virtual;
    procedure CalculateCaptionsBounds; virtual;
    function CalculateHeight(AWidth, ALeftReduction, ARightReduction: Integer): Integer; {overload;}reintroduce; virtual;
    function CalculateWidth: Integer; override;
    function CalculateIsTwoRowLayout(AWidth, ALeftReduction, ARightReduction: Integer): Boolean; virtual;
    procedure CalculateTitleBounds(out ATitleBounds, AContentBounds: TRect); virtual;
    function GetAlignmentHorz: TAlignment; override;
    function GetAxis: TcxGridChartHistogramAxis; virtual; abstract;
    function GetCaptionPosition(AIndex: Integer): Integer; virtual; abstract;
    function GetCaptionsVisible: Boolean; virtual;
    procedure GetEdgeCaptionsReductions(var ALeftReduction, ARightReduction: Integer); virtual;
    function GetIsEdgeCaptions: Boolean; virtual; abstract;
    function GetPosition: TcxGridChartAxisPosition; virtual; abstract;
    function GetTextAttributes(AForPainting: Boolean): Integer; override;
    procedure GetTitleViewParams(var AParams: TcxViewParams); virtual; abstract;
    function GetVisible: Boolean; override;

    property Axis: TcxGridChartHistogramAxis read GetAxis;
    property CaptionHeight: Integer read GetCaptionHeight;
    property CaptionWidths[Index: Integer]: Integer read GetCaptionWidth;
    property Diagram: TcxGridChartHistogram read GetDiagram;
    property IsEdgeCaptions: Boolean read GetIsEdgeCaptions;
    property IsReverseOrder: Boolean read GetIsReverseOrder;
    property IsTwoRowLayout: Boolean read FIsTwoRowLayout write FIsTwoRowLayout;
    property IsVertical: Boolean read GetIsVertical;
  public
    constructor Create(ADiagramViewInfo: TcxGridChartHistogramViewInfo); reintroduce; virtual;
    destructor Destroy; override;
    procedure Calculate(ALeftBound, ATopBound: Integer; AWidth: Integer = -1;
      AHeight: Integer = -1); override;
    procedure FitCaptionsHorz(AWidth: Integer; var ALeftReduction, ARightReduction: Integer); virtual;
    procedure FitCaptionsVert(var ATopReduction, ABottomReduction: Integer); virtual;
    function GetCaptionSpace(AWidth, ALeftReduction, ARightReduction: Integer): Integer; virtual;
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; override;

    property CaptionBounds[Index: Integer]: TRect read GetCaptionBounds write SetCaptionBounds;
    property Captions[Index: Integer]: string read GetCaption;
    property CaptionsVisible: Boolean read GetCaptionsVisible;
    property Count: Integer read GetCount;
    property DiagramViewInfo: TcxGridChartHistogramViewInfo read FDiagramViewInfo;
    property Position: TcxGridChartAxisPosition read GetPosition;
    property TitleViewInfo: TcxGridChartHistogramAxisTitleViewInfo read FTitleViewInfo;
    property Values[Index: Integer]: Variant read GetValue;
  end;

  TcxGridChartHistogramCategoryAxisTitleViewInfo = class(TcxGridChartHistogramAxisTitleViewInfo)
  protected
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
  end;

  TcxGridChartHistogramCategoryTickMarkLabelsViewInfoClass = class of TcxGridChartHistogramCategoryTickMarkLabelsViewInfo;

  TcxGridChartHistogramCategoryTickMarkLabelsViewInfo = class(TcxGridChartHistogramTickMarkLabelsViewInfo)
  protected
    function GetTitleViewInfoClass: TcxGridChartHistogramAxisTitleViewInfoClass; override;

    function GetCount: Integer; override;
    function GetIsReverseOrder: Boolean; override;
    function GetValue(Index: Integer): Variant; override;

    function GetAxis: TcxGridChartHistogramAxis; override;
    function GetCaptionPosition(AIndex: Integer): Integer; override;
    function GetIsEdgeCaptions: Boolean; override;
    function GetPosition: TcxGridChartAxisPosition; override;
    procedure GetTitleViewParams(var AParams: TcxViewParams); override;
    procedure GetViewParams(var AParams: TcxViewParams); override;
  end;

  TcxGridChartHistogramValueAxisTitleViewInfo = class(TcxGridChartHistogramAxisTitleViewInfo)
  protected
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
  end;

  TcxGridChartHistogramValueTickMarkLabelsViewInfoClass = class of TcxGridChartHistogramValueTickMarkLabelsViewInfo;

  TcxGridChartHistogramValueTickMarkLabelsViewInfo = class(TcxGridChartHistogramTickMarkLabelsViewInfo)
  private
    function GetAxisValue: TcxGridChartHistogramAxisValue;
  protected
    function GetTitleViewInfoClass: TcxGridChartHistogramAxisTitleViewInfoClass; override;

    function GetCaption(Index: Integer): string; override;
    function GetCount: Integer; override;
    function GetIsReverseOrder: Boolean; override;
    function GetValue(Index: Integer): Variant; override;

    function GetAxis: TcxGridChartHistogramAxis; override;
    function GetCaptionPosition(AIndex: Integer): Integer; override;
    function GetIsEdgeCaptions: Boolean; override;
    function GetPosition: TcxGridChartAxisPosition; override;
    procedure GetTitleViewParams(var AParams: TcxViewParams); override;
    procedure GetViewParams(var AParams: TcxViewParams); override;

    property Axis: TcxGridChartHistogramAxisValue read GetAxisValue;
  end;

  TcxGridChartHistogramMark = record
    Value: Variant;
    Position: Integer;
  end;
  TcxGridChartHistogramMarks = array of TcxGridChartHistogramMark;

  TcxGridChartHistogramViewInfo = class(TcxGridChartDiagramViewInfo)
  private
    FCategoryTickMarkLabelsViewInfo: TcxGridChartHistogramCategoryTickMarkLabelsViewInfo;
    FCategoryMarkHeight: Integer;
    FCategoryMarks: TcxGridChartHistogramMarks;
    FHasValuesOutOfRange: Boolean;
    FIsPlotBoundsCalculated: Boolean;
    FMinValue: Extended;
    FMaxValue: Extended;
    FMinVisualValue: Extended;
    FMaxVisualValue: Extended;
    FPlotBounds: TRect;
    FSumOfValues: TVariantArray;
    FValueTickMarkLabelsViewInfo: TcxGridChartHistogramValueTickMarkLabelsViewInfo;
    FValueMarkHeight: Integer;
    FValueMarks: TcxGridChartHistogramMarks;
    FValueStep: Extended;
    function GetCategoryAxisColor: TColor;
    function GetCategoryGridLineColor: TColor;
    function GetCategoryMarkCount: Integer;
    function GetCategoryMarkPosition(Index: Integer): Integer;
    function GetCategoryMarkValue(Index: Integer): Integer;
    function GetDiag

⌨️ 快捷键说明

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