📄 cxexportvglink.pas
字号:
if FRow.IsRootLevel then Include(ABorders, bLeft);
if (PaintStyle = psDotNet) and IsCategory then
begin
Include(ABorders, bLeft);
if FRow.HasVisibleChildren then
Exclude(ABorders, bBottom);
end;
cxCheckBorders(AStyle, ABorders, GridLineColor, GridLines);
Info.StyleIndex := Provider.RegisterStyle(AStyle);
FList.Add(Info);
end;
procedure TcxRowIndentsInfo.AddParentIndents;
var
AEnd: Integer;
Info: PcxRowIndentData;
ABorders: TcxBorders;
ANeedBottom, ALastRow: Boolean;
AParent: TcxCustomRow;
AStyle: TcxCacheCellStyle;
begin
if FRow.IsRootLevel then Exit;
AParent := Row;
ALastRow := Row.VerticalGrid.LastVisibleRow = Row;
ANeedBottom := True;
repeat
AParent := AParent.Parent;
New(Info);
Info.IsCategory := AParent is TcxCategoryRow;
HeaderColumnsMap.GetColumnInfoFromLevel(AParent.Level, Info.Column, AEnd);
Info.Width := AEnd - Info.Column;
cxViewParamsToCacheStyle(GetHeaderViewParams(AParent), AStyle);
if PaintStyle = psDelphi then
begin
ABorders := [bTop, bBottom];
if AParent.IsRootLevel then Include(ABorders, bLeft);
end
else
begin
if Info.IsCategory then
begin
ANeedBottom := False;
ABorders := [bLeft, bRight];
if AParent.GetLastVisibleChild = FRow then
Include(ABorders, bBottom);
end
else
if (not IsCategory and ANeedBottom) or ALastRow then
ABorders := [bBottom]
else
ABorders := [];
end;
cxCheckBorders(AStyle, ABorders, GridLineColor, GridLines);
Info.StyleIndex := Provider.RegisterStyle(AStyle);
FList.Add(Info);
until AParent.IsRootLevel;
end;
procedure TcxRowIndentsInfo.Calculate(AHeaderColumnsMap: TcxColumnsMap;
AProvider: IcxExportProvider);
begin
FHeaderColumnsMap := AHeaderColumnsMap;
FHeaderInfo := TcxRowHeaderAccess(FRow.ViewInfo.HeaderInfo);
with FRow.VerticalGrid.OptionsView do
begin
FGridLines := GridLines;
FPaintStyle := PaintStyle;
FGridLineColor := GridLineColor;
end;
FProvider := AProvider;
AddFirstIndent;
AddParentIndents;
end;
function TcxRowIndentsInfo.GetCount: Integer;
begin
Result := FList.Count;
end;
function TcxRowIndentsInfo.GetIndent(Index: Integer): TcxRowIndentData;
begin
Result := PcxRowIndentData(FList[Index])^;
end;
{ TcxRowsIndents }
procedure TcxRowsIndents.Clear;
var
I: Integer;
begin
for I := 0 to Count - 1 do
TObject(Items[I]).Free;
inherited Clear;
end;
function TcxRowsIndents.GetIndent(Index: Integer): TcxRowIndentsInfo;
begin
Result := List^[Index];
end;
{ TcxRowCellsInfo }
function TcxRowCellsInfo.AddCaption(AColumn, AWidth,
AStyleIndex: Integer; const ACaption: string): Integer;
var
C: PRowCaptionCellInfo;
begin
New(C);
with C^ do
begin
Caption := ACaption;
Column := AColumn;
StyleIndex := AStyleIndex;
Width := AWidth;
end;
Result := Add(C);
end;
procedure TcxRowCellsInfo.Clear;
var
I: Integer;
begin
for I := 0 to Count - 1 do
Dispose(PRowCaptionCellInfo(inherited Items[I]));
inherited Clear;
end;
function TcxRowCellsInfo.GetItem(Index: Integer): TRowCaptionCellInfo;
begin
Result := TRowCaptionCellInfo(inherited Items[Index]^);
end;
{ TcxRowsCaptions }
function TcxRowsCaptions.AddCaption: TcxRowCellsInfo;
begin
Result := TcxRowCellsInfo.Create;
Add(Result);
end;
procedure TcxRowsCaptions.Clear;
var
I: Integer;
begin
for I := 0 to Count - 1 do
TObject(Items[I]).Free;
inherited Clear;
end;
function TcxRowsCaptions.GetCaption(Index: Integer): TcxRowCellsInfo;
begin
Result := List^[Index];
end;
{ TcxColumnsMap }
constructor TcxColumnsMap.Create;
begin
FElements := TList.Create;
NeedWidth := 0;
end;
destructor TcxColumnsMap.Destroy;
var
I: Integer;
begin
for I := 0 to FElements.Count - 1 do
Dispose(PElementInfo(FElements.List^[I]));
FElements.Free;
FColumnWidths := nil;
inherited Destroy;
end;
procedure TcxColumnsMap.AddRowCell(APos: Integer; ARow: TcxCustomRow;
ACellIndex, AWidth: Integer);
var
E: PElementInfo;
begin
New(E);
E.Pos := APos;
E.Width := AWidth;
E.IsLevel := False;
E.Row := ARow;
E.CellIndex := ACellIndex;
FElements.Add(E);
if AWidth > 0 then
begin
New(E);
E.Pos := APos + AWidth;
E.Width := 0;
E.IsLevel := False;
E.Row := ARow;
E.CellIndex := ACellIndex;
FElements.Add(E);
end;
end;
procedure TcxColumnsMap.AddLevel(ALevel, APos, AWidth: Integer);
var
E: PElementInfo;
begin
New(E);
E.Pos := APos;
E.Width := AWidth;
E.IsLevel := True;
E.Level := ALevel;
FElements.Add(E);
if AWidth > 0 then
begin
New(E);
E.Pos := APos + AWidth;
E.Width := 0;
E.IsLevel := True;
E.Level := ALevel;
FElements.Add(E);
end;
end;
function ComparePos(Item1, Item2: Pointer): Integer;
begin
Result := PElementInfo(Item1).Pos - PElementInfo(Item2).Pos;
end;
procedure TcxColumnsMap.Build;
var
I, AColumn, APos: Integer;
begin
FElements.Sort(ComparePos);
AColumn := 0;
APos := 0;
for I := 0 to FElements.Count - 1 do
with PElementInfo(FElements.List^[I])^ do
begin
if Pos > APos then
begin
SetLength(FColumnWidths, Succ(AColumn));
FColumnWidths[AColumn] := Pos - APos;
APos := Pos;
Inc(AColumn);
end;
ColumnStart := AColumn;
end;
for I := 0 to FElements.Count - 1 do
with PElementInfo(FElements.List^[I])^ do
if Width > 0 then ColumnEnd := FindColumnForPos(Pos + Width);
MaxColumnIndex := AColumn - 1;
end;
procedure TcxColumnsMap.CheckNeedWidth(APos: Integer);
begin
NeedWidth := Max(NeedWidth, APos);
end;
function TcxColumnsMap.FindColumnForPos(APos: Integer): Integer;
var
I: Integer;
begin
Result := -1;
for I := 0 to FElements.Count - 1 do
with PElementInfo(FElements.List^[I])^ do
if APos = Pos then
begin
Result := ColumnStart;
break;
end;
end;
procedure TcxColumnsMap.GetColumnInfoFromRowCell(ARow: TcxCustomRow;
ACellIndex: Integer; var AStart, AEnd: Integer);
var
I: Integer;
begin
for I := 0 to FElements.Count - 1 do
with PElementInfo(FElements.List^[I])^ do
if not IsLevel and (Row = ARow) and (CellIndex = ACellIndex) then
begin
AStart := ColumnStart;
AEnd := ColumnEnd;
break;
end;
end;
procedure TcxColumnsMap.GetColumnInfoFromLevel(ALevel: Integer;
var AStart, AEnd: Integer);
var
I: Integer;
begin
for I := 0 to FElements.Count - 1 do
with PElementInfo(FElements.List^[I])^ do
if IsLevel and (Level = ALevel) then
begin
AStart := ColumnStart;
AEnd := ColumnEnd;
break;
end;
end;
function TcxColumnsMap.GetColumnWidth(AIndex: Integer): Integer;
begin
Result := FColumnWidths[AIndex];
end;
{ TcxVerticalGridMapsInfo }
constructor TcxVerticalGridMapsInfo.Create(
AOwner: TcxVerticalGridExportHelper);
begin
FOwner := AOwner;
FVerticalGrid := FOwner.VerticalGrid;
FViewInfo := TcxViewInfoAccess(FVerticalGrid.ViewInfo);
FRows := TList.Create;
FRowsCaptions := TcxRowsCaptions.Create;
FRowsIndents := TcxRowsIndents.Create;
FHeaderColumnsMap := TcxColumnsMap.Create;
FValueColumnsMap := TcxColumnsMap.Create;
with FVerticalGrid.OptionsView do
begin
FGridLineColor := GridLineColor;
FGridLines := GridLines;
FPaintStyle := PaintStyle;
end;
end;
destructor TcxVerticalGridMapsInfo.Destroy;
begin
FLevelIndents := nil;
FRows.Free;
FHeaderColumnsMap.Free;
FValueColumnsMap.Free;
FRowsCaptions.Free;
FRowsIndents.Free;
inherited Destroy;
end;
procedure TcxVerticalGridMapsInfo.AddMultiEditorRowCells(ARow: TcxCustomRow);
var
I, APosHeaderCell, AWidthHeaderCell, APosValueCell, AWidthValueCell: Integer;
begin
with GetMultiEditorRowProperties(ARow) do
begin
if Editors.Count < 2 then Exit;
APosHeaderCell := Succ(ARow.Level) * ViewInfo.RowIndentWidth;
APosValueCell := 0;
for I := 0 to Editors.Count - 1 do
begin
AWidthHeaderCell := Max(Editors[I].Width, FMinHeaderWidth);
AWidthValueCell := Max(Editors[I].Width, FMinValueWidth);
HeaderColumnsMap.CheckNeedWidth(APosHeaderCell + AWidthHeaderCell);
ValueColumnsMap.CheckNeedWidth(APosValueCell + AWidthValueCell);
if I = Editors.Count - 1 then break;
HeaderColumnsMap.AddRowCell(APosHeaderCell, ARow, I, AWidthHeaderCell);
Inc(APosHeaderCell, AWidthHeaderCell);
ValueColumnsMap.AddRowCell(APosValueCell, ARow, I, AWidthValueCell);
Inc(APosValueCell, AWidthValueCell);
end;
end;
end;
procedure TcxVerticalGridMapsInfo.AddMapRightSide(AMap: TcxColumnsMap;
ARight, AMinCellWidth: Integer; ACalcIndent: Boolean);
var
I, J, AWidth, APos: Integer;
ARow: TcxCustomRow;
begin
for I := 0 to RowCount - 1 do
begin
ARow := Rows[I];
APos := cxSetValue(ACalcIndent, (ARow.Level + 1) * ViewInfo.RowIndentWidth, 0);
if ARow is TcxCustomEditorRow then
AMap.AddRowCell(APos, ARow, 0, ARight - APos)
else
if ARow is TcxCustomMultiEditorRow then
with GetMultiEditorRowProperties(ARow) do
begin
if Editors.Count = 0 then continue;
for J := 0 to Editors.Count - 1 do
begin
AWidth := Max(Editors[J].Width, AMinCellWidth);
if J = Editors.Count - 1 then
AMap.AddRowCell(APos, ARow, J, ARight - APos);
Inc(APos, AWidth);
end;
end;
end;
end;
procedure TcxVerticalGridMapsInfo.AlignCategories;
var
I: Integer;
AProperties: TcxCaptionRowProperties;
ARow: TcxCustomRow;
AStart, AEnd: Integer;
AStyle: TcxCacheCellStyle;
AViewParams: TcxViewParams;
begin
for I := 0 to RowCount - 1 do
begin
ARow := Rows[I];
if ARow is TcxCategoryRow then
begin
AProperties := TcxCategoryRow(ARow).Properties;
HeaderColumnsMap.GetColumnInfoFromLevel(ARow.Level, AStart, AEnd);
AViewParams := VerticalGrid.Styles.GetCategoryParams(ARow);
cxViewParamsToCacheStyle(AViewParams, AStyle);
AStyle.AlignText := AlignToCxAlign[AProperties.HeaderAlignmentHorz];
cxCheckBorders(AStyle, [bTop, bBottom, bRight], GridLineColor, GridLines);
RowsCaptions.Captions[I].AddCaption(AEnd, Size.cx - AEnd,
Provider.RegisterStyle(AStyle), AProperties.Caption);
end;
end;
end;
procedure TcxVerticalGridMapsInfo.CalculateHeader;
var
I, AWidth: Integer;
ARow: TcxCustomRow;
begin
FMinHeaderWidth := VerticalGrid.OptionsView.RowHeaderMinWidth;
FMaxLevel := 0;
for I := 0 to VerticalGrid.Rows.Count - 1 do
begin
ARow := VerticalGrid.Rows[I];
if IsIncludeRow(ARow) then
begin
FRows.Add(ARow);
if ARow is TcxCustomMultiEditorRow then
AddMultiEditorRowCells(ARow);
FMaxLevel := Max(FMaxLevel, ARow.Level);
end;
end;
FRowCount := FRows.Count;
AWidth := ViewInfo.RowIndentWidth;
for I := 0 to FMaxLevel do
HeaderColumnsMap.AddLevel(I, I * AWidth, AWidth);
FMaxHeaderWidth := Max(HeaderColumnsMap.NeedWidth,
VerticalGrid.OptionsView.RowHeaderWidth);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -