fpvectorial: Adds multiline support for text, adds a new translate function to entities

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1809 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2011-08-18 11:39:57 +00:00
parent 126ca68383
commit 50167841fd
3 changed files with 32 additions and 5 deletions

View File

@ -163,6 +163,7 @@ type
procedure CalculateBoundingBox(var ALeft, ATop, ARight, ABottom: Double); virtual;
procedure ExpandBoundingBox(var ALeft, ATop, ARight, ABottom: Double);
function TryToSelect(APos: TPoint): TvFindEntityResult; virtual;
procedure Translate(ADeltaX, ADeltaY: Integer); virtual;
end;
TvClipMode = (vcmNonzeroWindingRule, vcmEvenOddRule);
@ -189,8 +190,10 @@ type
TvText = class(TvEntity)
public
Value: utf8string;
Value: TStringList;
Font: TvFont;
constructor Create; override;
destructor Destroy; override;
function TryToSelect(APos: TPoint): TvFindEntityResult; override;
end;
@ -489,6 +492,18 @@ end;
{ TvText }
constructor TvText.Create;
begin
inherited Create;
Value := TStringList.Create;
end;
destructor TvText.Destroy;
begin
Value.Free;
inherited Destroy;
end;
function TvText.TryToSelect(APos: TPoint): TvFindEntityResult;
var
lProximityFactor: Integer;
@ -534,6 +549,12 @@ begin
Result := vfrNotFound;
end;
procedure TvEntity.Translate(ADeltaX, ADeltaY: Integer);
begin
X := X + ADeltaX;
Y := Y + ADeltaY;
end;
{ TvEllipse }
procedure TvEllipse.CalculateBoundingRectangle;
@ -825,7 +846,7 @@ var
lText: TvText;
begin
lText := TvText.Create;
lText.Value := AText;
lText.Value.Text := AText;
lText.X := AX;
lText.Y := AY;
lText.Font.Name := FontName;

View File

@ -548,8 +548,14 @@ begin
ALCLDest.Font.Orientation := Round(CurText.Font.Orientation * 16);
{$endif}
LowerDim.Y := CurText.Y + CurText.Font.Size;
ADest.TextOut(CoordToCanvasX(CurText.X), CoordToCanvasY(LowerDim.Y), CurText.Value);
// TvText supports multiple lines
for i := 0 to CurText.Value.Count - 1 do
begin
if CurText.Font.Size = 0 then LowerDim.Y := CurText.Y - 12 * (i + 1)
else LowerDim.Y := CurText.Y - CurText.Font.Size * (i + 1);
ADest.TextOut(CoordToCanvasX(CurText.X), CoordToCanvasY(LowerDim.Y), CurText.Value.Strings[i]);
end;
end;
end.

View File

@ -232,7 +232,7 @@ begin
ConvertFPVCoordinatesToSVGCoordinates(
AData, lText.X, lText.Y, PtX, PtY);
TextStr := lText.Value;
TextStr := lText.Value.Text;
FontSize:= ceil(lText.Font.Size / FLOAT_MILIMETERS_PER_PIXEL);
SVGFontFamily := 'Arial, sans-serif';//lText.FontName;