From c1b073f40f29c2e734734c2044e8a014469c61cd Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 10:40:32 +0000
Subject: [PATCH 01/28] Update 3rd party PJSysInfo to v5.8.0
Fixes #43
---
Src/3rdParty/PJSysInfo.pas | 162 +++++++++++++++----------------------
1 file changed, 63 insertions(+), 99 deletions(-)
diff --git a/Src/3rdParty/PJSysInfo.pas b/Src/3rdParty/PJSysInfo.pas
index 4b0a2dbd3..fa4cd593b 100644
--- a/Src/3rdParty/PJSysInfo.pas
+++ b/Src/3rdParty/PJSysInfo.pas
@@ -1,12 +1,12 @@
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
- * obtain one at https://mozilla.org/MPL/2.0/
+ * obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2001-2021, Peter Johnson (@delphidabbler).
*
- * $Rev: 2079 $
- * $Date: 2021-11-27 14:29:47 +0000 (Sat, 27 Nov 2021) $
+ * $Rev: 2082 $
+ * $Date: 2022-01-01 10:12:03 +0000 (Sat, 01 Jan 2022) $
*
* This unit contains various static classes, constants, type definitions and
* global variables for use in providing information about the host computer and
@@ -1247,6 +1247,18 @@ implementation
// - 10.0.22463.1000 (RSPRERELEASE)
Win11v21H2PreRel5Build = 22468; // Windows 11 version 21H2
// - 10.0.22468.1000 (RSPRERELEASE)
+ Win11v21H2PreRel6Build = 22471; // Windows 11 version 21H2
+ // - 10.0.22471.1000 (RSPRERELEASE)
+ Win11v21H2PreRel7Build = 22478; // Windows 11 version 21H2
+ // - 10.0.22478.1000 (RSPRERELEASE)
+ Win11v21H2PreRel8Build = 22483; // Windows 11 version 21H2
+ // - 10.0.22483.1000 (RSPRERELEASE)
+ Win11v21H2PreRel9Build = 22489; // Windows 11 version 21H2
+ // - 10.0.22489.1000 (RSPRERELEASE)
+ Win11v21H2PreRel10Build = 22494;// Windows 11 version 21H2
+ // - 10.0.22494.1000 (RSPRERELEASE)
+ Win11v21H2PreRel11Build = 22509;// Windows 11 version 21H2
+ // - 10.0.22509.1000 (RSPRERELEASE)
Win11FirstBuild = Win11DevBuild; // First build number of Windows 11
@@ -1398,6 +1410,28 @@ function IsBuildNumber(BuildNumber: DWORD): Boolean;
Result := VerifyVersionInfo(POSVI, VER_BUILDNUMBER, ConditionalMask);
end;
+// Checks if any of the given build numbers match that of the current OS.
+// If current build number is in the list, FoundBN is set to the found build
+// number and True is returned. Otherwise False is returned and FoundBN is set
+// to zero.
+function FindBuildNumberFrom(const BNs: array of Integer; var FoundBN: Integer):
+ Boolean;
+var
+ I: Integer;
+begin
+ FoundBN := 0;
+ Result := False;
+ for I := Low(BNs) to High(BNs) do
+ begin
+ if IsBuildNumber(BNs[I]) then
+ begin
+ FoundBN := BNs[I];
+ Result := True;
+ Break;
+ end;
+ end;
+end;
+
// Checks if the OS has the given product type.
// Assumes VerifyVersionInfo & VerSetConditionMask APIs functions are available
function IsWindowsProductType(ProductType: Byte): Boolean;
@@ -1631,13 +1665,6 @@ procedure InitPlatformIdEx;
GetProductInfo: TGetProductInfo; // pointer to GetProductInfo API function
SI: TSystemInfo; // structure from GetSystemInfo API call
- // Return name of Windows Server 2019 insider preview release for given build
- // number. Build must be a valid insider preview release number
- function Win2019IPExtra(const Build: Integer): string;
- begin
- Result := Format('Insider Preview Build %d', [Build]);
- end;
-
// Get OS's revision number from registry.
function GetOSRevisionNumber(const IsNT: Boolean): Integer;
begin
@@ -1824,8 +1851,8 @@ procedure InitPlatformIdEx;
// release of Win 11 -- well hidden eh?!
InternalBuildNumber := Win11v21H2Build;
case InternalBuildNumber of
- 194:
- // First public release of Windows 11
+ 194..MaxInt:
+ // Public releases of Windows 11 have build number >= 194
InternalExtraUpdateInfo := 'Version 21H2';
51, 65, 71, 100, 120, 132, 168:
InternalExtraUpdateInfo := Format(
@@ -1844,41 +1871,18 @@ procedure InitPlatformIdEx;
);
end;
end
- else if IsBuildNumber(Win11v21H2PreRel1Build) then
- begin
- InternalBuildNumber := Win11v21H2PreRel1Build;
- InternalExtraUpdateInfo := Format(
- 'Version 21H2 [RSPRERELEASE v10.0.%d.%d]',
- [InternalBuildNumber, InternalRevisionNumber]
- );
- end
- else if IsBuildNumber(Win11v21H2PreRel2Build) then
- begin
- InternalBuildNumber := Win11v21H2PreRel2Build;
- InternalExtraUpdateInfo := Format(
- 'Version 21H2 [RSPRERELEASE v10.0.%d.%d]',
- [InternalBuildNumber, InternalRevisionNumber]
- );
- end
- else if IsBuildNumber(Win11v21H2PreRel3Build) then
- begin
- InternalBuildNumber := Win11v21H2PreRel3Build;
- InternalExtraUpdateInfo := Format(
- 'Version 21H2 [RSPRERELEASE v10.0.%d.%d]',
- [InternalBuildNumber, InternalRevisionNumber]
- );
- end
- else if IsBuildNumber(Win11v21H2PreRel4Build) then
- begin
- InternalBuildNumber := Win11v21H2PreRel4Build;
- InternalExtraUpdateInfo := Format(
- 'Version 21H2 [RSPRERELEASE v10.0.%d.%d]',
- [InternalBuildNumber, InternalRevisionNumber]
- );
- end
- else if IsBuildNumber(Win11v21H2PreRel5Build) then
+ else if FindBuildNumberFrom(
+ [
+ Win11v21H2PreRel1Build, Win11v21H2PreRel2Build,
+ Win11v21H2PreRel3Build, Win11v21H2PreRel4Build,
+ Win11v21H2PreRel5Build, Win11v21H2PreRel6Build,
+ Win11v21H2PreRel7Build, Win11v21H2PreRel8Build,
+ Win11v21H2PreRel9Build, Win11v21H2PreRel10Build,
+ Win11v21H2PreRel11Build
+ ],
+ InternalBuildNumber
+ ) then
begin
- InternalBuildNumber := Win11v21H2PreRel5Build;
InternalExtraUpdateInfo := Format(
'Version 21H2 [RSPRERELEASE v10.0.%d.%d]',
[InternalBuildNumber, InternalRevisionNumber]
@@ -1925,60 +1929,20 @@ procedure InitPlatformIdEx;
InternalBuildNumber := Win2016v1803Build;
InternalExtraUpdateInfo := 'Version 1803';
end
- else if IsBuildNumber(Win2019IP180320Build) then
- begin
- InternalBuildNumber := Win2019IP180320Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180320Build);
- end
- else if IsBuildNumber(Win2019IP180324Build) then
- begin
- InternalBuildNumber := Win2019IP180324Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180324Build);
- end
- else if IsBuildNumber(Win2019IP180515Build) then
- begin
- InternalBuildNumber := Win2019IP180515Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180515Build);
- end
- else if IsBuildNumber(Win2019IP180619Build) then
- begin
- InternalBuildNumber := Win2019IP180619Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180619Build);
- end
- else if IsBuildNumber(Win2019IP180710Build) then
+ else if FindBuildNumberFrom(
+ [
+ Win2019IP180320Build, Win2019IP180324Build,
+ Win2019IP180515Build, Win2019IP180619Build,
+ Win2019IP180710Build, Win2019IP180716Build,
+ Win2019IP180731Build, Win2019IP180814Build,
+ Win2019IP180821Build, Win2019IP180828Build
+ ],
+ InternalBuildNumber
+ ) then
begin
- InternalBuildNumber := Win2019IP180710Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180710Build);
- end
- else if IsBuildNumber(Win2019IP180716Build) then
- begin
- InternalBuildNumber := Win2019IP180716Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180716Build);
- end
- else if IsBuildNumber(Win2019IP180716Build) then
- begin
- InternalBuildNumber := Win2019IP180716Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180716Build);
- end
- else if IsBuildNumber(Win2019IP180731Build) then
- begin
- InternalBuildNumber := Win2019IP180731Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180731Build);
- end
- else if IsBuildNumber(Win2019IP180814Build) then
- begin
- InternalBuildNumber := Win2019IP180814Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180814Build);
- end
- else if IsBuildNumber(Win2019IP180821Build) then
- begin
- InternalBuildNumber := Win2019IP180821Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180821Build);
- end
- else if IsBuildNumber(Win2019IP180828Build) then
- begin
- InternalBuildNumber := Win2019IP180828Build;
- InternalExtraUpdateInfo := Win2019IPExtra(Win2019IP180828Build);
+ InternalExtraUpdateInfo := Format(
+ 'Insider Preview Build %d', [InternalBuildNumber]
+ );
end
else if IsBuildNumber(Win2019v1809Build) then
begin
From 4887bd176baef2db74a20d13fb661abf8f7eb9e0 Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 16:27:50 +0000
Subject: [PATCH 02/28] Add new methods to get default font sizes.
---
Src/UFontHelper.pas | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Src/UFontHelper.pas b/Src/UFontHelper.pas
index a149d6ada..5e40c0296 100644
--- a/Src/UFontHelper.pas
+++ b/Src/UFontHelper.pas
@@ -80,6 +80,8 @@ TFontHelper = class(TNoConstructObject)
@return Handle to cloned font. Caller is responsible for releasing the
handle.
}
+ class function GetDefaultFontSize: Integer;
+ class function GetDefaultContentFontSize: Integer;
strict private
const
FallbackFontName = 'Arial'; // Fallback font name
@@ -158,6 +160,32 @@ class function TFontHelper.FontExists(const FontName: string): Boolean;
Result := Screen.Fonts.IndexOf(FontName) >= 0;
end;
+class function TFontHelper.GetDefaultContentFontSize: Integer;
+var
+ Font: TFont;
+begin
+ Font := TFont.Create;
+ try
+ SetContentFont(Font);
+ Result := Font.Size;
+ finally
+ Font.Free;
+ end;
+end;
+
+class function TFontHelper.GetDefaultFontSize: Integer;
+var
+ Font: TFont;
+begin
+ Font := TFont.Create;
+ try
+ SetDefaultFont(Font);
+ Result := Font.Size;
+ finally
+ Font.Free;
+ end;
+end;
+
class function TFontHelper.IsInCommonFontSizeRange(
const FontSize: Integer): Boolean;
begin
From 042dd8a6f2c8ad7b1e7ac7b579681864915bdc0d Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 16:31:21 +0000
Subject: [PATCH 03/28] Add DetailFontSize preference & change font size
defaults
Change font size defaults for overview pane and detail pane to get
defaults that apply to underlying OS, rather than hard wiring them.
Setting either detail pane or overview pane font size preferences to
an out of range value resets the preference to its default value.
---
Src/UPreferences.pas | 63 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 3 deletions(-)
diff --git a/Src/UPreferences.pas b/Src/UPreferences.pas
index dc843214f..59bd8e09a 100644
--- a/Src/UPreferences.pas
+++ b/Src/UPreferences.pas
@@ -183,6 +183,14 @@ interface
property OverviewFontSize: Integer
read GetOverviewFontSize write SetOverviewFontSize;
+ /// Gets size of base font used in detail pane.
+ function GetDetailFontSize: Integer;
+ /// Sets size of base font used in detail pane.
+ procedure SetDetailFontSize(const Value: Integer);
+ /// Size of base font used in detail pane.
+ property DetailFontSize: Integer
+ read GetDetailFontSize write SetDetailFontSize;
+
/// Gets colour used for background of source code in main
/// display.
function GetSourceCodeBGColour: TColor;
@@ -289,7 +297,7 @@ implementation
SysUtils,
// Project
Hiliter.UAttrs, Hiliter.UPersist, IntfCommon, UExceptions, UColours,
- USettings;
+ UFontHelper, USettings;
type
@@ -342,6 +350,8 @@ TPreferences = class(TInterfacedObject,
/// Records size of font used in overview pane tree view.
///
fOverviewFontSize: Integer;
+ /// Records size of font used in details pane.
+ fDetailFontSize: Integer;
/// Records colour used for background of source code in main
/// display.
fSourceCodeBGColour: TColor;
@@ -366,6 +376,11 @@ TPreferences = class(TInterfacedObject,
/// Information describing snippet detail page customisations.
///
fPageStructures: TSnippetPageStructures;
+ /// Returns default font size for overview pane tree view.
+ ///
+ function DefaultOverviewFontSize: Integer;
+ /// Returns default font size for details pane.
+ function DefaultDetailFontSize: Integer;
public
/// Constructs a new object instance.
constructor Create;
@@ -510,6 +525,14 @@ TPreferences = class(TInterfacedObject,
/// Method of IPreferences.
procedure SetOverviewFontSize(const Value: Integer);
+ /// Gets size of base font used in detail pane.
+ /// Method of IPreferences.
+ function GetDetailFontSize: Integer;
+
+ /// Sets size of base font used in detail pane.
+ /// Method of IPreferences.
+ procedure SetDetailFontSize(const Value: Integer);
+
/// Gets colour used for background of source code in main
/// display.
/// Method of IPreferences.
@@ -677,6 +700,7 @@ procedure TPreferences.Assign(const Src: IInterface);
Self.fDBHeadingColours[True] := SrcPref.DBHeadingColours[True];
Self.fDBHeadingCustomColours[True] := SrcPref.DBHeadingCustomColours[True];
Self.fOverviewFontSize := SrcPref.OverviewFontSize;
+ Self.fDetailFontSize := SrcPref.DetailFontSize;
Self.fSourceCodeBGColour := SrcPref.SourceCodeBGColour;
Self.fSourceCodeBGCustomColours := SrcPref.SourceCodeBGCustomColours;
Self.fPrinterOptions := SrcPref.PrinterOptions;
@@ -701,6 +725,16 @@ constructor TPreferences.Create;
TDefaultPageStructures.SetDefaults(fPageStructures);
end;
+function TPreferences.DefaultDetailFontSize: Integer;
+begin
+ Result := TFontHelper.GetDefaultContentFontSize;
+end;
+
+function TPreferences.DefaultOverviewFontSize: Integer;
+begin
+ Result := TFontHelper.GetDefaultFontSize;
+end;
+
destructor TPreferences.Destroy;
begin
fPageStructures.Free;
@@ -723,6 +757,11 @@ function TPreferences.GetDBHeadingCustomColours(
Result := fDBHeadingCustomColours[UserDefined];
end;
+function TPreferences.GetDetailFontSize: Integer;
+begin
+ Result := fDetailFontSize;
+end;
+
function TPreferences.GetHiliteAttrs: IHiliteAttrs;
begin
Result := fHiliteAttrs;
@@ -830,6 +869,14 @@ procedure TPreferences.SetDBHeadingCustomColours(UserDefined: Boolean;
fDBHeadingCustomColours[UserDefined] := Value;
end;
+procedure TPreferences.SetDetailFontSize(const Value: Integer);
+begin
+ if TFontHelper.IsInCommonFontSizeRange(Value) then
+ fDetailFontSize := Value
+ else
+ fDetailFontSize := DefaultDetailFontSize;
+end;
+
procedure TPreferences.SetHiliteAttrs(const Attrs: IHiliteAttrs);
begin
(fHiliteAttrs as IAssignable).Assign(Attrs);
@@ -852,7 +899,10 @@ procedure TPreferences.SetNamedHiliteAttrs(NamedHiliteAttrs: INamedHiliteAttrs);
procedure TPreferences.SetOverviewFontSize(const Value: Integer);
begin
- fOverviewFontSize := Value;
+ if TFontHelper.IsInCommonFontSizeRange(Value) then
+ fOverviewFontSize := Value
+ else
+ fOverviewFontSize := DefaultOverviewFontSize;
end;
procedure TPreferences.SetOverviewStartState(const Value: TOverviewStartState);
@@ -945,6 +995,7 @@ function TPreferencesPersist.Clone: IInterface;
NewPref.DBHeadingColours[True] := Self.fDBHeadingColours[True];
NewPref.DBHeadingCustomColours[True] := Self.fDBHeadingCustomColours[True];
NewPref.OverviewFontSize := Self.fOverviewFontSize;
+ NewPref.DetailFontSize := Self.fDetailFontSize;
NewPref.SourceCodeBGColour := Self.fSourceCodeBGColour;
NewPref.SourceCodeBGCustomColours := Self.fSourceCodeBGCustomColours;
NewPref.PrinterOptions := Self.fPrinterOptions;
@@ -999,7 +1050,12 @@ constructor TPreferencesPersist.Create;
fDBHeadingCustomColours[True] := Storage.GetStrings(
'UserDBHeadingCustomColourCount', 'UserDBHeadingCustomColour%d'
);
- fOverviewFontSize := Storage.GetInteger('OverviewFontSize', 9);
+ fOverviewFontSize := Storage.GetInteger(
+ 'OverviewFontSize', DefaultOverviewFontSize
+ );
+ fDetailFontSize := Storage.GetInteger(
+ 'DetailFontSize', DefaultDetailFontSize
+ );
fSourceCodeBGCustomColours := Storage.GetStrings(
'SourceCodeBGCustomColourCount', 'SourceCodeBGCustomColour%d'
);
@@ -1071,6 +1127,7 @@ destructor TPreferencesPersist.Destroy;
Storage.SetInteger('MainDBHeadingColour', fDBHeadingColours[False]);
Storage.SetInteger('UserDBHeadingColour', fDBHeadingColours[True]);
Storage.SetInteger('OverviewFontSize', fOverviewFontSize);
+ Storage.SetInteger('DetailFontSize', fDetailFontSize);
Storage.SetInteger('SourceCodeBGColour', fSourceCodeBGColour);
Storage.SetStrings(
'MainDBHeadingCustomColourCount',
From 410543eaa8a446a9a99aca9f227f8e94cff9f3d6 Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 16:33:33 +0000
Subject: [PATCH 04/28] Add detail pane font size option & refactor font size
code
OnChange event handler for font size combo boxes is now shared
between the two. This required that current font size was store in
each combo box's Tag property rather than in separate field of
frame.
---
Src/FrDisplayPrefs.dfm | 18 ++++++-
Src/FrDisplayPrefs.pas | 115 +++++++++++++++++++++++------------------
2 files changed, 83 insertions(+), 50 deletions(-)
diff --git a/Src/FrDisplayPrefs.dfm b/Src/FrDisplayPrefs.dfm
index 5f060c451..e28212e79 100644
--- a/Src/FrDisplayPrefs.dfm
+++ b/Src/FrDisplayPrefs.dfm
@@ -40,6 +40,14 @@ inherited DisplayPrefsFrame: TDisplayPrefsFrame
Caption = 'Overview tree view &font size: '
FocusControl = cbOverviewFontSize
end
+ object lblDetailFontSize: TLabel
+ Left = 16
+ Top = 232
+ Width = 105
+ Height = 13
+ Caption = 'Detail pane font si&ze: '
+ FocusControl = cbDetailFontSize
+ end
object cbOverviewTree: TComboBox
Left = 192
Top = 2
@@ -80,6 +88,14 @@ inherited DisplayPrefsFrame: TDisplayPrefsFrame
Width = 57
Height = 21
TabOrder = 4
- OnChange = cbOverviewFontSizeChange
+ OnChange = FontSizeChange
+ end
+ object cbDetailFontSize: TComboBox
+ Left = 192
+ Top = 229
+ Width = 57
+ Height = 21
+ TabOrder = 5
+ OnChange = FontSizeChange
end
end
diff --git a/Src/FrDisplayPrefs.pas b/Src/FrDisplayPrefs.pas
index de3b90943..0109107c2 100644
--- a/Src/FrDisplayPrefs.pas
+++ b/Src/FrDisplayPrefs.pas
@@ -37,14 +37,15 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
lblSourceBGColour: TLabel;
lblOverviewFontSize: TLabel;
cbOverviewFontSize: TComboBox;
+ lblDetailFontSize: TLabel;
+ cbDetailFontSize: TComboBox;
procedure chkHideEmptySectionsClick(Sender: TObject);
procedure btnDefColoursClick(Sender: TObject);
- procedure cbOverviewFontSizeChange(Sender: TObject);
+ procedure FontSizeChange(Sender: TObject);
strict private
var
/// Flag indicating if changes affect UI.
fUIChanged: Boolean;
- fOverviewFontSize: Integer;
fMainColourBox: TColorBoxEx;
fMainColourDlg: TColorDialogEx;
fUserColourBox: TColorBoxEx;
@@ -63,7 +64,7 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
function CreateCustomColourBox(const ColourDlg: TColorDialogEx):
TColorBoxEx;
procedure ColourBoxChangeHandler(Sender: TObject);
- procedure PopulateFontSizeCombo;
+ procedure PopulateFontSizeCombos;
public
constructor Create(AOwner: TComponent); override;
{Class constructor. Sets up frame and populates controls.
@@ -137,8 +138,10 @@ procedure TDisplayPrefsFrame.Activate(const Prefs: IPreferences;
Prefs.DBHeadingCustomColours[False].CopyTo(fMainColourDlg.CustomColors, True);
Prefs.DBHeadingCustomColours[True].CopyTo(fUserColourDlg.CustomColors, True);
Prefs.SourceCodeBGCustomColours.CopyTo(fSourceBGColourDlg.CustomColors, True);
- fOverviewFontSize := Prefs.OverviewFontSize;
- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
+ cbOverviewFontSize.Tag := Prefs.OverviewFontSize; // store font size in .Tag
+ cbOverviewFontSize.Text := IntToStr(Prefs.OverviewFontSize);
+ cbDetailFontSize.Tag := Prefs.DetailFontSize; // store font size in .Tag
+ cbDetailFontSize.Text := IntToStr(Prefs.DetailFontSize);
end;
procedure TDisplayPrefsFrame.ArrangeControls;
@@ -149,14 +152,14 @@ procedure TDisplayPrefsFrame.ArrangeControls;
[
lblOverviewTree, chkHideEmptySections, chkSnippetsInNewTab,
lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours,
- lblOverviewFontSize
+ lblOverviewFontSize, lblDetailFontSize
],
0
);
TCtrlArranger.AlignLefts(
[
cbOverviewTree, fMainColourBox, fUserColourBox, fSourceBGColourBox,
- cbOverviewFontSize
+ cbOverviewFontSize, cbDetailFontSize
],
TCtrlArranger.RightOf(
[lblOverviewTree, lblMainColour, lblUserColour, lblSourceBGColour],
@@ -165,11 +168,11 @@ procedure TDisplayPrefsFrame.ArrangeControls;
);
TCtrlArranger.AlignVCentres(3, [lblOverviewTree, cbOverviewTree]);
TCtrlArranger.MoveBelow(
- [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 24
+ [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 12
);
TCtrlArranger.MoveBelow(chkSnippetsInNewTab, chkHideEmptySections, 8);
TCtrlArranger.AlignVCentres(
- TCtrlArranger.BottomOf(chkHideEmptySections, 24),
+ TCtrlArranger.BottomOf(chkHideEmptySections, 12),
[lblMainColour, fMainColourBox]
);
TCtrlArranger.AlignVCentres(
@@ -187,6 +190,10 @@ procedure TDisplayPrefsFrame.ArrangeControls;
TCtrlArranger.BottomOf(btnDefColours, 12),
[lblOverviewFontSize, cbOverviewFontSize]
);
+ TCtrlArranger.AlignVCentres(
+ TCtrlArranger.BottomOf(cbOverviewFontSize, 8),
+ [lblDetailFontSize, cbDetailFontSize]
+ );
chkHideEmptySections.Width := Self.Width - 16;
chkSnippetsInNewTab.Width := Self.Width - 16;
end;
@@ -201,43 +208,6 @@ procedure TDisplayPrefsFrame.btnDefColoursClick(Sender: TObject);
fUIChanged := True;
end;
-procedure TDisplayPrefsFrame.cbOverviewFontSizeChange(Sender: TObject);
-var
- Size: Integer; // font size entered by user
-begin
- inherited;
- // Do nothing if combo box text field cleared
- if cbOverviewFontSize.Text = '' then
- Exit;
- if TryStrToInt(cbOverviewFontSize.Text, Size) then
- begin
- if TFontHelper.IsInCommonFontSizeRange(Size) then
- begin
- // Combo has valid value entered: update
- fOverviewFontSize := Size;
- fUIChanged := True;
- end
- else
- begin
- // Font size out of range
- TMessageBox.Error(
- ParentForm,
- Format(
- sErrBadOverviewFontRange,
- [TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
- )
- );
- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
- end;
- end
- else
- begin
- // Combo has invalid value: say so
- TMessageBox.Error(ParentForm, sErrBadOverviewFontSize);
- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
- end;
-end;
-
procedure TDisplayPrefsFrame.chkHideEmptySectionsClick(Sender: TObject);
{Handles clicks on "Hide Empty Sections" check box. Flags UI preferences has
having changed.
@@ -287,7 +257,7 @@ constructor TDisplayPrefsFrame.Create(AOwner: TComponent);
fSourceBGColourBox.TabOrder := 5;
lblSourceBGColour.FocusControl := fSourceBGColourBox;
- PopulateFontSizeCombo;
+ PopulateFontSizeCombos;
end;
function TDisplayPrefsFrame.CreateCustomColourBox(
@@ -330,7 +300,10 @@ procedure TDisplayPrefsFrame.Deactivate(const Prefs: IPreferences);
Prefs.SourceCodeBGCustomColours.CopyFrom(
fSourceBGColourDlg.CustomColors, True
);
- Prefs.OverviewFontSize := StrToIntDef(cbOverviewFontSize.Text, 8);
+ // Setting following properties to -1 causes preferences object to use their
+ // default font size
+ Prefs.OverviewFontSize := StrToIntDef(cbOverviewFontSize.Text, -1);
+ Prefs.DetailFontSize := StrToIntDef(cbDetailFontSize.Text, -1);
end;
function TDisplayPrefsFrame.DisplayName: string;
@@ -344,6 +317,47 @@ function TDisplayPrefsFrame.DisplayName: string;
Result := sDisplayName;
end;
+procedure TDisplayPrefsFrame.FontSizeChange(Sender: TObject);
+var
+ Size: Integer; // font size entered by user
+ CB: TComboBox; // combo box that triggered event
+begin
+ inherited;
+ Assert(Sender is TComboBox,
+ ClassName + '.FontSizeChange: Sender not TComboBox');
+ CB := Sender as TComboBox;
+ // Do nothing if combo box text field cleared
+ if CB.Text = '' then
+ Exit;
+ if TryStrToInt(CB.Text, Size) then
+ begin
+ if TFontHelper.IsInCommonFontSizeRange(Size) then
+ begin
+ // Combo has valid value entered: update
+ CB.Tag := Size;
+ fUIChanged := True;
+ end
+ else
+ begin
+ // Font size out of range
+ TMessageBox.Error(
+ ParentForm,
+ Format(
+ sErrBadOverviewFontRange,
+ [TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
+ )
+ );
+ CB.Text := IntToStr(CB.Tag);
+ end;
+ end
+ else
+ begin
+ // Combo has invalid value: say so
+ TMessageBox.Error(ParentForm, sErrBadOverviewFontSize);
+ CB.Text := IntToStr(CB.Tag);
+ end;
+end;
+
class function TDisplayPrefsFrame.Index: Byte;
{Index number that determines the location of the tab containing this frame
when displayed in the preferences dialog box.
@@ -372,9 +386,12 @@ function TDisplayPrefsFrame.OverviewTreeStateDesc(
Result := cOTSStartStates[State];
end;
-procedure TDisplayPrefsFrame.PopulateFontSizeCombo;
+procedure TDisplayPrefsFrame.PopulateFontSizeCombos;
begin
+ cbOverviewFontSize.Clear;
TFontHelper.ListCommonFontSizes(cbOverviewFontSize.Items);
+ cbDetailFontSize.Clear;
+ TFontHelper.ListCommonFontSizes(cbDetailFontSize.Items);
end;
procedure TDisplayPrefsFrame.SelectOverviewTreeState(
From c7a09ed992bbc5d72ba263bf05c3f8295019c627 Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 16:37:41 +0000
Subject: [PATCH 05/28] Modify CSS generation to enable user specified font
size.
Adjustments had to be made to preserve ratio of sizes of baseline
content font in relation to heading a mono font styles.
---
Src/FrDetailView.pas | 76 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 63 insertions(+), 13 deletions(-)
diff --git a/Src/FrDetailView.pas b/Src/FrDetailView.pas
index 06da2e9bf..78d56a712 100644
--- a/Src/FrDetailView.pas
+++ b/Src/FrDetailView.pas
@@ -107,7 +107,7 @@ implementation
uses
// Delphi
- SysUtils, Graphics, Menus,
+ SysUtils, Graphics, Menus, Math,
// Project
ActiveText.UHTMLRenderer, Browser.UHighlighter, Hiliter.UAttrs, Hiliter.UCSS,
Hiliter.UGlobals, UColours, UCSSUtils, UFontHelper, UPreferences, UQuery,
@@ -119,27 +119,53 @@ implementation
procedure TDetailViewFrame.BuildCSS(const CSSBuilder: TCSSBuilder);
var
- HiliteAttrs: IHiliteAttrs; // syntax highlighter used to build CSS
- CSSFont: TFont; // font used to set CSS properties
+ HiliteAttrs: IHiliteAttrs; // syntax highlighter used to build CSS
+ ContentFont: TFont; // default content font sized per preferences
+ MonoFont: TFont; // default mono font sized per preferences
+ CSSFont: TFont; // font used to set CSS properties
+ ContentFontScaleFactor: Single; // amount to increase font size by to get
+ // proportionally same increase as adding 1 to
+ // default content font size
+ MonoToContentFontRatio: Single; // ratio of size of mono font to content font
+ DefContentFontSize: Integer; // default size of content font
+ DefMonoFontSize: Integer; // default size of mono font
begin
// NOTE:
// We only set CSS properties that may need to use system colours or fonts
// that may be changed by user or changing program defaults. CSS that controls
// layout remains in a CSS file embedded in resources.
inherited;
+ ContentFont := nil;
+ MonoFont := nil;
CSSFont := TFont.Create;
try
+ MonoFont := TFont.Create;
+ ContentFont := TFont.Create;
+ TFontHelper.SetDefaultMonoFont(MonoFont);
+ TFontHelper.SetContentFont(ContentFont);
+ // Must do next two lines before changing content & mono font sizes
+ DefContentFontSize := ContentFont.Size;
+ DefMonoFontSize := MonoFont.Size;
+ ContentFontScaleFactor := 1.0 / DefContentFontSize;
+ MonoToContentFontRatio := DefMonoFontSize / DefContentFontSize;
+ ContentFont.Size := Preferences.DetailFontSize;
+ MonoFont.Size := Round(ContentFont.Size * MonoToContentFontRatio);
// Set body style to use program's font and window colour
with CSSBuilder.AddSelector('body') do
begin
- TFontHelper.SetContentFont(CSSFont);
+ CSSFont.Assign(ContentFont);
AddProperty(TCSS.FontProps(CSSFont));
AddProperty(TCSS.BackgroundColorProp(clWindow));
end;
+ with CSSBuilder.Selectors['code'] do
+ begin
+ CSSFont.Assign(MonoFont);
+ AddProperty(TCSS.FontProps(CSSFont));
+ end;
// Set table to use required font
with CSSBuilder.AddSelector('table') do
begin
- TFontHelper.SetContentFont(CSSFont);
+ CSSFont.Assign(ContentFont);
AddProperty(TCSS.FontProps(CSSFont));
AddProperty(TCSS.BackgroundColorProp(clBorder));
end;
@@ -149,8 +175,10 @@ procedure TDetailViewFrame.BuildCSS(const CSSBuilder: TCSSBuilder);
// Sets H1 heading font size and border
with CSSBuilder.AddSelector('h1') do
begin
- TFontHelper.SetContentFont(CSSFont);
- CSSFont.Size := CSSFont.Size + 2;
+ CSSFont.Assign(ContentFont);
+ CSSFont.Size := CSSFont.Size + Max(
+ Round(2 * ContentFontScaleFactor * CSSFont.Size), 2
+ );
CSSFont.Style := [fsBold];
AddProperty(TCSS.FontProps(CSSFont));
AddProperty(TCSS.BorderProp(cssBottom, 1, cbsSolid, clBorder));
@@ -158,22 +186,42 @@ procedure TDetailViewFrame.BuildCSS(const CSSBuilder: TCSSBuilder);
// Sets H2 heading font size and border
with CSSBuilder.AddSelector('h2') do
begin
- TFontHelper.SetContentFont(CSSFont);
+ CSSFont.Assign(ContentFont);
CSSFont.Style := [fsBold];
AddProperty(TCSS.FontProps(CSSFont));
end;
// Set H2 heading font for use in rendered active text
with CSSBuilder.AddSelector('.active-text h2') do
begin
- TFontHelper.SetContentFont(CSSFont);
+ CSSFont.Assign(ContentFont);
CSSFont.Style := [fsBold];
- CSSFont.Size := CSSFont.Size + 1;
+ CSSFont.Size := CSSFont.Size + Max(
+ Round(ContentFontScaleFactor * CSSFont.Size), 1
+ );
+ AddProperty(TCSS.FontProps(CSSFont));
+ end;
+ // Set CODE tag within H2 heading for use in rendered active text
+ with CSSBuilder.AddSelector('.active-text h2 code') do
+ begin
+ CSSFont.Assign(MonoFont);
+ CSSFont.Style := [fsBold];
+ CSSFont.Size := CSSFont.Size + Max(
+ Round(ContentFontScaleFactor * CSSFont.Size), 1
+ );
AddProperty(TCSS.FontProps(CSSFont));
end;
// Set H2 heading font for use in rendered active text in snippet list table
with CSSBuilder.AddSelector('.snippet-list .active-text h2') do
begin
- TFontHelper.SetContentFont(CSSFont);
+ CSSFont.Assign(ContentFont);
+ CSSFont.Style := [fsBold];
+ AddProperty(TCSS.FontProps(CSSFont));
+ end;
+ // Set CODE within H2 heading font for use in rendered active text in
+ // snippet list table
+ with CSSBuilder.AddSelector('.snippet-list .active-text h2 code') do
+ begin
+ CSSFont.Assign(MonoFont);
CSSFont.Style := [fsBold];
AddProperty(TCSS.FontProps(CSSFont));
end;
@@ -187,8 +235,8 @@ procedure TDetailViewFrame.BuildCSS(const CSSBuilder: TCSSBuilder);
// Sets CSS for style of New Tab text
with CSSBuilder.AddSelector('#newtab') do
begin
- TFontHelper.SetContentFont(CSSFont);
- CSSFont.Size := 36;
+ CSSFont.Assign(ContentFont);
+ CSSFont.Size := 36 + Round(36 * ContentFontScaleFactor);
CSSFont.Color := clNewTabText;
AddProperty(TCSS.FontProps(CSSFont));
end;
@@ -218,6 +266,8 @@ procedure TDetailViewFrame.BuildCSS(const CSSBuilder: TCSSBuilder);
AddProperty(TCSS.FontWeightProp(cfwNormal));
end;
finally
+ ContentFont.Free;
+ MonoFont.Free;
CSSFont.Free;
end;
end;
From 3771b42880e6962f33aa967b2868ef7aaf465a09 Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 17:19:21 +0000
Subject: [PATCH 06/28] Change to restore default font size when bad value
assigned.
Setting highlighter font size preference to an out of range value
resets the preference to its default value.
---
Src/Hiliter.UAttrs.pas | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Src/Hiliter.UAttrs.pas b/Src/Hiliter.UAttrs.pas
index b137e6f9e..24a91dd25 100644
--- a/Src/Hiliter.UAttrs.pas
+++ b/Src/Hiliter.UAttrs.pas
@@ -107,7 +107,11 @@ THiliteAttrs = class(TInterfacedObject,
/// Method of IHiliteAttrs.
function GetFontSize: Integer;
/// Sets size of highlighter font.
- /// Method of IHiliteAttrs.
+ ///
+ /// If font size is out of range of supported sizes then the
+ /// highlighter font is reset to its default value.
+ /// Method of IHiliteAttrs.
+ ///
procedure SetFontSize(const AFontSize: Integer);
/// Resets highlighter font name and size to default values.
///
@@ -307,7 +311,10 @@ procedure THiliteAttrs.SetFontName(const AFontName: string);
procedure THiliteAttrs.SetFontSize(const AFontSize: Integer);
begin
- fFontSize := AFontSize;
+ if TFontHelper.IsInCommonFontSizeRange(AFontSize) then
+ fFontSize := AFontSize
+ else
+ fFontSize := cDefFontSize;
end;
{ THiliteElemAttrs }
From 6d58923d2e5b773eee560a63e8c8ff73abcd406f Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Sun, 2 Jan 2022 17:21:08 +0000
Subject: [PATCH 07/28] Condense dialogue controls & add info label
Add an information label explaining that Syntax Highlighter
preferences page must be used to set source code font size.
---
Src/FrDisplayPrefs.dfm | 13 +++++++++++++
Src/FrDisplayPrefs.pas | 14 ++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/Src/FrDisplayPrefs.dfm b/Src/FrDisplayPrefs.dfm
index e28212e79..80a7370ef 100644
--- a/Src/FrDisplayPrefs.dfm
+++ b/Src/FrDisplayPrefs.dfm
@@ -48,6 +48,19 @@ inherited DisplayPrefsFrame: TDisplayPrefsFrame
Caption = 'Detail pane font si&ze: '
FocusControl = cbDetailFontSize
end
+ object lblHiliterInfo: TLabel
+ Left = 16
+ Top = 256
+ Width = 370
+ Height = 36
+ Caption =
+ 'To change the size of the source code font use the the Syntax Hi' +
+ 'ghlighter options page.'
+ Color = clBtnFace
+ ParentColor = False
+ Transparent = True
+ WordWrap = True
+ end
object cbOverviewTree: TComboBox
Left = 192
Top = 2
diff --git a/Src/FrDisplayPrefs.pas b/Src/FrDisplayPrefs.pas
index 0109107c2..83ed29e2c 100644
--- a/Src/FrDisplayPrefs.pas
+++ b/Src/FrDisplayPrefs.pas
@@ -39,6 +39,7 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
cbOverviewFontSize: TComboBox;
lblDetailFontSize: TLabel;
cbDetailFontSize: TComboBox;
+ lblHiliterInfo: TLabel;
procedure chkHideEmptySectionsClick(Sender: TObject);
procedure btnDefColoursClick(Sender: TObject);
procedure FontSizeChange(Sender: TObject);
@@ -152,7 +153,7 @@ procedure TDisplayPrefsFrame.ArrangeControls;
[
lblOverviewTree, chkHideEmptySections, chkSnippetsInNewTab,
lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours,
- lblOverviewFontSize, lblDetailFontSize
+ lblOverviewFontSize, lblDetailFontSize, lblHiliterInfo
],
0
);
@@ -176,15 +177,15 @@ procedure TDisplayPrefsFrame.ArrangeControls;
[lblMainColour, fMainColourBox]
);
TCtrlArranger.AlignVCentres(
- TCtrlArranger.BottomOf([lblMainColour, fMainColourBox], 8),
+ TCtrlArranger.BottomOf([lblMainColour, fMainColourBox], 6),
[lblUserColour, fUserColourBox]
);
TCtrlArranger.AlignVCentres(
- TCtrlArranger.BottomOf([lblUserColour, fUserColourBox], 8),
+ TCtrlArranger.BottomOf([lblUserColour, fUserColourBox], 6),
[lblSourceBGColour, fSourceBGColourBox]
);
TCtrlArranger.MoveBelow(
- [lblSourceBGColour, fSourceBGColourBox], btnDefColours, 12
+ [lblSourceBGColour, fSourceBGColourBox], btnDefColours, 6
);
TCtrlArranger.AlignVCentres(
TCtrlArranger.BottomOf(btnDefColours, 12),
@@ -194,6 +195,11 @@ procedure TDisplayPrefsFrame.ArrangeControls;
TCtrlArranger.BottomOf(cbOverviewFontSize, 8),
[lblDetailFontSize, cbDetailFontSize]
);
+ TCtrlArranger.MoveBelow(
+ [lblDetailFontSize, cbDetailFontSize], lblHiliterInfo, 12
+ );
+ lblHiliterInfo.Width := Self.ClientWidth;
+ TCtrlArranger.SetLabelHeight(lblHiliterInfo);
chkHideEmptySections.Width := Self.Width - 16;
chkSnippetsInNewTab.Width := Self.Width - 16;
end;
From f5a2b5f8ef268f935fbd0cddd56409f1951cc776 Mon Sep 17 00:00:00 2001
From: delphidabbler <5164283+delphidabbler@users.noreply.github.com>
Date: Mon, 3 Jan 2022 10:37:46 +0000
Subject: [PATCH 08/28] Update help file re Display Preference Page changes
Noted new Display pane font size combo box
---
Src/Help/HTML/dlg_prefs_display.htm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Src/Help/HTML/dlg_prefs_display.htm b/Src/Help/HTML/dlg_prefs_display.htm
index 425181740..0dbb43732 100644
--- a/Src/Help/HTML/dlg_prefs_display.htm
+++ b/Src/Help/HTML/dlg_prefs_display.htm
@@ -97,6 +97,21 @@
>overview pane's tree view using the Overview tree font
size combo box.
+
+
+ Similarly, the size of font used in the details pane is set using the Detail pane font size
+ combo box.
+
+
+ Note: this combo box does
+ not affect the size of the font used to display source code
+ – this can be changed on the Syntax Highlighter Preferences page.
+
+