mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
SynEdit: start refactor gutter painting
git-svn-id: trunk@34829 -
This commit is contained in:
parent
e588d500e4
commit
bd8a968767
@ -14,7 +14,7 @@ type
|
|||||||
|
|
||||||
{ TLazSynTextArea }
|
{ TLazSynTextArea }
|
||||||
|
|
||||||
TLazSynTextArea = class(TPersistent)
|
TLazSynTextArea = class(TLazSynSurface)
|
||||||
private
|
private
|
||||||
FCharsInWindow: Integer;
|
FCharsInWindow: Integer;
|
||||||
FCharWidth: integer;
|
FCharWidth: integer;
|
||||||
@ -32,7 +32,7 @@ type
|
|||||||
FBackgroundColor: TColor;
|
FBackgroundColor: TColor;
|
||||||
FRightEdgeColor: TColor;
|
FRightEdgeColor: TColor;
|
||||||
|
|
||||||
FBounds, FTextBounds: TRect;
|
FTextBounds: TRect;
|
||||||
FPadding: array [TLazSynBorderSide] of Integer;
|
FPadding: array [TLazSynBorderSide] of Integer;
|
||||||
FExtraCharSpacing: integer;
|
FExtraCharSpacing: integer;
|
||||||
FExtraLineSpacing: integer;
|
FExtraLineSpacing: integer;
|
||||||
@ -51,6 +51,8 @@ type
|
|||||||
procedure SetTopLine(AValue: TLinePos);
|
procedure SetTopLine(AValue: TLinePos);
|
||||||
procedure DoDrawerFontChanged(Sender: TObject);
|
procedure DoDrawerFontChanged(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
|
procedure BoundsChanged; override;
|
||||||
|
procedure DoPaint(ACanvas: TCanvas; AClip: TRect); override;
|
||||||
procedure PaintTextLines(AClip: TRect; FirstLine, LastLine,
|
procedure PaintTextLines(AClip: TRect; FirstLine, LastLine,
|
||||||
FirstCol, LastCol: integer); virtual;
|
FirstCol, LastCol: integer); virtual;
|
||||||
property Canvas: TCanvas read FCanvas;
|
property Canvas: TCanvas read FCanvas;
|
||||||
@ -63,11 +65,9 @@ type
|
|||||||
function RowColumnToPixels(const RowCol: TPoint): TPoint;
|
function RowColumnToPixels(const RowCol: TPoint): TPoint;
|
||||||
function PixelsToRowColumn(Pixels: TPoint; aFlags: TSynCoordinateMappingFlags): TPoint; // ignores scmLimitToLines
|
function PixelsToRowColumn(Pixels: TPoint; aFlags: TSynCoordinateMappingFlags): TPoint; // ignores scmLimitToLines
|
||||||
|
|
||||||
procedure FontChanged; // must be called by owner of shared tetdrawer
|
procedure FontChanged;
|
||||||
procedure Paint(ACanvas: TCanvas; AClip: TRect);
|
|
||||||
|
|
||||||
// Settings controlled by SynEdit
|
// Settings controlled by SynEdit
|
||||||
procedure SetBounds(ATop, ALeft, ABottom, ARight: Integer);
|
|
||||||
property Padding[Side: TLazSynBorderSide]: integer read GetPadding write SetPadding;
|
property Padding[Side: TLazSynBorderSide]: integer read GetPadding write SetPadding;
|
||||||
property ForegroundColor: TColor read FForegroundColor write FForegroundColor;
|
property ForegroundColor: TColor read FForegroundColor write FForegroundColor;
|
||||||
property BackgroundColor: TColor read FBackgroundColor write FBackgroundColor;
|
property BackgroundColor: TColor read FBackgroundColor write FBackgroundColor;
|
||||||
@ -86,11 +86,6 @@ type
|
|||||||
property Highlighter: TSynCustomHighlighter read FHighlighter write FHighlighter;
|
property Highlighter: TSynCustomHighlighter read FHighlighter write FHighlighter;
|
||||||
property MarkupManager: TSynEditMarkupManager read FMarkupManager write FMarkupManager;
|
property MarkupManager: TSynEditMarkupManager read FMarkupManager write FMarkupManager;
|
||||||
public
|
public
|
||||||
property Left: Integer read FBounds.Left;
|
|
||||||
property Top: Integer read FBounds.Top;
|
|
||||||
property Right:Integer read FBounds.Right;
|
|
||||||
property Bottom: integer read FBounds.Bottom;
|
|
||||||
property Bounds: TRect read FBounds;
|
|
||||||
property TextBounds: TRect read FTextBounds;
|
property TextBounds: TRect read FTextBounds;
|
||||||
|
|
||||||
property LineHeight: integer read FTextHeight;
|
property LineHeight: integer read FTextHeight;
|
||||||
@ -99,24 +94,74 @@ type
|
|||||||
property CharsInWindow: Integer read FCharsInWindow;
|
property CharsInWindow: Integer read FCharsInWindow;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TLazSynSurfaceManager }
|
||||||
|
|
||||||
|
TLazSynSurfaceManager = class(TLazSynSurface)
|
||||||
|
private
|
||||||
|
FLeftGutterArea: TLazSynSurface;
|
||||||
|
FLeftGutterWidth: integer;
|
||||||
|
FRightGutterArea: TLazSynSurface;
|
||||||
|
FRightGutterWidth: integer;
|
||||||
|
FTextArea: TLazSynTextArea;
|
||||||
|
procedure SetLeftGutterWidth(AValue: integer);
|
||||||
|
procedure SetRightGutterWidth(AValue: integer);
|
||||||
|
protected
|
||||||
|
procedure DoPaint(ACanvas: TCanvas; AClip: TRect); override;
|
||||||
|
procedure BoundsChanged; override;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
property TextArea: TLazSynTextArea read FTextArea write FTextArea;
|
||||||
|
property LeftGutterArea: TLazSynSurface read FLeftGutterArea write FLeftGutterArea;
|
||||||
|
property RightGutterArea: TLazSynSurface read FRightGutterArea write FRightGutterArea;
|
||||||
|
property LeftGutterWidth: integer read FLeftGutterWidth write SetLeftGutterWidth;
|
||||||
|
property RightGutterWidth: integer read FRightGutterWidth write SetRightGutterWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TLazSynTextArea }
|
{ TLazSynSurfaceManager }
|
||||||
|
|
||||||
procedure TLazSynTextArea.SetBounds(ATop, ALeft, ABottom, ARight: Integer);
|
procedure TLazSynSurfaceManager.SetLeftGutterWidth(AValue: integer);
|
||||||
begin
|
begin
|
||||||
FBounds.Left := ALeft;
|
if FLeftGutterWidth = AValue then Exit;
|
||||||
FBounds.Top := ATop;
|
FLeftGutterWidth := AValue;
|
||||||
FBounds.Right := ARight;
|
BoundsChanged;
|
||||||
FBounds.Bottom := ABottom;
|
|
||||||
FTextBounds.Left := Left + FPadding[bsLeft];
|
|
||||||
FTextBounds.Top := Top + FPadding[bsTop];
|
|
||||||
FTextBounds.Right := Right - FPadding[bsRight];
|
|
||||||
FTextBounds.Bottom := Bottom - FPadding[bsBottom];
|
|
||||||
FontChanged;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynSurfaceManager.SetRightGutterWidth(AValue: integer);
|
||||||
|
begin
|
||||||
|
if FRightGutterWidth = AValue then Exit;
|
||||||
|
FRightGutterWidth := AValue;
|
||||||
|
BoundsChanged;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynSurfaceManager.DoPaint(ACanvas: TCanvas; AClip: TRect);
|
||||||
|
begin
|
||||||
|
FLeftGutterArea.Paint(ACanvas, AClip);
|
||||||
|
FTextArea.Paint(ACanvas, AClip);
|
||||||
|
FRightGutterArea.Paint(ACanvas, AClip);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynSurfaceManager.BoundsChanged;
|
||||||
|
var
|
||||||
|
l, r: Integer;
|
||||||
|
begin
|
||||||
|
r := Max(Left, Right - RightGutterWidth);
|
||||||
|
l := Min(r, Left + LeftGutterWidth);
|
||||||
|
FLeftGutterArea.SetBounds(Top, Left, Bottom, l);
|
||||||
|
FTextArea.SetBounds(Top, l, Bottom, r);
|
||||||
|
FRightGutterArea.SetBounds(Top, r, Bottom, Right);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TLazSynSurfaceManager.Create;
|
||||||
|
begin
|
||||||
|
FLeftGutterWidth := 0;
|
||||||
|
FRightGutterWidth := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TLazSynTextArea }
|
||||||
|
|
||||||
function TLazSynTextArea.GetPadding(Side: TLazSynBorderSide): integer;
|
function TLazSynTextArea.GetPadding(Side: TLazSynBorderSide): integer;
|
||||||
begin
|
begin
|
||||||
Result := FPadding[Side];
|
Result := FPadding[Side];
|
||||||
@ -167,6 +212,15 @@ begin
|
|||||||
FontChanged;
|
FontChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynTextArea.BoundsChanged;
|
||||||
|
begin
|
||||||
|
FTextBounds.Left := Left + FPadding[bsLeft];
|
||||||
|
FTextBounds.Top := Top + FPadding[bsTop];
|
||||||
|
FTextBounds.Right := Right - FPadding[bsRight];
|
||||||
|
FTextBounds.Bottom := Bottom - FPadding[bsBottom];
|
||||||
|
FontChanged;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLazSynTextArea.ScreenColumnToXValue(Col: integer): integer;
|
function TLazSynTextArea.ScreenColumnToXValue(Col: integer): integer;
|
||||||
begin
|
begin
|
||||||
Result := FTextBounds.Left + (Col - LeftChar) * fCharWidth;
|
Result := FTextBounds.Left + (Col - LeftChar) * fCharWidth;
|
||||||
@ -239,18 +293,12 @@ begin
|
|||||||
FLinesInWindow := Max(0, (FTextBounds.Bottom - FTextBounds.Top) div FTextHeight);
|
FLinesInWindow := Max(0, (FTextBounds.Bottom - FTextBounds.Top) div FTextHeight);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazSynTextArea.Paint(ACanvas: TCanvas; AClip: TRect);
|
procedure TLazSynTextArea.DoPaint(ACanvas: TCanvas; AClip: TRect);
|
||||||
var
|
var
|
||||||
PadRect, PadRect2: TRect;
|
PadRect, PadRect2: TRect;
|
||||||
ScreenRow1, ScreenRow2, TextColumn1, TextColumn2: integer;
|
ScreenRow1, ScreenRow2, TextColumn1, TextColumn2: integer;
|
||||||
dc: HDC;
|
dc: HDC;
|
||||||
begin
|
begin
|
||||||
if (AClip.Left >= FBounds.Right) or
|
|
||||||
(AClip.Right <= FBounds.Left) or
|
|
||||||
(AClip.Top >= FBounds.Bottom) or
|
|
||||||
(AClip.Bottom <= FBounds.Top)
|
|
||||||
then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
// paint padding
|
// paint padding
|
||||||
FCanvas := ACanvas;
|
FCanvas := ACanvas;
|
||||||
@ -258,25 +306,25 @@ begin
|
|||||||
SetBkColor(dc, ColorToRGB(BackgroundColor));
|
SetBkColor(dc, ColorToRGB(BackgroundColor));
|
||||||
|
|
||||||
if (AClip.Top < FTextBounds.Top) then begin
|
if (AClip.Top < FTextBounds.Top) then begin
|
||||||
PadRect2 := FBounds;
|
PadRect2 := Bounds;
|
||||||
PadRect2.Bottom := FTextBounds.Top;
|
PadRect2.Bottom := FTextBounds.Top;
|
||||||
IntersectRect(PadRect, AClip, PadRect2);
|
IntersectRect(PadRect, AClip, PadRect2);
|
||||||
InternalFillRect(dc, PadRect);
|
InternalFillRect(dc, PadRect);
|
||||||
end;
|
end;
|
||||||
if (AClip.Bottom > FTextBounds.Bottom) then begin
|
if (AClip.Bottom > FTextBounds.Bottom) then begin
|
||||||
PadRect2 := FBounds;
|
PadRect2 := Bounds;
|
||||||
PadRect2.Top := FTextBounds.Bottom;
|
PadRect2.Top := FTextBounds.Bottom;
|
||||||
IntersectRect(PadRect, AClip, PadRect2);
|
IntersectRect(PadRect, AClip, PadRect2);
|
||||||
InternalFillRect(dc, PadRect);
|
InternalFillRect(dc, PadRect);
|
||||||
end;
|
end;
|
||||||
if (AClip.Left < FTextBounds.Left) then begin
|
if (AClip.Left < FTextBounds.Left) then begin
|
||||||
PadRect2 := FBounds;
|
PadRect2 := Bounds;
|
||||||
PadRect2.Right := FTextBounds.Left;
|
PadRect2.Right := FTextBounds.Left;
|
||||||
IntersectRect(PadRect, AClip, PadRect2);
|
IntersectRect(PadRect, AClip, PadRect2);
|
||||||
InternalFillRect(dc, PadRect);
|
InternalFillRect(dc, PadRect);
|
||||||
end;
|
end;
|
||||||
if (AClip.Right > FTextBounds.Right) then begin
|
if (AClip.Right > FTextBounds.Right) then begin
|
||||||
PadRect2 := FBounds;
|
PadRect2 := Bounds;
|
||||||
PadRect2.Left := FTextBounds.Right;
|
PadRect2.Left := FTextBounds.Right;
|
||||||
IntersectRect(PadRect, AClip, PadRect2);
|
IntersectRect(PadRect, AClip, PadRect2);
|
||||||
InternalFillRect(dc, PadRect);
|
InternalFillRect(dc, PadRect);
|
||||||
|
@ -433,6 +433,8 @@ type
|
|||||||
FTopLinesView: TSynEditStrings; // The linesview that holds the real line-buffer/FLines
|
FTopLinesView: TSynEditStrings; // The linesview that holds the real line-buffer/FLines
|
||||||
FDisplayView: TLazSynDisplayView;
|
FDisplayView: TLazSynDisplayView;
|
||||||
FTextArea: TLazSynTextArea;
|
FTextArea: TLazSynTextArea;
|
||||||
|
FLeftGutterArea, FRightGutterArea: TLazSynGutterArea;
|
||||||
|
FPaintArea: TLazSynSurfaceManager;
|
||||||
|
|
||||||
fExtraCharSpacing: integer;
|
fExtraCharSpacing: integer;
|
||||||
fMaxLeftChar: Integer; // 1024
|
fMaxLeftChar: Integer; // 1024
|
||||||
@ -1910,6 +1912,18 @@ begin
|
|||||||
FTextArea.DisplayView := FDisplayView;
|
FTextArea.DisplayView := FDisplayView;
|
||||||
FTextArea.Highlighter := nil;
|
FTextArea.Highlighter := nil;
|
||||||
|
|
||||||
|
FLeftGutterArea := TLazSynGutterArea.Create;
|
||||||
|
FLeftGutterArea.TextArea := FTextArea;
|
||||||
|
FLeftGutterArea.Gutter := FLeftGutter;
|
||||||
|
FRightGutterArea := TLazSynGutterArea.Create;
|
||||||
|
FRightGutterArea.TextArea := FTextArea;
|
||||||
|
FRightGutterArea.Gutter := FRightGutter;
|
||||||
|
|
||||||
|
FPaintArea := TLazSynSurfaceManager.Create;
|
||||||
|
FPaintArea.TextArea := FTextArea;
|
||||||
|
FPaintArea.LeftGutterArea := FLeftGutterArea;
|
||||||
|
FPaintArea.RightGutterArea := FRightGutterArea;
|
||||||
|
|
||||||
Color := clWhite;
|
Color := clWhite;
|
||||||
Font.Assign(fFontDummy);
|
Font.Assign(fFontDummy);
|
||||||
Font.OnChange := {$IFDEF FPC}@{$ENDIF}FontChanged;
|
Font.OnChange := {$IFDEF FPC}@{$ENDIF}FontChanged;
|
||||||
@ -2161,6 +2175,9 @@ begin
|
|||||||
FCaret.Lines := nil;
|
FCaret.Lines := nil;
|
||||||
FInternalCaret.Lines := nil;
|
FInternalCaret.Lines := nil;
|
||||||
FMarkList.UnRegisterChangeHandler({$IFDEF FPC}@{$ENDIF}MarkListChange);
|
FMarkList.UnRegisterChangeHandler({$IFDEF FPC}@{$ENDIF}MarkListChange);
|
||||||
|
FreeAndNil(FPaintArea);
|
||||||
|
FreeAndNil(FLeftGutterArea);
|
||||||
|
FreeAndNil(FRightGutterArea);
|
||||||
FreeAndNil(FTextArea);
|
FreeAndNil(FTextArea);
|
||||||
FreeAndNil(fTSearch);
|
FreeAndNil(fTSearch);
|
||||||
FreeAndNil(fMarkupManager);
|
FreeAndNil(fMarkupManager);
|
||||||
@ -3083,8 +3100,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCustomSynEdit.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
|
||||||
Z: integer;
|
|
||||||
begin
|
begin
|
||||||
Exclude(FStateFlags, sfHideCursor);
|
Exclude(FStateFlags, sfHideCursor);
|
||||||
inherited MouseMove(Shift, x, y);
|
inherited MouseMove(Shift, x, y);
|
||||||
@ -3173,7 +3188,6 @@ procedure TCustomSynEdit.ScrollTimerHandler(Sender: TObject);
|
|||||||
var
|
var
|
||||||
C: TPoint;
|
C: TPoint;
|
||||||
CurMousePos: TPoint;
|
CurMousePos: TPoint;
|
||||||
Z: integer;
|
|
||||||
X, Y: Integer;
|
X, Y: Integer;
|
||||||
begin
|
begin
|
||||||
// changes to line / column in one go
|
// changes to line / column in one go
|
||||||
@ -3315,8 +3329,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomSynEdit.Paint;
|
procedure TCustomSynEdit.Paint;
|
||||||
var
|
var
|
||||||
rcClip, rcDraw: TRect;
|
rcClip: TRect;
|
||||||
nL1, nL2: integer;
|
|
||||||
begin
|
begin
|
||||||
// Get the invalidated rect. Compute the invalid area in lines / columns.
|
// Get the invalidated rect. Compute the invalid area in lines / columns.
|
||||||
rcClip := Canvas.ClipRect;
|
rcClip := Canvas.ClipRect;
|
||||||
@ -3349,32 +3362,10 @@ begin
|
|||||||
|
|
||||||
Include(fStateFlags,sfPainting);
|
Include(fStateFlags,sfPainting);
|
||||||
Exclude(fStateFlags, sfHasScrolled);
|
Exclude(fStateFlags, sfHasScrolled);
|
||||||
// columns
|
|
||||||
nL1 := Max(rcClip.Top div LineHeight, 0);
|
|
||||||
nL2 := Min((rcClip.Bottom-1) div LineHeight,
|
|
||||||
FFoldedLinesView.Count - FFoldedLinesView.TopLine);
|
|
||||||
{$IFDEF SYNSCROLLDEBUG}
|
|
||||||
debugln(['PAINT ',DbgSName(self),' rect=',dbgs(rcClip), ' L1=',nL1, ' Nl2=',nL2]);
|
|
||||||
{$ENDIF}
|
|
||||||
//DebugLn('TCustomSynEdit.Paint LinesInWindow=',dbgs(LinesInWindow),' nL1=',dbgs(nL1),' nL2=',dbgs(nL2));
|
|
||||||
// Now paint everything while the caret is hidden.
|
// Now paint everything while the caret is hidden.
|
||||||
FScreenCaret.Hide;
|
FScreenCaret.Hide;
|
||||||
try
|
try
|
||||||
// First paint the gutter area if it was (partly) invalidated.
|
FPaintArea.Paint(Canvas, rcClip);
|
||||||
if FLeftGutter.Visible and (rcClip.Left < FLeftGutter.Width) then begin
|
|
||||||
rcDraw := rcClip;
|
|
||||||
rcDraw.Right := FLeftGutter.Width;
|
|
||||||
FLeftGutter.Paint(Canvas, rcDraw, nL1, nL2);
|
|
||||||
end;
|
|
||||||
// Then paint the text area if it was (partly) invalidated.
|
|
||||||
FTextArea.Paint(Canvas, rcClip);
|
|
||||||
// right gutter
|
|
||||||
if FRightGutter.Visible and (rcClip.Right > ClientWidth - FRightGutter.Width - ScrollBarWidth) then begin
|
|
||||||
rcDraw := rcClip;
|
|
||||||
rcDraw.Left := ClientWidth - FRightGutter.Width - ScrollBarWidth;
|
|
||||||
FRightGutter.Paint(Canvas, rcDraw, nL1, nL2);
|
|
||||||
end;
|
|
||||||
// If there is a custom paint handler call it.
|
|
||||||
DoOnPaint;
|
DoOnPaint;
|
||||||
finally
|
finally
|
||||||
{$IFDEF EnableDoubleBuf}
|
{$IFDEF EnableDoubleBuf}
|
||||||
@ -7027,8 +7018,11 @@ begin
|
|||||||
else r := 0;
|
else r := 0;
|
||||||
|
|
||||||
OldLinesInWindow := FTextArea.LinesInWindow;
|
OldLinesInWindow := FTextArea.LinesInWindow;
|
||||||
|
|
||||||
// TODO: lock FTextArea, so size re-calc is done once only
|
// TODO: lock FTextArea, so size re-calc is done once only
|
||||||
FTextArea.SetBounds(0, l, ClientHeight - ScrollBarWidth, ClientWidth - r - ScrollBarWidth);
|
FPaintArea.SetBounds(0, 0, ClientHeight - ScrollBarWidth, ClientWidth - ScrollBarWidth);
|
||||||
|
FPaintArea.LeftGutterWidth := l;
|
||||||
|
FPaintArea.RightGutterWidth := r;
|
||||||
|
|
||||||
if FLeftGutter.Visible
|
if FLeftGutter.Visible
|
||||||
then FTextArea.Padding[bsLeft] := GutterTextDist
|
then FTextArea.Padding[bsLeft] := GutterTextDist
|
||||||
@ -7173,10 +7167,8 @@ end;
|
|||||||
procedure TCustomSynEdit.RecalcCharExtent;
|
procedure TCustomSynEdit.RecalcCharExtent;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
OldLinesInWindow: Integer;
|
|
||||||
begin
|
begin
|
||||||
(* Highlighter or Font changed *)
|
(* Highlighter or Font changed *)
|
||||||
OldLinesInWindow := FTextArea.LinesInWindow;
|
|
||||||
|
|
||||||
FFontDummy.Assign(Font);
|
FFontDummy.Assign(Font);
|
||||||
with FFontDummy do begin
|
with FFontDummy do begin
|
||||||
|
@ -264,6 +264,25 @@ type
|
|||||||
property UnderlinePriority default 0;
|
property UnderlinePriority default 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TLazSynSurface }
|
||||||
|
|
||||||
|
TLazSynSurface = class
|
||||||
|
private
|
||||||
|
FBounds: TRect;
|
||||||
|
protected
|
||||||
|
procedure BoundsChanged; virtual;
|
||||||
|
procedure DoPaint(ACanvas: TCanvas; AClip: TRect); virtual; abstract;
|
||||||
|
public
|
||||||
|
procedure Paint(ACanvas: TCanvas; AClip: TRect);
|
||||||
|
procedure SetBounds(ATop, ALeft, ABottom, ARight: Integer);
|
||||||
|
|
||||||
|
property Left: Integer read FBounds.Left;
|
||||||
|
property Top: Integer read FBounds.Top;
|
||||||
|
property Right:Integer read FBounds.Right;
|
||||||
|
property Bottom: integer read FBounds.Bottom;
|
||||||
|
property Bounds: TRect read FBounds;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynBookMarkOpt }
|
{ TSynBookMarkOpt }
|
||||||
|
|
||||||
TSynBookMarkOpt = class(TPersistent)
|
TSynBookMarkOpt = class(TPersistent)
|
||||||
@ -804,6 +823,43 @@ begin
|
|||||||
(Style <> []) or (StyleMask <> []);
|
(Style <> []) or (StyleMask <> []);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TLazSynSurface }
|
||||||
|
|
||||||
|
procedure TLazSynSurface.BoundsChanged;
|
||||||
|
begin
|
||||||
|
//
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynSurface.Paint(ACanvas: TCanvas; AClip: TRect);
|
||||||
|
begin
|
||||||
|
if (AClip.Left >= Bounds.Right) or
|
||||||
|
(AClip.Right <= Bounds.Left) or
|
||||||
|
(AClip.Top >= Bounds.Bottom) or
|
||||||
|
(AClip.Bottom <= Bounds.Top)
|
||||||
|
then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
if (AClip.Left < Bounds.Left) then AClip.Left := Bounds.Left;
|
||||||
|
if (AClip.Right > Bounds.Right) then AClip.Right := Bounds.Right;
|
||||||
|
if (AClip.Top < Bounds.Top) then AClip.Top := Bounds.Top;
|
||||||
|
if (AClip.Bottom < Bounds.Bottom) then AClip.Bottom := Bounds.Bottom;
|
||||||
|
|
||||||
|
DoPaint(ACanvas, AClip);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazSynSurface.SetBounds(ATop, ALeft, ABottom, ARight: Integer);
|
||||||
|
begin
|
||||||
|
if (FBounds.Left = ALeft) and (FBounds.Top = ATop) and
|
||||||
|
(FBounds.Right = ARight) and (FBounds.Bottom = ABottom)
|
||||||
|
then exit;
|
||||||
|
|
||||||
|
FBounds.Left := ALeft;
|
||||||
|
FBounds.Top := ATop;
|
||||||
|
FBounds.Right := ARight;
|
||||||
|
FBounds.Bottom := ABottom;
|
||||||
|
BoundsChanged;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynBookMarkOpt }
|
{ TSynBookMarkOpt }
|
||||||
|
|
||||||
constructor TSynBookMarkOpt.Create(AOwner: TComponent);
|
constructor TSynBookMarkOpt.Create(AOwner: TComponent);
|
||||||
|
@ -6,7 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Classes, Controls, Graphics, LCLType, LCLIntf, Menus,
|
SysUtils, Classes, Controls, Graphics, LCLType, LCLIntf, Menus,
|
||||||
SynEditMarks, SynEditMiscClasses, SynEditMiscProcs,
|
SynEditMarks, SynEditMiscClasses, SynEditMiscProcs, LazSynTextArea,
|
||||||
SynTextDrawer, SynGutterBase, SynGutterLineNumber, SynGutterCodeFolding,
|
SynTextDrawer, SynGutterBase, SynGutterLineNumber, SynGutterCodeFolding,
|
||||||
SynGutterMarks, SynGutterChanges, SynEditMouseCmds;
|
SynGutterMarks, SynGutterChanges, SynEditMouseCmds;
|
||||||
|
|
||||||
@ -92,11 +92,36 @@ type
|
|||||||
procedure InitForOptions(AnOptions: TSynEditorMouseOptions); override;
|
procedure InitForOptions(AnOptions: TSynEditorMouseOptions); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TLazSynGutterArea }
|
||||||
|
|
||||||
|
TLazSynGutterArea = class(TLazSynSurface)
|
||||||
|
private
|
||||||
|
FGutter: TSynGutter;
|
||||||
|
FTextArea: TLazSynTextArea;
|
||||||
|
protected
|
||||||
|
procedure DoPaint(ACanvas: TCanvas; AClip: TRect); override;
|
||||||
|
public
|
||||||
|
property TextArea: TLazSynTextArea read FTextArea write FTextArea;
|
||||||
|
property Gutter: TSynGutter read FGutter write FGutter;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
SynEdit;
|
SynEdit;
|
||||||
|
|
||||||
|
{ TLazSynGutterArea }
|
||||||
|
|
||||||
|
procedure TLazSynGutterArea.DoPaint(ACanvas: TCanvas; AClip: TRect);
|
||||||
|
var
|
||||||
|
ScreenRow1, ScreenRow2: integer;
|
||||||
|
begin
|
||||||
|
// TODO TextArea top/bottom padding;
|
||||||
|
ScreenRow1 := Max((AClip.Top - Bounds.Top) div TextArea.LineHeight, 0);
|
||||||
|
ScreenRow2 := Min((AClip.Bottom-1 - Bounds.Top) div TextArea.LineHeight, TextArea.LinesInWindow + 1);
|
||||||
|
|
||||||
|
FGutter.Paint(ACanvas, AClip, ScreenRow1, ScreenRow2);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynGutter }
|
{ TSynGutter }
|
||||||
|
|
||||||
constructor TSynGutter.Create(AOwner: TSynEditBase; ASide: TSynGutterSide;
|
constructor TSynGutter.Create(AOwner: TSynEditBase; ASide: TSynGutterSide;
|
||||||
|
@ -74,7 +74,7 @@ end;
|
|||||||
|
|
||||||
procedure TSynGutterChanges.Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer);
|
procedure TSynGutterChanges.Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer);
|
||||||
var
|
var
|
||||||
i, iLine: integer;
|
i, c, iLine: integer;
|
||||||
LineHeight: Integer;
|
LineHeight: Integer;
|
||||||
rcLine: TRect;
|
rcLine: TRect;
|
||||||
AliasMode: TAntialiasingMode;
|
AliasMode: TAntialiasingMode;
|
||||||
@ -82,6 +82,7 @@ begin
|
|||||||
if not Visible then exit;
|
if not Visible then exit;
|
||||||
|
|
||||||
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
||||||
|
c := TCustomSynEdit(SynEdit).Lines.Count;
|
||||||
|
|
||||||
if MarkupInfo.Background <> clNone then
|
if MarkupInfo.Background <> clNone then
|
||||||
begin
|
begin
|
||||||
@ -100,6 +101,7 @@ begin
|
|||||||
for i := FirstLine to LastLine do
|
for i := FirstLine to LastLine do
|
||||||
begin
|
begin
|
||||||
iLine := FoldView.TextIndex[i];
|
iLine := FoldView.TextIndex[i];
|
||||||
|
if (iLine < 0) or (iLine >= c) then break;
|
||||||
// next line rect
|
// next line rect
|
||||||
rcLine.Top := rcLine.Bottom;
|
rcLine.Top := rcLine.Bottom;
|
||||||
Inc(rcLine.Bottom, LineHeight);
|
Inc(rcLine.Bottom, LineHeight);
|
||||||
|
@ -218,7 +218,7 @@ end;
|
|||||||
|
|
||||||
procedure TSynGutterLineNumber.Paint(Canvas : TCanvas; AClip : TRect; FirstLine, LastLine : integer);
|
procedure TSynGutterLineNumber.Paint(Canvas : TCanvas; AClip : TRect; FirstLine, LastLine : integer);
|
||||||
var
|
var
|
||||||
i, iLine: integer;
|
i, c, iLine: integer;
|
||||||
rcLine: TRect;
|
rcLine: TRect;
|
||||||
s: string;
|
s: string;
|
||||||
dc: HDC;
|
dc: HDC;
|
||||||
@ -229,6 +229,7 @@ begin
|
|||||||
if not Visible then exit;
|
if not Visible then exit;
|
||||||
|
|
||||||
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
||||||
|
c := TCustomSynEdit(SynEdit).Lines.Count;
|
||||||
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
|
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
|
||||||
// when absolutely necessary. Note: Never change brush / pen / font of the
|
// when absolutely necessary. Note: Never change brush / pen / font of the
|
||||||
// canvas inside of this block (only through methods of fTextDrawer)!
|
// canvas inside of this block (only through methods of fTextDrawer)!
|
||||||
@ -256,6 +257,7 @@ begin
|
|||||||
for i := FirstLine to LastLine do
|
for i := FirstLine to LastLine do
|
||||||
begin
|
begin
|
||||||
iLine := FoldView.DisplayNumber[i];
|
iLine := FoldView.DisplayNumber[i];
|
||||||
|
if (iLine < 0) or (iLine >= c) then break;
|
||||||
// next line rect
|
// next line rect
|
||||||
rcLine.Top := rcLine.Bottom;
|
rcLine.Top := rcLine.Bottom;
|
||||||
// Must show a dot instead of line number if
|
// Must show a dot instead of line number if
|
||||||
|
@ -123,7 +123,10 @@ begin
|
|||||||
aFirstCustomColumnIdx := 0;
|
aFirstCustomColumnIdx := 0;
|
||||||
if FBookMarkOpt.DrawBookmarksFirst then
|
if FBookMarkOpt.DrawBookmarksFirst then
|
||||||
aFirstCustomColumnIdx := 1;
|
aFirstCustomColumnIdx := 1;
|
||||||
MLine := TCustomSynEdit(SynEdit).Marks.Line[FoldView.TextIndex[aScreenLine] + 1];
|
j := FoldView.TextIndex[aScreenLine];
|
||||||
|
if (j < 0) or (j >= TCustomSynEdit(SynEdit).Lines.Count) then
|
||||||
|
exit;
|
||||||
|
MLine := TCustomSynEdit(SynEdit).Marks.Line[j + 1];
|
||||||
if MLine = nil then
|
if MLine = nil then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user