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 -
This commit is contained in:
maxim 2017-01-16 21:52:54 +00:00
parent 3b2ee9a030
commit a51a45d3d2
3 changed files with 36 additions and 17 deletions

View File

@ -468,7 +468,7 @@ type
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; 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 TabRect(AIndex: Integer): TRect;
function GetImageIndex(ThePageIndex: Integer): Integer; virtual; function GetImageIndex(ThePageIndex: Integer): Integer; virtual;
function IndexOf(APage: TPersistent): integer; virtual; function IndexOf(APage: TPersistent): integer; virtual;
@ -480,6 +480,7 @@ type
function TabToPageIndex(AIndex: integer): integer; function TabToPageIndex(AIndex: integer): integer;
function PageToTabIndex(AIndex: integer): integer; function PageToTabIndex(AIndex: integer): integer;
function IndexOfTabAt(X, Y: Integer): Integer; function IndexOfTabAt(X, Y: Integer): Integer;
function IndexOfPageAt(X, Y: Integer): Integer;
public public
procedure DoCloseTabClicked(APage: TCustomPage); virtual; procedure DoCloseTabClicked(APage: TCustomPage); virtual;
property Images: TCustomImageList read FImages write SetImages; property Images: TCustomImageList read FImages write SetImages;

View File

@ -2993,7 +2993,11 @@ end;
{ TTimeEdit } { TTimeEdit }
function TTimeEdit.GetTime: TDateTime; function TTimeEdit.GetTime: TDateTime;
var
TmpResult: TDateTime;
begin begin
if DirectInput and TryParseInput(Text, TmpResult) then
FTime := TmpResult;
Result := FTime; Result := FTime;
if IsEmptyTime then begin if IsEmptyTime then begin
if FDefaultNow then if FDefaultNow then

View File

@ -349,24 +349,12 @@ end;
NoteBook1.ScreenToClient(Mouse.CursorPos)); NoteBook1.ScreenToClient(Mouse.CursorPos));
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCustomTabControl.TabIndexAtClientPos(ClientPos: TPoint): integer; function TCustomTabControl.TabIndexAtClientPos(ClientPos: TPoint): integer;
var
i, VisiblePageInd: Integer;
begin begin
if HandleAllocated then 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 // Result is the index in visible tabs because invisible tabs are removed
// from the native control. Calculate the real tab index here. // from the native control. Calculate the real tab index here.
VisiblePageInd:=-1; Result := TabToPageIndex(Result);
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;
end end
else else
Result := -1; Result := -1;
@ -451,9 +439,35 @@ begin
end; end;
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; function TCustomTabControl.IndexOfTabAt(X, Y: Integer): Integer;
begin 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; end;
function TCustomTabControl.TabToPageIndex(AIndex: integer): integer; function TCustomTabControl.TabToPageIndex(AIndex: integer): integer;