1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
unit TestADRestore;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
fpcunit, testregistry,
Controls, Forms, StdCtrls, ExtCtrls,
AnchorDocking,
SimpleFrm;
type
{ TMainBar }
TMainBar = class(TCustomForm)
BtnPanel: TPanel;
NewBtn: TButton;
public
end;
{ TCustomTestADRestore }
TCustomTestADRestore = class(TTestCase)
private
FMainBar: TMainBar;
protected
procedure SetUp; override;
procedure TearDown; override;
procedure DockMasterCreateControl(Sender: TObject; aName: string; var
AControl: TControl; DoDisableAutoSizing: boolean);
public
procedure CreateMainBar(DisabledAutoSize: boolean);
property MainBar: TMainBar read FMainBar;
end;
{ TTestADRestore }
TTestADRestore = class(TCustomTestADRestore)
published
procedure TestNoDock;
end;
implementation
{ TCustomTestADRestore }
procedure TCustomTestADRestore.SetUp;
begin
DockMaster.OnCreateControl:=@DockMasterCreateControl;
//DockMaster.OnShowOptions:=@ShowAnchorDockOptions;
end;
procedure TCustomTestADRestore.TearDown;
begin
DockMaster.OnCreateControl:=nil;
FreeAndNil(FMainBar);
end;
procedure TCustomTestADRestore.DockMasterCreateControl(Sender: TObject;
aName: string; var AControl: TControl; DoDisableAutoSizing: boolean);
procedure CreateForm(Caption: string; NewBounds: TRect);
begin
AControl:=CreateSimpleForm(aName,Caption,NewBounds,DoDisableAutoSizing);
end;
begin
if aName='CodeExplorer' then
CreateForm('Code Explorer',Bounds(700,230,100,250))
else if aName='FPDocEditor' then
CreateForm('FPDoc Editor',Bounds(200,720,300,100))
else if aName='Messages' then
CreateForm('Messages',Bounds(230,650,350,100))
else if aName='ObjectInspector' then
CreateForm('Object Inspector',Bounds(10,200,100,350))
else if aName='SourceEditor1' then
CreateForm('Source Editor 1',Bounds(230,200,400,400))
else if aName='SourceEditor2' then
CreateForm('Source Editor 2',Bounds(260,230,350,350))
else if aName='ProjectInspector' then
CreateForm('Project Inspector',Bounds(10,230,150,250))
else if aName='DebugOutput' then
CreateForm('Debug Output',Bounds(400,400,350,150));
end;
procedure TCustomTestADRestore.CreateMainBar(DisabledAutoSize: boolean);
begin
FMainBar:=TMainBar(TMainBar.NewInstance);
FMainBar.DisableAutoSizing;
try
with FMainBar do begin
Create(Application);
Name:='MainBar';
Caption:='Main Bar';
SetBounds(10,11,600,100);
Visible:=true;
end;
FMainBar.BtnPanel:=TPanel.Create(FMainBar);
with FMainBar.BtnPanel do begin
Parent:=FMainBar;
Name:='BtnPanel';
Caption:='';
AutoSize:=true;
Align:=alLeft;
end;
FMainBar.NewBtn:=TButton.Create(FMainBar);
with FMainBar.NewBtn do begin
Parent:=FMainBar.BtnPanel;
Name:='NewBtn';
AutoSize:=true;
end;
DockMaster.MakeDockSite(FMainBar,[akBottom],admrpChild);
finally
if not DisabledAutoSize then
FMainBar.EnableAutoSizing;
end;
end;
{ TTestADRestore }
procedure TTestADRestore.TestNoDock;
begin
CreateMainBar(false);
end;
initialization
RegisterTest(TCustomTestADRestore);
end.
|