2007-12-07 15:33:00 +00:00
|
|
|
{: Contains the base Switcher dialog.
|
|
|
|
|
|
|
|
Last changed: $Date$
|
|
|
|
Revision: $Rev$
|
|
|
|
Author: $Author$
|
|
|
|
}
|
|
|
|
unit BaseSwDialog;
|
|
|
|
|
|
|
|
{$WARN SYMBOL_PLATFORM OFF}
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
ActnList,
|
|
|
|
Classes,
|
|
|
|
ComCtrls,
|
|
|
|
Controls,
|
|
|
|
ExtCtrls,
|
|
|
|
Forms,
|
|
|
|
Graphics,
|
|
|
|
ImgList,
|
|
|
|
Menus,
|
|
|
|
StdCtrls,
|
|
|
|
Windows,
|
|
|
|
|
|
|
|
BaseSwFilters,
|
|
|
|
BaseSwObjects;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TBaseSwStyleVisitor = class(TInterfacedPersistent, IBaseSwVisitor)
|
|
|
|
private
|
|
|
|
FColor: TColor;
|
|
|
|
FImageIndex: Integer;
|
|
|
|
FOverlayIndex: Integer;
|
|
|
|
protected
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure VisitItem(const AItem: TBaseSwItem); virtual;
|
2007-12-07 15:33:00 +00:00
|
|
|
public
|
|
|
|
property Color: TColor read FColor write FColor;
|
|
|
|
property ImageIndex: Integer read FImageIndex write FImageIndex;
|
|
|
|
property OverlayIndex: Integer read FOverlayIndex write FOverlayIndex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrmBaseSwDialog = class(TForm)
|
|
|
|
actMRUNext: TAction;
|
|
|
|
actMRUPrior: TAction;
|
|
|
|
actSelectAll: TAction;
|
|
|
|
actSelectInvert: TAction;
|
|
|
|
alMain: TActionList;
|
|
|
|
btnCancel: TButton;
|
|
|
|
btnOK: TButton;
|
|
|
|
cmbSearch: TComboBox;
|
|
|
|
ilsTypes: TImageList;
|
|
|
|
lblSubFilters: TLabel;
|
|
|
|
lstItems: TListBox;
|
2007-12-09 12:02:11 +00:00
|
|
|
pmnItems: TPopupMenu;
|
|
|
|
pmnItemsSelectAll: TMenuItem;
|
|
|
|
pmnItemsSelectInvert: TMenuItem;
|
2007-12-07 15:33:00 +00:00
|
|
|
pnlButtons: TPanel;
|
|
|
|
pnlMain: TPanel;
|
|
|
|
pnlSearch: TPanel;
|
|
|
|
pnlSubFilters: TPanel;
|
|
|
|
sbStatus: TStatusBar;
|
|
|
|
|
|
|
|
procedure actMRUNextExecute(Sender: TObject);
|
|
|
|
procedure actMRUPriorExecute(Sender: TObject);
|
|
|
|
procedure actSelectAllExecute(Sender: TObject);
|
|
|
|
procedure actSelectInvertExecute(Sender: TObject);
|
|
|
|
procedure cmbSearchChange(Sender: TObject);
|
|
|
|
procedure cmbSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
|
|
procedure cmbSearchKeyPress(Sender: TObject; var Key: Char);
|
|
|
|
procedure FormResize(Sender: TObject);
|
|
|
|
procedure lstItemsData(Control: TWinControl; Index: Integer; var Data: string);
|
|
|
|
procedure lstItemsDblClick(Sender: TObject);
|
|
|
|
procedure lstItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
|
|
|
procedure lstItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure lstItemsClick(Sender: TObject);
|
2007-12-07 15:33:00 +00:00
|
|
|
procedure btnOKClick(Sender: TObject);
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure FormShow(Sender: TObject);
|
2007-12-07 15:33:00 +00:00
|
|
|
private
|
|
|
|
FItemList: TBaseSwItemList;
|
|
|
|
FActiveItem: TBaseSwItem;
|
|
|
|
FMRUList: TStrings;
|
|
|
|
FMRUIndex: Integer;
|
|
|
|
FSubFilters: TStringList;
|
|
|
|
|
|
|
|
FSubFilteredList: TBaseSwItemList;
|
|
|
|
FInputFilteredList: TBaseSwItemList;
|
|
|
|
|
|
|
|
FSubFilter: TBaseSwItemSimpleFilter;
|
|
|
|
FInputFilter: TBaseSwItemSimpleFilter;
|
|
|
|
FLastFilter: String;
|
|
|
|
|
|
|
|
FStyleVisitor: TBaseSwStyleVisitor;
|
|
|
|
protected
|
|
|
|
function InternalExecute(): TBaseSwItemList; virtual;
|
|
|
|
procedure UpdateList(); virtual;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function CreateItemList(): TBaseSwItemList; virtual;
|
|
|
|
function CreateInputFilter(): TBaseSwItemSimpleFilter; virtual;
|
|
|
|
function CreateStyleVisitor(): TBaseSwStyleVisitor; virtual;
|
|
|
|
|
|
|
|
function AllowEmptyResult(): Boolean; virtual; abstract;
|
|
|
|
function ColorsEnabled(): Boolean; virtual;
|
|
|
|
|
|
|
|
function GetBaseItemList(): TBaseSwItemList; virtual;
|
|
|
|
function GetItemDisplayName(const AItem: TBaseSwItem): String; virtual;
|
|
|
|
procedure UpdateItemActions(); virtual;
|
|
|
|
|
2007-12-07 15:33:00 +00:00
|
|
|
function GetActiveItems(): TBaseSwItemList;
|
|
|
|
procedure SelectMRUItem();
|
|
|
|
|
|
|
|
function PushFilter(const AFilter: String): Boolean;
|
|
|
|
procedure PopFilter();
|
|
|
|
procedure UpdateSubFilters();
|
|
|
|
|
|
|
|
procedure LoadSettings(); virtual;
|
|
|
|
procedure SaveSettings(); virtual;
|
2007-12-09 12:02:11 +00:00
|
|
|
protected
|
|
|
|
property ActiveItem: TBaseSwItem read FActiveItem write FActiveItem;
|
|
|
|
property ItemList: TBaseSwItemList read FItemList write FItemList;
|
|
|
|
property MRUList: TStrings read FMRUList;
|
2007-12-07 15:33:00 +00:00
|
|
|
public
|
|
|
|
class function Execute(const AItems: TBaseSwItemList; const AActive: TBaseSwItem = nil): TBaseSwItemList;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2007-12-09 12:02:11 +00:00
|
|
|
Messages,
|
|
|
|
SysUtils, Dialogs;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
SubFilterSeparator = ' '#187' ';
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TBaseSwStyleVisitor }
|
|
|
|
procedure TBaseSwStyleVisitor.VisitItem(const AItem: TBaseSwItem);
|
|
|
|
begin
|
|
|
|
Color := clDefault;
|
|
|
|
ImageIndex := -1;
|
|
|
|
OverlayIndex := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TfrmUnSwDialog }
|
|
|
|
class function TfrmBaseSwDialog.Execute(const AItems: TBaseSwItemList;
|
|
|
|
const AActive: TBaseSwItem): TBaseSwItemList;
|
|
|
|
begin
|
|
|
|
with Self.Create(nil) do
|
|
|
|
try
|
2007-12-09 12:02:11 +00:00
|
|
|
ItemList := AItems;
|
|
|
|
ActiveItem := AActive;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
Result := InternalExecute();
|
|
|
|
finally
|
|
|
|
Free();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.FormResize(Sender: TObject);
|
|
|
|
begin
|
|
|
|
lstItems.Invalidate();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TfrmBaseSwDialog.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
// Setting ListBox.Selected[x] won't work before OnShow...
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-07 15:33:00 +00:00
|
|
|
function TfrmBaseSwDialog.InternalExecute(): TBaseSwItemList;
|
|
|
|
type
|
|
|
|
TBaseSwItemSimpleFilterClass = class of TBaseSwItemSimpleFilter;
|
|
|
|
|
|
|
|
var
|
|
|
|
iIndex: Integer;
|
|
|
|
mruText: String;
|
|
|
|
subFilterIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
FSubFilters := TStringList.Create();
|
2007-12-09 12:02:11 +00:00
|
|
|
FSubFilteredList := CreateItemList();
|
|
|
|
FInputFilteredList := CreateItemList();
|
|
|
|
|
|
|
|
FSubFilter := CreateInputFilter();
|
|
|
|
FInputFilter := CreateInputFilter();
|
2007-12-07 15:33:00 +00:00
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
FMRUList := TStringList.Create();
|
2007-12-07 15:33:00 +00:00
|
|
|
try
|
2007-12-09 12:02:11 +00:00
|
|
|
LoadSettings();
|
|
|
|
|
|
|
|
FStyleVisitor := CreateStyleVisitor();
|
2007-12-07 15:33:00 +00:00
|
|
|
try
|
|
|
|
if Self.ShowModal() = mrOk then
|
|
|
|
begin
|
|
|
|
if Length(Trim(cmbSearch.Text)) > 0 then
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
iIndex := MRUList.IndexOf(cmbSearch.Text);
|
2007-12-07 15:33:00 +00:00
|
|
|
if iIndex > -1 then
|
2007-12-09 12:02:11 +00:00
|
|
|
MRUList.Delete(iIndex);
|
2007-12-07 15:33:00 +00:00
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
while MRUList.Count >= 10 do
|
|
|
|
MRUList.Delete(Pred(MRUList.Count));
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
mruText := cmbSearch.Text;
|
|
|
|
for subFilterIndex := Pred(FSubFilters.Count) downto 0 do
|
|
|
|
mruText := FSubFilters[subFilterIndex] + SubFilterSeparator;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
MRUList.Insert(0, mruText);
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
Result := GetActiveItems();
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
SaveSettings();
|
|
|
|
finally
|
|
|
|
FreeAndNil(FStyleVisitor);
|
|
|
|
end;
|
|
|
|
finally
|
2007-12-09 12:02:11 +00:00
|
|
|
FreeAndNil(FMRUList);
|
2007-12-07 15:33:00 +00:00
|
|
|
FreeAndNil(FInputFilter);
|
|
|
|
FreeAndNil(FSubFilter);
|
|
|
|
FreeAndNil(FSubFilteredList);
|
|
|
|
FreeAndNil(FInputFilteredList);
|
|
|
|
FreeAndNil(FSubFilters);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TfrmBaseSwDialog.LoadSettings();
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
cmbSearch.Items.Assign(MRUList);
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TfrmBaseSwDialog.SaveSettings();
|
|
|
|
begin
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TfrmBaseSwDialog.UpdateItemActions();
|
|
|
|
begin
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.UpdateList();
|
|
|
|
var
|
2007-12-09 12:02:11 +00:00
|
|
|
activeUnit: TBaseSwItem;
|
|
|
|
activeUnits: TBaseSwItemList;
|
2007-12-07 15:33:00 +00:00
|
|
|
itemIndex: Integer;
|
|
|
|
listIndex: Integer;
|
2007-12-09 12:02:11 +00:00
|
|
|
filteredList: TBaseSwItemList;
|
2007-12-07 15:33:00 +00:00
|
|
|
selStart: Integer;
|
|
|
|
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
activeUnits := GetActiveItems();
|
2007-12-07 15:33:00 +00:00
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
filteredList := CreateItemList();
|
2007-12-07 15:33:00 +00:00
|
|
|
try
|
|
|
|
filteredList.Clone(FSubFilteredList);
|
|
|
|
FInputFilter.FilterList(filteredList);
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
if (filteredList.Count = 0) and (not AllowEmptyResult) then
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
|
|
|
{ Only enforce AllowEmptyResult when adding to the filter }
|
|
|
|
if Length(FInputFilter.Filter) > Length(FLastFilter) then
|
|
|
|
begin
|
|
|
|
FInputFilter.Filter := FLastFilter;
|
|
|
|
selStart := cmbSearch.SelStart;
|
|
|
|
cmbSearch.Text := FLastFilter;
|
|
|
|
cmbSearch.SelStart := selStart;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
FLastFilter := FInputFilter.Filter;
|
|
|
|
FInputFilteredList.Clone(filteredList);
|
|
|
|
finally
|
|
|
|
FreeAndNil(filteredList);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
lstItems.Count := FInputFilteredList.Count;
|
|
|
|
if FInputFilteredList.Count > 0 then
|
|
|
|
begin
|
|
|
|
lstItems.ClearSelection();
|
|
|
|
|
|
|
|
if Assigned(activeUnits) then
|
|
|
|
try
|
|
|
|
for itemIndex := 0 to Pred(activeUnits.Count) do
|
|
|
|
begin
|
|
|
|
activeUnit := activeUnits[itemIndex];
|
|
|
|
listIndex := FInputFilteredList.IndexOf(activeUnit);
|
|
|
|
if listIndex > -1 then
|
|
|
|
lstItems.Selected[listIndex] := True;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FreeAndNil(activeUnits);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if lstItems.SelCount = 0 then
|
|
|
|
lstItems.Selected[0] := True;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if Assigned(lstItems.OnClick) then
|
|
|
|
lstItems.OnClick(nil);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.PopFilter();
|
|
|
|
begin
|
|
|
|
if FSubFilters.Count > 0 then
|
|
|
|
begin
|
|
|
|
FSubFilters.Delete(Pred(FSubFilters.Count));
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.UpdateSubFilters();
|
|
|
|
var
|
|
|
|
iFilter: Integer;
|
|
|
|
sFilters: String;
|
|
|
|
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
FSubFilteredList.Clone(GetBaseItemList());
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
if FSubFilters.Count > 0 then
|
|
|
|
begin
|
|
|
|
for iFilter := 0 to Pred(FSubFilters.Count) do
|
|
|
|
begin
|
|
|
|
sFilters := sFilters + FSubFilters[iFilter] + SubFilterSeparator;
|
|
|
|
FSubFilter.Filter := FSubFilters[iFilter];
|
|
|
|
FSubFilter.FilterList(FSubFilteredList);
|
|
|
|
end;
|
|
|
|
|
|
|
|
lblSubFilters.Caption := Trim(sFilters);
|
|
|
|
pnlSubFilters.Visible := True;
|
|
|
|
end else
|
|
|
|
pnlSubFilters.Visible := False;
|
|
|
|
|
|
|
|
UpdateList();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrmBaseSwDialog.PushFilter(const AFilter: String): Boolean;
|
|
|
|
var
|
|
|
|
sFilter: String;
|
|
|
|
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
sFilter := Trim(AFilter);
|
2007-12-07 15:33:00 +00:00
|
|
|
Result := (Length(sFilter) > 0) and (FSubFilters.IndexOf(AFilter) = -1);
|
|
|
|
if Result then
|
|
|
|
begin
|
|
|
|
FSubFilters.Add(AFilter);
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.GetActiveItems(): TBaseSwItemList;
|
2007-12-07 15:33:00 +00:00
|
|
|
var
|
|
|
|
itemIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
if Assigned(ActiveItem) then
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
Result := CreateItemList();
|
2007-12-07 15:33:00 +00:00
|
|
|
Result.OwnsObjects := False;
|
2007-12-09 12:02:11 +00:00
|
|
|
Result.Add(ActiveItem);
|
|
|
|
ActiveItem := nil;
|
2007-12-07 15:33:00 +00:00
|
|
|
end else if lstItems.SelCount > 0 then
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
Result := CreateItemList();
|
2007-12-07 15:33:00 +00:00
|
|
|
Result.OwnsObjects := False;
|
|
|
|
|
|
|
|
for itemIndex := 0 to Pred(lstItems.Items.Count) do
|
|
|
|
if lstItems.Selected[itemIndex] then
|
|
|
|
Result.Add(FInputFilteredList[itemIndex]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.GetBaseItemList(): TBaseSwItemList;
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
Result := ItemList;
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.GetItemDisplayName(const AItem: TBaseSwItem): String;
|
|
|
|
begin
|
|
|
|
Result := AItem.Name;
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.ColorsEnabled(): Boolean;
|
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
2007-12-07 15:33:00 +00:00
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.CreateItemList(): TBaseSwItemList;
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
Result := TBaseSwItemList.Create();
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.CreateInputFilter(): TBaseSwItemSimpleFilter;
|
|
|
|
begin
|
|
|
|
Result := TBaseSwItemSimpleNameFilter.Create();
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmBaseSwDialog.CreateStyleVisitor(): TBaseSwStyleVisitor;
|
|
|
|
begin
|
|
|
|
Result := nil;
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.actSelectAllExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
lstItems.SelectAll();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.actSelectInvertExecute(Sender: TObject);
|
|
|
|
var
|
|
|
|
iItem: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
for iItem := Pred(lstItems.Count) downto 0 do
|
|
|
|
lstItems.Selected[iItem] := not lstItems.Selected[iItem];
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TfrmBaseSwDialog.btnOKClick(Sender: TObject);
|
2007-12-07 15:33:00 +00:00
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
ModalResult := mrOk;
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.SelectMRUItem();
|
|
|
|
begin
|
|
|
|
cmbSearch.ItemIndex := FMRUIndex;
|
|
|
|
ActiveControl := cmbSearch;
|
|
|
|
cmbSearch.SelectAll();
|
|
|
|
|
|
|
|
if Assigned(cmbSearch.OnChange) then
|
|
|
|
cmbSearch.OnChange(nil);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.actMRUNextExecute(Sender: TObject);
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
if FMRUIndex < Pred(MRUList.Count) then
|
2007-12-07 15:33:00 +00:00
|
|
|
Inc(FMRUIndex);
|
|
|
|
|
|
|
|
SelectMRUItem();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.actMRUPriorExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if FMRUIndex >= -1 then
|
|
|
|
Dec(FMRUIndex);
|
|
|
|
|
|
|
|
SelectMRUItem();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.cmbSearchChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if cmbSearch.Text <> FInputFilter.Filter then
|
|
|
|
begin
|
|
|
|
FInputFilter.Filter := cmbSearch.Text;
|
|
|
|
UpdateList();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.cmbSearchKeyDown(Sender: TObject; var Key: Word;
|
|
|
|
Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if not cmbSearch.DroppedDown then
|
|
|
|
if ((Shift = []) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) or
|
|
|
|
((Shift = [ssCtrl]) and (Key in [VK_HOME, VK_END])) or
|
|
|
|
((Shift = [ssShift]) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) then
|
|
|
|
begin
|
|
|
|
lstItems.Perform(WM_KEYDOWN, Key, 0);
|
|
|
|
Key := 0;
|
|
|
|
end else if Shift = [ssCtrl] then
|
|
|
|
case Key of
|
|
|
|
VK_TAB:
|
|
|
|
begin
|
|
|
|
if PushFilter(cmbSearch.Text) then
|
|
|
|
cmbSearch.Text := '';
|
|
|
|
|
|
|
|
Key := 0;
|
|
|
|
end;
|
|
|
|
VK_BACK:
|
|
|
|
begin
|
|
|
|
cmbSearch.Text := '';
|
|
|
|
FInputFilter.Filter := '';
|
|
|
|
PopFilter();
|
|
|
|
Key := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.cmbSearchKeyPress(Sender: TObject; var Key: Char);
|
|
|
|
begin
|
|
|
|
// Ctrl-Backspace
|
|
|
|
if Key = #127 then
|
|
|
|
Key := #0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.lstItemsDblClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
btnOK.Click();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.lstItemsClick(Sender: TObject);
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
UpdateItemActions();
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.lstItemsData(Control: TWinControl; Index: Integer;
|
|
|
|
var Data: string);
|
|
|
|
begin
|
|
|
|
Data := FInputFilteredList[Index].Name;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.lstItemsDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
Rect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
2007-12-09 12:02:11 +00:00
|
|
|
currentItem: TBaseSwItem;
|
2007-12-07 15:33:00 +00:00
|
|
|
textRect: TRect;
|
|
|
|
text: String;
|
|
|
|
|
|
|
|
begin
|
|
|
|
with TListBox(Control) do
|
|
|
|
begin
|
2007-12-09 12:02:11 +00:00
|
|
|
currentItem := FInputFilteredList[Index];
|
|
|
|
if Assigned(FStyleVisitor) then
|
|
|
|
currentItem.AcceptVisitor(FStyleVisitor);
|
|
|
|
|
|
|
|
text := GetItemDisplayName(currentItem);
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
if odSelected in State then
|
|
|
|
begin
|
|
|
|
Canvas.Brush.Color := clHighlight;
|
|
|
|
Canvas.Font.Color := clHighlightText;
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
Canvas.Brush.Color := clWindow;
|
2007-12-09 12:02:11 +00:00
|
|
|
|
|
|
|
if Assigned(FStyleVisitor) and ColorsEnabled() then
|
2007-12-07 15:33:00 +00:00
|
|
|
Canvas.Font.Color := FStyleVisitor.Color
|
|
|
|
else
|
|
|
|
Canvas.Font.Color := clWindowText;
|
|
|
|
end;
|
|
|
|
Canvas.FillRect(Rect);
|
|
|
|
|
|
|
|
textRect := Rect;
|
|
|
|
InflateRect(textRect, -2, -2);
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
if Assigned(FStyleVisitor) then
|
|
|
|
begin
|
|
|
|
ilsTypes.Draw(Canvas, textRect.Left, textRect.Top, FStyleVisitor.ImageIndex);
|
|
|
|
|
|
|
|
if FStyleVisitor.OverlayIndex > -1 then
|
|
|
|
ilsTypes.Draw(Canvas, textRect.Left, textRect.Top, FStyleVisitor.OverlayIndex);
|
|
|
|
end;
|
2007-12-07 15:33:00 +00:00
|
|
|
|
|
|
|
Inc(textRect.Left, ilsTypes.Width + 4);
|
|
|
|
DrawText(Canvas.Handle, PChar(text), Length(text), textRect, DT_SINGLELINE or
|
|
|
|
DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmBaseSwDialog.lstItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|
|
|
var
|
|
|
|
itemIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
{ Bij rechtermuisknop het item selecteren indien deze niet al
|
|
|
|
geselecteerd was }
|
|
|
|
if Button = mbRight then
|
|
|
|
begin
|
|
|
|
itemIndex := lstItems.ItemAtPos(Point(X, Y), True);
|
|
|
|
if (itemIndex > -1) and (not lstItems.Selected[itemIndex]) then
|
|
|
|
begin
|
|
|
|
lstItems.ClearSelection;
|
|
|
|
lstItems.Selected[itemIndex] := True;
|
2007-12-09 12:02:11 +00:00
|
|
|
UpdateItemActions();
|
2007-12-07 15:33:00 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|