|
From: vrecion <pav...@sy...> - 2005-02-23 10:53:53
|
OK I will add it to code. It will appear in the next cvs release.
Pavel
_____
From: ext...@li...
[mailto:ext...@li...] On Behalf Of Marco
Wobben
Sent: Wednesday, February 23, 2005 11:29 AM
To: ext...@li...
Subject: [Extgraph-developer] TGraphNode.Layout
I've added a new property to the nodes:
published
property Layout: TTextLayout read fTextLayout write SetTextLayout
default tlCenter;
And a routine implementation using it:
function TGraphNode.GetTextRect: TRect;
var
MaxTextRect: TRect;
DrawTextFlags: Integer;
h: integer;
begin
if Text <> '' then
begin
MaxTextRect := GetMaxTextRect;
DrawTextFlags := DT_WORDBREAK or DT_NOPREFIX or DT_END_ELLIPSIS or
DT_EDITCONTROL or TextAlignFlags[Alignment];
Owner.Canvas.Font := Font;
Result := MaxTextRect;
h := Windows.DrawText(
Owner.Canvas.Handle, PChar(Text), Length(Text), Result,
Owner.DrawTextBiDiModeFlags(DrawTextFlags) or DT_CALCRECT);
if Result.Right > MaxTextRect.Right then
Result.Right := MaxTextRect.Right;
if Result.Bottom > MaxTextRect.Bottom then
Result.Bottom := MaxTextRect.Bottom;
if not IsRectEmpty(Result) then
begin
{ MW stripped any vertical alignment from the horizontal stuff. }
case Alignment of
taLeftJustify:
OffsetRect(Result, Left, 0);
taRightJustify:
OffsetRect(Result, Left + (MaxTextRect.Right - Result.Right) -
Margin, 0);
else
OffsetRect(Result, Left + (MaxTextRect.Right - Result.Right) div 2,
0);
end;
{ MW added vertical alignment }
case Layout of
tlTop:
OffsetRect(Result, 0, Top);
tlCenter:
OffsetRect(Result, 0, Top + (MaxTextRect.Bottom - Result.Bottom)
div 2);
tlBottom:
OffsetRect(Result, 0, (MaxTextRect.Bottom-Result.Bottom) - h);
end;
end;
end
else
FillChar(Result, SizeOf(Result), 0);
end;
|