@@ -37,14 +37,15 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
37
37
lblSourceBGColour: TLabel;
38
38
lblOverviewFontSize: TLabel;
39
39
cbOverviewFontSize: TComboBox;
40
+ lblDetailFontSize: TLabel;
41
+ cbDetailFontSize: TComboBox;
40
42
procedure chkHideEmptySectionsClick (Sender: TObject);
41
43
procedure btnDefColoursClick (Sender: TObject);
42
- procedure cbOverviewFontSizeChange (Sender: TObject);
44
+ procedure FontSizeChange (Sender: TObject);
43
45
strict private
44
46
var
45
47
// / <summary>Flag indicating if changes affect UI.</summary>
46
48
fUIChanged: Boolean;
47
- fOverviewFontSize: Integer;
48
49
fMainColourBox: TColorBoxEx;
49
50
fMainColourDlg: TColorDialogEx;
50
51
fUserColourBox: TColorBoxEx;
@@ -63,7 +64,7 @@ TDisplayPrefsFrame = class(TPrefsBaseFrame)
63
64
function CreateCustomColourBox (const ColourDlg: TColorDialogEx):
64
65
TColorBoxEx;
65
66
procedure ColourBoxChangeHandler (Sender: TObject);
66
- procedure PopulateFontSizeCombo ;
67
+ procedure PopulateFontSizeCombos ;
67
68
public
68
69
constructor Create(AOwner: TComponent); override;
69
70
{ Class constructor. Sets up frame and populates controls.
@@ -137,8 +138,10 @@ procedure TDisplayPrefsFrame.Activate(const Prefs: IPreferences;
137
138
Prefs.DBHeadingCustomColours[False].CopyTo(fMainColourDlg.CustomColors, True);
138
139
Prefs.DBHeadingCustomColours[True].CopyTo(fUserColourDlg.CustomColors, True);
139
140
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);
142
145
end ;
143
146
144
147
procedure TDisplayPrefsFrame.ArrangeControls ;
@@ -149,14 +152,14 @@ procedure TDisplayPrefsFrame.ArrangeControls;
149
152
[
150
153
lblOverviewTree, chkHideEmptySections, chkSnippetsInNewTab,
151
154
lblMainColour, lblUserColour, lblSourceBGColour, btnDefColours,
152
- lblOverviewFontSize
155
+ lblOverviewFontSize, lblDetailFontSize
153
156
],
154
157
0
155
158
);
156
159
TCtrlArranger.AlignLefts(
157
160
[
158
161
cbOverviewTree, fMainColourBox, fUserColourBox, fSourceBGColourBox,
159
- cbOverviewFontSize
162
+ cbOverviewFontSize, cbDetailFontSize
160
163
],
161
164
TCtrlArranger.RightOf(
162
165
[lblOverviewTree, lblMainColour, lblUserColour, lblSourceBGColour],
@@ -165,11 +168,11 @@ procedure TDisplayPrefsFrame.ArrangeControls;
165
168
);
166
169
TCtrlArranger.AlignVCentres(3 , [lblOverviewTree, cbOverviewTree]);
167
170
TCtrlArranger.MoveBelow(
168
- [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 24
171
+ [lblOverviewTree, cbOverviewTree], chkSnippetsInNewTab, 12
169
172
);
170
173
TCtrlArranger.MoveBelow(chkSnippetsInNewTab, chkHideEmptySections, 8 );
171
174
TCtrlArranger.AlignVCentres(
172
- TCtrlArranger.BottomOf(chkHideEmptySections, 24 ),
175
+ TCtrlArranger.BottomOf(chkHideEmptySections, 12 ),
173
176
[lblMainColour, fMainColourBox]
174
177
);
175
178
TCtrlArranger.AlignVCentres(
@@ -187,6 +190,10 @@ procedure TDisplayPrefsFrame.ArrangeControls;
187
190
TCtrlArranger.BottomOf(btnDefColours, 12 ),
188
191
[lblOverviewFontSize, cbOverviewFontSize]
189
192
);
193
+ TCtrlArranger.AlignVCentres(
194
+ TCtrlArranger.BottomOf(cbOverviewFontSize, 8 ),
195
+ [lblDetailFontSize, cbDetailFontSize]
196
+ );
190
197
chkHideEmptySections.Width := Self.Width - 16 ;
191
198
chkSnippetsInNewTab.Width := Self.Width - 16 ;
192
199
end ;
@@ -201,43 +208,6 @@ procedure TDisplayPrefsFrame.btnDefColoursClick(Sender: TObject);
201
208
fUIChanged := True;
202
209
end ;
203
210
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
-
241
211
procedure TDisplayPrefsFrame.chkHideEmptySectionsClick (Sender: TObject);
242
212
{ Handles clicks on "Hide Empty Sections" check box. Flags UI preferences has
243
213
having changed.
@@ -287,7 +257,7 @@ constructor TDisplayPrefsFrame.Create(AOwner: TComponent);
287
257
fSourceBGColourBox.TabOrder := 5 ;
288
258
lblSourceBGColour.FocusControl := fSourceBGColourBox;
289
259
290
- PopulateFontSizeCombo ;
260
+ PopulateFontSizeCombos ;
291
261
end ;
292
262
293
263
function TDisplayPrefsFrame.CreateCustomColourBox (
@@ -330,7 +300,10 @@ procedure TDisplayPrefsFrame.Deactivate(const Prefs: IPreferences);
330
300
Prefs.SourceCodeBGCustomColours.CopyFrom(
331
301
fSourceBGColourDlg.CustomColors, True
332
302
);
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 );
334
307
end ;
335
308
336
309
function TDisplayPrefsFrame.DisplayName : string;
@@ -344,6 +317,47 @@ function TDisplayPrefsFrame.DisplayName: string;
344
317
Result := sDisplayName;
345
318
end ;
346
319
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
+
347
361
class function TDisplayPrefsFrame.Index : Byte;
348
362
{ Index number that determines the location of the tab containing this frame
349
363
when displayed in the preferences dialog box.
@@ -372,9 +386,12 @@ function TDisplayPrefsFrame.OverviewTreeStateDesc(
372
386
Result := cOTSStartStates[State];
373
387
end ;
374
388
375
- procedure TDisplayPrefsFrame.PopulateFontSizeCombo ;
389
+ procedure TDisplayPrefsFrame.PopulateFontSizeCombos ;
376
390
begin
391
+ cbOverviewFontSize.Clear;
377
392
TFontHelper.ListCommonFontSizes(cbOverviewFontSize.Items);
393
+ cbDetailFontSize.Clear;
394
+ TFontHelper.ListCommonFontSizes(cbDetailFontSize.Items);
378
395
end ;
379
396
380
397
procedure TDisplayPrefsFrame.SelectOverviewTreeState (
0 commit comments