git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2396 8e941d3f-bd1b-0410-a28a-d453659cc2b4

This commit is contained in:
dopi
2012-04-20 12:39:44 +00:00
parent f71e98f6d9
commit 221bc57670
9 changed files with 291 additions and 106 deletions

View File

@ -44,7 +44,7 @@
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="3">
<Units Count="4">
<Unit0>
<Filename Value="TDIDemo.lpr"/>
<IsPartOfProject Value="True"/>
@ -65,6 +65,13 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uForm1"/>
</Unit2>
<Unit3>
<Filename Value="uform2.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form2"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uForm2"/>
</Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -7,7 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, uMainForm
Forms, uMainForm, uForm2
{ you can add units after this };
{$R *.res}
@ -16,6 +16,7 @@ begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TfMainForm, fMainForm) ;
Application.CreateForm(TForm2, Form2) ;
Application.Run;
end.

View File

@ -4,7 +4,7 @@
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="62">
<Units Count="63">
<Unit0>
<Filename Value="TDIDemo.lpr"/>
<IsPartOfProject Value="True"/>
@ -12,7 +12,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="36" Y="18"/>
<UsageCount Value="97"/>
<UsageCount Value="100"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>
@ -23,7 +23,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="10" Y="8"/>
<UsageCount Value="97"/>
<UsageCount Value="100"/>
</Unit1>
<Unit2>
<Filename Value="uform1.pas"/>
@ -32,12 +32,11 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uForm1"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="77"/>
<CursorPos X="2" Y="88"/>
<UsageCount Value="97"/>
<CursorPos X="1" Y="94"/>
<UsageCount Value="100"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
@ -49,24 +48,25 @@
<UnitName Value="uMainForm"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="110"/>
<CursorPos X="26" Y="121"/>
<UsageCount Value="48"/>
<TopLine Value="111"/>
<CursorPos X="32" Y="113"/>
<UsageCount Value="49"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\tdiclass.pas"/>
<UnitName Value="TDIClass"/>
<EditorIndex Value="4"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="748"/>
<CursorPos X="53" Y="754"/>
<UsageCount Value="48"/>
<TopLine Value="244"/>
<CursorPos X="22" Y="254"/>
<UsageCount Value="49"/>
<Bookmarks Count="3">
<Item0 X="17" Y="779" ID="3"/>
<Item1 X="3" Y="673" ID="2"/>
<Item2 X="3" Y="460" ID="1"/>
<Item0 X="17" Y="809" ID="3"/>
<Item1 X="3" Y="703" ID="2"/>
<Item2 X="3" Y="461" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit4>
@ -80,30 +80,26 @@
</Unit5>
<Unit6>
<Filename Value="C:\lazarus\lcl\include\customnotebook.inc"/>
<EditorIndex Value="9"/>
<WindowIndex Value="0"/>
<TopLine Value="292"/>
<CursorPos X="1" Y="303"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="C:\lazarus\lcl\include\control.inc"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="659"/>
<CursorPos X="3" Y="646"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\tdireg.pas"/>
<UnitName Value="TDIReg"/>
<EditorIndex Value="12"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="3"/>
<CursorPos X="29" Y="16"/>
<UsageCount Value="32"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
@ -166,22 +162,20 @@
<Unit15>
<Filename Value="..\tdiconst.pas"/>
<UnitName Value="TDIConst"/>
<EditorIndex Value="11"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="13" Y="10"/>
<UsageCount Value="45"/>
<UsageCount Value="46"/>
<Loaded Value="True"/>
</Unit15>
<Unit16>
<Filename Value="C:\lazarus\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="1203"/>
<CursorPos X="15" Y="1214"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="C:\lazarus\lcl\graphics.pp"/>
@ -202,12 +196,10 @@
<Unit19>
<Filename Value="C:\lazarus\lcl\comctrls.pp"/>
<UnitName Value="ComCtrls"/>
<EditorIndex Value="8"/>
<WindowIndex Value="0"/>
<TopLine Value="385"/>
<CursorPos X="22" Y="395"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="C:\lazarus\lcl\include\pagecontrol.inc"/>
@ -341,12 +333,10 @@
</Unit36>
<Unit37>
<Filename Value="C:\lazarus\fpc\2.6.0\source\rtl\objpas\classes\classesh.inc"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="1653"/>
<CursorPos X="15" Y="1664"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
<Filename Value="C:\lazarus\lcl\registerlcl.pas"/>
@ -469,12 +459,10 @@
<Unit53>
<Filename Value="C:\lazarus\lcl\lclproc.pas"/>
<UnitName Value="LCLProc"/>
<EditorIndex Value="7"/>
<WindowIndex Value="0"/>
<TopLine Value="851"/>
<CursorPos X="40" Y="862"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit53>
<Unit54>
<Filename Value="C:\lazarus\lcl\include\tabsheet.inc"/>
@ -503,13 +491,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="DJ_FormPrincipal"/>
<EditorIndex Value="10"/>
<WindowIndex Value="0"/>
<TopLine Value="388"/>
<CursorPos X="1" Y="404"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit57>
<Unit58>
<Filename Value="C:\lazarus\fpc\2.6.0\source\rtl\objpas\sysutils\sysstrh.inc"/>
@ -534,138 +519,161 @@
</Unit60>
<Unit61>
<Filename Value="C:\lazarus\fpc\2.6.0\source\rtl\objpas\classes\compon.inc"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="514"/>
<CursorPos X="6" Y="519"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit61>
<Unit62>
<Filename Value="uform2.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form2"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uForm2"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="47"/>
<CursorPos X="18" Y="50"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit62>
</Units>
<General>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="umainform.pas"/>
<Caret Line="79" Column="22" TopLine="71"/>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="506" Column="39" TopLine="493"/>
</Position1>
<Position2>
<Filename Value="umainform.pas"/>
<Caret Line="81" Column="22" TopLine="73"/>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position2>
<Position3>
<Filename Value="umainform.pas"/>
<Caret Line="121" Column="26" TopLine="110"/>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="59" Column="15" TopLine="48"/>
</Position3>
<Position4>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="144" Column="61" TopLine="127"/>
<Caret Line="514" Column="25" TopLine="499"/>
</Position4>
<Position5>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="446" Column="2" TopLine="441"/>
<Caret Line="519" Column="20" TopLine="499"/>
</Position5>
<Position6>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="512" Column="3" TopLine="510"/>
<Filename Value="uform1.pas"/>
<Caret Line="88" Column="1" TopLine="77"/>
</Position6>
<Position7>
<Filename Value="C:\lazarus\lcl\lclproc.pas"/>
<Caret Line="864" Column="51" TopLine="851"/>
<Filename Value="uform1.pas"/>
<Caret Line="89" Column="1" TopLine="77"/>
</Position7>
<Position8>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="512" Column="3" TopLine="510"/>
<Caret Line="327" Column="1" TopLine="316"/>
</Position8>
<Position9>
<Filename Value="..\..\..\..\TOOLS\DJ_FormPrincipal.pas"/>
<Caret Line="141" Column="38" TopLine="141"/>
<Filename Value="umainform.pas"/>
<Caret Line="130" Column="29" TopLine="120"/>
</Position9>
<Position10>
<Filename Value="..\..\..\..\TOOLS\DJ_FormPrincipal.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="umainform.pas"/>
<Caret Line="113" Column="34" TopLine="111"/>
</Position10>
<Position11>
<Filename Value="..\..\..\..\TOOLS\DJ_FormPrincipal.pas"/>
<Caret Line="304" Column="21" TopLine="291"/>
<Filename Value="umainform.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position11>
<Position12>
<Filename Value="..\..\..\..\TOOLS\DJ_FormPrincipal.pas"/>
<Caret Line="305" Column="21" TopLine="291"/>
<Filename Value="umainform.pas"/>
<Caret Line="8" Column="5" TopLine="1"/>
</Position12>
<Position13>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="114" Column="15" TopLine="112"/>
<Filename Value="umainform.pas"/>
<Caret Line="60" Column="20" TopLine="41"/>
</Position13>
<Position14>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="508" Column="2" TopLine="493"/>
<Filename Value="uform2.pas"/>
<Caret Line="40" Column="38" TopLine="24"/>
</Position14>
<Position15>
<Filename Value="uform1.pas"/>
<Caret Line="87" Column="3" TopLine="69"/>
<Filename Value="uform2.pas"/>
<Caret Line="46" Column="63" TopLine="30"/>
</Position15>
<Position16>
<Filename Value="uform1.pas"/>
<Caret Line="84" Column="27" TopLine="70"/>
<Filename Value="uform2.pas"/>
<Caret Line="52" Column="38" TopLine="36"/>
</Position16>
<Position17>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="502" Column="30" TopLine="493"/>
<Filename Value="uform2.pas"/>
<Caret Line="63" Column="43" TopLine="42"/>
</Position17>
<Position18>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="503" Column="1" TopLine="493"/>
<Filename Value="uform2.pas"/>
<Caret Line="57" Column="14" TopLine="47"/>
</Position18>
<Position19>
<Filename Value="C:\lazarus\lcl\controls.pp"/>
<Caret Line="1625" Column="14" TopLine="1614"/>
<Filename Value="uform2.pas"/>
<Caret Line="64" Column="14" TopLine="54"/>
</Position19>
<Position20>
<Filename Value="C:\lazarus\lcl\include\control.inc"/>
<Caret Line="3994" Column="3" TopLine="3987"/>
<Filename Value="uform2.pas"/>
<Caret Line="50" Column="1" TopLine="46"/>
</Position20>
<Position21>
<Filename Value="C:\lazarus\lcl\include\control.inc"/>
<Caret Line="3680" Column="3" TopLine="3675"/>
<Filename Value="umainform.pas"/>
<Caret Line="114" Column="13" TopLine="111"/>
</Position21>
<Position22>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="506" Column="39" TopLine="493"/>
<Filename Value="uform2.pas"/>
<Caret Line="50" Column="1" TopLine="46"/>
</Position22>
<Position23>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="uform2.pas"/>
<Caret Line="55" Column="24" TopLine="49"/>
</Position23>
<Position24>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="59" Column="15" TopLine="48"/>
<Filename Value="uform2.pas"/>
<Caret Line="54" Column="24" TopLine="48"/>
</Position24>
<Position25>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="514" Column="25" TopLine="499"/>
<Filename Value="uform2.pas"/>
<Caret Line="53" Column="24" TopLine="47"/>
</Position25>
<Position26>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="519" Column="20" TopLine="499"/>
<Filename Value="uform2.pas"/>
<Caret Line="51" Column="1" TopLine="38"/>
</Position26>
<Position27>
<Filename Value="uform1.pas"/>
<Caret Line="88" Column="1" TopLine="77"/>
<Filename Value="umainform.pas"/>
<Caret Line="119" Column="19" TopLine="111"/>
</Position27>
<Position28>
<Filename Value="uform1.pas"/>
<Caret Line="89" Column="1" TopLine="77"/>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="125" Column="38" TopLine="117"/>
</Position28>
<Position29>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="327" Column="1" TopLine="316"/>
<Filename Value="umainform.pas"/>
<Caret Line="113" Column="32" TopLine="111"/>
</Position29>
<Position30>
<Filename Value="C:\lazarus\lcl\include\customnotebook.inc"/>
<Caret Line="303" Column="1" TopLine="292"/>
<Filename Value="..\tdiclass.pas"/>
<Caret Line="248" Column="3" TopLine="245"/>
</Position30>
</JumpHistory>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="..\tdiclass.pas"/>
<Line Value="248"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>

View File

@ -16,12 +16,12 @@ object Form1: TForm1
OnDestroy = FormDestroy
LCLVersion = '1.1'
object bClose: TButton
Left = 400
Left = 376
Height = 25
Top = 224
Width = 86
Top = 216
Width = 111
AutoSize = True
Caption = 'Close Form'
Caption = 'Close,Free Form'
OnClick = bCloseClick
TabOrder = 2
end
@ -65,14 +65,14 @@ object Form1: TForm1
Left = 16
Height = 46
Top = 208
Width = 360
Caption = 'You can Close or Hide your Forms the same way you used to.'#13#10'No Special method is necessary. TDINotebook will detect by internal'#13#10'Notification and Close the Tab Sheet'
Width = 324
Caption = 'You can Close or Hide your Forms the same way you used to.'#13#10'No Special method is necessary. TDINotebook will detect by '#13#10'internal Notification and Close the Tab Sheet'
ParentColor = False
end
object bHide: TButton
AnchorSideLeft.Control = bClose
AnchorSideLeft.Side = asrCenter
Left = 402
Left = 390
Height = 25
Top = 256
Width = 82

View File

@ -0,0 +1,57 @@
object Form2: TForm2
Left = 709
Height = 240
Top = 330
Width = 320
Caption = 'Form2'
ClientHeight = 240
ClientWidth = 320
OnClose = FormClose
OnCloseQuery = FormCloseQuery
OnDestroy = FormDestroy
OnHide = FormHide
OnShow = FormShow
LCLVersion = '1.1'
object Edit1: TEdit
Left = 51
Height = 23
Top = 37
Width = 80
TabOrder = 0
Text = 'Edit1'
end
object Edit2: TEdit
Left = 159
Height = 23
Top = 37
Width = 80
TabOrder = 1
Text = 'Edit2'
end
object CheckBox1: TCheckBox
Left = 51
Height = 19
Top = 72
Width = 78
Caption = 'CheckBox1'
TabOrder = 2
end
object CheckBox2: TCheckBox
Left = 51
Height = 19
Top = 104
Width = 78
Caption = 'CheckBox2'
TabOrder = 3
end
object Button1: TButton
Left = 208
Height = 25
Top = 186
Width = 86
AutoSize = True
Caption = 'Close Form'
OnClick = Button1Click
TabOrder = 4
end
end

View File

@ -0,0 +1,75 @@
unit uForm2 ;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons ;
type
{ TForm2 }
TForm2 = class(TForm)
Button1 : TButton ;
CheckBox1 : TCheckBox ;
CheckBox2 : TCheckBox ;
Edit1 : TEdit ;
Edit2 : TEdit ;
procedure Button1Click(Sender : TObject) ;
procedure FormClose(Sender : TObject ; var CloseAction : TCloseAction) ;
procedure FormCloseQuery(Sender : TObject ; var CanClose : boolean) ;
procedure FormDestroy(Sender : TObject) ;
procedure FormHide(Sender : TObject) ;
procedure FormShow(Sender : TObject) ;
private
{ private declarations }
public
{ public declarations }
end ;
var
Form2 : TForm2 ;
implementation
Uses uMainForm;
{ TForm2 }
procedure TForm2.FormClose(Sender : TObject ; var CloseAction : TCloseAction) ;
begin
fMainForm.mEvents.Lines.Add( 'Form2.Close' );
end;
procedure TForm2.Button1Click(Sender : TObject) ;
begin
Close;
end;
procedure TForm2.FormCloseQuery(Sender : TObject ; var CanClose : boolean) ;
begin
fMainForm.mEvents.Lines.Add( 'Form2.CloseQuery: '+BoolToStr(CanClose,'True','False') );
end;
procedure TForm2.FormDestroy(Sender : TObject) ;
begin
fMainForm.mEvents.Lines.Add( 'Form2.Destroy' );
end;
procedure TForm2.FormHide(Sender : TObject) ;
begin
fMainForm.mEvents.Lines.Add( 'Form2.Hide' );
end;
procedure TForm2.FormShow(Sender : TObject) ;
begin
fMainForm.mEvents.Lines.Add( 'Form2.Show' );
end;
{$R *.lfm}
end.

View File

@ -1,5 +1,5 @@
object fMainForm: TfMainForm
Left = 478
Left = 471
Height = 484
Top = 200
Width = 746
@ -63,7 +63,7 @@ object fMainForm: TfMainForm
AnchorSideLeft.Side = asrCenter
Left = 167
Height = 31
Top = 304
Top = 312
Width = 244
Alignment = taCenter
Caption = 'This is a Fixed Page, and cannot be closed.'#13#10'You can configure it on "FixedPages" Property'
@ -672,6 +672,7 @@ object fMainForm: TfMainForm
end
object miForm2: TMenuItem
Caption = 'Show Already Created Form 2'
OnClick = miForm2Click
end
object MenuItem2: TMenuItem
Caption = '-'

View File

@ -41,6 +41,7 @@ type
procedure FormCreate(Sender : TObject) ;
procedure miExitClick(Sender : TObject) ;
procedure miForm1Click(Sender : TObject) ;
procedure miForm2Click(Sender : TObject) ;
procedure seFixedPagesChange(Sender : TObject) ;
procedure TDINoteBook1Change(Sender : TObject) ;
private
@ -56,7 +57,7 @@ var
implementation
Uses uForm1 ;
Uses uForm1, uForm2 ;
{$R *.lfm}
@ -107,6 +108,11 @@ begin
TDINoteBook1.CreateFormInNewPage( TForm1, 3 );
end;
procedure TfMainForm.miForm2Click(Sender : TObject) ;
begin
TDINoteBook1.ShowForInNewPage( Form2, 4 );
end;
procedure TfMainForm.seFixedPagesChange(Sender : TObject) ;
begin
TDINoteBook1.FixedPages := seFixedPages.Value;

View File

@ -122,6 +122,7 @@ type
procedure CreateFormInNewPage( AFormClass: TFormClass; ImageIndex : Integer = -1 ) ;
procedure ShowForInNewPage( AForm: TForm; ImageIndex : Integer = -1 );
Function FindFormInPages( AForm: TForm): Integer ;
Function CanCloseAllPages: Boolean ;
Function CanCloseAPage( APageIndex: Integer): Boolean;
@ -499,7 +500,16 @@ end ;
procedure TTDINoteBook.ShowForInNewPage(AForm : TForm ; ImageIndex : Integer) ;
Var
NewPage : TTDIPage ;
AlreadyExistingPage : Integer ;
begin
// Looking for a Page with same AForm Object //
AlreadyExistingPage := FindFormInPages( AForm );
if AlreadyExistingPage >= 0 then
begin
PageIndex := AlreadyExistingPage;
exit ;
end ;
// Create a new Page
NewPage := TTDIPage.Create(Self);
NewPage.ImageIndex := ImageIndex;
@ -520,6 +530,26 @@ begin
end ;
end ;
function TTDINoteBook.FindFormInPages(AForm : TForm) : Integer ;
var
I : Integer ;
begin
Result := -1;
I := 0;
while (Result < 0) and (I < PageCount) do
begin
if Pages[I] is TTDIPage then
with TTDIPage( Pages[I] ) do
begin
if AForm = FormInPage then
Result := I;
end ;
Inc( I ) ;
end ;
end ;
procedure TTDINoteBook.CheckInterface ;
begin
if ([csDesigning, csDestroying] * ComponentState <> []) then exit ;