mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 09:56:12 +02:00
synedit: don't statically use pen with FrameColor for TextDrawer, just create, select and delete it on demand. In other case it affects gutter and margin which uses pens too.
git-svn-id: trunk@17562 -
This commit is contained in:
parent
62995bc2be
commit
f69fe79d0e
@ -194,8 +194,6 @@ type
|
|||||||
FSaveDC: Integer;
|
FSaveDC: Integer;
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
FSavedFont: HFont;
|
FSavedFont: HFont;
|
||||||
FCrntPen: HPen;
|
|
||||||
FSavedPen: HPen;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
// Font information
|
// Font information
|
||||||
@ -227,6 +225,7 @@ type
|
|||||||
function GetUseUTF8: boolean;
|
function GetUseUTF8: boolean;
|
||||||
function GetMonoSpace: boolean;
|
function GetMonoSpace: boolean;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
function CreateColorPen(AColor: TColor): HPen;
|
||||||
property StockDC: HDC read FDC;
|
property StockDC: HDC read FDC;
|
||||||
property DrawingCount: Integer read FDrawingCount;
|
property DrawingCount: Integer read FDrawingCount;
|
||||||
property FontStock: TheFontStock read FFontStock;
|
property FontStock: TheFontStock read FFontStock;
|
||||||
@ -968,9 +967,6 @@ begin
|
|||||||
FColor := clWindowText;
|
FColor := clWindowText;
|
||||||
FBkColor := clWindow;
|
FBkColor := clWindow;
|
||||||
FFrameColor := clNone;
|
FFrameColor := clNone;
|
||||||
|
|
||||||
FSavedPen := 0;
|
|
||||||
FCrntPen := 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TheTextDrawer.Destroy;
|
destructor TheTextDrawer.Destroy;
|
||||||
@ -995,6 +991,18 @@ begin
|
|||||||
Result:=FFontStock.BaseFont.IsMonoSpace;
|
Result:=FFontStock.BaseFont.IsMonoSpace;
|
||||||
//debugln('TheTextDrawer.GetMonoSpace ',FFontStock.BaseFont.Name,' ',dbgs(FFontStock.BaseFont.IsMonoSpace),' ',dbgs(FFontStock.BaseFont.HandleAllocated));
|
//debugln('TheTextDrawer.GetMonoSpace ',FFontStock.BaseFont.Name,' ',dbgs(FFontStock.BaseFont.IsMonoSpace),' ',dbgs(FFontStock.BaseFont.HandleAllocated));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TheTextDrawer.CreateColorPen(AColor: TColor): HPen;
|
||||||
|
var
|
||||||
|
lp: TLogPen;
|
||||||
|
begin
|
||||||
|
lp.lopnColor := ColorToRGB(AColor);
|
||||||
|
lp.lopnWidth := Point(1, 0);
|
||||||
|
lp.lopnStyle := PS_SOLID;
|
||||||
|
|
||||||
|
Result := CreatePenIndirect(lp);
|
||||||
|
end;
|
||||||
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
procedure TheTextDrawer.ReleaseETODist;
|
procedure TheTextDrawer.ReleaseETODist;
|
||||||
@ -1023,10 +1031,6 @@ begin
|
|||||||
DoSetCharExtra(FCharExtra);
|
DoSetCharExtra(FCharExtra);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
FSavedFont := SelectObject(DC, FCrntFont);
|
FSavedFont := SelectObject(DC, FCrntFont);
|
||||||
if FCrntPen <> 0 then
|
|
||||||
FSavedPen := SelectObject(DC, FCrntPen)
|
|
||||||
else
|
|
||||||
FSavedPen := 0;
|
|
||||||
LCLIntf.SetTextColor(DC, FColor);
|
LCLIntf.SetTextColor(DC, FColor);
|
||||||
LCLIntf.SetBkColor(DC, FBkColor);
|
LCLIntf.SetBkColor(DC, FBkColor);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1045,12 +1049,6 @@ begin
|
|||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
if FSavedFont <> 0 then
|
if FSavedFont <> 0 then
|
||||||
SelectObject(FDC, FSavedFont);
|
SelectObject(FDC, FSavedFont);
|
||||||
if FSavedPen <> 0 then
|
|
||||||
begin
|
|
||||||
DeleteObject(SelectObject(FDC, FSavedPen));
|
|
||||||
FSavedPen := 0;
|
|
||||||
FCrntPen := 0;
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
RestoreDC(FDC, FSaveDC);
|
RestoreDC(FDC, FSaveDC);
|
||||||
end;
|
end;
|
||||||
@ -1149,23 +1147,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TheTextDrawer.SetFrameColor(AValue: TColor);
|
procedure TheTextDrawer.SetFrameColor(AValue: TColor);
|
||||||
var
|
|
||||||
lp: TLogPen;
|
|
||||||
begin
|
begin
|
||||||
if FFrameColor <> AValue then
|
if FFrameColor <> AValue then
|
||||||
begin
|
begin
|
||||||
FFrameColor := AValue;
|
FFrameColor := AValue;
|
||||||
lp.lopnColor := ColorToRGB(FFrameColor);
|
|
||||||
lp.lopnWidth := Point(1, 0);
|
|
||||||
lp.lopnStyle := PS_SOLID;
|
|
||||||
|
|
||||||
FCrntPen := CreatePenIndirect(lp);
|
|
||||||
if FDC <> 0 then
|
|
||||||
begin
|
|
||||||
if FSavedPen <> 0 then
|
|
||||||
DeleteObject(SelectObject(FDC, FSavedPen));
|
|
||||||
FSavedPen := SelectObject(FDC, FCrntPen);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1231,6 +1216,7 @@ procedure TheTextDrawer.ExtTextOut(X, Y: Integer; fuOptions: UINT;
|
|||||||
var
|
var
|
||||||
NeedDistArray: Boolean;
|
NeedDistArray: Boolean;
|
||||||
DistArray: PInteger;
|
DistArray: PInteger;
|
||||||
|
Pen, OldPen: HPen;
|
||||||
Points: array[0..4] of TPoint;
|
Points: array[0..4] of TPoint;
|
||||||
begin
|
begin
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
@ -1264,7 +1250,10 @@ begin
|
|||||||
Points[4] := TopLeft;
|
Points[4] := TopLeft;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Pen := CreateColorPen(FFrameColor);
|
||||||
|
OldPen := SelectObject(FDC, Pen);
|
||||||
Polyline(FDC, @Points, 5);
|
Polyline(FDC, @Points, 5);
|
||||||
|
DeleteObject(SelectObject(FDC, OldPen));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user