📄 designintf.pas
字号:
editor modifies the component in any way it *must* call
ADesigner.Modified. }
TBaseComponentEditor = class(TInterfacedObject)
public
constructor Create(AComponent: TComponent; ADesigner: IDesigner); virtual;
end;
TComponentEditorClass = class of TBaseComponentEditor;
IDefaultEditor = interface(IComponentEditor)
['{5484FAE1-5C60-11D1-9FB6-0020AF3D82DA}']
end;
{ Register a component editor to be created when a component derived from
ComponentClass is the only selection in the designer }
type
TRegisterComponentEditorProc = procedure (ComponentClass: TComponentClass;
ComponentEditor: TComponentEditorClass);
var
RegisterComponentEditorProc: TRegisterComponentEditorProc;
procedure RegisterComponentEditor(ComponentClass: TComponentClass;
ComponentEditor: TComponentEditorClass);
{ Selection Editor Types }
type
{ ISelectionEditor
This interface performs functions similar to IComponentEditor but is not
limited to one participant at a time. When a editor menu is needed Delphi
will look at all of the selected objects and allow all selection editors
that can match them participate in the menu construction and selection.
A selection editor is selected by finding the most derived common ancestor
of all the components in the selection and then finding the selection editor
that was registered for that class or its closes ancestor. For example, if
you register a selection editor for TControl and TButton and a button and
a label are selected, the TControl selection editor will be created (because
TControl is their common ancestor) but if two TButton's are selected, the
TButton selection editor will be created. In other words, all the components
in the selection are guarenteed, by the designer, to be at least derived
from the class the selection editor is registered for.
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 selection 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.
RequiresUnits
Should call Proc with all the units that are needed to be used when
using this class. The form designer automatically ensures the unit
the class was declared in and all its ancestor's units are used in the
user's program when they use this component. Sometimes, however, an
event will use a type in one of its parameters that is not in its unit
nor any of its ancestor's units. If this is the case a selection editor
should be registerd that implements RequiresUnits and it should call
Proc for each unit that declare the types needed by its events }
ISelectionEditor = interface
['{B91F7A78-BB2C-45D9-957A-8A45A2D30435}']
procedure ExecuteVerb(Index: Integer; const List: IDesignerSelections);
function GetVerb(Index: Integer): string;
function GetVerbCount: Integer;
procedure PrepareItem(Index: Integer; const AItem: IMenuItem);
procedure RequiresUnits(Proc: TGetStrProc);
end;
{ TBaseSelectionEditor
All selection editors are assumed to derive from this class. A default
implemenation for the ISelectionEditor interface is provided in
TSelectionEditor class. }
TBaseSelectionEditor = class(TInterfacedObject)
public
constructor Create(const ADesigner: IDesigner); virtual;
end;
TSelectionEditorClass = class of TBaseSelectionEditor;
ISelectionEditorList = interface
['{C1360368-0099-4A7C-A4A8-7650503BA0C6}']
function Get(Index: Integer): ISelectionEditor;
function GetCount: Integer;
property Count: Integer read GetCount;
property Items[Index: Integer]: ISelectionEditor read Get; default;
end;
type
TRegisterSelectionEditorProc = procedure (AClass: TClass; AEditor: TSelectionEditorClass);
var
RegisterSelectionEditorProc: TRegisterSelectionEditorProc;
procedure RegisterSelectionEditor(AClass: TClass; AEditor: TSelectionEditorClass);
{ Custom Module Types }
{ A custom module allows containers that descend from classes other than TForm
to be created and edited by the form designer. This is useful for other form
like containers (e.g. a report designer) or for specialized forms (e.g. an
ActiveForm) or for generic component containers (e.g. a TDataModule). It is
assumed that the base class registered will call InitInheritedComponent in its
constructor which will initialize the component from the associated DFM or
XFM file stored in the programs resources. See the constructors of TDataModule
and TForm for examples of how to write such a constructor.
The following designer assumptions are made, depending on the base components
ancestor,
If ComponentBaseClass descends from TForm (in either VCL or Clx),
it is designed by creating an instance of the component as the form.
Allows designing TForm descendants and modifying their properties as
well as the form properties
If ComponentBaseClass descends from TWinControl or TWidgetControl (but not
TForm),
it is designed by creating an instance of the control, placing it into a
design-time form. The form's client size is the default size of the
control.
If ComponentBaseClass descends from TDataModule,
it is designed by creating an instance of the class and creating a
special non-visual container designer to edit the components and display
the icons of the contained components.
The module will appear in the project file with a colon and the base class
name appended after the component name (e.g. MyDataModule: TDataModule).
Note it is undefined what will happen if you try register anything that does
not descend from one of the above. }
type
TCustomModuleAttribute = (cmaVirtualSize);
TCustomModuleAttributes = set of TCustomModuleAttribute;
{ ICustomModule
Created when a module is selected and prior to the module being created to
request information about the custom module.
GetAttributes
Return information about the verb. Currently the only defined information
is whether the designer should be virtually sized. This is only
meaningful for modules that design visual components but not the
top level visual component. This causes scroll-bars to appear instead of
the visual component being client aligned in the parent designer.
ExecuteVerb
Execute the verb associated with Index. The text of the verb should be
return by GetVerb.
GetVerb
Return the text, suitable for placement in a menu, that you want the use
to operate on the module as a whole.
GetVerbCount
Return the number of verbs returned by GetVerb and executed by
ExecuteVerb.
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 module 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.
Saving
This is called prior to the module being saved. This allows the custom
module to make sure the state of the module is consistent prior to saving.
This method can be left blank.
ValidateComponent
This allows the custom module to reject components that are not suitable
for the module. If the component is not applicable for the module
ValidateComponent should raise and exception. TCustomModule implements
this by calling ValidateComponentClass on the class of the component
so if the filtering is done strictly by class implement
ValidateComponentClass instead.
ValidateComponentClass
ValidateComponentClass is called by the designer to filter the contents
of the palette to only the classes that are suitable for the module.
Nestable
Return true if this module can be nested into other modules. This will
only be called if the TBaseCustomModule is created with a nil Root and,
when Root is nil, only Nestable will be called on this interface. }
ICustomModule = interface
['{95DA4A2B-D800-4CBB-B0B8-85AB7D3CFADA}']
function GetAttributes: TCustomModuleAttributes;
procedure ExecuteVerb(Index: Integer);
function GetVerb(Index: Integer): string;
function GetVerbCount: Integer;
procedure PrepareItem(Index: Integer; const AItem: IMenuItem);
procedure Saving;
procedure ValidateComponent(Component: TComponent);
function ValidateComponentClass(ComponentClass: TComponentClass): Boolean;
function Nestable: Boolean;
end;
{ TBaseCustomModule
All custom modules are assumed to derive from TBaseCustomModule. The ARoot
ARoot parameter might be nil which means that only Nestable will be called
on the ICustomModule interfaced implementated by the instance }
TBaseCustomModule = class(TInterfacedObject)
public
constructor Create(ARoot: TComponent; const Designer: IDesigner); virtual;
class function DesignClass: TComponentClass; virtual;
end;
TCustomModuleClass = class of TBaseCustomModule;
TRegisterCustomModuleProc = procedure (Group: Integer;
ComponentBaseClass: TComponentClass;
CustomModuleClass: TCustomModuleClass);
var
RegisterCustomModuleProc: TRegisterCustomModuleProc;
procedure RegisterCustomModule(ComponentBaseClass: TComponentClass;
CustomModuleClass: TCustomModuleClass);
{ Designer selection }
type
{ This is the default implementation of IDesignerSelections }
TDesignerSelections = class(TInterfacedObject, IDesignerSelections)
private
FList: TList;
protected
function Add(const Item: TPersistent): Integer;
function Equals(const List: IDesignerSelections): Boolean;
function Get(Index: Integer): TPersistent;
function GetCount: Integer;
property Count: Integer read GetCount;
property Items[Index: Integer]: TPersistent read Get; default;
public
constructor Create; virtual;
constructor Copy(const Selections: IDesignerSelections);
destructor Destroy; override;
end;
function CreateSelectionList: IDesignerSelections;
const
MaxIdentLength = 63;
{ Designer types }
type
TEditAction = (eaUndo, eaRedo, eaCut, eaCopy, eaPaste, eaDelete, eaSelectAll,
eaPrint, eaBringToFront, eaSendToBack, eaAlignToGrid, eaFlipChildrenAll,
eaFlipChildrenSelected);
TEditStates = (esCanUndo, esCanRedo, esCanCut, esCanCopy, esCanPaste,
esCanDelete, esCanZOrder, esCanAlignGrid, esCanEditOle, esCanTabOrder,
esCanCreationOrder, esCanPrint, esCanSelectAll, esCanCreateTemplate);
TEditState = set of TEditStates;
IImplementation = interface
['{F9D448F2-50BC-11D1-9FB5-0020AF3D82DA}']
function GetInstance: TObject;
end;
IEditHandler = interface
['{7ED7BF2D-E349-11D3-AB4A-00C04FB17A72}']
function EditAction(Action: TEditAction): Boolean;
function GetEditState: TEditState;
end;
IDesignEditQuery = IEditHandler; // For compatiblity with v5.0
{$IFDEF LINUX}
TThreadAffinity = (taQT, taWine);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -