ide, designer: extend jitform list to handle also TCustomForm descendants (not only TForm) (fixes issue #0013694)

git-svn-id: trunk@21780 -
This commit is contained in:
paul 2009-09-20 07:20:16 +00:00
parent 900a8acec8
commit 634d3996d9
2 changed files with 61 additions and 56 deletions

View File

@ -21,7 +21,7 @@
Author: Mattias Gaertner
Abstract:
This unit defines a list of forms descendents. The forms are normal TForm
This unit defines a list of forms descendents. The forms are normal TCustomForm
descendents with one exception: Every form has its own class. These classes
are changeable at runtime, so that IDEs can add, remove or rename methods
and such stuff. Also these forms can be loaded from streams and missing
@ -215,10 +215,10 @@ type
TJITForms = class(TJITComponentList)
private
function GetItem(Index: integer): TForm;
function GetItem(Index: integer): TCustomForm;
public
function IsJITForm(AComponent: TComponent): boolean;
property Items[Index:integer]: TForm read GetItem; default;
property Items[Index:integer]: TCustomForm read GetItem; default;
end;
@ -1864,22 +1864,22 @@ end;
{ TJITForms }
function TJITForms.IsJITForm(AComponent: TComponent): boolean;
function TJITForms.IsJITForm(AComponent: TComponent): Boolean;
begin
Result:=(AComponent<>nil) and (AComponent is TForm)
and (TForm(AComponent).Parent=nil) and (IndexOf(AComponent)>=0);
Result:=(AComponent<>nil) and (AComponent is TCustomForm)
and (TCustomForm(AComponent).Parent=nil) and (IndexOf(AComponent)>=0);
end;
function TJITForms.GetItem(Index: integer): TForm;
function TJITForms.GetItem(Index: integer): TCustomForm;
begin
Result:=TForm(inherited Items[Index]);
Result:=TCustomForm(inherited Items[Index]);
end;
{ TJITNonFormComponents }
function TJITNonFormComponents.IsJITNonForm(AComponent: TComponent): boolean;
begin
Result:=(AComponent<>nil) and (not (AComponent is TForm))
Result:=(AComponent<>nil) and (not (AComponent is TCustomForm))
and (IndexOf(AComponent)>=0);
end;

View File

@ -1162,48 +1162,48 @@ begin
or JITNonFormList.IsJITNonForm(AComponent);
end;
function TCustomFormEditor.GetJITListOfType(AncestorType: TComponentClass
): TJITComponentList;
function TCustomFormEditor.GetJITListOfType(AncestorType: TComponentClass): TJITComponentList;
begin
if AncestorType.InheritsFrom(TForm) then
Result:=JITFormList
else if AncestorType.InheritsFrom(TComponent) then
Result:=JITNonFormList
if AncestorType.InheritsFrom(TCustomForm) then
Result := JITFormList
else
if AncestorType.InheritsFrom(TComponent) then
Result := JITNonFormList
else
Result:=nil;
Result := nil;
end;
function TCustomFormEditor.FindJITList(AComponent: TComponent
): TJITComponentList;
function TCustomFormEditor.FindJITList(AComponent: TComponent): TJITComponentList;
begin
if JITFormList.IndexOf(AComponent)>=0 then
Result:=JITFormList
else if JITNonFormList.IndexOf(AComponent)>=0 then
Result:=JITNonFormList
if JITFormList.IndexOf(AComponent) >= 0 then
Result := JITFormList
else
if JITNonFormList.IndexOf(AComponent) >= 0 then
Result := JITNonFormList
else
Result:=nil;
Result := nil;
end;
function TCustomFormEditor.FindJITListByClassName(
const AComponentClassName: string): TJITComponentList;
function TCustomFormEditor.FindJITListByClassName(const AComponentClassName: string): TJITComponentList;
begin
if JITFormList.FindComponentByClassName(AComponentClassName)>=0 then
Result:=JITFormList
else if JITNonFormList.FindComponentByClassName(AComponentClassName)>=0 then
Result:=JITNonFormList
if JITFormList.FindComponentByClassName(AComponentClassName) >= 0 then
Result := JITFormList
else
if JITNonFormList.FindComponentByClassName(AComponentClassName) >= 0 then
Result := JITNonFormList
else
Result:=nil;
Result := nil;
end;
function TCustomFormEditor.FindJITListByClass(AComponentClass: TComponentClass
): TJITComponentList;
function TCustomFormEditor.FindJITListByClass(AComponentClass: TComponentClass): TJITComponentList;
begin
if JITFormList.FindComponentByClass(AComponentClass)>=0 then
Result:=JITFormList
else if JITNonFormList.FindComponentByClass(AComponentClass)>=0 then
Result:=JITNonFormList
if JITFormList.FindComponentByClass(AComponentClass) >= 0 then
Result := JITFormList
else
if JITNonFormList.FindComponentByClass(AComponentClass) >= 0 then
Result := JITNonFormList
else
Result:=nil;
Result := nil;
end;
function TCustomFormEditor.GetDesignerForm(AComponent: TComponent): TCustomForm;
@ -1341,15 +1341,17 @@ function TCustomFormEditor.FindJITComponentByClassName(
var
i: LongInt;
begin
Result:=nil;
i:=JITFormList.FindComponentByClassName(AComponentClassName);
if i>=0 then begin
Result:=JITFormList[i];
Result := nil;
i := JITFormList.FindComponentByClassName(AComponentClassName);
if i >= 0 then
begin
Result := JITFormList[i];
exit;
end;
i:=JITNonFormList.FindComponentByClassName(AComponentClassName);
if i>=0 then begin
Result:=JITNonFormList[i];
i := JITNonFormList.FindComponentByClassName(AComponentClassName);
if i >= 0 then
begin
Result := JITNonFormList[i];
exit;
end;
end;
@ -1359,15 +1361,17 @@ function TCustomFormEditor.FindJITComponentByClass(
var
i: LongInt;
begin
Result:=nil;
i:=JITFormList.FindComponentByClass(AComponentClass);
if i>=0 then begin
Result:=JITFormList[i];
Result := nil;
i := JITFormList.FindComponentByClass(AComponentClass);
if i >= 0 then
begin
Result := JITFormList[i];
exit;
end;
i:=JITNonFormList.FindComponentByClass(AComponentClass);
if i>=0 then begin
Result:=JITNonFormList[i];
i := JITNonFormList.FindComponentByClass(AComponentClass);
if i >= 0 then
begin
Result := JITNonFormList[i];
exit;
end;
end;
@ -1489,11 +1493,12 @@ function TCustomFormEditor.GetDesigner(Index: integer): TIDesigner;
var
AForm: TCustomForm;
begin
if Index<JITFormList.Count then
Result:=JITFormList[Index].Designer
else begin
AForm:=GetDesignerForm(JITNonFormList[Index-JITFormList.Count]);
Result:=TIDesigner(AForm.Designer);
if Index < JITFormList.Count then
Result := JITFormList[Index].Designer
else
begin
AForm := GetDesignerForm(JITNonFormList[Index-JITFormList.Count]);
Result := TIDesigner(AForm.Designer);
end;
end;