mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-02 19:24:46 +01:00
TAChart: Make text output code aware of SetXor mode instead of direct call to DrawXorText
git-svn-id: trunk@38438 -
This commit is contained in:
parent
220eac068b
commit
3c118fcf49
@ -113,8 +113,8 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
FPCanvas, Graphics, GraphMath, Math, SysUtils, Types,
|
||||
TAChartAxis, TACustomSeries, TADrawerCanvas, TAGeometry;
|
||||
GraphMath, Math, SysUtils, Types,
|
||||
TAChartAxis, TACustomSeries, TAGeometry;
|
||||
|
||||
const
|
||||
DEF_DISTANCE_FORMAT = '%0:.9g';
|
||||
@ -225,10 +225,7 @@ begin
|
||||
DrawPointer(PointerEnd, p2);
|
||||
if Marks.Visible then begin
|
||||
p1 := (p1 + p2) div 2;
|
||||
if EffectiveDrawingMode = tdmNormal then
|
||||
Marks.DrawLabel(FChart.Drawer, p1, p1, GetDistanceText, dummy)
|
||||
else
|
||||
DrawXorText(FChart.Canvas, p1, GetDistanceText);
|
||||
Marks.DrawLabel(FChart.Drawer, p1, p1, GetDistanceText, dummy)
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -75,7 +75,6 @@ type
|
||||
|
||||
function CanvasGetFontOrientationFunc(AFont: TFPCustomFont): Integer;
|
||||
function ChartColorSysToFPColor(AChartColor: TChartColor): TFPColor;
|
||||
procedure DrawXorText(ACanvas: TCanvas; APoint: TPoint; const AText: String);
|
||||
|
||||
implementation
|
||||
|
||||
@ -96,28 +95,6 @@ begin
|
||||
Result := ChartColorToFPColor(ColorToRGB(AChartColor));
|
||||
end;
|
||||
|
||||
procedure DrawXorText(ACanvas: TCanvas; APoint: TPoint; const AText: String);
|
||||
var
|
||||
bmp: TBitmap;
|
||||
ext: TPoint;
|
||||
begin
|
||||
ext := ACanvas.TextExtent(AText);
|
||||
bmp := TBitmap.Create;
|
||||
try
|
||||
bmp.SetSize(ext.X, ext.Y);
|
||||
bmp.Canvas.Brush.Style := bsClear;
|
||||
bmp.Canvas.Font := ACanvas.Font;
|
||||
bmp.Canvas.Font.Color := clWhite;
|
||||
bmp.Canvas.TextOut(0, 0, AText);
|
||||
APoint -= ext div 2;
|
||||
BitBlt(
|
||||
ACanvas.Handle, APoint.X, APoint.Y, ext.X, ext.Y,
|
||||
bmp.Canvas.Handle, 0, 0, SRCINVERT);
|
||||
finally
|
||||
bmp.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TCanvasDrawer }
|
||||
|
||||
procedure TCanvasDrawer.AddToFontOrientation(ADelta: Integer);
|
||||
@ -304,8 +281,39 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCanvasDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
|
||||
|
||||
procedure DrawXorText;
|
||||
var
|
||||
bmp: TBitmap;
|
||||
p, ext, bmpSize: TPoint;
|
||||
a: Double;
|
||||
begin
|
||||
ext := FCanvas.TextExtent(AText);
|
||||
a := OrientToRad(FCanvas.Font.Orientation);
|
||||
bmpSize := MeasureRotatedRect(ext, a);
|
||||
p := bmpSize div 2 - RotatePoint(ext div 2, -a);
|
||||
|
||||
bmp := TBitmap.Create;
|
||||
try
|
||||
bmp.SetSize(bmpSize.X, bmpSize.Y);
|
||||
bmp.Canvas.Brush.Style := bsClear;
|
||||
bmp.Canvas.Font := FCanvas.Font;
|
||||
bmp.Canvas.Font.Color := clWhite;
|
||||
bmp.Canvas.TextOut(p.X, p.Y, AText);
|
||||
bmp.Canvas.Pen.Color := clWhite;
|
||||
BitBlt(
|
||||
FCanvas.Handle, AX - p.X, AY - p.Y, bmpSize.X, bmpSize.Y,
|
||||
bmp.Canvas.Handle, 0, 0, SRCINVERT);
|
||||
finally
|
||||
bmp.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
FCanvas.TextOut(AX, AY, AText);
|
||||
if FXor then
|
||||
DrawXorText
|
||||
else
|
||||
FCanvas.TextOut(AX, AY, AText);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
Loading…
Reference in New Issue
Block a user