source: trunk/NewView/SearchDirectoriesFormUnit.pas@ 33

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

more uses cleanup

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