1 | Unit OptionsForm;
|
---|
2 |
|
---|
3 | // NewView - a new OS/2 Help Viewer
|
---|
4 | // Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
|
---|
5 | // This software is released under the Gnu Public License - see readme.txt
|
---|
6 |
|
---|
7 | Interface
|
---|
8 |
|
---|
9 | Uses
|
---|
10 | Classes, Forms, Graphics, Buttons, ExtCtrls, StdCtrls, Dialogs,
|
---|
11 | TabCtrls, ComCtrls, Spin,
|
---|
12 | ColorWheel, CustomFontDialog, ACLLanguageUnit,
|
---|
13 | SettingsUnit;
|
---|
14 |
|
---|
15 | // The correct sizes are:
|
---|
16 | // Form: 479x378
|
---|
17 | // Notebook: 471x306
|
---|
18 |
|
---|
19 | Type
|
---|
20 | TOptionsForm = Class (TForm)
|
---|
21 | TabbedNotebook: TTabbedNotebook;
|
---|
22 | SmoothScrollingCheckBox: TCheckBox;
|
---|
23 | UseOriginalDialogsCheckBox: TCheckBox;
|
---|
24 | Label1: TLabel;
|
---|
25 | NormalFontPanel: TPanel;
|
---|
26 | Label2: TLabel;
|
---|
27 | FixedFontPanel: TPanel;
|
---|
28 | Label5: TLabel;
|
---|
29 | ColorItemsListBox: TListBox;
|
---|
30 | GroupBox1: TGroupBox;
|
---|
31 | FontDialog: TCustomFontDialog;
|
---|
32 | NormalFontButton: TButton;
|
---|
33 | FixedFontButton: TButton;
|
---|
34 | DefaultFontsButton: TButton;
|
---|
35 | OpenBackgroundImageButton: TButton;
|
---|
36 | ClearBackgroundBitmapButton: TButton;
|
---|
37 | CancelButton: TButton;
|
---|
38 | OKButton: TButton;
|
---|
39 | FixedFontSubstitutionCheckBox: TCheckBox;
|
---|
40 | FixedFontSubstitutesEdit: TEdit;
|
---|
41 | CheckBox1: TCheckBox;
|
---|
42 | CheckBox2: TCheckBox;
|
---|
43 | ConfirmWinHelpCheckBox: TCheckBox;
|
---|
44 | CheckBox3: TCheckBox;
|
---|
45 | GroupBox2: TGroupBox;
|
---|
46 | ShowLeftPanel_HelpCheckBox: TCheckBox;
|
---|
47 | ShowLeftPanel_StandaloneCheckBox: TCheckBox;
|
---|
48 | DefaultColorsButton: TButton;
|
---|
49 | ToolbarStyleRadioGroup: TRadioGroup;
|
---|
50 | ApplicationFontPanel: TPanel;
|
---|
51 | ApplicationFontButton: TButton;
|
---|
52 | ApplicationFontLabel: TLabel;
|
---|
53 | IndexStyleRadioGroup: TRadioGroup;
|
---|
54 | StartupHelpCheckBox: TCheckBox;
|
---|
55 | RedTrackBar: TTrackBar;
|
---|
56 | RedEdit: TEdit;
|
---|
57 | GreenTrackBar: TTrackBar;
|
---|
58 | GreenEdit: TEdit;
|
---|
59 | BlueTrackBar: TTrackBar;
|
---|
60 | BlueEdit: TEdit;
|
---|
61 | RedLabel: TLabel;
|
---|
62 | Label8: TLabel;
|
---|
63 | Label9: TLabel;
|
---|
64 | RedUpDown: TUpDown;
|
---|
65 | GreenUpDown: TUpDown;
|
---|
66 | BlueUpDown: TUpDown;
|
---|
67 | OpenWithExpandedContentsCheckBox: TCheckBox;
|
---|
68 | ColorWheel: TColorWheel;
|
---|
69 | ValueBar: TValueBar;
|
---|
70 | BackgroundImageFilenameEdit: TEdit;
|
---|
71 | Label6: TLabel;
|
---|
72 | Procedure OptionsFormOnSetupShow (Sender: TObject);
|
---|
73 | Procedure ApplicationFontButtonOnClick (Sender: TObject);
|
---|
74 | Procedure ColorItemsListBoxOnClick (Sender: TObject);
|
---|
75 | Procedure DefaultFontsButtonOnClick (Sender: TObject);
|
---|
76 | Procedure DefaultColorsButtonOnClick (Sender: TObject);
|
---|
77 | Procedure BlueUpDownOnChanging (Sender: TComponent;
|
---|
78 | Var AllowChange: Boolean);
|
---|
79 | Procedure GreenUpDownOnChanging (Sender: TComponent;
|
---|
80 | Var AllowChange: Boolean);
|
---|
81 | Procedure RedUpDownOnChanging (Sender: TComponent;
|
---|
82 | Var AllowChange: Boolean);
|
---|
83 | Procedure RedTrackBarOnChange (Sender: TObject);
|
---|
84 | Procedure GreenTrackBarOnChange (Sender: TObject);
|
---|
85 | Procedure BlueTrackBarOnChange (Sender: TObject);
|
---|
86 | Procedure BlueEditOnChange (Sender: TObject);
|
---|
87 | Procedure GreenEditOnChange (Sender: TObject);
|
---|
88 | Procedure RedEditOnChange (Sender: TObject);
|
---|
89 | Procedure ClearBackgroundBitmapButtonOnClick (Sender: TObject);
|
---|
90 | Procedure OpenBackgroundImageButtonOnClick (Sender: TObject);
|
---|
91 | Procedure OptionsFormOnCreate (Sender: TObject);
|
---|
92 | Procedure ValueBarOnChange (Sender: TObject);
|
---|
93 | Procedure ColorItemsListBoxOnItemFocus (Sender: TObject; Index: LongInt);
|
---|
94 | Procedure OKButtonOnClick (Sender: TObject);
|
---|
95 | Procedure FixedFontButtonOnClick (Sender: TObject);
|
---|
96 | Procedure NormalFontButtonOnClick (Sender: TObject);
|
---|
97 | Procedure OptionsFormOnShow (Sender: TObject);
|
---|
98 | Protected
|
---|
99 | Colors: Array[ 0..NumColorSettings - 1 ] of TColor;
|
---|
100 | UpdatingColor: boolean;
|
---|
101 | ImageDirectory: string;
|
---|
102 | ApplicationFontCustomised: boolean;
|
---|
103 | Procedure SetSelectedColor( bit: longword;
|
---|
104 | value: longint;
|
---|
105 | ExcludeControl: TComponent );
|
---|
106 | Procedure SetFontCaptions;
|
---|
107 | Procedure DisplayColorItem( ExcludeControl: TComponent );
|
---|
108 |
|
---|
109 | function GetFontString( Font: TFont ): string;
|
---|
110 |
|
---|
111 | Protected
|
---|
112 | Procedure OnLanguageEvent( Language: TLanguageFile;
|
---|
113 | const Apply: boolean );
|
---|
114 |
|
---|
115 | SelectBitmapTitle: string;
|
---|
116 | BitmapFilesDesc: string;
|
---|
117 | BoldFontSuffix: string;
|
---|
118 | ItalicFontSuffix: string;
|
---|
119 |
|
---|
120 | Public
|
---|
121 | MyParent: TForm;
|
---|
122 | End;
|
---|
123 |
|
---|
124 | Var
|
---|
125 | OptionsForm: TOptionsForm;
|
---|
126 |
|
---|
127 | procedure EnsureOptionsFormLoaded;
|
---|
128 |
|
---|
129 | Implementation
|
---|
130 |
|
---|
131 | uses
|
---|
132 | PmWin,
|
---|
133 | SysUtils,
|
---|
134 | ACLUtility, ControlsUtility,
|
---|
135 | FileDialogForm;
|
---|
136 |
|
---|
137 | Procedure TOptionsForm.OptionsFormOnSetupShow (Sender: TObject);
|
---|
138 | Begin
|
---|
139 | ScaleForm( self, 11, 16 );
|
---|
140 | End;
|
---|
141 |
|
---|
142 | Procedure TOptionsForm.ApplicationFontButtonOnClick (Sender: TObject);
|
---|
143 | Begin
|
---|
144 | FontDialog.EditFont := ApplicationFontPanel.Font;
|
---|
145 | if FontDialog.Execute then
|
---|
146 | begin
|
---|
147 | ApplicationFontPanel.Font := Screen.CreateCompatibleFont( FontDialog.EditFont );
|
---|
148 | ApplicationFontCustomised := true;
|
---|
149 | SetFontCaptions;
|
---|
150 | end;
|
---|
151 | End;
|
---|
152 |
|
---|
153 | function TOptionsForm.GetFontString( Font: TFont ): string;
|
---|
154 | begin
|
---|
155 | Result := Font.FaceName
|
---|
156 | + ' '
|
---|
157 | + IntToStr( Font.PointSize );
|
---|
158 | if faBold in Font.Attributes then
|
---|
159 | Result := Result + BoldFontSuffix;
|
---|
160 | if faItalic in Font.Attributes then
|
---|
161 | Result := Result + ItalicFontSuffix;
|
---|
162 | end;
|
---|
163 |
|
---|
164 | Procedure TOptionsForm.ColorItemsListBoxOnClick (Sender: TObject);
|
---|
165 | Begin
|
---|
166 |
|
---|
167 | End;
|
---|
168 |
|
---|
169 | const
|
---|
170 | DefaultColorItemNames: array[ 0 .. NumColorSettings - 1 ] of string =
|
---|
171 | (
|
---|
172 | 'Contents Background',
|
---|
173 | ' Text',
|
---|
174 | ' Lines',
|
---|
175 | 'Index Background',
|
---|
176 | ' Text',
|
---|
177 | 'Search Background',
|
---|
178 | ' Text',
|
---|
179 | 'Notes Background',
|
---|
180 | ' Text',
|
---|
181 | 'Topic Background',
|
---|
182 | ' Notes Text',
|
---|
183 | 'Search Highlight'
|
---|
184 | );
|
---|
185 |
|
---|
186 | Procedure TOptionsForm.OnLanguageEvent( Language: TLanguageFile;
|
---|
187 | const Apply: boolean );
|
---|
188 | var
|
---|
189 | i: longint;
|
---|
190 | ColorItemName: string;
|
---|
191 | begin
|
---|
192 | Language.LoadComponentLanguage( self, Apply );
|
---|
193 |
|
---|
194 | if Apply then
|
---|
195 | begin
|
---|
196 | ColorItemsListBox.Items.BeginUpdate;
|
---|
197 | ColorItemsListBox.Items.Clear;
|
---|
198 | end;
|
---|
199 |
|
---|
200 | for i := 0 to NumColorSettings - 1 do
|
---|
201 | begin
|
---|
202 | Language.LL( Apply,
|
---|
203 | ColorItemName,
|
---|
204 | 'ColorItemName' + IntToStr( i ),
|
---|
205 | DefaultColorItemNames[ i ] );
|
---|
206 | if Apply then
|
---|
207 | ColorItemsListBox.Items.Add( ColorItemName );
|
---|
208 | end;
|
---|
209 |
|
---|
210 | if Apply then
|
---|
211 | ColorItemsListBox.EndUpdate;
|
---|
212 |
|
---|
213 | Language.LL( Apply, SelectBitmapTitle, 'SelectBitmapTitle', 'Select Bitmap File' );
|
---|
214 | Language.LL( Apply, BitmapFilesDesc, 'BitmapFilesDesc', 'Bitmaps (*.bmp)' );
|
---|
215 | Language.LL( Apply, BoldFontSuffix, 'BoldFontSuffix', ' Bold' );
|
---|
216 | Language.LL( Apply, ItalicFontSuffix, 'ItalicFontSuffix', ' Italic' );
|
---|
217 | end;
|
---|
218 |
|
---|
219 | Procedure TOptionsForm.DefaultFontsButtonOnClick (Sender: TObject);
|
---|
220 | Begin
|
---|
221 | NormalFontPanel.Font := Screen.GetFontFromPointSize( DefaultTopicFontName,
|
---|
222 | DefaultTopicFontSize );
|
---|
223 | FixedFontPanel.Font := Screen.GetFontFromPointSize( DefaultTopicFixedFontName,
|
---|
224 | DefaultTopicFixedFontSize );
|
---|
225 | ApplicationFontCustomised := false;
|
---|
226 | ApplicationFontPanel.Font := GetNiceDefaultFont;
|
---|
227 |
|
---|
228 | SetFontCaptions;
|
---|
229 | End;
|
---|
230 |
|
---|
231 | Procedure TOptionsForm.DefaultColorsButtonOnClick (Sender: TObject);
|
---|
232 | var
|
---|
233 | i: longint;
|
---|
234 | Begin
|
---|
235 | // restore default colors
|
---|
236 | for i := 0 to NumColorSettings - 1 do
|
---|
237 | begin
|
---|
238 | Colors[ i ] := DefaultColors[ i ];
|
---|
239 | end;
|
---|
240 | DisplayColorItem( nil );
|
---|
241 | End;
|
---|
242 |
|
---|
243 | Procedure TOptionsForm.SetSelectedColor( bit: longword;
|
---|
244 | value: longint;
|
---|
245 | ExcludeControl: TComponent );
|
---|
246 | var
|
---|
247 | mask: longword;
|
---|
248 | begin
|
---|
249 | if UpdatingColor then
|
---|
250 | exit;
|
---|
251 |
|
---|
252 | if value < 0 then
|
---|
253 | value := 0;
|
---|
254 | if value > 255 then
|
---|
255 | value := 255;
|
---|
256 |
|
---|
257 | UpdatingColor := true;
|
---|
258 |
|
---|
259 | Mask := $ffffff and not ( $ff shl bit );
|
---|
260 |
|
---|
261 | Colors[ ColorItemsListBox.ItemIndex ] :=
|
---|
262 | Colors[ ColorItemsListBox.ItemIndex ]
|
---|
263 | and Mask
|
---|
264 | or ( Value shl bit );
|
---|
265 |
|
---|
266 | DisplayColorItem( ExcludeControl );
|
---|
267 |
|
---|
268 | UpdatingColor := false;
|
---|
269 |
|
---|
270 | end;
|
---|
271 |
|
---|
272 | Procedure TOptionsForm.RedUpDownOnChanging (Sender: TComponent;
|
---|
273 | Var AllowChange: Boolean);
|
---|
274 | Begin
|
---|
275 | SetSelectedColor( 16, RedUpDown.Position, RedUpDown );
|
---|
276 | End;
|
---|
277 |
|
---|
278 | Procedure TOptionsForm.GreenUpDownOnChanging (Sender: TComponent;
|
---|
279 | Var AllowChange: Boolean);
|
---|
280 | Begin
|
---|
281 | SetSelectedColor( 8, GreenUpDown.Position, GreenUpDown );
|
---|
282 | End;
|
---|
283 |
|
---|
284 | Procedure TOptionsForm.BlueUpDownOnChanging (Sender: TComponent;
|
---|
285 | Var AllowChange: Boolean);
|
---|
286 | Begin
|
---|
287 | SetSelectedColor( 0, BlueUpDown.Position, BlueUpDown );
|
---|
288 | End;
|
---|
289 |
|
---|
290 | Procedure TOptionsForm.RedTrackBarOnChange (Sender: TObject);
|
---|
291 | Begin
|
---|
292 | SetSelectedColor( 16, RedTrackBar.Position, RedTrackBar );
|
---|
293 | End;
|
---|
294 |
|
---|
295 | Procedure TOptionsForm.GreenTrackBarOnChange (Sender: TObject);
|
---|
296 | Begin
|
---|
297 | SetSelectedColor( 8, GreenTrackBar.Position, GreenTrackBar );
|
---|
298 | End;
|
---|
299 |
|
---|
300 | Procedure TOptionsForm.BlueTrackBarOnChange (Sender: TObject);
|
---|
301 | Begin
|
---|
302 | SetSelectedColor( 0, BlueTrackBar.Position, BlueTrackBar );
|
---|
303 | End;
|
---|
304 |
|
---|
305 | Procedure TOptionsForm.RedEditOnChange (Sender: TObject);
|
---|
306 | Begin
|
---|
307 | try
|
---|
308 | SetSelectedColor( 16, StrToInt( RedEdit.Text ), RedEdit );
|
---|
309 | except
|
---|
310 | end;
|
---|
311 | End;
|
---|
312 |
|
---|
313 | Procedure TOptionsForm.GreenEditOnChange (Sender: TObject);
|
---|
314 | Begin
|
---|
315 | try
|
---|
316 | SetSelectedColor( 8, StrToInt( GreenEdit.Text ), GreenEdit );
|
---|
317 | except
|
---|
318 | end;
|
---|
319 | End;
|
---|
320 |
|
---|
321 | Procedure TOptionsForm.BlueEditOnChange (Sender: TObject);
|
---|
322 | Begin
|
---|
323 | try
|
---|
324 | SetSelectedColor( 0, StrToInt( BlueEdit.Text ), BlueEdit );
|
---|
325 | except
|
---|
326 | end;
|
---|
327 | End;
|
---|
328 |
|
---|
329 | Procedure TOptionsForm.ClearBackgroundBitmapButtonOnClick (Sender: TObject);
|
---|
330 | Begin
|
---|
331 | BackgroundImageFilenameEdit.Text := '';
|
---|
332 | End;
|
---|
333 |
|
---|
334 | Procedure TOptionsForm.OpenBackgroundImageButtonOnClick (Sender: TObject);
|
---|
335 | var
|
---|
336 | Filename: string;
|
---|
337 | Begin
|
---|
338 | if DoOpenFileDialog( SelectBitmapTitle,
|
---|
339 | BitmapFilesDesc + '|*.bmp',
|
---|
340 | '*.bmp',
|
---|
341 | ImageDirectory,
|
---|
342 | Filename ) then
|
---|
343 | begin
|
---|
344 | BackgroundImageFilenameEdit.Text := Filename;
|
---|
345 | end;
|
---|
346 | End;
|
---|
347 |
|
---|
348 | Procedure TOptionsForm.OptionsFormOnCreate (Sender: TObject);
|
---|
349 | Begin
|
---|
350 | RegisterForLanguages( OnLanguageEvent );
|
---|
351 |
|
---|
352 | TabbedNoteBook.ShowPageHint := false;
|
---|
353 | TabbedNoteBook.NotebookMargin := 2;
|
---|
354 | TabbedNoteBook.PageIndex := 0;
|
---|
355 |
|
---|
356 | // Select the first colour item
|
---|
357 | ColorItemsListBox.ItemIndex := 0;
|
---|
358 | RedTrackBar.Frequency := 32;
|
---|
359 | GreenTrackBar.Frequency := 32;
|
---|
360 | BlueTrackBar.Frequency := 32;
|
---|
361 |
|
---|
362 | ImageDirectory := GetApplicationDir;
|
---|
363 | End;
|
---|
364 |
|
---|
365 | Procedure TOptionsForm.ValueBarOnChange (Sender: TObject);
|
---|
366 | Begin
|
---|
367 | if UpdatingColor then
|
---|
368 | exit;
|
---|
369 |
|
---|
370 | UpdatingColor := true;
|
---|
371 |
|
---|
372 | Colors[ ColorItemsListBox.ItemIndex ] := ValueBar.SelectedColor;
|
---|
373 |
|
---|
374 | DisplayColorItem( ColorWheel );
|
---|
375 |
|
---|
376 | UpdatingColor := false;
|
---|
377 | End;
|
---|
378 |
|
---|
379 | Procedure TOptionsForm.ColorItemsListBoxOnItemFocus (Sender: TObject;
|
---|
380 | Index: LongInt);
|
---|
381 | begin
|
---|
382 | DisplayColorItem( nil );
|
---|
383 | end;
|
---|
384 |
|
---|
385 | Procedure TOptionsForm.DisplayColorItem( ExcludeControl: TComponent );
|
---|
386 | Var
|
---|
387 | c: longint;
|
---|
388 | r: longint;
|
---|
389 | g: longint;
|
---|
390 | b: longint;
|
---|
391 | Begin
|
---|
392 | c := Colors[ ColorItemsListBox.ItemIndex ];
|
---|
393 | c := SysColorToRGB( c );
|
---|
394 | r := ( c shr 16 ) and 255;
|
---|
395 | g := ( c shr 8 ) and 255;
|
---|
396 | b := ( c ) and 255;
|
---|
397 |
|
---|
398 | if ExcludeControl <> ColorWheel then
|
---|
399 | ColorWheel.SetSelectedColor( c );
|
---|
400 |
|
---|
401 | if ExcludeControl <> RedEdit then
|
---|
402 | RedEdit.Text := IntToStr( r );
|
---|
403 | if ExcludeControl <> GreenEdit then
|
---|
404 | GreenEdit.Text := IntToStr( g );
|
---|
405 | if ExcludeControl <> BlueEdit then
|
---|
406 | BlueEdit.Text := IntToStr( b );
|
---|
407 |
|
---|
408 | if ExcludeControl <> RedTrackBar then
|
---|
409 | RedTrackBar.Position := r;
|
---|
410 | if ExcludeControl <> GreenTrackBar then
|
---|
411 | GreenTrackBar.Position := g;
|
---|
412 | if ExcludeControl <> BlueTrackBar then
|
---|
413 | BlueTrackBar.Position := b;
|
---|
414 |
|
---|
415 | if ExcludeControl <> RedUpDown then
|
---|
416 | RedUpDown.Position := r;
|
---|
417 | if ExcludeControl <> GreenUpDown then
|
---|
418 | GreenUpDown.Position := g;
|
---|
419 | if ExcludeControl <> BlueUpDown then
|
---|
420 | BlueUpDown.Position := b;
|
---|
421 | End;
|
---|
422 |
|
---|
423 | Procedure TOptionsForm.OKButtonOnClick (Sender: TObject);
|
---|
424 | var
|
---|
425 | ColorIndex: integer;
|
---|
426 | Begin
|
---|
427 | // Save settings from controls
|
---|
428 | Settings.ShowLeftPanel_Help := ShowLeftPanel_HelpCheckBox.Checked;
|
---|
429 | Settings.ShowLeftPanel_StandAlone := ShowLeftPanel_StandaloneCheckBox.Checked;
|
---|
430 |
|
---|
431 | Settings.NormalFont := NormalFontPanel.Font;
|
---|
432 | Settings.FixedFont := FixedFontPanel.Font;
|
---|
433 |
|
---|
434 | Settings.FixedFontSubstitution := FixedFontSubstitutionCheckBox.Checked;
|
---|
435 | Settings.FixedFontSubstitutes := FixedFontSubstitutesEdit.Text;
|
---|
436 |
|
---|
437 | Settings.StartupHelp := StartupHelpCheckBox.Checked;
|
---|
438 |
|
---|
439 | Settings.IndexStyle := TIndexStyle( IndexStyleRadioGroup.ItemIndex );
|
---|
440 | Settings.SmoothScrolling := SmoothScrollingCheckbox.Checked;
|
---|
441 | Settings.UseOriginalDialogs := UseOriginalDialogsCheckBox.Checked;
|
---|
442 | Settings.OpenWithExpandedContents := OpenWithExpandedContentsCheckBox.Checked;
|
---|
443 |
|
---|
444 | for ColorIndex := 0 to High( Settings.Colors ) do
|
---|
445 | Settings.Colors[ ColorIndex ] := Colors[ ColorIndex ];
|
---|
446 |
|
---|
447 | Settings.ToolbarBackgroundImageFilename := BackgroundImageFilenameEdit.Text;
|
---|
448 |
|
---|
449 | Settings.ToolbarStyle := TToolbarStyle( ToolbarStyleRadioGroup.ItemIndex );
|
---|
450 |
|
---|
451 | if ApplicationFontCustomised then
|
---|
452 | Settings.Fonts[ ApplicationFontIndex ] := ApplicationFontPanel.Font
|
---|
453 | else
|
---|
454 | Settings.Fonts[ ApplicationFontIndex ] := nil;
|
---|
455 |
|
---|
456 | Settings.ConfirmWinHelp := ConfirmWinHelpCheckBox.Checked;
|
---|
457 | End;
|
---|
458 |
|
---|
459 | Procedure TOptionsForm.FixedFontButtonOnClick (Sender: TObject);
|
---|
460 | Begin
|
---|
461 | FontDialog.EditFont := FixedFontPanel.Font;
|
---|
462 | if FontDialog.Execute then
|
---|
463 | begin
|
---|
464 | FixedFontPanel.Font := Screen.CreateCompatibleFont( FontDialog.EditFont );
|
---|
465 | SetFontCaptions;
|
---|
466 | end;
|
---|
467 |
|
---|
468 | End;
|
---|
469 |
|
---|
470 | Procedure TOptionsForm.NormalFontButtonOnClick (Sender: TObject);
|
---|
471 | Begin
|
---|
472 | FontDialog.EditFont := NormalFontPanel.Font;
|
---|
473 | if FontDialog.Execute then
|
---|
474 | begin
|
---|
475 | NormalFontPanel.Font := FontDialog.EditFont;
|
---|
476 | SetFontCaptions;
|
---|
477 | end;
|
---|
478 | End;
|
---|
479 |
|
---|
480 | Procedure TOptionsForm.OptionsFormOnShow (Sender: TObject);
|
---|
481 | var
|
---|
482 | ColorIndex: integer;
|
---|
483 | Begin
|
---|
484 |
|
---|
485 | // Load settings into controls.
|
---|
486 | ShowLeftPanel_HelpCheckBox.Checked := Settings.ShowLeftPanel_Help;
|
---|
487 | ShowLeftPanel_StandaloneCheckBox.Checked := Settings.ShowLeftPanel_StandAlone;
|
---|
488 |
|
---|
489 | NormalFontPanel.Font := Settings.NormalFont;
|
---|
490 | FixedFontPanel.Font := Settings.FixedFont;
|
---|
491 |
|
---|
492 | ApplicationFontCustomised := Settings.Fonts[ ApplicationFontIndex ] <> nil;
|
---|
493 | if ApplicationFontCustomised then
|
---|
494 | ApplicationFontPanel.Font := Settings.Fonts[ ApplicationFontIndex ]
|
---|
495 | else
|
---|
496 | ApplicationFontPanel.Font := GetNiceDefaultFont;
|
---|
497 |
|
---|
498 | SetFontCaptions;
|
---|
499 |
|
---|
500 | FixedFontSubstitutionCheckBox.Checked := Settings.FixedFontSubstitution;
|
---|
501 | FixedFontSubstitutesEdit.Text := Settings.FixedFontSubstitutes;
|
---|
502 |
|
---|
503 | StartupHelpCheckBox.Checked := Settings.StartupHelp;
|
---|
504 |
|
---|
505 | SmoothScrollingCheckbox.Checked := Settings.SmoothScrolling;
|
---|
506 | IndexStyleRadioGroup.ItemIndex := integer( Settings.IndexStyle );
|
---|
507 | UseOriginalDialogsCheckBox.Checked := Settings.UseOriginalDialogs;
|
---|
508 | OpenWithExpandedContentsCheckBox.Checked := Settings.OpenWithExpandedContents;
|
---|
509 |
|
---|
510 | for ColorIndex := 0 to High( Settings.Colors ) do
|
---|
511 | Colors[ ColorIndex ] := Settings.Colors[ ColorIndex ];
|
---|
512 |
|
---|
513 | DisplayColorItem( nil );
|
---|
514 |
|
---|
515 | FontDialog.Font := Font;
|
---|
516 |
|
---|
517 | BackgroundImageFilenameEdit.Text := Settings.ToolbarBackgroundImageFilename;
|
---|
518 |
|
---|
519 | ToolbarStyleRadioGroup.ItemIndex := Ord( Settings.ToolbarStyle );
|
---|
520 |
|
---|
521 | ConfirmWinHelpCheckBox.Checked := Settings.ConfirmWinHelp;
|
---|
522 |
|
---|
523 | UpdatingColor := false;
|
---|
524 |
|
---|
525 | SmoothScrollingCheckBox.Focus; // TNotebook should do this for us, but doesn't (a bug)
|
---|
526 |
|
---|
527 | OKButton.Default := true;
|
---|
528 | End;
|
---|
529 |
|
---|
530 | Procedure TOptionsForm.SetFontCaptions;
|
---|
531 | begin
|
---|
532 | NormalFontPanel.Caption := GetFontString( NormalFontPanel.Font );
|
---|
533 | FixedFontPanel.Caption := GetFontString( FixedFontPanel.Font );
|
---|
534 | if ApplicationFontCustomised then
|
---|
535 | ApplicationFontPanel.Caption := GetFontString( ApplicationFontPanel.Font )
|
---|
536 | else
|
---|
537 | ApplicationFontPanel.Caption := '(Default)';
|
---|
538 | end;
|
---|
539 |
|
---|
540 | procedure EnsureOptionsFormLoaded;
|
---|
541 | begin
|
---|
542 | if OptionsForm = nil then
|
---|
543 | OptionsForm := TOptionsForm.Create( nil );
|
---|
544 | end;
|
---|
545 |
|
---|
546 | Initialization
|
---|
547 | RegisterClasses ([TOptionsForm,
|
---|
548 | TLabel, TTabbedNotebook
|
---|
549 | , TCheckBox, TPanel, TListBox, TGroupBox,
|
---|
550 | TCustomFontDialog, TEdit, TColorWheel, TValueBar, TTrackBar, TUpDown
|
---|
551 | , TRadioGroup, TButton]);
|
---|
552 |
|
---|
553 | RegisterUpdateProcForLanguages( EnsureOptionsFormLoaded );
|
---|
554 | End.
|
---|