IDE: designer: implemented creating a nested frame

git-svn-id: trunk@15226 -
This commit is contained in:
mattias 2008-05-25 16:30:59 +00:00
parent 07802eab4d
commit 29eab2b98f
3 changed files with 34 additions and 8 deletions

View File

@ -74,6 +74,7 @@ type
TLFMObjectNode = class(TLFMTreeNode)
public
IsInherited: boolean;
IsInline: boolean;
ChildPos: Integer;
Name: string;
NamePosition: integer;
@ -413,7 +414,8 @@ begin
repeat
ProcessObject;
until (not Parser.TokenSymbolIs('OBJECT'))
and (not Parser.TokenSymbolIs('INHERITED'));
and (not Parser.TokenSymbolIs('INHERITED'))
and (not Parser.TokenSymbolIs('INLINE'));
Result:=true;
except
on E: EParserError do begin
@ -730,9 +732,11 @@ begin
ObjectNode:=TLFMObjectNode(CurNode);
if Parser.TokenSymbolIs('OBJECT') then
ObjectNode.IsInherited := False
else if Parser.TokenSymbolIs('INHERITED') then
ObjectNode.IsInherited := True
else begin
Parser.CheckTokenSymbol('INHERITED');
ObjectNode.IsInherited := True;
Parser.CheckTokenSymbol('INLINE');
ObjectNode.IsInline := True;
end;
NextToken;
Parser.CheckToken(toSymbol);
@ -763,7 +767,8 @@ begin
// read property list
while not (Parser.TokenSymbolIs('END')
or Parser.TokenSymbolIs('OBJECT')
or Parser.TokenSymbolIs('INHERITED')) do
or Parser.TokenSymbolIs('INHERITED')
or Parser.TokenSymbolIs('INLINE')) do
ProcessProperty;
// read child objects
@ -893,7 +898,7 @@ begin
inc(IdentEnd);
if TheType=lfmnObject then begin
// skip object/inherited
// skip object/inherited/inline
IdentStart:=IdentEnd;
while (IdentStart<=SrcLen) and (Src[IdentStart] in [#0..#32]) do
inc(IdentStart);

View File

@ -1590,6 +1590,9 @@ procedure TJITComponentList.ReaderCreateComponent(Reader: TReader;
var
DestroyDriver: Boolean;
SubReader: TReader;
BinStream: TExtMemoryStream;
IsBaseClass: boolean;
Abort: boolean;
{$ENDIF}
begin
fCurReadChild:=Component;
@ -1601,6 +1604,7 @@ begin
DestroyDriver:=false;
SubReader:=nil;
try
Abort:=false;
OnFindAncestorBinStream(Self, ComponentClass, BinStream, IsBaseClass, Abort);
if Abort then begin
DebugLn(['TJITComponentList.ReaderCreateComponent aborted reading ComponentClass=',DbgSName(ComponentClass)]);
@ -1611,15 +1615,31 @@ begin
DebugLn(['TJITComponentList.ReaderCreateComponent Has Stream: ',DbgSName(ComponentClass),' IsBaseClass=',IsBaseClass]);
if Component=nil then begin
DebugLn(['TJITComponentList.ReaderCreateComponent creating ',DbgSName(ComponentClass),' Owner=',DbgSName(Reader.Owner),' ...']);
Component:=ComponentClass.Create(Reader.Owner);
// allocate memory without running the constructor
Component:=TComponent(ComponentClass.newinstance);
// set csDesigning and csDesignInstance
// csDesigning is set for all components at designtime
// csDesignInstance is set for Delphi compatibility. It is used by TFrame.
SetComponentDesignMode(Component,true);
SetComponentDesignInstanceMode(Component,true);
// this is a streamed sub component => set csInline
SetComponentInlineMode(Component,true);
// now run the constructor
Component.Create(Reader.Owner);
end;
fCurReadChild:=Component;
fCurReadChildClass:=ComponentClass;
DestroyDriver:=false;
CreateReader(BinStream,SubReader,DestroyDriver);
SubReader.ReadRootComponent(Component);
end;
finally
if DestroyDriver then SubReader.Driver.Free;
SubReader.Free;
BinStream.Free;
end;
fCurReadChild:=Component;
fCurReadChildClass:=ComponentClass;
end;
{$ENDIF}
//debugln(['[TJITComponentList.ReaderCreateComponent] Class=',ComponentClass.ClassName,' Component=',dbgsName(Component)]);

View File

@ -105,7 +105,8 @@ begin
inherited Create(AOwner);
ControlStyle:=[csAcceptsControls,csCaptureMouse,csClickEvents,csSetCaption,
csDoubleClicks, csParentBackground];
if (ClassType<>TFrame) and not (csDesignInstance in ComponentState) then begin
if (ClassType<>TFrame) and ([csDesignInstance,csDesigning]*ComponentState=[])
then begin
if not InitInheritedComponent(Self,TFrame) then
raise EResNotFound.CreateFmt(rsResourceNotFound, [ClassName]);
end else begin