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