lcl: add TPage.PageIndex and TNotebook.IndexOf

git-svn-id: trunk@52343 -
This commit is contained in:
ondrej 2016-05-22 10:12:03 +00:00
parent 6b94a5fca9
commit d22c7ed37a
3 changed files with 20 additions and 1 deletions

View File

@ -42,11 +42,14 @@ type
TPage = class(TCustomControl)
private
FOnBeforeShow: TBeforeShowPageEvent;
function GetPageIndex: Integer;
protected
procedure SetParent(AParent: TWinControl); override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
public
property PageIndex: Integer read GetPageIndex;
published
// Lazarus-specific TPage events
// OnBeforeShow occurs before a page is displayed, so that
@ -128,8 +131,8 @@ type
{ function TabIndexAtClientPos(ClientPos: TPoint): integer;
function TabRect(AIndex: Integer): TRect;
function GetImageIndex(ThePageIndex: Integer): Integer; virtual;
function IndexOf(APage: TCustomPage): integer;
function CustomPage(Index: integer): TCustomPage;}
function IndexOf(APage: TPage): integer;
public
property ActivePage: String read GetActivePage;// write SetActivePage; // should not be published because the read can raise an exception
property ActivePageComponent: TPage read GetActivePageComponent;// write SetActivePage; // should not be published because the read can raise an exception

View File

@ -154,6 +154,15 @@ begin
Result := FPageIndex;
end;
function TNotebook.IndexOf(APage: TPage): integer;
begin
for Result := 0 to PageCount-1 do
if Page[Result] = APage then
Exit;
Result := -1;
end;
procedure TNotebook.InsertPage(APage: TPage; Index: Integer);
begin
if FPageList.IndexOf(APage) >= 0 then Exit;

View File

@ -73,6 +73,13 @@ begin
inherited Destroy;
end;
function TPage.GetPageIndex: Integer;
begin
if Parent is TNotebook then
Result := TNotebook(Parent).IndexOf(Self)
else
Result := -1;
end;
// included by extctrls.pp