diff --git a/Packages/D2006/UnitSwitcher.bdsproj b/Packages/D2006/UnitSwitcher.bdsproj new file mode 100644 index 0000000..ad9c071 --- /dev/null +++ b/Packages/D2006/UnitSwitcher.bdsproj @@ -0,0 +1,172 @@ + + + + + + + + + + + + UnitSwitcher.dpk + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + True + True + True + + + + 0 + 0 + False + 1 + False + False + False + 16384 + 1048576 + 4194304 + UnitSwitcher + + + + + + + + + + + False + + + + + + False + + + True + False + + + True + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1043 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + + diff --git a/Packages/D2006/UnitSwitcher.cfg b/Packages/D2006/UnitSwitcher.cfg new file mode 100644 index 0000000..12d4a5a --- /dev/null +++ b/Packages/D2006/UnitSwitcher.cfg @@ -0,0 +1,39 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl" +-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl" +-Z +-w-UNSAFE_TYPE +-w-UNSAFE_CODE +-w-UNSAFE_CAST diff --git a/Packages/D2006/UnitSwitcher.dpk b/Packages/D2006/UnitSwitcher.dpk new file mode 100644 index 0000000..9fd73e4 --- /dev/null +++ b/Packages/D2006/UnitSwitcher.dpk @@ -0,0 +1,39 @@ +package UnitSwitcher; + +{$R *.res} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'UnitSwitcher'} +{$LIBSUFFIX 'D2006'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + designide; + +contains + UnSwClient in '..\..\Source\UnSwClient.pas', + UnSwObjects in '..\..\Source\UnSwObjects.pas', + UnSwDialog in '..\..\Source\UnSwDialog.pas' {frmUnSwDialog}; + +end. diff --git a/Packages/D2006/UnitSwitcher.res b/Packages/D2006/UnitSwitcher.res new file mode 100644 index 0000000..9f71601 Binary files /dev/null and b/Packages/D2006/UnitSwitcher.res differ diff --git a/Resources/DataModule.ico b/Resources/DataModule.ico new file mode 100644 index 0000000..709b8fd Binary files /dev/null and b/Resources/DataModule.ico differ diff --git a/Resources/Form.ico b/Resources/Form.ico new file mode 100644 index 0000000..0ef07f9 Binary files /dev/null and b/Resources/Form.ico differ diff --git a/Resources/Project.ico b/Resources/Project.ico new file mode 100644 index 0000000..fc98304 Binary files /dev/null and b/Resources/Project.ico differ diff --git a/Resources/Unit.ico b/Resources/Unit.ico new file mode 100644 index 0000000..1f4d17b Binary files /dev/null and b/Resources/Unit.ico differ diff --git a/Source/UnSwClient.pas b/Source/UnSwClient.pas new file mode 100644 index 0000000..917a3c5 --- /dev/null +++ b/Source/UnSwClient.pas @@ -0,0 +1,107 @@ +{$ASSERTIONS ON} +unit UnSwClient; + +interface +implementation +uses + ActnList, + Classes, + Dialogs, + SysUtils, + ToolsAPI, + + UnSwDialog, + UnSwObjects; + +type + TUnitSwitcherHook = class(TObject) + private + FOldExecute: TNotifyEvent; + FViewUnitAction: TContainedAction; + protected + procedure NewExecute(Sender: TObject); virtual; + public + constructor Create(); + destructor Destroy(); override; + end; + + +{ TUnitSwitcherHook} +constructor TUnitSwitcherHook.Create(); +var + iAction: Integer; + ifNTA: INTAServices; + pAction: TContainedAction; + +begin + try + Assert(Assigned(BorlandIDEServices), 'BorlandIDEServices not available.'); + Assert(Supports(BorlandIDEServices, INTAServices, ifNTA), + 'BorlandIDEServices does not support the ' + + 'INTAServices interface.'); + Assert(Supports(BorlandIDEServices, IOTAModuleServices), + 'BorlandIDEServices does not support the ' + + 'IOTAModuleServices interface.'); + + for iAction := 0 to Pred(ifNTA.ActionList.ActionCount) do + begin + pAction := ifNTA.ActionList.Actions[iAction]; + if pAction.Name = 'ViewUnitCommand' then + begin + FOldExecute := pAction.OnExecute; + pAction.OnExecute := NewExecute; + FViewUnitAction := pAction; + break; + end; + end; + + Assert(Assigned(FViewUnitAction), 'ViewUnitCommand action is not' + + 'available in the IDE.'); + except + on E:EAssertionFailed do + ShowMessage('Error while loading UnitSwitcher: ' + E.Message); + end; +end; + +destructor TUnitSwitcherHook.Destroy(); +begin + if Assigned(FViewUnitAction) then + FViewUnitAction.OnExecute := FOldExecute; + + inherited; +end; + + +procedure TUnitSwitcherHook.NewExecute(Sender: TObject); +var + iModule: Integer; + pProject: IOTAProject; + pUnits: TUnSwUnitList; + +begin + pProject := (BorlandIDEServices as IOTAModuleServices).GetActiveProject; + if not Assigned(pProject) then + exit; + + pUnits := TUnSwUnitList.Create(); + try + for iModule := 0 to Pred(pProject.GetModuleCount) do + pUnits.Add(TUnSwUnit.Create(pProject.GetModule(iModule))); + + TfrmUnSwDialog.Execute(pUnits); + finally + FreeAndNil(pUnits); + end; +end; + + +var + GUnitSwitcher: TUnitSwitcherHook; + +initialization + GUnitSwitcher := TUnitSwitcherHook.Create(); + +finalization + FreeAndNil(GUnitSwitcher); + +end. diff --git a/Source/UnSwDialog.dfm b/Source/UnSwDialog.dfm new file mode 100644 index 0000000..1b84d8d --- /dev/null +++ b/Source/UnSwDialog.dfm @@ -0,0 +1,512 @@ +object frmUnSwDialog: TfrmUnSwDialog + Left = 187 + Top = 83 + BorderIcons = [biSystemMenu] + Caption = 'UnitSwitcher - it almosts makes coffee.' + ClientHeight = 387 + ClientWidth = 299 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + PixelsPerInch = 96 + TextHeight = 13 + object sbStatus: TStatusBar + Left = 0 + Top = 368 + Width = 299 + Height = 19 + Panels = < + item + Width = 50 + end> + end + object pnlMain: TPanel + Left = 0 + Top = 0 + Width = 299 + Height = 334 + Align = alClient + BevelOuter = bvNone + BorderWidth = 4 + TabOrder = 1 + ExplicitWidth = 297 + ExplicitHeight = 368 + object pnlSearch: TPanel + Left = 4 + Top = 4 + Width = 291 + Height = 25 + Align = alTop + BevelOuter = bvNone + TabOrder = 0 + object edtSearch: TEdit + Left = 0 + Top = 0 + Width = 291 + Height = 21 + Align = alTop + TabOrder = 0 + OnChange = edtSearchChange + OnKeyDown = edtSearchKeyDown + end + end + object lstUnits: TListBox + Left = 4 + Top = 29 + Width = 291 + Height = 301 + Style = lbVirtualOwnerDraw + Align = alClient + ItemHeight = 20 + TabOrder = 1 + OnData = lstUnitsData + OnDrawItem = lstUnitsDrawItem + end + end + object Panel1: TPanel + Left = 0 + Top = 334 + Width = 299 + Height = 34 + Align = alBottom + BevelOuter = bvNone + TabOrder = 2 + DesignSize = ( + 299 + 34) + object btnCancel: TButton + Left = 220 + Top = 2 + Width = 75 + Height = 25 + Anchors = [akTop, akRight] + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 0 + end + object btnOK: TButton + Left = 139 + Top = 2 + Width = 75 + Height = 25 + Anchors = [akTop, akRight] + Caption = 'OK' + Default = True + ModalResult = 1 + TabOrder = 1 + end + end + object ilsTypes: TImageList + Left = 8 + Top = 32 + Bitmap = { + 494C010104000900040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000003000000001002000000000000030 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000008000 + 0000000000000000000080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFFFFF008080800080808000808080008080800080808000808080008080 + 8000808080008080800080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000080000000800000008000 + 0000800000000000000080808000C0C0C000C0C0C000C0C0C000C0C0C0000000 + 00000000000000000000000000000000000000000000FFFFFF00808080008080 + 8000808080008080800080808000808080008080800080808000808080008080 + 8000808080000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000080000000000000008000 + 0000000000000000000080808000808080008080800000000000808080008080 + 80000000000000000000000000000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000808080000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00808080008080 + 8000808080008080800080808000808080008080800080808000808080008080 + 8000808080008080800080808000000000000000000080000000000000000000 + 0000000000000000000000000000000000008080800000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00FFFFFF0000000000000000000000000000000000000000000000 + 000000000000FFFFFF00808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C00080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF0000000000FFFFFF0080808000808080008080 + 8000808080008080800080808000000000000000000000000000000000000000 + 0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF0080808000000000008080800000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C00000000000FFFFFF00FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000 + 0000FFFFFF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF00808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C00080808000000000008080800080808000000000000000 + 000000000000FFFFFF0080808000808080008080800080808000808080008080 + 80008080800080808000808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF0000000000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C00080808000000000000000000080000000000000000000 + 0000FFFFFF000000FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF000000FF00808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000 + 000000000000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C00000000000FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000000000000000 + 0000FFFFFF000000FF000000FF000000FF000000FF000000FF000000FF000000 + FF000000FF000000FF00808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C00080808000000000000000000000000000000000000000 + 000000000000FFFFFF00FFFFFF00C0C0C0000000FF000000FF000000FF00C0C0 + C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF00C0C0C000808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF0080808000000000000000000000000000000000000000 + 000000000000FFFFFF00C0C0C000FFFFFF000000FF000000FF00C0C0C000FFFF + FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C00000000000FF000000FF000000FF000000FF00 + 0000FF00000000000000C0C0C000000000000000000000000000000000000000 + 0000FFFFFF00FFFFFF0000000000000000000000000000000000000000000000 + 0000C0C0C000FFFFFF00808080000000000000000000FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000000000000000 + 000000000000FFFFFF00FFFFFF00C0C0C0000000FF00C0C0C0000000FF000000 + FF00FFFFFF00C0C0C000808080000000000000000000FFFFFF00FFFFFF00C0C0 + C000FFFFFF00C0C0C000FFFFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C000FFFFFF008080800080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00808080000000000000000000FFFFFF00C0C0C000FFFF + FF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFF + FF00808080000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00FFFFFF0000000000000000000000000000000000C0C0C000FFFF + FF000000000000000000000000000000000000000000FF000000FF000000FF00 + 0000FF000000FF000000FF000000FF000000FF00000000000000C0C0C0000000 + 0000C0C0C00000000000C0C0C000000000000000000000000000000000000000 + 000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0C000FFFFFF00C0C0 + C00000000000FFFFFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000FF000000FF000000FF000000FF00000000000000C0C0C0000000 + 0000C0C0C00000000000C0C0C0000000000000000000FF000000FF000000FF00 + 0000FF000000FF000000FF00000000000000C0C0C00000000000C0C0C0000000 + 0000C0C0C0000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000300000000100010000000000800100000000000000000000 + 000000000000000000000000FFFFFF0000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000E000FFFFEC0F0003E000FFFF840F0003 + E0000000AC0F0003E0000000BF3F0000E0000000FFFF00006000000010000000 + 200000001000000000000000B000000020000000F000000060000000F0000000 + E0000000F0000000E0000000F0000003E0000000F0000003E0010000F0000003 + E003FFFFF0000003E007FFFFF000000300000000000000000000000000000000 + 000000000000} + end +end diff --git a/Source/UnSwDialog.pas b/Source/UnSwDialog.pas new file mode 100644 index 0000000..f5542ff --- /dev/null +++ b/Source/UnSwDialog.pas @@ -0,0 +1,191 @@ +unit UnSwDialog; + +interface +uses + Classes, + ComCtrls, + Controls, + ExtCtrls, + Forms, + ImgList, + StdCtrls, + Windows, + + UnSwObjects; + +type + TfrmUnSwDialog = class(TForm) + edtSearch: TEdit; + ilsTypes: TImageList; + lstUnits: TListBox; + pnlMain: TPanel; + pnlSearch: TPanel; + sbStatus: TStatusBar; + Panel1: TPanel; + btnCancel: TButton; + btnOK: TButton; + + procedure edtSearchChange(Sender: TObject); + procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string); + procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); + private + FUnitList: TUnSwUnitList; + FTypeFilteredList: TUnSwUnitList; + FInputFilteredList: TUnSwUnitList; + + FTypeFilter: TUnSwUnitTypeFilter; + FInputFilter: TUnSwUnitSimpleFilter; + + function InternalExecute(const AUnits: TUnSwUnitList): Integer; + procedure UpdateList(); + + function GetActiveUnit(): TUnSwUnit; + public + class function Execute(const AUnits: TUnSwUnitList): Integer; + end; + +implementation +uses + SysUtils, + Graphics; + +{$R *.dfm} + +{ TfrmUnSwDialog } +class function TfrmUnSwDialog.Execute(const AUnits: TUnSwUnitList): Integer; +begin + with Self.Create(nil) do + try + Result := InternalExecute(AUnits); + finally + Free(); + end; +end; + + +function SortByName(Item1, Item2: Pointer): Integer; +begin + Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name) +end; + +function TfrmUnSwDialog.InternalExecute(const AUnits: TUnSwUnitList): Integer; +begin + Result := -1; + FUnitList := AUnits; + + FTypeFilteredList := TUnSwUnitList.Create(); + FInputFilteredList := TUnSwUnitList.Create(); + FTypeFilter := TUnSwUnitTypeFilter.Create(); + FInputFilter := TUnSwUnitSimpleFilter.Create(); + try + FTypeFilteredList.Clone(FUnitList); + FTypeFilteredList.ApplyFilter(FTypeFilter); + FTypeFilteredList.Sort(SortByName); + UpdateList(); + + Self.ShowModal(); + finally + FreeAndNil(FInputFilter); + FreeAndNil(FTypeFilter); + FreeAndNil(FInputFilteredList); + FreeAndNil(FTypeFilteredList); + end; +end; + +procedure TfrmUnSwDialog.UpdateList(); +var + pActive: TUnSwUnit; + +begin + pActive := GetActiveUnit(); + // #ToDo1 Try to select the previous unit, otherwise select the first + + FInputFilteredList.Clone(FTypeFilteredList); + FInputFilteredList.ApplyFilter(FInputFilter); + + lstUnits.Count := FInputFilteredList.Count; + if FInputFilteredList.Count > 0 then + begin + if Assigned(pActive) then + lstUnits.ItemIndex := FInputFilteredList.IndexOf(pActive); + + if lstUnits.ItemIndex = -1 then + lstUnits.ItemIndex := 0; + end; +end; + +function TfrmUnSwDialog.GetActiveUnit(): TUnSwUnit; +begin + Result := nil; + if lstUnits.ItemIndex > -1 then + Result := FInputFilteredList[lstUnits.ItemIndex]; +end; + +procedure TfrmUnSwDialog.edtSearchChange(Sender: TObject); +begin + FInputFilter.Filter := edtSearch.Text; + UpdateList(); +end; + +procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Shift = [] then + case Key of + VK_UP: + if lstUnits.ItemIndex > 0 then + lstUnits.ItemIndex := Pred(lstUnits.ItemIndex); + VK_DOWN: + if lstUnits.ItemIndex < Pred(lstUnits.Items.Count) then + lstUnits.ItemIndex := Succ(lstUnits.ItemIndex); + end; +end; + + +procedure TfrmUnSwDialog.lstUnitsData(Control: TWinControl; Index: Integer; + var Data: string); +begin + Data := FInputFilteredList[Index].Name; +end; + +procedure TfrmUnSwDialog.lstUnitsDrawItem(Control: TWinControl; Index: Integer; + Rect: TRect; State: TOwnerDrawState); +var + iIcon: Integer; + rText: TRect; + sText: String; + +begin + with TListBox(Control) do + begin + if odSelected in State then + begin + Canvas.Brush.Color := clHighlight; + Canvas.Font.Color := clHighlightText; + end else + begin + Canvas.Brush.Color := clWindow; + Canvas.Font.Color := clWindowText; + end; + Canvas.FillRect(Rect); + + rText := Rect; + InflateRect(rText, -2, -2); + + iIcon := 0; + case FInputFilteredList[Index].UnitType of + swutForm: iIcon := 1; + swutDataModule: iIcon := 2; + swutProjUnit: iIcon := 3; + end; + ilsTypes.Draw(Canvas, rText.Left, rText.Top, iIcon); + + Inc(rText.Left, ilsTypes.Width + 4); + sText := FInputFilteredList[Index].Name; + DrawText(Canvas.Handle, PChar(sText), Length(sText), rText, DT_SINGLELINE or + DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS); + end; +end; + +end. diff --git a/Source/UnSwObjects.pas b/Source/UnSwObjects.pas new file mode 100644 index 0000000..2460f88 --- /dev/null +++ b/Source/UnSwObjects.pas @@ -0,0 +1,256 @@ +unit UnSwObjects; + +interface +uses + Classes, + Contnrs, + ToolsAPI; + +type + // Forward declarations + TUnSwUnitFilter = class; + + TUnSwUnitType = ( + swutForm = 0, + swutDataModule = 1, + swutProjUnit = 2, + swutUnit = 3, + swutRc = 4, + swutAsm = 5, + swutDef = 6, + swutObj = 7, + swutRes = 8, + swutLib = 9, + swutTypeLib = 10, + swutPackageImport = 11, + swutFormResource = 12, + swutCustom = 13, + swutIDL = 14 + ); + TUnSwUnitTypes = set of TUnSwUnitType; + + TUnSwUnit = class(TPersistent) + private + FModule: IOTAModuleInfo; + + function GetName(): String; + function GetFileName(): String; + function GetUnitType(): TUnSwUnitType; + public + constructor Create(const AModule: IOTAModuleInfo); virtual; + + property Name: String read GetName; + property FileName: String read GetFileName; + property UnitType: TUnSwUnitType read GetUnitType; + end; + + TUnSwUnitList = class(TPersistent) + private + FItems: TObjectList; + + function GetCount(): Integer; + function GetItem(Index: Integer): TUnSwUnit; + procedure SetItem(Index: Integer; Value: TUnSwUnit); + public + constructor Create(); + destructor Destroy(); override; + + function Add(const AUnit: TUnSwUnit): Integer; virtual; + function IndexOf(const AUnit: TUnSwUnit): Integer; + procedure Sort(Compare: TListSortCompare); + + procedure Clone(const ASource: TUnSwUnitList); virtual; + procedure ApplyFilter(const AFilter: TUnSwUnitFilter); virtual; + + property Count: Integer read GetCount; + property Items[Index: Integer]: TUnSwUnit read GetItem + write SetItem; default; + end; + + TUnSwUnitFilter = class(TObject) + protected + function IsFiltered(const AUnit: TUnSwUnit): Boolean; virtual; abstract; + public + constructor Create(); virtual; + end; + + TUnSwUnitSimpleFilter = class(TUnSwUnitFilter) + private + FFilter: String; + + procedure SetFilter(const Value: String); + protected + function IsFiltered(const AUnit: TUnSwUnit): Boolean; override; + public + property Filter: String read FFilter write SetFilter; + end; + + TUnSwUnitTypeFilter = class(TUnSwUnitFilter) + private + FIncludeDataModules: Boolean; + FIncludeForms: Boolean; + FIncludeProjectSource: Boolean; + protected + function IsFiltered(const AUnit: TUnSwUnit): Boolean; override; + public + constructor Create(); override; + + property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules; + property IncludeForms: Boolean read FIncludeForms write FIncludeForms; + property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource; + end; + +implementation +uses + SysUtils; + + +{ TUnSwUnit } +constructor TUnSwUnit.Create(const AModule: IOTAModuleInfo); +begin + inherited Create(); + + FModule := AModule; +end; + + +function TUnSwUnit.GetName(): String; +begin + Result := FModule.Name; +end; + +function TUnSwUnit.GetFileName(): String; +begin + Result := FModule.FileName; +end; + +function TUnSwUnit.GetUnitType(): TUnSwUnitType; +begin + Result := TUnSwUnitType(FModule.ModuleType); + if (Result = swutForm) and (Length(FModule.FormName) = 0) then + Result := swutUnit; +end; + + +{ TUnSwUnitList} +constructor TUnSwUnitList.Create(); +begin + inherited Create(); + + FItems := TObjectList.Create(True); +end; + + +destructor TUnSwUnitList.Destroy(); +begin + FreeAndNil(FItems); + + inherited; +end; + + +function TUnSwUnitList.Add(const AUnit: TUnSwUnit): Integer; +begin + Result := FItems.Add(AUnit); +end; + +function TUnSwUnitList.IndexOf(const AUnit: TUnSwUnit): Integer; +begin + Result := FItems.IndexOf(AUnit); +end; + +procedure TUnSwUnitList.Sort(Compare: TListSortCompare); +begin + FItems.Sort(Compare); +end; + + +procedure TUnSwUnitList.ApplyFilter(const AFilter: TUnSwUnitFilter); +var + iItem: Integer; + +begin + for iItem := Pred(Count) downto 0 do + if AFilter.IsFiltered(Items[iItem]) then + FItems.Delete(iItem); +end; + +procedure TUnSwUnitList.Clone(const ASource: TUnSwUnitList); +var + iItem: Integer; + +begin + FItems.Clear(); + FItems.OwnsObjects := False; + + for iItem := 0 to Pred(ASource.Count) do + FItems.Add(ASource[iItem]); +end; + + +function TUnSwUnitList.GetCount(): Integer; +begin + Result := FItems.Count; +end; + +function TUnSwUnitList.GetItem(Index: Integer): TUnSwUnit; +begin + Result := TUnSwUnit(FItems[Index]); +end; + +procedure TUnSwUnitList.SetItem(Index: Integer; Value: TUnSwUnit); +begin + FItems[Index] := Value; +end; + + +{ TUnSwUnitFilter } +constructor TUnSwUnitFilter.Create(); +begin + inherited Create(); +end; + + +{ TUnSwUnitSimpleFilter } +function TUnSwUnitSimpleFilter.IsFiltered(const AUnit: TUnSwUnit): Boolean; +begin + Result := (Length(FFilter) > 0) and + (AnsiPos(FFilter, LowerCase(AUnit.Name)) = 0); +end; + +procedure TUnSwUnitSimpleFilter.SetFilter(const Value: String); +begin + FFilter := LowerCase(Value); +end; + + +{ TUnSwUnitTypeFilter } +constructor TUnSwUnitTypeFilter.Create(); +begin + inherited; + + FIncludeDataModules := True; + FIncludeForms := True; + FIncludeProjectSource := True; +end; + +function TUnSwUnitTypeFilter.IsFiltered(const AUnit: TUnSwUnit): Boolean; +var + eValidTypes: TUnSwUnitTypes; + +begin + eValidTypes := [swutUnit]; + + if FIncludeDataModules then + Include(eValidTypes, swutDataModule); + + if FIncludeForms then + Include(eValidTypes, swutForm); + + if FIncludeProjectSource then + Include(eValidTypes, swutProjUnit); + + Result := not (AUnit.UnitType in eValidTypes); +end; + +end.