📄 designintf.pas
字号:
is True then this indicates that the design root is being destroyed but
the designer itself is not. This will happen when a design-time package
is unloaded. In *most* cases, the reference to the designer must be
released regardless of the AGoingDormant flag, however it is not
mandatory. }
IDesignNotification = interface
['{E8C9F739-5601-4ADD-9D95-594132D4CEFD}']
procedure ItemDeleted(const ADesigner: IDesigner; AItem: TPersistent);
procedure ItemInserted(const ADesigner: IDesigner; AItem: TPersistent);
procedure ItemsModified(const ADesigner: IDesigner);
procedure SelectionChanged(const ADesigner: IDesigner;
const ASelection: IDesignerSelections);
procedure DesignerOpened(const ADesigner: IDesigner; AResurrecting: Boolean);
procedure DesignerClosed(const ADesigner: IDesigner; AGoingDormant: Boolean);
end;
{ IDesignWindow
IDesignWindow should be used when the IDesignNotification handler is a
top level window. It it is also registered with RegisterDesignNotifications.
WindowHide - This is called when all design windows should be hidden such
as when the IDE is debugging.
WindowShow - This is called when all design windows can not be reshown
such as when the IDE finishes debugging. }
IDesignWindow = interface(IDesignNotification)
['{7ED7BF2E-E349-11D3-AB4A-00C04FB17A72}']
procedure WindowHide;
procedure WindowShow;
end;
TRegisterDesignNotification = procedure (const DesignNotification: IDesignNotification);
var
RegisterDesignNotificationProc: TRegisterDesignNotification;
UnregisterDesignNotificationProc: TRegisterDesignNotification;
procedure RegisterDesignNotification(const DesignNotification: IDesignNotification);
procedure UnregisterDesignNotification(const DesignNotification: IDesignNotification);
type
TBasePropertyEditor = class(TInterfacedObject)
protected
procedure Initialize; virtual; abstract;
procedure SetPropEntry(Index: Integer; AInstance: TPersistent;
APropInfo: PPropInfo); virtual; abstract;
public
constructor Create(const ADesigner: IDesigner; APropCount: Integer); virtual;
end;
TPropertyEditorClass = class of TBasePropertyEditor;
{ RegisterPropertyEditor
Registers a new property editor for the given type. When a component is
selected the Object Inspector will create a property editor for each
of the component's properties. The property editor is created based on
the type of the property. If, for example, the property type is an
Integer, the property editor for Integer will be created (by default
that would be TIntegerProperty). Most properties do not need specialized
property editors. For example, if the property is an ordinal type the
default property editor will restrict the range to the ordinal subtype
range (e.g. a property of type TMyRange = 1..10 will only allow values
between 1 and 10 to be entered into the property). Enumerated types will
display a drop-down list of all the enumerated values (e.g. TShapes =
(sCircle, sSquare, sTriangle) will be edited by a drop-down list containing
only sCircle, sSquare and sTriangle). A property editor need only be
created if default property editor or none of the existing property editors
are sufficient to edit the property. This is typically because the
property is an object. The properties are looked up newest to oldest.
This allows and existing property editor replaced by a custom property
editor.
PropertyType
The type information pointer returned by the TypeInfo built-in function
(e.g. TypeInfo(TMyRange) or TypeInfo(TShapes)).
ComponentClass
Type of the component to which to restrict this type editor. This
parameter can be left nil which will mean this type editor applies to all
properties of PropertyType.
PropertyName
The name of the property to which to restrict this type editor. This
parameter is ignored if ComponentClass is nil. This parameter can be
an empty string ('') which will mean that this editor applies to all
properties of PropertyType in ComponentClass.
EditorClass
The class of the editor to be created whenever a property of the type
passed in PropertyTypeInfo is displayed in the Object Inspector. The
class will be created by calling EditorClass.Create. }
type
TRegisterPropertyEditorProc = procedure (PropertyType: PTypeInfo;
ComponentClass: TClass; const PropertyName: string;
EditorClass: TPropertyEditorClass);
TPropertyEditorFilterFunc = function(const ATestEditor: IProperty): Boolean of object;
var
RegisterPropertyEditorProc: TRegisterPropertyEditorProc;
procedure RegisterPropertyEditor(PropertyType: PTypeInfo;
ComponentClass: TClass; const PropertyName: string;
EditorClass: TPropertyEditorClass);
{ SetPropertyEditorGroup
Restricts the given editor class to be active the for classes associated
to GroupClass by calls to GroupDescendentsWith. For example, this is used
to ensure the proper version of TShortCutProperty is created depending on
if is is a CLX component or a VCL component. Using this is very similar to
using the ComponentClass parameter of RegisterPropertyEditor, but instead of
limiting it to a particular class, it limits the editor to a group of classes
created by StartClassGroup.
EditorClass
The class of the editor to restrict to a particular class group.
GroupClass
The class used to determine the group EditorClass is restricted to. }
type
TSetPropertyEditorGroupProc = procedure (EditorClass: TPropertyEditorClass;
GroupClass: TPersistentClass);
var
SetPropertyEditorGroupProc: TSetPropertyEditorGroupProc;
procedure SetPropertyEditorGroup(EditorClass: TPropertyEditorClass;
GroupClass: TPersistentClass);
{ UnlistPublishedProperty
From time to time the need to hide a property that has been published by one
of your ancesters. Most of the time when this occurs you should make sure you
are decending off the right classes. But we realize that sometimes nothing
can be done and the following procedure will allow you to make a specific
property on a specific class not appear in the object inspector.
** Please note that this function does not stop the streaming system from
streaming the published property nor does it make the published property from
begin programmatically access at runtime. It simply tells the object inspector
not to list (and in turn edit) it when components of the specified class are
selected. }
procedure UnlistPublishedProperty(ComponentClass: TClass; const PropertyName: string);
{ Standard Property Category Names }
resourcestring
sActionCategoryName = 'Action';
sDataCategoryName = 'Data';
sDatabaseCategoryName = 'Database';
{$IFDEF MSWINDOWS}
sDragNDropCategoryName = 'Drag, Drop and Docking';
{$ENDIF}
{$IFDEF LINUX}
sDragNDropCategoryName = 'Drag and Drop';
{$ENDIF}
sHelpCategoryName = 'Help and Hints';
sLayoutCategoryName = 'Layout';
sLegacyCategoryName = 'Legacy';
sLinkageCategoryName = 'Linkage';
sLocaleCategoryName = 'Locale';
sLocalizableCategoryName = 'Localizable';
sMiscellaneousCategoryName = 'Miscellaneous';
sVisualCategoryName = 'Visual';
sInputCategoryName = 'Input';
{ Property Category Types }
type
TRegisterPropertyInCategoryProc = procedure (const CategoryName: string;
ComponentClass: TClass; PropertyType: PTypeInfo;
const PropertyName: string);
var
RegisterPropertyInCategoryProc: TRegisterPropertyInCategoryProc;
procedure RegisterPropertyInCategory(const CategoryName, PropertyName: string);
overload;
procedure RegisterPropertyInCategory(const CategoryName: string;
ComponentClass: TClass; const PropertyName: string); overload;
procedure RegisterPropertyInCategory(const CategoryName: string;
PropertyType: PTypeInfo; const PropertyName: string); overload;
procedure RegisterPropertyInCategory(const CategoryName: string;
PropertyType: PTypeInfo); overload;
procedure RegisterPropertiesInCategory(const CategoryName: string;
const Filters: array of const); overload;
procedure RegisterPropertiesInCategory(const CategoryName: string;
ComponentClass: TClass; const Filters: array of string); overload;
procedure RegisterPropertiesInCategory(const CategoryName: string;
PropertyType: PTypeInfo; const Filters: array of string); overload;
resourcestring
sInvalidFilter = 'Property filters may only be name, class or type based (%d:%d)';
{ Property Mapper }
type
TPropertyMapperFunc = function(Obj: TPersistent;
PropInfo: PPropInfo): TPropertyEditorClass;
TRegisterPropertyMapperProc = procedure (Mapper: TPropertyMapperFunc);
var
RegisterPropertyMapperProc: TRegisterPropertyMapperProc;
procedure RegisterPropertyMapper(Mapper: TPropertyMapperFunc);
{ Component Editor Types }
type
{ IComponentEditor
A component editor is created for each component that is selected in the
form designer based on the component's type (see GetComponentEditor and
RegisterComponentEditor). When the component is double-clicked the Edit
method is called. When the context menu for the component is invoked the
GetVerbCount and GetVerb methods are called to build the menu. If one
of the verbs are selected ExecuteVerb is called. Paste is called whenever
the component is pasted to the clipboard. You only need to create a
component editor if you wish to add verbs to the context menu, change
the default double-click behavior, or paste an additional clipboard format.
The default component editor (TDefaultEditor) implements Edit to searches the
properties of the component and generates (or navigates to) the OnCreate,
OnChanged, or OnClick event (whichever it finds first). Whenever the
component modifies the component is *must* call Designer.Modified to inform
the designer that the form has been modified.
Edit
Called when the user double-clicks the component. The component editor can
bring up a dialog in response to this method, for example, or some kind
of design expert. If GetVerbCount is greater than zero, edit will execute
the first verb in the list (ExecuteVerb(0)).
ExecuteVerb(Index)
The Index'ed verb was selected by the use off the context menu. The
meaning of this is determined by component editor.
GetVerb
The component editor should return a string that will be displayed in the
context menu. It is the responsibility of the component editor to place
the & character and the '...' characters as appropriate.
GetVerbCount
The number of valid indices to GetVerb and Execute verb. The index is assumed
to be zero based (i.e. 0..GetVerbCount - 1).
PrepareItem
While constructing the context menu PrepareItem will be called for
each verb. It will be passed the menu item that will be used to represent
the verb. The component editor can customize the menu item as it sees fit,
including adding subitems. If you don't want that particular menu item
to be shown, don't free it, simply set its Visible property to False.
Copy
Called when the component is being copied to the clipboard. The
component's filed image is already on the clipboard. This gives the
component editor a chance to paste a different type of format which is
ignored by the designer but might be recognized by another application.
IsInInlined
Determines whether Component is in the Designer which owns it. Essentially,
Components should not be able to be added to a Frame instance (collections
are fine though) so this function checks to determine whether the currently
selected component is within a Frame instance or not.
GetComponent
TODO
GetDesigner
TODO
}
IComponentEditor = interface
['{ECACBA34-DCDF-4BE2-A645-E4404BC06106}']
procedure Edit;
procedure ExecuteVerb(Index: Integer);
function GetVerb(Index: Integer): string;
function GetVerbCount: Integer;
procedure PrepareItem(Index: Integer; const AItem: IMenuItem);
procedure Copy;
function IsInInlined: Boolean;
function GetComponent: TComponent;
function GetDesigner: IDesigner;
end;
{ TBaseComponentEditor
All component editors are assumed derived from TBaseComponentEditor and
implements the IComponentEditor interface.
Create(AComponent, ADesigner)
Called to create the component editor. AComponent is the component to
be edited by the editor. ADesigner is an interface to the designer to
find controls and create methods (this is not use often). If a component
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -