From a51a45d3d2090ca31e9dbaa8bcc3fee2e169c0ee Mon Sep 17 00:00:00 2001 From: maxim Date: Mon, 16 Jan 2017 21:52:54 +0000 Subject: [PATCH] Merged revision(s) 53944 #8af43e0c0b, 53947 #dccf31997b, 53950 #f723ac55cd from trunk: LCL: Try to derive Time from the text in the control in TTimeEdit.GetTime, if DirectInput is True. Issue #0031227. ........ LCL: Make fix for Issue #0031227 a bit more safe (don't rely on implementation details of TryParseInput). ........ LCL: TPageControl: fixed TabIndexAtClientPos page index after invisible tab. Issue #30343 ........ git-svn-id: branches/fixes_1_6@53960 - --- lcl/comctrls.pp | 3 ++- lcl/editbtn.pas | 4 +++ lcl/include/customnotebook.inc | 46 ++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 923e24a73d..ecdacb03b8 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -468,7 +468,7 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; - function TabIndexAtClientPos(ClientPos: TPoint): integer; + function TabIndexAtClientPos(ClientPos: TPoint): integer; deprecated 'Will be deleted in next major Lazarus release, use IndexOfPageAt'; function TabRect(AIndex: Integer): TRect; function GetImageIndex(ThePageIndex: Integer): Integer; virtual; function IndexOf(APage: TPersistent): integer; virtual; @@ -480,6 +480,7 @@ type function TabToPageIndex(AIndex: integer): integer; function PageToTabIndex(AIndex: integer): integer; function IndexOfTabAt(X, Y: Integer): Integer; + function IndexOfPageAt(X, Y: Integer): Integer; public procedure DoCloseTabClicked(APage: TCustomPage); virtual; property Images: TCustomImageList read FImages write SetImages; diff --git a/lcl/editbtn.pas b/lcl/editbtn.pas index 7168116552..75ab68570f 100644 --- a/lcl/editbtn.pas +++ b/lcl/editbtn.pas @@ -2993,7 +2993,11 @@ end; { TTimeEdit } function TTimeEdit.GetTime: TDateTime; +var + TmpResult: TDateTime; begin + if DirectInput and TryParseInput(Text, TmpResult) then + FTime := TmpResult; Result := FTime; if IsEmptyTime then begin if FDefaultNow then diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index d6d52a3df0..3cf5680e9a 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -349,27 +349,15 @@ end; NoteBook1.ScreenToClient(Mouse.CursorPos)); ------------------------------------------------------------------------------} function TCustomTabControl.TabIndexAtClientPos(ClientPos: TPoint): integer; -var - i, VisiblePageInd: Integer; begin if HandleAllocated then begin - Result:=TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, ClientPos); + Result := TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, ClientPos); // Result is the index in visible tabs because invisible tabs are removed // from the native control. Calculate the real tab index here. - VisiblePageInd:=-1; - for i:=0 to PageCount-1 do begin - if Page[i].TabVisible then - Inc(VisiblePageInd) - else begin - if VisiblePageInd < Result then - Inc(Result) - else - Break; - end; - end; + Result := TabToPageIndex(Result); end else - Result:=-1; + Result := -1; end; function TCustomTabControl.TabRect(AIndex: Integer): TRect; @@ -451,9 +439,35 @@ begin end; end; +{------------------------------------------------------------------------------ + function TCustomTabControl.IndexOfTabAt(X, Y: Integer): Integer; + + Returns the index of the visible tab at the client position. + For example: + Index:=NoteBook1.IndexOfTabAt( + NoteBook1.ScreenToClient(Mouse.CursorPos)); + ------------------------------------------------------------------------------} function TCustomTabControl.IndexOfTabAt(X, Y: Integer): Integer; begin - Result := TabIndexAtClientPos(Point(X, Y)); + if HandleAllocated then + Result := TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, Point(X, Y)) + else + Result := -1; +end; + +{------------------------------------------------------------------------------ + function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer; + + Returns the index of the page at the client position. + For example: + Index:=NoteBook1.IndexOfPageAt( + NoteBook1.ScreenToClient(Mouse.CursorPos)); + ------------------------------------------------------------------------------} +function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer; +begin + Result := IndexOfTabAt(X, Y); + if Result <> -1 then + Result := TabToPageIndex(Result); end; function TCustomTabControl.TabToPageIndex(AIndex: integer): integer;