| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <Common.h>
- #include <FileMasks.h>
- #include <CoreMain.h>
- #include <TextsWin.h>
- #include <HelpWin.h>
- #include <Tools.h>
- #include <VCLCommon.h>
- #include "SelectMask.h"
- #include "WinConfiguration.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "HistoryComboBox"
- #ifndef NO_RESOURCES
- #pragma resource "*.dfm"
- #endif
- //---------------------------------------------------------------------------
- bool __fastcall DoSelectMaskDialog(TControl * Parent, bool Select, TFileFilter & Filter)
- {
- std::unique_ptr<TSelectMaskDialog> Dialog(new TSelectMaskDialog(Application));
- Dialog->Init((Select ? TSelectMaskDialog::smSelect : TSelectMaskDialog::smDeselect), Parent);
- DefaultFileFilter(Filter);
- Filter.Masks = WinConfiguration->SelectMask;
- Filter.Directories = WinConfiguration->SelectDirectories;
- bool Result = Dialog->Execute(Filter);
- if (Result)
- {
- WinConfiguration->SelectMask = Filter.Masks;
- WinConfiguration->SelectDirectories = Filter.Directories;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- bool __fastcall DoFilterMaskDialog(TControl * Parent, UnicodeString & Mask)
- {
- TFileFilter Filter;
- DefaultFileFilter(Filter);
- Filter.Masks = Mask;
- std::unique_ptr<TSelectMaskDialog> Dialog(new TSelectMaskDialog(Application));
- Dialog->Init(TSelectMaskDialog::smFilter, Parent);
- bool Result = Dialog->Execute(Filter);
- if (Result)
- {
- Mask = Filter.Masks;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- __fastcall TSelectMaskDialog::TSelectMaskDialog(TComponent * Owner) :
- TForm(Owner)
- {
- UseSystemSettings(this);
- HintLabel(HintText,
- FORMAT(L"%s\n \n%s\n \n%s\n \n%s", (LoadStr(MASK_HINT2), LoadStr(FILE_MASK_EX_HINT),
- LoadStr(COMBINING_MASKS_HINT), LoadStr(MASK_HELP))));
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::Init(TMode Mode, TControl * Parent)
- {
- int CaptionStr;
- switch (Mode)
- {
- case smSelect:
- CaptionStr = SELECT_MASK_SELECT_CAPTION;
- ClearButton->Hide();
- break;
- case smDeselect:
- CaptionStr = SELECT_MASK_DESELECT_CAPTION;
- ClearButton->Hide();
- break;
- case smFilter:
- CaptionStr = FILTER_MASK_CAPTION;
- ApplyToDirectoriesCheck->Hide();
- HelpKeyword = HELP_FILTER;
- break;
- }
- Caption = LoadStr(CaptionStr);
- FParent = Parent;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::FormCloseQuery(TObject *, bool & DebugUsedArg(CanClose))
- {
- if (ModalResult == DefaultResult(this))
- {
- if (MaskEdit->Focused())
- {
- MaskEditExit(NULL);
- }
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TSelectMaskDialog::Execute(TFileFilter & FileFilter)
- {
- ApplyToDirectoriesCheck->Checked = FileFilter.Directories;
- MaskEdit->Text = FileFilter.Masks;
- MaskEdit->Items = WinConfiguration->History[L"Mask"];
- ActiveControl = MaskEdit;
- bool Result = (ShowModal() == DefaultResult(this));
- if (Result)
- {
- MaskEdit->SaveToHistory();
- WinConfiguration->History[L"Mask"] = MaskEdit->Items;
- FileFilter.Directories = ApplyToDirectoriesCheck->Checked;
- FileFilter.Masks = MaskEdit->Text;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::MaskEditExit(TObject * /*Sender*/)
- {
- ValidateMaskEdit(MaskEdit);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::HelpButtonClick(TObject * /*Sender*/)
- {
- FormHelp(this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::ClearButtonClick(TObject * /*Sender*/)
- {
- MaskEdit->Text = L"";
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::FormShow(TObject * /*Sender*/)
- {
- InstallPathWordBreakProc(MaskEdit);
- // Only now it is scaled
- CenterFormOn(this, FParent);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSelectMaskDialog::MaskButtonClick(TObject * /*Sender*/)
- {
- TFileMasks Masks = MaskEdit->Text;
- if (DoEditMaskDialog(Masks))
- {
- MaskEdit->Text = Masks.Masks;
- }
- }
- //---------------------------------------------------------------------------
|