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