mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 01:48:03 +02:00
IDEIntf+LCL: TGetDesignerFormEvent using TPersistent instead of TComponent
git-svn-id: trunk@22907 -
This commit is contained in:
parent
53ede9fe10
commit
f358340f56
@ -186,7 +186,7 @@ each control that's dropped onto the form
|
||||
): TJITComponentList;
|
||||
function FindJITListByClass(AComponentClass: TComponentClass
|
||||
): TJITComponentList;
|
||||
function GetDesignerForm(AComponent: TComponent): TCustomForm; override;
|
||||
function GetDesignerForm(APersistent: TPersistent): TCustomForm; override;
|
||||
|
||||
function FindNonFormForm(LookupRoot: TComponent): TCustomNonFormDesignerForm;
|
||||
|
||||
@ -1207,19 +1207,20 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCustomFormEditor.GetDesignerForm(AComponent: TComponent): TCustomForm;
|
||||
function TCustomFormEditor.GetDesignerForm(APersistent: TPersistent): TCustomForm;
|
||||
var
|
||||
OwnerComponent: TComponent;
|
||||
TheOwner: TPersistent;
|
||||
begin
|
||||
Result := nil;
|
||||
if AComponent = nil then exit;
|
||||
OwnerComponent := AComponent;
|
||||
while OwnerComponent.Owner <> nil do
|
||||
OwnerComponent := OwnerComponent.Owner;
|
||||
if OwnerComponent is TCustomForm then
|
||||
Result := TCustomForm(OwnerComponent)
|
||||
Result:=nil;
|
||||
TheOwner := GetLookupRootForComponent(APersistent);
|
||||
if TheOwner = nil then
|
||||
exit;
|
||||
if TheOwner is TCustomForm then
|
||||
Result := TCustomForm(TheOwner)
|
||||
else if TheOwner is TComponent then
|
||||
Result := FindNonFormForm(TComponent(TheOwner))
|
||||
else
|
||||
Result := FindNonFormForm(OwnerComponent);
|
||||
exit;
|
||||
end;
|
||||
|
||||
function TCustomFormEditor.FindNonFormForm(LookupRoot: TComponent): TCustomNonFormDesignerForm;
|
||||
|
@ -197,7 +197,7 @@ type
|
||||
function DesignerCount: integer; virtual; abstract;
|
||||
property Designer[Index: integer]: TIDesigner read GetDesigner;
|
||||
function GetCurrentDesigner: TIDesigner; virtual; abstract;
|
||||
function GetDesignerForm(AComponent: TComponent): TCustomForm; virtual; abstract;
|
||||
function GetDesignerForm(APersistent: TPersistent): TCustomForm; virtual; abstract;
|
||||
function GetDesignerByComponent(AComponent: TComponent
|
||||
): TIDesigner; virtual; abstract;
|
||||
|
||||
|
@ -4232,9 +4232,10 @@ end;
|
||||
|
||||
procedure TObjectInspectorDlg.ComponentTreeDblClick(Sender: TObject);
|
||||
var
|
||||
AComponent: TComponent;
|
||||
APersistent: TPersistent;
|
||||
CompEditor: TBaseComponentEditor;
|
||||
ADesigner: TIDesigner;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
if (PropertyEditorHook=nil) or (PropertyEditorHook.LookupRoot=nil) then
|
||||
Exit;
|
||||
@ -4242,7 +4243,10 @@ begin
|
||||
ComponentTreeSelectionChanged(Sender);
|
||||
if not Assigned(ComponentTree.Selected) then
|
||||
Exit;
|
||||
AComponent := TComponent(ComponentTree.Selected.Data);
|
||||
APersistent := TPersistent(ComponentTree.Selected.Data);
|
||||
if not (APersistent is TComponent) then
|
||||
exit;
|
||||
AComponent:=TComponent(APersistent);
|
||||
ADesigner := FindRootDesigner(AComponent);
|
||||
if not (ADesigner is TComponentEditorDesigner) then
|
||||
Exit;
|
||||
|
44
lcl/forms.pp
44
lcl/forms.pp
@ -1500,15 +1500,15 @@ procedure RestoreFocusState(FocusState: TFocusState);
|
||||
|
||||
type
|
||||
TGetDesignerFormEvent =
|
||||
function(AComponent: TComponent): TCustomForm of object;
|
||||
function(APersistent: TPersistent): TCustomForm of object;
|
||||
|
||||
var
|
||||
OnGetDesignerForm: TGetDesignerFormEvent = nil;
|
||||
|
||||
function GetParentForm(Control:TControl): TCustomForm;
|
||||
function GetFirstParentForm(Control:TControl): TCustomForm;
|
||||
function GetDesignerForm(AComponent: TComponent): TCustomForm;
|
||||
function FindRootDesigner(AComponent: TComponent): TIDesigner;
|
||||
function GetDesignerForm(APersistent: TPersistent): TCustomForm;
|
||||
function FindRootDesigner(APersistent: TPersistent): TIDesigner;
|
||||
|
||||
function IsAccel(VK: word; const Str: string): Boolean;
|
||||
procedure NotifyApplicationUserInput(Msg: Cardinal);
|
||||
@ -1705,12 +1705,12 @@ end;
|
||||
|
||||
//==============================================================================
|
||||
|
||||
function FindRootDesigner(AComponent: TComponent): TIDesigner;
|
||||
function FindRootDesigner(APersistent: TPersistent): TIDesigner;
|
||||
var
|
||||
Form: TCustomForm;
|
||||
begin
|
||||
Result:=nil;
|
||||
Form:=GetDesignerForm(AComponent);
|
||||
Form:=GetDesignerForm(APersistent);
|
||||
if Form<>nil then
|
||||
Result:=Form.Designer;
|
||||
end;
|
||||
@ -1722,21 +1722,35 @@ begin
|
||||
Result:=TCustomForm(Control);
|
||||
end;
|
||||
|
||||
function GetDesignerForm(AComponent: TComponent): TCustomForm;
|
||||
var
|
||||
OwnerComponent: TComponent;
|
||||
function GetDesignerForm(APersistent: TPersistent): TCustomForm;
|
||||
begin
|
||||
if AComponent = nil then Exit(nil);
|
||||
if APersistent = nil then Exit(nil);
|
||||
if Assigned(OnGetDesignerForm) then
|
||||
Result := OnGetDesignerForm(AComponent)
|
||||
Result := OnGetDesignerForm(APersistent)
|
||||
else
|
||||
begin
|
||||
Result := nil;
|
||||
OwnerComponent := AComponent;
|
||||
while OwnerComponent.Owner <> nil do
|
||||
OwnerComponent := OwnerComponent.Owner;
|
||||
if OwnerComponent is TCustomForm then
|
||||
Result := TCustomForm(OwnerComponent);
|
||||
repeat
|
||||
if (APersistent is TComponent) then begin
|
||||
if TComponent(APersistent).Owner<>nil then
|
||||
APersistent:=TComponent(APersistent).Owner
|
||||
else
|
||||
exit;
|
||||
end else if APersistent is TCollection then begin
|
||||
if TCollection(APersistent).Owner<>nil then
|
||||
APersistent:=TCollection(APersistent).Owner
|
||||
else
|
||||
exit;
|
||||
end else if APersistent is TCollectionItem then begin
|
||||
if TCollectionItem(APersistent).Collection<>nil then
|
||||
APersistent:=TCollectionItem(APersistent).Collection
|
||||
else
|
||||
exit;
|
||||
end else
|
||||
exit;
|
||||
until false;
|
||||
if APersistent is TCustomForm then
|
||||
Result := TCustomForm(APersistent);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user