@@ -34,12 +34,16 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
3434 lblUserColour: TLabel;
3535 btnDefColours: TButton;
3636 lblSourceBGColour: TLabel;
37+ lblOverviewFontSize: TLabel;
38+ cbOverviewFontSize: TComboBox;
3739 procedure chkHideEmptySectionsClick (Sender: TObject);
3840 procedure btnDefColoursClick (Sender: TObject);
41+ procedure cbOverviewFontSizeChange (Sender: TObject);
3942 strict private
4043 var
4144 // / <summary>Flag indicating if changes affect UI.</summary>
4245 fUIChanged: Boolean;
46+ fOverviewFontSize: Integer;
4347 fMainColourBox: TColorBoxEx;
4448 fMainColourDlg: TColorDialogEx;
4549 fUserColourBox: TColorBoxEx;
@@ -58,6 +62,7 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
5862 function CreateCustomColourBox (const ColourDlg: TColorDialogEx):
5963 TColorBoxEx;
6064 procedure ColourBoxChangeHandler (Sender: TObject);
65+ procedure PopulateFontSizeCombo ;
6166 public
6267 constructor Create(AOwner: TComponent); override;
6368 { Class constructor. Sets up frame and populates controls.
@@ -97,14 +102,21 @@ implementation
97102
98103uses
99104 // Delphi
100- Math, Graphics, ExtCtrls,
105+ SysUtils, Math, Graphics, ExtCtrls,
101106 // Project
102- FmPreferencesDlg, UColours, UCtrlArranger, UGraphicUtils;
107+ FmPreferencesDlg, UColours, UCtrlArranger, UFontHelper, UGraphicUtils,
108+ UMessageBox;
103109
104110
105111{ $R *.dfm}
106112
107113
114+ resourcestring
115+ // Error messages
116+ sErrBadOverviewFontSize = ' Invalid font size' ;
117+ sErrBadOverviewFontRange = ' Font size out of range. '
118+ + ' Enter a value between %0:d and %1:d' ;
119+
108120{ TDisplayPrefsFrame }
109121
110122procedure TDisplayPrefsFrame.Activate (const Prefs: IPreferences;
@@ -124,6 +136,8 @@ procedure TDisplayPrefsFrame.Activate(const Prefs: IPreferences;
124136 Prefs.DBHeadingCustomColours[False].CopyTo(fMainColourDlg.CustomColors, True);
125137 Prefs.DBHeadingCustomColours[True].CopyTo(fUserColourDlg.CustomColors, True);
126138 Prefs.SourceCodeBGCustomColours.CopyTo(fSourceBGColourDlg.CustomColors, True);
139+ fOverviewFontSize := Prefs.OverviewFontSize;
140+ cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
127141end ;
128142
129143procedure TDisplayPrefsFrame.ArrangeControls ;
@@ -133,12 +147,16 @@ procedure TDisplayPrefsFrame.ArrangeControls;
133147 TCtrlArranger.AlignLefts(
134148 [
135149 lblOverviewTree, chkHideEmptySections, chkSnippetsInNewTab,
136- lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours
150+ lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours,
151+ lblOverviewFontSize
137152 ],
138153 0
139154 );
140155 TCtrlArranger.AlignLefts(
141- [cbOverviewTree, fMainColourBox, fUserColourBox, fSourceBGColourBox],
156+ [
157+ cbOverviewTree, fMainColourBox, fUserColourBox, fSourceBGColourBox,
158+ cbOverviewFontSize
159+ ],
142160 TCtrlArranger.RightOf(
143161 [lblOverviewTree, lblMainColour, lblUserColour, lblSourceBGColour],
144162 8
@@ -164,6 +182,10 @@ procedure TDisplayPrefsFrame.ArrangeControls;
164182 TCtrlArranger.MoveBelow(
165183 [lblSourceBGColour, fSourceBGColourBox], btnDefColours, 12
166184 );
185+ TCtrlArranger.AlignVCentres(
186+ TCtrlArranger.BottomOf(btnDefColours, 12 ),
187+ [lblOverviewFontSize, cbOverviewFontSize]
188+ );
167189 chkHideEmptySections.Width := Self.Width - 16 ;
168190 chkSnippetsInNewTab.Width := Self.Width - 16 ;
169191end ;
@@ -178,6 +200,43 @@ procedure TDisplayPrefsFrame.btnDefColoursClick(Sender: TObject);
178200 fUIChanged := True;
179201end ;
180202
203+ procedure TDisplayPrefsFrame.cbOverviewFontSizeChange (Sender: TObject);
204+ var
205+ Size: Integer; // font size entered by user
206+ begin
207+ inherited ;
208+ // Do nothing if combo box text field cleared
209+ if cbOverviewFontSize.Text = ' ' then
210+ Exit;
211+ if TryStrToInt(cbOverviewFontSize.Text, Size) then
212+ begin
213+ if TFontHelper.IsInCommonFontSizeRange(Size) then
214+ begin
215+ // Combo has valid value entered: update
216+ fOverviewFontSize := Size;
217+ fUIChanged := True;
218+ end
219+ else
220+ begin
221+ // Font size out of range
222+ TMessageBox.Error(
223+ ParentForm,
224+ Format(
225+ sErrBadOverviewFontRange,
226+ [TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
227+ )
228+ );
229+ cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
230+ end ;
231+ end
232+ else
233+ begin
234+ // Combo has invalid value: say so
235+ TMessageBox.Error(ParentForm, sErrBadOverviewFontSize);
236+ cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
237+ end ;
238+ end ;
239+
181240procedure TDisplayPrefsFrame.chkHideEmptySectionsClick (Sender: TObject);
182241 { Handles clicks on "Hide Empty Sections" check box. Flags UI preferences has
183242 having changed.
@@ -226,6 +285,8 @@ constructor TDisplayPrefsFrame.Create(AOwner: TComponent);
226285 fSourceBGColourBox := CreateCustomColourBox(fSourceBGColourDlg);
227286 fSourceBGColourBox.TabOrder := 5 ;
228287 lblSourceBGColour.FocusControl := fSourceBGColourBox;
288+
289+ PopulateFontSizeCombo;
229290end ;
230291
231292function TDisplayPrefsFrame.CreateCustomColourBox (
@@ -268,6 +329,7 @@ procedure TDisplayPrefsFrame.Deactivate(const Prefs: IPreferences);
268329 Prefs.SourceCodeBGCustomColours.CopyFrom(
269330 fSourceBGColourDlg.CustomColors, True
270331 );
332+ Prefs.OverviewFontSize := StrToIntDef(cbOverviewFontSize.Text, 8 );
271333end ;
272334
273335function TDisplayPrefsFrame.DisplayName : string;
@@ -309,6 +371,11 @@ function TDisplayPrefsFrame.OverviewTreeStateDesc(
309371 Result := cOTSStartStates[State];
310372end ;
311373
374+ procedure TDisplayPrefsFrame.PopulateFontSizeCombo ;
375+ begin
376+ TFontHelper.ListCommonFontSizes(cbOverviewFontSize.Items);
377+ end ;
378+
312379procedure TDisplayPrefsFrame.SelectOverviewTreeState (
313380 const State: TOverviewStartState);
314381 { Selects combo box item associated with a overview treeview startup state.
0 commit comments