mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 21:18:01 +02:00
synedit: high-DPI: implement DoAutoAdjustLayout. issue #31753
git-svn-id: trunk@55675 -
This commit is contained in:
parent
f215e1f571
commit
3f21545b7d
@ -784,6 +784,8 @@ type
|
||||
property PaintLockOwner: TSynEditBase read GetPaintLockOwner write SetPaintLockOwner;
|
||||
property TextDrawer: TheTextDrawer read fTextDrawer;
|
||||
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
const AXProportion, AYProportion: Double); override;
|
||||
protected
|
||||
procedure CreateHandle; override;
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
@ -8229,6 +8231,19 @@ begin
|
||||
inherited DestroyWnd;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.DoAutoAdjustLayout(
|
||||
const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double
|
||||
);
|
||||
begin
|
||||
inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
|
||||
|
||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||
begin
|
||||
FLeftGutter.ScalePPI(AXProportion);
|
||||
FRightGutter.ScalePPI(AXProportion);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.DoBlockIndent;
|
||||
var
|
||||
BB,BE : TPoint;
|
||||
|
@ -71,6 +71,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure RecalcBounds;
|
||||
procedure ScalePPI(const AScaleFactor: Double);
|
||||
function MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||
HandleActionProc: TSynEditMouseActionHandler): Boolean; virtual;
|
||||
procedure ResetMouseActions; virtual; // set mouse-actions according to current Options / may clear them
|
||||
@ -190,6 +191,7 @@ type
|
||||
property Height:Integer read FHeight;
|
||||
procedure Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer);
|
||||
virtual abstract;
|
||||
procedure ScalePPI(const AScaleFactor: Double); virtual;
|
||||
public
|
||||
// X/Y are relative to the gutter, not the gutter part
|
||||
function HasCustomPopupMenu(out PopMenu: TPopupMenu): Boolean; virtual;
|
||||
@ -322,6 +324,14 @@ begin
|
||||
FMouseActions.ResetUserActions;
|
||||
end;
|
||||
|
||||
procedure TSynGutterBase.ScalePPI(const AScaleFactor: Double);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
for I := 0 to PartCount-1 do
|
||||
Parts[I].ScalePPI(AScaleFactor);
|
||||
end;
|
||||
|
||||
procedure TSynGutterBase.RegisterResizeHandler(AHandler: TNotifyEvent);
|
||||
begin
|
||||
FOnResizeHandler.Add(TMethod(AHandler));
|
||||
@ -745,6 +755,11 @@ begin
|
||||
FMouseActions.ResetUserActions;
|
||||
end;
|
||||
|
||||
procedure TSynGutterPartBase.ScalePPI(const AScaleFactor: Double);
|
||||
begin
|
||||
Width := Round(Width*AScaleFactor);
|
||||
end;
|
||||
|
||||
procedure TSynGutterPartBase.DoOnGutterClick(X, Y : integer);
|
||||
begin
|
||||
if Assigned(FOnGutterClick) then
|
||||
|
@ -98,6 +98,7 @@ type
|
||||
function DoHandleMouseAction(AnAction: TSynEditMouseAction;
|
||||
var AnInfo: TSynEditMouseActionInfo): Boolean; override;
|
||||
procedure ResetMouseActions; override; // set mouse-actions according to current Options / may clear them
|
||||
procedure ScalePPI(const AScaleFactor: Double); override;
|
||||
published
|
||||
property MarkupInfo;
|
||||
property MouseActionsExpanded: TSynEditMouseActions
|
||||
@ -484,11 +485,17 @@ begin
|
||||
FMouseActionsCollapsed.ResetUserActions;
|
||||
end;
|
||||
|
||||
procedure TSynGutterCodeFolding.ScalePPI(const AScaleFactor: Double);
|
||||
begin
|
||||
AutoSize := False;
|
||||
inherited ScalePPI(AScaleFactor);
|
||||
end;
|
||||
|
||||
procedure TSynGutterCodeFolding.DrawNodeSymbol(Canvas: TCanvas; Rect: TRect;
|
||||
NodeType: TSynEditFoldLineCapability; SubType: TDrawNodeSymbolOptions);
|
||||
var
|
||||
Points: Array [0..3] of TPoint;
|
||||
X, Y: Integer;
|
||||
X, Y, LineBorder: Integer;
|
||||
AliasMode: TAntialiasingMode;
|
||||
OdlCosmetic: Boolean;
|
||||
begin
|
||||
@ -506,6 +513,7 @@ begin
|
||||
Canvas.Rectangle(Rect);
|
||||
Canvas.Pen.Style := psSolid;
|
||||
Canvas.Pen.Cosmetic := OdlCosmetic;
|
||||
LineBorder := Round((Rect.Right-Rect.Left) / 5);
|
||||
X := (Rect.Left - 1 + Rect.Right) div 2;
|
||||
Y := (Rect.Top - 1 + Rect.Bottom) div 2;
|
||||
|
||||
@ -513,8 +521,8 @@ begin
|
||||
cfFoldStart:
|
||||
begin
|
||||
// [-]
|
||||
Canvas.MoveTo(X - 2, Y);
|
||||
Canvas.LineTo(X + 3, Y);
|
||||
Canvas.MoveTo(Rect.Left + LineBorder, Y);
|
||||
Canvas.LineTo(Rect.Right - LineBorder, Y);
|
||||
end;
|
||||
cfHideStart:
|
||||
begin
|
||||
@ -525,10 +533,10 @@ begin
|
||||
cfCollapsedFold:
|
||||
begin
|
||||
// [+]
|
||||
Canvas.MoveTo(X - 2, Y);
|
||||
Canvas.LineTo(X + 3, Y);
|
||||
Canvas.MoveTo(X, Y - 2);
|
||||
Canvas.LineTo(X, Y + 3);
|
||||
Canvas.MoveTo(Rect.Left + LineBorder, Y);
|
||||
Canvas.LineTo(Rect.Right - LineBorder, Y);
|
||||
Canvas.MoveTo(X, Rect.Top + LineBorder);
|
||||
Canvas.LineTo(X, Rect.Bottom - LineBorder);
|
||||
end;
|
||||
cfCollapsedHide:
|
||||
begin
|
||||
@ -536,24 +544,22 @@ begin
|
||||
false: begin
|
||||
// [v]
|
||||
Points[0].X := X;
|
||||
Points[0].y := Y + 2;
|
||||
Points[1].X := X - 2;
|
||||
Points[0].y := Rect.Bottom - LineBorder - 1;
|
||||
Points[1].X := Rect.Left + LineBorder;
|
||||
Points[1].y := Y;
|
||||
Points[2].X := X + 2;
|
||||
Points[2].X := Rect.Right - LineBorder - 1;
|
||||
Points[2].y := Y;
|
||||
Points[3].X := X;
|
||||
Points[3].y := Y + 2;
|
||||
Points[3] := Points[0];
|
||||
end;
|
||||
true: begin
|
||||
// [v]
|
||||
Points[0].X := X;
|
||||
Points[0].y := Y - 2;
|
||||
Points[1].X := X - 2;
|
||||
Points[0].y := Rect.Top + LineBorder;
|
||||
Points[1].X := Rect.Left + LineBorder;
|
||||
Points[1].y := Y;
|
||||
Points[2].X := X + 2;
|
||||
Points[2].X := Rect.Right - LineBorder - 1;
|
||||
Points[2].y := Y;
|
||||
Points[3].X := X;
|
||||
Points[3].y := Y - 2;
|
||||
Points[3] := Points[0];
|
||||
end;
|
||||
end;
|
||||
Canvas.Polygon(Points);
|
||||
|
@ -319,6 +319,7 @@ type
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure Paint(Canvas: TCanvas; AClip: TRect; FirstLine, LastLine: integer); override;
|
||||
procedure AddMark(AMark: TSynGutterLOvMark);
|
||||
procedure ScalePPI(const AScaleFactor: Double); override;
|
||||
|
||||
function MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||
HandleActionProc: TSynEditMouseActionHandler): Boolean; override;
|
||||
@ -1041,7 +1042,7 @@ var
|
||||
begin
|
||||
if FFirstTextLineChanged > 0 then ReScan;
|
||||
|
||||
AClip.Right := AClip.Left + 3;
|
||||
AClip.Right := Round((AClip.Right - AClip.Left) / 3);
|
||||
i := AClip.Top - TopOffset;
|
||||
imax := AClip.Bottom - TopOffset;
|
||||
if imax > high(FPixLineStates) then imax := high(FPixLineStates);
|
||||
@ -1541,6 +1542,13 @@ begin
|
||||
Result := 10;
|
||||
end;
|
||||
|
||||
procedure TSynGutterLineOverview.ScalePPI(const AScaleFactor: Double);
|
||||
begin
|
||||
AutoSize := False;
|
||||
FLineMarks.ItemHeight := Round(FLineMarks.ItemHeight*AScaleFactor);
|
||||
inherited ScalePPI(AScaleFactor);
|
||||
end;
|
||||
|
||||
procedure TSynGutterLineOverview.Assign(Source : TPersistent);
|
||||
begin
|
||||
if Assigned(Source) and (Source is TSynGutterLineOverview) then
|
||||
|
Loading…
Reference in New Issue
Block a user