From d90cad29721f922960c3b64c4e2e70353d10111d Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 28 Mar 2007 04:48:30 +0000 Subject: [PATCH] - moved DoShow, DoHide, OnShow, OnHide from TTabSheet to TCustomPage (ancestor) - fireing OnShow and OnHide on page changing git-svn-id: trunk@10816 - --- lcl/comctrls.pp | 9 ++------- lcl/extctrls.pp | 6 ++++++ lcl/include/customnotebook.inc | 12 +++++++++++- lcl/include/custompage.inc | 12 ++++++++++++ lcl/include/tabsheet.inc | 10 ---------- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 55e786ab8b..73ec49c055 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -177,15 +177,10 @@ type TTabSheet = class(TCustomPage) private - FOnHide: TNotifyEvent; - FOnShow: TNotifyEvent; function GetPageControl: TPageControl; function GetTabIndex: Integer; procedure SetPageControl(APageControl: TPageControl); procedure SetTabIndex(const AValue: Integer); - protected - procedure DoHide; dynamic; - procedure DoShow; dynamic; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -206,12 +201,12 @@ type property OnEndDrag; property OnEnter; property OnExit; - property OnHide: TNotifyEvent read FOnHide write FOnHide; + property OnHide; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnResize; - property OnShow: TNotifyEvent read FOnShow write FOnShow; + property OnShow; property OnStartDrag; property PageIndex stored False; property ParentFont; diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index 8a73fb907c..245f225be7 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -54,6 +54,8 @@ type FTabVisible: Boolean; FFlags: TPageFlags; FImageIndex: integer; + FOnHide: TNotifyEvent; + FOnShow: TNotifyEvent; function GetTabVisible: Boolean; procedure SetImageIndex(const AValue: integer); procedure SetTabVisible(const AValue: Boolean); @@ -65,6 +67,8 @@ type function GetPageIndex: integer; procedure SetPageIndex(AValue: Integer); function DialogChar(var Message: TLMKey): boolean; override; + procedure DoHide; dynamic; + procedure DoShow; dynamic; public constructor Create(TheOwner: TComponent); override; procedure AdjustClientRect(var ARect: TRect); override; @@ -81,6 +85,8 @@ type property Height stored False; property TabOrder stored False; property Visible stored false; + property OnHide: TNotifyEvent read FOnHide write FOnHide; + property OnShow: TNotifyEvent read FOnShow write FOnShow; end; TCustomPageClass = class of TCustomPage; diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index e4a6a50995..5c76f310cf 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -716,8 +716,8 @@ end; ------------------------------------------------------------------------------} procedure TCustomNotebook.Change; Begin - fPageIndexOnLastChange:=fPageIndex; ShowCurrentPage; + fPageIndexOnLastChange := fPageIndex; if ([csLoading,csDestroying]*ComponentState=[]) and (not fAddingPages) then begin if Assigned(fOnPageChanged) then fOnPageChanged(Self); @@ -794,7 +794,17 @@ end; procedure TCustomNotebook.ShowCurrentPage; begin if (FPageIndex >= 0) and (FPageIndex < PageCount) then + begin Page[FPageIndex].Visible := true; + Page[FPageIndex].DoShow; + if (FPageIndexOnLastChange >= 0) and (FPageIndexOnLastChange < PageCount) and + (FPageIndexOnLastChange <> FPageIndex) then + begin + // Page[FPageIndexOnLastChange].Visible := False; <-- this will be better, + // but this is not work on gtk (tab hides too) + Page[FPageIndexOnLastChange].DoHide; + end; + end; end; {------------------------------------------------------------------------------ diff --git a/lcl/include/custompage.inc b/lcl/include/custompage.inc index 2566116edd..b19e73b5a6 100644 --- a/lcl/include/custompage.inc +++ b/lcl/include/custompage.inc @@ -188,6 +188,18 @@ begin Result:=inherited DialogChar(Message); end; +procedure TCustomPage.DoHide; +begin + if Assigned(FOnHide) then + FOnHide(Self); +end; + +procedure TCustomPage.DoShow; +begin + if Assigned(FOnShow) then + FOnShow(Self); +end; + function TCustomPage.IsControlVisible: Boolean; begin if Parent is TCustomNotebook then diff --git a/lcl/include/tabsheet.inc b/lcl/include/tabsheet.inc index b740e2ab30..bfa42505d9 100644 --- a/lcl/include/tabsheet.inc +++ b/lcl/include/tabsheet.inc @@ -46,16 +46,6 @@ begin PageIndex:=AValue; end; -procedure TTabSheet.DoHide; -begin - -end; - -procedure TTabSheet.DoShow; -begin - -end; - constructor TTabSheet.Create(TheOwner: TComponent); begin inherited Create(TheOwner);