82 lines
2.1 KiB
ObjectPascal
82 lines
2.1 KiB
ObjectPascal
unit uEditorRegistryUtils;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, Forms, uClassRegistryUtils, uCustomEditor;
|
|
|
|
type
|
|
{
|
|
IEditorRegistry = interface (IComponentRegistry)
|
|
22F14B82-AC61-4987-847E-AF8513DE2A10
|
|
function CreateEditor(const aClassOrDisplayname: String;
|
|
aOwner: TComponent = NIL): TCustomEditor;
|
|
end;
|
|
|
|
TEditorRegistry = class(TComponentRegistry, IEditorRegistry)
|
|
protected
|
|
procedure ValidateMinAcceptableClass(var aMinAcceptableClass: TClass); override;
|
|
function CreateEditor(const aClassOrDisplayname: String;
|
|
aOwner: TComponent = nil): TCustomEditor;
|
|
end;
|
|
}
|
|
|
|
IEditorRegistry = interface (IFormRegistry)
|
|
['{F6AC050F-5547-4E1F-AA44-DA0D06EDA4D7}']
|
|
function CreateEditor(const aClassOrDisplayname: String;
|
|
aOwner: TComponent = NIL): TForm;
|
|
end;
|
|
|
|
TEditorRegistry = class(TFormRegistry, IEditorRegistry)
|
|
protected
|
|
function CreateEditor(const aClassOrDisplayname: String;
|
|
aOwner: TComponent = nil): TForm;
|
|
end;
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
var
|
|
EditorRegistry : IEditorRegistry;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, cxControls;
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Supports(EditorRegistry.CreateEditor(AName, Application), IID, Intf);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TEditorRegistry }
|
|
|
|
function TEditorRegistry.CreateEditor(const aClassOrDisplayname: String;
|
|
aOwner: TComponent): TForm;
|
|
begin
|
|
if not Assigned(AOwner) then
|
|
AOwner := Application;
|
|
Result := CreateComponent( aClassOrDisplayname, aOwner ) as TForm;
|
|
end;
|
|
|
|
{procedure TEditorRegistry.ValidateMinAcceptableClass(
|
|
var aMinAcceptableClass: TClass);
|
|
begin
|
|
inherited;
|
|
if not aMinAcceptableClass.InheritsFrom(TCustomEditor) then
|
|
aMinAcceptableClass := TCustomEditor;
|
|
end;}
|
|
|
|
initialization
|
|
EditorRegistry := TEditorRegistry.Create;
|
|
|
|
finalization
|
|
EditorRegistry := NIL;
|
|
|
|
end.
|