Merged revision(s) 62505-62506 #fbf5621974-#fbf5621974 from trunk:

LCL: grids: don't store default TitleFont
........
Grid: fix High-DPI font scaling
........

git-svn-id: branches/fixes_2_0@62838 -
This commit is contained in:
maxim 2020-03-31 21:25:27 +00:00
parent b110179beb
commit cb59956acd

View File

@ -479,6 +479,8 @@ type
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure FillTitleDefaultFont;
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); virtual;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); virtual;
function IsDefault: boolean;
property Column: TGridColumn read FColumn;
published
@ -582,6 +584,8 @@ type
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure FillDefaultFont;
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); virtual;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); virtual;
function IsDefault: boolean; virtual;
property Grid: TCustomGrid read GetGrid;
property DefaultWidth: Integer read GetDefaultWidth;
@ -909,6 +913,7 @@ type
procedure SetTopRow(const AValue: Integer);
function StartColSizing(const X, Y: Integer): boolean;
procedure ChangeCursor(ACursor: Integer = MAXINT);
function TitleFontIsStored: Boolean;
function TrySmoothScrollBy(aColDelta, aRowDelta: Integer): Boolean;
procedure TryScrollTo(aCol,aRow: Integer; ClearColOff, ClearRowOff: Boolean);
procedure UpdateCachedSizes;
@ -1116,6 +1121,8 @@ type
procedure RowHeightsChanged; virtual;
procedure SaveContent(cfg: TXMLConfig); virtual;
procedure SaveGridOptions(cfg: TXMLConfig); virtual;
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
procedure ScrollBarRange(Which:Integer; aRange,aPage,aPos: Integer);
procedure ScrollBarPosition(Which, Value: integer);
function ScrollBarIsVisible(Which:Integer): Boolean;
@ -1225,7 +1232,7 @@ type
property Selection: TGridRect read GetSelection write SetSelection;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssAutoBoth;
property StrictSort: boolean read FStrictSort write FStrictSort;
property TitleFont: TFont read FTitleFont write SetTitleFont;
property TitleFont: TFont read FTitleFont write SetTitleFont stored TitleFontIsStored;
property TitleStyle: TTitleStyle read FTitleStyle write SetTitleStyle default tsLazarus;
property TopRow: Integer read GetTopRow write SetTopRow;
property UseXORFeatures: boolean read FUseXORFeatures write SetUseXorFeatures default false;
@ -4024,6 +4031,11 @@ begin
DoPushCell;
end;
function TCustomGrid.TitleFontIsStored: Boolean;
begin
Result := not FTitleFontIsDefault;
end;
function TCustomGrid.SelectCell(ACol, ARow: Integer): Boolean;
begin
Result:=true;
@ -8351,6 +8363,20 @@ begin
result := FixedCols;
end;
procedure TCustomGrid.FixDesignFontsPPI(const ADesignTimePPI: Integer);
var
LTitleFontIsDefault: Boolean;
I: Integer;
begin
inherited FixDesignFontsPPI(ADesignTimePPI);
LTitleFontIsDefault := FTitleFontIsDefault;
DoFixDesignFontPPI(TitleFont, ADesignTimePPI);
FTitleFontIsDefault := LTitleFontIsDefault;
for I := 0 to FColumns.Count-1 do
FColumns[I].FixDesignFontsPPI(ADesignTimePPI);
end;
function TCustomGrid.FixedGrid: boolean;
begin
result := (FixedCols=ColCount) or (FixedRows=RowCount)
@ -9755,6 +9781,18 @@ begin
end;
end;
procedure TCustomGrid.ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double);
var
LTitleFontIsDefault: Boolean;
I: Integer;
begin
inherited ScaleFontsPPI(AToPPI, AProportion);
LTitleFontIsDefault := FTitleFontIsDefault;
DoScaleFontPPI(TitleFont, AToPPI, AProportion);
FTitleFontIsDefault := LTitleFontIsDefault;
for I := 0 to FColumns.Count-1 do
FColumns[I].ScaleFontsPPI(AToPPI, AProportion);
end;
type
TWinCtrlAccess=class(TWinControl);
@ -11956,6 +11994,15 @@ begin
FIsDefaultTitleFont := True;
end;
procedure TGridColumnTitle.FixDesignFontsPPI(const ADesignTimePPI: Integer);
var
LIsDefaultTitleFont: Boolean;
begin
LIsDefaultTitleFont := FIsDefaultTitleFont;
FColumn.Grid.DoFixDesignFontPPI(Font, ADesignTimePPI);
FIsDefaultTitleFont := LIsDefaultTitleFont;
end;
function TGridColumnTitle.GetFont: TFont;
begin
Result := FFont;
@ -11994,6 +12041,15 @@ begin
result := FLayout <> nil;
end;
procedure TGridColumnTitle.ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double);
var
LIsDefaultTitleFont: Boolean;
begin
LIsDefaultTitleFont := FIsDefaultTitleFont;
FColumn.Grid.DoScaleFontPPI(Font, AToPPI, AProportion);
FIsDefaultTitleFont := LIsDefaultTitleFont;
end;
procedure TGridColumnTitle.SetAlignment(const AValue: TAlignment);
begin
if Falignment = nil then begin
@ -12354,6 +12410,16 @@ begin
result := FWidth <> nil;
end;
procedure TGridColumn.ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double);
var
LisDefaultFont: Boolean;
begin
LisDefaultFont := FisDefaultFont;
Grid.DoScaleFontPPI(Font, AToPPI, AProportion);
FisDefaultFont := LisDefaultFont;
Title.ScaleFontsPPI(AToPPI, AProportion);
end;
procedure TGridColumn.SetAlignment(const AValue: TAlignment);
begin
if FAlignment = nil then begin
@ -12720,6 +12786,16 @@ begin
end;
end;
procedure TGridColumn.FixDesignFontsPPI(const ADesignTimePPI: Integer);
var
LisDefaultFont: Boolean;
begin
LisDefaultFont := FisDefaultFont;
Grid.DoFixDesignFontPPI(Font, ADesignTimePPI);
FisDefaultFont := LisDefaultFont;
Title.FixDesignFontsPPI(ADesignTimePPI);
end;
function TGridColumn.IsDefault: boolean;
begin
result := FTitle.IsDefault and (FAlignment=nil) and (FColor=nil)