jvcllaz: Some corrections of TJvNotebookPageList. Issue #36956, patch by Michal Gawrycki.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7398 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-04-24 16:29:11 +00:00
parent 71e0209dda
commit cbf60e2a8b

View File

@ -21,7 +21,7 @@ unit JvNotebookPageList;
interface interface
uses uses
Classes, SysUtils, ExtCtrls, Classes, SysUtils, ExtCtrls, LCLVersion,
JvPageList; JvPageList;
type type
@ -72,13 +72,8 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TJvNotebookPageList.AddPage(const ACaption: String); procedure TJvNotebookPageList.AddPage(const ACaption: String);
var
idx: Integer;
lPage: TPage;
begin begin
idx := Pages.Add(ACaption); Pages.Add(ACaption);
lPage := Page[idx];
lPage.Name := GetUniqueName(Self, 'TPage');
end; end;
function TJvNotebookPageList.CanChange(AIndex: Integer): Boolean; function TJvNotebookPageList.CanChange(AIndex: Integer): Boolean;
@ -95,7 +90,7 @@ end;
function TJvNotebookPageList.GetPageCaption(AIndex: Integer): string; function TJvNotebookPageList.GetPageCaption(AIndex: Integer): string;
begin begin
Result := Pages[AIndex]; Result := Page[AIndex].Caption;
end; end;
function TJvNotebookPageList.GetPageCount: Integer; function TJvNotebookPageList.GetPageCount: Integer;
@ -105,13 +100,19 @@ end;
procedure TJvNotebookPageList.MovePage(CurIndex, NewIndex: Integer); procedure TJvNotebookPageList.MovePage(CurIndex, NewIndex: Integer);
begin begin
{$IF LCL_FullVersion >= 2010000}
Pages.Move(CurIndex, NewIndex); // Fix for issue #36956
{$ELSE}
Pages.Exchange(CurIndex, NewIndex); Pages.Exchange(CurIndex, NewIndex);
// Note: This code is not working (issue #36956), it exchanges the captions,
// not the pages. Required changes in TNotebook are available only in Laz 2.1+
{$IFEND}
end; end;
procedure TJvNotebookPagelist.PageCaptionChanged(AIndex: Integer; procedure TJvNotebookPagelist.PageCaptionChanged(AIndex: Integer;
const NewCaption: string); const NewCaption: string);
begin begin
Pages[AIndex] := NewCaption; Page[AIndex].Caption := NewCaption;
end; end;
procedure TJvNotebookPageList.SetActivePageIndex(AIndex: Integer); procedure TJvNotebookPageList.SetActivePageIndex(AIndex: Integer);