mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 16:59:11 +02:00
SynEdit Gutter: Fixing some AutoSize stuff
git-svn-id: trunk@18362 -
This commit is contained in:
parent
de0f8578f0
commit
3b28b9026f
@ -7857,7 +7857,8 @@ var
|
|||||||
begin
|
begin
|
||||||
if not (csLoading in ComponentState) then begin
|
if not (csLoading in ComponentState) then begin
|
||||||
FGutter.AutoSizeDigitCount(FTheLinesView.Count); // Todo: Make the LineNumberGutterPart an observer
|
FGutter.AutoSizeDigitCount(FTheLinesView.Count); // Todo: Make the LineNumberGutterPart an observer
|
||||||
nW := fGutter.RealGutterWidth(fCharWidth);
|
fGutter.RealGutterWidth(fCharWidth);
|
||||||
|
nW := fGutter.Width;
|
||||||
if nW = fGutterWidth then
|
if nW = fGutterWidth then
|
||||||
InvalidateGutter
|
InvalidateGutter
|
||||||
else
|
else
|
||||||
|
@ -99,7 +99,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
constructor Create(AOwner: TComponent; AGutter: TSynGutter);
|
constructor Create(AOwner: TComponent; AGutter: TSynGutter);
|
||||||
// destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property Items[Index: Integer]: TSynGutterPartBase
|
property Items[Index: Integer]: TSynGutterPartBase
|
||||||
read GetPart write PutPart; default;
|
read GetPart write PutPart; default;
|
||||||
end;
|
end;
|
||||||
@ -114,12 +114,12 @@ type
|
|||||||
FMarkupInfo: TSynSelectedColor;
|
FMarkupInfo: TSynSelectedColor;
|
||||||
FCursor: TCursor;
|
FCursor: TCursor;
|
||||||
FVisible: Boolean;
|
FVisible: Boolean;
|
||||||
FWidth : integer;
|
|
||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
FOnGutterClick: TGutterClickEvent;
|
FOnGutterClick: TGutterClickEvent;
|
||||||
function GetGutterParts: TSynGutterPartList;
|
function GetGutterParts: TSynGutterPartList;
|
||||||
procedure SetMarkupInfo(const AValue: TSynSelectedColor);
|
procedure SetMarkupInfo(const AValue: TSynSelectedColor);
|
||||||
protected
|
protected
|
||||||
|
FWidth : integer;
|
||||||
procedure SetAutoSize(const AValue : boolean); virtual;
|
procedure SetAutoSize(const AValue : boolean); virtual;
|
||||||
procedure SetVisible(const AValue : boolean); virtual;
|
procedure SetVisible(const AValue : boolean); virtual;
|
||||||
procedure SetWidth(const AValue : integer); virtual;
|
procedure SetWidth(const AValue : integer); virtual;
|
||||||
@ -476,7 +476,7 @@ begin
|
|||||||
|
|
||||||
Result := FLeftOffset + FRightOffset;
|
Result := FLeftOffset + FRightOffset;
|
||||||
|
|
||||||
for i := FGutterPartList.Count-1 downto 0 do
|
for i := GutterPartCount-1 downto 0 do
|
||||||
Result := Result + GutterPart[i].RealGutterWidth(CharWidth);
|
Result := Result + GutterPart[i].RealGutterWidth(CharWidth);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -487,7 +487,10 @@ end;
|
|||||||
|
|
||||||
function TSynGutter.GetGutterPartCount: integer;
|
function TSynGutter.GetGutterPartCount: integer;
|
||||||
begin
|
begin
|
||||||
result := FGutterPartList.Count;
|
if FGutterPartList <> nil then
|
||||||
|
result := FGutterPartList.Count
|
||||||
|
else
|
||||||
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynGutter.GetGutterPartCountByClass(AClass: TSynGutterPartBaseClass): integer;
|
function TSynGutter.GetGutterPartCountByClass(AClass: TSynGutterPartBaseClass): integer;
|
||||||
@ -552,6 +555,7 @@ procedure TSynGutter.Clear;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
if FGutterPartList = nil then exit;
|
||||||
for i := FGutterPartList.Count-1 downto 0 do
|
for i := FGutterPartList.Count-1 downto 0 do
|
||||||
GutterPart[i].Free;
|
GutterPart[i].Free;
|
||||||
FGutterPartList.Clear;
|
FGutterPartList.Clear;
|
||||||
@ -597,7 +601,7 @@ end;
|
|||||||
procedure TSynGutter.SetWidth(Value: integer);
|
procedure TSynGutter.SetWidth(Value: integer);
|
||||||
begin
|
begin
|
||||||
Value := Max(0, Value);
|
Value := Max(0, Value);
|
||||||
if FWidth <> Value then
|
if (FWidth <> Value) and not FAutoSize then
|
||||||
begin
|
begin
|
||||||
FWidth := Value;
|
FWidth := Value;
|
||||||
DoChange(Self);
|
DoChange(Self);
|
||||||
@ -606,6 +610,8 @@ end;
|
|||||||
|
|
||||||
procedure TSynGutter.DoChange(Sender: TObject);
|
procedure TSynGutter.DoChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
If FAutoSize then
|
||||||
|
FWidth := RealGutterWidth(FTextDrawer.CharWidth);
|
||||||
if Assigned(FOnChange) then
|
if Assigned(FOnChange) then
|
||||||
FOnChange(Self);
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
@ -654,7 +660,7 @@ var
|
|||||||
begin
|
begin
|
||||||
i := 0;
|
i := 0;
|
||||||
x2 := x;
|
x2 := x;
|
||||||
while i < FGutterPartList.Count-1 do begin
|
while i < GutterPartCount-1 do begin
|
||||||
if GutterPart[i].Visible then begin
|
if GutterPart[i].Visible then begin
|
||||||
if x2 >= GutterPart[i].Width then
|
if x2 >= GutterPart[i].Width then
|
||||||
x2 := x2 - GutterPart[i].Width
|
x2 := x2 - GutterPart[i].Width
|
||||||
@ -690,12 +696,13 @@ begin
|
|||||||
AClip.Left := FLeftOffset;
|
AClip.Left := FLeftOffset;
|
||||||
rcLine := AClip;
|
rcLine := AClip;
|
||||||
rcLine.Right := rcLine.Left;
|
rcLine.Right := rcLine.Left;
|
||||||
for i := 0 to FGutterPartList.Count -1 do
|
for i := 0 to GutterPartCount -1 do
|
||||||
begin
|
begin
|
||||||
|
if rcLine.Right >= AClip.Right then break;
|
||||||
if GutterPart[i].Visible then
|
if GutterPart[i].Visible then
|
||||||
begin
|
begin
|
||||||
rcLine.Left := rcLine.Right;
|
rcLine.Left := rcLine.Right;
|
||||||
rcLine.Right := rcLine.Left + GutterPart[i].Width;
|
rcLine.Right := min(rcLine.Left + GutterPart[i].Width, AClip.Right);
|
||||||
GutterPart[i].Paint(Canvas, rcLine, FirstLine, LastLine);
|
GutterPart[i].Paint(Canvas, rcLine, FirstLine, LastLine);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -737,7 +744,7 @@ end;
|
|||||||
|
|
||||||
procedure TSynGutterPartBase.SetWidth(const AValue : integer);
|
procedure TSynGutterPartBase.SetWidth(const AValue : integer);
|
||||||
begin
|
begin
|
||||||
if FWidth=AValue then exit;
|
if (FWidth=AValue) or (FAutoSize) then exit;
|
||||||
FWidth:=AValue;
|
FWidth:=AValue;
|
||||||
DoChange(self);
|
DoChange(self);
|
||||||
end;
|
end;
|
||||||
@ -798,7 +805,7 @@ end;
|
|||||||
constructor TSynGutterSeparator.Create(AOwner: TComponent);
|
constructor TSynGutterSeparator.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
Width := 2;
|
FWidth := 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynGutterSeparator.Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer);
|
procedure TSynGutterSeparator.Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer);
|
||||||
@ -842,6 +849,13 @@ begin
|
|||||||
Create(AOwner);
|
Create(AOwner);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TSynGutterPartList.Destroy;
|
||||||
|
begin
|
||||||
|
FGutter.FGutterPartList := nil;
|
||||||
|
OnChange := nil;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynGutterPartList.RegisterItem(AnItem: TSynObjectListItem);
|
procedure TSynGutterPartList.RegisterItem(AnItem: TSynObjectListItem);
|
||||||
begin
|
begin
|
||||||
TSynGutterPartBase(AnItem).OnChange := {$IFDEF FPC}@{$ENDIF}DoChange;
|
TSynGutterPartBase(AnItem).OnChange := {$IFDEF FPC}@{$ENDIF}DoChange;
|
||||||
|
@ -18,6 +18,8 @@ type
|
|||||||
function GetSavedColor: TColor;
|
function GetSavedColor: TColor;
|
||||||
procedure SetModifiedColor(const AValue: TColor);
|
procedure SetModifiedColor(const AValue: TColor);
|
||||||
procedure SetSavedColor(const AValue: TColor);
|
procedure SetSavedColor(const AValue: TColor);
|
||||||
|
protected
|
||||||
|
procedure DoChange(Sender: TObject); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -44,7 +46,7 @@ begin
|
|||||||
MarkupInfo.Foreground := clGreen;
|
MarkupInfo.Foreground := clGreen;
|
||||||
MarkupInfo.FrameColor := $00E9FC;
|
MarkupInfo.FrameColor := $00E9FC;
|
||||||
|
|
||||||
Width := 6;
|
FWidth := 4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSynGutterChanges.Destroy;
|
destructor TSynGutterChanges.Destroy;
|
||||||
@ -72,6 +74,13 @@ begin
|
|||||||
MarkupInfo.Foreground := AValue;
|
MarkupInfo.Foreground := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynGutterChanges.DoChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if AutoSize then
|
||||||
|
FWidth := 4;
|
||||||
|
inherited DoChange(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
function TSynGutterChanges.RealGutterWidth(CharWidth: integer): integer;
|
function TSynGutterChanges.RealGutterWidth(CharWidth: integer): integer;
|
||||||
begin
|
begin
|
||||||
if not Visible then
|
if not Visible then
|
||||||
|
@ -15,6 +15,8 @@ type
|
|||||||
TSynGutterCodeFolding = class(TSynGutterPartBase)
|
TSynGutterCodeFolding = class(TSynGutterPartBase)
|
||||||
private
|
private
|
||||||
FFoldView: TSynEditFoldedView;
|
FFoldView: TSynEditFoldedView;
|
||||||
|
protected
|
||||||
|
procedure DoChange(Sender: TObject); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -33,6 +35,13 @@ uses
|
|||||||
|
|
||||||
{ TSynGutterCodeFolding }
|
{ TSynGutterCodeFolding }
|
||||||
|
|
||||||
|
procedure TSynGutterCodeFolding.DoChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if AutoSize then
|
||||||
|
FWidth := 10;
|
||||||
|
inherited DoChange(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TSynGutterCodeFolding.Create(AOwner: TComponent);
|
constructor TSynGutterCodeFolding.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
@ -42,7 +51,7 @@ begin
|
|||||||
MarkupInfo.Foreground := clDkGray;
|
MarkupInfo.Foreground := clDkGray;
|
||||||
MarkupInfo.FrameColor := clNone;
|
MarkupInfo.FrameColor := clNone;
|
||||||
|
|
||||||
Width := 10;
|
FWidth := 10;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSynGutterCodeFolding.Destroy;
|
destructor TSynGutterCodeFolding.Destroy;
|
||||||
|
@ -28,6 +28,8 @@ type
|
|||||||
procedure SetShowOnlyLineNumbersMultiplesOf(const AValue : integer);
|
procedure SetShowOnlyLineNumbersMultiplesOf(const AValue : integer);
|
||||||
procedure SetZeroStart(const AValue : boolean);
|
procedure SetZeroStart(const AValue : boolean);
|
||||||
function FormatLineNumber(Line: integer; IsDot: boolean): string;
|
function FormatLineNumber(Line: integer; IsDot: boolean): string;
|
||||||
|
protected
|
||||||
|
procedure DoChange(Sender: TObject); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -63,6 +65,7 @@ begin
|
|||||||
FShowOnlyLineNumbersMultiplesOf := 1;
|
FShowOnlyLineNumbersMultiplesOf := 1;
|
||||||
FLeadingZeros := false;
|
FLeadingZeros := false;
|
||||||
FZeroStart := False;
|
FZeroStart := False;
|
||||||
|
FWidth := 25;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSynGutterLineNumber.Destroy;
|
destructor TSynGutterLineNumber.Destroy;
|
||||||
@ -133,7 +136,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if AutoSize then
|
if AutoSize then
|
||||||
Width := FAutoSizeDigitCount * CharWidth + 1;
|
FWidth := FAutoSizeDigitCount * CharWidth + 1;
|
||||||
Result := Width;
|
Result := Width;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -177,6 +180,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynGutterLineNumber.DoChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if AutoSize then
|
||||||
|
FWidth := RealGutterWidth(FTextDrawer.CharWidth);
|
||||||
|
inherited DoChange(Sender);
|
||||||
|
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, iLine: integer;
|
||||||
|
@ -17,6 +17,8 @@ type
|
|||||||
FFoldView: TSynEditFoldedView;
|
FFoldView: TSynEditFoldedView;
|
||||||
FBookMarkOpt: TSynBookMarkOpt;
|
FBookMarkOpt: TSynBookMarkOpt;
|
||||||
FInternalImage: TSynInternalImage;
|
FInternalImage: TSynInternalImage;
|
||||||
|
protected
|
||||||
|
procedure DoChange(Sender: TObject); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -33,6 +35,13 @@ uses
|
|||||||
|
|
||||||
{ TSynGutterMarks }
|
{ TSynGutterMarks }
|
||||||
|
|
||||||
|
procedure TSynGutterMarks.DoChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if AutoSize then
|
||||||
|
FWidth := 22;
|
||||||
|
inherited DoChange(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TSynGutterMarks.Create(AOwner: TComponent);
|
constructor TSynGutterMarks.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
@ -40,7 +49,7 @@ begin
|
|||||||
FBookMarkOpt := TSynEdit(SynEdit).BookMarkOptions;
|
FBookMarkOpt := TSynEdit(SynEdit).BookMarkOptions;
|
||||||
FInternalImage := nil;
|
FInternalImage := nil;
|
||||||
|
|
||||||
Width := 22;
|
FWidth := 22;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSynGutterMarks.Destroy;
|
destructor TSynGutterMarks.Destroy;
|
||||||
|
Loading…
Reference in New Issue
Block a user