| 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 | tmpPrefix : String;
|
|---|
| 201 | begin
|
|---|
| 202 | // LogEvent(LogI18n, 'TOptionsForm.OnLanguageEvent apply: "' + BoolToStr(Apply) + '"');
|
|---|
| 203 | Language.LoadComponentLanguage( self, Apply );
|
|---|
| 204 |
|
|---|
| 205 | if Apply then
|
|---|
| 206 | begin
|
|---|
| 207 | ColorItemsListBox.Items.BeginUpdate;
|
|---|
| 208 | ColorItemsListBox.Items.Clear;
|
|---|
| 209 | end;
|
|---|
| 210 |
|
|---|
| 211 | tmpPrefix := 'OptionsForm' + LANGUAGE_LABEL_DELIMITER;
|
|---|
| 212 |
|
|---|
| 213 | for i := 0 to NumColorSettings - 1 do
|
|---|
| 214 | begin
|
|---|
| 215 | Language.LL( Apply,
|
|---|
| 216 | ColorItemName,
|
|---|
| 217 | tmpPrefix + 'ColorItemName' + IntToStr( i ),
|
|---|
| 218 | DefaultColorItemNames[ i ] );
|
|---|
| 219 | if Apply then
|
|---|
| 220 | ColorItemsListBox.Items.Add( ColorItemName );
|
|---|
| 221 | end;
|
|---|
| 222 |
|
|---|
| 223 | if Apply then
|
|---|
| 224 | ColorItemsListBox.EndUpdate;
|
|---|
| 225 |
|
|---|
| 226 | Language.LL( Apply, SelectBitmapTitle, tmpPrefix + 'SelectBitmapTitle', 'Select Bitmap File' );
|
|---|
| 227 | Language.LL( Apply, BitmapFilesDesc, tmpPrefix + 'BitmapFilesDesc', 'Bitmaps (*.bmp)' );
|
|---|
| 228 | Language.LL( Apply, BoldFontSuffix, tmpPrefix + 'BoldFontSuffix', ' Bold' );
|
|---|
| 229 | Language.LL( Apply, ItalicFontSuffix, tmpPrefix + 'ItalicFontSuffix', ' Italic' );
|
|---|
| 230 | end;
|
|---|
| 231 |
|
|---|
| 232 | Procedure TOptionsForm.DefaultFontsButtonOnClick (Sender: TObject);
|
|---|
| 233 | Begin
|
|---|
| 234 | NormalFontPanel.Font := Screen.GetFontFromPointSize( DefaultTopicFontName,
|
|---|
| 235 | DefaultTopicFontSize );
|
|---|
| 236 | FixedFontPanel.Font := Screen.GetFontFromPointSize( DefaultTopicFixedFontName,
|
|---|
| 237 | DefaultTopicFixedFontSize );
|
|---|
| 238 | ApplicationFontCustomised := false;
|
|---|
| 239 | ApplicationFontPanel.Font := GetNiceDefaultFont;
|
|---|
| 240 |
|
|---|
| 241 | SetFontCaptions;
|
|---|
| 242 | End;
|
|---|
| 243 |
|
|---|
| 244 | Procedure TOptionsForm.DefaultColorsButtonOnClick (Sender: TObject);
|
|---|
| 245 | var
|
|---|
| 246 | i: longint;
|
|---|
| 247 | Begin
|
|---|
| 248 | // restore default colors
|
|---|
| 249 | for i := 0 to NumColorSettings - 1 do
|
|---|
| 250 | begin
|
|---|
| 251 | Colors[ i ] := DefaultColors[ i ];
|
|---|
| 252 | end;
|
|---|
| 253 | DisplayColorItem( nil );
|
|---|
| 254 | End;
|
|---|
| 255 |
|
|---|
| 256 | Procedure TOptionsForm.SetSelectedColor( bit: longword;
|
|---|
| 257 | value: longint;
|
|---|
| 258 | ExcludeControl: TComponent );
|
|---|
| 259 | var
|
|---|
| 260 | mask: longword;
|
|---|
| 261 | begin
|
|---|
| 262 | if UpdatingColor then
|
|---|
| 263 | exit;
|
|---|
| 264 |
|
|---|
| 265 | if value < 0 then
|
|---|
| 266 | value := 0;
|
|---|
| 267 | if value > 255 then
|
|---|
| 268 | value := 255;
|
|---|
| 269 |
|
|---|
| 270 | UpdatingColor := true;
|
|---|
| 271 |
|
|---|
| 272 | Mask := $ffffff and not ( $ff shl bit );
|
|---|
| 273 |
|
|---|
| 274 | Colors[ ColorItemsListBox.ItemIndex ] :=
|
|---|
| 275 | Colors[ ColorItemsListBox.ItemIndex ]
|
|---|
| 276 | and Mask
|
|---|
| 277 | or ( Value shl bit );
|
|---|
| 278 |
|
|---|
| 279 | DisplayColorItem( ExcludeControl );
|
|---|
| 280 |
|
|---|
| 281 | UpdatingColor := false;
|
|---|
| 282 |
|
|---|
| 283 | end;
|
|---|
| 284 |
|
|---|
| 285 | Procedure TOptionsForm.RedUpDownOnChanging (Sender: TComponent;
|
|---|
| 286 | Var AllowChange: Boolean);
|
|---|
| 287 | Begin
|
|---|
| 288 | SetSelectedColor( 16, RedUpDown.Position, RedUpDown );
|
|---|
| 289 | End;
|
|---|
| 290 |
|
|---|
| 291 | Procedure TOptionsForm.GreenUpDownOnChanging (Sender: TComponent;
|
|---|
| 292 | Var AllowChange: Boolean);
|
|---|
| 293 | Begin
|
|---|
| 294 | SetSelectedColor( 8, GreenUpDown.Position, GreenUpDown );
|
|---|
| 295 | End;
|
|---|
| 296 |
|
|---|
| 297 | Procedure TOptionsForm.BlueUpDownOnChanging (Sender: TComponent;
|
|---|
| 298 | Var AllowChange: Boolean);
|
|---|
| 299 | Begin
|
|---|
| 300 | SetSelectedColor( 0, BlueUpDown.Position, BlueUpDown );
|
|---|
| 301 | End;
|
|---|
| 302 |
|
|---|
| 303 | Procedure TOptionsForm.RedTrackBarOnChange (Sender: TObject);
|
|---|
| 304 | Begin
|
|---|
| 305 | SetSelectedColor( 16, RedTrackBar.Position, RedTrackBar );
|
|---|
| 306 | End;
|
|---|
| 307 |
|
|---|
| 308 | Procedure TOptionsForm.GreenTrackBarOnChange (Sender: TObject);
|
|---|
| 309 | Begin
|
|---|
| 310 | SetSelectedColor( 8, GreenTrackBar.Position, GreenTrackBar );
|
|---|
| 311 | End;
|
|---|
| 312 |
|
|---|
| 313 | Procedure TOptionsForm.BlueTrackBarOnChange (Sender: TObject);
|
|---|
| 314 | Begin
|
|---|
| 315 | SetSelectedColor( 0, BlueTrackBar.Position, BlueTrackBar );
|
|---|
| 316 | End;
|
|---|
| 317 |
|
|---|
| 318 | Procedure TOptionsForm.RedEditOnChange (Sender: TObject);
|
|---|
| 319 | Begin
|
|---|
| 320 | try
|
|---|
| 321 | SetSelectedColor( 16, StrToInt( RedEdit.Text ), RedEdit );
|
|---|
| 322 | except
|
|---|
| 323 | end;
|
|---|
| 324 | End;
|
|---|
| 325 |
|
|---|
| 326 | Procedure TOptionsForm.GreenEditOnChange (Sender: TObject);
|
|---|
| 327 | Begin
|
|---|
| 328 | try
|
|---|
| 329 | SetSelectedColor( 8, StrToInt( GreenEdit.Text ), GreenEdit );
|
|---|
| 330 | except
|
|---|
| 331 | end;
|
|---|
| 332 | End;
|
|---|
| 333 |
|
|---|
| 334 | Procedure TOptionsForm.BlueEditOnChange (Sender: TObject);
|
|---|
| 335 | Begin
|
|---|
| 336 | try
|
|---|
| 337 | SetSelectedColor( 0, StrToInt( BlueEdit.Text ), BlueEdit );
|
|---|
| 338 | except
|
|---|
| 339 | end;
|
|---|
| 340 | End;
|
|---|
| 341 |
|
|---|
| 342 | Procedure TOptionsForm.ClearBackgroundBitmapButtonOnClick (Sender: TObject);
|
|---|
| 343 | Begin
|
|---|
| 344 | BackgroundImageFilenameEdit.Text := '';
|
|---|
| 345 | End;
|
|---|
| 346 |
|
|---|
| 347 | Procedure TOptionsForm.OpenBackgroundImageButtonOnClick (Sender: TObject);
|
|---|
| 348 | var
|
|---|
| 349 | Filename: string;
|
|---|
| 350 | Begin
|
|---|
| 351 | if DoOpenFileDialog( SelectBitmapTitle,
|
|---|
| 352 | BitmapFilesDesc + '|*.bmp',
|
|---|
| 353 | '*.bmp',
|
|---|
| 354 | ImageDirectory,
|
|---|
| 355 | Filename ) then
|
|---|
| 356 | begin
|
|---|
| 357 | BackgroundImageFilenameEdit.Text := Filename;
|
|---|
| 358 | end;
|
|---|
| 359 | End;
|
|---|
| 360 |
|
|---|
| 361 | Procedure TOptionsForm.OptionsFormOnCreate (Sender: TObject);
|
|---|
| 362 | Begin
|
|---|
| 363 | RegisterEventForLanguages( OnLanguageEvent );
|
|---|
| 364 |
|
|---|
| 365 | TabbedNoteBook.ShowPageHint := false;
|
|---|
| 366 | TabbedNoteBook.NotebookMargin := 2;
|
|---|
| 367 | TabbedNoteBook.PageIndex := 0;
|
|---|
| 368 |
|
|---|
| 369 | // Select the first colour item
|
|---|
| 370 | ColorItemsListBox.ItemIndex := 0;
|
|---|
| 371 | RedTrackBar.Frequency := 32;
|
|---|
| 372 | GreenTrackBar.Frequency := 32;
|
|---|
| 373 | BlueTrackBar.Frequency := 32;
|
|---|
| 374 |
|
|---|
| 375 | ImageDirectory := GetApplicationDir;
|
|---|
| 376 | End;
|
|---|
| 377 |
|
|---|
| 378 | Procedure TOptionsForm.ValueBarOnChange (Sender: TObject);
|
|---|
| 379 | Begin
|
|---|
| 380 | if UpdatingColor then
|
|---|
| 381 | exit;
|
|---|
| 382 |
|
|---|
| 383 | UpdatingColor := true;
|
|---|
| 384 |
|
|---|
| 385 | Colors[ ColorItemsListBox.ItemIndex ] := ValueBar.SelectedColor;
|
|---|
| 386 |
|
|---|
| 387 | DisplayColorItem( ColorWheel );
|
|---|
| 388 |
|
|---|
| 389 | UpdatingColor := false;
|
|---|
| 390 | End;
|
|---|
| 391 |
|
|---|
| 392 | Procedure TOptionsForm.ColorItemsListBoxOnItemFocus (Sender: TObject;
|
|---|
| 393 | Index: LongInt);
|
|---|
| 394 | begin
|
|---|
| 395 | DisplayColorItem( nil );
|
|---|
| 396 | end;
|
|---|
| 397 |
|
|---|
| 398 | Procedure TOptionsForm.DisplayColorItem( ExcludeControl: TComponent );
|
|---|
| 399 | Var
|
|---|
| 400 | c: longint;
|
|---|
| 401 | r: longint;
|
|---|
| 402 | g: longint;
|
|---|
| 403 | b: longint;
|
|---|
| 404 | Begin
|
|---|
| 405 | c := Colors[ ColorItemsListBox.ItemIndex ];
|
|---|
| 406 | c := SysColorToRGB( c );
|
|---|
| 407 | r := ( c shr 16 ) and 255;
|
|---|
| 408 | g := ( c shr 8 ) and 255;
|
|---|
| 409 | b := ( c ) and 255;
|
|---|
| 410 |
|
|---|
| 411 | if ExcludeControl <> ColorWheel then
|
|---|
| 412 | ColorWheel.SetSelectedColor( c );
|
|---|
| 413 |
|
|---|
| 414 | if ExcludeControl <> RedEdit then
|
|---|
| 415 | RedEdit.Text := IntToStr( r );
|
|---|
| 416 | if ExcludeControl <> GreenEdit then
|
|---|
| 417 | GreenEdit.Text := IntToStr( g );
|
|---|
| 418 | if ExcludeControl <> BlueEdit then
|
|---|
| 419 | BlueEdit.Text := IntToStr( b );
|
|---|
| 420 |
|
|---|
| 421 | if ExcludeControl <> RedTrackBar then
|
|---|
| 422 | RedTrackBar.Position := r;
|
|---|
| 423 | if ExcludeControl <> GreenTrackBar then
|
|---|
| 424 | GreenTrackBar.Position := g;
|
|---|
| 425 | if ExcludeControl <> BlueTrackBar then
|
|---|
| 426 | BlueTrackBar.Position := b;
|
|---|
| 427 |
|
|---|
| 428 | if ExcludeControl <> RedUpDown then
|
|---|
| 429 | RedUpDown.Position := r;
|
|---|
| 430 | if ExcludeControl <> GreenUpDown then
|
|---|
| 431 | GreenUpDown.Position := g;
|
|---|
| 432 | if ExcludeControl <> BlueUpDown then
|
|---|
| 433 | BlueUpDown.Position := b;
|
|---|
| 434 | End;
|
|---|
| 435 |
|
|---|
| 436 | Procedure TOptionsForm.OKButtonOnClick (Sender: TObject);
|
|---|
| 437 | var
|
|---|
| 438 | ColorIndex: integer;
|
|---|
| 439 | Begin
|
|---|
| 440 | // Save settings from controls
|
|---|
| 441 | Settings.ShowLeftPanel_Help := ShowLeftPanel_HelpCheckBox.Checked;
|
|---|
| 442 | Settings.ShowLeftPanel_StandAlone := ShowLeftPanel_StandaloneCheckBox.Checked;
|
|---|
| 443 |
|
|---|
| 444 | Settings.NormalFont := NormalFontPanel.Font;
|
|---|
| 445 | Settings.FixedFont := FixedFontPanel.Font;
|
|---|
| 446 |
|
|---|
| 447 | Settings.FixedFontSubstitution := FixedFontSubstitutionCheckBox.Checked;
|
|---|
| 448 | Settings.FixedFontSubstitutes := FixedFontSubstitutesEdit.Text;
|
|---|
| 449 |
|
|---|
| 450 | Settings.StartupHelp := StartupHelpCheckBox.Checked;
|
|---|
| 451 |
|
|---|
| 452 | Settings.IndexStyle := TIndexStyle( IndexStyleRadioGroup.ItemIndex );
|
|---|
| 453 | Settings.SmoothScrolling := SmoothScrollingCheckbox.Checked;
|
|---|
| 454 | Settings.UseOriginalDialogs := UseOriginalDialogsCheckBox.Checked;
|
|---|
| 455 | Settings.OpenWithExpandedContents := OpenWithExpandedContentsCheckBox.Checked;
|
|---|
| 456 |
|
|---|
| 457 | for ColorIndex := 0 to High( Settings.Colors ) do
|
|---|
| 458 | Settings.Colors[ ColorIndex ] := Colors[ ColorIndex ];
|
|---|
| 459 |
|
|---|
| 460 | Settings.ToolbarBackgroundImageFilename := BackgroundImageFilenameEdit.Text;
|
|---|
| 461 |
|
|---|
| 462 | Settings.ToolbarStyle := TToolbarStyle( ToolbarStyleRadioGroup.ItemIndex );
|
|---|
| 463 |
|
|---|
| 464 | if ApplicationFontCustomised then
|
|---|
| 465 | Settings.Fonts[ ApplicationFontIndex ] := ApplicationFontPanel.Font
|
|---|
| 466 | else
|
|---|
| 467 | Settings.Fonts[ ApplicationFontIndex ] := nil;
|
|---|
| 468 |
|
|---|
| 469 | Settings.ConfirmWinHelp := ConfirmWinHelpCheckBox.Checked;
|
|---|
| 470 | End;
|
|---|
| 471 |
|
|---|
| 472 | Procedure TOptionsForm.FixedFontButtonOnClick (Sender: TObject);
|
|---|
| 473 | Begin
|
|---|
| 474 | FontDialog.EditFont := FixedFontPanel.Font;
|
|---|
| 475 | if FontDialog.Execute then
|
|---|
| 476 | begin
|
|---|
| 477 | FixedFontPanel.Font := Screen.CreateCompatibleFont( FontDialog.EditFont );
|
|---|
| 478 | SetFontCaptions;
|
|---|
| 479 | end;
|
|---|
| 480 |
|
|---|
| 481 | End;
|
|---|
| 482 |
|
|---|
| 483 | Procedure TOptionsForm.NormalFontButtonOnClick (Sender: TObject);
|
|---|
| 484 | Begin
|
|---|
| 485 | FontDialog.EditFont := NormalFontPanel.Font;
|
|---|
| 486 | if FontDialog.Execute then
|
|---|
| 487 | begin
|
|---|
| 488 | NormalFontPanel.Font := FontDialog.EditFont;
|
|---|
| 489 | SetFontCaptions;
|
|---|
| 490 | end;
|
|---|
| 491 | End;
|
|---|
| 492 |
|
|---|
| 493 | Procedure TOptionsForm.OptionsFormOnShow (Sender: TObject);
|
|---|
| 494 | var
|
|---|
| 495 | ColorIndex: integer;
|
|---|
| 496 | Begin
|
|---|
| 497 |
|
|---|
| 498 | // Load settings into controls.
|
|---|
| 499 | ShowLeftPanel_HelpCheckBox.Checked := Settings.ShowLeftPanel_Help;
|
|---|
| 500 | ShowLeftPanel_StandaloneCheckBox.Checked := Settings.ShowLeftPanel_StandAlone;
|
|---|
| 501 |
|
|---|
| 502 | NormalFontPanel.Font := Settings.NormalFont;
|
|---|
| 503 | FixedFontPanel.Font := Settings.FixedFont;
|
|---|
| 504 |
|
|---|
| 505 | ApplicationFontCustomised := Settings.Fonts[ ApplicationFontIndex ] <> nil;
|
|---|
| 506 | if ApplicationFontCustomised then
|
|---|
| 507 | ApplicationFontPanel.Font := Settings.Fonts[ ApplicationFontIndex ]
|
|---|
| 508 | else
|
|---|
| 509 | ApplicationFontPanel.Font := GetNiceDefaultFont;
|
|---|
| 510 |
|
|---|
| 511 | SetFontCaptions;
|
|---|
| 512 |
|
|---|
| 513 | FixedFontSubstitutionCheckBox.Checked := Settings.FixedFontSubstitution;
|
|---|
| 514 | FixedFontSubstitutesEdit.Text := Settings.FixedFontSubstitutes;
|
|---|
| 515 |
|
|---|
| 516 | StartupHelpCheckBox.Checked := Settings.StartupHelp;
|
|---|
| 517 |
|
|---|
| 518 | SmoothScrollingCheckbox.Checked := Settings.SmoothScrolling;
|
|---|
| 519 | IndexStyleRadioGroup.ItemIndex := integer( Settings.IndexStyle );
|
|---|
| 520 | UseOriginalDialogsCheckBox.Checked := Settings.UseOriginalDialogs;
|
|---|
| 521 | OpenWithExpandedContentsCheckBox.Checked := Settings.OpenWithExpandedContents;
|
|---|
| 522 |
|
|---|
| 523 | for ColorIndex := 0 to High( Settings.Colors ) do
|
|---|
| 524 | Colors[ ColorIndex ] := Settings.Colors[ ColorIndex ];
|
|---|
| 525 |
|
|---|
| 526 | DisplayColorItem( nil );
|
|---|
| 527 |
|
|---|
| 528 | FontDialog.Font := Font;
|
|---|
| 529 |
|
|---|
| 530 | BackgroundImageFilenameEdit.Text := Settings.ToolbarBackgroundImageFilename;
|
|---|
| 531 |
|
|---|
| 532 | ToolbarStyleRadioGroup.ItemIndex := Ord( Settings.ToolbarStyle );
|
|---|
| 533 |
|
|---|
| 534 | ConfirmWinHelpCheckBox.Checked := Settings.ConfirmWinHelp;
|
|---|
| 535 |
|
|---|
| 536 | UpdatingColor := false;
|
|---|
| 537 |
|
|---|
| 538 | SmoothScrollingCheckBox.Focus; // TNotebook should do this for us, but doesn't (a bug)
|
|---|
| 539 |
|
|---|
| 540 | OKButton.Default := true;
|
|---|
| 541 | End;
|
|---|
| 542 |
|
|---|
| 543 | Procedure TOptionsForm.SetFontCaptions;
|
|---|
| 544 | begin
|
|---|
| 545 | NormalFontPanel.Caption := GetFontString( NormalFontPanel.Font );
|
|---|
| 546 | FixedFontPanel.Caption := GetFontString( FixedFontPanel.Font );
|
|---|
| 547 | if ApplicationFontCustomised then
|
|---|
| 548 | ApplicationFontPanel.Caption := GetFontString( ApplicationFontPanel.Font )
|
|---|
| 549 | else
|
|---|
| 550 | ApplicationFontPanel.Caption := '(Default)';
|
|---|
| 551 | end;
|
|---|
| 552 |
|
|---|
| 553 | procedure EnsureOptionsFormLoaded;
|
|---|
| 554 | begin
|
|---|
| 555 | if OptionsForm = nil then
|
|---|
| 556 | OptionsForm := TOptionsForm.Create( nil );
|
|---|
| 557 | end;
|
|---|
| 558 |
|
|---|
| 559 | Initialization
|
|---|
| 560 | RegisterClasses ([TOptionsForm,
|
|---|
| 561 | TLabel, TTabbedNotebook
|
|---|
| 562 | , TCheckBox, TPanel, TListBox, TGroupBox,
|
|---|
| 563 | TCustomFontDialog, TEdit, TColorWheel, TValueBar, TTrackBar, TUpDown
|
|---|
| 564 | , TRadioGroup, TButton]);
|
|---|
| 565 |
|
|---|
| 566 | RegisterUpdateProcForLanguages( EnsureOptionsFormLoaded );
|
|---|
| 567 | End.
|
|---|