home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / SETTINGS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  28.9 KB  |  775 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 2.1                                                    }
  5. {    Copyright (C) 1997-1998 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.   TDisplayMode = (dmLargeIcons, dmSmallIcons, dmList);
  56.  
  57.   { trash management }
  58.   TBinAction  = (baLeave, baDelete, baEmpty, baCollect);
  59.  
  60.   { application colour palette }
  61.   TCalColor = (ccWinFrame, ccIconBack, ccIconSel, ccShortArrow,
  62.     ccAliasArrow, ccPercent, ccPercentBack, ccTaskbar, ccStartHighlight);
  63.  
  64.   TSettingChanges = set of (scSystem, scFileSystem, scDesktop,
  65.     scStartMenu, scBin, scTaskbar, scDisplay, scINIFile, sc4DOS, scDevices);
  66.  
  67.   TLayout = record
  68.     Lower: Integer;
  69.     Upper: Integer;
  70.     Size : TPoint;
  71.   end;
  72.  
  73.   TFileDetail = (fdSize, fdDate, fdTime, fdAttr, fdDesc);
  74.   TFileDetails = set of TFileDetail;
  75.  
  76.  
  77. const
  78.   ColorNames : array[TCalColor] of string[15] =
  79.   ('Window frames', 'Icon background', 'Icon selection', 'Shortcut arrows',
  80.    'Alias arrows', 'Percent bar', 'Percent back', 'Taskbar', 'Start highlight');
  81.  
  82.   DefaultColors : array[TCalColor] of TColor =
  83.     (clSilver, clWindow, clSilver, clBlack, clBlack, clBlue,
  84.      clSilver, clSilver, clNavy);
  85.  
  86.   Programs      : string[79] = ' com exe bat pif ';
  87.  
  88.   AllDetails    : TFileDetails = [fdSize, fdDate, fdTime, fdAttr, fdDesc];
  89.  
  90. var
  91.   { System properties }
  92.   ComputerCaption   : TCaption;
  93.   ShowSplash   : Boolean;
  94.   RestoreSys   : Boolean;   { restore Computer window after loading }
  95.   SysWinQuit   : Boolean;   { close Computer window to quit program }
  96.   QueryQuit    : Boolean;
  97.   TrackThumb   : Boolean;   { scroll window contents when dragging scrollbar }
  98.   GlobalHotkeys  : Boolean;
  99.   ShowBrowseBtns : Boolean;
  100.   ShowDailyTips  : Boolean;
  101.   CompIconStart  : Boolean;
  102.  
  103.   EnableWinScripts  : Boolean;  { these are available in the dialog }
  104.   EnableDosScripts  : Boolean;
  105.  
  106.   DosTimerInterval  : Integer;  { these must be manually edited }
  107.   DosScriptFilename : TFilename;
  108.   WinScriptExtension : string[4];
  109.  
  110.  
  111.   { File system properties }
  112.  
  113.   DefaultSort   : TSortOrder;
  114.   DefaultDisplay: TDisplayMode;
  115.   DefaultFilter : string[79];
  116.   IconStrings   : TFilename;    { extensions to search for icons in }
  117.   ListKBDecimals : Integer;
  118.   AliasExtension : string[4];
  119.   AliasExtensionUpper : string[4];
  120.  
  121.   FileHints    : Boolean;
  122.   HintDelay    : Integer;
  123.  
  124.   UseDescriptions : Boolean;
  125.   DescCaptions    : Boolean;    { show descriptions as captions }
  126.   Simul4DOS       : Boolean;    { load description file before changing }
  127.  
  128.   ConfirmCopyStart : Boolean;
  129.   ConfirmMoveStart : Boolean;
  130.   ConfirmDelStart  : Boolean;
  131.   ConfirmCopyFile  : Boolean;
  132.   ConfirmMoveFile  : Boolean;
  133.   ConfirmDelFile   : Boolean;
  134.   ConfirmReplace   : Boolean;
  135.   ConfirmProtect   : Boolean;
  136.   ConfirmCopyFolder : Boolean;
  137.   ConfirmMoveFolder : Boolean;
  138.   ConfirmDelFolder  : Boolean;
  139.   ConfirmNewAlias   : Boolean;
  140.  
  141.   ShortWinCaptions : Boolean;
  142.   ShowHidSys    : Boolean;  { show hidden/system files }
  143.   ProgDrop      : Boolean;  { allow drop into programs }
  144.   FindDlgIcons  : Boolean;  { icons in find dialog list }
  145.   AliasArrows   : Boolean;
  146.   DefDragCopy   : Boolean;
  147.   MiniIcons     : Boolean;
  148.   UpcaseFirstChar : Boolean;
  149.   NoRegExtensions : Boolean;
  150.  
  151.   HintDesc      : Boolean;
  152.   HintDate      : Boolean;
  153.   HintTime      : Boolean;
  154.   HintAttrib    : Boolean;
  155.   HintBytes      : Boolean;
  156.  
  157.   DefaultColumns   : TFileDetails;
  158.  
  159.   InspectProg  : TFilename;
  160.   DefaultProg  : TFilename;
  161.   UndeleteProg : TFilename;
  162.   DiskProg     : TFilename;
  163.  
  164.   { Desktop properties }
  165.  
  166.   WindowOpen    : TWindowOpen;   { new window placement }
  167.   SingleStatus  : Boolean;
  168.   SaveWindows   : Boolean;       { save windows between sessions }
  169.   ShortArrows   : Boolean;
  170.   AnimCursor    : Boolean;
  171.   ShowDeskMenu  : Boolean;
  172.   TreeCloseFilepane  : Boolean;  { closes associated icon window with explorer }
  173.   ExploreLastFolder  : Boolean;
  174.   ConfirmDelShort : Boolean;
  175.   StickyShorts : Boolean;     { move only when caption is dragged }
  176.   OneClickShorts : Boolean;   { activate after single click }
  177.   BrowseSame : Boolean;       { browse folders in same window }
  178.   RightClose : Boolean;       { right click on min/max box to close }
  179.   RButtonUpClose : Boolean;
  180.   RunAutoClose : Boolean;     { closes run dialog after execution }
  181.   DesktopParent : Boolean;
  182.   FilePaneCols : Integer;
  183.  
  184.   { Taskbar properties }
  185.  
  186.   DisableTaskbar: Boolean;
  187.   StayVisible   : Boolean;
  188.   ShrinkMax     : Boolean;    { constrain maximised windows above the bar }
  189.   Clock24       : Boolean;
  190.   PopupRes      : Boolean;
  191.   PopupDate     : Boolean;
  192.   Animate       : Boolean;
  193.   ButtonHints   : Boolean;
  194.   ArrangeMin    : Boolean;    { move minimised windows upwards }
  195.   HideMinApps   : Boolean;
  196.   IconWindowTask : Boolean;
  197.   ExplorerTask   : Boolean;
  198.   FullFolderPath : Boolean;
  199.   DocNameFirst   : Boolean;
  200.   DocNameLower   : Boolean;
  201.  
  202.   { Bin properties }
  203.  
  204.   BinCaption   : TCaption;
  205.   BinAction    : TBinAction;
  206.   BinCapacity  : Integer;
  207.   BinIcons     : Boolean;
  208.   DeleteToBin  : Boolean;
  209.  
  210.   { Start menu properties }
  211.  
  212.   StartMenu3D  : Boolean;
  213.   ShellStartup : Boolean;
  214.   ShellDDE     : Boolean;
  215.   BoldSelect   : Boolean;
  216.   StartMouseUp : Boolean;
  217.   LargeRootmenu : Boolean;
  218.   ColouredBar  : Boolean;
  219.   StartFile    : TFilename;  { normally "START.INI" }
  220.  
  221.   { Internal }
  222.  
  223.   IsShell : Boolean;             { true when this program is the shell }
  224.   DoubleClickSpeed : Integer;    { read from WIN.INI }
  225.   Sounds  : TStringList;         { sound effects WAV file list }
  226.   KeyMaps : TStringList;         { keyboard shortcuts }
  227.   WindowPos : TStringList;       { window positions }
  228.   GlobalCaptions : TStringList;
  229.   ini     : TProfile;           { main ini file }
  230.   FirstRun: Boolean;            { first time Calmira is run }
  231.   LoadFromWinDir : Boolean;
  232.   NormalHintPause : Integer;
  233.  
  234.   Colors  : array[TCalColor] of TColor;
  235.  
  236.   DeskGrid        : TPoint;   { desktop grid for lining up icons }
  237.   BrowseGrid      : TPoint;   { icon window grid size }
  238.   LineHeight      : Integer;  { height of lists and outlines }
  239.   MinAppHeight    : Integer;  { height of icons above the taskbar }
  240.   DescWidth       : Integer;  { width of descriptions in icon windows }
  241.   ColumnPadding   : Integer;
  242.  
  243.   GlobalFont : TFont;
  244.  
  245.   Layouts : array[0..15] of TLayout;
  246.   NumLayouts : Integer;
  247.   FileWritePath : TFilename;
  248.  
  249. procedure LoadSettings;
  250. procedure AnnounceSettingsChanged(changes : TSettingChanges);
  251. procedure ModulesLoaded;
  252.  
  253. procedure LoadSystemProp;
  254. procedure SaveSystemProp;
  255. procedure LoadFileSysProp;
  256. procedure SaveFileSysProp;
  257. procedure LoadBinProp;
  258. procedure SaveBinProp;
  259. procedure LoadDeskProp;
  260. procedure SaveDeskProp;
  261. procedure LoadStartProp;
  262. procedure SaveStartProp;
  263. procedure LoadTaskProp;
  264. procedure SaveTaskProp;
  265.  
  266.  
  267. implementation
  268.  
  269. uses Directry, Strings, MiscUtil, WinProcs, Resource, CalMsgs, Menus, Task,
  270.   Start, FourDOS, Environs, Files, FileMan, IconSel, IconWin, Internet;
  271.  
  272.  
  273. procedure ReplaceBitmapColors(bitmap : TBitmap; source, dest: TColor);
  274. var i, j: Integer;
  275. begin
  276.   { changes pixels from one colour to another }
  277.   if source <> dest then
  278.     with bitmap do
  279.       for i := 0 to Width-1 do
  280.         for j := 0 to Height-1 do
  281.           if Canvas.Pixels[i, j] = source then Canvas.Pixels[i, j] := dest;
  282. end;
  283.  
  284.  
  285. function ReadColor(col: TCalColor): TColor;
  286. var s: string[31];
  287. begin
  288.   s := ini.ReadString('Colors', ColorNames[col], '');
  289.   if s = '' then Result := DefaultColors[col]
  290.   else Result := StringToColor(s);
  291. end;
  292.  
  293. procedure Patch20Ini;
  294. begin
  295.   ini.WriteString('Colour descriptions', IntToStr(Ord(ccPercentBack)),
  296.     'Progress bar background');
  297.   ini.WriteString('Colors', ColorNames[ccPercentBack], 'clBtnFace');
  298. end;
  299.  
  300. procedure LoadSettings;
  301. var
  302.   i : Integer;
  303. begin
  304.   with ini do begin
  305.     FirstRun := ReadBool('Calmira', 'FirstRun21', True);
  306.     if FirstRun then Patch20Ini;
  307.     WriteBool('Calmira', 'FirstRun21', False);
  308.  
  309.     DeskGrid.X   := ReadInteger('Desktop', 'DeskGridX', 16);
  310.     DeskGrid.Y   := ReadInteger('Desktop', 'DeskGridY', 16);
  311.     FilePaneCols := ReadInteger('Desktop', 'FilePaneCols', 4);
  312.  
  313.     ReadFont('Display', GlobalFont);
  314.     NormalHintPause := ReadInteger('Calmira', 'NormalHintPause', 800);
  315.  
  316.     ReadSectionValues('Environment', Environment);
  317.     Environment.Values['CALMIRA'] := Lowercase(ExtractFileDir(ApplicationPath));
  318.     Sounds.Clear;
  319.     ReadSectionValues('Sounds', Sounds);
  320.  
  321.     GlobalCaptions.Clear;
  322.     ReadSectionValues('Drives', GlobalCaptions);
  323.     ReadSectionValues('Window captions', GlobalCaptions);
  324.  
  325.     ReadSectionValues('Window positions', WindowPos);
  326.  
  327.     Keymaps.Clear;
  328.     ReadSection('Keyboard', KeyMaps);
  329.     for i := 0 to KeyMaps.Count-1 do
  330.       KeyMaps.Objects[i] :=
  331.         TObject(TextToShortcut(ReadString('Keyboard', KeyMaps[i], '')));
  332.  
  333.     DescriptionFile := ReadString('File system', 'DescriptionFile', 'descript.ion');
  334.     DescWidth       := ReadInteger('File system', 'DescriptionWidth', -1);
  335.     ColumnPadding   := ReadInteger('File system', 'ColumnPadding', 8);
  336.  
  337.     MaxHistorySize  := ReadInteger('Calmira', 'MaxHistorySize', 24);
  338.     AliasExtension  := Lowercase(ReadString('File system', 'AliasExtension', '.als'));
  339.     AliasExtensionUpper := Uppercase(AliasExtension);
  340.  
  341.     RepaintBeforeHourglass := ReadInteger('Display', 'RepaintBeforeHourglass', 2);
  342.     URLPrefixes := ini.ReadString('Internet', 'URLPrefixes', URLPrefixes);
  343.   end;
  344.  
  345.   LoadSystemProp;
  346.   LoadDeskProp;
  347.   LoadFileSysProp;
  348.   LoadTaskProp;
  349.   LoadBinProp;
  350.   LoadStartProp;
  351. end;
  352.  
  353.  
  354. { Bin properties }
  355.  
  356. procedure LoadBinProp;
  357. begin
  358.   with ini do begin
  359.     BinCaption  := ReadString('Bin', 'Caption', 'Bin');
  360.     BinAction   := TBinAction(ReadInteger('Bin', 'Action', 0));
  361.     BinCapacity := ReadInteger('Bin', 'Capacity', 8);
  362.     BinIcons    := ReadBool('Bin', 'Icons', False);
  363.     DeleteToBin := ReadBool('Bin', 'DeleteToBin', False);
  364.   end;
  365. end;
  366.  
  367. procedure SaveBinProp;
  368. begin
  369.   with ini do begin
  370.     WriteString('Bin', 'Caption', BinCaption);
  371.     WriteInteger('Bin', 'Action', Integer(BinAction));
  372.     WriteInteger('Bin', 'Capacity', BinCapacity);
  373.     WriteBool('Bin', 'Icons', BinIcons);
  374.     WriteBool('Bin', 'DeleteToBin', DeleteToBin);
  375.   end;
  376. end;
  377.  
  378.  
  379. { Desktop properties }
  380.  
  381. procedure LoadDeskProp;
  382. var
  383.   strings : TStringList;
  384.   i : Integer;
  385. begin
  386.   with ini do begin
  387.     SingleStatus      := ReadBool('Preferences', 'SingleStatus', False);
  388.     SaveWindows       := ReadBool('Preferences', 'SaveWindows', False);
  389.     ShortArrows       := ReadBool('Preferences', 'ShortArrows', True);
  390.     AnimCursor        := ReadBool('Preferences', 'AnimCursor', True);
  391.     ShowDeskMenu      := ReadBool('Preferences', 'ShowDeskMenu', True);
  392.     TreeCloseFilePane := ReadBool('Preferences', 'TreeCloseFilePane', True);
  393.     ExploreLastFolder := ReadBool('Preferences', 'ExploreLastFolder', False);
  394.     StickyShorts      := ReadBool('Preferences', 'StickyShorts', True);
  395.     OneClickShorts    := ReadBool('Preferences', 'OneClickShorts', False);
  396.     BrowseSame        := ReadBool('Preferences', 'BrowseSame', False);
  397.     RightClose        := ReadBool('Preferences', 'RightClose', True);
  398.     RButtonUpClose    := ReadBool('Preferences', 'RButtonUpClose', False);
  399.     ConfirmDelShort   := ReadBool('Confirmation', 'DelShort', True);
  400.     RunAutoClose      := ReadBool('Preferences', 'RunAutoClose', True);
  401.     DesktopParent     := ReadBool('Preferences', 'DesktopParent', False);
  402.     WindowOpen        := TWindowOpen(ReadInteger('Preferences', 'WindowOpen', 0));
  403.   end;
  404.  
  405.   strings := TStringList.Create;
  406.   try
  407.     ini.ReadSectionValues('Layouts', strings);
  408.     NumLayouts := Min(strings.Count, High(Layouts)+1);
  409.     for i := 0 to NumLayouts-1 do
  410.       with Layouts[i] do
  411.         Unformat(strings[i], '%d..%d=%d*%d', [@Lower, @Upper, @Size.X, @Size.Y]);
  412.   finally
  413.     strings.Free;
  414.   end;
  415. end;
  416.  
  417.  
  418. procedure SaveDeskProp;
  419. begin
  420.   with ini do begin
  421.     WriteBool('Preferences', 'SingleStatus', SingleStatus);
  422.     WriteBool('Preferences', 'SaveWindows', SaveWindows);
  423.     WriteBool('Preferences', 'ShortArrows', ShortArrows);
  424.     WriteBool('Preferences', 'AnimCursor', AnimCursor);
  425.     WriteBool('Preferences', 'ShowDeskMenu', ShowDeskMenu);
  426.     WriteBool('Preferences', 'TreeCloseFilePane', TreeCloseFilePane);
  427.     WriteBool('Preferences', 'ExploreLastFolder', ExploreLastFolder);
  428.     WriteBool('Confirmation', 'DelShort', ConfirmDelShort);
  429.     WriteBool('Preferences', 'StickyShorts', StickyShorts);
  430.     WriteBool('Preferences', 'OneClickShorts', OneClickShorts);
  431.     WriteBool('Preferences', 'BrowseSame', BrowseSame);
  432.     WriteBool('Preferences', 'RightClose', RightClose);
  433.     WriteBool('Preferences', 'RunAutoClose', RunAutoClose);
  434.     WriteBool('Preferences', 'DesktopParent', DesktopParent);
  435.     WriteBool('Preferences', 'RButtonUpClose', RButtonUpClose);
  436.     WriteInteger('Preferences', 'WindowOpen', Integer(WindowOpen));
  437.   end;
  438. end;
  439.  
  440. { File system properties }
  441.  
  442. procedure LoadFileSysProp;
  443. var b: Byte;
  444. begin
  445.   with ini do begin
  446.     DefaultDisplay:= TDisplayMode(ReadInteger('File system', 'DefaultDisplay', 0));
  447.     DefaultSort     := TSortOrder(ReadInteger('File system', 'DefaultSort', 0));
  448.     IconStrings     := ' ' + ReadString('File system', 'IconStrings', 'exe') + ' ';
  449.     DefaultFilter   := ReadString('File system ', 'DefaultFilter', '*.*');
  450.     FileHints       := ReadBool('File system ', 'FileHints', True);
  451.     HintDelay       := ReadInteger('File system ', 'HintDelay', 1300);
  452.     UseDescriptions := ReadBool('File system', 'UseDescriptions', True);
  453.     DescCaptions    := ReadBool('File system', 'DescCaptions', True);
  454.     Simul4DOS       := ReadBool('File system', 'Simul4DOS', False);
  455.  
  456.     ListKBDecimals := ReadInteger('File system', 'ListKBDecimals', 0);
  457.  
  458.     ConfirmCopyStart  := ReadBool('Confirmation', 'CopyStart', False);
  459.     ConfirmMoveStart  := ReadBool('Confirmation', 'MoveStart', False);
  460.     ConfirmDelStart   := ReadBool('Confirmation', 'DelStart', True);
  461.     ConfirmCopyFile   := ReadBool('Confirmation', 'CopyFile', False);
  462.     ConfirmMoveFile   := ReadBool('Confirmation', 'MoveFile', False);
  463.     ConfirmDelFile    := ReadBool('Confirmation', 'DelFile', False);
  464.     ConfirmReplace    := ReadBool('Confirmation', 'Replace', True);
  465.     ConfirmProtect    := ReadBool('Confirmation', 'Protect', True);
  466.     ConfirmCopyFolder := ReadBool('Confirmation', 'CopyFolder', False);
  467.     ConfirmMoveFolder := ReadBool('Confirmation', 'MoveFolder', False);
  468.     ConfirmDelFolder  := ReadBool('Confirmation', 'DelFolder', True);
  469.     ConfirmNewAlias   := ReadBool('Confirmation', 'NewAlias', False);
  470.  
  471.     ShortWinCaptions := ReadBool('Preferences', 'ShortWinCaptions', True);
  472.     ShowHidSys       := ReadBool('Preferences', 'ShowHidSys', False);
  473.     ProgDrop         := ReadBool('Preferences', 'ProgDrop', False);
  474.     FindDlgIcons     := ReadBool('Preferences', 'FindDlgIcons', True);
  475.     AliasArrows      := ReadBool('Preferences', 'AliasArrows', True);
  476.     DefDragCopy      := ReadBool('Preferences', 'DefDragCopy', True);
  477.     MiniIcons        := ReadBool('Preferences', 'MiniIcons', True);
  478.     UpcaseFirstChar  := ReadBool('Preferences', 'UpcaseFirstChar', True);
  479.     NoRegExtensions  := ReadBool('Preferences', 'NoRegExtensions', True);
  480.  
  481.     HintDesc     := ReadBool('Preferences', 'HintDesc',   HintDesc);
  482.     HintDate     := ReadBool('Preferences', 'HintDate',   HintDate);
  483.     HintTime     := ReadBool('Preferences', 'HintTime',   HintTime);
  484.     HintAttrib   := ReadBool('Preferences', 'HintAttrib', HintAttrib);
  485.     HintBytes     := ReadBool('Preferences', 'HintBytes', HintBytes);
  486.  
  487.     b := ReadInteger('Preferences', 'DefaultColumns', Byte(AllDetails));
  488.     DefaultColumns  := TFileDetails(b);
  489.  
  490.     InspectProg  := ReadString('Utilities', 'Inspect', '%windir%\notepad.exe');
  491.     DefaultProg  := ReadString('Utilities', 'Default', '%windir%\notepad.exe');
  492.     UndeleteProg := ReadString('Utilities', 'Undelete', '');
  493.     DiskProg     := ReadString('Utilities', 'Disk', '');
  494.   end;
  495.  
  496.   @BackgroundProc := @FileMan.BackgroundProcess
  497. end;
  498.  
  499. procedure SaveFileSysProp;
  500. begin
  501.   with ini do begin
  502.     WriteInteger('File system', 'DefaultDisplay', Integer(DefaultDisplay));
  503.     WriteInteger('File system', 'DefaultSort', Integer(DefaultSort));
  504.     WriteString('File system', 'IconStrings', IconStrings);
  505.     WriteString('File system ', 'DefaultFilter', DefaultFilter);
  506.     WriteBool('File system', 'FileHints', FileHints);
  507.     WriteInteger('File system', 'HintDelay', HintDelay);
  508.     WriteBool('File system', 'UseDescriptions', UseDescriptions);
  509.     WriteBool('File system', 'DescCaptions', DescCaptions);
  510.     WriteBool('File system', 'Simul4DOS', Simul4DOS);
  511.  
  512.     WriteBool('Confirmation', 'CopyStart', ConfirmCopyStart);
  513.     WriteBool('Confirmation', 'MoveStart', ConfirmMoveStart);
  514.     WriteBool('Confirmation', 'DelStart', ConfirmDelStart);
  515.     WriteBool('Confirmation', 'CopyFile', ConfirmCopyFile);
  516.     WriteBool('Confirmation', 'MoveFile', ConfirmMoveFile);
  517.     WriteBool('Confirmation', 'DelFile', ConfirmDelFile);
  518.     WriteBool('Confirmation', 'Replace', ConfirmReplace);
  519.     WriteBool('Confirmation', 'Protect', ConfirmProtect);
  520.     WriteBool('Confirmation', 'CopyFolder', ConfirmCopyFolder);
  521.     WriteBool('Confirmation', 'MoveFolder', ConfirmMoveFolder);
  522.     WriteBool('Confirmation', 'DelFolder', ConfirmDelFolder);
  523.     WriteBool('Confirmation', 'NewAlias', ConfirmNewAlias);
  524.  
  525.     WriteBool('Preferences', 'ShortWinCaptions', ShortWinCaptions);
  526.     WriteBool('Preferences', 'ShowHidSys', ShowHidSys);
  527.     WriteBool('Preferences', 'ProgDrop', ProgDrop);
  528.     WriteBool('Preferences', 'FindDlgIcons', FindDlgIcons);
  529.     WriteBool('Preferences', 'AliasArrows', AliasArrows);
  530.     WriteBool('Preferences', 'DefDragCopy', DefDragCopy);
  531.     WriteBool('Preferences', 'MiniIcons', MiniIcons);
  532.     WriteBool('Preferences', 'UpcaseFirstChar', UpcaseFirstChar);
  533.     WriteBool('Preferences', 'NoRegExtensions', NoRegExtensions);
  534.  
  535.     WriteBool('Preferences', 'HintDesc', HintDesc);
  536.     WriteBool('Preferences', 'HintDate', HintDate);
  537.     WriteBool('Preferences', 'HintTime', HintTime);
  538.     WriteBool('Preferences', 'HintAttrib', HintAttrib);
  539.     WriteBool('Preferences', 'HintBytes', HintBytes);
  540.     WriteInteger('Preferences', 'DefaultColumns', Byte(DefaultColumns));
  541.  
  542.     WriteString('Utilities', 'Inspect', InspectProg);
  543.     WriteString('Utilities', 'Default', DefaultProg);
  544.     WriteString('Utilities', 'Undelete', UndeleteProg);
  545.     WriteString('Utilities', 'Disk', DiskProg);
  546.   end;
  547. end;
  548.  
  549. { Start menu properties }
  550.  
  551. procedure SaveStartProp;
  552. begin
  553.   with ini do begin
  554.     WriteBool('Start menu', 'StartMenu3D', StartMenu3D);
  555.     WriteBool('Start menu', 'BoldSelect', BoldSelect);
  556.     WriteBool('Start menu', 'ShellStartup', ShellStartup);
  557.     WriteBool('Start menu', 'ShellDDE', ShellDDE);
  558.     WriteBool('Start menu', 'StartMouseUp', StartMouseUp);
  559.     WriteBool('Start menu', 'LargeRootMenu', LargeRootMenu);
  560.     WriteBool('Start menu', 'ColouredBar', ColouredBar);
  561.   end;
  562. end;
  563.  
  564. procedure LoadStartProp;
  565. begin
  566.   with ini do begin
  567.     StartMenu3D  := ReadBool('Start menu', 'StartMenu3D', True);
  568.     BoldSelect   := ReadBool('Start menu', 'BoldSelect', True);
  569.     ShellStartup := ReadBool('Start menu', 'ShellStartup', False);
  570.     ShellDDE     := ReadBool('Start menu', 'ShellDDE', False);
  571.     StartMouseUp := ReadBool('Start menu', 'StartMouseUp', False);
  572.     ColouredBar := ReadBool('Start menu', 'ColouredBar', True);
  573.     LargeRootMenu := ReadBool('Start menu', 'LargeRootMenu', True);
  574.   end;
  575. end;
  576.  
  577. { System properties }
  578.  
  579. procedure LoadSystemProp;
  580. var
  581.   c: TCalColor;
  582. begin
  583.   with ini do begin
  584.     ComputerCaption := ReadString('Computer', 'Caption', 'Computer');
  585.     ShowSplash := ReadBool('Preferences', 'ShowSplash', True);
  586.     RestoreSys := ReadBool('Preferences', 'RestoreSys', False);
  587.     SysWinQuit := ReadBool('Preferences', 'SysWinQuit', True);
  588.     QueryQuit := ReadBool('Preferences', 'QueryQuit', True);
  589.     MsgDialogSounds := ReadBool('Preferences', 'MsgDialogSounds', True);
  590.     TrackThumb := ReadBool('Preferences', 'TrackThumb', True);
  591.     GlobalHotkeys := ReadBool('Preferences', 'GlobalHotKeys', True);
  592.     ShowBrowseBtns := ReadBool('Preferences', 'ShowBrowseBtns', False);
  593.     NotifyNoIcons := ReadBool('Preferences', 'NotifyNoIcons', True);
  594.     ShowDailyTips := ReadBool('Preferences', 'ShowDailyTips', True);
  595.     CompIconStart := ReadBool('Preferences', 'CompIconStart', False);
  596.     DarkIconStretch := ReadBool('Preferences', 'DarkIconStretch', True);
  597.  
  598.     EnableDosScripts := ReadBool('Scripts', 'EnableDosScripts', True);
  599.     EnableWinScripts := ReadBool('Scripts', 'EnableWinScripts', True);
  600.  
  601.     { loaded only }
  602.     DosTimerInterval := ReadInteger('Scripts', 'DosTimerInterval', 3000);
  603.     DosScriptFilename := ReadString('Scripts', 'DosScriptFilename', 'c:\calmira.run');
  604.     WinScriptExtension := ReadString('Scripts', 'WinScriptExtension', '.run');
  605.  
  606.     for c := Low(TCalColor) to High(TCalColor) do
  607.       Colors[c] := ReadColor(c);
  608.  
  609.     ReplaceBitmapColors(ShortArrow, clBlack, Colors[ccShortArrow]);
  610.     ReplaceBitmapColors(AliasArrow, clBlack, Colors[ccAliasArrow]);
  611.     ReplaceBitmapColors(SizeBox, clSilver, Colors[ccWinFrame]);
  612.  
  613.     BrowseGrid.X := ReadInteger('Display', 'BrowseGridX', 70);
  614.     BrowseGrid.Y := ReadInteger('Display', 'BrowseGridY', 60);
  615.     LineHeight   := ReadInteger('Display', 'LineHeight', 17);
  616.   end;
  617. end;
  618.  
  619. procedure SaveSystemProp;
  620. var
  621.   c: TCalColor;
  622. begin
  623.   with ini do begin
  624.     WriteString('Computer', 'Caption', ComputerCaption);
  625.     WriteBool('Preferences', 'ShowSplash', ShowSplash);
  626.     WriteBool('Preferences', 'RestoreSys', RestoreSys);
  627.     WriteBool('Preferences', 'SysWinQuit', SysWinQuit);
  628.     WriteBool('Preferences', 'QueryQuit', QueryQuit);
  629.     WriteBool('Preferences', 'MsgDialogSounds', MsgDialogSounds);
  630.     WriteBool('Preferences', 'TrackThumb', TrackThumb);
  631.     WriteBool('Preferences', 'GlobalHotKeys', GlobalHotKeys);
  632.     WriteBool('Preferences', 'ShowBrowseBtns', ShowBrowseBtns);
  633.     WriteBool('Preferences', 'NotifyNoIcons', NotifyNoIcons);
  634.     WriteBool('Preferences', 'ShowDailyTips', ShowDailyTips);
  635.     WriteBool('Preferences', 'CompIconStart', CompIconStart);
  636.     WriteBool('Preferences', 'DarkIconStretch', DarkIconStretch);
  637.  
  638.     WriteBool('Scripts', 'EnableDosScripts', EnableDosScripts);
  639.     WriteBool('Scripts', 'EnableWinScripts', EnableWinScripts);
  640.  
  641.     for c := Low(TCalColor) to High(TCalColor) do
  642.       WriteString('Colors', ColorNames[c], ColorToString(Colors[c]));;
  643.  
  644.     WriteInteger('Display', 'BrowseGridX', BrowseGrid.X);
  645.     WriteInteger('Display', 'BrowseGridY', BrowseGrid.Y );
  646.     WriteInteger('Display', 'LineHeight', LineHeight);
  647.   end;
  648. end;
  649.  
  650. { Taskbar properties }
  651.  
  652. procedure LoadTaskProp;
  653. begin
  654.   with ini do begin
  655.     DisableTaskbar := ReadBool('Taskbar', 'Disable', False);
  656.     StayVisible := ReadBool('Taskbar', 'StayVisible', True);
  657.     ShrinkMax   := ReadBool('Taskbar', 'ShrinkMax', True);
  658.     Clock24     := ReadBool('Taskbar', 'Clock24', False);
  659.     PopupRes    := ReadBool('Taskbar', 'PopupRes', True);
  660.     PopupDate   := ReadBool('Taskbar', 'PopupDate', True);
  661.     Animate     := ReadBool('Taskbar', 'Animate', True);
  662.     ButtonHints := ReadBool('Taskbar', 'ButtonHints', True);
  663.     ArrangeMin  := ReadBool('Taskbar', 'ArrangeMin', True);
  664.     HideMinApps := ReadBool('Taskbar', 'MideMinApps', True);
  665.     IconWindowTask := ReadBool('Taskbar', 'IconWindowTask', True);
  666.     ExplorerTask := ReadBool('Taskbar', 'ExplorerTask', True);
  667.     FullFolderPath := ReadBool('Taskbar', 'FullFolderPath', False);
  668.     DocNameFirst := ReadBool('Taskbar', 'DocNameFirst', True);
  669.     DocNameLower := ReadBool('Taskbar', 'DocNameLower', True);
  670.     MinAppHeight := ReadInteger('Taskbar', 'MinAppHeight', 60);
  671.   end;
  672. end;
  673.  
  674.  
  675. procedure SaveTaskProp;
  676. begin
  677.   with ini do begin
  678.     WriteBool('Taskbar', 'Disable', DisableTaskbar);
  679.     WriteBool('Taskbar', 'StayVisible', StayVisible);
  680.     WriteBool('Taskbar', 'ShrinkMax', ShrinkMax);
  681.     WriteBool('Taskbar', 'Clock24', Clock24);
  682.     WriteBool('Taskbar', 'PopupRes', PopupRes);
  683.     WriteBool('Taskbar', 'PopupDate', PopupDate);
  684.     WriteBool('Taskbar', 'Animate', Animate);
  685.     WriteBool('Taskbar', 'ButtonHints', ButtonHints);
  686.     WriteBool('Taskbar', 'ArrangeMin', ArrangeMin);
  687.     WriteBool('Taskbar', 'MideMinApps', HideMinApps);
  688.     WriteBool('Taskbar', 'IconWindowTask', IconWindowTask);
  689.     WriteBool('Taskbar', 'ExplorerTask', ExplorerTask);
  690.     WriteBool('Taskbar', 'FullFolderPath', FullFolderPath);
  691.     WriteBool('Taskbar', 'DocNameFirst', DocNameFirst);
  692.     WriteBool('Taskbar', 'DocNameLower', DocNameLower);
  693.   end;
  694. end;
  695.  
  696.  
  697. procedure AnnounceSettingsChanged(changes: TSettingChanges);
  698. var
  699.   i: Integer;
  700. begin
  701.   if scINIFile in changes then LoadSettings;
  702.  
  703.   { Notify taskbar of updates }
  704.   if [scDisplay, scINIFile, scTaskbar] * changes <> [] then
  705.     Taskbar.Configure;
  706.  
  707.   if scDisplay in changes then begin
  708.     ShortArrow.Reload;
  709.     AliasArrow.Reload;
  710.     SizeBox.Reload;
  711.     ReplaceBitmapColors(ShortArrow, clBlack, Colors[ccShortArrow]);
  712.     ReplaceBitmapColors(AliasArrow, clBlack, Colors[ccAliasArrow]);
  713.     ReplaceBitmapColors(SizeBox, clSilver, Colors[ccWinFrame]);
  714.   end;
  715.  
  716.   StartMenu.Configure;
  717.  
  718.   with Screen do
  719.     for i := 0 to FormCount-1 do
  720.       PostMessage(Forms[i].Handle, WM_SETTINGSCHANGED, Word(Changes), 0);
  721. end;
  722.  
  723.  
  724. procedure ModulesLoaded;
  725. begin
  726.   TIconWindow.CalcColWidths;
  727. end;
  728.  
  729.  
  730. procedure InitSettings;
  731. begin
  732.   Sounds := TStringList.Create;
  733.   KeyMaps := TStringList.Create;
  734.   WindowPos := TStringList.Create;
  735.   GlobalCaptions := TStringList.Create;
  736.   GlobalFont := TFont.Create;
  737.  
  738.   with TIniFile.Create('system.ini') do begin
  739.     IsShell := CompareText(ExtractFilename(
  740.       ReadString('boot', 'shell', 'progman.exe')), 'calmira.exe') = 0;
  741.     Free;
  742.   end;
  743.  
  744.   with TIniFile.Create('win.ini') do begin
  745.     programs := Format(' %s ',
  746.       [Lowercase(ReadString('windows', 'Programs', programs))]);
  747.     DoubleClickSpeed := ReadInteger('windows', 'DoubleClickSpeed', 250);
  748.     LoadFromWinDir := ReadBool('Calmira', 'LoadFromWinDir', False);
  749.     Free;
  750.   end;
  751.  
  752.   if LoadFromWinDir then FileWritePath := WinPath
  753.   else FileWritePath := ApplicationPath;
  754.  
  755.   ini := TProfile.Create(FileWritePath + 'CALMIRA.INI');
  756.   StartFile := FileWritePath + 'START.INI';
  757. end;
  758.  
  759.  
  760. procedure DoneSettings; far;
  761. begin
  762.   Sounds.Free;
  763.   KeyMaps.Free;
  764.   WindowPos.Free;
  765.   GlobalCaptions.Free;
  766.   ini.Free;
  767.   GlobalFont.Free;
  768. end;
  769.  
  770.  
  771. initialization
  772.   InitSettings;
  773.   AddExitProc(DoneSettings);
  774. end.
  775.