cxgridrows.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,895 行 · 第 1/5 页
PAS
1,895 行
function TcxGridDataRowViewInfo.GetCellViewInfoCount: Integer;
begin
Result := FCellViewInfos.Count;
end;
function TcxGridDataRowViewInfo.GetGridRecord: TcxGridDataRow;
begin
Result := TcxGridDataRow(inherited GridRecord);
end;
function TcxGridDataRowViewInfo.GetHasPreview: Boolean;
begin
Result := FPreviewViewInfo <> nil;
end;
function TcxGridDataRowViewInfo.GetInternalCellViewInfo(Index: Integer): TcxGridDataCellViewInfo;
begin
Result := TcxGridDataCellViewInfo(FCellViewInfos[Index]);
end;
procedure TcxGridDataRowViewInfo.CreateViewInfos;
begin
FCellViewInfos := TList.Create;
FCellViewInfos.Count := GridViewInfo.HeaderViewInfo.Count;
FCellsAreaViewInfo := GetCellsAreaViewInfoClass.Create(Self);
if ShowPreview then
FPreviewViewInfo := GetPreviewViewInfoClass.Create(Self, GridView.Preview.Column);
end;
procedure TcxGridDataRowViewInfo.DestroyViewInfos;
var
I: Integer;
begin
FPreviewViewInfo.Free;
FCellsAreaViewInfo.Free;
for I := 0 to CellViewInfoCount - 1 do
InternalCellViewInfos[I].Free;
FCellViewInfos.Free;
end;
procedure TcxGridDataRowViewInfo.AfterRowsViewInfoCalculate;
var
I: Integer;
ACellViewInfo: TcxGridDataCellViewInfo;
begin
inherited;
for I := 0 to CellViewInfoCount - 1 do
begin
ACellViewInfo := InternalCellViewInfos[I];
if (ACellViewInfo <> nil) and ACellViewInfo.Calculated then
ACellViewInfo.AfterRowsViewInfoCalculate;
end;
end;
procedure TcxGridDataRowViewInfo.AfterRowsViewInfoOffset;
var
I: Integer;
ACellViewInfo: TcxGridDataCellViewInfo;
begin
inherited;
for I := 0 to CellViewInfoCount - 1 do
begin
ACellViewInfo := InternalCellViewInfos[I];
if ACellViewInfo <> nil then
ACellViewInfo.AfterRowsViewInfoOffset;
end;
end;
procedure TcxGridDataRowViewInfo.ApplyMergedCellsBounds(var R: TRect;
AItem: TcxCustomGridTableItem);
var
I: Integer;
procedure ProcessCell(ACellViewInfo: TcxGridDataCellViewInfo);
begin
if (ACellViewInfo <> nil) and ACellViewInfo.IsMerged then
with ACellViewInfo.MergingCell do
begin
if Bounds.Top < R.Top then
R.Top := Bounds.Top;
if Bounds.Bottom > R.Bottom then
R.Bottom := Bounds.Bottom;
end;
end;
begin
if AItem = nil then
for I := 0 to CellViewInfoCount - 1 do
ProcessCell(InternalCellViewInfos[I])
else
ProcessCell(InternalCellViewInfos[AItem.VisibleIndex]);
end;
procedure TcxGridDataRowViewInfo.ApplyMergingCellsBounds(var R: TRect);
var
I: Integer;
ACellViewInfo: TcxGridDataCellViewInfo;
begin
for I := 0 to CellViewInfoCount - 1 do
begin
ACellViewInfo := InternalCellViewInfos[I];
if (ACellViewInfo <> nil) and
ACellViewInfo.IsMerging and (ACellViewInfo.Bounds.Bottom > R.Bottom) then
R.Bottom := ACellViewInfo.Bounds.Bottom;
end;
end;
procedure TcxGridDataRowViewInfo.CalculateCellViewInfo(AIndex: Integer);
begin
CellViewInfos[AIndex].Calculate(GetCellLeftBound(AIndex), GetCellTopBound(AIndex),
-1, GetCellHeight(AIndex));
end;
function TcxGridDataRowViewInfo.CalculateHeight: Integer;
var
I, AHeight: Integer;
begin
if AutoHeight then
begin
Result := 0;
for I := 0 to CellViewInfoCount - 1 do
begin
AHeight := CellViewInfos[I].CalculateHeight;
if AHeight > Result then Result := AHeight;
end;
Result := RecordsViewInfo.GetCellHeight(Result);
if not TcxCustomGridTableViewAccess.IsGetCellHeightAssigned(GridView) then
with RecordsViewInfo do
if Result < DataRowHeight then Result := DataRowHeight;
end
else
Result := RecordsViewInfo.DataRowHeight;
if HasPreview then
Inc(Result, PreviewViewInfo.Height);
Inc(Result, inherited CalculateHeight);
end;
function TcxGridDataRowViewInfo.CanSize: Boolean;
begin
Result := RecordsViewInfo.CanDataRowSize;
end;
procedure TcxGridDataRowViewInfo.CheckRowHeight(var AValue: Integer);
begin
Dec(AValue, NonBaseHeight);
inherited;
GridView.OptionsView.CheckDataRowHeight(AValue);
Inc(AValue, NonBaseHeight);
end;
function TcxGridDataRowViewInfo.GetAutoHeight: Boolean;
begin
Result := RecordsViewInfo.AutoDataRecordHeight;
end;
function TcxGridDataRowViewInfo.GetBackgroundBitmapBounds: TRect;
begin
Result := inherited GetBackgroundBitmapBounds;
if HasPreview and (FPreviewViewInfo.BackgroundBitmap <> nil) then
with CellsAreaBounds do
begin
Result.Top := Top;
Result.Bottom := Bottom;
end;
end;
function TcxGridDataRowViewInfo.GetBaseHeight: Integer;
begin
Result := inherited GetBaseHeight;
if HasPreview then
Dec(Result, PreviewViewInfo.Height);
end;
function TcxGridDataRowViewInfo.GetPainterClass: TcxCustomGridCellPainterClass;
begin
Result := TcxGridDataRowPainter;
end;
procedure TcxGridDataRowViewInfo.Offset(DX, DY: Integer);
procedure OffsetCells;
var
I: Integer;
ACellViewInfo: TcxGridDataCellViewInfo;
begin
for I := 0 to CellViewInfoCount - 1 do
begin
ACellViewInfo := InternalCellViewInfos[I];
if IsCellVisible(I) then
if (ACellViewInfo = nil) or not ACellViewInfo.Calculated then
CalculateCellViewInfo(I)
else
ACellViewInfo.DoOffset(DX, DY)
else
if (DX <> 0) and (ACellViewInfo <> nil) then
begin
ACellViewInfo.Free;
FCellViewInfos[I] := nil;
end;
end;
end;
begin
inherited;
OffsetRect(FCellsAreaBounds, DX, DY);
OffsetCells;
FCellsAreaViewInfo.DoOffset(DX, DY);
if FPreviewViewInfo <> nil then
FPreviewViewInfo.DoOffset(DX, DY);
end;
procedure TcxGridDataRowViewInfo.SetRowHeight(Value: Integer);
begin
if RowHeight <> Value then
GridView.OptionsView.DataRowHeight := Value - NonBaseHeight;
end;
function TcxGridDataRowViewInfo.GetCellHeight(AIndex: Integer): Integer;
begin
if CellViewInfos[AIndex].IsMerging then
Result := InternalCellViewInfos[AIndex].Height
else
Result := GridViewInfo.GetCellHeight(AIndex, FCellHeight);
end;
function TcxGridDataRowViewInfo.GetCellHeightValue: Integer;
begin
if AutoHeight then
begin
Result := DataHeight;
if HasPreview then Dec(Result, PreviewViewInfo.Height);
end
else
Result := RecordsViewInfo.RowHeight;
end;
function TcxGridDataRowViewInfo.GetCellLeftBound(AIndex: Integer): Integer;
begin
Result := GridViewInfo.HeaderViewInfo[AIndex].DataOffset;
end;
function TcxGridDataRowViewInfo.GetCellTopBound(AIndex: Integer): Integer;
begin
Result := FCellsAreaBounds.Top + GridViewInfo.GetCellTopOffset(AIndex, FCellHeight);
end;
function TcxGridDataRowViewInfo.GetCellsAreaBounds: TRect;
begin
with Result do
begin
Left := DataIndent;
Right := Left + DataWidth;
Top := Bounds.Top;
Bottom := Top + DataHeight;
if HasPreview then
if PreviewViewInfo.Preview.Place = ppTop then
Inc(Top, PreviewViewInfo.Height)
else
Dec(Bottom, PreviewViewInfo.Height);
end;
end;
function TcxGridDataRowViewInfo.GetCellsAreaViewInfoClass: TcxGridDataRowCellsAreaViewInfoClass;
begin
Result := TcxGridDataRowCellsAreaViewInfoClass(RecordsViewInfo.GetDataRowCellsAreaViewInfoClass);
end;
function TcxGridDataRowViewInfo.GetCellViewInfoClass(AIndex: Integer): TcxGridDataCellViewInfoClass;
begin
Result := TcxGridDataCellViewInfo;
end;
function TcxGridDataRowViewInfo.GetCellWidth(AIndex: Integer): Integer;
begin
Result := GridViewInfo.HeaderViewInfo[AIndex].RealWidth;
end;
function TcxGridDataRowViewInfo.GetPreviewViewInfoClass: TcxGridPreviewCellViewInfoClass;
begin
Result := TcxGridPreviewCellViewInfo;
end;
function TcxGridDataRowViewInfo.GetShowPreview: Boolean;
begin
Result := GridView.Preview.Active;
end;
function TcxGridDataRowViewInfo.IsCellVisible(AIndex: Integer): Boolean;
begin
Result := GridViewInfo.HeaderViewInfo[AIndex].Visible;
end;
procedure TcxGridDataRowViewInfo.BeforeCellRecalculation(ACell: TcxGridTableCellViewInfo);
begin
end;
procedure TcxGridDataRowViewInfo.BeforeRecalculation;
var
I: Integer;
begin
inherited;
FCellsAreaViewInfo.BeforeRecalculation;
for I := 0 to CellViewInfoCount - 1 do
if InternalCellViewInfos[I] <> nil then
InternalCellViewInfos[I].BeforeRecalculation;
if FPreviewViewInfo <> nil then
FPreviewViewInfo.BeforeRecalculation;
end;
procedure TcxGridDataRowViewInfo.Calculate(ALeftBound, ATopBound: Integer;
AWidth: Integer = -1; AHeight: Integer = -1);
var
I: Integer;
procedure CalculatePreview;
function GetTopBound: Integer;
begin
if PreviewViewInfo.Preview.Place = ppTop then
Result := ATopBound
else
Result := FCellsAreaBounds.Bottom;
end;
begin
PreviewViewInfo.Calculate(FCellsAreaBounds.Left, GetTopBound);
end;
begin
inherited;
FCellsAreaBounds := CellsAreaBounds;
if HasPreview then CalculatePreview;
FCellHeight := CellHeight;
for I := 0 to CellViewInfoCount - 1 do
if IsCellVisible(I) then CalculateCellViewInfo(I);
if FCellsAreaViewInfo.Visible then
FCellsAreaViewInfo.Calculate(FCellsAreaBounds);
end;
function TcxGridDataRowViewInfo.GetAreaBoundsForPainting: TRect;
begin
Result := inherited GetAreaBoundsForPainting;
ApplyMergingCellsBounds(Result);
end;
function TcxGridDataRowViewInfo.GetBoundsForInvalidate(AItem: TcxCustomGridTableItem): TRect;
begin
Result := inherited GetBoundsForInvalidate(AItem);
if AItem = nil then
ApplyMergingCellsBounds(Result);
ApplyMergedCellsBounds(Result, AItem);
end;
function TcxGridDataRowViewInfo.GetBoundsForItem(AItem: TcxCustomGridTableItem): TRect;
begin
if InternalCellViewInfos[AItem.VisibleIndex] = nil then
Result := inherited GetBoundsForItem(AItem)
else
Result := InternalCellViewInfos[AItem.VisibleIndex].Bounds;
end;
function TcxGridDataRowViewInfo.GetCellBorders(AIsRight, AIsBottom: Boolean): TcxBorders;
begin
Result := GridViewInfo.GetCellBorders(AIsRight, AIsBottom);
end;
function TcxGridDataRowViewInfo.GetCellViewInfoByItem(AItem: TcxCustomGridTableItem): TcxGridTableDataCellViewInfo;
begin
if TcxGridColumn(AItem).IsPreview then
Result := FPreviewViewInfo
else
if (AItem.VisibleIndex = -1) or TcxCustomGrid(GridView.Control).UpdateLocked then
Result := nil
else
Result := InternalCellViewInfos[AItem.VisibleIndex];
end;
function TcxGridDataRowViewInfo.GetHitTest(const
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?