📄 dsgnintf.pas
字号:
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const AValue: string); override;
function GetFormMethodName: string; virtual;
function GetTrimmedEventName: string;
end;
{ TComponentProperty
The default editor for TComponents. It does not allow editing of the
properties of the component. It allow the user to set the value of this
property to point to a component in the same form that is type compatible
with the property being edited (e.g. the ActiveControl property). }
TComponentProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetEditLimit: Integer; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
{ TComponentNameProperty
Property editor for the Name property. It restricts the name property
from being displayed when more than one component is selected. }
TComponentNameProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetEditLimit: Integer; override;
end;
{ TFontNameProperty
Editor for the TFont.FontName property. Displays a drop-down list of all
the fonts known by Windows. The following global variable will make
this property editor actually show examples of each of the fonts in the
drop down list. We would have enabled this by default but it takes
too many cycles on slower machines or those with a lot of fonts. Enable
it at your own risk. ;-}
var
FontNamePropertyDisplayFontNames: Boolean = False;
type
TFontNameProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
var AHeight: Integer); override;
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer); override;
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); override;
end;
{ TFontCharsetProperty
Editor for the TFont.Charset property. Displays a drop-down list of the
character-set by Windows.}
TFontCharsetProperty = class(TIntegerProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
{ TImeNameProperty
Editor for the TImeName property. Displays a drop-down list of all
the IME names known by Windows.}
TImeNameProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
{ TColorProperty
Property editor for the TColor type. Displays the color as a clXXX value
if one exists, otherwise displays the value as hex. Also allows the
clXXX value to be picked from a list. }
TColorProperty = class(TIntegerProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer); override;
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); override;
procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
ASelected: Boolean); override;
end;
{ TBrushStyleProperty
Property editor for TBrush's Style. Simply provides for custom render. }
TBrushStyleProperty = class(TEnumProperty)
public
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer); override;
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); override;
procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
ASelected: Boolean); override;
end;
{ TPenStyleProperty
Property editor for TPen's Style. Simply provides for custom render. }
TPenStyleProperty = class(TEnumProperty)
public
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer); override;
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); override;
procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
ASelected: Boolean); override;
end;
{ TCursorProperty
Property editor for the TCursor type. Displays the cursor as a clXXX value
if one exists, otherwise displays the value as hex. Also allows the
clXXX value to be picked from a list. }
TCursorProperty = class(TIntegerProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
var AHeight: Integer); override;
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer); override;
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); override;
end;
{ TFontProperty
Property editor for the Font property. Brings up the font dialog as well as
allowing the properties of the object to be edited. }
TFontProperty = class(TClassProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
{ TModalResultProperty }
TModalResultProperty = class(TIntegerProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
{ TShortCutProperty
Property editor the ShortCut property. Allows both typing in a short
cut value or picking a short-cut value from a list. }
TShortCutProperty = class(TOrdinalProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
{ TMPFilenameProperty
Property editor for the TMediaPlayer. Displays an File Open Dialog
for the name of the media file.}
TMPFilenameProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
{ TTabOrderProperty
Property editor for the TabOrder property. Prevents the property from being
displayed when more than one component is selected. }
TTabOrderProperty = class(TIntegerProperty)
public
function GetAttributes: TPropertyAttributes; override;
end;
{ TCaptionProperty
Property editor for the Caption and Text properties. Updates the value of
the property for each change instead on when the property is approved. }
TCaptionProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
end;
{ TDateProperty
Property editor for date portion of TDateTime type. }
TDateProperty = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
{ TTimeProperty
Property editor for time portion of TDateTime type. }
TTimeProperty = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
{ TDateTimeProperty
Edits both date and time data... simultaneously! }
TDateTimeProperty = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
{ TComponentEditor
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.
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).
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.
}
IComponentEditor = interface
['{ABBE7252-5495-11D1-9FB5-0020AF3D82DA}']
procedure Edit;
procedure ExecuteVerb(Index: Integer);
function GetIComponent: IComponent;
function GetDesigner: IFormDesigner;
function GetVerb(Index: Integer): string;
function GetVerbCount: Integer;
procedure PrepareItem(Index: Integer; const AItem: TMenuItem);
procedure Copy;
end;
TComponentEditor = class(TInterfacedObject, IComponentEditor)
private
FComponent: TComponent;
FDesigner: IFormDesigner;
public
constructor Create(AComponent: TComponent; ADesigner: IFormDesigner); virtual;
procedure Edit; virtual;
procedure ExecuteVerb(Index: Integer); virtual;
function GetIComponent: IComponent;
function GetDesigner: IFormDesigner;
function GetVerb(Index: Integer): string; virtual;
function GetVerbCount: Integer; virtual;
function IsInInlined: Boolean;
procedure PrepareItem(Index: Integer; const AItem: TMenuItem); virtual;
procedure Copy; virtual;
property Component: TComponent read FComponent;
property Designer: IFormDesigner read GetDesigner;
end;
TComponentEditorClass = class of TComponentEditor;
IDefaultEditor = interface(IComponentEditor)
['{5484FAE1-5C60-11D1-9FB6-0020AF3D82DA}']
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -