📄 cxvgrid.pas
字号:
RowsCount: Integer;
BandHeight: Integer;
FirstRow: TcxCustomRow;
end;
TBandInfoList = class(TcxDataList)
private
function GetItem(Index: Integer): TBandInfo;
public
constructor Create;
function Add(ABandIndex, ARowsCount, ABandHeight: Integer;
AFirstRow: TcxCustomRow): Integer;
property Items[Index: Integer]: TBandInfo read GetItem; default;
end;
{ TcxvgCustomScrollStrategy }
TcxvgCustomScrollStrategy = class
private
FBandsInfo: TBandInfoList;
FCheckingCoordinate: Boolean;
FLeftVisibleRecord: Integer;
FTopVisibleRowIndex: Integer;
FScroller: TcxvgScroller;
FViewInfo: TcxvgCustomViewInfo;
function GetController: TcxvgController;
function GetDataController: TcxCustomDataController;
function GetScrollBarPos: Integer;
function GetVerticalGrid: TcxCustomVerticalGrid;
function GetVisibleRowCount: Integer;
procedure SetScrollBarPos(Value: Integer);
procedure SetTopVisibleRowIndex(Value: Integer);
protected
function CanContinueForward(Index: Integer): Boolean; virtual;
function CanContinueBackward(Index: Integer): Boolean; virtual;
function CanCalcRowsOnTheNextBand(ALeft, ANextBandIndex: Integer): Boolean; virtual;
procedure CheckLeftVisibleRecord(var AValue: Integer); virtual;
function GetBandInterval: Integer; virtual; abstract;
function GetBandWidth: Integer;
function GetBottomVisibleChild(ARow: TcxCustomRow): TcxCustomRow;
function GetFullRowHeight(ARow: TcxCustomRow; out ChildCount: Integer): Integer;
function GetLeftVisibleBand: Integer; virtual; abstract;
function GetScrollBarOffsetBegin: Integer; virtual;
function GetScrollBarOffsetEnd: Integer; virtual;
function GetVisibleBandCount: Integer; virtual; abstract;
function GetVisibleCount(ABeginIndex, AAreaHeight, AStep: Integer;
AForward: Boolean): Integer; virtual;
function GetVisibleValueCount: Integer; virtual; abstract;
function IsBehindRightClientEdge(X: Integer): Boolean;
function IsHideHScrollBar: Boolean; virtual;
function IsHideVScrollBar: Boolean; virtual;
function IsRecordsScrollMode: Boolean; virtual;
procedure ScrollH(AScrollCode: TScrollCode; var AScrollPos: Integer); virtual;
procedure ScrollV(AScrollCode: TScrollCode; var AScrollPos: Integer); virtual;
procedure SetLeftVisibleBand(Value: Integer); virtual; abstract;
procedure SetLeftVisibleRecord(Value: Integer); virtual;
procedure SetTopVisibleRowIndexAndBand(Index: Integer);
property Scroller: TcxvgScroller read FScroller;
property ScrollBarPos: Integer read GetScrollBarPos write SetScrollBarPos;
public
constructor Create(AScroller: TcxvgScroller); virtual;
destructor Destroy; override;
procedure CheckDecreaseLeftIndex; virtual;
procedure CheckDecreaseTopIndex(AScrollRectHeight: Integer); virtual;
function CheckTopVisibleIndex(AIndex, AStep: Integer): Integer; virtual;
function FindNextCustomItem(AFocusedItemIndex, AItemCount: Integer;
AGoForward: Boolean; var AItemIndex: Integer): Boolean;
function FindNextRecord(AFocusedRecordIndex: Integer; AGoForward: Boolean): Integer;
function FocusNextRecord(AFocusedRecordIndex: Integer; AGoForward: Boolean): Boolean;
function GetBandIndexByRowIndex(ARowIndex: Integer): Integer; virtual; abstract;
function GetVisibleCountFromBottom(ABottomIndex, AHeight: Integer): Integer;
function GetVisibleCountFromTop(ATopIndex, AHeight: Integer): Integer;
function GetFirstRowByBandIndex(ABandIndex: Integer): TcxCustomRow; virtual;
procedure InitHScrollBarParameters; virtual;
procedure InitVScrollBarParameters; virtual;
procedure RecalcBandsInfo; virtual;
procedure ScrollRecords(AForward: Boolean; ACount: Integer);
procedure SetRowMaxVisible(ARow: TcxCustomRow); virtual;
property BandInterval: Integer read GetBandInterval;
property BandWidth: Integer read GetBandWidth;
property BandsInfo: TBandInfoList read FBandsInfo;
property Controller: TcxvgController read GetController;
property DataController: TcxCustomDataController read GetDataController;
property LeftVisibleBand: Integer read GetLeftVisibleBand write SetLeftVisibleBand;
property LeftVisibleRecord: Integer read FLeftVisibleRecord write SetLeftVisibleRecord;
property ScrollBarOffsetBegin: Integer read GetScrollBarOffsetBegin;
property ScrollBarOffsetEnd: Integer read GetScrollBarOffsetEnd;
property TopVisibleRowIndex: Integer read FTopVisibleRowIndex write SetTopVisibleRowIndex;
property VerticalGrid: TcxCustomVerticalGrid read GetVerticalGrid;
property ViewInfo: TcxvgCustomViewInfo read FViewInfo;
property VisibleBandCount: Integer read GetVisibleBandCount;
property VisibleRowCount: Integer read GetVisibleRowCount;
property VisibleValueCount: Integer read GetVisibleValueCount;
end;
TcxvgCustomScrollStrategyClass = class of TcxvgCustomScrollStrategy;
{ TcxvgSingleRecordScrollStrategy }
TcxvgSingleRecordScrollStrategy = class(TcxvgCustomScrollStrategy)
protected
function GetBandInterval: Integer; override;
function GetLeftVisibleBand: Integer; override;
function GetVisibleBandCount: Integer; override;
function GetVisibleValueCount: Integer; override;
procedure SetLeftVisibleBand(Value: Integer); override;
public
function GetBandIndexByRowIndex(ARowIndex: Integer): Integer; override;
end;
{ TcxvgMultiRecordsScrollStrategy }
TcxvgMultiRecordsScrollStrategy = class(TcxvgCustomScrollStrategy)
private
function GetRecordsInterval: Integer;
protected
function GetBandInterval: Integer; override;
function GetLeftVisibleBand: Integer; override;
function GetVisibleBandCount: Integer; override;
function GetVisibleValueCount: Integer; override;
procedure SetLeftVisibleBand(Value: Integer); override;
procedure SetLeftVisibleRecord(Value: Integer); override;
property RecordsInterval: Integer read GetRecordsInterval;
public
procedure CheckDecreaseLeftIndex; override;
function GetBandIndexByRowIndex(ARowIndex: Integer): Integer; override;
end;
{ TcxvgBandsScrollStrategy }
TcxvgBandsScrollStrategy = class(TcxvgCustomScrollStrategy)
private
FLeftVisibleBand: Integer;
protected
function CanCalcRowsOnTheNextBand(ALeft, ANextBandIndex: Integer): Boolean; override;
function GetBandInterval: Integer; override;
function GetBandViewRowMaxVisibleTopIndex(ARow: TcxCustomRow): Integer;
function GetLeftVisibleBand: Integer; override;
function GetVisibleBandCount: Integer; override;
function GetVisibleValueCount: Integer; override;
function IsRecordsScrollMode: Boolean; override;
procedure SetLeftVisibleBand(Value: Integer); override;
public
procedure CheckDecreaseTopIndex(AScrollRectHeight: Integer); override;
function CheckTopVisibleIndex(AIndex, AStep: Integer): Integer; override;
function GetBandIndexByRowIndex(ARowIndex: Integer): Integer; override;
procedure InitHScrollBarParameters; override;
function IsHideVScrollBar: Boolean; override;
procedure RecalcBandsInfo; override;
procedure SetRowMaxVisible(ARow: TcxCustomRow); override;
end;
{ TcxvgScroller }
TcxvgScroller = class
private
FCheckDecreaseLeftIndex: Boolean;
FCheckDecreaseTopIndex: Boolean;
FScrollStrategy: TcxvgCustomScrollStrategy;
FVerticalGrid: TcxCustomVerticalGrid;
procedure CheckDecreaseLeftIndex;
procedure CheckDecreaseTopIndex;
function GetBandsInfo: TBandInfoList;
function GetCheckDecrease: Boolean;
function GetFocusedRecordIndex: Integer;
function GetLeftVisibleBand: Integer;
function GetLeftVisibleRecord: Integer;
function GetTopVisibleRowIndex: Integer;
function GetViewInfo: TcxvgCustomViewInfo;
function GetVisibleCountFromBottom(ARowIndex: Integer): Integer;
function GetVisibleRowCount: Integer;
function GetVisibleValueCount: Integer;
procedure SetCheckDecrease(Value: Boolean);
procedure SetLeftVisibleBand(Value: Integer);
procedure SetLeftVisibleRecord(Value: Integer);
procedure SetTopVisibleRowIndex(Value: Integer);
protected
function CreateScrollStrategy(AScroller: TcxvgScroller): TcxvgCustomScrollStrategy; virtual;
procedure LayoutStyleChanged;
// other
property FocusedRecordIndex: Integer read GetFocusedRecordIndex;
property ScrollStrategy: TcxvgCustomScrollStrategy read FScrollStrategy;
property VerticalGrid: TcxCustomVerticalGrid read FVerticalGrid;
property ViewInfo: TcxvgCustomViewInfo read GetViewInfo;
public
constructor Create(AVerticalGrid: TcxCustomVerticalGrid); virtual;
destructor Destroy; override;
// navigation
function GoToFirst: Boolean;
function GoToLast: Boolean;
function GoToNext: Boolean;
function GoToPrev: Boolean;
function GetBandIndexByRowIndex(ARowIndex: Integer): Integer;
procedure InitScrollBarsParameters; virtual;
procedure RecalcBandsInfo;
procedure RecreateScrollStrategy;
procedure Scroll(AScrollBarKind: TScrollBarKind; AScrollCode: TScrollCode; var AScrollPos: Integer);
function SetRecordVisible(ARecordIndex: Integer): Boolean; virtual;
procedure SetRowVisible(ARow: TcxCustomRow); virtual;
procedure SetRowMaxVisible(ARow: TcxCustomRow);
property BandsInfo: TBandInfoList read GetBandsInfo;
property CheckDecrease: Boolean read GetCheckDecrease write SetCheckDecrease;
property LeftVisibleBand: Integer read GetLeftVisibleBand write SetLeftVisibleBand;
property LeftVisibleRecord: Integer read GetLeftVisibleRecord write SetLeftVisibleRecord;
property TopVisibleRowIndex: Integer read GetTopVisibleRowIndex write SetTopVisibleRowIndex;
property VisibleRowCount: Integer read GetVisibleRowCount;
property VisibleValueCount: Integer read GetVisibleValueCount;
end;
{ TcxvgHitTest }
TcxvgHitTest = class(TcxCustomHitTestController)
private
FHitInControl: Boolean;
FHitBandIndex: Integer;
FHitRow: TcxCustomRow;
FHitCellIndex: Integer;
function GetHitAtRowHeader: Boolean;
function GetVerticalGrid: TcxCustomVerticalGrid;
protected
FNewHitTestItem: TObject;
function AllowDesignMouseEvents(X, Y: Integer; AShift: TShiftState): Boolean; override;
procedure CalcBandsHitTest(AViewInfo: TcxvgCustomViewInfo); virtual;
function CalcCustomizingHitTest: Boolean; virtual;
function CalcRowHeaderHitTest(AHeaderInfo: TcxCustomRowHeaderInfo): Boolean; virtual;
function CalcRowHitTest(ARowViewInfo: TcxCustomRowViewInfo): Boolean;
procedure CalcRowValuesHitTest(ARowViewInfo: TcxCustomRowViewInfo); virtual;
procedure CalcRowsHitTest(AViewInfo: TcxvgCustomViewInfo);
function CanMoving: Boolean; virtual;
function CanSizing: Boolean; overload;
function CanSizing(var ASizeDirection: TcxDragSizingDirection): Boolean; overload; virtual;
function Check(const ARect: TRect): Boolean;
procedure DoCalculate; override;
function GetCurrentCursor: TCursor; override;
function GetState(Index: Integer): Boolean;
procedure SetHitState(Index: Integer; Value: Boolean);
property VerticalGrid: TcxCustomVerticalGrid read GetVerticalGrid;
public
property HitAtBandSizing: Boolean index vghc_HitAtBandSizing read GetState;
property HitAtButton: Boolean index vghc_HitAtButton read GetState;
property HitAtCaption: Boolean index vghc_HitAtCaption read GetState;
property HitAtCustomize: Boolean index vghc_HitAtCustomize read GetState;
property HitAtDivider: Boolean index vghc_HitAtDivider read GetState;
property HitAtEmpty: Boolean index vghc_HitAtEmpty read GetState;
property HitAtImage: Boolean index vghc_HitAtImage read GetState;
property HitAtIndent: Boolean index vghc_HitAtIndent read GetState;
property HitAtRowHeader: Boolean read GetHitAtRowHeader;
property HitAtRowSizing: Boolean index vghc_HitAtRowSizing read GetState;
property HitAtValue: Boolean index vghc_HitAtValue read GetState;
property HitBandIndex: Integer read FHitBandIndex;
property HitInControl: Boolean read FHitInControl;
property HitRow: TcxCustomRow read FHitRow;
property HitCellIndex: Integer read FHitCellIndex;
end;
{ TcxvgCellNavigator }
TcxvgCellNavigator = class(TcxCustomCellNavigator)
private
function GetController: TcxvgController;
function GetRecordCount: Integer;
function GetRow(Index: Integer): TcxCustomRow;
function GetValueCount: Integer;
protected
procedure CalcNextRow(AForward: Boolean; var ARowIndex, ACellIndex: Integer); override;
function FindNextRecord(AForward: Boolean): Boolean;
function GetCellContainer(ARowIndex, ACellIndex: Integer): TcxCustomInplaceEditContainer; override;
function GetContainerCount(ARowIndex: Integer): Integer;
function GetCount(ARowIndex: Integer): Integer; override;
procedure Init(var ARowIndex, ACellIndex, ARowCount: Integer); override;
function MayFocusedEmptyRow(ARowIndex: Integer): Boolean; override;
procedure SetFocusCell(ARowIndex, ACellIndex: Integer; AShift: TShiftState = []); override;
public
constructor Create(AController: TcxCustomControlController); override;
procedure FocusNextCell(AForward, ANextRow: Boolean; AShift: TShiftState = []); override;
property RecordCount: Integer read GetRecordCount;
property Rows[Index: Integer]: TcxCustomRow read GetRow;
property Controller: TcxvgController read GetController;
property ValueCount: Integer read GetValueCount;
end;
{ TcxvgDragImageHelper }
TcxvgDragImageHelper = class(TcxDragImageHelper)
protected
procedure DragAndDrop(const P: TPoint); override;
function GetCursor: TCursor; virtual;
end;
{ TcxvgController }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -