Remove typecasts because LookupRoot was moved to TIDesigner. Also formatting.

git-svn-id: trunk@45784 -
This commit is contained in:
juha 2014-07-05 10:49:34 +00:00
parent 2f1bc3998e
commit 503833f19b
5 changed files with 26 additions and 42 deletions

View File

@ -47,8 +47,7 @@ type
procedure SetLCLForm(const AValue: TForm); virtual;
procedure SetRoot(const AValue: TComponent); virtual;
procedure CollectChildren(Child: TComponent); virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
class function FormClass: TComponentClass; virtual; abstract;
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; virtual;

View File

@ -666,9 +666,8 @@ procedure TDesigner.PrepareFreeDesigner(AFreeComponent: boolean);
begin
// was FinalizeFreeDesigner
Include(FFlags, dfDestroyingForm);
if FLookupRoot is TComponent then
// free or hide the form
TheFormEditor.DeleteComponent(TComponent(FLookupRoot),AFreeComponent);
// free or hide the form
TheFormEditor.DeleteComponent(FLookupRoot,AFreeComponent);
DisconnectComponent;
Free;
end;
@ -1095,8 +1094,7 @@ begin
break;
end;
end;
if (Result=nil)
and (FLookupRoot is TWinControl) then
if (Result=nil) and (FLookupRoot is TWinControl) then
Result:=TWinControl(FLookupRoot);
end;

View File

@ -501,15 +501,12 @@ begin
FrameComp.OnGetCreationClass:=@FrameCompGetCreationClass;
end;
procedure TCustomFormEditor.SetSelection(
const ASelection: TPersistentSelectionList);
procedure TCustomFormEditor.SetSelection(const ASelection: TPersistentSelectionList);
begin
FSelection.Assign(ASelection);
if Obj_Inspector=nil then exit;
if FSelection.Count>0 then begin
Obj_Inspector.PropertyEditorHook.LookupRoot:=
GetLookupRootForComponent(FSelection[0]);
end;
if FSelection.Count>0 then
Obj_Inspector.PropertyEditorHook.LookupRoot:=GetLookupRootForComponent(FSelection[0]);
Obj_Inspector.Selection := FSelection;
end;
@ -1102,7 +1099,7 @@ begin
else
begin
AForm := GetDesignerForm(JITNonFormList[Index-JITFormList.Count]);
Result := TIDesigner(AForm.Designer);
Result := AForm.Designer;
end;
end;

View File

@ -3401,7 +3401,7 @@ begin
ecShowAbstractMethods: DoShowAbstractMethods;
ecRemoveEmptyMethods: DoRemoveEmptyMethods;
ecRemoveUnusedUnits: DoRemoveUnusedUnits;
ecUseUnit: DoUseUnit;
ecUseUnit: DoUseUnit;
ecFindOverloads: DoFindOverloads;
ecFindBlockOtherEnd: DoGoToPascalBlockOtherEnd;
ecFindBlockStart: DoGoToPascalBlockStart;
@ -3770,8 +3770,8 @@ procedure TMainIDE.UpdateIDEComponentPalette;
begin
IDEComponentPalette.HideControls:=(LastFormActivated<>nil)
and (LastFormActivated.Designer<>nil)
and (TDesigner(LastFormActivated.Designer).LookupRoot<>nil)
and not ((LastFormActivated.Designer as TDesigner).LookupRoot is TControl);
and (LastFormActivated.Designer.LookupRoot<>nil)
and not (LastFormActivated.Designer.LookupRoot is TControl);
IDEComponentPalette.UpdateVisible;
TComponentPalette(IDEComponentPalette).OnClassSelected := @ComponentPaletteClassSelected;
SetupHints;
@ -8034,7 +8034,7 @@ begin
if AForm<>nil then begin
if (AForm.Designer=nil) then
RaiseException('TMainIDE.GetUnitWithForm AForm.Designer');
AComponent:=TDesigner(AForm.Designer).LookupRoot;
AComponent:=AForm.Designer.LookupRoot;
if AComponent=nil then
RaiseException('TMainIDE.GetUnitWithForm AComponent=nil');
GetUnitWithPersistent(AComponent,ActiveSourceEditor,ActiveUnitInfo);
@ -8351,12 +8351,10 @@ var
begin
if SourceEditorManager.SourceEditorCount = 0 then exit;
if LastFormActivated <> nil then begin
ActiveUnitInfo := Project1.UnitWithComponent(
TDesigner(LastFormActivated.Designer).LookupRoot);
ActiveUnitInfo := Project1.UnitWithComponent(LastFormActivated.Designer.LookupRoot);
if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.OpenEditorInfoCount > 0) then
begin
SourceEditorManager.ActiveEditor := TSourceEditor(ActiveUnitInfo.OpenEditorInfo[0].EditorComponent);
end;
SourceEditorManager.ActiveEditor :=
TSourceEditor(ActiveUnitInfo.OpenEditorInfo[0].EditorComponent);
end;
SourceEditorManager.ShowActiveWindowOnTop(False);
{$IFDEF VerboseIDEDisplayState}
@ -8865,11 +8863,8 @@ end;
procedure TMainIDE.OnDesignerPersistentDeleted(Sender: TObject; APersistent: TPersistent);
// important: APersistent was freed, do not access it
var
CurDesigner: TDesigner;
begin
CurDesigner := TDesigner(Sender);
if dfDestroyingForm in CurDesigner.Flags then exit;
if dfDestroyingForm in TDesigner(Sender).Flags then exit;
if ObjectInspector1<>nil then
ObjectInspector1.FillPersistentComboBox;
end;
@ -12166,11 +12161,9 @@ end;
function TMainIDE.GetProjectFileWithDesigner(ADesigner: TIDesigner): TLazProjectFile;
var
TheDesigner: TDesigner;
AComponent: TComponent;
begin
TheDesigner:=ADesigner as TDesigner;
AComponent:=TheDesigner.LookupRoot;
AComponent:=ADesigner.LookupRoot;
if AComponent=nil then
RaiseException('TMainIDE.GetProjectFileWithDesigner Designer.LookupRoot=nil');
Result:=GetProjectFileWithRootComponent(AComponent);
@ -12614,7 +12607,7 @@ procedure TMainIDE.OnPropHookObjectPropertyChanged(Sender: TObject;
var
AnUnitInfo: TUnitInfo;
NewComponent: TComponent;
ReferenceDesigner: TDesigner;
ReferenceDesigner: TIDesigner;
ReferenceUnitInfo: TUnitInfo;
begin
// check if a TPersistentPropertyEditor was changed
@ -12629,7 +12622,7 @@ begin
// find the reference unit
if (NewObject is TComponent) then begin
NewComponent:=TComponent(NewObject);
ReferenceDesigner:=TDesigner(FindRootDesigner(NewComponent));
ReferenceDesigner:=FindRootDesigner(NewComponent);
if ReferenceDesigner=nil then exit;
ReferenceUnitInfo:=Project1.UnitWithComponent(ReferenceDesigner.LookupRoot);
if ReferenceUnitInfo=nil then begin

View File

@ -169,7 +169,7 @@ type
procedure DoMergeDefaultProjectOptions(AProject: TProject);
procedure DoSwitchToFormSrc(var ActiveSourceEditor:TSourceEditor;
var ActiveUnitInfo:TUnitInfo);
procedure DoSwitchToFormSrc(ADesigner: TDesigner;
procedure DoSwitchToFormSrc(ADesigner: TIDesigner;
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
procedure GetUnitInfoForDesigner(ADesigner: TIDesigner;
@ -335,8 +335,7 @@ begin
end;
procedure TMainIDEBase.GetUnitInfoForDesigner(ADesigner: TIDesigner;
out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo
);
out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo);
var
SrcEdit: TSourceEditor;
begin
@ -349,8 +348,7 @@ begin
end;
procedure TMainIDEBase.GetCurrentUnitInfo(
out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo
);
out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo);
var
ASrcEdit: TSourceEditor;
AnUnitInfo: TUnitInfo;
@ -508,11 +506,9 @@ begin
DoSwitchToFormSrc(nil,ActiveSourceEditor,ActiveUnitInfo);
end;
procedure TMainIDEBase.DoSwitchToFormSrc(ADesigner: TDesigner;
procedure TMainIDEBase.DoSwitchToFormSrc(ADesigner: TIDesigner;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
begin
ActiveSourceEditor:=nil;
ActiveUnitInfo:=nil;
if (ADesigner<>nil) then
ActiveUnitInfo:=Project1.UnitWithComponent(ADesigner.LookupRoot)
else if (GlobalDesignHook.LookupRoot<>nil)
@ -523,8 +519,9 @@ begin
if (ActiveUnitInfo<>nil) and (ActiveUnitInfo.OpenEditorInfoCount > 0) then begin
ActiveSourceEditor := TSourceEditor(ActiveUnitInfo.OpenEditorInfo[0].EditorComponent);
SourceEditorManagerIntf.ActiveEditor := ActiveSourceEditor;
exit;
end;
end
else
ActiveSourceEditor:=nil;
end;
procedure TMainIDEBase.DoMnuWindowClicked(Sender: TObject);