TAChart: Better support drawing of too narrow legend panel. Update demo.

git-svn-id: trunk@27785 -
This commit is contained in:
ask 2010-10-21 09:27:15 +00:00
parent b9412bed2b
commit 16f53a6e50
3 changed files with 19 additions and 2 deletions

View File

@ -98,7 +98,7 @@ object Form1: TForm1
Left = 0
Height = 336
Top = 0
Width = 332
Width = 327
AxisList = <
item
Title.LabelFont.Orientation = 900
@ -170,6 +170,14 @@ object Form1: TForm1
TabOrder = 2
end
end
object Splitter1: TSplitter
Left = 327
Height = 336
Top = 0
Width = 5
Align = alRight
ResizeAnchor = akRight
end
end
end
object UserDefinedChartSource1: TUserDefinedChartSource

View File

@ -33,6 +33,7 @@ type
Panel1: TPanel;
tsDomain: TTabSheet;
tsColorMap: TTabSheet;
Splitter1: TSplitter;
UserDefinedChartSource1: TUserDefinedChartSource;
procedure cbDomainChange(Sender: TObject);
procedure cbInterpolateChange(Sender: TObject);

View File

@ -343,6 +343,10 @@ begin
ACanvas.Pen.Assign(Frame);
ACanvas.Rectangle(ABounds);
r := ABounds;
r.Right -= 1;
ACanvas.ClipRect := r;
ACanvas.Clipping := true;
// Draw items.
h := TypicalTextHeight(ACanvas);
r := Bounds(ABounds.Left + Spacing, ABounds.Top + Spacing, SymbolWidth, h);
@ -373,9 +377,13 @@ begin
with AItems[i] as TLegendItem do
legendWidth := Max(ACanvas.TextWidth(FText), legendWidth);
legendWidth += 2 * Spacing + SYMBOL_TEXT_SPACING + SymbolWidth;
w := 2 * MarginX;
with AClipRect do
legendWidth := EnsureRange(legendWidth, 0, Right - Left - w);
w += legendWidth;
textHeight := TypicalTextHeight(ACanvas);
legendHeight := Spacing + AItems.Count * (textHeight + Spacing);
w := legendWidth + 2 * MarginX;
// Determine position according to the alignment.
if Alignment in [laTopLeft, laBottomLeft] then begin