diff --git a/components/tdi/Demo/TDIDemo.lpi b/components/tdi/Demo/TDIDemo.lpi
index 04b003dc9..36c3d3933 100644
--- a/components/tdi/Demo/TDIDemo.lpi
+++ b/components/tdi/Demo/TDIDemo.lpi
@@ -33,13 +33,16 @@
-
+
-
+
-
+
+
+
+
diff --git a/components/tdi/Demo/TDIDemo.lps b/components/tdi/Demo/TDIDemo.lps
index b5f488bf7..87078ce53 100644
--- a/components/tdi/Demo/TDIDemo.lps
+++ b/components/tdi/Demo/TDIDemo.lps
@@ -12,7 +12,7 @@
-
+
@@ -23,7 +23,7 @@
-
+
@@ -34,9 +34,9 @@
-
-
-
+
+
+
@@ -48,24 +48,25 @@
-
-
-
+
+
+
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -79,27 +80,30 @@
+
-
-
+
+
+
+
-
-
+
+
+
-
-
+
-
-
-
+
+
+
@@ -162,20 +166,22 @@
-
+
-
+
+
-
-
-
+
+
+
+
@@ -196,10 +202,12 @@
+
-
-
+
+
+
@@ -420,12 +428,10 @@
-
-
-
+
@@ -461,10 +467,12 @@
+
-
-
+
+
+
@@ -493,11 +501,11 @@
-
+
-
-
-
+
+
+
@@ -529,123 +537,123 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/components/tdi/Demo/uform1.lfm b/components/tdi/Demo/uform1.lfm
index 234d77a37..28f285bb2 100644
--- a/components/tdi/Demo/uform1.lfm
+++ b/components/tdi/Demo/uform1.lfm
@@ -28,7 +28,7 @@ object Form1: TForm1
object Edit1: TEdit
Left = 24
Height = 23
- Top = 24
+ Top = 80
Width = 82
TabOrder = 0
Text = 'Edit1'
@@ -36,7 +36,7 @@ object Form1: TForm1
object Edit2: TEdit
Left = 24
Height = 23
- Top = 96
+ Top = 136
Width = 82
OnExit = Edit2Exit
TabOrder = 1
@@ -51,12 +51,15 @@ object Form1: TForm1
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
- Left = 23
- Height = 16
- Top = 143
- Width = 454
- Caption = 'This Form has Max Constraints. It will be centralized on Tab Sheet if it is smaller than it'
+ Left = 98
+ Height = 31
+ Top = 16
+ Width = 305
+ Alignment = taCenter
+ Caption = 'This Form has Max Constraints.'#13#10'It will be centralized on Tab Sheet if it is smaller than it'
+ Font.Style = [fsBold]
ParentColor = False
+ ParentFont = False
end
object Label3: TLabel
Left = 16
@@ -90,19 +93,23 @@ object Form1: TForm1
Visible = False
end
object Label4: TLabel
- Left = 24
+ AnchorSideTop.Control = Edit1
+ AnchorSideTop.Side = asrCenter
+ Left = 120
Height = 16
- Top = 8
+ Top = 83
Width = 106
Caption = 'This is a regular Edit'
ParentColor = False
end
object Label5: TLabel
- Left = 24
- Height = 31
- Top = 63
- Width = 450
- Caption = 'This Edit has a OnExit Validation, who doesn''t allow Page Change if this Edit is empty'#13#10'This can be configured by "VerifyIfCanChange" property'
+ AnchorSideTop.Control = Edit2
+ AnchorSideTop.Side = asrCenter
+ Left = 120
+ Height = 46
+ Top = 124
+ Width = 347
+ Caption = 'This Edit has a OnExit Validation, who doesn''t allow Page Change'#13#10' if this Edit is empty, and the focus is on it... '#13#10'This can be disabled changing the property "VerifyIfCanChange"'
ParentColor = False
end
object tShowmeAgain: TTimer
diff --git a/components/tdi/Demo/uform1.pas b/components/tdi/Demo/uform1.pas
index 464de1ab5..a32dfe739 100644
--- a/components/tdi/Demo/uform1.pas
+++ b/components/tdi/Demo/uform1.pas
@@ -84,7 +84,9 @@ begin
ShowMessage( 'Remember... Edit2 cannot be empty' );
Edit2.Text := 'Ok, fixed';
end ;
- fMainForm.mEvents.Lines.Add( 'Form1.CloseQuery: '+BoolToStr(CanClose,'True','False') );
+
+ if Assigned( fMainForm ) then
+ fMainForm.mEvents.Lines.Add( 'Form1.CloseQuery: '+BoolToStr(CanClose,'True','False') );
end;
procedure TForm1.FormDestroy(Sender : TObject) ;
diff --git a/components/tdi/Demo/umainform.lfm b/components/tdi/Demo/umainform.lfm
index 210ff0510..60948f48e 100644
--- a/components/tdi/Demo/umainform.lfm
+++ b/components/tdi/Demo/umainform.lfm
@@ -32,7 +32,7 @@ object fMainForm: TfMainForm
Top = 0
Width = 587
TabStop = False
- ActivePage = TabSheet1
+ ActivePage = tsFixed
Align = alClient
Constraints.MinHeight = 300
Constraints.MinWidth = 500
@@ -53,13 +53,13 @@ object fMainForm: TfMainForm
TDIActions.CloseAllTabs.Caption = 'Close All Tabs'
TDIActions.CloseAllTabs.ImageIndex = 2
FixedPages = 1
- object TabSheet1: TTabSheet
- Caption = 'TabSheet1'
+ object tsFixed: TTabSheet
+ Caption = 'TTDINotebook Demo'
ClientHeight = 363
ClientWidth = 579
ImageIndex = 5
object Label2: TLabel
- AnchorSideLeft.Control = TabSheet1
+ AnchorSideLeft.Control = tsFixed
AnchorSideLeft.Side = asrCenter
Left = 167
Height = 31
@@ -120,6 +120,37 @@ object fMainForm: TfMainForm
Caption = 'BackgroundCorner'
ParentColor = False
end
+ object bToggleLog: TButton
+ AnchorSideTop.Control = pBottom
+ AnchorSideTop.Side = asrCenter
+ Left = 622
+ Height = 25
+ Top = 13
+ Width = 85
+ Anchors = [akTop, akRight]
+ AutoSize = True
+ Caption = 'Hide Log >'
+ OnClick = bToggleLogClick
+ TabOrder = 1
+ end
+ object Label3: TLabel
+ Left = 182
+ Height = 16
+ Top = 1
+ Width = 59
+ Caption = 'FixedPages'
+ ParentColor = False
+ end
+ object seFixedPages: TSpinEdit
+ Left = 184
+ Height = 23
+ Top = 17
+ Width = 50
+ MaxValue = 10
+ OnChange = seFixedPagesChange
+ TabOrder = 2
+ Value = 1
+ end
end
object mEvents: TMemo
Left = 592
diff --git a/components/tdi/Demo/umainform.pas b/components/tdi/Demo/umainform.pas
index 7b8139518..14e15ad38 100644
--- a/components/tdi/Demo/umainform.pas
+++ b/components/tdi/Demo/umainform.pas
@@ -6,19 +6,21 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
- ComCtrls, Buttons, StdCtrls, ExtCtrls, TDIClass , types, SynMemo, IpHtml;
+ ComCtrls, Buttons, StdCtrls, ExtCtrls, Spin, TDIClass , types, IpHtml;
type
{ TfMainForm }
TfMainForm = class(TForm)
+ bToggleLog : TButton ;
cbxBackgroundCorner : TComboBox ;
Image1 : TImage ;
ImageList1 : TImageList ;
IpHtmlPanel1 : TIpHtmlPanel ;
Label1 : TLabel ;
Label2 : TLabel ;
+ Label3 : TLabel ;
MainMenu1 : TMainMenu ;
mEvents : TMemo ;
MenuItem1 : TMenuItem ;
@@ -27,16 +29,19 @@ type
miForm2 : TMenuItem ;
miForm1 : TMenuItem ;
pBottom : TPanel ;
+ seFixedPages : TSpinEdit ;
Splitter1 : TSplitter ;
StatusBar1 : TStatusBar ;
- TabSheet1 : TTabSheet ;
+ tsFixed : TTabSheet ;
TDINoteBook1 : TTDINoteBook ;
+ procedure bToggleLogClick(Sender : TObject) ;
procedure cbxBackgroundCornerChange(Sender : TObject) ;
procedure FormClose(Sender : TObject ; var CloseAction : TCloseAction) ;
procedure FormCloseQuery(Sender : TObject ; var CanClose : boolean) ;
procedure FormCreate(Sender : TObject) ;
procedure miExitClick(Sender : TObject) ;
procedure miForm1Click(Sender : TObject) ;
+ procedure seFixedPagesChange(Sender : TObject) ;
procedure TDINoteBook1Change(Sender : TObject) ;
private
{ private declarations }
@@ -70,6 +75,16 @@ begin
TDINoteBook1.BackgroundCorner := TTDIBackgroundCorner( cbxBackgroundCorner.ItemIndex );
end;
+procedure TfMainForm.bToggleLogClick(Sender : TObject) ;
+begin
+ mEvents.Visible := not mEvents.Visible ;
+
+ if mEvents.Visible then
+ bToggleLog.Caption := 'Hide Log >'
+ else
+ bToggleLog.Caption := '< Show Log' ;
+end;
+
procedure TfMainForm.FormClose(Sender : TObject ; var CloseAction : TCloseAction
) ;
begin
@@ -92,6 +107,11 @@ begin
TDINoteBook1.CreateFormInNewPage( TForm1, 3 );
end;
+procedure TfMainForm.seFixedPagesChange(Sender : TObject) ;
+begin
+ TDINoteBook1.FixedPages := seFixedPages.Value;
+end;
+
procedure TfMainForm.TDINoteBook1Change(Sender : TObject) ;
begin
mEvents.Lines.Add('OnChange');
diff --git a/components/tdi/tdiclass.pas b/components/tdi/tdiclass.pas
index cfe4396d0..570fdb6b1 100644
--- a/components/tdi/tdiclass.pas
+++ b/components/tdi/tdiclass.pas
@@ -56,6 +56,7 @@ type
procedure SetFormInPage(AValue : TForm) ;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
+ procedure CheckFormAlign ;
public
constructor Create(TheOwner: TComponent ); override;
@@ -81,6 +82,7 @@ type
procedure SetBackgroundCorner(AValue : TTDIBackgroundCorner) ;
procedure SetCloseTabButtom(AValue : TTDICloseTabButtom) ;
procedure SetMainMenu(AValue : TMainMenu) ;
+ procedure SetFixedPages(AValue : Integer) ;
private
FCloseBitBtn : TBitBtn ;
FCloseMenuItem : TMenuItem ;
@@ -110,6 +112,8 @@ type
function CanChange: Boolean; override;
procedure DoChange; override;
procedure Loaded; override;
+ procedure RemovePage(Index: Integer); override;
+
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
@@ -138,7 +142,7 @@ type
write FRestoreActiveControl default True;
property VerifyIfCanChangePage : Boolean read FVerifyIfCanChangePage
write FVerifyIfCanChangePage default True;
- property FixedPages : Integer read FFixedPages write FFixedPages default 0;
+ property FixedPages : Integer read FFixedPages write SetFixedPages default 0;
end ;
@@ -246,7 +250,7 @@ begin
fsFormInPage := nil;
end ;
-procedure TTDIPage.OnResizeTDIPage(Sender : TObject) ;
+procedure TTDIPage.CheckFormAlign ;
begin
if not Assigned(fsFormInPage) then exit ;
@@ -266,6 +270,11 @@ begin
fsFormInPage.Align := alClient;
end ;
+procedure TTDIPage.OnResizeTDIPage(Sender : TObject) ;
+begin
+ CheckFormAlign;
+end ;
+
{ TTDINoteBook }
constructor TTDINoteBook.Create(TheOwner : TComponent) ;
@@ -435,6 +444,14 @@ begin
FTabsMenuItem.Add(FCloseAllTabsMenuItem);
end ;
+procedure TTDINoteBook.SetFixedPages(AValue : Integer) ;
+begin
+ if FFixedPages = AValue then Exit ;
+ FFixedPages := AValue ;
+
+ CheckInterface;
+end ;
+
procedure TTDINoteBook.SetBackgroundImage(AValue : TImage) ;
begin
if FBackgroundImage = AValue then Exit ;
@@ -483,17 +500,24 @@ procedure TTDINoteBook.ShowForInNewPage(AForm : TForm ; ImageIndex : Integer) ;
Var
NewPage : TTDIPage ;
begin
- Visible := True;
-
// Create a new Page
NewPage := TTDIPage.Create(Self);
NewPage.ImageIndex := ImageIndex;
+ Visible := True;
+
// This will call TTDIPage.SetFormInPage, who does the magic //
NewPage.FormInPage := AForm;
// Activate the new Page
ActivePage := NewPage;
+
+ // First Page always need a little help for align form inside //
+ if PageCount = 1 then
+ begin
+ NewPage.CheckFormAlign ;
+ CheckInterface;
+ end ;
end ;
procedure TTDINoteBook.CheckInterface ;
@@ -558,8 +582,7 @@ end ;
procedure TTDINoteBook.CloseTabClicked(Sender : TObject) ;
begin
- if CanCloseAPage( ActivePageIndex ) then
- RemovePage( ActivePageIndex );
+ RemovePage( ActivePageIndex );
end ;
procedure TTDINoteBook.CloseAllTabsClicked(Sender : TObject) ;
@@ -573,9 +596,9 @@ begin
// Close while have pages, and Pages still being closed //
while (PageCount > FFixedPages) and (LastPageCount <> PageCount) do
begin
- LastPageCount := PageCount ;
- CloseTabClicked(Sender);
- Application.ProcessMessages;
+ LastPageCount := PageCount ;
+ RemovePage( ActivePageIndex );
+ Application.ProcessMessages;
end;
end ;
@@ -722,6 +745,32 @@ begin
CheckInterface;
end ;
+procedure TTDINoteBook.RemovePage(Index : Integer) ;
+Var
+ CanRemovePage : Boolean ;
+begin
+ CanRemovePage := True;
+
+ if Pages[Index] is TTDIPage then
+ with TTDIPage(Pages[Index]) do
+ begin
+ if Assigned( FormInPage ) then
+ begin
+ CanRemovePage := FormInPage.CloseQuery ;
+ if CanRemovePage then
+ FormInPage.Close ;
+ end ;
+ end ;
+
+ if CanRemovePage then
+ begin
+ inherited RemovePage(Index) ;
+
+ if PageCount < 1 then // On this case, DoChange is not fired //
+ CheckInterface;
+ end ;
+end ;
+
procedure TTDINoteBook.Notification(AComponent : TComponent ;
Operation : TOperation) ;
begin