diff --git a/.gitattributes b/.gitattributes index bedb9ea349..9313e492d3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4783,7 +4783,6 @@ lcl/include/toolwindow.inc svneol=native#text/pascal lcl/include/trackbar.inc svneol=native#text/pascal lcl/include/treeview.inc svneol=native#text/pascal 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/winapih.inc svneol=native#text/pascal lcl/include/wincontrol.inc svneol=native#text/pascal diff --git a/ideintf/componenteditors.pas b/ideintf/componenteditors.pas index 8b57c4f96f..57eef7dd2e 100644 --- a/ideintf/componenteditors.pas +++ b/ideintf/componenteditors.pas @@ -287,15 +287,15 @@ type function GetVerb(Index: Integer): string; override; function GetVerbCount: Integer; override; procedure PrepareItem(Index: Integer; const AnItem: TMenuItem); override; - function Notebook: TUntabbedNotebook; virtual; + function Notebook: TNotebook; virtual; end; { TUNBPageComponentEditor The default component editor for TUNBPage. } TUNBPageComponentEditor = class(TUntabbedNotebookComponentEditor) public - function Notebook: TUntabbedNotebook; override; - function Page: TUNBPage; virtual; + function Notebook: TNotebook; override; + function Page: TPage; virtual; end; { TTabControlComponentEditor @@ -932,7 +932,7 @@ procedure TUntabbedNotebookComponentEditor.AddNewPageToDesigner(Index: integer ); var Hook: TPropertyEditorHook; - NewPage: TUNBPage; + NewPage: TPage; NewName: string; begin Hook:=nil; @@ -1034,25 +1034,25 @@ begin end; end; -function TUntabbedNotebookComponentEditor.Notebook: TUntabbedNotebook; +function TUntabbedNotebookComponentEditor.Notebook: TNotebook; begin - Result:=TUntabbedNotebook(GetComponent); + Result:=TNotebook(GetComponent); end; { TUNBPageComponentEditor } -function TUNBPageComponentEditor.Notebook: TUntabbedNotebook; +function TUNBPageComponentEditor.Notebook: TNotebook; var - APage: TUNBPage; + APage: TPage; begin APage:=Page; - if (APage.Parent<>nil) and (APage.Parent is TUntabbedNotebook) then - Result:=TUntabbedNotebook(APage.Parent); + if (APage.Parent<>nil) and (APage.Parent is TNotebook) then + Result:=TNotebook(APage.Parent); end; -function TUNBPageComponentEditor.Page: TUNBPage; +function TUNBPageComponentEditor.Page: TPage; begin - Result:=TUNBPage(GetComponent); + Result:=TPage(GetComponent); end; { TStringGridComponentEditor } @@ -1491,8 +1491,8 @@ initialization RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc; RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor); RegisterComponentEditor(TCustomPage, TPageComponentEditor); - RegisterComponentEditor(TUntabbedNotebook, TUntabbedNotebookComponentEditor); - RegisterComponentEditor(TUNBPage, TUNBPageComponentEditor); + RegisterComponentEditor(TNotebook, TUntabbedNotebookComponentEditor); + RegisterComponentEditor(TPage, TUNBPageComponentEditor); RegisterComponentEditor(TCustomTabControl, TTabControlComponentEditor); RegisterComponentEditor(TStringGrid, TStringGridComponentEditor); RegisterComponentEditor(TCheckListBox, TCheckListBoxComponentEditor); diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 6f87f4cc41..517a782e41 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -424,7 +424,7 @@ type TTabControlNoteBookStrings = class(TTabControlStrings) private - FNoteBook: TNoteBook{%H-}; + FNoteBook: TCustomNoteBook{%H-}; protected function Get(Index: Integer): string; override; function GetCount: Integer; override; @@ -451,7 +451,7 @@ type procedure TabControlBoundsChange; override; function IndexOfTabAt(X, Y: Integer): Integer; override; public - property NoteBook: TNoteBook read FNoteBook; + property NoteBook: TCustomNoteBook read FNoteBook; end; diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index 4d4425fcce..dfd3c7c2d9 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -93,7 +93,6 @@ type TCustomPageClass = class of TCustomPage; - { TNBPages } TCustomNotebook = class; @@ -117,7 +116,6 @@ type procedure Move(CurIndex, NewIndex: Integer); override; end; - { TCustomNotebook } TTabChangingEvent = procedure(Sender: TObject; @@ -235,97 +233,13 @@ type property TabStop default true; end; - { TPage } - TPage = class(TCustomPage) - 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; + TPage = class; + TBeforeShowPageEvent = procedure (ASender: TObject; ANewPage: TPage; ANewIndex: Integer) of object; - { TNotebook } - - 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) + TPage = class(TCustomControl) private FOnBeforeShow: TBeforeShowPageEvent; protected @@ -363,12 +277,12 @@ type { TUNBPages } - TUntabbedNotebook = class; + TNotebook = class; TUNBPages = class(TStrings) private FPageList: TListWithEvent; - FUNotebook: TUntabbedNotebook; + FNotebook: TNotebook; procedure PageListChange(Ptr: Pointer; AnAction: TListNotification); protected function Get(Index: Integer): String; override; @@ -377,27 +291,27 @@ type procedure Put(Index: Integer; const S: String); override; public constructor Create(thePageList: TListWithEvent; - theUNotebook: TUntabbedNotebook); + theNotebook: TNotebook); procedure Clear; override; procedure Delete(Index: Integer); override; procedure Insert(Index: Integer; const S: String); override; // procedure Move(CurIndex, NewIndex: Integer); override; end; - { TUntabbedNotebook } + { TNotebook } - TUntabbedNotebook = class(TCustomControl) + TNotebook = class(TCustomControl) private FPages: TStrings; // TUNBPages FPageIndex: Integer; FPageList: TListWithEvent; { function GetActivePage: String; function GetActivePageComponent: TCustomPage;} - function GetPage(AIndex: Integer): TUNBPage; + function GetPage(AIndex: Integer): TPage; // function GetPageCount : integer; function GetPageIndex: 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 RemovePage(Index: Integer); procedure SetActivePage(const Value: String);} @@ -412,7 +326,7 @@ type function IndexOf(APage: TCustomPage): integer; function CustomPage(Index: integer): TCustomPage;} public - property Page[Index: Integer]: TUNBPage read GetPage; + property Page[Index: Integer]: TPage read GetPage; // property PageCount: integer read GetPageCount; // property PageList: TList read FPageList; published @@ -1395,17 +1309,15 @@ procedure Register; begin RegisterComponents('Standard',[TRadioGroup,TCheckGroup,TPanel]); RegisterComponents('Additional',[TImage,TShape,TBevel,TPaintBox, - {$ifdef INSTALL_TUNTABBEDNOTEBOOK} TUntabbedNotebook, {$ENDIF} - TLabeledEdit, TSplitter, TTrayIcon]); + TNotebook, TLabeledEdit, TSplitter, TTrayIcon]); RegisterComponents('System',[TTimer,TIdleTimer]); - RegisterNoIcon([TNotebook{%H-}, TPage{$ifdef INSTALL_TUNTABBEDNOTEBOOK}, TUNBPage{$ENDIF}]); + RegisterNoIcon([TPage]); end; {$I custompage.inc} -{$I page.inc} {$I customnotebook.inc} +{$I page.inc} {$I notebook.inc} -{$I untabbednotebook.inc} {$I timer.inc} {$I idletimer.inc} {$I shape.inc} diff --git a/lcl/include/notebook.inc b/lcl/include/notebook.inc index bfdfd7a51e..94b523edab 100644 --- a/lcl/include/notebook.inc +++ b/lcl/include/notebook.inc @@ -1,6 +1,6 @@ {%MainUnit ../extctrls.pp} {****************************************************************************** - TNotebook + TNotebook ****************************************************************************** ***************************************************************************** @@ -17,27 +17,198 @@ ***************************************************************************** } -function TNotebook.GetActiveNotebookPageComponent: TPage; +{****************************************************************************** + TUNBPages + ******************************************************************************} + +{------------------------------------------------------------------------------ + TUNBPages Constructor + ------------------------------------------------------------------------------} +constructor TUNBPages.Create(thePageList: TListWithEvent; + theNotebook: TNotebook); begin - Result:=TPage{%H-}(GetActivePageComponent); + inherited Create; + fPageList := thePageList; + fPageList.OnChange:=@PageListChange; + fNotebook := theNotebook; 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 - 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; -procedure TNotebook.SetActiveNotebookPageComponent(const AValue: TPage); +{------------------------------------------------------------------------------ + TUNBPages Get + ------------------------------------------------------------------------------} +function TUNBPages.Get(Index: Integer): string; 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; {------------------------------------------------------------------------------ TNotebook Constructor ------------------------------------------------------------------------------} constructor TNotebook.Create(TheOwner: TComponent); +var + lSize: TSize; begin - PageClass:=TPage{%H-}; 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; diff --git a/lcl/include/page.inc b/lcl/include/page.inc index 2b3a741f80..9ca781d5b0 100644 --- a/lcl/include/page.inc +++ b/lcl/include/page.inc @@ -19,39 +19,37 @@ { TPage } -{ TUNBPage } - -procedure TUNBPage.SetParent(AParent: TWinControl); +procedure TPage.SetParent(AParent: TWinControl); var OldParent: TWinControl; - ParentNotebook: TUntabbedNotebook; + ParentNotebook: TNotebook; i: integer; begin if (AParent = Parent) {or (pfInserting in FFlags)} then Exit; OldParent := Parent; 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 // remove from old pagelist - ParentNotebook := TUntabbedNotebook(OldParent); + ParentNotebook := TNotebook(OldParent); i := ParentNotebook.FPageList.IndexOf(Self); ParentNotebook.Pages.Delete(i); end; inherited SetParent(AParent); - if (Parent <> nil) and (Parent is TUntabbedNotebook) then + if (Parent <> nil) and (Parent is TNotebook) then begin // add to new pagelist - ParentNotebook := TUntabbedNotebook(Parent); + ParentNotebook := TNotebook(Parent); i := ParentNotebook.FPageList.IndexOf(Self); if i < 0 then ParentNotebook.InsertPage(Self, ParentNotebook.Pages.Count); end; end; -constructor TUNBPage.Create(TheOwner: TComponent); +constructor TPage.Create(TheOwner: TComponent); begin inherited Create(TheOwner); @@ -64,18 +62,18 @@ begin Visible := False; end; -destructor TUNBPage.Destroy; +destructor TPage.Destroy; begin {$ifdef DEBUG_NEW_NOTEBOOK} - DebugLn('[TUNBPage.Destroy]'); + DebugLn('[TPage.Destroy]'); {$endif} - if (Parent <> nil) and (Parent is TUntabbedNotebook) then + if (Parent <> nil) and (Parent is TNotebook) then begin {$ifdef DEBUG_NEW_NOTEBOOK} - DebugLn('[TUNBPage.Destroy] FPageList.Remove(Self)'); + DebugLn('[TPage.Destroy] FPageList.Remove(Self)'); {$endif} - TUntabbedNotebook(Parent).FPageList.Remove(Self); + TNotebook(Parent).FPageList.Remove(Self); end; inherited Destroy; diff --git a/lcl/include/tabcontrol.inc b/lcl/include/tabcontrol.inc index 74de0936a6..ef314ad164 100644 --- a/lcl/include/tabcontrol.inc +++ b/lcl/include/tabcontrol.inc @@ -233,7 +233,7 @@ end; constructor TTabControlNoteBookStrings.Create(TheTabControl: TCustomTabControl); begin inherited Create(TheTabControl); - FNoteBook := TNoteBook{%H-}.Create(nil); + FNoteBook := TCustomNoteBook{%H-}.Create(nil); FNoteBook.ControlStyle := FNoteBook.ControlStyle + [csNoDesignSelectable]; FNoteBook.Parent := TabControl; FNoteBook.OnGetImageIndex := @NBGetImageIndex; diff --git a/lcl/include/untabbednotebook.inc b/lcl/include/untabbednotebook.inc deleted file mode 100644 index 85488e8330..0000000000 --- a/lcl/include/untabbednotebook.inc +++ /dev/null @@ -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; -