From 9a0bc7076fb7ccc89646a93425bbcbd56d5e9db4 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 3 Nov 2011 13:44:24 +0000 Subject: [PATCH] customdrawn: Many small pagecontrol fixes git-svn-id: trunk@33263 - --- .../customdrawn/customdrawncontrols.pas | 20 ++++++++++++++++--- components/customdrawn/customdrawnutils.pas | 1 - 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/customdrawn/customdrawncontrols.pas b/components/customdrawn/customdrawncontrols.pas index cd67bc2c40..b2b7808236 100644 --- a/components/customdrawn/customdrawncontrols.pas +++ b/components/customdrawn/customdrawncontrols.pas @@ -381,7 +381,8 @@ type destructor Destroy; override; function InsertPage(aIndex: integer; S: string): TCDTabSheet; procedure RemovePage(aIndex: integer); - function AddPage(S: string): TCDTabSheet; + function AddPage(S: string): TCDTabSheet; overload; + procedure AddPage(APage: TCDTabSheet); overload; function GetPage(aIndex: integer): TCDTabSheet; property PageCount: integer read GetPageCount; // Used by the property editor in customdrawnextras @@ -1268,7 +1269,11 @@ end; procedure TCDTabSheet.SetParent(NewParent: TWinControl); begin inherited SetParent(NewParent); - CDTabControl := NewParent as TCDCustomTabControl; + if (NewParent <> nil) and (NewParent is TCDPageControl) then + begin + CDTabControl := NewParent as TCDCustomTabControl; + TCDPageControl(CDTabControl).AddPage(Self); + end; end; constructor TCDTabSheet.Create(AOwner: TComponent); @@ -1342,6 +1347,14 @@ begin Result := NewPage; end; +procedure TCDPageControl.AddPage(APage: TCDTabSheet); +begin + APage.CDTabControl := Self; + PositionTabSheet(APage); + FTabs.AddObject(APage.Caption, APage); + SetActivePage(APage); +end; + function TCDPageControl.GetPage(AIndex: integer): TCDTabSheet; begin if (AIndex >= 0) and (AIndex < FTabs.Count) then @@ -1503,9 +1516,10 @@ procedure TCDPageControl.PositionTabSheet(ATabSheet: TCDTabSheet); var lTabHeight, lIndex: Integer; begin -// ATabSheet.SetBounds(1, 32 + 1, Width - 3, Height - 32 - 4); lIndex := FTabs.IndexOfObject(ATabSheet); FTabCState.TabIndex := lIndex; + PrepareControlState; + PrepareControlStateEx; lTabHeight := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_HEIGHT, FState, FStateEx); ATabSheet.BorderSpacing.Top := lTabHeight; ATabSheet.BorderSpacing.Left := 2; diff --git a/components/customdrawn/customdrawnutils.pas b/components/customdrawn/customdrawnutils.pas index 2c62312bf5..b6e014af4e 100644 --- a/components/customdrawn/customdrawnutils.pas +++ b/components/customdrawn/customdrawnutils.pas @@ -25,7 +25,6 @@ procedure GradCenterFill(Canvas: TFPCustomCanvas; aRect: TRect; procedure DrawAndroidButton(Canvas: TCanvas; Color: TColor); procedure DrawXPTaskbarButton(Canvas: TCanvas; Color: TColor); procedure FPImgCloneRect(IntfImg1, IntfImg2: TLazIntfImage; lRect: TRect; Fast: boolean); -function GetUniqueName(const Name: string; PControl: TComponent): string; procedure DrawArrow(aDest: TFPCustomCanvas; aRect: TRect; R: boolean); procedure DrawCDButtonDown(Canvas: TCanvas; ABackgroundColor: TColor);