[18] | 1 | Unit SettingsUnit;
|
---|
| 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 | // Defines settings (options) in a record and contains functions
|
---|
| 10 | // for loading and saving them to ini file.
|
---|
| 11 |
|
---|
| 12 | Uses
|
---|
| 13 | Graphics, Forms, Classes;
|
---|
| 14 |
|
---|
| 15 | Const
|
---|
| 16 | ContentsBackgroundColorIndex = 0;
|
---|
| 17 | ContentsTextColorIndex = 1;
|
---|
| 18 | ContentsLinesColorIndex = 2;
|
---|
| 19 | IndexBackgroundColorIndex = 3;
|
---|
| 20 | IndexTextColorIndex = 4;
|
---|
| 21 | SearchBackgroundColorIndex = 5;
|
---|
| 22 | SearchTextColorIndex = 6;
|
---|
| 23 | NotesListBackgroundColorIndex = 7;
|
---|
| 24 | NotesListTextColorIndex = 8;
|
---|
| 25 | TopicBackgroundColorIndex = 9;
|
---|
| 26 | NotesTextColorIndex = 10;
|
---|
| 27 | SearchHighlightTextColorIndex = 11;
|
---|
| 28 | NumColorSettings = 12;
|
---|
| 29 |
|
---|
| 30 | clLightYellow = $ffffc0;
|
---|
| 31 | clLightBlue = $e0e0ff;
|
---|
| 32 | clLightCyan = $c0ffff;
|
---|
| 33 | clLightGreen = $e0ffe0;
|
---|
| 34 |
|
---|
| 35 | VGADefaultColors: array[ 0 .. NumColorSettings - 1 ] of TColor
|
---|
| 36 | = ( clWindow,
|
---|
| 37 | clWindowText,
|
---|
| 38 | clWindowText,
|
---|
| 39 | clWindow,
|
---|
| 40 | clWindowText,
|
---|
| 41 | clWindow,
|
---|
| 42 | clWindowText,
|
---|
| 43 | clWindow,
|
---|
| 44 | clWindowText,
|
---|
| 45 | clWindow,
|
---|
| 46 | clGreen,
|
---|
| 47 | clYellow );
|
---|
| 48 |
|
---|
| 49 | DefaultColors: array[ 0 .. NumColorSettings - 1 ] of TColor
|
---|
| 50 | = ( clLightCyan,
|
---|
| 51 | clBlack,
|
---|
| 52 | clBlue,
|
---|
| 53 | clLightGreen,
|
---|
| 54 | clBlack,
|
---|
| 55 | clLightBlue,
|
---|
| 56 | clBlack,
|
---|
| 57 | clWhite,
|
---|
| 58 | clBlack,
|
---|
| 59 | clWhite,
|
---|
| 60 | clGreen,
|
---|
| 61 | clYellow );
|
---|
| 62 |
|
---|
| 63 | ApplicationFontIndex = 0;
|
---|
| 64 | NumFontSettings = 1;
|
---|
| 65 |
|
---|
| 66 | DefaultTopicFontName = 'Helv';
|
---|
| 67 | DefaultTopicFontSize = 8;
|
---|
| 68 |
|
---|
| 69 | DefaultTopicFixedFontName = 'Courier';
|
---|
| 70 | DefaultTopicFixedFontSize = 8;
|
---|
| 71 |
|
---|
| 72 | Type
|
---|
| 73 | TIndexStyle = ( isFileOnly, isAlphabetical, isFull );
|
---|
| 74 | TToolbarStyle = ( tsNone, tsImages, tsText, tsImagesAndText );
|
---|
| 75 | TGlobalSearchLocation = ( gsHelpPaths, gsFixedDrives, gsSelectedHelpPaths, gsCustom );
|
---|
| 76 |
|
---|
| 77 | TMRUItem = class
|
---|
| 78 | Title: string;
|
---|
| 79 | Filenames: TStringList;
|
---|
| 80 | constructor Create;
|
---|
| 81 | destructor Destroy; override;
|
---|
| 82 | end;
|
---|
| 83 |
|
---|
| 84 | TSettings = record
|
---|
| 85 | MRUList: TList;
|
---|
| 86 |
|
---|
| 87 | LastOpenDirectory: string;
|
---|
| 88 | LastSaveDirectory: string;
|
---|
| 89 |
|
---|
| 90 | StartupHelp: boolean;
|
---|
| 91 |
|
---|
| 92 | LeftPanelWidth: longint;
|
---|
| 93 | ShowLeftPanel_Help: boolean;
|
---|
| 94 | ShowLeftPanel_Standalone: boolean;
|
---|
| 95 |
|
---|
| 96 | FileDialogSplit: real;
|
---|
| 97 |
|
---|
| 98 | // COlours
|
---|
| 99 | Colors: array[ 0..NumColorSettings - 1 ] of TColor;
|
---|
| 100 |
|
---|
| 101 | NormalFont: TFont;
|
---|
| 102 | FixedFont: TFont;
|
---|
| 103 | Fonts: array[ 0..NumFontSettings - 1 ] of TFont;
|
---|
| 104 | FixedFontSubstitution: boolean;
|
---|
| 105 | FixedFontSubstitutes: string;
|
---|
| 106 |
|
---|
| 107 | IndexStyle: TIndexStyle;
|
---|
| 108 |
|
---|
| 109 | SmoothScrolling: boolean;
|
---|
| 110 | UseOriginalDialogs: boolean;
|
---|
| 111 | OpenWithExpandedContents: boolean;
|
---|
| 112 |
|
---|
| 113 | ToolbarBackgroundImageFilename: string;
|
---|
| 114 | ToolbarStyle: TToolbarStyle;
|
---|
| 115 |
|
---|
| 116 | ConfirmWinHelp: boolean;
|
---|
| 117 |
|
---|
| 118 | GlobalSearchLocation: TGlobalSearchLocation;
|
---|
| 119 |
|
---|
| 120 | SearchDirectories: TStringList;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | Procedure WriteWindowPos( Form: TForm );
|
---|
| 124 | Procedure ReadWindowPos( Form: TForm );
|
---|
| 125 | Procedure LoadSettings;
|
---|
| 126 | Procedure SaveSettings;
|
---|
| 127 |
|
---|
| 128 | Procedure AddToMRUList( const Title: string;
|
---|
| 129 | Filenames: TStrings );
|
---|
| 130 |
|
---|
| 131 | Var
|
---|
| 132 | Settings: TSettings;
|
---|
| 133 |
|
---|
| 134 | Implementation
|
---|
| 135 |
|
---|
| 136 | Uses
|
---|
| 137 | SysUtils, IniFiles, Dos, Forms,
|
---|
| 138 | ACLFileUtility, ACLUtility, ACLStringUtility, ACLDialogs, ACLProfile,
|
---|
| 139 | ControlsUtility;
|
---|
| 140 |
|
---|
| 141 | Const
|
---|
| 142 | IniFileName = 'NewView.ini';
|
---|
| 143 | GeneralSection = 'General';
|
---|
| 144 | FontsSection = 'Fonts';
|
---|
| 145 | ColoursSection = 'Colours';
|
---|
| 146 | MRUSection = 'RecentFiles';
|
---|
| 147 | MRUItemBaseSection = 'RecentFile';
|
---|
| 148 | SearchSection = 'Search';
|
---|
| 149 |
|
---|
| 150 | DefaultWidth = 620;
|
---|
| 151 | DefaultHeight = 460;
|
---|
| 152 |
|
---|
| 153 | MaxMRUListEntries = 9;
|
---|
| 154 |
|
---|
| 155 | constructor TMRUItem.Create;
|
---|
| 156 | begin
|
---|
| 157 | Title := '';
|
---|
| 158 | Filenames := TStringList.Create;
|
---|
| 159 | end;
|
---|
| 160 |
|
---|
| 161 | destructor TMRUItem.Destroy;
|
---|
| 162 | begin
|
---|
| 163 | Filenames.Destroy;
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
| 166 | Function IniFilePath: string;
|
---|
| 167 | Var
|
---|
| 168 | Dir: string;
|
---|
| 169 | Name, Ext: string;
|
---|
| 170 | UserIniFile: string;
|
---|
| 171 | Begin
|
---|
| 172 | // Put it in the same place as the application
|
---|
| 173 | UserIniFile := GetApplicationDir;
|
---|
| 174 | // Note: do NOT combine these two steps. Caused an obscure bug!
|
---|
| 175 | FSplit( UserIniFile, Dir, Name, Ext );
|
---|
| 176 | Result := AddSlash( Dir ) + IniFileName;
|
---|
| 177 | End;
|
---|
| 178 |
|
---|
| 179 | // Note: since Sibyl SPCC 2.1.8.3
|
---|
| 180 | // the Ascii ini file constructor does not throw an exception
|
---|
| 181 | procedure GetIniFile( Var IniFile: TMyIniFile );
|
---|
| 182 | begin
|
---|
| 183 | IniFile := TMyIniFile.Create( IniFilePath );
|
---|
| 184 | end;
|
---|
| 185 |
|
---|
| 186 | procedure CloseIniFile( Var IniFIle: TMyIniFile );
|
---|
| 187 | begin
|
---|
| 188 | try
|
---|
| 189 | ProfileEvent( 'Calling IniFile.Destroy' );
|
---|
| 190 | IniFile.Destroy;
|
---|
| 191 | except
|
---|
| 192 | on E: Exception do
|
---|
| 193 | begin
|
---|
| 194 | // don't care if we can't save settings.
|
---|
| 195 | ProfileEvent( ' Exception: ' + E.Message );
|
---|
| 196 | end;
|
---|
| 197 | end;
|
---|
| 198 | end;
|
---|
| 199 |
|
---|
| 200 | Procedure LoadSettings;
|
---|
| 201 | Var
|
---|
| 202 | IniFile: TMyIniFile;
|
---|
| 203 | ColorIndex: longint;
|
---|
| 204 | DefaultColor: TColor;
|
---|
| 205 | FontName: string;
|
---|
| 206 | SettingString: string;
|
---|
| 207 |
|
---|
| 208 | MRUItem: TMRUItem;
|
---|
| 209 | MRUItemSection: string;
|
---|
| 210 | MRUItemFileCount: longint;
|
---|
| 211 | MRUItemFileIndex: longint;
|
---|
| 212 | i: longint;
|
---|
| 213 | Count: longint;
|
---|
| 214 | MRUFilename: string;
|
---|
| 215 | MRUFileTitle: string;
|
---|
| 216 | Begin
|
---|
| 217 | GetIniFile( IniFile );
|
---|
| 218 | with IniFile do
|
---|
| 219 | begin
|
---|
| 220 | IniFile.EraseSection( 'Windows' );
|
---|
| 221 | with Settings do
|
---|
| 222 | begin
|
---|
| 223 | LastOpenDirectory := ReadString( GeneralSection, 'LastOpenDirectory', '' );
|
---|
| 224 | LastSaveDirectory := ReadString( GeneralSection, 'LastSaveDirectory', '' );
|
---|
| 225 |
|
---|
| 226 | // Read split points, as units of 0.1%
|
---|
| 227 | LeftPanelWidth := ReadInteger( GeneralSection, 'LeftPanelWidth', 225 );
|
---|
| 228 | FileDialogSplit := ReadInteger( GeneralSection, 'FileDialogSplit', 500 ) / 1000;
|
---|
| 229 |
|
---|
| 230 | ShowLeftPanel_Help := ReadBool( GeneralSection, 'ShowLeftPanel_Help', false );
|
---|
| 231 | ShowLeftPanel_Standalone := ReadBool( GeneralSection, 'ShowLeftPanel_Standalone', true );
|
---|
| 232 |
|
---|
| 233 | // Colours
|
---|
| 234 | for ColorIndex := 0 to High( Colors ) do
|
---|
| 235 | begin
|
---|
| 236 | if GetScreenColorDepth > 8 then
|
---|
| 237 | DefaultColor := DefaultColors[ ColorIndex ]
|
---|
| 238 | else
|
---|
| 239 | DefaultColor := VGADefaultColors[ ColorIndex ];
|
---|
| 240 | Colors[ ColorIndex ] := ReadInteger( ColoursSection,
|
---|
| 241 | 'Color' + IntToStr( ColorIndex ),
|
---|
| 242 | DefaultColor );
|
---|
| 243 | end;
|
---|
| 244 |
|
---|
| 245 | // Most Recently Used files list...
|
---|
| 246 |
|
---|
| 247 | Count := ReadInteger( MRUSection,
|
---|
| 248 | 'Count',
|
---|
| 249 | 0 );
|
---|
| 250 |
|
---|
| 251 | // Old style MRU list
|
---|
| 252 | for i := 0 to Count - 1 do
|
---|
| 253 | begin
|
---|
| 254 | MRUFilename := ReadString( MRUSection,
|
---|
| 255 | 'File' + IntToStr( i ),
|
---|
| 256 | '' );
|
---|
| 257 | MRUFileTitle := ReadString( MRUSection,
|
---|
| 258 | 'Title' + IntToStr( i ),
|
---|
| 259 | '' );
|
---|
| 260 | if MRUFilename <> '' then
|
---|
| 261 | begin
|
---|
| 262 | MRUItem := TMRUItem.Create;
|
---|
| 263 | MRUItem.Title := MRUFileTitle;
|
---|
| 264 | StringToList( MRUFilename,
|
---|
| 265 | MRUItem.Filenames,
|
---|
| 266 | '+' );
|
---|
| 267 | MRUList.Add( MRUItem );
|
---|
| 268 | end;
|
---|
| 269 | end;
|
---|
| 270 |
|
---|
| 271 | // New style
|
---|
| 272 | for i := 0 to Count - 1 do
|
---|
| 273 | begin
|
---|
| 274 | MRUItemSection := MRUItemBaseSection + IntToStr( i );
|
---|
| 275 |
|
---|
| 276 | MRUItem := TMRUItem.Create;
|
---|
| 277 |
|
---|
| 278 | MRUItem.Title := ReadString( MRUItemSection,
|
---|
| 279 | 'Title',
|
---|
| 280 | '' );
|
---|
| 281 |
|
---|
| 282 | MRUItemFileCount := ReadInteger( MRUItemSection,
|
---|
| 283 | 'FileCount',
|
---|
| 284 | 0 );
|
---|
| 285 | for MRUItemFileIndex := 0 to MRUItemFileCount - 1 do
|
---|
| 286 | begin
|
---|
| 287 | MRUFilename := ReadString( MRUItemSection,
|
---|
| 288 | 'File' + IntToStr( MRUItemFileIndex ),
|
---|
| 289 | '' );
|
---|
| 290 | if MRUFilename <> '' then
|
---|
| 291 | begin
|
---|
| 292 | MRUItem.Filenames.Add( MRUFilename );
|
---|
| 293 | end;
|
---|
| 294 | end;
|
---|
| 295 |
|
---|
| 296 | if ( MRUItem.Title <> '' )
|
---|
| 297 | and ( MRUItem.Filenames.Count > 0 ) then
|
---|
| 298 | begin
|
---|
| 299 | // valid MRU item
|
---|
| 300 | MRUList.Add( MRUItem );
|
---|
| 301 | end
|
---|
| 302 | else
|
---|
| 303 | begin
|
---|
| 304 | // not valid
|
---|
| 305 | MRUItem.Destroy;
|
---|
| 306 | MRUItem := nil;
|
---|
| 307 | end;
|
---|
| 308 |
|
---|
| 309 | end;
|
---|
| 310 |
|
---|
| 311 | // Fonts
|
---|
| 312 | NormalFont := Screen.GetFontFromPointSize(
|
---|
| 313 | ReadString( FontsSection, 'NormalFont', DefaultTopicFontName ),
|
---|
| 314 | ReadInteger( FontsSection, 'NormalFontSize', DefaultTopicFontSize ) );
|
---|
| 315 | if NormalFont = nil then
|
---|
| 316 | NormalFont := Screen.DefaultFont;
|
---|
| 317 |
|
---|
| 318 | FixedFont := Screen.GetFontFromPointSize(
|
---|
| 319 | ReadString( FontsSection, 'FixedFont', DefaultTopicFixedFontName ),
|
---|
| 320 | ReadInteger( FontsSection, 'FixedFontSize', DefaultTopicFixedFontSize ) );
|
---|
| 321 | if FixedFont = nil then
|
---|
| 322 | FixedFont := Screen.DefaultFont;
|
---|
| 323 |
|
---|
| 324 | for i := 0 to NumFontSettings - 1 do
|
---|
| 325 | begin
|
---|
| 326 | FontName := 'Font' + IntToStr( i );
|
---|
| 327 | Fonts[ i ] := nil;
|
---|
| 328 | if ReadBool( FontsSection,
|
---|
| 329 | FontName
|
---|
| 330 | + 'Customised',
|
---|
| 331 | false ) then
|
---|
| 332 | Fonts[ i ] := Screen.GetFontFromPointSize(
|
---|
| 333 | ReadString( FontsSection, FontName + 'Face', DefaultTopicFontName ),
|
---|
| 334 | ReadInteger( FontsSection, FontName + 'Size', 10 ) );
|
---|
| 335 | end;
|
---|
| 336 |
|
---|
| 337 | FixedFontSubstitution := ReadBool( FontsSection, 'FixedFontSubstitution', true );
|
---|
| 338 | FixedFontSubstitutes := ReadString( FontsSection, 'FixedFontSubstitutes', 'Courier 18x12' );
|
---|
| 339 |
|
---|
| 340 | // Index style
|
---|
| 341 | SettingString := ReadString( GeneralSection, 'IndexStyle', 'Full' );
|
---|
| 342 | if StringsSame( SettingString, 'FileOnly' ) then
|
---|
| 343 | IndexStyle := isFileOnly
|
---|
| 344 | else if StringsSame( SettingString, 'Alphabetical' ) then
|
---|
| 345 | IndexStyle := isAlphabetical
|
---|
| 346 | else
|
---|
| 347 | IndexStyle := isFull;
|
---|
| 348 |
|
---|
| 349 | StartupHelp := ReadBool( GeneralSection, 'StartupHelp', true );
|
---|
| 350 |
|
---|
| 351 | SmoothScrolling := ReadBool( GeneralSection, 'SmoothScrolling', true );
|
---|
| 352 | UseOriginalDialogs := ReadBool( GeneralSection, 'UseOriginalDialogs', false );
|
---|
| 353 | OpenWithExpandedContents := ReadBool( GeneralSection, 'OpenWithExpandedContents', false );
|
---|
| 354 |
|
---|
| 355 | ToolBarBackgroundImageFilename := ReadString( GeneralSection, 'ToolbarBackground', '' );
|
---|
| 356 | SettingString := ReadString( GeneralSection, 'ToolbarStyle', 'ImagesAndText' );
|
---|
| 357 |
|
---|
| 358 | if StringsSame( SettingString, 'None' ) then
|
---|
| 359 | ToolbarStyle := tsNone
|
---|
| 360 | else if StringsSame( SettingString, 'Images' ) then
|
---|
| 361 | ToolbarStyle := tsImages
|
---|
| 362 | else if StringsSame( SettingString, 'Text' ) then
|
---|
| 363 | ToolbarStyle := tsText
|
---|
| 364 | else
|
---|
| 365 | ToolbarStyle := tsImagesAndText;
|
---|
| 366 |
|
---|
| 367 | ConfirmWinHelp := ReadBool( GeneralSection, 'ConfirmWinHelp', true );
|
---|
| 368 |
|
---|
| 369 | Count := ReadInteger( SearchSection,
|
---|
| 370 | 'CustomDirCount',
|
---|
| 371 | 0 );
|
---|
| 372 |
|
---|
| 373 | SearchDirectories.Clear;
|
---|
| 374 | for i := 0 to Count - 1 do
|
---|
| 375 | begin
|
---|
| 376 | SettingString := ReadString( SearchSection,
|
---|
| 377 | 'CustomDir' + IntToStr( i ),
|
---|
| 378 | '' );
|
---|
| 379 | if trim( SettingString ) <> '' then
|
---|
| 380 | SearchDirectories.Add( SettingString );
|
---|
| 381 | end;
|
---|
| 382 |
|
---|
| 383 | SettingString := ReadString( SearchSection,
|
---|
| 384 | 'Location',
|
---|
| 385 | 'HelpPaths' );
|
---|
| 386 | if StringsSame( SettingString, 'HelpPaths' ) then
|
---|
| 387 | GlobalSearchLocation := gsHelpPaths
|
---|
| 388 | else if StringsSame( SettingString, 'FixedDrives' ) then
|
---|
| 389 | GlobalSearchLocation := gsFixedDrives
|
---|
| 390 | else if StringsSame( SettingString, 'SelectedHelpPaths' ) then
|
---|
| 391 | GlobalSearchLocation := gsSelectedHelpPaths
|
---|
| 392 | else
|
---|
| 393 | GlobalSearchLocation := gsCustom;
|
---|
| 394 |
|
---|
| 395 | end;
|
---|
| 396 | end;
|
---|
| 397 | CloseIniFile( IniFile );
|
---|
| 398 | End;
|
---|
| 399 |
|
---|
| 400 | Procedure SaveSettings;
|
---|
| 401 | Var
|
---|
| 402 | IniFile: TMyIniFile;
|
---|
| 403 | ColorIndex: longint;
|
---|
| 404 | FontIndex: longint;
|
---|
| 405 | FontName: string;
|
---|
| 406 | i: longint;
|
---|
| 407 | MRUItemFileIndex: longint;
|
---|
| 408 | SettingString: string;
|
---|
| 409 | MRUItem: TMRUItem;
|
---|
| 410 | MRUItemSection: string;
|
---|
| 411 |
|
---|
| 412 | Begin
|
---|
| 413 | ProfileEvent( 'SaveSettings' );
|
---|
| 414 | GetIniFile( IniFile );
|
---|
| 415 | with IniFile do
|
---|
| 416 | begin
|
---|
| 417 | with Settings do
|
---|
| 418 | begin
|
---|
| 419 | WriteString( GeneralSection, 'LastOpenDirectory', LastOpenDirectory );
|
---|
| 420 | WriteString( GeneralSection, 'LastSaveDirectory', LastSaveDirectory );
|
---|
| 421 |
|
---|
| 422 | WriteInteger( GeneralSection, 'LeftPanelWidth', LeftPanelWidth );
|
---|
| 423 | // Write split points, as units of 0.1%
|
---|
| 424 | WriteInteger( GeneralSection, 'FileDialogSplit', Round( FileDialogSplit * 1000 ) );
|
---|
| 425 |
|
---|
| 426 | WriteBool( GeneralSection, 'ShowLeftPanel_Help', ShowLeftPanel_Help );
|
---|
| 427 | WriteBool( GeneralSection, 'ShowLeftPanel_Standalone', ShowLeftPanel_Standalone );
|
---|
| 428 |
|
---|
| 429 | // COlours
|
---|
| 430 | for ColorIndex := 0 to High( Colors ) do
|
---|
| 431 | WriteInteger( ColoursSection,
|
---|
| 432 | 'Color' + IntToStr( ColorIndex ),
|
---|
| 433 | Colors[ ColorIndex ] );
|
---|
| 434 |
|
---|
| 435 | EraseSection( MRUSection ); // get rid of old style MRU
|
---|
| 436 | WriteInteger( MRUSection,
|
---|
| 437 | 'Count',
|
---|
| 438 | MRUList.Count );
|
---|
| 439 |
|
---|
| 440 | for i := 0 to MRUList.Count - 1 do
|
---|
| 441 | begin
|
---|
| 442 | MRUItem := MRUList[ i ];
|
---|
| 443 |
|
---|
| 444 | MRUItemSection := MRUItemBaseSection + IntToStr( i );
|
---|
| 445 | EraseSection( MRUItemSection );
|
---|
| 446 |
|
---|
| 447 | WriteString( MRUItemSection,
|
---|
| 448 | 'Title',
|
---|
| 449 | MRUItem.Title );
|
---|
| 450 |
|
---|
| 451 | WriteInteger( MRUItemSection,
|
---|
| 452 | 'FileCount',
|
---|
| 453 | MRUItem.Filenames.Count );
|
---|
| 454 |
|
---|
| 455 | for MRUItemFileIndex := 0 to MRUItem.Filenames.Count - 1 do
|
---|
| 456 | WriteString( MRUItemSection,
|
---|
| 457 | 'File' + IntToStr( MRUItemFileIndex ),
|
---|
| 458 | MRUItem.Filenames[ MRUItemFileIndex ] );
|
---|
| 459 | end;
|
---|
| 460 |
|
---|
| 461 | // clear unused sections
|
---|
| 462 | for i := MRUList.Count to MaxMRUListEntries do
|
---|
| 463 | begin
|
---|
| 464 | MRUItemSection := MRUItemBaseSection + IntToStr( i );
|
---|
| 465 | EraseSection( MRUItemSection );
|
---|
| 466 | end;
|
---|
| 467 |
|
---|
| 468 | WriteString( FontsSection, 'NormalFont', NormalFont.FaceName );
|
---|
| 469 | WriteInteger( FontsSection, 'NormalFontSize', NormalFont.PointSize );
|
---|
| 470 | WriteString( FontsSection, 'FixedFont', FixedFont.FaceName );
|
---|
| 471 | WriteInteger( FontsSection, 'FixedFontSize', FixedFont.PointSize );
|
---|
| 472 |
|
---|
| 473 | for FontIndex := 0 to NumFontSettings - 1 do
|
---|
| 474 | begin
|
---|
| 475 | FontName := 'Font' + IntToStr( FontIndex );
|
---|
| 476 |
|
---|
| 477 | WriteBool( FontsSection, FontName + 'Customised', Fonts[ FontIndex ] <> nil );
|
---|
| 478 |
|
---|
| 479 | if Fonts[ FontIndex ] <> nil then
|
---|
| 480 | begin
|
---|
| 481 | WriteString( FontsSection, FontName + 'Face', Fonts[ FontIndex ].FaceName );
|
---|
| 482 | WriteInteger( FontsSection, FontName + 'Size', Fonts[ FontIndex ].PointSize );
|
---|
| 483 | end;
|
---|
| 484 |
|
---|
| 485 | end;
|
---|
| 486 |
|
---|
| 487 | WriteBool( FontsSection, 'FixedFontSubstitution', FixedFontSubstitution );
|
---|
| 488 | WriteString( FontsSection, 'FixedFontSubstitutes', FixedFontSubstitutes );
|
---|
| 489 |
|
---|
| 490 | case IndexStyle of
|
---|
| 491 | isFileOnly:
|
---|
| 492 | SettingString := 'FileOnly';
|
---|
| 493 | isAlphabetical:
|
---|
| 494 | SettingString := 'Alphabetical';
|
---|
| 495 | isFull:
|
---|
| 496 | SettingString := 'Full';
|
---|
| 497 | end;
|
---|
| 498 |
|
---|
| 499 | WriteString( GeneralSection, 'IndexStyle', SettingString );
|
---|
| 500 |
|
---|
| 501 | WriteBool( GeneralSection, 'StartupHelp', StartupHelp );
|
---|
| 502 |
|
---|
| 503 | WriteBool( GeneralSection, 'SmoothScrolling', SmoothScrolling );
|
---|
| 504 | WriteBool( GeneralSection, 'UseOriginalDialogs', UseOriginalDialogs );
|
---|
| 505 | WriteBool( GeneralSection, 'OpenWithExpandedContents', OpenWithExpandedContents );
|
---|
| 506 |
|
---|
| 507 | WriteString( GeneralSection, 'ToolbarBackground', ToolbarBackgroundImageFilename );
|
---|
| 508 |
|
---|
| 509 | case ToolbarStyle of
|
---|
| 510 | tsNone:
|
---|
| 511 | SettingString := 'None';
|
---|
| 512 | tsImages:
|
---|
| 513 | SettingString := 'Images';
|
---|
| 514 | tsText:
|
---|
| 515 | SettingString := 'Text';
|
---|
| 516 | tsImagesAndText:
|
---|
| 517 | SettingString := 'ImagesAndText';
|
---|
| 518 | end;
|
---|
| 519 |
|
---|
| 520 | WriteString( GeneralSection, 'ToolbarStyle', SettingString );
|
---|
| 521 |
|
---|
| 522 | WriteBool( GeneralSection, 'ConfirmWinHelp', ConfirmWinHelp );
|
---|
| 523 |
|
---|
| 524 | WriteInteger( SearchSection,
|
---|
| 525 | 'CustomDirCount',
|
---|
| 526 | SearchDirectories.Count );
|
---|
| 527 |
|
---|
| 528 | SearchDirectories.Sorted := true;
|
---|
| 529 | SearchDirectories.CaseSensitive := false;
|
---|
| 530 | SearchDirectories.Duplicates := dupIgnore;
|
---|
| 531 |
|
---|
| 532 | for i := 0 to SearchDirectories.Count - 1 do
|
---|
| 533 | begin
|
---|
| 534 | WriteString( SearchSection,
|
---|
| 535 | 'CustomDir' + IntToStr( i ),
|
---|
| 536 | SearchDirectories[ i ] );
|
---|
| 537 | end;
|
---|
| 538 |
|
---|
| 539 | case GlobalSearchLocation of
|
---|
| 540 | gsHelpPaths:
|
---|
| 541 | SettingString := 'HelpPaths';
|
---|
| 542 |
|
---|
| 543 | gsFixedDrives:
|
---|
| 544 | SettingString := 'FixedDrives';
|
---|
| 545 |
|
---|
| 546 | gsSelectedHelpPaths:
|
---|
| 547 | SettingString := 'SelectedHelpPaths';
|
---|
| 548 |
|
---|
| 549 | gsCustom:
|
---|
| 550 | SettingString := 'Custom';
|
---|
| 551 | end;
|
---|
| 552 |
|
---|
| 553 | WriteString( SearchSection,
|
---|
| 554 | 'Location',
|
---|
| 555 | SettingString );
|
---|
| 556 |
|
---|
| 557 | end;
|
---|
| 558 | end;
|
---|
| 559 | CloseIniFile( IniFile );
|
---|
| 560 | ProfileEvent( ' Done' );
|
---|
| 561 |
|
---|
| 562 | End;
|
---|
| 563 |
|
---|
| 564 | Procedure AddToMRUList( const Title: string;
|
---|
| 565 | Filenames: TStrings );
|
---|
| 566 | var
|
---|
| 567 | MRUIndex: longint;
|
---|
| 568 | PreviousMRUIndex: longint;
|
---|
| 569 | MRUItem: TMRUItem;
|
---|
| 570 | begin
|
---|
| 571 | PreviousMRUIndex := -1;
|
---|
| 572 | for MRUIndex := 0 to Settings.MRUList.Count - 1 do
|
---|
| 573 | begin
|
---|
| 574 | MRUItem := Settings.MRUList[ MRUIndex ];
|
---|
| 575 |
|
---|
| 576 | if ( MRUItem.Title = Title )
|
---|
| 577 | and ( MRUItem.Filenames.Equals( Filenames ) ) then
|
---|
| 578 | begin
|
---|
| 579 | // found identical entry in the list already.
|
---|
| 580 | PreviousMRUIndex := MRUIndex;
|
---|
| 581 | break;
|
---|
| 582 | end;
|
---|
| 583 | end;
|
---|
| 584 |
|
---|
| 585 | if PreviousMRUIndex > -1 then
|
---|
| 586 | begin
|
---|
| 587 | // is already in list, move to top of list
|
---|
| 588 | MRUItem := Settings.MRUList[ PreviousMRUIndex ];
|
---|
| 589 | Settings.MRUList.Delete( PreviousMRUIndex );
|
---|
| 590 | end
|
---|
| 591 | else
|
---|
| 592 | begin
|
---|
| 593 | // not yet in list. Create new
|
---|
| 594 | MRUItem := TMRUItem.Create;
|
---|
| 595 | MRUItem.Title := Title;
|
---|
| 596 | MRUItem.Filenames.Assign( Filenames );
|
---|
| 597 | end;
|
---|
| 598 |
|
---|
| 599 | Settings.MRUList.Insert( 0, MRUItem );
|
---|
| 600 |
|
---|
| 601 | while Settings.MRUList.Count > MaxMRUListEntries do
|
---|
| 602 | begin
|
---|
| 603 | MRUItem := Settings.MRUList[ MaxMRUListEntries ];
|
---|
| 604 | Settings.MRUList.Delete( MaxMRUListEntries );
|
---|
| 605 | MRUItem.Destroy;
|
---|
| 606 | end;
|
---|
| 607 | end;
|
---|
| 608 |
|
---|
| 609 | Procedure WriteWindowPos( Form: TForm );
|
---|
| 610 | Var
|
---|
| 611 | IniFile: TMyIniFile;
|
---|
| 612 | Begin
|
---|
| 613 | GetIniFile( IniFile );
|
---|
| 614 | SaveFormSizePosition( Form, IniFile );
|
---|
| 615 | CloseIniFile( IniFile );
|
---|
| 616 | End;
|
---|
| 617 |
|
---|
| 618 | Procedure ReadWindowPos( Form: TForm );
|
---|
| 619 | Var
|
---|
| 620 | IniFile: TMyIniFile;
|
---|
| 621 | Begin
|
---|
| 622 | GetIniFile( IniFile );
|
---|
| 623 | LoadFormSizePosition( Form, IniFile );
|
---|
| 624 | CloseIniFile( IniFile );
|
---|
| 625 | End;
|
---|
| 626 |
|
---|
| 627 | Initialization
|
---|
| 628 | Settings.NormalFont := Screen.GetFontFromPointSize( 'Helv',
|
---|
| 629 | 8 );
|
---|
| 630 | Settings.FixedFont := Screen.GetFontFromPointSize( 'Courier',
|
---|
| 631 | 8 );
|
---|
| 632 | Settings.SearchDirectories := TStringList.Create;
|
---|
| 633 |
|
---|
| 634 | Finalization
|
---|
| 635 | Settings.NormalFont.Destroy;
|
---|
| 636 | Settings.FixedFont.Destroy;
|
---|
| 637 | Settings.SearchDirectories.Destroy;
|
---|
| 638 | End.
|
---|