cxgridcardview.pas

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

PAS
1,418
字号
    function CaptureMouseOnPress: Boolean; override;
    procedure Click; override;
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
    function GetHotTrack: Boolean; override;
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function GetVisible: Boolean; override;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;
  public
    constructor Create(ACardViewInfo: TcxGridCardViewInfo); reintroduce; virtual;
    function HasPoint(const P: TPoint): Boolean; override;
    property CardViewInfo: TcxGridCardViewInfo read FCardViewInfo;
  end;

  // card row layout

  TcxGridCardRowLayerClass = class of TcxGridCardRowLayer;

  TcxGridCardRowLayer = class
  private
    FIndex: Integer;
    FLength: Integer;
    FOwner: TcxGridCardRowLayout;
    FThickness: Integer;
    function GetBounds: TRect;
    function GetLength: Integer;
    function GetRow(AIndex: Integer): TcxGridCardRowViewInfo;
    function GetRowCount: Integer;
    function GetThickness: Integer;
  protected
    procedure BeforeCalculation; virtual;
    function CalculateLength: Integer; virtual; abstract;
    function CalculateThickness: Integer; virtual; abstract;
    procedure SetThickness(Value: Integer); virtual;
  public
    constructor Create(AOwner: TcxGridCardRowLayout; AIndex: Integer); virtual;
    procedure Calculate(AOwnerWidth: Integer); virtual;
    procedure CalculateRows(const ABounds: TRect; ATopRowIndex: Integer;
      var AVisibleRowCount, APartVisibleRowCount: Integer); virtual; abstract;
    function HasPoint(const P: TPoint): Boolean; virtual; abstract;

    property Bounds: TRect read GetBounds;
    property Index: Integer read FIndex;
    property Length: Integer read GetLength;
    property Owner: TcxGridCardRowLayout read FOwner;
    property RowCount: Integer read GetRowCount;
    property Rows[Index: Integer]: TcxGridCardRowViewInfo read GetRow;
    property Thickness: Integer read GetThickness write SetThickness;
  end;

  TcxGridCardRowLayout = class(TcxGridCardVisibleRowLayoutObject)
  private
    FCardViewInfo: TcxGridCardViewInfo;
    FLayers: array of TcxGridCardRowLayer;
    FSeparatorWidth: Integer;
    FSimple: Boolean;
    function GetLayer(Index: Integer): TcxGridCardRowLayer;
    function GetLayerRowViewInfo(ALayerIndex, AIndex: Integer): TcxGridCardRowViewInfo;
    function GetSeparatorCount: Integer;
    procedure CreateLayers;
    procedure DestroyLayers;
  protected
    procedure BeforeCalculation; virtual;
    procedure CalculateLayerBounds(ALayer: TcxGridCardRowLayer; AMaxRowHeight: Integer;
      var ABounds: TRect); virtual; abstract;
    procedure CalculateLayers(AWidth: Integer); virtual;
    function CalculateRowsHeaderWidth(ARows: TList; AWidth: Integer): Integer; virtual;
    function GetLayerClass: TcxGridCardRowLayerClass; virtual;
    function GetLayersHeight: Integer; virtual; abstract;
    function GetLayersLength: Integer; virtual;
    function GetLayersThickness: Integer; virtual;
    function GetNonContentThickness: Integer; virtual;
    function HasSeparator(ALayer: TcxGridCardRowLayer): Boolean;
    function IsLayerVisible(ALayer: TcxGridCardRowLayer; ATopRowIndex: Integer): Boolean; overload; virtual;
    function IsLayerVisible(const ABounds, ALayerBounds: TRect): Boolean; overload; virtual;

    property LayersLength: Integer read GetLayersLength;
    property LayersThickness: Integer read GetLayersThickness;
    property NonContentThickness: Integer read GetNonContentThickness;
  public
    constructor Create(ACardViewInfo: TcxGridCardViewInfo; ASimple: Boolean); virtual;
    destructor Destroy; override;
    procedure Calculate(AWidth: Integer); virtual;
    procedure CalculateRows(const ABounds: TRect; ATopRowIndex, AMaxRowHeight: Integer;
      var AVisibleRowCount, APartVisibleRowCount: Integer); virtual;
    function GetHeaderWidth(ARowViewInfo: TcxGridCardRowViewInfo): Integer; virtual; abstract;
    function GetIndexInLayer(ARowViewInfo: TcxGridCardRowViewInfo): Integer; overload;
    function GetLayerIndex(ARowViewInfo: TcxGridCardRowViewInfo): Integer; overload;
    function GetLayerIndex(const P: TPoint): Integer; overload;
    function GetSeparatorBounds(AIndex: Integer): TRect; virtual; abstract;
    function IsLeft(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; virtual; abstract;
    function IsTop(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; virtual; abstract;
    function IsZoneVertical(AZone: TcxGridCardRowContainerZone): Boolean; virtual; abstract;

    property CardViewInfo: TcxGridCardViewInfo read FCardViewInfo;
    property LayerRowViewInfos[ALayerIndex, AIndex: Integer]: TcxGridCardRowViewInfo read GetLayerRowViewInfo;
    property LayersHeight: Integer read GetLayersHeight;
    property Layers[Index: Integer]: TcxGridCardRowLayer read GetLayer;
    property SeparatorCount: Integer read GetSeparatorCount;
    property SeparatorWidth: Integer read FSeparatorWidth write FSeparatorWidth;
    property Simple: Boolean read FSimple;
  end;

  // - horizontal

  TcxGridCardRowHorizontalLayer = class(TcxGridCardRowLayer)
  private
    function GetOwner: TcxGridCardRowHorizontalLayout;
  protected
    function CalculateLength: Integer; override;
    procedure CalculateRowWidths(AAvailableWidth: Integer); virtual;
    function CalculateThickness: Integer; override;
  public
    procedure Calculate(AOwnerWidth: Integer); override;
    procedure CalculateRows(const ABounds: TRect; ATopRowIndex: Integer;
      var AVisibleRowCount, APartVisibleRowCount: Integer); override;
    function HasPoint(const P: TPoint): Boolean; override;
    property Owner: TcxGridCardRowHorizontalLayout read GetOwner;
  end;

  TcxGridCardRowHorizontalLayout = class(TcxGridCardRowLayout)
  private
    FFirstColumnRowsHeaderWidth: Integer;
  protected
    function CalculateFirstColumnRowsHeaderWidth(AWidth: Integer): Integer; virtual;
    procedure CalculateLayerBounds(ALayer: TcxGridCardRowLayer; AMaxRowHeight: Integer;
      var ABounds: TRect); override;
    function GetLayerClass: TcxGridCardRowLayerClass; override;
    function GetLayersHeight: Integer; override;
    function IsLayerVisible(ALayer: TcxGridCardRowLayer; ATopRowIndex: Integer): Boolean; override;
    function IsLayerVisible(const ABounds, ALayerBounds: TRect): Boolean; override;
  public
    constructor Create(ACardViewInfo: TcxGridCardViewInfo; ASimple: Boolean); override;
    procedure Calculate(AWidth: Integer); override;
    function GetHeaderWidth(ARowViewInfo: TcxGridCardRowViewInfo): Integer; override;
    function GetSeparatorBounds(AIndex: Integer): TRect; override;
    function IsLeft(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; override;
    function IsTop(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; override;
    function IsZoneVertical(AZone: TcxGridCardRowContainerZone): Boolean; override;
    property FirstColumnRowsHeaderWidth: Integer read FFirstColumnRowsHeaderWidth;
  end;

  // - vertical

  TcxGridCardRowVerticalLayer = class(TcxGridCardRowLayer)
  private
    FRowsHeaderWidth: Integer;
  protected
    function CalculateLength: Integer; override;
    function CalculateRowsHeaderWidth: Integer; virtual;
    function CalculateThickness: Integer; override;
    procedure SetThickness(Value: Integer); override;
  public
    constructor Create(AOwner: TcxGridCardRowLayout; AIndex: Integer); override;
    procedure Calculate(AOwnerWidth: Integer); override;
    procedure CalculateRows(const ABounds: TRect; ATopRowIndex: Integer;
      var AVisibleRowCount, APartVisibleRowCount: Integer); override;
    function HasPoint(const P: TPoint): Boolean; override;
    property RowsHeaderWidth: Integer read FRowsHeaderWidth;
  end;

  TcxGridCardRowVerticalLayout = class(TcxGridCardRowLayout)
  protected
    procedure CalculateLayerBounds(ALayer: TcxGridCardRowLayer; AMaxRowHeight: Integer;
      var ABounds: TRect); override;
    procedure CalculateLayers(AWidth: Integer); override;
    procedure CalculateLayerWidths(AAvailableWidth: Integer); virtual;
    function GetLayerClass: TcxGridCardRowLayerClass; override;
    function GetLayersHeight: Integer; override;
  public
    function GetHeaderWidth(ARowViewInfo: TcxGridCardRowViewInfo): Integer; override;
    function GetSeparatorBounds(AIndex: Integer): TRect; override;
    function IsLeft(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; override;
    function IsTop(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; override;
    function IsZoneVertical(AZone: TcxGridCardRowContainerZone): Boolean; override;
  end;

  // card

  TcxGridCardViewInfo = class(TcxCustomGridRecordViewInfo)
  private
    FCol: Integer;
    FExpandButtonViewInfo: TcxGridCardExpandButtonViewInfo;
    FLayout: TcxGridCardRowLayout;
    FLayoutCalculated: Boolean;
    FPartVisibleRowCount: Integer;
    FRow: Integer;
    FRowViewInfos: TList;
    FScrollButtonDown: TcxGridCardScrollButtonDownViewInfo;
    FScrollButtonUp: TcxGridCardScrollButtonUpViewInfo;
    FVisibleRowCount: Integer;
    function GetCacheItem: TcxGridCardViewInfoCacheItem;
    function GetCardBorderWidth: Integer;
    function GetExpandButtonSizeValue: Integer;
    function GetFirstCaptionRowViewInfo: TcxGridCardRowViewInfo;
    function GetGridView: TcxGridCardView;
    function GetGridRecord: TcxGridCard;
    function GetRecordsViewInfo: TcxGridCardsViewInfo;
    function GetRowViewInfo(Index: Integer): TcxGridCardRowViewInfo;
    function GetRowViewInfoCount: Integer;
    function GetTopRowIndex: Integer;
    function GetVisibleRowViewInfo(Index: Integer): TcxGridCardRowViewInfo;
    function GetVisibleRowViewInfoCount: Integer;
    procedure SetTopRowIndex(Value: Integer);
    procedure CreateRowViewInfos;
    procedure DestroyRowViewInfos;
    procedure CreateScrollButtons;
    procedure DestroyScrollButtons;
  protected
    procedure CalculateExpandButtonBounds(var ABounds: TRect); override;
    function CalculateHeight: Integer; override;
    procedure CalculateLayout; virtual;
    procedure DoCalculateLayout;
    procedure CalculateRows; virtual;
    procedure CalculateRowVisibles; virtual;
    function CalculateWidth: Integer; override;
    function CanGenerateExpandButtonHitTest: Boolean; override;
    function GetAutoHeight: Boolean; override;
    function GetBackgroundBitmapBounds: TRect; override;
    function GetContentBounds: TRect; override;
    function GetContentHeight: Integer; override;
    function GetContentWidth: Integer; override;
    function GetExpandButtonAlignment: TcxGridCardExpandButtonAlignment; virtual;
    function GetExpandButtonAreaBounds: TRect; override;
    function GetExpandButtonAreaWidth: Integer; virtual;
    class function GetExpandButtonSize(ALookAndFeelPainter: TcxCustomLookAndFeelPainterClass): Integer; virtual;
    function GetHeight: Integer; override;
    function GetLayerSeparatorAreaBounds: TRect; virtual;
    function GetLayerSeparatorColor: TColor; virtual;
    function GetLayerSeparatorWidth: Integer; virtual;
    function GetMaxRowViewInfoHeight: Integer; virtual;
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function GetRestSpaceBounds: TRect; virtual;
    function GetScrollableAreaBounds: TRect; virtual;
    function GetScrollButtonDownBounds: TRect; virtual;
    function GetScrollButtonDownViewInfoClass: TcxGridCardScrollButtonDownViewInfoClass; virtual;
    function GetScrollButtonUpViewInfoClass: TcxGridCardScrollButtonUpViewInfoClass; virtual;
    function GetScrollButtonHeight: Integer; virtual;
    function GetScrollButtonUpBounds: TRect; virtual;
    procedure GetViewParams(var AParams: TcxViewParams); override;
    function GetVisible: Boolean; override;
    function GetWidth: Integer; override;
    function HasCategorySeparator(ARowViewInfo: TcxGridCardCategoryRowViewInfo): Boolean; overload; virtual;
    class function HasCategorySeparator(ARow: TcxGridCardViewRow): Boolean; overload; virtual;
    function HasIndent(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; virtual;
    function HasLayerSeparators: Boolean; virtual;
    function IsRowPartiallyVisible(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; virtual;
    function IsRowVisible(ARowViewInfo: TcxGridCardRowViewInfo): Boolean; virtual;
    function SupportsScrolling: Boolean; virtual;

    function GetZone(AHitTest: TcxCustomGridHitTest): TcxGridItemContainerZone; virtual;
    function GetZoneBounds(AZone: TcxGridCardRowContainerZone): TRect; virtual;
    function IsZoneVertical(AZone: TcxGridCardRowContainerZone): Boolean; virtual;

    function GetExpandButtonViewInfoClass: TcxGridCardExpandButtonViewInfoClass; virtual;
    class function GetRowViewInfoClass(ARow: TcxGridCardViewRow): TcxGridCardRowViewInfoClass; virtual;

    property CacheItem: TcxGridCardViewInfoCacheItem read GetCacheItem;
    property ExpandButtonAreaWidth: Integer read GetExpandButtonAreaWidth;
    property ExpandButtonSize: Integer read GetExpandButtonSizeValue;
    property FirstCaptionRowViewInfo: TcxGridCardRowViewInfo read GetFirstCaptionRowViewInfo;
    property LayerSeparatorWidth: Integer read GetLayerSeparatorWidth;
    property MaxRowViewInfoHeight: Integer read GetMaxRowViewInfoHeight;
    property ScrollButtonDownBounds: TRect read GetScrollButtonDownBounds;
    property ScrollButtonHeight: Integer read GetScrollButtonHeight;
    property ScrollButtonUpBounds: TRect read GetScrollButtonUpBounds;
  public
    constructor Create(ARecordsViewInfo: TcxCustomGridRecordsViewInfo;
      ARecord: TcxCustomGridRecord); override;
    destructor Destroy; override;
    procedure BeforeRecalculation; override;
    procedure Calculate(ALeftBound, ATopBound: Integer; AWidth: Integer = -1;
      AHeight: Integer = -1); override;
    function GetBoundsForItem(AItem: TcxCustomGridTableItem): TRect; override;
    procedure GetCardBorderViewParams(var AParams: TcxViewParams); virtual;
    function GetCellViewInfoByItem(AItem: TcxCustomGridTableItem): TcxGridTableDataCellViewInfo; override;
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; override;
    function IsFullyVisible: Boolean;
    procedure MainCalculate(ALeftBound, ATopBound: Integer); override;
    procedure MakeRowVisible(ARow: TcxGridCardViewRow); virtual;
    function NeedsScrollingDown: Boolean; virtual;
    function NeedsScrollingUp: Boolean; virtual;
    function VisibleRowViewInfoIndexOf(ARow: TcxGridCardViewRow): Integer; o

⌨️ 快捷键说明

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