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