@@ -137,6 +137,7 @@ TFrameStand = class(TComponent)
137
137
FCommonActionList: TActionList;
138
138
FCommonActionPrefix: string;
139
139
FOnBindCommonActionList: TOnBindCommonActionList;
140
+ FDefaultParent: TFmxObject;
140
141
function GetCount : Integer;
141
142
protected
142
143
FFrameInfos: TObjectDictionary<TFrame, TFrameInfo<TFrame>>;
@@ -160,12 +161,13 @@ TFrameStand = class(TComponent)
160
161
property CommonActions: TCommonActionDictionary read FCommonActions;
161
162
property FrameInfos: TObjectDictionary<TFrame, TFrameInfo<TFrame>> read FFrameInfos;
162
163
published
163
- property StyleBook: TStyleBook read FStyleBook write FStyleBook;
164
- property DefaultStyleName: string read FDefaultStyleName write FDefaultStyleName;
165
164
property AnimationShow: string read FAnimationShow write FAnimationShow;
166
165
property AnimationHide: string read FAnimationHide write FAnimationHide;
167
166
property CommonActionList: TActionList read FCommonActionList write FCommonActionList;
168
167
property CommonActionPrefix: string read FCommonActionPrefix write FCommonActionPrefix;
168
+ property DefaultStyleName: string read FDefaultStyleName write FDefaultStyleName;
169
+ property DefaultParent: TFmxObject read FDefaultParent write FDefaultParent;
170
+ property StyleBook: TStyleBook read FStyleBook write FStyleBook;
169
171
170
172
// Events
171
173
property OnBeforeShow: TOnBeforeShowEvent read FOnBeforeShow write FOnBeforeShow;
@@ -219,7 +221,10 @@ function TFrameStand.GetCount: Integer;
219
221
220
222
function TFrameStand.GetDefaultParent : TFmxObject;
221
223
begin
222
- Result := Self.Owner as TFmxObject;
224
+ if Assigned(FDefaultParent) then
225
+ Result := FDefaultParent
226
+ else
227
+ Result := Self.Owner as TFmxObject;
223
228
end ;
224
229
225
230
function TFrameStand.GetFrameClass <T>(const AParent: TFmxObject; const AStandStyleName: string): TFrameClass;
@@ -259,11 +264,16 @@ function TFrameStand.Use<T>(const AFrame: T; const AParent: TFmxObject; const AS
259
264
function TFrameStand.New <T>(const AParent: TFmxObject; const AStandStyleName: string): TFrameInfo<T>;
260
265
var
261
266
LFrame: T;
267
+ LParent: TFmxObject;
262
268
begin
263
- LFrame := T(GetFrameClass<T>(AParent, AStandStyleName).Create(nil ));
269
+ LParent := AParent;
270
+ if not Assigned(LParent) then
271
+ LParent := GetDefaultParent;
272
+
273
+ LFrame := T(GetFrameClass<T>(LParent, AStandStyleName).Create(nil ));
264
274
try
265
275
LFrame.Name := ' ' ;
266
- Result := Use<T>(LFrame, AParent , AStandStyleName);
276
+ Result := Use<T>(LFrame, LParent , AStandStyleName);
267
277
Result.FrameIsOwned := True;
268
278
except
269
279
LFrame.Free;
@@ -281,7 +291,9 @@ procedure TFrameStand.Notification(AComponent: TComponent;
281
291
if (AComponent = FStyleBook) then
282
292
FStyleBook := nil
283
293
else if (AComponent = FCommonActionList) then
284
- FCommonActionList := nil ;
294
+ FCommonActionList := nil
295
+ else if (AComponent = FDefaultParent) then
296
+ FDefaultParent := nil ;
285
297
end ;
286
298
end ;
287
299
0 commit comments