1239
1239
function GetHandlerCount(HookType: TPropHookType): integer;
1240
1240
function GetNextHandlerIndex(HookType: TPropHookType;
1241
1241
var i: integer): boolean;
1243
procedure Notification(AComponent: TComponent; Operation: TOperation);
1243
1246
GetPrivateDirectory: AnsiString;
1247
constructor Create; overload; deprecated; // use Create(TComponent) instead
1245
1248
destructor Destroy; override;
1248
1251
property LookupRoot: TPersistent read FLookupRoot write SetLookupRoot;
1250
function CreateMethod(const Name: ShortString; ATypeInfo:PTypeInfo;
1253
function CreateMethod(const aName: ShortString; ATypeInfo:PTypeInfo;
1251
1254
APersistent: TPersistent;
1252
1255
const APropertyPath: string): TMethod;
1253
1256
function GetMethodName(const Method: TMethod; PropOwner: TObject): String;
1254
1257
procedure GetMethods(TypeData: PTypeData; const Proc: TGetStrProc);
1255
1258
procedure GetCompatibleMethods(InstProp: PInstProp; const Proc: TGetStrProc);
1256
function MethodExists(const Name: String; TypeData: PTypeData;
1259
function MethodExists(const aName: String; TypeData: PTypeData;
1257
1260
var MethodIsCompatible,MethodIsPublished,IdentIsMethod: boolean):boolean;
1258
function CompatibleMethodExists(const Name: String; InstProp: PInstProp;
1261
function CompatibleMethodExists(const aName: String; InstProp: PInstProp;
1259
1262
var MethodIsCompatible,MethodIsPublished,IdentIsMethod: boolean):boolean;
1260
1263
procedure RenameMethod(const CurName, NewName: String);
1261
procedure ShowMethod(const Name: String);
1264
procedure ShowMethod(const aName: String);
1262
1265
function MethodFromAncestor(const Method: TMethod): boolean;
1263
1266
procedure ChainCall(const AMethodName, InstanceName,
1264
1267
InstanceMethod: ShortString; TypeData: PTypeData);
1280
1283
function IsSelected(const APersistent: TPersistent): boolean;
1281
1284
procedure SelectOnlyThis(const APersistent: TPersistent);
1282
1285
// persistent objects
1283
function GetObject(const Name: ShortString): TPersistent;
1286
function GetObject(const aName: ShortString): TPersistent;
1284
1287
function GetObjectName(Instance: TPersistent): ShortString;
1285
1288
procedure GetObjectNames(TypeData: PTypeData; const Proc: TGetStrProc);
1286
1289
procedure ObjectReferenceChanged(Sender: TObject; NewObject: TPersistent);
5229
5232
{ TPropertyEditorHook }
5231
function TPropertyEditorHook.CreateMethod(const Name: Shortstring;
5232
ATypeInfo: PTypeInfo;
5233
APersistent: TPersistent; const APropertyPath: string): TMethod;
5234
function TPropertyEditorHook.CreateMethod(const aName: ShortString;
5235
ATypeInfo: PTypeInfo; APersistent: TPersistent; const APropertyPath: string
5236
5239
Handler: TPropHookCreateMethod;
5238
5241
Result.Code := nil;
5239
5242
Result.Data := nil;
5240
if IsValidIdent(Name) and Assigned(ATypeInfo) then
5243
if IsValidIdent(aName) and Assigned(ATypeInfo) then
5242
5245
i := GetHandlerCount(htCreateMethod);
5243
5246
while GetNextHandlerIndex(htCreateMethod, i) do
5245
5248
Handler := TPropHookCreateMethod(FHandlers[htCreateMethod][i]);
5246
Result := Handler(Name, ATypeInfo, APersistent, APropertyPath);
5249
Result := Handler(aName, ATypeInfo, APersistent, APropertyPath);
5247
5250
if Assigned(Result.Data) or Assigned(Result.Code) then exit;
5291
5294
TPropHookGetCompatibleMethods(FHandlers[htGetCompatibleMethods][i])(InstProp,Proc);
5294
function TPropertyEditorHook.MethodExists(const Name: String;
5297
function TPropertyEditorHook.MethodExists(const aName: String;
5295
5298
TypeData: PTypeData;
5296
5299
var MethodIsCompatible, MethodIsPublished, IdentIsMethod: boolean):boolean;
5299
5302
Handler: TPropHookMethodExists;
5301
// check if a published method with given name exists in LookupRoot
5302
Result:=IsValidIdent(Name) and Assigned(FLookupRoot);
5304
// check if a published method with given aName exists in LookupRoot
5305
Result:=IsValidIdent(aName) and Assigned(FLookupRoot);
5303
5306
if not Result then exit;
5304
5307
i:=GetHandlerCount(htMethodExists);
5305
5308
if i>=0 then begin
5306
5309
while GetNextHandlerIndex(htMethodExists,i) do begin
5307
5310
Handler:=TPropHookMethodExists(FHandlers[htMethodExists][i]);
5308
Result:=Handler(Name,TypeData,
5311
Result:=Handler(aName,TypeData,
5309
5312
MethodIsCompatible,MethodIsPublished,IdentIsMethod);
5312
Result:=(LookupRoot.MethodAddress(Name)<>nil);
5315
Result:=(LookupRoot.MethodAddress(aName)<>nil);
5313
5316
MethodIsCompatible:=Result;
5314
5317
MethodIsPublished:=Result;
5315
5318
IdentIsMethod:=Result;
5319
function TPropertyEditorHook.CompatibleMethodExists(const Name: String;
5322
function TPropertyEditorHook.CompatibleMethodExists(const aName: String;
5320
5323
InstProp: PInstProp; var MethodIsCompatible, MethodIsPublished,
5321
5324
IdentIsMethod: boolean): boolean;
5324
5327
Handler: TPropHookCompatibleMethodExists;
5326
// check if a published method with given name exists in LookupRoot
5327
Result:=IsValidIdent(Name) and Assigned(FLookupRoot);
5329
// check if a published method with given aName exists in LookupRoot
5330
Result:=IsValidIdent(aName) and Assigned(FLookupRoot);
5328
5331
if not Result then exit;
5329
5332
i:=GetHandlerCount(htCompatibleMethodExists);
5330
5333
if i>=0 then begin
5331
5334
while GetNextHandlerIndex(htCompatibleMethodExists,i) do begin
5332
5335
Handler:=TPropHookCompatibleMethodExists(FHandlers[htCompatibleMethodExists][i]);
5333
Result:=Handler(Name,InstProp,
5336
Result:=Handler(aName,InstProp,
5334
5337
MethodIsCompatible,MethodIsPublished,IdentIsMethod);
5337
Result:=(LookupRoot.MethodAddress(Name)<>nil);
5340
Result:=(LookupRoot.MethodAddress(aName)<>nil);
5338
5341
MethodIsCompatible:=Result;
5339
5342
MethodIsPublished:=Result;
5340
5343
IdentIsMethod:=Result;
5351
5354
TPropHookRenameMethod(FHandlers[htRenameMethod][i])(CurName,NewName);
5354
procedure TPropertyEditorHook.ShowMethod(const Name:String);
5357
procedure TPropertyEditorHook.ShowMethod(const aName:String);
5355
5358
// jump cursor to published method body
5359
5362
i:=GetHandlerCount(htShowMethod);
5360
5363
while GetNextHandlerIndex(htShowMethod,i) do
5361
TPropHookShowMethod(FHandlers[htShowMethod][i])(Name);
5364
TPropHookShowMethod(FHandlers[htShowMethod][i])(aName);
5364
5367
function TPropertyEditorHook.MethodFromAncestor(const Method: TMethod): boolean;
5641
5644
TPropHookAddDependency(FHandlers[htAddDependency][i])(AClass,AnUnitName);
5644
function TPropertyEditorHook.GetObject(const Name: Shortstring): TPersistent;
5647
function TPropertyEditorHook.GetObject(const aName: ShortString): TPersistent;
5649
5652
i:=GetHandlerCount(htGetObject);
5650
5653
while GetNextHandlerIndex(htGetObject,i) and (Result=nil) do
5651
Result:=TPropHookGetObject(FHandlers[htGetObject][i])(Name);
5654
Result:=TPropHookGetObject(FHandlers[htGetObject][i])(aName);
5654
5657
function TPropertyEditorHook.GetObjectName(Instance: TPersistent): Shortstring;
6130
6133
if FLookupRoot=APersistent then exit;
6134
if FLookupRoot is TComponent then
6135
RemoveFreeNotification(TComponent(FLookupRoot));
6131
6136
FLookupRoot:=APersistent;
6137
if FLookupRoot is TComponent then
6138
FreeNotification(TComponent(FLookupRoot));
6132
6139
i:=GetHandlerCount(htChangeLookupRoot);
6133
6140
while GetNextHandlerIndex(htChangeLookupRoot,i) do
6134
6141
TPropHookChangeLookupRoot(FHandlers[htChangeLookupRoot][i])();
6160
6167
Result:=FHandlers[HookType].NextDownIndex(i);
6170
procedure TPropertyEditorHook.Notification(AComponent: TComponent;
6171
Operation: TOperation);
6173
inherited Notification(AComponent, Operation);
6174
if (Operation=opRemove) and (AComponent=FLookupRoot) then
6163
6178
constructor TPropertyEditorHook.Create;
6168
6183
destructor TPropertyEditorHook.Destroy;