~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to components/ideintf/propedits.pp

  • Committer: Package Import Robot
  • Author(s): Abou Al Montacir
  • Date: 2014-05-15 23:17:51 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140515231751-gumj9a01g0ghm7ac
Tags: 1.2.2+dfsg-1
* New upstream release with few fixes and official support of FPC 2.6.4.
  - The detailed list of changes can be found here:
  http://wiki.lazarus.freepascal.org/Lazarus_1.2_fixes_branch#Fixes_for_1.2.2_.28Merged.29

Show diffs side-by-side

added added

removed removed

Lines of Context:
1227
1227
 
1228
1228
  { TPropertyEditorHook }
1229
1229
 
1230
 
  TPropertyEditorHook = class
 
1230
  TPropertyEditorHook = class(TComponent)
1231
1231
  private
1232
1232
    FHandlers: array[TPropHookType] of TMethodList;
1233
1233
    // lookup root
1239
1239
    function GetHandlerCount(HookType: TPropHookType): integer;
1240
1240
    function GetNextHandlerIndex(HookType: TPropHookType;
1241
1241
                                 var i: integer): boolean;
 
1242
  protected
 
1243
    procedure Notification(AComponent: TComponent; Operation: TOperation);
 
1244
      override;
1242
1245
  public
1243
1246
    GetPrivateDirectory: AnsiString;
1244
 
    constructor Create;
 
1247
    constructor Create; overload; deprecated; // use Create(TComponent) instead
1245
1248
    destructor Destroy; override;
1246
1249
 
1247
1250
    // lookup root
1248
1251
    property LookupRoot: TPersistent read FLookupRoot write SetLookupRoot;
1249
1252
    // methods
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);
5228
5231
 
5229
5232
{ TPropertyEditorHook }
5230
5233
 
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
  ): TMethod;
5234
5237
var
5235
5238
  i: Integer;
5236
5239
  Handler: TPropHookCreateMethod;
5237
5240
begin
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
5241
5244
  begin
5242
5245
    i := GetHandlerCount(htCreateMethod);
5243
5246
    while GetNextHandlerIndex(htCreateMethod, i) do
5244
5247
    begin
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;
5248
5251
    end;
5249
5252
  end;
5291
5294
    TPropHookGetCompatibleMethods(FHandlers[htGetCompatibleMethods][i])(InstProp,Proc);
5292
5295
end;
5293
5296
 
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;
5297
5300
var
5298
5301
  i: Integer;
5299
5302
  Handler: TPropHookMethodExists;
5300
5303
begin
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);
5310
5313
    end;
5311
5314
  end else begin
5312
 
    Result:=(LookupRoot.MethodAddress(Name)<>nil);
 
5315
    Result:=(LookupRoot.MethodAddress(aName)<>nil);
5313
5316
    MethodIsCompatible:=Result;
5314
5317
    MethodIsPublished:=Result;
5315
5318
    IdentIsMethod:=Result;
5316
5319
  end;
5317
5320
end;
5318
5321
 
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;
5322
5325
var
5323
5326
  i: Integer;
5324
5327
  Handler: TPropHookCompatibleMethodExists;
5325
5328
begin
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);
5335
5338
    end;
5336
5339
  end else begin
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);
5352
5355
end;
5353
5356
 
5354
 
procedure TPropertyEditorHook.ShowMethod(const Name:String);
 
5357
procedure TPropertyEditorHook.ShowMethod(const aName:String);
5355
5358
// jump cursor to published method body
5356
5359
var
5357
5360
  i: Integer;
5358
5361
begin
5359
5362
  i:=GetHandlerCount(htShowMethod);
5360
5363
  while GetNextHandlerIndex(htShowMethod,i) do
5361
 
    TPropHookShowMethod(FHandlers[htShowMethod][i])(Name);
 
5364
    TPropHookShowMethod(FHandlers[htShowMethod][i])(aName);
5362
5365
end;
5363
5366
 
5364
5367
function TPropertyEditorHook.MethodFromAncestor(const Method: TMethod): boolean;
5641
5644
    TPropHookAddDependency(FHandlers[htAddDependency][i])(AClass,AnUnitName);
5642
5645
end;
5643
5646
 
5644
 
function TPropertyEditorHook.GetObject(const Name: Shortstring): TPersistent;
 
5647
function TPropertyEditorHook.GetObject(const aName: ShortString): TPersistent;
5645
5648
var
5646
5649
  i: Integer;
5647
5650
begin
5648
5651
  Result:=nil;
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);
5652
5655
end;
5653
5656
 
5654
5657
function TPropertyEditorHook.GetObjectName(Instance: TPersistent): Shortstring;
6128
6131
  i: Integer;
6129
6132
begin
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);
6161
6168
end;
6162
6169
 
 
6170
procedure TPropertyEditorHook.Notification(AComponent: TComponent;
 
6171
  Operation: TOperation);
 
6172
begin
 
6173
  inherited Notification(AComponent, Operation);
 
6174
  if (Operation=opRemove) and (AComponent=FLookupRoot) then
 
6175
    LookupRoot:=nil;
 
6176
end;
 
6177
 
6163
6178
constructor TPropertyEditorHook.Create;
6164
6179
begin
6165
 
  inherited Create;
 
6180
  Create(nil);
6166
6181
end;
6167
6182
 
6168
6183
destructor TPropertyEditorHook.Destroy;