IDE: added TDesignerMediator.UseRTTIForMethods

git-svn-id: trunk@40122 -
This commit is contained in:
mattias 2013-02-02 15:46:43 +00:00
parent 1b4524ada4
commit c54dedb94a
5 changed files with 43 additions and 14 deletions

View File

@ -3548,7 +3548,7 @@ begin
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.GetCompatiblePublishedMethods(AClassName,
PropInstance,PropName,Proc);
PropInstance,PropName,Proc);
except
on e: Exception do Result:=HandleException(e);
end;

View File

@ -449,14 +449,14 @@ begin
Obj_Inspector.Selection := FSelection;
end;
Function TCustomFormEditor.AddSelected(Value : TComponent) : Integer;
function TCustomFormEditor.AddSelected(Value: TComponent): Integer;
Begin
Result := FSelection.Add(Value) + 1;
if Obj_Inspector<>nil then
Obj_Inspector.Selection := FSelection;
end;
Procedure TCustomFormEditor.DeleteComponent(AComponent: TComponent;
procedure TCustomFormEditor.DeleteComponent(AComponent: TComponent;
FreeComponent: boolean);
var
AForm: TCustomForm;
@ -534,7 +534,7 @@ Begin
end;
end;
Function TCustomFormEditor.FindComponentByName(const Name: ShortString
function TCustomFormEditor.FindComponentByName(const Name: ShortString
): TComponent;
var
i: longint;
@ -556,7 +556,7 @@ Begin
Result:=nil;
end;
function TCustomFormEditor.SaveSelectionToStream(s: TStream): boolean;
function TCustomFormEditor.SaveSelectionToStream(s: TStream): Boolean;
var
ADesigner: TIDesigner;
begin

View File

@ -49,6 +49,8 @@ type
procedure CheckDesignerPositions;
function GetDesignerMediatorByComponent(AComponent: TComponent
): TDesignerMediator; override;
function ComponentUsesRTTIForMethods(Component: TComponent): boolean;
end;
var
@ -133,6 +135,14 @@ begin
Result:=nil;
end;
function TFormEditor.ComponentUsesRTTIForMethods(Component: TComponent): boolean;
var
Mediator: TDesignerMediator;
begin
Mediator:=GetDesignerMediatorByComponent(Component);
Result:=(Mediator<>nil) and (Mediator.UseRTTIForMethods(Component));
end;
initialization
RegisterLCLBase;

View File

@ -1755,6 +1755,7 @@ procedure TMainIDE.OnPropHookGetCompatibleMethods(InstProp: PInstProp;
var
ActiveSrcEdit: TSourceEditor;
ActiveUnitInfo: TUnitInfo;
CTResult: Boolean;
begin
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource])
then exit;
@ -1762,12 +1763,17 @@ begin
DebugLn('');
DebugLn('[TMainIDE.OnPropHookGetCompatibleMethods] ************');
{$ENDIF}
if not CodeToolBoss.GetCompatiblePublishedMethods(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName,
InstProp^.Instance,InstProp^.PropInfo^.Name,Proc) then
begin
DoJumpToCodeToolBossError;
if FormEditor1.ComponentUsesRTTIForMethods(ActiveUnitInfo.Component) then begin
CTResult:=CodeToolBoss.GetCompatiblePublishedMethods(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName,
GetTypeData(InstProp^.PropInfo^.PropType),Proc);
end else begin
CTResult:=CodeToolBoss.GetCompatiblePublishedMethods(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName,
InstProp^.Instance,InstProp^.PropInfo^.Name,Proc);
end;
if not CTResult then
DoJumpToCodeToolBossError;
end;
function TMainIDE.OnPropHookCompatibleMethodExists(const AMethodName: String;
@ -1783,10 +1789,17 @@ begin
WriteLn('');
WriteLn('[TMainIDE.OnPropHookCompatibleMethodExists] ************ ',AMethodName);
{$ENDIF}
Result := CodeToolBoss.PublishedMethodExists(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName, AMethodName,
InstProp^.Instance, InstProp^.PropInfo^.Name,
MethodIsCompatible, MethodIsPublished, IdentIsMethod);
if FormEditor1.ComponentUsesRTTIForMethods(ActiveUnitInfo.Component) then begin
Result := CodeToolBoss.PublishedMethodExists(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName, AMethodName,
GetTypeData(InstProp^.PropInfo^.PropType),
MethodIsCompatible, MethodIsPublished, IdentIsMethod);
end else begin
Result := CodeToolBoss.PublishedMethodExists(ActiveUnitInfo.Source,
ActiveUnitInfo.Component.ClassName, AMethodName,
InstProp^.Instance, InstProp^.PropInfo^.Name,
MethodIsCompatible, MethodIsPublished, IdentIsMethod);
end;
if CodeToolBoss.ErrorMessage <> '' then
begin
DoJumpToCodeToolBossError;

View File

@ -74,6 +74,7 @@ type
function ComponentAtPos(p: TPoint; MinClass: TComponentClass;
Flags: TDMCompAtPosFlags): TComponent; virtual;
procedure GetChilds(Parent: TComponent; ChildComponents: TFPList); virtual;
function UseRTTIForMethods(aComponent: TComponent): boolean; virtual; // false = use sources
// events
procedure InitComponent(AComponent, NewParent: TComponent; NewBounds: TRect); virtual;
@ -479,6 +480,11 @@ begin
end;
end;
function TDesignerMediator.UseRTTIForMethods(aComponent: TComponent): boolean;
begin
Result:=false;
end;
procedure TDesignerMediator.InitComponent(AComponent, NewParent: TComponent;
NewBounds: TRect);
begin