fpvectorial: Improves list rendering

git-svn-id: trunk@48985 -
This commit is contained in:
sekelsenmat 2015-05-11 10:02:24 +00:00
parent d74381d94a
commit 3acde3bf25
2 changed files with 22 additions and 25 deletions

View File

@ -726,7 +726,7 @@ Var
If Not Assigned(TvParagraph(oEntity).Style) Then
TvParagraph(oEntity).Style := AList.Style;
ProcessParagraph(TvParagraph(oEntity), AList.Level, FData.FindListStyleIndex(AList.ListStyle) + 1);
ProcessParagraph(TvParagraph(oEntity), AList.GetLevel(), FData.FindListStyleIndex(AList.ListStyle) + 1);
End
Else If oEntity Is TvList Then
ProcessList(TvList(oEntity))

View File

@ -1006,7 +1006,8 @@ type
destructor Destroy; override;
function AddParagraph(ASimpleText: string): TvParagraph;
function AddList : TvList;
function Level : Integer;
function GetLevel : Integer;
function GetBulletSize: Double;
class procedure DrawBullet(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo;
ALevel: Integer; AX, AY: Double; ADestX: Integer = 0; ADestY: Integer = 0;
AMulX: Double = 1.0; AMulY: Double = 1.0; ADoDraw: Boolean = True);
@ -6271,7 +6272,7 @@ begin
AddEntity(Result);
end;
function TvList.Level: Integer;
function TvList.GetLevel: Integer;
var
oListItem : TvList;
begin
@ -6287,6 +6288,13 @@ begin
end;
end;
function TvList.GetBulletSize: Double;
begin
Result := Font.Size;
if Result = 0 then Result := 10;
Result := Result * 1.5; // for upper/lower spacing
end;
class procedure TvList.DrawBullet(ADest: TFPCustomCanvas;
var ARenderInfo: TvRenderInfo; ALevel: Integer; AX, AY: Double;
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double;
@ -6329,37 +6337,26 @@ begin
InitializeRenderInfo(ARenderInfo);
// Don't call inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY, ADoDraw);
CurX := X + GetBulletSize();
CurY := Y;
lEntity := GetFirstEntity();
while lEntity <> nil do
begin
if lEntity is TvParagraph then
begin
{lText.Render(ADest, lEntityRenderInfo, CurX, ADestY + lHeight_px, AMulX, AMulY, ADoDraw);
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
lCurWidth := lCurWidth + Abs(lRight - lLeft);
lFirstText := False;
lPrevText := lText;
lText.X := OldTextX;
lText.Y := OldTextY;
if lResetOldStyle then
TvText(lEntity).Style := nil; }
end
else if lEntity is TvList then
begin
{OldTextX := lText.X;
OldTextY := lText.Y;
lEntity.X := CoordToCanvasX(lEntity.X + X + lCurWidth);
lEntity.Y := lEntity.Y + Y;
lEntity.Render(ADest, lEntityRenderInfo, ADestX, ADestY + lHeight_px, AMulX, AMulY, ADoDraw);
lEntity.X := OldTextX;
lEntity.Y := OldTextY; }
TvList.DrawBullet(ADest, lEntityRenderInfo, GetLevel(),
X, CurY, ADestX, ADestY, AMulX, AMulY, ADoDraw);
end;
lEntity.X := CurX;
lEntity.Y := CurY;
lEntity.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMulY, ADoDraw);
MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
CurY := CurY + GetBulletSize();
lEntity := GetNextEntity();
end;
end;