mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:19:34 +02:00
Replaces the current wrongly implement TPage and TNotebook with their correct implementations. TCustomPage and TCustomNotebook remain because they are used in TPageControl.
git-svn-id: trunk@28850 -
This commit is contained in:
parent
1fe899bfee
commit
cadb31f8a9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -4783,7 +4783,6 @@ lcl/include/toolwindow.inc svneol=native#text/pascal
|
|||||||
lcl/include/trackbar.inc svneol=native#text/pascal
|
lcl/include/trackbar.inc svneol=native#text/pascal
|
||||||
lcl/include/treeview.inc svneol=native#text/pascal
|
lcl/include/treeview.inc svneol=native#text/pascal
|
||||||
lcl/include/unixfileutil.inc svneol=native#text/plain
|
lcl/include/unixfileutil.inc svneol=native#text/plain
|
||||||
lcl/include/untabbednotebook.inc svneol=native#text/plain
|
|
||||||
lcl/include/winapi.inc svneol=native#text/pascal
|
lcl/include/winapi.inc svneol=native#text/pascal
|
||||||
lcl/include/winapih.inc svneol=native#text/pascal
|
lcl/include/winapih.inc svneol=native#text/pascal
|
||||||
lcl/include/wincontrol.inc svneol=native#text/pascal
|
lcl/include/wincontrol.inc svneol=native#text/pascal
|
||||||
|
@ -287,15 +287,15 @@ type
|
|||||||
function GetVerb(Index: Integer): string; override;
|
function GetVerb(Index: Integer): string; override;
|
||||||
function GetVerbCount: Integer; override;
|
function GetVerbCount: Integer; override;
|
||||||
procedure PrepareItem(Index: Integer; const AnItem: TMenuItem); override;
|
procedure PrepareItem(Index: Integer; const AnItem: TMenuItem); override;
|
||||||
function Notebook: TUntabbedNotebook; virtual;
|
function Notebook: TNotebook; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUNBPageComponentEditor
|
{ TUNBPageComponentEditor
|
||||||
The default component editor for TUNBPage. }
|
The default component editor for TUNBPage. }
|
||||||
TUNBPageComponentEditor = class(TUntabbedNotebookComponentEditor)
|
TUNBPageComponentEditor = class(TUntabbedNotebookComponentEditor)
|
||||||
public
|
public
|
||||||
function Notebook: TUntabbedNotebook; override;
|
function Notebook: TNotebook; override;
|
||||||
function Page: TUNBPage; virtual;
|
function Page: TPage; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTabControlComponentEditor
|
{ TTabControlComponentEditor
|
||||||
@ -932,7 +932,7 @@ procedure TUntabbedNotebookComponentEditor.AddNewPageToDesigner(Index: integer
|
|||||||
);
|
);
|
||||||
var
|
var
|
||||||
Hook: TPropertyEditorHook;
|
Hook: TPropertyEditorHook;
|
||||||
NewPage: TUNBPage;
|
NewPage: TPage;
|
||||||
NewName: string;
|
NewName: string;
|
||||||
begin
|
begin
|
||||||
Hook:=nil;
|
Hook:=nil;
|
||||||
@ -1034,25 +1034,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TUntabbedNotebookComponentEditor.Notebook: TUntabbedNotebook;
|
function TUntabbedNotebookComponentEditor.Notebook: TNotebook;
|
||||||
begin
|
begin
|
||||||
Result:=TUntabbedNotebook(GetComponent);
|
Result:=TNotebook(GetComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUNBPageComponentEditor }
|
{ TUNBPageComponentEditor }
|
||||||
|
|
||||||
function TUNBPageComponentEditor.Notebook: TUntabbedNotebook;
|
function TUNBPageComponentEditor.Notebook: TNotebook;
|
||||||
var
|
var
|
||||||
APage: TUNBPage;
|
APage: TPage;
|
||||||
begin
|
begin
|
||||||
APage:=Page;
|
APage:=Page;
|
||||||
if (APage.Parent<>nil) and (APage.Parent is TUntabbedNotebook) then
|
if (APage.Parent<>nil) and (APage.Parent is TNotebook) then
|
||||||
Result:=TUntabbedNotebook(APage.Parent);
|
Result:=TNotebook(APage.Parent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TUNBPageComponentEditor.Page: TUNBPage;
|
function TUNBPageComponentEditor.Page: TPage;
|
||||||
begin
|
begin
|
||||||
Result:=TUNBPage(GetComponent);
|
Result:=TPage(GetComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TStringGridComponentEditor }
|
{ TStringGridComponentEditor }
|
||||||
@ -1491,8 +1491,8 @@ initialization
|
|||||||
RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc;
|
RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc;
|
||||||
RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor);
|
RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor);
|
||||||
RegisterComponentEditor(TCustomPage, TPageComponentEditor);
|
RegisterComponentEditor(TCustomPage, TPageComponentEditor);
|
||||||
RegisterComponentEditor(TUntabbedNotebook, TUntabbedNotebookComponentEditor);
|
RegisterComponentEditor(TNotebook, TUntabbedNotebookComponentEditor);
|
||||||
RegisterComponentEditor(TUNBPage, TUNBPageComponentEditor);
|
RegisterComponentEditor(TPage, TUNBPageComponentEditor);
|
||||||
RegisterComponentEditor(TCustomTabControl, TTabControlComponentEditor);
|
RegisterComponentEditor(TCustomTabControl, TTabControlComponentEditor);
|
||||||
RegisterComponentEditor(TStringGrid, TStringGridComponentEditor);
|
RegisterComponentEditor(TStringGrid, TStringGridComponentEditor);
|
||||||
RegisterComponentEditor(TCheckListBox, TCheckListBoxComponentEditor);
|
RegisterComponentEditor(TCheckListBox, TCheckListBoxComponentEditor);
|
||||||
|
@ -424,7 +424,7 @@ type
|
|||||||
|
|
||||||
TTabControlNoteBookStrings = class(TTabControlStrings)
|
TTabControlNoteBookStrings = class(TTabControlStrings)
|
||||||
private
|
private
|
||||||
FNoteBook: TNoteBook{%H-};
|
FNoteBook: TCustomNoteBook{%H-};
|
||||||
protected
|
protected
|
||||||
function Get(Index: Integer): string; override;
|
function Get(Index: Integer): string; override;
|
||||||
function GetCount: Integer; override;
|
function GetCount: Integer; override;
|
||||||
@ -451,7 +451,7 @@ type
|
|||||||
procedure TabControlBoundsChange; override;
|
procedure TabControlBoundsChange; override;
|
||||||
function IndexOfTabAt(X, Y: Integer): Integer; override;
|
function IndexOfTabAt(X, Y: Integer): Integer; override;
|
||||||
public
|
public
|
||||||
property NoteBook: TNoteBook read FNoteBook;
|
property NoteBook: TCustomNoteBook read FNoteBook;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
116
lcl/extctrls.pp
116
lcl/extctrls.pp
@ -93,7 +93,6 @@ type
|
|||||||
|
|
||||||
TCustomPageClass = class of TCustomPage;
|
TCustomPageClass = class of TCustomPage;
|
||||||
|
|
||||||
|
|
||||||
{ TNBPages }
|
{ TNBPages }
|
||||||
|
|
||||||
TCustomNotebook = class;
|
TCustomNotebook = class;
|
||||||
@ -117,7 +116,6 @@ type
|
|||||||
procedure Move(CurIndex, NewIndex: Integer); override;
|
procedure Move(CurIndex, NewIndex: Integer); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TCustomNotebook }
|
{ TCustomNotebook }
|
||||||
|
|
||||||
TTabChangingEvent = procedure(Sender: TObject;
|
TTabChangingEvent = procedure(Sender: TObject;
|
||||||
@ -235,97 +233,13 @@ type
|
|||||||
property TabStop default true;
|
property TabStop default true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TPage }
|
{ TPage }
|
||||||
|
|
||||||
TPage = class(TCustomPage)
|
TPage = class;
|
||||||
published
|
|
||||||
property Caption;
|
|
||||||
property ChildSizing;
|
|
||||||
property ClientWidth;
|
|
||||||
property ClientHeight;
|
|
||||||
property Font;
|
|
||||||
property ImageIndex;
|
|
||||||
property Left stored False;
|
|
||||||
property Top stored False;
|
|
||||||
property Width stored False;
|
|
||||||
property Height stored False;
|
|
||||||
property OnContextPopup;
|
|
||||||
property OnEnter;
|
|
||||||
property OnExit;
|
|
||||||
property OnMouseDown;
|
|
||||||
property OnMouseEnter;
|
|
||||||
property OnMouseLeave;
|
|
||||||
property OnMouseMove;
|
|
||||||
property OnMouseUp;
|
|
||||||
property OnResize;
|
|
||||||
property PageIndex stored False;
|
|
||||||
property ParentFont;
|
|
||||||
property ParentShowHint;
|
|
||||||
property PopupMenu;
|
|
||||||
property TabOrder stored False;
|
|
||||||
property Visible stored False;
|
|
||||||
end deprecated;
|
|
||||||
|
|
||||||
|
TBeforeShowPageEvent = procedure (ASender: TObject; ANewPage: TPage; ANewIndex: Integer) of object;
|
||||||
|
|
||||||
{ TNotebook }
|
TPage = class(TCustomControl)
|
||||||
|
|
||||||
TNotebook = class(TCustomNotebook)
|
|
||||||
private
|
|
||||||
function GetActiveNotebookPageComponent: TPage;
|
|
||||||
function GetNoteBookPage(Index: Integer): TPage;
|
|
||||||
procedure SetActiveNotebookPageComponent(const AValue: TPage);
|
|
||||||
public
|
|
||||||
constructor Create(TheOwner: TComponent); override;
|
|
||||||
property Page[Index: Integer]: TPage read GetNoteBookPage;
|
|
||||||
property ActivePageComponent: TPage read GetActiveNotebookPageComponent
|
|
||||||
write SetActiveNotebookPageComponent;
|
|
||||||
property Pages;
|
|
||||||
published
|
|
||||||
property ActivePage;
|
|
||||||
property Align;
|
|
||||||
property Anchors;
|
|
||||||
property BorderSpacing;
|
|
||||||
property Constraints;
|
|
||||||
property DragCursor;
|
|
||||||
property DragMode;
|
|
||||||
property Enabled;
|
|
||||||
property Font;
|
|
||||||
property Images;
|
|
||||||
property OnChangeBounds;
|
|
||||||
property OnChanging;
|
|
||||||
property OnCloseTabClicked;
|
|
||||||
property OnContextPopup;
|
|
||||||
property OnDragDrop;
|
|
||||||
property OnDragOver;
|
|
||||||
property OnEndDrag;
|
|
||||||
property OnEnter;
|
|
||||||
property OnExit;
|
|
||||||
property OnGetImageIndex;
|
|
||||||
property OnMouseDown;
|
|
||||||
property OnMouseEnter;
|
|
||||||
property OnMouseLeave;
|
|
||||||
property OnMouseMove;
|
|
||||||
property OnMouseUp;
|
|
||||||
property OnPageChanged;
|
|
||||||
property OnResize;
|
|
||||||
property OnStartDrag;
|
|
||||||
property Options;
|
|
||||||
property PageIndex;
|
|
||||||
property ParentFont;
|
|
||||||
property PopupMenu;
|
|
||||||
property ShowTabs;
|
|
||||||
property TabOrder;
|
|
||||||
property TabStop;
|
|
||||||
end deprecated;
|
|
||||||
|
|
||||||
TUNBPage = class;
|
|
||||||
|
|
||||||
TBeforeShowPageEvent = procedure (ASender: TObject; ANewPage: TUNBPage; ANewIndex: Integer) of object;
|
|
||||||
|
|
||||||
{ TUNBPage }
|
|
||||||
|
|
||||||
TUNBPage = class(TCustomControl)
|
|
||||||
private
|
private
|
||||||
FOnBeforeShow: TBeforeShowPageEvent;
|
FOnBeforeShow: TBeforeShowPageEvent;
|
||||||
protected
|
protected
|
||||||
@ -363,12 +277,12 @@ type
|
|||||||
|
|
||||||
{ TUNBPages }
|
{ TUNBPages }
|
||||||
|
|
||||||
TUntabbedNotebook = class;
|
TNotebook = class;
|
||||||
|
|
||||||
TUNBPages = class(TStrings)
|
TUNBPages = class(TStrings)
|
||||||
private
|
private
|
||||||
FPageList: TListWithEvent;
|
FPageList: TListWithEvent;
|
||||||
FUNotebook: TUntabbedNotebook;
|
FNotebook: TNotebook;
|
||||||
procedure PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
procedure PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
||||||
protected
|
protected
|
||||||
function Get(Index: Integer): String; override;
|
function Get(Index: Integer): String; override;
|
||||||
@ -377,27 +291,27 @@ type
|
|||||||
procedure Put(Index: Integer; const S: String); override;
|
procedure Put(Index: Integer; const S: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(thePageList: TListWithEvent;
|
constructor Create(thePageList: TListWithEvent;
|
||||||
theUNotebook: TUntabbedNotebook);
|
theNotebook: TNotebook);
|
||||||
procedure Clear; override;
|
procedure Clear; override;
|
||||||
procedure Delete(Index: Integer); override;
|
procedure Delete(Index: Integer); override;
|
||||||
procedure Insert(Index: Integer; const S: String); override;
|
procedure Insert(Index: Integer; const S: String); override;
|
||||||
// procedure Move(CurIndex, NewIndex: Integer); override;
|
// procedure Move(CurIndex, NewIndex: Integer); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUntabbedNotebook }
|
{ TNotebook }
|
||||||
|
|
||||||
TUntabbedNotebook = class(TCustomControl)
|
TNotebook = class(TCustomControl)
|
||||||
private
|
private
|
||||||
FPages: TStrings; // TUNBPages
|
FPages: TStrings; // TUNBPages
|
||||||
FPageIndex: Integer;
|
FPageIndex: Integer;
|
||||||
FPageList: TListWithEvent;
|
FPageList: TListWithEvent;
|
||||||
{ function GetActivePage: String;
|
{ function GetActivePage: String;
|
||||||
function GetActivePageComponent: TCustomPage;}
|
function GetActivePageComponent: TCustomPage;}
|
||||||
function GetPage(AIndex: Integer): TUNBPage;
|
function GetPage(AIndex: Integer): TPage;
|
||||||
// function GetPageCount : integer;
|
// function GetPageCount : integer;
|
||||||
function GetPageIndex: Integer;
|
function GetPageIndex: Integer;
|
||||||
{ function FindVisiblePage(Index: Integer): Integer;}
|
{ function FindVisiblePage(Index: Integer): Integer;}
|
||||||
procedure InsertPage(APage: TUNBPage; Index: Integer);
|
procedure InsertPage(APage: TPage; Index: Integer);
|
||||||
{ procedure MovePage(APage: TCustomPage; NewIndex: Integer);
|
{ procedure MovePage(APage: TCustomPage; NewIndex: Integer);
|
||||||
procedure RemovePage(Index: Integer);
|
procedure RemovePage(Index: Integer);
|
||||||
procedure SetActivePage(const Value: String);}
|
procedure SetActivePage(const Value: String);}
|
||||||
@ -412,7 +326,7 @@ type
|
|||||||
function IndexOf(APage: TCustomPage): integer;
|
function IndexOf(APage: TCustomPage): integer;
|
||||||
function CustomPage(Index: integer): TCustomPage;}
|
function CustomPage(Index: integer): TCustomPage;}
|
||||||
public
|
public
|
||||||
property Page[Index: Integer]: TUNBPage read GetPage;
|
property Page[Index: Integer]: TPage read GetPage;
|
||||||
// property PageCount: integer read GetPageCount;
|
// property PageCount: integer read GetPageCount;
|
||||||
// property PageList: TList read FPageList;
|
// property PageList: TList read FPageList;
|
||||||
published
|
published
|
||||||
@ -1395,17 +1309,15 @@ procedure Register;
|
|||||||
begin
|
begin
|
||||||
RegisterComponents('Standard',[TRadioGroup,TCheckGroup,TPanel]);
|
RegisterComponents('Standard',[TRadioGroup,TCheckGroup,TPanel]);
|
||||||
RegisterComponents('Additional',[TImage,TShape,TBevel,TPaintBox,
|
RegisterComponents('Additional',[TImage,TShape,TBevel,TPaintBox,
|
||||||
{$ifdef INSTALL_TUNTABBEDNOTEBOOK} TUntabbedNotebook, {$ENDIF}
|
TNotebook, TLabeledEdit, TSplitter, TTrayIcon]);
|
||||||
TLabeledEdit, TSplitter, TTrayIcon]);
|
|
||||||
RegisterComponents('System',[TTimer,TIdleTimer]);
|
RegisterComponents('System',[TTimer,TIdleTimer]);
|
||||||
RegisterNoIcon([TNotebook{%H-}, TPage{$ifdef INSTALL_TUNTABBEDNOTEBOOK}, TUNBPage{$ENDIF}]);
|
RegisterNoIcon([TPage]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$I custompage.inc}
|
{$I custompage.inc}
|
||||||
{$I page.inc}
|
|
||||||
{$I customnotebook.inc}
|
{$I customnotebook.inc}
|
||||||
|
{$I page.inc}
|
||||||
{$I notebook.inc}
|
{$I notebook.inc}
|
||||||
{$I untabbednotebook.inc}
|
|
||||||
{$I timer.inc}
|
{$I timer.inc}
|
||||||
{$I idletimer.inc}
|
{$I idletimer.inc}
|
||||||
{$I shape.inc}
|
{$I shape.inc}
|
||||||
|
@ -17,27 +17,198 @@
|
|||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
function TNotebook.GetActiveNotebookPageComponent: TPage;
|
{******************************************************************************
|
||||||
|
TUNBPages
|
||||||
|
******************************************************************************}
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Constructor
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
constructor TUNBPages.Create(thePageList: TListWithEvent;
|
||||||
|
theNotebook: TNotebook);
|
||||||
begin
|
begin
|
||||||
Result:=TPage{%H-}(GetActivePageComponent);
|
inherited Create;
|
||||||
|
fPageList := thePageList;
|
||||||
|
fPageList.OnChange:=@PageListChange;
|
||||||
|
fNotebook := theNotebook;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNotebook.GetNoteBookPage(Index: Integer): TPage;
|
{------------------------------------------------------------------------------
|
||||||
|
procedure TUNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TUNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
||||||
|
{var
|
||||||
|
APage: TUNBPage;}
|
||||||
begin
|
begin
|
||||||
Result:=TPage{%H-}(GetPage(Index));
|
{ if (AnAction=lnAdded) then
|
||||||
|
begin
|
||||||
|
APage:=TObject(Ptr) as TUNBPage;
|
||||||
|
if not (pfInserting in APage.FFlags) then
|
||||||
|
APage.Parent:=fNotebook;
|
||||||
|
end;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNotebook.SetActiveNotebookPageComponent(const AValue: TPage);
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Get
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TUNBPages.Get(Index: Integer): string;
|
||||||
begin
|
begin
|
||||||
SetActivePageComponent(AValue);
|
if (Index<0) or (Index>=fPageList.Count) then
|
||||||
|
RaiseGDBException('TUNBPages.Get Index out of bounds');
|
||||||
|
Result := TPage(fPageList[Index]).Caption;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages GetCount
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TUNBPages.GetCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := fPageList.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages GetObject
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TUNBPages.GetObject(Index: Integer): TObject;
|
||||||
|
begin
|
||||||
|
if (Index<0) or (Index>=fPageList.Count) then
|
||||||
|
RaiseGDBException('TUNBPages.GetObject Index out of bounds');
|
||||||
|
Result := TPage(fPageList[Index]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Put
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TUNBPages.Put(Index: Integer; const S: String);
|
||||||
|
begin
|
||||||
|
if (Index<0) or (Index>=fPageList.Count) then
|
||||||
|
RaiseGDBException('TUNBPages.Put Index out of bounds');
|
||||||
|
//debugln(['TUNBPages.Put ',DbgSName(FNotebook),' ',Index,' S="',S,'"']);
|
||||||
|
TPage(fPageList[Index]).Caption := S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Clear
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TUNBPages.Clear;
|
||||||
|
begin
|
||||||
|
while fPageList.Count>0 do
|
||||||
|
Delete(fPageList.Count-1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Delete
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TUNBPages.Delete(Index: Integer);
|
||||||
|
var
|
||||||
|
APage: TCustomPage;
|
||||||
|
begin
|
||||||
|
// Make sure Index is in the range of valid pages to delete
|
||||||
|
if (Index < 0) or (Index >= fPageList.Count) then Exit;
|
||||||
|
|
||||||
|
APage := TCustomPage(fPageList[Index]);
|
||||||
|
// delete handle
|
||||||
|
APage.Parent := nil;
|
||||||
|
// free the page
|
||||||
|
Application.ReleaseComponent(APage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
TUNBPages Insert
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TUNBPages.Insert(Index: Integer; const S: String);
|
||||||
|
var
|
||||||
|
NewPage: TPage;
|
||||||
|
NewOwner: TComponent;
|
||||||
|
begin
|
||||||
|
NewOwner := FNotebook.Owner;
|
||||||
|
if NewOwner = nil then
|
||||||
|
NewOwner := FNotebook;
|
||||||
|
NewPage := TPage.Create(NewOwner);
|
||||||
|
NewPage.Caption := S;
|
||||||
|
|
||||||
|
FNoteBook.InsertPage(NewPage,Index);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{******************************************************************************
|
||||||
|
TNotebook
|
||||||
|
******************************************************************************}
|
||||||
|
|
||||||
|
function TNotebook.GetPage(AIndex: Integer): TPage;
|
||||||
|
begin
|
||||||
|
if (AIndex < 0) or (AIndex >= FPageList.Count) then
|
||||||
|
RaiseGDBException('TUntabbedNotebook.GetCustomPage Index out of bounds');
|
||||||
|
Result := TPage(FPageList.Items[AIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TNotebook.GetPageIndex: Integer;
|
||||||
|
begin
|
||||||
|
Result := FPageIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TNotebook.InsertPage(APage: TPage; Index: Integer);
|
||||||
|
begin
|
||||||
|
if FPageList.IndexOf(APage) >= 0 then Exit;
|
||||||
|
|
||||||
|
FPageList.Insert(Index, APage);
|
||||||
|
|
||||||
|
APage.Parent := Self;
|
||||||
|
APage.Align := alClient;
|
||||||
|
APage.Visible := False;
|
||||||
|
APage.ControlStyle := APage.ControlStyle + [csNoDesignVisible];
|
||||||
|
|
||||||
|
if PageIndex = -1 then SetPageIndex(Index);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TNotebook.SetPageIndex(AValue: Integer);
|
||||||
|
begin
|
||||||
|
if (AValue < -1) or (AValue >= Pages.Count) then Exit;
|
||||||
|
if FPageIndex = AValue then exit;
|
||||||
|
|
||||||
|
// Hide the previously shown page
|
||||||
|
if (FPageIndex >= 0) and (FPageIndex < Pages.Count) then
|
||||||
|
begin
|
||||||
|
Page[FPageIndex].ControlStyle :=
|
||||||
|
Page[FPageIndex].ControlStyle + [csNoDesignVisible];
|
||||||
|
Page[FPageIndex].Visible := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Update the property
|
||||||
|
FPageIndex := AValue;
|
||||||
|
|
||||||
|
// And show the new one
|
||||||
|
if Assigned(Page[FPageIndex].FOnBeforeShow) then Page[FPageIndex].FOnBeforeShow(Self, Page[FPageIndex], FPageIndex); // OnBeforeShow event
|
||||||
|
Page[FPageIndex].Visible := True;
|
||||||
|
Page[FPageIndex].ControlStyle :=
|
||||||
|
Page[FPageIndex].ControlStyle - [csNoDesignVisible];
|
||||||
|
Page[FPageIndex].Align := alClient;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TNotebook Constructor
|
TNotebook Constructor
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
constructor TNotebook.Create(TheOwner: TComponent);
|
constructor TNotebook.Create(TheOwner: TComponent);
|
||||||
|
var
|
||||||
|
lSize: TSize;
|
||||||
begin
|
begin
|
||||||
PageClass:=TPage{%H-};
|
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
|
|
||||||
|
FPageList := TListWithEvent.Create;
|
||||||
|
FPageIndex := -1;
|
||||||
|
FPages := TUNBPages.Create(FPageList, Self);
|
||||||
|
|
||||||
|
ControlStyle := []; // do not add csAcceptsControls
|
||||||
|
TabStop := true;
|
||||||
|
|
||||||
|
// Initial size
|
||||||
|
lSize := GetControlClassDefaultSize();
|
||||||
|
SetInitialBounds(0, 0, lSize.CX, lSize.CY);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TNotebook.Destroy;
|
||||||
|
begin
|
||||||
|
FPageList.Free;
|
||||||
|
|
||||||
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -19,39 +19,37 @@
|
|||||||
|
|
||||||
{ TPage }
|
{ TPage }
|
||||||
|
|
||||||
{ TUNBPage }
|
procedure TPage.SetParent(AParent: TWinControl);
|
||||||
|
|
||||||
procedure TUNBPage.SetParent(AParent: TWinControl);
|
|
||||||
var
|
var
|
||||||
OldParent: TWinControl;
|
OldParent: TWinControl;
|
||||||
ParentNotebook: TUntabbedNotebook;
|
ParentNotebook: TNotebook;
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
if (AParent = Parent) {or (pfInserting in FFlags)} then Exit;
|
if (AParent = Parent) {or (pfInserting in FFlags)} then Exit;
|
||||||
|
|
||||||
OldParent := Parent;
|
OldParent := Parent;
|
||||||
if (OldParent <> AParent) and (OldParent <> nil) and
|
if (OldParent <> AParent) and (OldParent <> nil) and
|
||||||
(OldParent is TUntabbedNotebook) {and (not (pfRemoving in FFlags))} then
|
(OldParent is TNotebook) {and (not (pfRemoving in FFlags))} then
|
||||||
begin
|
begin
|
||||||
// remove from old pagelist
|
// remove from old pagelist
|
||||||
ParentNotebook := TUntabbedNotebook(OldParent);
|
ParentNotebook := TNotebook(OldParent);
|
||||||
i := ParentNotebook.FPageList.IndexOf(Self);
|
i := ParentNotebook.FPageList.IndexOf(Self);
|
||||||
ParentNotebook.Pages.Delete(i);
|
ParentNotebook.Pages.Delete(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
inherited SetParent(AParent);
|
inherited SetParent(AParent);
|
||||||
|
|
||||||
if (Parent <> nil) and (Parent is TUntabbedNotebook) then
|
if (Parent <> nil) and (Parent is TNotebook) then
|
||||||
begin
|
begin
|
||||||
// add to new pagelist
|
// add to new pagelist
|
||||||
ParentNotebook := TUntabbedNotebook(Parent);
|
ParentNotebook := TNotebook(Parent);
|
||||||
i := ParentNotebook.FPageList.IndexOf(Self);
|
i := ParentNotebook.FPageList.IndexOf(Self);
|
||||||
if i < 0 then
|
if i < 0 then
|
||||||
ParentNotebook.InsertPage(Self, ParentNotebook.Pages.Count);
|
ParentNotebook.InsertPage(Self, ParentNotebook.Pages.Count);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TUNBPage.Create(TheOwner: TComponent);
|
constructor TPage.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
|
|
||||||
@ -64,18 +62,18 @@ begin
|
|||||||
Visible := False;
|
Visible := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TUNBPage.Destroy;
|
destructor TPage.Destroy;
|
||||||
begin
|
begin
|
||||||
{$ifdef DEBUG_NEW_NOTEBOOK}
|
{$ifdef DEBUG_NEW_NOTEBOOK}
|
||||||
DebugLn('[TUNBPage.Destroy]');
|
DebugLn('[TPage.Destroy]');
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
if (Parent <> nil) and (Parent is TUntabbedNotebook) then
|
if (Parent <> nil) and (Parent is TNotebook) then
|
||||||
begin
|
begin
|
||||||
{$ifdef DEBUG_NEW_NOTEBOOK}
|
{$ifdef DEBUG_NEW_NOTEBOOK}
|
||||||
DebugLn('[TUNBPage.Destroy] FPageList.Remove(Self)');
|
DebugLn('[TPage.Destroy] FPageList.Remove(Self)');
|
||||||
{$endif}
|
{$endif}
|
||||||
TUntabbedNotebook(Parent).FPageList.Remove(Self);
|
TNotebook(Parent).FPageList.Remove(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
|
@ -233,7 +233,7 @@ end;
|
|||||||
constructor TTabControlNoteBookStrings.Create(TheTabControl: TCustomTabControl);
|
constructor TTabControlNoteBookStrings.Create(TheTabControl: TCustomTabControl);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheTabControl);
|
inherited Create(TheTabControl);
|
||||||
FNoteBook := TNoteBook{%H-}.Create(nil);
|
FNoteBook := TCustomNoteBook{%H-}.Create(nil);
|
||||||
FNoteBook.ControlStyle := FNoteBook.ControlStyle + [csNoDesignSelectable];
|
FNoteBook.ControlStyle := FNoteBook.ControlStyle + [csNoDesignSelectable];
|
||||||
FNoteBook.Parent := TabControl;
|
FNoteBook.Parent := TabControl;
|
||||||
FNoteBook.OnGetImageIndex := @NBGetImageIndex;
|
FNoteBook.OnGetImageIndex := @NBGetImageIndex;
|
||||||
|
@ -1,214 +0,0 @@
|
|||||||
{%MainUnit ../extctrls.pp}
|
|
||||||
{******************************************************************************
|
|
||||||
TUntabbedNotebook
|
|
||||||
******************************************************************************
|
|
||||||
|
|
||||||
*****************************************************************************
|
|
||||||
* *
|
|
||||||
* This file is part of the Lazarus Component Library (LCL) *
|
|
||||||
* *
|
|
||||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
|
||||||
* for details about the copyright. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
||||||
* *
|
|
||||||
*****************************************************************************
|
|
||||||
}
|
|
||||||
|
|
||||||
{******************************************************************************
|
|
||||||
TUNBPages
|
|
||||||
******************************************************************************}
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Constructor
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
constructor TUNBPages.Create(thePageList: TListWithEvent;
|
|
||||||
theUNotebook: TUntabbedNotebook);
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
fPageList := thePageList;
|
|
||||||
fPageList.OnChange:=@PageListChange;
|
|
||||||
fUNotebook := theUNotebook;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
procedure TUNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TUNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
|
||||||
{var
|
|
||||||
APage: TUNBPage;}
|
|
||||||
begin
|
|
||||||
{ if (AnAction=lnAdded) then
|
|
||||||
begin
|
|
||||||
APage:=TObject(Ptr) as TUNBPage;
|
|
||||||
if not (pfInserting in APage.FFlags) then
|
|
||||||
APage.Parent:=fNotebook;
|
|
||||||
end;}
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Get
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TUNBPages.Get(Index: Integer): string;
|
|
||||||
begin
|
|
||||||
if (Index<0) or (Index>=fPageList.Count) then
|
|
||||||
RaiseGDBException('TUNBPages.Get Index out of bounds');
|
|
||||||
Result := TUNBPage(fPageList[Index]).Caption;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages GetCount
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TUNBPages.GetCount: Integer;
|
|
||||||
begin
|
|
||||||
Result := fPageList.Count;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages GetObject
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TUNBPages.GetObject(Index: Integer): TObject;
|
|
||||||
begin
|
|
||||||
if (Index<0) or (Index>=fPageList.Count) then
|
|
||||||
RaiseGDBException('TUNBPages.GetObject Index out of bounds');
|
|
||||||
Result := TUNBPage(fPageList[Index]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Put
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TUNBPages.Put(Index: Integer; const S: String);
|
|
||||||
begin
|
|
||||||
if (Index<0) or (Index>=fPageList.Count) then
|
|
||||||
RaiseGDBException('TUNBPages.Put Index out of bounds');
|
|
||||||
//debugln(['TUNBPages.Put ',DbgSName(FNotebook),' ',Index,' S="',S,'"']);
|
|
||||||
TUNBPage(fPageList[Index]).Caption := S;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Clear
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TUNBPages.Clear;
|
|
||||||
begin
|
|
||||||
while fPageList.Count>0 do
|
|
||||||
Delete(fPageList.Count-1);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Delete
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TUNBPages.Delete(Index: Integer);
|
|
||||||
var
|
|
||||||
APage: TCustomPage;
|
|
||||||
begin
|
|
||||||
// Make sure Index is in the range of valid pages to delete
|
|
||||||
if (Index < 0) or (Index >= fPageList.Count) then Exit;
|
|
||||||
|
|
||||||
APage := TCustomPage(fPageList[Index]);
|
|
||||||
// delete handle
|
|
||||||
APage.Parent := nil;
|
|
||||||
// free the page
|
|
||||||
Application.ReleaseComponent(APage);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUNBPages Insert
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TUNBPages.Insert(Index: Integer; const S: String);
|
|
||||||
var
|
|
||||||
NewPage: TUNBPage;
|
|
||||||
NewOwner: TComponent;
|
|
||||||
begin
|
|
||||||
NewOwner := FUNotebook.Owner;
|
|
||||||
if NewOwner = nil then
|
|
||||||
NewOwner := FUNotebook;
|
|
||||||
NewPage := TUNBPage.Create(NewOwner);
|
|
||||||
NewPage.Caption := S;
|
|
||||||
|
|
||||||
FUNoteBook.InsertPage(NewPage,Index);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{******************************************************************************
|
|
||||||
TUntabbedNotebook
|
|
||||||
******************************************************************************}
|
|
||||||
|
|
||||||
function TUntabbedNotebook.GetPage(AIndex: Integer): TUNBPage;
|
|
||||||
begin
|
|
||||||
if (AIndex < 0) or (AIndex >= FPageList.Count) then
|
|
||||||
RaiseGDBException('TUntabbedNotebook.GetCustomPage Index out of bounds');
|
|
||||||
Result := TUNBPage(FPageList.Items[AIndex]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TUntabbedNotebook.GetPageIndex: Integer;
|
|
||||||
begin
|
|
||||||
Result := FPageIndex;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUntabbedNotebook.InsertPage(APage: TUNBPage; Index: Integer);
|
|
||||||
begin
|
|
||||||
if FPageList.IndexOf(APage) >= 0 then Exit;
|
|
||||||
|
|
||||||
FPageList.Insert(Index, APage);
|
|
||||||
|
|
||||||
APage.Parent := Self;
|
|
||||||
APage.Align := alClient;
|
|
||||||
APage.Visible := False;
|
|
||||||
APage.ControlStyle := APage.ControlStyle + [csNoDesignVisible];
|
|
||||||
|
|
||||||
if PageIndex = -1 then SetPageIndex(Index);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUntabbedNotebook.SetPageIndex(AValue: Integer);
|
|
||||||
begin
|
|
||||||
if (AValue < -1) or (AValue >= Pages.Count) then Exit;
|
|
||||||
if FPageIndex = AValue then exit;
|
|
||||||
|
|
||||||
// Hide the previously shown page
|
|
||||||
if (FPageIndex >= 0) and (FPageIndex < Pages.Count) then
|
|
||||||
begin
|
|
||||||
Page[FPageIndex].ControlStyle :=
|
|
||||||
Page[FPageIndex].ControlStyle + [csNoDesignVisible];
|
|
||||||
Page[FPageIndex].Visible := False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Update the property
|
|
||||||
FPageIndex := AValue;
|
|
||||||
|
|
||||||
// And show the new one
|
|
||||||
if Assigned(Page[FPageIndex].FOnBeforeShow) then Page[FPageIndex].FOnBeforeShow(Self, Page[FPageIndex], FPageIndex); // OnBeforeShow event
|
|
||||||
Page[FPageIndex].Visible := True;
|
|
||||||
Page[FPageIndex].ControlStyle :=
|
|
||||||
Page[FPageIndex].ControlStyle - [csNoDesignVisible];
|
|
||||||
Page[FPageIndex].Align := alClient;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
TUntabbedNotebook Constructor
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
constructor TUntabbedNotebook.Create(TheOwner: TComponent);
|
|
||||||
var
|
|
||||||
lSize: TSize;
|
|
||||||
begin
|
|
||||||
inherited Create(TheOwner);
|
|
||||||
|
|
||||||
FPageList := TListWithEvent.Create;
|
|
||||||
FPageIndex := -1;
|
|
||||||
FPages := TUNBPages.Create(FPageList, Self);
|
|
||||||
|
|
||||||
ControlStyle := []; // do not add csAcceptsControls
|
|
||||||
TabStop := true;
|
|
||||||
|
|
||||||
// Initial size
|
|
||||||
lSize := GetControlClassDefaultSize();
|
|
||||||
SetInitialBounds(0, 0, lSize.CX, lSize.CY);
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TUntabbedNotebook.Destroy;
|
|
||||||
begin
|
|
||||||
FPageList.Free;
|
|
||||||
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user