source: trunk/NewView/SearchDirectoriesFormUnit.pas@ 18

Last change on this file since 18 was 18, checked in by RBRi, 19 years ago

+ newview source

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1Unit SearchDirectoriesFormUnit;
2
3Interface
4
5Uses
6 Classes, Forms, Graphics, Buttons, StdCtrls,
7 ACLLanguageUnit, CustomFileControls;
8
9Type
10 TSearchDirectoriesForm = Class (TForm)
11 OKButton: TButton;
12 CancelButton: TButton;
13 DirectoriesLabel: TLabel;
14 HelpButton: TButton;
15 AddButton: TButton;
16 AddDirectoryButton: TButton;
17 SubdirectoriesCheckBox: TCheckBox;
18 DirectoryListBox: TCustomDirectoryListBox;
19 DriveComboBox: TCustomDriveComboBox;
20 DirectoriesListBox: TListBox;
21 DriveLabel: TLabel;
22 DirectoryLabel: TLabel;
23 Procedure SearchDirectoriesFormOnSetupShow (Sender: TObject);
24 Procedure AddDirectoryButtonOnClick (Sender: TObject);
25 Procedure SearchDirectoriesFormOnDestroy (Sender: TObject);
26 Procedure AddButtonOnClick (Sender: TObject);
27 Procedure SearchDirectoriesFormOnCreate (Sender: TObject);
28 Procedure OKButtonOnClick (Sender: TObject);
29 Procedure SearchDirectoriesFormOnShow (Sender: TObject);
30 Protected
31 Procedure ShowBrowseControls( Show: boolean );
32
33 Public
34 {Insert public declarations here}
35 Procedure OnLanguageEvent( Language: TLanguageFile;
36 const Apply: boolean );
37
38 SelectedFolders: TStringList; // input/output.
39 // On input; if the associated object is non-nil, then
40 // the folder will be displayed as non-selected.
41 CustomDirAdded: boolean; // output
42 End;
43
44Var
45 SearchDirectoriesForm: TSearchDirectoriesForm;
46
47Implementation
48
49Uses
50 ControlsUtility, ACLFileUtility, SysUtils;
51
52Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnSetupShow (Sender: TObject);
53Begin
54 ScaleForm( self, 11, 16 );
55End;
56
57Procedure TSearchDirectoriesForm.AddDirectoryButtonOnClick (Sender: TObject);
58var
59 Dir: string;
60 i: longint;
61Begin
62 Dir := DirectoryListBox.Directory;
63 if SubdirectoriesCheckBox.Checked then
64 Dir := Dir + '...';
65
66 i := DirectoriesListBox.Items.IndexOf( Dir );
67
68 if i = -1 then
69 begin
70 // not already present...
71 i := DirectoriesListBox.Items.Add( Dir );
72 CustomDirAdded := true;
73 end;
74 DirectoriesListBox.Selected[ i ] := true;
75
76 DirectoriesListBox.TopIndex := i;
77End;
78
79Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnDestroy (Sender: TObject);
80Begin
81 SelectedFolders.Destroy;
82End;
83
84// Show or hide controls so they are in the tab order when appropriate
85Procedure TSearchDirectoriesForm.ShowBrowseControls( Show: boolean );
86Begin
87 DriveComboBox.Visible := Show;
88 DirectoryListBox.Visible := Show;
89 AddDirectoryButton.Visible := Show;
90 SubdirectoriesCheckBox.Visible := Show;
91End;
92
93Procedure TSearchDirectoriesForm.AddButtonOnClick (Sender: TObject);
94Begin
95 ShowBrowseControls( true );
96
97 ClientWidth := DirectoryListBox.Left
98 + DirectoryListBox.Width
99 + DirectoriesListBox.Left; // same margin as left
100 DriveComboBox.Focus;
101
102 AddButton.Visible := false;
103End;
104
105Procedure TSearchDirectoriesForm.OnLanguageEvent( Language: TLanguageFile;
106 const Apply: boolean );
107begin
108 Language.LoadComponentLanguage( self, Apply );
109end;
110
111Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnCreate (Sender: TObject);
112Begin
113 RegisterForLanguages( OnLanguageEvent );
114 ClientWidth := DirectoriesListBox.Left + DirectoriesListBox.Width + DirectoriesListBox.Left;
115
116 ShowBrowseControls( false );
117
118 SelectedFolders := TStringList.Create;
119End;
120
121Procedure TSearchDirectoriesForm.OKButtonOnClick (Sender: TObject);
122var
123 i: longint;
124begin
125 // SelectedDrives := '';
126 SelectedFolders.Clear;
127 for i := 0 to DirectoriesListBox.Items.Count -1 do
128 begin
129 if DirectoriesListBox.Selected[ i ] then
130 begin
131 SelectedFolders.Add( DirectoriesListBox.Items[ i ] );
132 end;
133 end;
134end;
135
136Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnShow (Sender: TObject);
137var
138 i: longint;
139Begin
140// AddButton.Visible := true;
141 CustomDirAdded := false;
142 OKButton.Default := true;
143
144 DirectoriesListBox.CLear;
145
146 for i := 0 to SelectedFolders.Count - 1 do
147 begin
148 DirectoriesListBox.Items.Add( SelectedFolders[ i ] );
149 if SelectedFolders.Objects[ i ] = nil then
150 DirectoriesListBox.Selected[ i ] := true;
151 end;
152 // SelectedFolders
153// DriveListBox.Clear;
154// SetAllCheckListItems( DirectoriesListBox, true );
155// End;
156End;
157
158Initialization
159 RegisterClasses ([TSearchDirectoriesForm, TButton,
160 TLabel, TCustomDirectoryListBox, TCustomDriveComboBox, TListBox, TCheckBox]);
161End.
Note: See TracBrowser for help on using the repository browser.