LCL: TCustomTabControl: overload IndexOfTabAt and IndexOfPageAt to further use TPoint

git-svn-id: trunk@53952 -
This commit is contained in:
michl 2017-01-15 22:31:18 +00:00
parent 32b4763c04
commit 684c92d6d4
2 changed files with 28 additions and 6 deletions

View File

@ -482,8 +482,10 @@ type
function GetCapabilities: TNoteBookCapabilities; virtual;
function TabToPageIndex(AIndex: integer): integer;
function PageToTabIndex(AIndex: integer): integer;
function IndexOfTabAt(X, Y: Integer): Integer;
function IndexOfPageAt(X, Y: Integer): Integer;
function IndexOfTabAt(X, Y: Integer): Integer; overload;
function IndexOfTabAt(P: TPoint): Integer; overload;
function IndexOfPageAt(X, Y: Integer): Integer; overload;
function IndexOfPageAt(P: TPoint): Integer; overload;
public
procedure DoCloseTabClicked(APage: TCustomPage); virtual;
property Images: TCustomImageList read FImages write SetImages;

View File

@ -458,19 +458,39 @@ end;
{------------------------------------------------------------------------------
function TCustomTabControl.IndexOfTabAt(X, Y: Integer): Integer;
Returns the index of the visible tab at the client position.
------------------------------------------------------------------------------}
function TCustomTabControl.IndexOfTabAt(X, Y: Integer): Integer;
begin
Result := IndexOfTabAt(Point(X, Y));
end;
{------------------------------------------------------------------------------
function TCustomTabControl.IndexOfTabAt(P: TPoint): 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(P: TPoint): Integer;
begin
if HandleAllocated then
Result := TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, Point(X, Y))
Result := TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, P)
else
Result := -1;
end;
{------------------------------------------------------------------------------
function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer;
Returns the index of the page at the client position.
------------------------------------------------------------------------------}
function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer;
begin
Result := IndexOfPageAt(Point(X, Y));
end;
{------------------------------------------------------------------------------
function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer;
@ -479,9 +499,9 @@ end;
Index:=NoteBook1.IndexOfPageAt(
NoteBook1.ScreenToClient(Mouse.CursorPos));
------------------------------------------------------------------------------}
function TCustomTabControl.IndexOfPageAt(X, Y: Integer): Integer;
function TCustomTabControl.IndexOfPageAt(P: TPoint): Integer;
begin
Result := IndexOfTabAt(X, Y);
Result := IndexOfTabAt(P);
if Result <> -1 then
Result := TabToPageIndex(Result);
end;