doublecmd/src/fmaskinputdlg.pas
2010-01-12 18:07:54 +00:00

109 lines
3 KiB
ObjectPascal

{
Double Commander
-------------------------------------------------------------------------
File mask input dialog
Copyright (C) 2010 Koblov Alexander (Alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit fMaskInputDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons;
type
{ TfrmMaskInputDlg }
TfrmMaskInputDlg = class(TForm)
lblPrompt: TLabel;
lblSearchTemplate: TLabel;
cmbMask: TComboBox;
btnOK: TBitBtn;
btnCancel: TBitBtn;
lbxSearchTemplate: TListBox;
procedure FormCreate(Sender: TObject);
procedure lbxSearchTemplateClick(Sender: TObject);
procedure lbxSearchTemplateDblClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
function ShowMaskInputDlg(const sCaption, sPrompt: UTF8String; slValueList: TStringList; var sValue: UTF8String): Boolean;
implementation
uses
uGlobs, uSearchTemplate;
function ShowMaskInputDlg(const sCaption, sPrompt: UTF8String;
slValueList: TStringList; var sValue: UTF8String): Boolean;
begin
Result:= False;
with TfrmMaskInputDlg.Create(Application) do
try
Caption:= sCaption;
lblPrompt.Caption:= sPrompt;
cmbMask.Items.Assign(slValueList);
cmbMask.Text := sValue;
if ShowModal = mrOK then
begin
if not IsMaskSearchTemplate(cmbMask.Text) then
if slValueList.IndexOf(cmbMask.Text) < 0 then
slValueList.Add(cmbMask.Text);
sValue:= cmbMask.Text;
Result:= True;
end;
finally
Free;
end;
end;
{ TfrmMaskInputDlg }
procedure TfrmMaskInputDlg.lbxSearchTemplateClick(Sender: TObject);
begin
cmbMask.Text:= cTemplateSign + lbxSearchTemplate.Items[lbxSearchTemplate.ItemIndex];
end;
procedure TfrmMaskInputDlg.lbxSearchTemplateDblClick(Sender: TObject);
begin
cmbMask.Text:= cTemplateSign + lbxSearchTemplate.Items[lbxSearchTemplate.ItemIndex];
Close;
ModalResult:= mrOK;
end;
procedure TfrmMaskInputDlg.FormCreate(Sender: TObject);
var
I: Integer;
begin
for I:= 0 to gSearchTemplateList.Count - 1 do
lbxSearchTemplate.Items.Add(gSearchTemplateList.Templates[I].TemplateName);
end;
initialization
{$I fmaskinputdlg.lrs}
end.