Skip to content

Commit

Permalink
* added DefaultParent property
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-magni committed Nov 3, 2015
1 parent 7538da2 commit a3bab6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/cpp/FrameStand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class PASCALIMPLEMENTATION TFrameStand : public System::Classes::TComponent
Fmx::Actnlist::TActionList* FCommonActionList;
System::UnicodeString FCommonActionPrefix;
TOnBindCommonActionList FOnBindCommonActionList;
Fmx::Types::TFmxObject* FDefaultParent;
int __fastcall GetCount(void);

protected:
Expand All @@ -322,12 +323,13 @@ class PASCALIMPLEMENTATION TFrameStand : public System::Classes::TComponent
__property System::Generics::Collections::TObjectDictionary__2<Fmx::Forms::TFrame*,TFrameInfo__1<Fmx::Forms::TFrame*>*>* FrameInfos = {read=FFrameInfos};

__published:
__property Fmx::Controls::TStyleBook* StyleBook = {read=FStyleBook, write=FStyleBook};
__property System::UnicodeString DefaultStyleName = {read=FDefaultStyleName, write=FDefaultStyleName};
__property System::UnicodeString AnimationShow = {read=FAnimationShow, write=FAnimationShow};
__property System::UnicodeString AnimationHide = {read=FAnimationHide, write=FAnimationHide};
__property Fmx::Actnlist::TActionList* CommonActionList = {read=FCommonActionList, write=FCommonActionList};
__property System::UnicodeString CommonActionPrefix = {read=FCommonActionPrefix, write=FCommonActionPrefix};
__property System::UnicodeString DefaultStyleName = {read=FDefaultStyleName, write=FDefaultStyleName};
__property Fmx::Types::TFmxObject* DefaultParent = {read=FDefaultParent, write=FDefaultParent};
__property Fmx::Controls::TStyleBook* StyleBook = {read=FStyleBook, write=FStyleBook};
__property TOnBeforeShowEvent OnBeforeShow = {read=FOnBeforeShow, write=FOnBeforeShow};
__property TOnBeforeStartAnimationEvent OnBeforeStartAnimation = {read=FOnBeforeStartAnimation, write=FOnBeforeStartAnimation};
__property TOnBindCommonActionList OnBindCommonActionList = {read=FOnBindCommonActionList, write=FOnBindCommonActionList};
Expand Down
24 changes: 18 additions & 6 deletions source/FrameStand.pas
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ TFrameStand = class(TComponent)
FCommonActionList: TActionList;
FCommonActionPrefix: string;
FOnBindCommonActionList: TOnBindCommonActionList;
FDefaultParent: TFmxObject;
function GetCount: Integer;
protected
FFrameInfos: TObjectDictionary<TFrame, TFrameInfo<TFrame>>;
Expand All @@ -160,12 +161,13 @@ TFrameStand = class(TComponent)
property CommonActions: TCommonActionDictionary read FCommonActions;
property FrameInfos: TObjectDictionary<TFrame, TFrameInfo<TFrame>> read FFrameInfos;
published
property StyleBook: TStyleBook read FStyleBook write FStyleBook;
property DefaultStyleName: string read FDefaultStyleName write FDefaultStyleName;
property AnimationShow: string read FAnimationShow write FAnimationShow;
property AnimationHide: string read FAnimationHide write FAnimationHide;
property CommonActionList: TActionList read FCommonActionList write FCommonActionList;
property CommonActionPrefix: string read FCommonActionPrefix write FCommonActionPrefix;
property DefaultStyleName: string read FDefaultStyleName write FDefaultStyleName;
property DefaultParent: TFmxObject read FDefaultParent write FDefaultParent;
property StyleBook: TStyleBook read FStyleBook write FStyleBook;

// Events
property OnBeforeShow: TOnBeforeShowEvent read FOnBeforeShow write FOnBeforeShow;
Expand Down Expand Up @@ -219,7 +221,10 @@ function TFrameStand.GetCount: Integer;

function TFrameStand.GetDefaultParent: TFmxObject;
begin
Result := Self.Owner as TFmxObject;
if Assigned(FDefaultParent) then
Result := FDefaultParent
else
Result := Self.Owner as TFmxObject;
end;

function TFrameStand.GetFrameClass<T>(const AParent: TFmxObject; const AStandStyleName: string): TFrameClass;
Expand Down Expand Up @@ -259,11 +264,16 @@ function TFrameStand.Use<T>(const AFrame: T; const AParent: TFmxObject; const AS
function TFrameStand.New<T>(const AParent: TFmxObject; const AStandStyleName: string): TFrameInfo<T>;
var
LFrame: T;
LParent: TFmxObject;
begin
LFrame := T(GetFrameClass<T>(AParent, AStandStyleName).Create(nil));
LParent := AParent;
if not Assigned(LParent) then
LParent := GetDefaultParent;

LFrame := T(GetFrameClass<T>(LParent, AStandStyleName).Create(nil));
try
LFrame.Name := '';
Result := Use<T>(LFrame, AParent, AStandStyleName);
Result := Use<T>(LFrame, LParent, AStandStyleName);
Result.FrameIsOwned := True;
except
LFrame.Free;
Expand All @@ -281,7 +291,9 @@ procedure TFrameStand.Notification(AComponent: TComponent;
if (AComponent = FStyleBook) then
FStyleBook := nil
else if (AComponent = FCommonActionList) then
FCommonActionList := nil;
FCommonActionList := nil
else if (AComponent = FDefaultParent) then
FDefaultParent := nil;
end;
end;

Expand Down

0 comments on commit a3bab6d

Please sign in to comment.