home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / FILTER.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  3.4 KB  |  103 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 Filter;
  24.  
  25. interface
  26.  
  27. uses
  28.   Classes, Controls, Forms, StdCtrls, Buttons, ExtCtrls, Directry, Chklist;
  29.  
  30. type
  31.   TFilterDialog = class(TForm)
  32.     OKBtn: TBitBtn;
  33.     CancelBtn: TBitBtn;
  34.     Label1: TLabel;
  35.     Label2: TLabel;
  36.     Bevel1: TBevel;
  37.     CheckList: TCheckList;
  38.     Label3: TLabel;
  39.     FilterEdit: TComboBox;
  40.     procedure FormCreate(Sender: TObject);
  41.     procedure OKBtnClick(Sender: TObject);
  42.   private
  43.     { Private declarations }
  44.   public
  45.     { Public declarations }
  46.     function Execute(Dir : TDirectory): TModalResult;
  47.   end;
  48.  
  49. {
  50. var
  51.   FilterDialog: TFilterDialog;
  52. }
  53.  
  54. implementation
  55.  
  56. {$R *.DFM}
  57.  
  58. uses SysUtils, Settings, MiscUtil, Strings;
  59.  
  60. function TFilterDialog.Execute(Dir : TDirectory): TModalResult;
  61. var
  62.   details : TFileDetails;
  63.   i: Integer;
  64.   b: array[0..4] of Boolean;
  65.   hidsys : Boolean;
  66. begin
  67.   FilterEdit.Text := Dir.Filter;
  68.   details := Dir.Columns;
  69.  
  70.   CheckList.SetData([Dir.Mask and faHidden <> 0, fdSize in details,
  71.     fdDate in details, fdTime in details, fdAttr in details, fdDesc in details]);
  72.  
  73.   Result := ShowModal;
  74.  
  75.   if Result = mrOK then begin
  76.     Dir.Filter := FilterEdit.Text;
  77.     CheckList.GetData([@hidsys, @b[0], @b[1], @b[2], @b[3], @b[4]]);
  78.     Dir.Mask := DirectoryMasks[hidsys];
  79.  
  80.     details := [];
  81.     for i := 0 to 4 do if b[i] then Include(details, TFileDetail(i));
  82.     Dir.Columns := details;
  83.   end;
  84. end;
  85.  
  86. procedure TFilterDialog.FormCreate(Sender: TObject);
  87. begin
  88.   ini.ReadStrings('Browser Filters', FilterEdit.Items);
  89. end;
  90.  
  91. procedure TFilterDialog.OKBtnClick(Sender: TObject);
  92. begin
  93.   with FilterEdit do begin
  94.     Text := RemoveSpaces(Text);
  95.     if Text = '' then Text := DefaultFilter;
  96.   end;
  97.  
  98.   if AddHistory(FilterEdit) then
  99.     ini.RewriteSectionStrings('Browser Filters', FilterEdit.Items);
  100. end;
  101.  
  102. end.
  103.