@@ -37,14 +37,15 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
3737 lblSourceBGColour: TLabel;
3838 lblOverviewFontSize: TLabel;
3939 cbOverviewFontSize: TComboBox;
40+ lblDetailFontSize: TLabel;
41+ cbDetailFontSize: TComboBox;
4042 procedure chkHideEmptySectionsClick (Sender: TObject);
4143 procedure btnDefColoursClick (Sender: TObject);
42- procedure cbOverviewFontSizeChange (Sender: TObject);
44+ procedure FontSizeChange (Sender: TObject);
4345 strict private
4446 var
4547 // / <summary>Flag indicating if changes affect UI.</summary>
4648 fUIChanged: Boolean;
47- fOverviewFontSize: Integer;
4849 fMainColourBox: TColorBoxEx;
4950 fMainColourDlg: TColorDialogEx;
5051 fUserColourBox: TColorBoxEx;
@@ -63,7 +64,7 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
6364 function CreateCustomColourBox (const ColourDlg: TColorDialogEx):
6465 TColorBoxEx;
6566 procedure ColourBoxChangeHandler (Sender: TObject);
66- procedure PopulateFontSizeCombo ;
67+ procedure PopulateFontSizeCombos ;
6768 public
6869 constructor Create(AOwner: TComponent); override;
6970 { Class constructor. Sets up frame and populates controls.
@@ -137,8 +138,10 @@ procedure TDisplayPrefsFrame.Activate(const Prefs: IPreferences;
137138 Prefs.DBHeadingCustomColours[False].CopyTo(fMainColourDlg.CustomColors, True);
138139 Prefs.DBHeadingCustomColours[True].CopyTo(fUserColourDlg.CustomColors, True);
139140 Prefs.SourceCodeBGCustomColours.CopyTo(fSourceBGColourDlg.CustomColors, True);
140- fOverviewFontSize := Prefs.OverviewFontSize;
141- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
141+ cbOverviewFontSize.Tag := Prefs.OverviewFontSize; // store font size in .Tag
142+ cbOverviewFontSize.Text := IntToStr(Prefs.OverviewFontSize);
143+ cbDetailFontSize.Tag := Prefs.DetailFontSize; // store font size in .Tag
144+ cbDetailFontSize.Text := IntToStr(Prefs.DetailFontSize);
142145end ;
143146
144147procedure TDisplayPrefsFrame.ArrangeControls ;
@@ -149,14 +152,14 @@ procedure TDisplayPrefsFrame.ArrangeControls;
149152 [
150153 lblOverviewTree, chkHideEmptySections, chkSnippetsInNewTab,
151154 lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours,
152- lblOverviewFontSize
155+ lblOverviewFontSize, lblDetailFontSize
153156 ],
154157 0
155158 );
156159 TCtrlArranger.AlignLefts(
157160 [
158161 cbOverviewTree, fMainColourBox, fUserColourBox, fSourceBGColourBox,
159- cbOverviewFontSize
162+ cbOverviewFontSize, cbDetailFontSize
160163 ],
161164 TCtrlArranger.RightOf(
162165 [lblOverviewTree, lblMainColour, lblUserColour, lblSourceBGColour],
@@ -165,11 +168,11 @@ procedure TDisplayPrefsFrame.ArrangeControls;
165168 );
166169 TCtrlArranger.AlignVCentres(3 , [lblOverviewTree, cbOverviewTree]);
167170 TCtrlArranger.MoveBelow(
168- [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 24
171+ [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 12
169172 );
170173 TCtrlArranger.MoveBelow(chkSnippetsInNewTab, chkHideEmptySections, 8 );
171174 TCtrlArranger.AlignVCentres(
172- TCtrlArranger.BottomOf(chkHideEmptySections, 24 ),
175+ TCtrlArranger.BottomOf(chkHideEmptySections, 12 ),
173176 [lblMainColour, fMainColourBox]
174177 );
175178 TCtrlArranger.AlignVCentres(
@@ -187,6 +190,10 @@ procedure TDisplayPrefsFrame.ArrangeControls;
187190 TCtrlArranger.BottomOf(btnDefColours, 12 ),
188191 [lblOverviewFontSize, cbOverviewFontSize]
189192 );
193+ TCtrlArranger.AlignVCentres(
194+ TCtrlArranger.BottomOf(cbOverviewFontSize, 8 ),
195+ [lblDetailFontSize, cbDetailFontSize]
196+ );
190197 chkHideEmptySections.Width := Self.Width - 16 ;
191198 chkSnippetsInNewTab.Width := Self.Width - 16 ;
192199end ;
@@ -201,43 +208,6 @@ procedure TDisplayPrefsFrame.btnDefColoursClick(Sender: TObject);
201208 fUIChanged := True;
202209end ;
203210
204- procedure TDisplayPrefsFrame.cbOverviewFontSizeChange (Sender: TObject);
205- var
206- Size: Integer; // font size entered by user
207- begin
208- inherited ;
209- // Do nothing if combo box text field cleared
210- if cbOverviewFontSize.Text = ' ' then
211- Exit;
212- if TryStrToInt(cbOverviewFontSize.Text, Size) then
213- begin
214- if TFontHelper.IsInCommonFontSizeRange(Size) then
215- begin
216- // Combo has valid value entered: update
217- fOverviewFontSize := Size;
218- fUIChanged := True;
219- end
220- else
221- begin
222- // Font size out of range
223- TMessageBox.Error(
224- ParentForm,
225- Format(
226- sErrBadOverviewFontRange,
227- [TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
228- )
229- );
230- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
231- end ;
232- end
233- else
234- begin
235- // Combo has invalid value: say so
236- TMessageBox.Error(ParentForm, sErrBadOverviewFontSize);
237- cbOverviewFontSize.Text := IntToStr(fOverviewFontSize);
238- end ;
239- end ;
240-
241211procedure TDisplayPrefsFrame.chkHideEmptySectionsClick (Sender: TObject);
242212 { Handles clicks on "Hide Empty Sections" check box. Flags UI preferences has
243213 having changed.
@@ -287,7 +257,7 @@ constructor TDisplayPrefsFrame.Create(AOwner: TComponent);
287257 fSourceBGColourBox.TabOrder := 5 ;
288258 lblSourceBGColour.FocusControl := fSourceBGColourBox;
289259
290- PopulateFontSizeCombo ;
260+ PopulateFontSizeCombos ;
291261end ;
292262
293263function TDisplayPrefsFrame.CreateCustomColourBox (
@@ -330,7 +300,10 @@ procedure TDisplayPrefsFrame.Deactivate(const Prefs: IPreferences);
330300 Prefs.SourceCodeBGCustomColours.CopyFrom(
331301 fSourceBGColourDlg.CustomColors, True
332302 );
333- Prefs.OverviewFontSize := StrToIntDef(cbOverviewFontSize.Text, 8 );
303+ // Setting following properties to -1 causes preferences object to use their
304+ // default font size
305+ Prefs.OverviewFontSize := StrToIntDef(cbOverviewFontSize.Text, -1 );
306+ Prefs.DetailFontSize := StrToIntDef(cbDetailFontSize.Text, -1 );
334307end ;
335308
336309function TDisplayPrefsFrame.DisplayName : string;
@@ -344,6 +317,47 @@ function TDisplayPrefsFrame.DisplayName: string;
344317 Result := sDisplayName;
345318end ;
346319
320+ procedure TDisplayPrefsFrame.FontSizeChange (Sender: TObject);
321+ var
322+ Size: Integer; // font size entered by user
323+ CB: TComboBox; // combo box that triggered event
324+ begin
325+ inherited ;
326+ Assert(Sender is TComboBox,
327+ ClassName + ' .FontSizeChange: Sender not TComboBox' );
328+ CB := Sender as TComboBox;
329+ // Do nothing if combo box text field cleared
330+ if CB.Text = ' ' then
331+ Exit;
332+ if TryStrToInt(CB.Text, Size) then
333+ begin
334+ if TFontHelper.IsInCommonFontSizeRange(Size) then
335+ begin
336+ // Combo has valid value entered: update
337+ CB.Tag := Size;
338+ fUIChanged := True;
339+ end
340+ else
341+ begin
342+ // Font size out of range
343+ TMessageBox.Error(
344+ ParentForm,
345+ Format(
346+ sErrBadOverviewFontRange,
347+ [TFontHelper.CommonFontSizes.Min, TFontHelper.CommonFontSizes.Max]
348+ )
349+ );
350+ CB.Text := IntToStr(CB.Tag);
351+ end ;
352+ end
353+ else
354+ begin
355+ // Combo has invalid value: say so
356+ TMessageBox.Error(ParentForm, sErrBadOverviewFontSize);
357+ CB.Text := IntToStr(CB.Tag);
358+ end ;
359+ end ;
360+
347361class function TDisplayPrefsFrame.Index : Byte;
348362 { Index number that determines the location of the tab containing this frame
349363 when displayed in the preferences dialog box.
@@ -372,9 +386,12 @@ function TDisplayPrefsFrame.OverviewTreeStateDesc(
372386 Result := cOTSStartStates[State];
373387end ;
374388
375- procedure TDisplayPrefsFrame.PopulateFontSizeCombo ;
389+ procedure TDisplayPrefsFrame.PopulateFontSizeCombos ;
376390begin
391+ cbOverviewFontSize.Clear;
377392 TFontHelper.ListCommonFontSizes(cbOverviewFontSize.Items);
393+ cbDetailFontSize.Clear;
394+ TFontHelper.ListCommonFontSizes(cbDetailFontSize.Items);
378395end ;
379396
380397procedure TDisplayPrefsFrame.SelectOverviewTreeState (
0 commit comments