mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 13:59:15 +02:00
fpvectorial: Fixes table rendering
git-svn-id: trunk@47865 -
This commit is contained in:
parent
0910e1bd5b
commit
e0796f811f
@ -402,6 +402,7 @@ type
|
|||||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); virtual;
|
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); virtual;
|
||||||
procedure ExpandBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); // helper to help CalculateBoundingBox
|
procedure ExpandBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); // helper to help CalculateBoundingBox
|
||||||
procedure CalcEntityCanvasMinMaxXY(var ARenderInfo: TvRenderInfo; APointX, APointY: Integer); virtual;
|
procedure CalcEntityCanvasMinMaxXY(var ARenderInfo: TvRenderInfo; APointX, APointY: Integer); virtual;
|
||||||
|
procedure MergeRenderInfo(var AFrom, ATo: TvRenderInfo);
|
||||||
{@@ ASubpart is only valid if this routine returns vfrSubpartFound }
|
{@@ ASubpart is only valid if this routine returns vfrSubpartFound }
|
||||||
function TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult; virtual;
|
function TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult; virtual;
|
||||||
procedure Move(ADeltaX, ADeltaY: Double); virtual;
|
procedure Move(ADeltaX, ADeltaY: Double); virtual;
|
||||||
@ -1109,6 +1110,7 @@ type
|
|||||||
function AddCell: TvTableCell;
|
function AddCell: TvTableCell;
|
||||||
function GetCellCount: Integer;
|
function GetCellCount: Integer;
|
||||||
function GetCell(AIndex: Integer): TvTableCell;
|
function GetCell(AIndex: Integer): TvTableCell;
|
||||||
|
function CalculateMaxCellSpacing_Y(): Double;
|
||||||
//
|
//
|
||||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
||||||
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
@ -1164,6 +1166,7 @@ type
|
|||||||
//
|
//
|
||||||
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||||
|
function GetEntityFeatures: TvEntityFeatures; override;
|
||||||
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override;
|
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1766,7 +1769,7 @@ begin
|
|||||||
CurRow.Height := Max(CurRow.Height, lCellHeight);
|
CurRow.Height := Max(CurRow.Height, lCellHeight);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CurRow.Height := CurRow.Height + 5;
|
CurRow.Height := CurRow.Height + CurRow.CalculateMaxCellSpacing_Y();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1850,11 +1853,20 @@ procedure TvTable.Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo;
|
|||||||
Result := Round(ADestY + AmulY * ACoord);
|
Result := Round(ADestY + AmulY * ACoord);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DeltaToCanvasY(ACoord: Double): Integer;
|
||||||
|
begin
|
||||||
|
Result := Round(AmulY * ACoord);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
row, col: Integer;
|
row, col: Integer;
|
||||||
CurRow: TvTableRow;
|
CurRow: TvTableRow;
|
||||||
CurHeight: Double;
|
CurY: Integer;
|
||||||
|
lEntityRenderInfo: TvRenderInfo;
|
||||||
begin
|
begin
|
||||||
|
ARenderInfo.EntityCanvasMinXY := Point(-1, -1);
|
||||||
|
ARenderInfo.EntityCanvasMaxXY := Point(-1, -1);
|
||||||
|
|
||||||
// First calculate the column widths and heights
|
// First calculate the column widths and heights
|
||||||
CalculateColWidths(ADest);
|
CalculateColWidths(ADest);
|
||||||
|
|
||||||
@ -1862,15 +1874,21 @@ begin
|
|||||||
CalculateRowHeights(ADest);
|
CalculateRowHeights(ADest);
|
||||||
|
|
||||||
// Now draw the table
|
// Now draw the table
|
||||||
CurHeight := 0;
|
CurY := CoordToCanvasY(Y);
|
||||||
for row := 0 to GetRowCount()-1 do
|
for row := 0 to GetRowCount()-1 do
|
||||||
begin
|
begin
|
||||||
CurRow := GetRow(row);
|
CurRow := GetRow(row);
|
||||||
CurRow.Render(ADest, ARenderInfo, ADestX, CoordToCanvasY(CurHeight), AMulX, AMulY);
|
CurRow.Render(ADest, lEntityRenderInfo, ADestX, CurY, AMulX, AMulY);
|
||||||
CurHeight := CurHeight + CurRow.Height;
|
MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
|
||||||
|
CurY := ARenderInfo.EntityCanvasMaxXY.Y + DeltaToCanvasY(CurRow.Height);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TvTable.GetEntityFeatures: TvEntityFeatures;
|
||||||
|
begin
|
||||||
|
Result.DrawsUpwards := False;
|
||||||
|
end;
|
||||||
|
|
||||||
function TvTable.GenerateDebugTree(ADestRoutine: TvDebugAddItemProc;
|
function TvTable.GenerateDebugTree(ADestRoutine: TvDebugAddItemProc;
|
||||||
APageItem: Pointer): Pointer;
|
APageItem: Pointer): Pointer;
|
||||||
var
|
var
|
||||||
@ -2188,6 +2206,19 @@ begin
|
|||||||
Result := TvTableCell(Cells[AIndex]);
|
Result := TvTableCell(Cells[AIndex]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TvTableRow.CalculateMaxCellSpacing_Y(): Double;
|
||||||
|
Var
|
||||||
|
i : Integer;
|
||||||
|
CurCell: TvTableCell;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
for i := 0 to GetCellCount()-1 do
|
||||||
|
begin
|
||||||
|
CurCell := GetCell(i);
|
||||||
|
Result := Max(Result, CurCell.SpacingBottom+CurCell.SpacingTop);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TvTableRow.CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double);
|
procedure TvTableRow.CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double);
|
||||||
begin
|
begin
|
||||||
ALeft := X;
|
ALeft := X;
|
||||||
@ -2213,14 +2244,20 @@ var
|
|||||||
CurCell: TvTableCell;
|
CurCell: TvTableCell;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurX: Double = 0.0;
|
CurX: Double = 0.0;
|
||||||
|
lEntityRenderInfo: TvRenderInfo;
|
||||||
begin
|
begin
|
||||||
|
ARenderInfo.EntityCanvasMinXY := Point(-1, -1);
|
||||||
|
ARenderInfo.EntityCanvasMaxXY := Point(-1, -1);
|
||||||
|
|
||||||
for i := 0 to GetCellCount()-1 do
|
for i := 0 to GetCellCount()-1 do
|
||||||
begin
|
begin
|
||||||
CurCell := GetCell(i);
|
CurCell := GetCell(i);
|
||||||
CurCell.X := CurX;
|
CurCell.X := CurX;
|
||||||
CurCell.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY);
|
CurCell.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMulY);
|
||||||
if (Table <> nil) and (Length(Table.ColWidthsInMM) > i) then
|
if (Table <> nil) and (Length(Table.ColWidthsInMM) > i) then
|
||||||
CurX := CurX + Table.ColWidthsInMM[i];
|
CurX := CurX + Table.ColWidthsInMM[i];
|
||||||
|
|
||||||
|
MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2667,6 +2704,12 @@ begin
|
|||||||
else ARenderInfo.EntityCanvasMaxXY.Y := Max(ARenderInfo.EntityCanvasMaxXY.Y, APointY);
|
else ARenderInfo.EntityCanvasMaxXY.Y := Max(ARenderInfo.EntityCanvasMaxXY.Y, APointY);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TvEntity.MergeRenderInfo(var AFrom, ATo: TvRenderInfo);
|
||||||
|
begin
|
||||||
|
CalcEntityCanvasMinMaxXY(ATo, AFrom.EntityCanvasMinXY.X, AFrom.EntityCanvasMinXY.Y);
|
||||||
|
CalcEntityCanvasMinMaxXY(ATo, AFrom.EntityCanvasMaxXY.X, AFrom.EntityCanvasMaxXY.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
function TvEntity.TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult;
|
function TvEntity.TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult;
|
||||||
begin
|
begin
|
||||||
Result := vfrNotFound;
|
Result := vfrNotFound;
|
||||||
@ -5793,7 +5836,11 @@ var
|
|||||||
lPrevText: TvText = nil;
|
lPrevText: TvText = nil;
|
||||||
lFirstText: Boolean = True;
|
lFirstText: Boolean = True;
|
||||||
lResetOldStyle: Boolean = False;
|
lResetOldStyle: Boolean = False;
|
||||||
|
lEntityRenderInfo: TvRenderInfo;
|
||||||
begin
|
begin
|
||||||
|
ARenderInfo.EntityCanvasMinXY := Point(-1, -1);
|
||||||
|
ARenderInfo.EntityCanvasMaxXY := Point(-1, -1);
|
||||||
|
|
||||||
// Don't call inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY);
|
// Don't call inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY);
|
||||||
lEntity := GetFirstEntity();
|
lEntity := GetFirstEntity();
|
||||||
while lEntity <> nil do
|
while lEntity <> nil do
|
||||||
@ -5823,7 +5870,7 @@ begin
|
|||||||
if lText.Render_Use_NextText_X then
|
if lText.Render_Use_NextText_X then
|
||||||
lText.Render_NextText_X := lPrevText.Render_NextText_X;
|
lText.Render_NextText_X := lPrevText.Render_NextText_X;
|
||||||
|
|
||||||
lText.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
lText.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMuly);
|
||||||
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
||||||
lCurWidth := lCurWidth + Abs(lRight - lLeft);
|
lCurWidth := lCurWidth + Abs(lRight - lLeft);
|
||||||
lFirstText := False;
|
lFirstText := False;
|
||||||
@ -5834,6 +5881,9 @@ begin
|
|||||||
if lResetOldStyle then
|
if lResetOldStyle then
|
||||||
TvText(lEntity).Style := nil;
|
TvText(lEntity).Style := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
|
||||||
|
|
||||||
lEntity := GetNextEntity();
|
lEntity := GetNextEntity();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6002,7 +6052,10 @@ var
|
|||||||
lLeft, lTop, lRight, lBottom: Double;
|
lLeft, lTop, lRight, lBottom: Double;
|
||||||
lEntity: TvEntity;
|
lEntity: TvEntity;
|
||||||
lParagraph: TvParagraph absolute lEntity;
|
lParagraph: TvParagraph absolute lEntity;
|
||||||
|
lEntityRenderInfo: TvRenderInfo;
|
||||||
begin
|
begin
|
||||||
|
ARenderInfo.EntityCanvasMinXY := Point(-1, -1);
|
||||||
|
ARenderInfo.EntityCanvasMaxXY := Point(-1, -1);
|
||||||
// Don't call inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY);
|
// Don't call inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY);
|
||||||
lEntity := GetFirstEntity();
|
lEntity := GetFirstEntity();
|
||||||
while lEntity <> nil do
|
while lEntity <> nil do
|
||||||
@ -6011,11 +6064,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
lParagraph.X := X;
|
lParagraph.X := X;
|
||||||
lParagraph.Y := Y + lCurHeight;
|
lParagraph.Y := Y + lCurHeight;
|
||||||
lParagraph.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
lParagraph.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMuly);
|
||||||
lParagraph.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
lParagraph.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
||||||
lCurHeight := lCurHeight + (lBottom - lTop);
|
lCurHeight := lCurHeight + (lBottom - lTop);
|
||||||
end;
|
end;
|
||||||
lEntity := GetNextEntity();
|
lEntity := GetNextEntity();
|
||||||
|
MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6954,7 +7008,7 @@ begin
|
|||||||
// Store the old position in X/Y but don't use it, we use this to debug out the position
|
// Store the old position in X/Y but don't use it, we use this to debug out the position
|
||||||
CurEntity.X := ADestX;
|
CurEntity.X := ADestX;
|
||||||
CurEntity.Y := CurY;
|
CurEntity.Y := CurY;
|
||||||
CurY := RenderInfo.EntityCanvasMaxXY.Y;
|
CurY := CurY + Abs(RenderInfo.EntityCanvasMaxXY.Y - RenderInfo.EntityCanvasMinXY.Y)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
|
Loading…
Reference in New Issue
Block a user