📄 cxvgridviewinfo.pas
字号:
ARowValueInfo := TcxRowValueInfoAccess(
CalcRowValueInfo(Row.Properties, AViewInfo, ARecordIndex, 0));
ARowValueInfo.CellContentRect := cxRectBounds(0, 0, AWidth, 0);
Result := ARowValueInfo.CalculateEditHeight;
ValuesInfo.Trunc(VisibleValueCount);
end;
end;
function TcxEditorRowViewInfo.GetRow: TcxEditorRow;
begin
Result := TcxEditorRow(inherited Row);
end;
{ TcxMultiEditorRowHeaderInfo }
constructor TcxMultiEditorRowHeaderInfo.Create(ARow: TcxCustomRow);
begin
inherited Create(ARow);
FSeparatorRects := TcxRectList.Create;
end;
destructor TcxMultiEditorRowHeaderInfo.Destroy;
begin
FSeparatorRects.Free;
inherited Destroy;
end;
procedure TcxMultiEditorRowHeaderInfo.CalcRowCaptionsInfo;
var
I: Integer;
R: TRect;
ARects: TcxRectList;
ACaptionInfo: TcxRowCaptionInfo;
begin
CalcSeparatorWidth(ViewInfo.DividerWidth);
CalcSeparatorStyle;
ARects := TcxMultiEditorRowViewInfo.GetCellRects(Row, HeaderCellsRect, FSeparatorInfo.Width);
if ARects <> nil then
try
for I := 0 to ARects.Count - 1 do
begin
R := ARects[I];
if R.Left < HeaderCellsRect.Right then
begin
ACaptionInfo := CalcCaptionInfo(Row.Properties.Editors[I], R);
ACaptionInfo.RowCellIndex := I;
CaptionsInfo.Add(ACaptionInfo);
end;
end;
CalcSeparatorRects(ARects);
finally
ARects.Free;
end;
end;
procedure TcxMultiEditorRowHeaderInfo.CalcSeparatorRects(
AHeaderCells: TcxRectList);
begin
TcxMultiEditorRowViewInfo(Row.ViewInfo).AddSeparatorRects(
True, SeparatorRects, SeparatorInfo.Kind, AHeaderCells, HeaderCellsRect);
end;
procedure TcxMultiEditorRowHeaderInfo.CalcSeparatorWidth(
ASeparatorWidth: Integer);
begin
with FSeparatorInfo do
begin
Kind := Row.Properties.SeparatorKind;
Caption := Row.Properties.SeparatorString;
if Kind = skVertLine then
Width := ASeparatorWidth
else
Width := cxTextWidth(Self.ViewParams.Font, SeparatorInfo.Caption + '0');
end;
end;
procedure TcxMultiEditorRowHeaderInfo.CalcSeparatorStyle;
begin
FSeparatorInfo.ViewParams := ViewParams;
with Row.Properties do
FSeparatorInfo.TextFlags := GetTextAligmentFlags(taCenter, SeparatorAlignmentVert);
end;
procedure TcxMultiEditorRowHeaderInfo.Clear;
begin
inherited Clear;
FSeparatorRects.Clear;
end;
function TcxMultiEditorRowHeaderInfo.GetRow: TcxMultiEditorRow;
begin
Result := TcxMultiEditorRow(FRow);
end;
{ TcxMultiEditorRowViewInfo }
constructor TcxMultiEditorRowViewInfo.Create(ARow: TcxCustomRow);
begin
inherited Create(ARow);
FSeparatorRects := TcxRectList.Create;
end;
destructor TcxMultiEditorRowViewInfo.Destroy;
begin
FreeAndNil(FSeparatorRects);
inherited Destroy;
end;
class function TcxMultiEditorRowViewInfo.GetCellRects(ARow: TcxMultiEditorRow;
const R: TRect; ASepWidth: Integer): TcxRectList;
var
I, ACount, AMinWidth: Integer;
begin
Result := nil;
AMinWidth := ARow.VerticalGrid.OptionsView.RowHeaderMinWidth;
ACount := ARow.Properties.Editors.Count;
with TRectScaler.Create do
try
for I := 0 to ACount - 1 do
Add(ARow.Properties.Editors[I].Width, AMinWidth,
cxSetValue(I = ACount - 1, 0, ASepWidth));
if ARow.Properties.Fixed then CalcRect(R) else ScaleRect(R);
if ScaledRects.Count > 0 then
begin
Result := TcxRectList.Create;
Result.Assign(ScaledRects);
end;
finally
Free;
end;
end;
procedure TcxMultiEditorRowViewInfo.AddSeparatorRects(
AHeader: Boolean;
ASepRects: TcxRectList;
ASeparatorKind: TSeparatorKind;
AValueCells: TcxRectList;
const ABounds: TRect);
var
I: Integer;
R: TRect;
begin
for I := 0 to AValueCells.Count - 2 do
with AValueCells[I] do
if ASeparatorKind = skString then
begin
R := cxRect(Right, Top, AValueCells[I + 1].Left, Bottom);
if cxRectIntersect(R, R, ABounds) then ASepRects.Add(R)
end
else
begin
R := cxRect(Right - ViewInfo.DividerWidth, Top, Right, Bottom);
if cxRectIntersect(R, R, ABounds) then
if AHeader then
ViewInfo.CalcHelper.AddDivider(HeaderInfo.LinesInfo, R,
HeaderInfo.ViewParams.Color, True)
else
ViewInfo.CalcHelper.AddDivider(ViewInfo.LinesInfo, R,
HeaderInfo.ViewParams.Color, True);
end;
end;
procedure TcxMultiEditorRowViewInfo.CalcValuesInfo;
var
I, J, ASepWidth, ACount, AValuesCount: Integer;
AValueRect, R: TRect;
ARects: TcxRectList;
ARowValueInfo: TcxRowValueInfo;
ASepKind: TSeparatorKind;
begin
ACount := 0;
SeparatorRects.Clear;
with HeaderInfo.SeparatorInfo do
begin
ASepWidth := Width;
ASepKind := Kind;
end;
with ViewInfo do
begin
AValuesCount := VisibleValueCount;
for I := 0 to AValuesCount - 1 do
begin
AValueRect := GetValueRect(I, Self);
ARects := GetCellRects(Row, AValueRect, ASepWidth);
if ARects <> nil then
begin
ACount := Min(ARects.Count, TcxCustomRowAccess(Row).GetEditContainerCount);
try
for J := 0 to ACount - 1 do
begin
R := ARects[J];
if not cxRectIsEmpty(R) then
begin
ARowValueInfo := CalcRowValueInfo(Row.Properties.Editors[J],
ViewInfo, FirstVisibleRecordIndex + I, J);
CalcEditCell(R, ARowValueInfo);
end;
end;
AddSeparatorRects(False, SeparatorRects, ASepKind, ARects, AValueRect);
finally
ARects.Free;
end;
end;
AddRectValueLines(AValueRect, I = AValuesCount - 1);
end;
ValuesInfo.Trunc(AValuesCount * ACount);
end;
CheckEmptyValuesInfo;
end;
procedure TcxMultiEditorRowViewInfo.CheckEmptyValuesInfo;
begin
if (Row.Properties.Editors.Count = 0) and (cxRectWidth(ValuesRect) > 0) then
begin
HeaderInfo.LinesInfo.Add(RowRect, HeaderInfo.ViewParams.Color);
AddRectValueLines(ValuesRect, True);
end;
end;
function TcxMultiEditorRowViewInfo.GetValueHeight(ARecordIndex: Integer;
AWidth: Integer; AViewInfo: TcxvgCustomViewInfo): Integer;
var
I, J, ASepWidth, ACount, AValuesCount: Integer;
AValueRect, R: TRect;
ARects: TcxRectList;
ARowValueInfo: TcxRowValueInfoAccess;
begin
Result := -1;
ACount := 0;
ASepWidth := HeaderInfo.SeparatorInfo.Width;
with AViewInfo do
begin
AValuesCount := VisibleValueCount;
for I := 0 to AValuesCount - 1 do
begin
AValueRect := GetValueRect(I, Self);
ARects := GetCellRects(Row, AValueRect, ASepWidth);
if ARects <> nil then
begin
ACount := Min(ARects.Count, TcxCustomRowAccess(Row).GetEditContainerCount);
try
for J := 0 to ACount - 1 do
begin
R := ARects[J];
if not cxRectIsEmpty(R) then
begin
ARowValueInfo := TcxRowValueInfoAccess(CalcRowValueInfo(
Row.Properties.Editors[J], AViewInfo, FirstVisibleRecordIndex + I, J));
ARowValueInfo.CellContentRect := cxRectBounds(0, 0, R.Right - R.Left, 0);
Result := Max(Result, ARowValueInfo.CalculateEditHeight);
end;
end;
finally
ARects.Free;
end;
end;
end;
ValuesInfo.Trunc(AValuesCount * ACount);
end;
end;
function TcxMultiEditorRowViewInfo.GetHeaderInfo: TcxMultiEditorRowHeaderInfo;
begin
Result := TcxMultiEditorRowHeaderInfo(inherited HeaderInfo);
end;
function TcxMultiEditorRowViewInfo.GetRow: TcxMultiEditorRow;
begin
Result := TcxMultiEditorRow(inherited Row);
end;
function TcxMultiEditorRowViewInfo.GetSeparatorRects: TcxRectList;
begin
Result := FSeparatorRects;
end;
{ TcxInspectorViewInfo }
procedure TcxInspectorViewInfo.AddEmptyRects;
begin
end;
procedure TcxInspectorViewInfo.CheckMaxRowHeaderWidth(var Value: Integer;
AValueMinWidth: Integer);
begin
if ViewBandWidth > 0 then
Value := Min(Value, ViewBandWidth - Max(AValueMinWidth, 4));
end;
function TcxInspectorViewInfo.GetViewValueWidth: Integer;
begin
Result := ViewBandWidth - ViewHeaderWidth - DividerWidth - 2 * VertLineWidth;
end;
function TcxInspectorViewInfo.GetVisibleValueCount: Integer;
begin
Result := 1;
end;
{ TcxBandsViewInfo }
procedure TcxBandsViewInfo.AddEmptyRects;
var
I, AHeight: Integer;
ABand: TRect;
begin
AHeight := ClientRect.Bottom - ClientRect.Top;
with ABand, ViewRects do
begin
if BandsIndent > 0 then
for I := 0 to BandRects.Count - 2 do
begin
ABand := BandRects[I];
EmptyRects.Add(cxRectBounds(Right, Top, BandsIndent, AHeight));
end;
// check last band
ABand := BandRects[BandRects.Count - 1];
if Right < ClientRect.Right then
//suppose non-autoWidth mode
EmptyRects.Add(cxRectBounds(Right, Top, ClientRect.Right - Right, AHeight));
end;
end;
procedure TcxBandsViewInfo.CalcBandRects;
var
I: Integer;
begin
with Scroller do
for I := LeftVisibleBand to BandsInfo.Count - 1 do
CreateBand(BandsInfo[I].BandHeight, 40);
UpdateBandsWidth;
end;
procedure TcxBandsViewInfo.CalcBandWidth;
var
ABandIndentWidth, ASaveWidth, ABandCount: Integer;
APos: Double;
begin
ViewHeaderWidth := GetViewHeaderWidth;
if not AutoScaleBands then
begin
ViewValueWidth := GetViewValueWidth;
ViewBandWidth := GetViewBandWidth;
end
else
begin
if LockDividerPos then Exit;
ASaveWidth := GetViewBandWidth;
if ShowHeaders and (ASaveWidth > 0) then
APos := Max(GetViewBandWidth, VerticalGrid.OptionsView.ValueMinWidth ) / Max(ViewHeaderWidth, 1)
else
APos := 1;
ABandCount := Scroller.BandsInfo.Count;
ABandIndentWidth := cxSetValue(ABandCount > 1, (ABandCount - 1) * BandsIndent, 0);
ViewBandWidth := Max(GetMinViewBandWidth,
(cxRectWidth(ClientRect) - ABandIndentWidth) div Max(ABandCount, 1));
if ViewBandWidth < BandMinWidth then
ViewBandWidth := BandMinWidth;
if ShowHeaders and not FLock and (ASaveWidth > ViewHeaderWidth) and
(ASaveWidth <> ViewBandWidth) then
SetDividerPos(Round(ViewBandWidth / APos));
ViewHeaderWidth := GetViewHeaderWidth;
end;
end;
procedure TcxBandsViewInfo.CalcLayoutGeneral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -