2007-12-09 12:02:11 +00:00
|
|
|
unit CmpSwDialog;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
ActnList,
|
|
|
|
Classes,
|
|
|
|
ComCtrls,
|
2007-12-11 19:41:46 +00:00
|
|
|
Contnrs,
|
2007-12-09 12:02:11 +00:00
|
|
|
Controls,
|
|
|
|
ExtCtrls,
|
2007-12-10 20:29:57 +00:00
|
|
|
Graphics,
|
2007-12-09 12:02:11 +00:00
|
|
|
ImgList,
|
2007-12-10 16:13:05 +00:00
|
|
|
IniFiles,
|
2007-12-09 12:02:11 +00:00
|
|
|
Menus,
|
|
|
|
StdCtrls,
|
2007-12-10 20:29:57 +00:00
|
|
|
Windows,
|
2007-12-09 12:02:11 +00:00
|
|
|
|
|
|
|
BaseSwDialog,
|
2007-12-10 20:29:57 +00:00
|
|
|
BaseSwObjects,
|
2007-12-19 14:11:31 +00:00
|
|
|
CmpSwFilters;
|
2007-12-09 12:02:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TCmpSwStyleVisitor = class(TBaseSwStyleVisitor)
|
2007-12-10 16:13:05 +00:00
|
|
|
private
|
|
|
|
FImageList: TImageList;
|
|
|
|
FImageMap: TStringHash;
|
2007-12-09 12:02:11 +00:00
|
|
|
protected
|
|
|
|
procedure VisitItem(const AItem: TBaseSwItem); override;
|
2007-12-16 13:06:21 +00:00
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
function GetComponentPackage(const AClassName: String): String;
|
|
|
|
function LoadComponentImage(const APackageName, AClassName: String): Integer;
|
2007-12-10 20:29:57 +00:00
|
|
|
procedure ResizeBitmap(const ABitmap: Graphics.TBitmap; const AWidth, AHeight: Integer);
|
2007-12-10 16:13:05 +00:00
|
|
|
public
|
|
|
|
constructor Create(AImageList: TImageList);
|
|
|
|
destructor Destroy(); override;
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
TfrmCmpSwDialog = class(TfrmBaseSwDialog)
|
2007-12-11 19:41:46 +00:00
|
|
|
pmnItemsSep1: TMenuItem;
|
|
|
|
pmnItemsFilters: TMenuItem;
|
|
|
|
pmnItemsFilterSelected: TMenuItem;
|
|
|
|
actFilterSelected: TAction;
|
|
|
|
pnlFilters: TPanel;
|
|
|
|
gbFilters: TGroupBox;
|
|
|
|
btnMoreFilters: TButton;
|
|
|
|
pmnMoreFilters: TPopupMenu;
|
2007-12-12 10:18:59 +00:00
|
|
|
actSortByName: TAction;
|
|
|
|
actSortByType: TAction;
|
|
|
|
pmnItemsSortByName: TMenuItem;
|
|
|
|
pmnItemsSortByType: TMenuItem;
|
|
|
|
pmnItemsSep2: TMenuItem;
|
2007-12-14 15:38:55 +00:00
|
|
|
btnConfiguration: TButton;
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
procedure btnMoreFiltersClick(Sender: TObject);
|
|
|
|
procedure FormShow(Sender: TObject);
|
2007-12-12 10:18:59 +00:00
|
|
|
procedure SortExecute(Sender: TObject);
|
2007-12-14 15:38:55 +00:00
|
|
|
procedure btnConfigurationClick(Sender: TObject);
|
2007-12-10 20:29:57 +00:00
|
|
|
private
|
|
|
|
FClassFilteredList: TBaseSwItemList;
|
|
|
|
FClassFilter: TCmpSwComponentClassFilter;
|
2007-12-11 19:41:46 +00:00
|
|
|
|
|
|
|
FFilterCheckBoxes: TObjectList;
|
2007-12-12 10:18:59 +00:00
|
|
|
FOtherGroup: TCmpSwFilterGroup;
|
2007-12-09 12:02:11 +00:00
|
|
|
protected
|
2007-12-10 20:29:57 +00:00
|
|
|
function InternalExecute(): TBaseSwItemList; override;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function CreateStyleVisitor(): TBaseSwStyleVisitor; override;
|
2007-12-10 20:29:57 +00:00
|
|
|
function GetBaseItemList(): TBaseSwItemList; override;
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
function AllowEmptyResult(): Boolean; override;
|
|
|
|
function ColorsEnabled(): Boolean; override;
|
2009-05-01 08:44:18 +00:00
|
|
|
function Wildchars(): Boolean; override;
|
2007-12-12 10:18:59 +00:00
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
procedure LoadSettings(); override;
|
|
|
|
procedure SaveSettings(); override;
|
2009-05-01 08:44:18 +00:00
|
|
|
procedure SettingsChanged(); override;
|
2007-12-10 20:29:57 +00:00
|
|
|
|
2008-01-10 13:42:52 +00:00
|
|
|
procedure DrawItemText(ACanvas: TCanvas; AItem: TBaseSwItem; ARect: TRect; AState: TOwnerDrawState); override;
|
2007-12-10 20:29:57 +00:00
|
|
|
procedure UpdateClassFilter();
|
2007-12-12 10:18:59 +00:00
|
|
|
procedure SortList();
|
2007-12-11 19:41:46 +00:00
|
|
|
|
|
|
|
procedure BuildFilterCheckboxes();
|
|
|
|
function CreateFilterMenuItem(AParent: TMenuItem; AGroup: TCmpSwFilterGroup; AItemIndex: Integer): TMenuItem;
|
|
|
|
|
|
|
|
procedure FilterCheckBoxClick(Sender: TObject);
|
|
|
|
procedure FilterMenuItemClick(Sender: TObject);
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
property ClassFilter: TCmpSwComponentClassFilter read FClassFilter;
|
|
|
|
property ClassFilteredList: TBaseSwItemList read FClassFilteredList;
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
2007-12-10 16:13:05 +00:00
|
|
|
uses
|
|
|
|
SysUtils,
|
|
|
|
ToolsAPI,
|
|
|
|
|
2007-12-14 15:38:55 +00:00
|
|
|
CmpSwConfiguration,
|
2007-12-11 19:41:46 +00:00
|
|
|
CmpSwObjects,
|
|
|
|
CmpSwSettings;
|
2007-12-09 12:02:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TCmpSwStyleVisitor }
|
2007-12-10 16:13:05 +00:00
|
|
|
constructor TCmpSwStyleVisitor.Create(AImageList: TImageList);
|
|
|
|
begin
|
|
|
|
inherited Create();
|
|
|
|
|
|
|
|
FImageList := AImageList;
|
|
|
|
FImageMap := TStringHash.Create();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TCmpSwStyleVisitor.Destroy();
|
|
|
|
begin
|
|
|
|
FreeAndNil(FImageMap);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
procedure TCmpSwStyleVisitor.VisitItem(const AItem: TBaseSwItem);
|
2007-12-10 16:13:05 +00:00
|
|
|
var
|
|
|
|
component: TCmpSwComponent;
|
|
|
|
package: String;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
component := (AItem as TCmpSwComponent);
|
|
|
|
ImageIndex := FImageMap.ValueOf(component.ComponentClass);
|
|
|
|
|
|
|
|
if ImageIndex = -1 then
|
|
|
|
begin
|
|
|
|
package := GetComponentPackage(component.ComponentClass);
|
|
|
|
if Length(package) > 0 then
|
|
|
|
ImageIndex := LoadComponentImage(package, component.ComponentClass);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ImageIndex = -2 then
|
2007-12-10 20:29:57 +00:00
|
|
|
ImageIndex := -1;
|
2007-12-10 16:13:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TCmpSwStyleVisitor.GetComponentPackage(const AClassName: String): String;
|
|
|
|
var
|
|
|
|
packageServices: IOTAPackageServices;
|
|
|
|
packageIndex: Integer;
|
|
|
|
componentIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := '';
|
|
|
|
packageServices := (BorlandIDEServices as IOTAPackageServices);
|
|
|
|
|
|
|
|
for packageIndex := Pred(packageServices.PackageCount) downto 0 do
|
|
|
|
begin
|
|
|
|
for componentIndex := Pred(packageServices.ComponentCount[packageIndex]) downto 0 do
|
|
|
|
begin
|
|
|
|
if SameText(packageServices.ComponentNames[packageIndex, componentIndex],
|
|
|
|
AClassName) then
|
|
|
|
begin
|
2007-12-10 20:29:57 +00:00
|
|
|
Result := packageServices.PackageNames[packageIndex];
|
|
|
|
|
|
|
|
{ Delphi 7 doesn't add the .bpl extension, BDS 2006 does, let's just
|
|
|
|
take the safe route and check }
|
|
|
|
if not SameText(ExtractFileExt(Result), '.bpl') then
|
|
|
|
Result := Result + '.bpl';
|
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TCmpSwStyleVisitor.LoadComponentImage(const APackageName, AClassName: String): Integer;
|
|
|
|
var
|
|
|
|
packageHandle: THandle;
|
|
|
|
bitmapHandle: THandle;
|
2007-12-10 20:29:57 +00:00
|
|
|
bitmap: Graphics.TBitmap;
|
2007-12-19 14:11:31 +00:00
|
|
|
transpColor: TColor;
|
2007-12-10 16:13:05 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
Result := -1;
|
|
|
|
packageHandle := LoadLibrary(PChar(APackageName));
|
|
|
|
|
|
|
|
if packageHandle <> 0 then
|
|
|
|
try
|
2007-12-10 20:29:57 +00:00
|
|
|
{ BDS includes 16x16 versions of the component bitmaps, try those first }
|
|
|
|
bitmapHandle := LoadBitmap(packageHandle, PChar(AClassName + '16'));
|
|
|
|
if bitmapHandle = 0 then
|
|
|
|
bitmapHandle := LoadBitmap(packageHandle, PChar(AClassName));
|
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
if bitmapHandle <> 0 then
|
|
|
|
begin
|
2007-12-10 20:29:57 +00:00
|
|
|
bitmap := Graphics.TBitmap.Create();
|
|
|
|
try
|
|
|
|
bitmap.Handle := bitmapHandle;
|
2007-12-19 14:11:31 +00:00
|
|
|
transpColor := bitmap.TransparentColor;
|
2007-12-10 20:29:57 +00:00
|
|
|
|
|
|
|
if (bitmap.Width <> FImageList.Width) or
|
|
|
|
(bitmap.Height <> FImageList.Height) then
|
|
|
|
begin
|
|
|
|
ResizeBitmap(bitmap, FImageList.Width, FImageList.Height);
|
|
|
|
end;
|
|
|
|
|
2007-12-19 14:11:31 +00:00
|
|
|
Result := FImageList.AddMasked(bitmap, transpColor);
|
2007-12-10 20:29:57 +00:00
|
|
|
finally
|
|
|
|
FreeAndNil(bitmap);
|
|
|
|
end;
|
2007-12-10 16:13:05 +00:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FreeLibrary(packageHandle);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if Result = -1 then
|
|
|
|
Result := -2;
|
|
|
|
|
|
|
|
FImageMap.Add(AClassName, Result);
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-10 20:29:57 +00:00
|
|
|
procedure TCmpSwStyleVisitor.ResizeBitmap(const ABitmap: Graphics.TBitmap;
|
|
|
|
const AWidth, AHeight: Integer);
|
|
|
|
var
|
|
|
|
tempBitmap: Graphics.TBitmap;
|
|
|
|
|
|
|
|
begin
|
|
|
|
tempBitmap := Graphics.TBitmap.Create();
|
|
|
|
try
|
|
|
|
tempBitmap.PixelFormat := pf24bit;
|
|
|
|
tempBitmap.Width := AWidth;
|
|
|
|
tempBitmap.Height := AHeight;
|
|
|
|
|
|
|
|
tempBitmap.Canvas.CopyRect(Rect(0, 0, AWidth, AHeight), ABitmap.Canvas,
|
|
|
|
Rect(0, 0, ABitmap.Width, ABitmap.Height));
|
|
|
|
|
|
|
|
ABitmap.Assign(tempBitmap);
|
|
|
|
finally
|
|
|
|
FreeAndNil(tempBitmap);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
{ TfrmCmpSwDialog }
|
2007-12-10 20:29:57 +00:00
|
|
|
function TfrmCmpSwDialog.InternalExecute(): TBaseSwItemList;
|
|
|
|
begin
|
|
|
|
FClassFilteredList := TBaseSwItemList.Create();
|
|
|
|
FClassFilter := TCmpSwComponentClassFilter.Create();
|
2007-12-11 19:41:46 +00:00
|
|
|
FFilterCheckBoxes := TObjectList.Create();
|
2007-12-12 10:18:59 +00:00
|
|
|
FOtherGroup := TCmpSwFilterGroup.Create(nil);
|
2007-12-10 20:29:57 +00:00
|
|
|
try
|
2009-05-01 08:44:18 +00:00
|
|
|
ClassFilter.Groups := Settings.FilterGroups;
|
2007-12-14 15:38:55 +00:00
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
FOtherGroup.Name := 'Other';
|
|
|
|
FOtherGroup.Enabled := False;
|
|
|
|
FOtherGroup.Visible := False;
|
|
|
|
|
|
|
|
Result := inherited InternalExecute();
|
2007-12-10 20:29:57 +00:00
|
|
|
finally
|
2007-12-12 10:18:59 +00:00
|
|
|
FreeAndNil(FOtherGroup);
|
2007-12-11 19:41:46 +00:00
|
|
|
FreeAndNil(FFilterCheckBoxes);
|
2007-12-10 20:29:57 +00:00
|
|
|
FreeAndNil(FClassFilter);
|
|
|
|
FreeAndNil(FClassFilteredList);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
procedure TfrmCmpSwDialog.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateClassFilter();
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
function TfrmCmpSwDialog.CreateStyleVisitor(): TBaseSwStyleVisitor;
|
|
|
|
begin
|
2007-12-10 16:13:05 +00:00
|
|
|
Result := TCmpSwStyleVisitor.Create(ilsTypes);
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
2007-12-10 20:29:57 +00:00
|
|
|
|
2008-01-10 13:42:52 +00:00
|
|
|
procedure TfrmCmpSwDialog.DrawItemText(ACanvas: TCanvas; AItem: TBaseSwItem; ARect: TRect; AState: TOwnerDrawState);
|
2007-12-10 20:29:57 +00:00
|
|
|
var
|
2007-12-11 19:41:46 +00:00
|
|
|
text: String;
|
|
|
|
textRect: TRect;
|
2007-12-10 20:29:57 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
{ Calculate item text rectangle }
|
|
|
|
text := GetItemDisplayName(AItem);
|
|
|
|
textRect := ARect;
|
|
|
|
DrawText(ACanvas.Handle, PChar(text), Length(text), textRect, DT_SINGLELINE or
|
|
|
|
DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS or DT_CALCRECT);
|
|
|
|
|
|
|
|
textRect.Left := textRect.Right;
|
2007-12-12 10:18:59 +00:00
|
|
|
textRect.Right := ARect.Right - 2;
|
2007-12-11 19:41:46 +00:00
|
|
|
|
|
|
|
{ Draw component class text }
|
2008-01-10 13:42:52 +00:00
|
|
|
if not (odSelected in AState) then
|
|
|
|
ACanvas.Font.Color := clGrayText;
|
|
|
|
|
2007-12-10 20:29:57 +00:00
|
|
|
text := (AItem as TCmpSwComponent).ComponentClass;
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
DrawText(ACanvas.Handle, PChar(text), Length(text), textRect, DT_SINGLELINE or
|
|
|
|
DT_RIGHT or DT_VCENTER or DT_END_ELLIPSIS);
|
2007-12-10 20:29:57 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.UpdateClassFilter();
|
2007-12-11 19:41:46 +00:00
|
|
|
var
|
|
|
|
groupIndex: Integer;
|
|
|
|
itemIndex: Integer;
|
|
|
|
|
2007-12-10 20:29:57 +00:00
|
|
|
begin
|
2007-12-11 19:41:46 +00:00
|
|
|
{ Update / extend the menu }
|
|
|
|
itemIndex := 0;
|
|
|
|
for groupIndex := 0 to Pred(ClassFilter.Groups.Count) do
|
|
|
|
begin
|
|
|
|
if ClassFilter.Groups[groupIndex].Visible then
|
|
|
|
begin
|
|
|
|
CreateFilterMenuItem(pmnItemsFilters, ClassFilter.Groups[groupIndex], itemIndex);
|
|
|
|
Inc(itemIndex);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
CreateFilterMenuItem(pmnItemsFilters, FOtherGroup, itemIndex);
|
|
|
|
Inc(itemIndex);
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
{ Remove excess menu items }
|
|
|
|
for groupIndex := Pred(pmnItemsFilters.Count) downto itemIndex do
|
|
|
|
pmnItemsFilters.Delete(groupIndex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
itemIndex := 0;
|
|
|
|
for groupIndex := 0 to Pred(ClassFilter.Groups.Count) do
|
|
|
|
begin
|
|
|
|
if not ClassFilter.Groups[groupIndex].Visible then
|
|
|
|
begin
|
|
|
|
CreateFilterMenuItem(pmnMoreFilters.Items, ClassFilter.Groups[groupIndex], itemIndex);
|
|
|
|
Inc(itemIndex);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
CreateFilterMenuItem(pmnMoreFilters.Items, FOtherGroup, itemIndex);
|
|
|
|
Inc(itemIndex);
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
for groupIndex := Pred(pmnMoreFilters.Items.Count) downto itemIndex do
|
|
|
|
pmnMoreFilters.Items.Delete(groupIndex);
|
|
|
|
|
|
|
|
|
|
|
|
BuildFilterCheckboxes();
|
|
|
|
btnMoreFilters.Visible := (pmnMoreFilters.Items.Count > 0);
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
ClassFilteredList.Clone(ItemList);
|
|
|
|
|
|
|
|
ClassFilter.FilterUnmatched := FOtherGroup.Enabled;
|
|
|
|
ClassFilter.FilterList(ClassFilteredList);
|
|
|
|
SortList();
|
2007-12-10 20:29:57 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrmCmpSwDialog.GetBaseItemList(): TBaseSwItemList;
|
|
|
|
begin
|
2007-12-12 10:18:59 +00:00
|
|
|
Result := ClassFilteredList;
|
2007-12-11 19:41:46 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.BuildFilterCheckboxes();
|
|
|
|
var
|
|
|
|
checkBox: TCheckBox;
|
|
|
|
checkBoxTop: Integer;
|
|
|
|
childIndex: Integer;
|
|
|
|
group: TCmpSwFilterGroup;
|
|
|
|
groupIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
for childIndex := Pred(gbFilters.ControlCount) downto 0 do
|
|
|
|
if gbFilters.Controls[childIndex] is TCheckBox then
|
|
|
|
gbFilters.Controls[childIndex].Free;
|
|
|
|
|
|
|
|
// #ToDo3 (MvR) 11-12-2007: get rid of a few "magic" numbers
|
|
|
|
checkBoxTop := 16;
|
|
|
|
|
|
|
|
for groupIndex := 0 to Pred(ClassFilter.Groups.Count) do
|
|
|
|
begin
|
|
|
|
group := ClassFilter.Groups[groupIndex];
|
|
|
|
|
2007-12-16 13:06:21 +00:00
|
|
|
if group.Visible then
|
2007-12-11 19:41:46 +00:00
|
|
|
begin
|
|
|
|
checkBox := TCheckBox.Create(Self);
|
|
|
|
checkBox.Top := checkBoxTop;
|
|
|
|
checkBox.Left := 12;
|
|
|
|
checkBox.Caption := StringReplace(group.Name, '&', '&&', [rfReplaceAll]);
|
2007-12-12 10:18:59 +00:00
|
|
|
checkBox.Checked := not group.Enabled;
|
2007-12-11 19:41:46 +00:00
|
|
|
checkBox.Tag := Integer(group);
|
|
|
|
checkBox.OnClick := FilterCheckBoxClick;
|
2007-12-16 13:06:21 +00:00
|
|
|
checkBox.Width := gbFilters.ClientWidth - 24;
|
|
|
|
checkBox.Anchors := [akLeft, akTop, akRight];
|
2007-12-11 19:41:46 +00:00
|
|
|
checkBox.Parent := gbFilters;
|
|
|
|
|
|
|
|
Inc(checkBoxTop, 20);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-12-16 13:06:21 +00:00
|
|
|
btnMoreFilters.BringToFront();
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
pnlFilters.Height := (2 * pnlFilters.BorderWidth) + checkBoxTop + 11;
|
2007-12-16 13:06:21 +00:00
|
|
|
pnlButtons.Top := pnlFilters.Top + pnlFilters.Height;
|
|
|
|
sbStatus.Top := MaxInt;
|
2007-12-11 19:41:46 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrmCmpSwDialog.CreateFilterMenuItem(AParent: TMenuItem; AGroup: TCmpSwFilterGroup; AItemIndex: Integer): TMenuItem;
|
|
|
|
begin
|
|
|
|
if (AItemIndex = -1) or (AItemIndex >= AParent.Count) then
|
|
|
|
begin
|
|
|
|
Result := TMenuItem.Create(Self);
|
|
|
|
Result.OnClick := FilterMenuItemClick;
|
|
|
|
|
|
|
|
AParent.Add(Result);
|
|
|
|
end else
|
|
|
|
Result := AParent[AItemIndex];
|
|
|
|
|
|
|
|
Result.Caption := StringReplace(AGroup.Name, '&', '&&', [rfReplaceAll]);
|
2007-12-12 10:18:59 +00:00
|
|
|
Result.Checked := not AGroup.Enabled;
|
2007-12-11 19:41:46 +00:00
|
|
|
Result.Tag := Integer(AGroup);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.FilterCheckBoxClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
checkBox: TCheckBox;
|
|
|
|
group: TCmpSwFilterGroup;
|
|
|
|
|
|
|
|
begin
|
|
|
|
checkBox := (Sender as TCheckBox);
|
|
|
|
group := TCmpSwFilterGroup(checkBox.Tag);
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
if checkBox.Checked = group.Enabled then
|
2007-12-11 19:41:46 +00:00
|
|
|
begin
|
2007-12-12 10:18:59 +00:00
|
|
|
group.Enabled := not checkBox.Checked;
|
2007-12-11 19:41:46 +00:00
|
|
|
|
|
|
|
UpdateClassFilter();
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.FilterMenuItemClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
menuItem: TMenuItem;
|
|
|
|
group: TCmpSwFilterGroup;
|
|
|
|
|
|
|
|
begin
|
|
|
|
menuItem := (Sender as TMenuItem);
|
|
|
|
group := TCmpSwFilterGroup(menuItem.Tag);
|
|
|
|
|
|
|
|
group.Enabled := menuItem.Checked;
|
2007-12-12 10:18:59 +00:00
|
|
|
menuItem.Checked := not menuItem.Checked;
|
2007-12-11 19:41:46 +00:00
|
|
|
|
|
|
|
UpdateClassFilter();
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.btnMoreFiltersClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
buttonPos: TPoint;
|
|
|
|
|
|
|
|
begin
|
|
|
|
buttonPos := btnMoreFilters.ClientToScreen(Point(btnMoreFilters.Width, 0));
|
|
|
|
pmnMoreFilters.Popup(buttonPos.X, buttonPos.Y);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.LoadSettings();
|
|
|
|
begin
|
|
|
|
Self.ClientWidth := Settings.Dialog.Width;
|
|
|
|
Self.ClientHeight := Settings.Dialog.Height;
|
|
|
|
MRUList.Assign(Settings.Dialog.MRUList);
|
|
|
|
|
|
|
|
inherited LoadSettings();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.SaveSettings();
|
|
|
|
begin
|
2007-12-12 10:18:59 +00:00
|
|
|
// #ToDo2 (MvR) 12-12-2007: save 'sort by ...'
|
|
|
|
|
2007-12-11 19:41:46 +00:00
|
|
|
Settings.Dialog.Width := Self.ClientWidth;
|
|
|
|
Settings.Dialog.Height := Self.ClientHeight;
|
|
|
|
Settings.Dialog.MRUList.Assign(MRUList);
|
|
|
|
Settings.Save();
|
|
|
|
|
|
|
|
inherited SaveSettings();
|
2007-12-10 20:29:57 +00:00
|
|
|
end;
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
function TfrmCmpSwDialog.AllowEmptyResult(): Boolean;
|
|
|
|
begin
|
2009-05-01 08:44:18 +00:00
|
|
|
Result := Settings.Filter.AllowEmptyResult;
|
2007-12-12 10:18:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrmCmpSwDialog.ColorsEnabled(): Boolean;
|
|
|
|
begin
|
|
|
|
Result := inherited ColorsEnabled();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2009-05-01 08:44:18 +00:00
|
|
|
function TfrmCmpSwDialog.Wildchars(): Boolean;
|
|
|
|
begin
|
|
|
|
Result := Settings.Filter.Wildchars;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-12-12 10:18:59 +00:00
|
|
|
procedure TfrmCmpSwDialog.SortExecute(Sender: TObject);
|
|
|
|
begin
|
|
|
|
(Sender as TAction).Checked := True;
|
|
|
|
SortList();
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function SortByName(Item1, Item2: Pointer): Integer;
|
|
|
|
begin
|
|
|
|
Result := CompareText(TCmpSwComponent(Item1).Name, TCmpSwComponent(Item2).Name);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function SortByType(Item1, Item2: Pointer): Integer;
|
|
|
|
begin
|
|
|
|
Result := CompareText(TCmpSwComponent(Item1).ComponentClass, TCmpSwComponent(Item2).ComponentClass);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.SortList();
|
|
|
|
begin
|
|
|
|
if actSortByType.Checked then
|
|
|
|
ClassFilteredList.Sort(SortByType)
|
|
|
|
else
|
|
|
|
ClassFilteredList.Sort(SortByName);
|
|
|
|
end;
|
|
|
|
|
2007-12-14 15:38:55 +00:00
|
|
|
|
|
|
|
procedure TfrmCmpSwDialog.btnConfigurationClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if TfrmCmpSwConfiguration.Execute() then
|
|
|
|
begin
|
2009-05-01 08:44:18 +00:00
|
|
|
SettingsChanged();
|
2007-12-14 15:38:55 +00:00
|
|
|
UpdateClassFilter();
|
|
|
|
UpdateSubFilters();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-05-01 08:44:18 +00:00
|
|
|
procedure TfrmCmpSwDialog.SettingsChanged;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2007-12-09 12:02:11 +00:00
|
|
|
end.
|