cxgridbandedtableview.pas

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

PAS
1,455
字号
  protected
    procedure CreateControls; override;
    procedure InitPageControl; override;

    function GetBandsListBoxClass: TcxGridBandedTableBandsListBoxClass; virtual;

    property BandsListBox: TcxGridBandedTableBandsListBox read FBandsListBox;
    property GridView: TcxGridBandedTableView read GetGridView;
  public
    procedure RefreshData; override;
    property BandsPage: TcxTabSheet read FBandsPage;
  end;

  // popup

  TcxGridBandsCustomizationPopupClass = class of TcxGridBandsCustomizationPopup;

  TcxGridBandsCustomizationPopup = class(TcxCustomGridCustomizationPopup)
  private
    function GetGridView: TcxGridBandedTableView;
  protected
    procedure AddCheckListBoxItems; override;
    function GetDropDownCount: Integer; override;
    function SupportsItemMoving: Boolean; override;

    procedure ItemClicked(AItem: TObject; AChecked: Boolean); override;
    function GetItemIndex(AItem: TObject): Integer; override;
    procedure SetItemIndex(AItem: TObject; AIndex: Integer); override;
  public
    property GridView: TcxGridBandedTableView read GetGridView;
  end;

  // controller

  TcxGridBandedTableController = class(TcxGridTableController)
  private
    FBandsCustomizationPopup: TcxGridBandsCustomizationPopup;
    FForcingWidthBand: TcxGridBand;
    FMovingBand: TcxGridBand;
    FPressedBand: TcxGridBand;
    FSizingBand: TcxGridBand;
    FVertSizingColumn: TcxGridBandedColumn;
    function GetBandsCustomizationPopup: TcxGridBandsCustomizationPopup;
    function GetGridView: TcxGridBandedTableView;
    function GetIsBandMoving: Boolean;
    function GetIsBandSizing: Boolean;
    function GetIsColumnVertSizing: Boolean;
    function GetViewInfo: TcxGridBandedTableViewInfo;
    procedure SetPressedBand(Value: TcxGridBand);
  protected
    function GetBandsCustomizationPopupClass: TcxGridBandsCustomizationPopupClass; virtual;
    function GetColumnHeaderDragAndDropObjectClass: TcxGridColumnHeaderMovingObjectClass; override;
    procedure GetColumnNeighbors(AColumn: TcxGridBandedColumn; AGoForward: Boolean;
      AList: TList); virtual;
    function GetCustomizationFormClass: TcxCustomGridCustomizationFormClass; override;
    function GetDesignHitTest(AHitTest: TcxCustomGridHitTest): Boolean; override;
    function GetPatternObject(AObject: TPersistent): TPersistent; override;
    function IsBandFixedDuringSizing(ABand: TcxGridBand): Boolean; virtual;
    function IsColumnFixedDuringHorzSizing(AColumn: TcxGridColumn): Boolean; override;
    procedure LeftPosChanged; override;

    // cells selection
    function GetCellMultiSelect: Boolean; override;

    property ForcingWidthBand: TcxGridBand read FForcingWidthBand write FForcingWidthBand;
    property ViewInfo: TcxGridBandedTableViewInfo read GetViewInfo;
  public
    destructor Destroy; override;
    procedure DoCancelMode; override;
    procedure EndDragAndDrop(Accepted: Boolean); override;
    function HasBandsCustomizationPopup: Boolean;

    function FindNextColumnVertically(AFocusedItemIndex: Integer;
      AGoForward, AGoOnCycle: Boolean): Integer; virtual;
    function FindNextItem(AFocusedItemIndex: Integer;
      AGoForward, AGoOnCycle, AFollowVisualOrder: Boolean; out ACycleChanged: Boolean;
      ARecord: TcxCustomGridRecord): Integer; override;
    function FocusNextColumnVertically(AFocusedColumnIndex: Integer;
      AGoForward, AGoOnCycle: Boolean): Boolean;

    procedure KeyDown(var Key: Word; Shift: TShiftState); override;

    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

    property BandsCustomizationPopup: TcxGridBandsCustomizationPopup read GetBandsCustomizationPopup;
    property GridView: TcxGridBandedTableView read GetGridView;
    property IsBandMoving: Boolean read GetIsBandMoving;
    property IsBandSizing: Boolean read GetIsBandSizing;
    property IsColumnVertSizing: Boolean read GetIsColumnVertSizing;
    property MovingBand: TcxGridBand read FMovingBand;
    property PressedBand: TcxGridBand read FPressedBand write SetPressedBand;
    property SizingBand: TcxGridBand read FSizingBand;
    property VertSizingColumn: TcxGridBandedColumn read FVertSizingColumn;
  end;

  { painters }

  TcxGridBandHeaderPainter = class(TcxCustomGridCellPainter)
  private
    function GetViewInfo: TcxGridBandHeaderViewInfo;
  protected
    procedure DrawBorders; override;
    procedure DrawContent; override;
    procedure DrawPressed; virtual;
    function ExcludeFromClipRect: Boolean; override;
    procedure Paint; override;
    property ViewInfo: TcxGridBandHeaderViewInfo read GetViewInfo;
  end;

  TcxGridBandPainter = class(TcxCustomGridCellPainter)
  private
    function GetViewInfo: TcxGridBandViewInfo;
  protected
    procedure DrawChildBands; virtual;
    procedure DrawColumnHeaders; virtual;
    procedure DrawContent; override;
    procedure DrawHeader; virtual;
    function ExcludeFromClipRect: Boolean; override;
    property ViewInfo: TcxGridBandViewInfo read GetViewInfo;
  end;

  TcxGridBandedHeaderPainter = class(TcxGridHeaderPainter)
  private
    function GetViewInfo: TcxGridBandedHeaderViewInfo;
  protected
    procedure DrawBands; virtual;
    procedure DrawItems; override;
    property ViewInfo: TcxGridBandedHeaderViewInfo read GetViewInfo;
  end;

  TcxGridBandedFooterPainter = class(TcxGridFooterPainter)
  protected
    procedure DrawItems; override;
  end;

  TcxGridIndicatorBandHeaderItemPainter = class(TcxGridIndicatorHeaderItemPainter)
  private
   function GetViewInfo: TcxGridIndicatorBandHeaderItemViewInfo;
  protected
    function DrawBackgroundHandler(ACanvas: TcxCanvas; const ABounds: TRect): Boolean; override;
    property ViewInfo: TcxGridIndicatorBandHeaderItemViewInfo read GetViewInfo;
  end;

  TcxGridBandedDataRowCellsAreaItemPainter = class(TcxCustomGridCellPainter)
  private
    function GetViewInfo: TcxGridBandedDataRowCellsAreaItemViewInfo;
  protected
    procedure DrawFixedBandsSeparator; virtual;
    procedure DrawContent; override;
    procedure DrawLines; virtual;
    function ExcludeFromClipRect: Boolean; override;
    procedure Paint; override;
    property ViewInfo: TcxGridBandedDataRowCellsAreaItemViewInfo read GetViewInfo;
  end;

  TcxGridBandedRowsPainter = class(TcxGridRowsPainter)
  public
    class procedure DrawDataRowCells(ARowViewInfo: TcxCustomGridRowViewInfo); override;
  end;

  TcxGridBandedTablePainter = class(TcxGridTablePainter)
  private
    function GetViewInfo: TcxGridBandedTableViewInfo;
  protected
    function CanOffset(AItemsOffset, DX, DY: Integer): Boolean; override;
  public
    property ViewInfo: TcxGridBandedTableViewInfo read GetViewInfo;
  end;

  { view infos }

  // column container

  // column header

  TcxGridBandedColumnHeaderVertSizingEdgeViewInfo = class(TcxGridColumnHeaderAreaViewInfo)
  protected
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function GetAlignmentVert: TcxAlignmentVert; override;
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function OccupiesSpace: Boolean; override;
    function ResidesInContent: Boolean; override;
  public
    procedure Calculate(const ABounds: TRect; var ATextAreaBounds: TRect); override;
  end;

  TcxGridBandedColumnHeaderViewInfo = class(TcxGridColumnHeaderViewInfo)
  private
    function GetBandViewInfo: TcxGridBandViewInfo;
    function GetColumn: TcxGridBandedColumn;
    function GetContainer: TcxGridBandedHeaderViewInfo;
    function GetRowViewInfo: TcxGridBandRowViewInfo;
  protected
    function CanVertSize: Boolean; virtual;
    procedure GetAreaViewInfoClasses(AProc: TcxGridClassEnumeratorProc); override;
    function GetMaxWidth: Integer; override;
    property BandViewInfo: TcxGridBandViewInfo read GetBandViewInfo;
    property Container: TcxGridBandedHeaderViewInfo read GetContainer;
    property RowViewInfo: TcxGridBandRowViewInfo read GetRowViewInfo;
  public
    property Column: TcxGridBandedColumn read GetColumn;
  end;

  // bands

  TcxGridBandHeaderViewInfoClass = class of TcxGridBandHeaderViewInfo;

  TcxGridBandHeaderViewInfo = class(TcxCustomGridViewCellViewInfo)
  private
    FBandViewInfo: TcxGridBandViewInfo;
    function GetBand: TcxGridBand;
    function GetGridView: TcxGridBandedTableView;
    function GetGridViewInfo: TcxGridBandedTableViewInfo;
    function GetRowCount: Integer;
  protected
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function CanShowHint: Boolean; override;
    function CustomDraw(ACanvas: TcxCanvas): Boolean; override;
    function GetAlignmentHorz: TAlignment; override;
    function GetAlignmentVert: TcxAlignmentVert; override;
    function GetAreaBounds: TRect; override;
    function GetBackgroundBitmap: TBitmap; override;
    function GetBorders: TcxBorders; override;
    function GetBorderWidth(AIndex: TcxBorder): Integer; override;
    function GetCanvas: TcxCanvas; override;
    class function GetCellHeight(ATextHeight: Integer;
      ALookAndFeelPainter: TcxCustomLookAndFeelPainterClass): Integer; override;
    function GetHeight: Integer; override;
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
    function GetHotTrack: Boolean; override;
    function GetIsDesignSelected: Boolean; override;
    function GetIsPressed: Boolean; virtual;
    function GetMultiLinePainting: Boolean; override;
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function GetShowEndEllipsis: Boolean; override;
    function GetSizingEdgeBounds: TRect; virtual;
    function GetText: string; override;
    function GetVisible: Boolean; override;
    procedure GetViewParams(var AParams: TcxViewParams); override;
    function HasCustomDraw: Boolean; override;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;
    property SizingEdgeBounds: TRect read GetSizingEdgeBounds;
  public
    constructor Create(ABandViewInfo: TcxGridBandViewInfo); reintroduce; virtual;
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; override;
    function MouseDown(AHitTest: TcxCustomGridHitTest; AButton: TMouseButton;
      AShift: TShiftState): Boolean; override;
    property Band: TcxGridBand read GetBand;
    property BandViewInfo: TcxGridBandViewInfo read FBandViewInfo;
    property GridView: TcxGridBandedTableView read GetGridView;
    property GridViewInfo: TcxGridBandedTableViewInfo read GetGridViewInfo;
    property IsPressed: Boolean read GetIsPressed;
    property RowCount: Integer read GetRowCount;
  end;

  TcxGridBandRowViewInfoClass = class of TcxGridBandRowViewInfo;

  TcxGridBandRowViewInfo = class
  private
    FColumnViewInfos: TList;
    FHeight: Integer;
    FIndex: Integer;
    FRowsViewInfo: TcxGridBandRowsViewInfo;
    function GetBandRow: TcxGridBandRow;
    function GetBandViewInfo: TcxGridBandViewInfo;
    function GetColumnViewInfo(Index: Integer): TcxGridBandedColumnHeaderViewInfo;
    function GetColumnViewInfoCount: Integer;
    function GetGridView: TcxGridBandedTableView;
    function GetHeight: Integer;
    function GetLineHeight: Integer;
    function GetMinWidth: Integer;
    function GetWidth: Integer;
  protected
    procedure AddColumnViewInfos; virtual;
    procedure Calculate(const ABounds: TRect); virtual;
    procedure CalculateColumnWidths; virtual;
    function CalculateHeight: Integer; virtual;
    function CalculateLineHeight: Integer; virtual;
    function CalculateWidth: Integer; virtual;
    property GridView: TcxGridBandedTableView read GetGridView;
    property LineHeight: Integer read GetLineHeight;
  public
    Bounds: TRect;
    constructor Create(ARowsViewInfo: TcxGridBandRowsViewInfo; AIndex: Integer); virtual;
    destructor Destroy; override;
    procedure AssignColumnWidths;
    procedure Offset(DX, DY: Integer); virtual;
    property BandRow: TcxGridBandRow read GetBandRow;

⌨️ 快捷键说明

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