home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Calmira / Src / SRC / SETTINGS.PAS < prev    next >
Pascal/Delphi Source File  |  1997-02-15  |  25KB  |  653 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 1.0                                                    }
  5. {    Copyright (C) 1997  Li-Hsin Huang                                     }
  6. {                                                                          }
  7. {    This program is free software; you can redistribute it and/or modify  }
  8. {    it under the terms of the GNU General Public License as published by  }
  9. {    the Free Software Foundation; either version 2 of the License, or     }
  10. {    (at your option) any later version.                                   }
  11. {                                                                          }
  12. {    This program is distributed in the hope that it will be useful,       }
  13. {    but WITHOUT ANY WARRANTY; without even the implied warranty of        }
  14. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         }
  15. {    GNU General Public License for more details.                          }
  16. {                                                                          }
  17. {    You should have received a copy of the GNU General Public License     }
  18. {    along with this program; if not, write to the Free Software           }
  19. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             }
  20. {                                                                          }
  21. {**************************************************************************}
  22.  
  23. unit Settings;
  24.  
  25. { Settings manager
  26.  
  27.   This unit is responsible for loading and saving most settings, using
  28.   the main INI file.  Most settings are also declared here.
  29.  
  30.   Each set of properties has associated load and save procedures.  The
  31.   load procedure is called during startup, and the save procedure is
  32.   called by the individual property dialogs, after the user presses OK.
  33.  
  34.   LoadSettings() will initialize some general settings, and those which
  35.   are not available for editing in dialogs.  Then it loads all the
  36.   settings which do belong in property dialogs.
  37.  
  38.   AnnounceSettingsChanged() should be called by a property dialog
  39.   after it has saved its properties, passing a parameter that indicates
  40.   which part of the setup has changed.  This causes WM_SETTINGSCHANGED
  41.   to be broadcast to all forms, which respond appropriately.
  42. }
  43.  
  44. interface
  45.  
  46. uses Classes, SysUtils, IniFiles, Profile, WinTypes, Graphics, Controls, Forms;
  47.  
  48. type
  49.   { sorting in icon windows }
  50.   TSortOrder = (soType, soName, soSize, soDate);
  51.  
  52.   { new window placement }
  53.   TWindowOpen = (woCascaded, woRandom, woSaved);
  54.  
  55.   { trash management }
  56.   TBinAction  = (baLeave, baDelete, baEmpty, baCollect);
  57.  
  58.   { application colour palette }
  59.   TCalColor = (ccWinFrame, ccIconBack, ccIconSel, ccShortArrow,
  60.     ccAliasArrow, ccPercent, ccPercentText, ccTaskbar);
  61.  
  62.   TSettingChanges = set of (scSystem, scFileSystem, scDesktop,
  63.     scStartMenu, scBin, scTaskbar, scDisplay, scINIFile, sc4DOS, scDevices);
  64.  
  65. const
  66.   ColorNames : array[TCalColor] of string[15] =
  67.   ('Window frames', 'Icon background', 'Icon selection', 'Shortcut arrows',
  68.    'Alias arrows', 'Percent bar', 'Percent text', 'Taskbar');
  69.  
  70.   DefaultColors : array[TCalColor] of TColor =
  71.     (clSilver, clWindow, clSilver, clBlack, clBlack, clBlue,
  72.      clOlive, clSilver);
  73.  
  74.   Programs      : string[79] = 'com exe bat pif';
  75.  
  76. var
  77.   { System properties }
  78.   SysCaption   : TCaption;
  79.   ShowSplash   : Boolean;
  80.   LoadTaskbar  : Boolean;
  81.   RestoreSys   : Boolean;   { restore system window after loading }
  82.   SysWinQuit   : Boolean;   { close system window to quit program }
  83.   QueryQuit    : Boolean;
  84.   TrackThumb   : Boolean;   { scroll window contents when dragging scrollbar }
  85.   KeyBreak     : Boolean;   { break from loops using Esc }
  86.  
  87.   { File system properties }
  88.  
  89.   DefaultSort   : TSortOrder;
  90.   DefaultFilter : string[12];
  91.   IconStrings   : TFilename;    { extensions to search for icons in }
  92.  
  93.   FileHints    : Boolean;
  94.   HintDelay    : Integer;
  95.  
  96.   UseDescriptions : Boolean;
  97.   DescCaptions    : Boolean;    { show descriptions as captions }
  98.   Simul4DOS       : Boolean;    { load description file before changing }
  99.   IgnoreCtrlD     : Boolean;    { don't bother with ^D markers in descriptions }
  100.  
  101.   ConfirmCopyStart : Boolean;
  102.   ConfirmMoveStart : Boolean;
  103.   ConfirmDelStart  : Boolean;
  104.   ConfirmCopyFile  : Boolean;
  105.   ConfirmMoveFile  : Boolean;
  106.   ConfirmDelFile   : Boolean;
  107.   ConfirmReplace   : Boolean;
  108.   ConfirmProtect   : Boolean;
  109.   ConfirmCopyFolder : Boolean;
  110.   ConfirmMoveFolder : Boolean;
  111.   ConfirmDelFolder  : Boolean;
  112.   ConfirmNewAlias   : Boolean;
  113.  
  114.   BackCopying   : Boolean;  { background copying }
  115.   ShowHidSys    : Boolean;  { show hidden/system files }
  116.   ShowList      : Boolean;  { display list view in new icon windows }
  117.   ProgDrop      : Boolean;  { allow drop into programs }
  118.   FindVersion   : Boolean;  { look for version information }
  119.   FindDlgIcons  : Boolean;  { icons in find dialog list }
  120.   RefreshFolders: Boolean;  { refresh windows re-opened by shortcuts }
  121.   AliasArrows   : Boolean;
  122.   HintDesc      : Boolean;
  123.   HintDate      : Boolean;
  124.   HintTime      : Boolean;
  125.   HintAttrib    : Boolean;
  126.  
  127.   InspectProg  : TFilename;
  128.   DefaultProg  : TFilename;
  129.   UndeleteProg : TFilename;
  130.   DiskProg     : TFilename;
  131.  
  132.   { Desktop properties }
  133.  
  134.   WindowOpen : TWindowOpen;   { new window placement }
  135.   AutoSize : Boolean;         { adjust icon window size to fit contents }
  136.   HollowDrag : Boolean;
  137.   SaveWindows : Boolean;      { save windows between sessions }
  138.   ShortArrows : Boolean;
  139.   AnimCursor : Boolean;
  140.   ShowDeskMenu : Boolean;
  141.   TreeAlign : Boolean;        { align file window with tree view }
  142.   ConfirmDelShort : Boolean;
  143.   StickyShorts : Boolean;     { move only when caption is dragged }
  144.   OneClickShorts : Boolean;   { activate after single click }
  145.   BrowseSame : Boolean;       { browse folders in same window }
  146.   RightClose : Boolean;       { right click on min/max box to close }
  147.   FilePaneCols : Integer;     { columns in file pane of explorer }
  148.  
  149.   { Taskbar properties }
  150.  
  151.   StayVisible   : Boolean;
  152.   Highlight     : Boolean;    { press button of active task }
  153.   ShrinkMax     : Boolean;    { constrain maximised windows above the bar }
  154.   Clock24       : Boolean;
  155.   PopupRes      : Boolean;
  156.   PopupDate     : Boolean;
  157.   Animate       : Boolean;
  158.   ButtonHints   : Boolean;
  159.   ArrangeMin    : Boolean;    { move minimised windows upwards }
  160.   HideMinApps   : Boolean;
  161.   IconWindowTask : Boolean;
  162.   ExplorerTask   : Boolean;
  163.   FullFolderPath : Boolean;
  164.   CalIcons       : Boolean;
  165.   DocNameFirst   : Boolean;
  166.   DocNameLower   : Boolean;
  167.  
  168.  
  169.   { Bin properties }
  170.  
  171.   BinCaption   : TCaption;
  172.   BinAction    : TBinAction;
  173.   BinCapacity  : Integer;
  174.   BinIcons     : Boolean;
  175.   BinDisable   : Boolean;
  176.  
  177.   { Start menu properties }
  178.  
  179.   StartMenu3D  : Boolean;
  180.   ShellStartup : Boolean;
  181.   BoldSelect   : Boolean;
  182.   StartMouseUp : Boolean;
  183.   StartFile    : TFilename;  { normally "START.INI" }
  184.  
  185.   { Internal }
  186.  
  187.   IsShell : Boolean;            { true when this program is the shell }
  188.   DoubleClickSpeed : Integer;   { read from WIN.INI }
  189.   Sounds  : TStringList;        { sound effects WAV file list }
  190.   KeyMaps : TStringList;        { keyboard shortcuts }
  191.   WindowPos : TStringList;      { window positions }
  192.   DriveNames : TStringList;    { user defined names for disk drives }
  193.   ini     : TProfile;           { main ini file }
  194.   FirstRun: Boolean;            { first time Calmira is run }
  195.   FillMenu : Boolean;           { fill start menu with grey }
  196.   Colors  : array[TCalColor] of TColor;
  197.  
  198.   DeskGrid        : TPoint;   { desktop grid for lining up icons }
  199.   BrowseGrid      : TPoint;   { icon window grid size }
  200.   LineHeight      : Integer;  { height of lists and outlines }
  201.   MinAppHeight    : Integer;  { height of icons above the taskbar }
  202.   DescWidth       : Integer;  { width of descriptions in icon windows }
  203.  
  204.   GlobalFont : TFont;
  205.  
  206. procedure LoadSettings;
  207. procedure AnnounceSettingsChanged(changes : TSettingChanges);
  208.  
  209. procedure LoadSystemProp;
  210. procedure SaveSystemProp;
  211. procedure LoadFileSysProp;
  212. procedure SaveFileSysProp;
  213. procedure LoadBinProp;
  214. procedure SaveBinProp;
  215. procedure LoadDeskProp;
  216. procedure SaveDeskProp;
  217. procedure LoadStartProp;
  218. procedure SaveStartProp;
  219. procedure LoadTaskProp;
  220. procedure SaveTaskProp;
  221.  
  222.  
  223. implementation
  224.  
  225. uses Directry, Strings, MiscUtil, WinProcs, Resource, CalMsgs, Menus,
  226.   Start, FourDOS, Environs, Files, FileMan;
  227.  
  228.  
  229. procedure ReplaceBitmapColors(bitmap : TBitmap; source, dest: TColor);
  230. var i, j: Integer;
  231. begin
  232.   { changes pixels from one colour to another }
  233.   if source <> dest then
  234.     with bitmap do
  235.       for i := 0 to Width-1 do
  236.         for j := 0 to Height-1 do
  237.           if Canvas.Pixels[i, j] = source then Canvas.Pixels[i, j] := dest;
  238. end;
  239.  
  240.  
  241. function ReadColor(col: TCalColor): TColor;
  242. var s: string[31];
  243. begin
  244.   s := ini.ReadString('Colors', ColorNames[col], '');
  245.   if s = '' then Result := DefaultColors[col]
  246.   else Result := StringToColor(s);
  247. end;
  248.  
  249.  
  250. procedure LoadSettings;
  251. var
  252.   i : Integer;
  253.   s : string;
  254.   sysini : TIniFile;
  255. begin
  256.   with ini do begin
  257.     DeskGrid.X   := ReadInteger('Desktop', 'DeskGridX', 16);
  258.     DeskGrid.Y   := ReadInteger('Desktop', 'DeskGridY', 16);
  259.     FilePaneCols := ReadInteger('Desktop', 'FilePaneCols', 4);
  260.  
  261.     ReadFont('Display', GlobalFont);
  262.  
  263.     ReadSectionValues('Environment', Environment);
  264.     Environment.Values['CALMIRA'] := Lowercase(ExtractFileDir(ApplicationPath));
  265.     Sounds.Clear;
  266.     ReadSectionValues('Sounds', Sounds);
  267.  
  268.     DriveNames.Clear;
  269.     ReadSectionValues('Drives', DriveNames);
  270.     ReadSectionValues('Window positions', WindowPos);
  271.  
  272.     Keymaps.Clear;
  273.     ReadSection('Keyboard', KeyMaps);
  274.     for i := 0 to KeyMaps.Count-1 do begin
  275.       s := ReadString('Keyboard', KeyMaps[i], '');
  276.       KeyMaps.Objects[i] := TObject(TextToShortcut('Ctrl+Alt+' + s));
  277.     end;
  278.  
  279.     DescriptionFile := ReadString('File system', 'DescriptionFile', 'descript.ion');
  280.     DescWidth       := ReadInteger('File System', 'DescriptionWidth', -1);
  281.     FirstRun        := ReadBool('Calmira', 'FirstRun', True);
  282.     WriteBool('Calmira', 'FirstRun', False);
  283.   end;
  284.  
  285.   sysini := TIniFile.Create('system.ini');
  286.   IsShell := Lowercase(ExtractFilename(
  287.     sysini.ReadString('boot', 'shell', 'progman.exe'))) = 'calmira.exe';
  288.   sysini.Free;
  289.  
  290.   sysini := TIniFile.Create('win.ini');
  291.   programs := ' ' + Lowercase(sysini.ReadString('windows', 'Programs', programs)) + ' ';
  292.   DoubleClickSpeed := sysini.ReadInteger('windows', 'DoubleClickSpeed', 250);
  293.   sysini.Free;
  294.  
  295.   LoadSystemProp;
  296.   LoadDeskProp;
  297.   LoadFileSysProp;
  298.   LoadTaskProp;
  299.   LoadBinProp;
  300.   LoadStartProp;
  301. end;
  302.  
  303.  
  304. { Bin properties }
  305.  
  306. procedure LoadBinProp;
  307. begin
  308.   with ini do begin
  309.     BinCaption  := ReadString('Bin', 'Caption', 'Bin');
  310.     BinAction   := TBinAction(ReadInteger('Bin', 'Action', 0));
  311.     BinCapacity := ReadInteger('Bin', 'Capacity', 8);
  312.     BinIcons    := ReadBool('Bin', 'Icons', False);
  313.     BinDisable  := ReadBool('Bin', 'Disable', False);
  314.   end;
  315. end;
  316.  
  317. procedure SaveBinProp;
  318. begin
  319.   with ini do begin
  320.     WriteString('Bin', 'Caption', BinCaption);
  321.     WriteInteger('Bin', 'Action', Integer(BinAction));
  322.     WriteInteger('Bin', 'Capacity', BinCapacity);
  323.     WriteBool('Bin', 'Icons', BinIcons);
  324.     WriteBool('Bin', 'Disable', BinDisable);
  325.   end;
  326. end;
  327.  
  328.  
  329. { Desktop properties }
  330.  
  331. procedure LoadDeskProp;
  332. begin
  333.   with ini do begin
  334.     AutoSize := ReadBool('Preferences', 'AutoSize', True);
  335.     HollowDrag := ReadBool('Preferences', 'HollowDrag', False);
  336.     SaveWindows := ReadBool('Preferences', 'SaveWindows', False);
  337.     ShortArrows := ReadBool('Preferences', 'ShortArrows', True);
  338.     AnimCursor := ReadBool('Preferences', 'AnimCursor', True);
  339.     ShowDeskMenu := ReadBool('Preferences', 'ShowDeskMenu', True);
  340.     TreeAlign := ReadBool('Preferences', 'TreeAlign', True);
  341.     StickyShorts := ReadBool('Preferences', 'StickyShorts', True);
  342.     OneClickShorts := ReadBool('Preferences', 'OneClickShorts', False);
  343.     BrowseSame := ReadBool('Preferences', 'BrowseSame', False);
  344.     RightClose := ReadBool('Preferences', 'RightClose', False);
  345.     ConfirmDelShort := ReadBool('Confirmation', 'DelShort', True);
  346.     WindowOpen := TWindowOpen(ReadInteger('Preferences', 'WindowOpen', 0));
  347.   end;
  348. end;
  349.  
  350.  
  351. procedure SaveDeskProp;
  352. begin
  353.   with ini do begin
  354.     WriteBool('Preferences', 'AutoSize', AutoSize);
  355.     WriteBool('Preferences', 'HollowDrag', HollowDrag);
  356.     WriteBool('Preferences', 'SaveWindows', SaveWindows);
  357.     WriteBool('Preferences', 'ShortArrows', ShortArrows);
  358.     WriteBool('Preferences', 'AnimCursor', AnimCursor);
  359.     WriteBool('Preferences', 'ShowDeskMenu', ShowDeskMenu);
  360.     WriteBool('Preferences', 'TreeAlign', TreeAlign);
  361.     WriteBool('Confirmation', 'DelShort', ConfirmDelShort);
  362.     WriteBool('Preferences', 'StickyShorts', StickyShorts);
  363.     WriteBool('Preferences', 'OneClickShorts', OneClickShorts);
  364.     WriteBool('Preferences', 'BrowseSame', BrowseSame);
  365.     WriteBool('Preferences', 'RightClose', RightClose);
  366.     WriteInteger('Preferences', 'WindowOpen', Integer(WindowOpen));
  367.   end;
  368. end;
  369.  
  370. { File system properties }
  371.  
  372. procedure LoadFileSysProp;
  373. begin
  374.   with ini do begin
  375.     DefaultSort   := TSortOrder(ReadInteger('File system', 'DefaultSort', 0));
  376.     IconStrings   := ' ' + ReadString('File system', 'IconStrings', 'EXE') + ' ';
  377.     DefaultFilter := ReadString('File system ', 'DefaultFilter', '*.*');
  378.     FileHints     := ReadBool('File system ', 'FileHints', True);
  379.     HintDelay     := ReadInteger('File system ', 'HintDelay', 1000);
  380.     UseDescriptions := ReadBool('File system', 'UseDescriptions', False);
  381.     DescCaptions  := ReadBool('File system', 'DescCaptions', False);
  382.     Simul4DOS   := ReadBool('File system', 'Simul4DOS', False);
  383.  
  384.     ConfirmCopyStart  := ReadBool('Confirmation', 'CopyStart', False);
  385.     ConfirmMoveStart  := ReadBool('Confirmation', 'MoveStart', False);
  386.     ConfirmDelStart   := ReadBool('Confirmation', 'DelStart', True);
  387.     ConfirmCopyFile   := ReadBool('Confirmation', 'CopyFile', False);
  388.     ConfirmMoveFile   := ReadBool('Confirmation', 'MoveFile', False);
  389.     ConfirmDelFile    := ReadBool('Confirmation', 'DelFile', False);
  390.     ConfirmReplace    := ReadBool('Confirmation', 'Replace', True);
  391.     ConfirmProtect    := ReadBool('Confirmation', 'Protect', True);
  392.     ConfirmCopyFolder := ReadBool('Confirmation', 'CopyFolder', False);
  393.     ConfirmMoveFolder := ReadBool('Confirmation', 'MoveFolder', False);
  394.     ConfirmDelFolder  := ReadBool('Confirmation', 'DelFolder', True);
  395.     ConfirmNewAlias   := ReadBool('Confirmation', 'NewAlias', False);
  396.  
  397.     BackCopying  := ReadBool('Preferences', 'BackCopying', True);
  398.     ShowHidSys   := ReadBool('Preferences', 'ShowHidSys', False);
  399.     ShowList     := ReadBool('Preferences', 'ShowList', False);
  400.     ProgDrop     := ReadBool('Preferences', 'ProgDrop', False);
  401.     FindVersion  := ReadBool('Preferences', 'FindVersion', True);
  402.     FindDlgIcons := ReadBool('Preferences', 'FindDlgIcons', True);
  403.     RefreshFolders := ReadBool('Preferences', 'RefreshFolders', True);
  404.     AliasArrows  := ReadBool('Preferences', 'AliasArrows', True);
  405.     IgnoreCtrlD  := ReadBool('Preferences', 'IgnoreCtrlD', False);
  406.     HintDesc     := ReadBool('Preferences', 'HintDesc', HintDesc);
  407.     HintDate     := ReadBool('Preferences', 'HintDate', HintDate);
  408.     HintTime     := ReadBool('Preferences', 'HintTime', HintTime);
  409.     HintAttrib   := ReadBool('Preferences', 'HintAttrib', HintAttrib);
  410.  
  411.     InspectProg  := ReadString('Utilities', 'Inspect', '');
  412.     DefaultProg  := ReadString('Utilities', 'Default', '');
  413.     UndeleteProg := ReadString('Utilities', 'Undelete', '');
  414.     DiskProg     := ReadString('Utilities', 'Disk', '');
  415.   end;
  416.  
  417.   if BackCopying then @BackgroundProc := @FileMan.BackgroundProcess
  418.   else @BackgroundProc := nil;
  419. end;
  420.  
  421. procedure SaveFileSysProp;
  422. begin
  423.   with ini do begin
  424.     WriteInteger('File system', 'DefaultSort', Integer(DefaultSort));
  425.     WriteString('File system', 'IconStrings', IconStrings);
  426.     WriteString('File system ', 'DefaultFilter', DefaultFilter);
  427.     WriteBool('File system', 'FileHints', FileHints);
  428.     WriteInteger('File system', 'HintDelay', HintDelay);
  429.     WriteBool('File system', 'UseDescriptions', UseDescriptions);
  430.     WriteBool('File system', 'DescCaptions', DescCaptions);
  431.     WriteBool('File system', 'Simul4DOS', Simul4DOS);
  432.  
  433.     WriteBool('Confirmation', 'CopyStart', ConfirmCopyStart);
  434.     WriteBool('Confirmation', 'MoveStart', ConfirmMoveStart);
  435.     WriteBool('Confirmation', 'DelStart', ConfirmDelStart);
  436.     WriteBool('Confirmation', 'CopyFile', ConfirmCopyFile);
  437.     WriteBool('Confirmation', 'MoveFile', ConfirmMoveFile);
  438.     WriteBool('Confirmation', 'DelFile', ConfirmDelFile);
  439.     WriteBool('Confirmation', 'Replace', ConfirmReplace);
  440.     WriteBool('Confirmation', 'Protect', ConfirmProtect);
  441.     WriteBool('Confirmation', 'CopyFolder', ConfirmCopyFolder);
  442.     WriteBool('Confirmation', 'MoveFolder', ConfirmMoveFolder);
  443.     WriteBool('Confirmation', 'DelFolder', ConfirmDelFolder);
  444.     WriteBool('Confirmation', 'NewAlias', ConfirmNewAlias);
  445.  
  446.     WriteBool('Preferences', 'BackCopying', BackCopying);
  447.     WriteBool('Preferences', 'ShowHidSys', ShowHidSys);
  448.     WriteBool('Preferences', 'ShowList', ShowList);
  449.     WriteBool('Preferences', 'ProgDrop', ProgDrop);
  450.     WriteBool('Preferences', 'FindVersion', FindVersion);
  451.     WriteBool('Preferences', 'FindDlgIcons', FindDlgIcons);
  452.     WriteBool('Preferences', 'RefreshFolders', RefreshFolders);
  453.     WriteBool('Preferences', 'AliasArrows', AliasArrows);
  454.     WriteBool('Preferences', 'IgnoreCtrlD', IgnoreCtrlD);
  455.     WriteBool('Preferences', 'HintDesc', HintDesc);
  456.     WriteBool('Preferences', 'HintDate', HintDate);
  457.     WriteBool('Preferences', 'HintTime', HintTime);
  458.     WriteBool('Preferences', 'HintAttrib', HintAttrib);
  459.  
  460.     WriteString('Utilities', 'Inspect', InspectProg);
  461.     WriteString('Utilities', 'Default', DefaultProg);
  462.     WriteString('Utilities', 'Undelete', UndeleteProg);
  463.     WriteString('Utilities', 'Disk', DiskProg);
  464.   end;
  465. end;
  466.  
  467. { Start menu properties }
  468.  
  469. procedure SaveStartProp;
  470. begin
  471.   with ini do begin
  472.     WriteBool('Start menu', 'StartMenu3D', StartMenu3D);
  473.     WriteBool('Start menu', 'BoldSelect', BoldSelect);
  474.     WriteBool('Start menu', 'ShellStartup', ShellStartup);
  475.     WriteBool('Start menu', 'StartMouseUp', StartMouseUp);
  476.   end;
  477. end;
  478.  
  479. procedure LoadStartProp;
  480. begin
  481.   with ini do begin
  482.     StartMenu3D  := ReadBool('Start menu', 'StartMenu3D', True);
  483.     BoldSelect := ReadBool('Start menu', 'BoldSelect', True);
  484.     ShellStartup := ReadBool('Start menu', 'ShellStartup', False);
  485.     StartMouseUp := ReadBool('Start menu', 'StartMouseUp', True);
  486.     StartFile := ReadString('Start menu', 'Filename',
  487.       ApplicationPath + 'start.ini');
  488.   end;
  489. end;
  490.  
  491. { System properties }
  492.  
  493. procedure LoadSystemProp;
  494. var
  495.   c: TCalColor;
  496. begin
  497.   with ini do begin
  498.     SysCaption := ReadString('System', 'Caption', 'System');
  499.     ShowSplash := ReadBool('Preferences', 'ShowSplash', True);
  500.     RestoreSys := ReadBool('Preferences', 'RestoreSys', False);
  501.     SysWinQuit := ReadBool('Preferences', 'SysWinQuit', True);
  502.     QueryQuit := ReadBool('Preferences', 'QueryQuit', True);
  503.     MsgDialogSounds := ReadBool('Preferences', 'MsgDialogSounds', True);
  504.     LoadTaskbar := ReadBool('Preferences', 'LoadTaskbar', True);
  505.     TrackThumb := ReadBool('Preferences', 'TrackThumb', False);
  506.     KeyBreak := ReadBool('Preferences', 'KeyBreak', False);
  507.  
  508.     for c := Low(TCalColor) to High(TCalColor) do
  509.       Colors[c] := ReadColor(c);
  510.  
  511.     ReplaceBitmapColors(ShortArrow, clBlack, Colors[ccShortArrow]);
  512.     ReplaceBitmapColors(AliasArrow, clBlack, Colors[ccAliasArrow]);
  513.     ReplaceBitmapColors(SizeBox, clSilver, Colors[ccWinFrame]);
  514.  
  515.     BrowseGrid.X := ReadInteger('Display', 'BrowseGridX', 75);
  516.     BrowseGrid.Y := ReadInteger('Display', 'BrowseGridY', 60);
  517.     LineHeight := ReadInteger('Display', 'LineHeight', 16);
  518.   end;
  519. end;
  520.  
  521. procedure SaveSystemProp;
  522. var
  523.   c: TCalColor;
  524. begin
  525.   with ini do begin
  526.     WriteString('System', 'Caption', SysCaption);
  527.     WriteBool('Preferences', 'ShowSplash', ShowSplash);
  528.     WriteBool('Preferences', 'RestoreSys', RestoreSys);
  529.     WriteBool('Preferences', 'SysWinQuit', SysWinQuit);
  530.     WriteBool('Preferences', 'QueryQuit', QueryQuit);
  531.     WriteBool('Preferences', 'MsgDialogSounds', MsgDialogSounds);
  532.     WriteBool('Preferences', 'LoadTaskbar', LoadTaskbar);
  533.     WriteBool('Preferences', 'TrackThumb', TrackThumb);
  534.     WriteBool('Preferences', 'KeyBreak', KeyBreak);
  535.  
  536.     for c := Low(TCalColor) to High(TCalColor) do
  537.       WriteString('Colors', ColorNames[c], ColorToString(Colors[c]));;
  538.  
  539.     WriteInteger('Display', 'BrowseGridX', BrowseGrid.X);
  540.     WriteInteger('Display', 'BrowseGridY', BrowseGrid.Y );
  541.     WriteInteger('Display', 'LineHeight', LineHeight);
  542.   end;
  543. end;
  544.  
  545. { Taskbar properties }
  546.  
  547. procedure LoadTaskProp;
  548. begin
  549.   with ini do begin
  550.     StayVisible := ReadBool('Taskbar', 'StayVisible', True);
  551.     Highlight   := ReadBool('Taskbar', 'Highlight', True);
  552.     ShrinkMax   := ReadBool('Taskbar', 'ShrinkMax', True);
  553.     Clock24     := ReadBool('Taskbar', 'Clock24', True);
  554.     PopupRes    := ReadBool('Taskbar', 'PopupRes', True);
  555.     PopupDate   := ReadBool('Taskbar', 'PopupDate', True);
  556.     Animate     := ReadBool('Taskbar', 'Animate', True);
  557.     ButtonHints := ReadBool('Taskbar', 'ButtonHints', True);
  558.     ArrangeMin  := ReadBool('Taskbar', 'ArrangeMin', True);
  559.     HideMinApps := ReadBool('Taskbar', 'MideMinApps', True);
  560.     IconWindowTask := ReadBool('Taskbar', 'IconWindowTask', True);
  561.     ExplorerTask := ReadBool('Taskbar', 'ExplorerTask', True);
  562.     CalIcons := ReadBool('Taskbar', 'CalIcons', True);
  563.     FullFolderPath := ReadBool('Taskbar', 'FullFolderPath', False);
  564.     DocNameFirst := ReadBool('Taskbar', 'DocNameFirst', True);
  565.     DocNameLower := ReadBool('Taskbar', 'DocNameLower', True);
  566.     MinAppHeight := ReadInteger('Taskbar', 'MinAppHeight', 60);
  567.   end;
  568. end;
  569.  
  570.  
  571. procedure SaveTaskProp;
  572. begin
  573.   with ini do begin
  574.     WriteBool('Taskbar', 'StayVisible', StayVisible);
  575.     WriteBool('Taskbar', 'Highlight', Highlight);
  576.     WriteBool('Taskbar', 'ShrinkMax', ShrinkMax);
  577.     WriteBool('Taskbar', 'Clock24', Clock24);
  578.     WriteBool('Taskbar', 'PopupRes', PopupRes);
  579.     WriteBool('Taskbar', 'PopupDate', PopupDate);
  580.     WriteBool('Taskbar', 'Animate', Animate);
  581.     WriteBool('Taskbar', 'ButtonHints', ButtonHints);
  582.     WriteBool('Taskbar', 'ArrangeMin', ArrangeMin);
  583.     WriteBool('Taskbar', 'MideMinApps', HideMinApps);
  584.     WriteBool('Taskbar', 'IconWindowTask', IconWindowTask);
  585.     WriteBool('Taskbar', 'ExplorerTask', ExplorerTask);
  586.     WriteBool('Taskbar', 'FullFolderPath', FullFolderPath);
  587.     WriteBool('Taskbar', 'CalIcons', CalIcons);
  588.     WriteBool('Taskbar', 'DocNameFirst', DocNameFirst);
  589.     WriteBool('Taskbar', 'DocNameLower', DocNameLower);
  590.   end;
  591. end;
  592.  
  593.  
  594. procedure AnnounceSettingsChanged(changes: TSettingChanges);
  595. var
  596.   i: Integer;
  597. begin
  598.   if scINIFile in changes then LoadSettings;
  599.  
  600.   { Notify taskbar of updates }
  601.   if [scINIFile, scTaskbar] * changes <> [] then
  602.     if TaskbarWindow > 0 then
  603.       PostMessage(TaskBarWnd, WM_CALMIRA, CM_TASKCONFIG, 0);
  604.  
  605.   if scDisplay in changes then begin
  606.     ShortArrow.Reload;
  607.     AliasArrow.Reload;
  608.     SizeBox.Reload;
  609.     ReplaceBitmapColors(ShortArrow, clBlack, Colors[ccShortArrow]);
  610.     ReplaceBitmapColors(AliasArrow, clBlack, Colors[ccAliasArrow]);
  611.     ReplaceBitmapColors(SizeBox, clSilver, Colors[ccWinFrame]);
  612.   end;
  613.  
  614.   if scFileSystem in changes then
  615.     if BackCopying then @BackgroundProc := @FileMan.BackgroundProcess
  616.     else @BackgroundProc := nil;
  617.  
  618.   StartMenu.Configure;
  619.  
  620.   with Screen do
  621.     for i := 0 to FormCount-1 do
  622.       PostMessage(Forms[i].Handle, WM_SETTINGSCHANGED, Word(Changes), 0);
  623. end;
  624.  
  625.  
  626.  
  627. procedure InitSettings;
  628. begin
  629.   ini := TProfile.Create(ApplicationPath + 'CALMIRA.INI');
  630.   Sounds := TStringList.Create;
  631.   KeyMaps := TStringList.Create;
  632.   WindowPos := TStringList.Create;
  633.   DriveNames := TStringList.Create;
  634.   GlobalFont := TFont.Create;
  635. end;
  636.  
  637.  
  638. procedure DoneSettings; far;
  639. begin
  640.   Sounds.Free;
  641.   KeyMaps.Free;
  642.   WindowPos.Free;
  643.   DriveNames.Free;
  644.   ini.Free;
  645.   GlobalFont.Free;
  646. end;
  647.  
  648.  
  649. initialization
  650.   InitSettings;
  651.   AddExitProc(DoneSettings);
  652. end.
  653.