mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 19:09:19 +02:00
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:
parent
900a8acec8
commit
634d3996d9
@ -21,7 +21,7 @@
|
|||||||
Author: Mattias Gaertner
|
Author: Mattias Gaertner
|
||||||
|
|
||||||
Abstract:
|
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
|
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
|
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
|
and such stuff. Also these forms can be loaded from streams and missing
|
||||||
@ -215,10 +215,10 @@ type
|
|||||||
|
|
||||||
TJITForms = class(TJITComponentList)
|
TJITForms = class(TJITComponentList)
|
||||||
private
|
private
|
||||||
function GetItem(Index: integer): TForm;
|
function GetItem(Index: integer): TCustomForm;
|
||||||
public
|
public
|
||||||
function IsJITForm(AComponent: TComponent): boolean;
|
function IsJITForm(AComponent: TComponent): boolean;
|
||||||
property Items[Index:integer]: TForm read GetItem; default;
|
property Items[Index:integer]: TCustomForm read GetItem; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1864,22 +1864,22 @@ end;
|
|||||||
|
|
||||||
{ TJITForms }
|
{ TJITForms }
|
||||||
|
|
||||||
function TJITForms.IsJITForm(AComponent: TComponent): boolean;
|
function TJITForms.IsJITForm(AComponent: TComponent): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(AComponent<>nil) and (AComponent is TForm)
|
Result:=(AComponent<>nil) and (AComponent is TCustomForm)
|
||||||
and (TForm(AComponent).Parent=nil) and (IndexOf(AComponent)>=0);
|
and (TCustomForm(AComponent).Parent=nil) and (IndexOf(AComponent)>=0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJITForms.GetItem(Index: integer): TForm;
|
function TJITForms.GetItem(Index: integer): TCustomForm;
|
||||||
begin
|
begin
|
||||||
Result:=TForm(inherited Items[Index]);
|
Result:=TCustomForm(inherited Items[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TJITNonFormComponents }
|
{ TJITNonFormComponents }
|
||||||
|
|
||||||
function TJITNonFormComponents.IsJITNonForm(AComponent: TComponent): boolean;
|
function TJITNonFormComponents.IsJITNonForm(AComponent: TComponent): boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(AComponent<>nil) and (not (AComponent is TForm))
|
Result:=(AComponent<>nil) and (not (AComponent is TCustomForm))
|
||||||
and (IndexOf(AComponent)>=0);
|
and (IndexOf(AComponent)>=0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1162,48 +1162,48 @@ begin
|
|||||||
or JITNonFormList.IsJITNonForm(AComponent);
|
or JITNonFormList.IsJITNonForm(AComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.GetJITListOfType(AncestorType: TComponentClass
|
function TCustomFormEditor.GetJITListOfType(AncestorType: TComponentClass): TJITComponentList;
|
||||||
): TJITComponentList;
|
|
||||||
begin
|
begin
|
||||||
if AncestorType.InheritsFrom(TForm) then
|
if AncestorType.InheritsFrom(TCustomForm) then
|
||||||
Result:=JITFormList
|
Result := JITFormList
|
||||||
else if AncestorType.InheritsFrom(TComponent) then
|
|
||||||
Result:=JITNonFormList
|
|
||||||
else
|
else
|
||||||
Result:=nil;
|
if AncestorType.InheritsFrom(TComponent) then
|
||||||
|
Result := JITNonFormList
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.FindJITList(AComponent: TComponent
|
function TCustomFormEditor.FindJITList(AComponent: TComponent): TJITComponentList;
|
||||||
): TJITComponentList;
|
|
||||||
begin
|
begin
|
||||||
if JITFormList.IndexOf(AComponent)>=0 then
|
if JITFormList.IndexOf(AComponent) >= 0 then
|
||||||
Result:=JITFormList
|
Result := JITFormList
|
||||||
else if JITNonFormList.IndexOf(AComponent)>=0 then
|
|
||||||
Result:=JITNonFormList
|
|
||||||
else
|
else
|
||||||
Result:=nil;
|
if JITNonFormList.IndexOf(AComponent) >= 0 then
|
||||||
|
Result := JITNonFormList
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.FindJITListByClassName(
|
function TCustomFormEditor.FindJITListByClassName(const AComponentClassName: string): TJITComponentList;
|
||||||
const AComponentClassName: string): TJITComponentList;
|
|
||||||
begin
|
begin
|
||||||
if JITFormList.FindComponentByClassName(AComponentClassName)>=0 then
|
if JITFormList.FindComponentByClassName(AComponentClassName) >= 0 then
|
||||||
Result:=JITFormList
|
Result := JITFormList
|
||||||
else if JITNonFormList.FindComponentByClassName(AComponentClassName)>=0 then
|
|
||||||
Result:=JITNonFormList
|
|
||||||
else
|
else
|
||||||
Result:=nil;
|
if JITNonFormList.FindComponentByClassName(AComponentClassName) >= 0 then
|
||||||
|
Result := JITNonFormList
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.FindJITListByClass(AComponentClass: TComponentClass
|
function TCustomFormEditor.FindJITListByClass(AComponentClass: TComponentClass): TJITComponentList;
|
||||||
): TJITComponentList;
|
|
||||||
begin
|
begin
|
||||||
if JITFormList.FindComponentByClass(AComponentClass)>=0 then
|
if JITFormList.FindComponentByClass(AComponentClass) >= 0 then
|
||||||
Result:=JITFormList
|
Result := JITFormList
|
||||||
else if JITNonFormList.FindComponentByClass(AComponentClass)>=0 then
|
|
||||||
Result:=JITNonFormList
|
|
||||||
else
|
else
|
||||||
Result:=nil;
|
if JITNonFormList.FindComponentByClass(AComponentClass) >= 0 then
|
||||||
|
Result := JITNonFormList
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.GetDesignerForm(AComponent: TComponent): TCustomForm;
|
function TCustomFormEditor.GetDesignerForm(AComponent: TComponent): TCustomForm;
|
||||||
@ -1341,15 +1341,17 @@ function TCustomFormEditor.FindJITComponentByClassName(
|
|||||||
var
|
var
|
||||||
i: LongInt;
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result := nil;
|
||||||
i:=JITFormList.FindComponentByClassName(AComponentClassName);
|
i := JITFormList.FindComponentByClassName(AComponentClassName);
|
||||||
if i>=0 then begin
|
if i >= 0 then
|
||||||
Result:=JITFormList[i];
|
begin
|
||||||
|
Result := JITFormList[i];
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
i:=JITNonFormList.FindComponentByClassName(AComponentClassName);
|
i := JITNonFormList.FindComponentByClassName(AComponentClassName);
|
||||||
if i>=0 then begin
|
if i >= 0 then
|
||||||
Result:=JITNonFormList[i];
|
begin
|
||||||
|
Result := JITNonFormList[i];
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1359,15 +1361,17 @@ function TCustomFormEditor.FindJITComponentByClass(
|
|||||||
var
|
var
|
||||||
i: LongInt;
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result := nil;
|
||||||
i:=JITFormList.FindComponentByClass(AComponentClass);
|
i := JITFormList.FindComponentByClass(AComponentClass);
|
||||||
if i>=0 then begin
|
if i >= 0 then
|
||||||
Result:=JITFormList[i];
|
begin
|
||||||
|
Result := JITFormList[i];
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
i:=JITNonFormList.FindComponentByClass(AComponentClass);
|
i := JITNonFormList.FindComponentByClass(AComponentClass);
|
||||||
if i>=0 then begin
|
if i >= 0 then
|
||||||
Result:=JITNonFormList[i];
|
begin
|
||||||
|
Result := JITNonFormList[i];
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1489,11 +1493,12 @@ function TCustomFormEditor.GetDesigner(Index: integer): TIDesigner;
|
|||||||
var
|
var
|
||||||
AForm: TCustomForm;
|
AForm: TCustomForm;
|
||||||
begin
|
begin
|
||||||
if Index<JITFormList.Count then
|
if Index < JITFormList.Count then
|
||||||
Result:=JITFormList[Index].Designer
|
Result := JITFormList[Index].Designer
|
||||||
else begin
|
else
|
||||||
AForm:=GetDesignerForm(JITNonFormList[Index-JITFormList.Count]);
|
begin
|
||||||
Result:=TIDesigner(AForm.Designer);
|
AForm := GetDesignerForm(JITNonFormList[Index-JITFormList.Count]);
|
||||||
|
Result := TIDesigner(AForm.Designer);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user