123
123
TIDEWindowState = (iwsNormal, iwsMaximized, iwsMinimized, iwsHidden);
124
124
TIDEWindowStates = set of TIDEWindowState;
126
TSimpleWindowLayoutDividerPosPlacement = (
127
iwpdDefault, // set column/row/splitter to the default size
128
iwpdCustomSize, // set column/row/splitter to the custom size
129
iwpdRestore, // save column/row/splitter size on exit, and restore
133
TSimpleWindowLayoutDividerPosSizeGetter =
134
function(AForm: TCustomForm; AColId: Integer; var ASize: Integer): Boolean;
136
TSimpleWindowLayoutDividerPosSizeSetter =
137
procedure(AForm: TCustomForm; AColId: Integer; ASize: Integer);
139
{ TSimpleWindowLayoutDividerPos }
141
TSimpleWindowLayoutDividerPos = class
143
FDefaultSize: integer;
144
FDisplayName: PString;
147
FPlacement: TSimpleWindowLayoutDividerPosPlacement;
149
function GetDisplayName: String;
151
procedure SetDisplayName(ADisplayName: PString);
152
procedure SetId(AnId: Integer);
154
constructor Create(AnIdString: String);
155
constructor Create(AnIdString: String; AnId: Integer; ADisplayName: PString);
156
procedure Assign(ADividerPos: TSimpleWindowLayoutDividerPos); reintroduce;
157
procedure LoadFromConfig(Config: TConfigStorage; const Path: string);
158
function SaveToConfig(Config: TConfigStorage; const Path: string) : Boolean;
160
property IdString: String read FIdString;
161
property Id: Integer read FId;
162
property DisplayName: String read GetDisplayName;
163
property Placement: TSimpleWindowLayoutDividerPosPlacement read FPlacement write FPlacement;
164
property Size: integer read FSize write FSize;
165
property DefaultSize: integer read FDefaultSize write FDefaultSize;
168
{ TSimpleWindowLayoutDividerPosList }
170
TSimpleWindowLayoutDividerPosList = class
173
function GetItems(Index: Integer): TSimpleWindowLayoutDividerPos;
174
function GetNamedItems(Index: Integer): TSimpleWindowLayoutDividerPos;
176
procedure Merge(AnItem: TSimpleWindowLayoutDividerPos);
179
destructor Destroy; override;
180
procedure Assign(ADividerPosList: TSimpleWindowLayoutDividerPosList); reintroduce;
181
procedure LoadFromConfig(Config: TConfigStorage; const Path: string);
182
procedure SaveToConfig(Config: TConfigStorage; const Path: string);
184
procedure ClearItems;
185
function Add(AnIdString: String; AnId: Integer; ADisplayName: PString): TSimpleWindowLayoutDividerPos;
186
function Add(AnIdString: String): TSimpleWindowLayoutDividerPos;
187
function Count: Integer;
188
function NamedCount: Integer;
189
function Find(AnId: Integer): TSimpleWindowLayoutDividerPos;
190
function Find(AnIdString: String): TSimpleWindowLayoutDividerPos;
191
function IndexOf(AnId: Integer): Integer;
192
function IndexOf(AnIdString: String): Integer;
193
function IndexOf(AnItem: TSimpleWindowLayoutDividerPos): Integer;
194
property Items[Index: Integer]: TSimpleWindowLayoutDividerPos read GetItems; default;
195
property NamedItems[Index: Integer]: TSimpleWindowLayoutDividerPos read GetNamedItems;
126
198
{ TSimpleWindowLayout }
128
200
TSimpleWindowLayout = class(TComponent)
149
222
constructor Create(AFormID: string); reintroduce;
150
223
destructor Destroy; override;
224
function CreateCopy: TSimpleWindowLayout;
152
226
procedure GetCurrentPosition;
227
function Apply: Boolean;
228
procedure ApplyDivider(AForce: Boolean = False);
153
229
procedure Assign(Layout: TSimpleWindowLayout); reintroduce;
230
procedure ReadCurrentDividers(AForce: Boolean = False);
154
231
procedure ReadCurrentCoordinates;
155
232
procedure ReadCurrentState;
156
233
procedure LoadFromConfig(Config: TConfigStorage; const Path: string);
157
234
procedure SaveToConfig(Config: TConfigStorage; const Path: string);
158
235
function CustomCoordinatesAreValid: boolean;
159
236
procedure CloseForm;
237
function ValidateAndSetCoordinates: Boolean;
161
239
property FormID: string read GetFormID write FFormID;
162
240
function FormBaseID(out SubIndex: Integer): String; // split FormID into name+number
163
241
property FormCaption: string read GetFormCaption;
164
242
property WindowPlacement: TIDEWindowPlacement read fWindowPlacement write FWindowPlacement;
165
243
property DefaultWindowPlacement: TIDEWindowPlacement
166
read fDefaultWindowPlacement write fDefaultWindowPlacement;
167
property Left: integer read fLeft write FLeft;
168
property Top: integer read fTop write FTop;
169
property Width: integer read fWidth write FWidth;
170
property Height: integer read fHeight write FHeight;
171
property WindowState: TIDEWindowState read fWindowState write FWindowState;
172
property Form: TCustomForm read fForm write SetForm;
244
read FDefaultWindowPlacement write FDefaultWindowPlacement;
245
property Left: integer read FLeft write FLeft;
246
property Top: integer read FTop write FTop;
247
property Width: integer read FWidth write FWidth;
248
property Height: integer read FHeight write FHeight;
249
property WindowState: TIDEWindowState read FWindowState write FWindowState;
250
property Form: TCustomForm read FForm write SetForm;
173
251
property Visible: boolean read FVisible write FVisible;
174
252
property Applied: boolean read FApplied write FApplied;
253
property Dividers: TSimpleWindowLayoutDividerPosList read FDividers;
177
256
{ TSimpleWindowLayoutList }
426
523
RegisterComponents('Misc',[TIDEDialogLayoutStorage]);
526
{ TSimpleWindowLayoutDividerPosList }
528
function TSimpleWindowLayoutDividerPosList.GetItems(Index: Integer): TSimpleWindowLayoutDividerPos;
530
Result := TSimpleWindowLayoutDividerPos(FList[Index]);
533
function TSimpleWindowLayoutDividerPosList.GetNamedItems(Index: Integer): TSimpleWindowLayoutDividerPos;
539
while i < Count do begin
540
if Items[i].DisplayName <> '' then begin
541
if Index = 0 then begin
551
procedure TSimpleWindowLayoutDividerPosList.Merge(AnItem: TSimpleWindowLayoutDividerPos);
554
old: TSimpleWindowLayoutDividerPos;
556
i := IndexOf(AnItem.IdString);
562
if AnItem.Id < 0 then
563
AnItem.SetId(old.Id);
564
if AnItem.DisplayName = '' then
565
AnItem.SetDisplayName(old.FDisplayName);
566
if AnItem.DefaultSize < 0 then
567
AnItem.DefaultSize := old.DefaultSize;
573
constructor TSimpleWindowLayoutDividerPosList.Create;
575
FList := TList.Create;
578
destructor TSimpleWindowLayoutDividerPosList.Destroy;
585
procedure TSimpleWindowLayoutDividerPosList.Assign(ADividerPosList: TSimpleWindowLayoutDividerPosList);
588
tmp: TSimpleWindowLayoutDividerPos;
591
for i := 0 to ADividerPosList.Count - 1 do begin
593
tmp.Assign(ADividerPosList[i]);
597
procedure TSimpleWindowLayoutDividerPosList.LoadFromConfig(Config: TConfigStorage;
600
tmp: TSimpleWindowLayoutDividerPos;
604
c := Config.GetValue(Path+'Count', 0);
605
for i := 0 to c - 1 do begin
606
tmp := TSimpleWindowLayoutDividerPos.Create('');
607
tmp.LoadFromConfig(Config, Path + 'Item' + IntToStr(i) + '/');
612
procedure TSimpleWindowLayoutDividerPosList.SaveToConfig(Config: TConfigStorage;
618
for i := 0 to Count - 1 do
619
if Items[i].SaveToConfig(Config, Path + 'Item' + IntToStr(c) + '/') then
621
for i := c to Count - 1 do
622
Config.DeletePath(Path + 'Item' + IntToStr(i) + '/');
623
Config.SetDeleteValue(Path+'Count', c, 0);
626
procedure TSimpleWindowLayoutDividerPosList.Clear;
628
while FList.Count > 0 do begin
629
TObject(FList[0]).Free;
634
procedure TSimpleWindowLayoutDividerPosList.ClearItems;
638
for i := 0 to Count - 1 do
642
function TSimpleWindowLayoutDividerPosList.Add(AnIdString: String;
643
AnId: Integer; ADisplayName: PString): TSimpleWindowLayoutDividerPos;
650
Result := TSimpleWindowLayoutDividerPos.Create(AnIdString, AnId, ADisplayName);
655
if ADisplayName = nil then
656
Result.SetDisplayName(ADisplayName);
660
function TSimpleWindowLayoutDividerPosList.Add(AnIdString: String): TSimpleWindowLayoutDividerPos;
662
Result := Add(AnIdString, -1, nil);
665
function TSimpleWindowLayoutDividerPosList.Count: Integer;
667
Result := FList.Count;
670
function TSimpleWindowLayoutDividerPosList.NamedCount: Integer;
676
while i >= 0 do begin
677
if Items[i].DisplayName <> '' then inc(Result);
682
function TSimpleWindowLayoutDividerPosList.Find(AnId: Integer): TSimpleWindowLayoutDividerPos;
692
function TSimpleWindowLayoutDividerPosList.Find(AnIdString: String): TSimpleWindowLayoutDividerPos;
697
i := IndexOf(AnIdString);
702
function TSimpleWindowLayoutDividerPosList.IndexOf(AnId: Integer): Integer;
704
Result := Flist.Count-1;
705
while Result >= 0 do begin
706
if Items[Result].Id = AnId then
712
function TSimpleWindowLayoutDividerPosList.IndexOf(AnIdString: String): Integer;
714
Result := Flist.Count-1;
715
while Result >= 0 do begin
716
if Items[Result].IdString = AnIdString then
722
function TSimpleWindowLayoutDividerPosList.IndexOf(AnItem: TSimpleWindowLayoutDividerPos): Integer;
724
Result := FList.IndexOf(AnItem);
727
{ TSimpleWindowLayoutDividerPos }
729
function TSimpleWindowLayoutDividerPos.GetDisplayName: String;
731
if FDisplayName = nil then
734
Result := FDisplayName^;
737
procedure TSimpleWindowLayoutDividerPos.SetDisplayName(ADisplayName: PString);
739
FDisplayName := ADisplayName;
742
procedure TSimpleWindowLayoutDividerPos.SetId(AnId: Integer);
747
constructor TSimpleWindowLayoutDividerPos.Create(AnIdString: String);
749
Create(AnIdString, -1, nil);
752
constructor TSimpleWindowLayoutDividerPos.Create(AnIdString: String; AnId: Integer;
753
ADisplayName: PString);
758
FIdString := AnIdString;
759
FDisplayName := ADisplayName;
762
procedure TSimpleWindowLayoutDividerPos.Assign(ADividerPos: TSimpleWindowLayoutDividerPos);
764
FDefaultSize := ADividerPos.FDefaultSize;
765
FDisplayName := ADividerPos.FDisplayName;
766
FId := ADividerPos.FId;
767
FIdString := ADividerPos.FIdString;
768
FPlacement := ADividerPos.FPlacement;
769
FSize := ADividerPos.FSize;
772
procedure TSimpleWindowLayoutDividerPos.LoadFromConfig(Config: TConfigStorage;
778
FIdString := Config.GetValue(Path+'ID', '');
779
FSize := Config.GetValue(Path+'Size', -1);
780
s := Config.GetValue(Path+'Placement', 'iwpdUseWindowSetting');
782
ReadStr(s, FPlacement);
784
FPlacement := iwpdUseWindowSetting;
788
function TSimpleWindowLayoutDividerPos.SaveToConfig(Config: TConfigStorage;
789
const Path: string): Boolean;
793
Result := (FSize <> -1) or (FPlacement <> iwpdUseWindowSetting);
796
WriteStr(s, FPlacement);
797
Config.SetDeleteValue(Path+'ID', FIdString, '');
798
Config.SetDeleteValue(Path+'Size', FSize, -1);
799
Config.SetDeleteValue(Path+'Placement', s, 'iwpdUseWindowSetting');
802
procedure TSimpleWindowLayoutDividerPos.Clear;
804
FSize := FDefaultSize;
805
FPlacement := iwpdUseWindowSetting;
429
808
{ TIDEDialogLayout }
431
procedure TIDEDialogLayout.SetHeight(const AValue: integer);
433
if FHeight=AValue then exit;
438
810
procedure TIDEDialogLayout.SetList(const AValue: TIDEDialogLayoutList);
440
812
if FList=AValue then exit;
694
1083
fWindowPlacement:=StrToIDEWindowPlacement(Config.GetValue(
695
1084
P+'WindowPlacement/Value',IDEWindowPlacementNames[fWindowPlacement]));
696
1085
// custom position
697
fLeft:=Config.GetValue(P+'CustomPosition/Left',fLeft);
698
fTop:=Config.GetValue(P+'CustomPosition/Top',fTop);
699
fWidth:=Config.GetValue(P+'CustomPosition/Width',fWidth);
700
fHeight:=Config.GetValue(P+'CustomPosition/Height',fHeight);
1086
Left := Config.GetValue(P+'CustomPosition/Left', Left);
1087
Top := Config.GetValue(P+'CustomPosition/Top', Top);
1088
Width := Config.GetValue(P+'CustomPosition/Width', Width);
1089
Height := Config.GetValue(P+'CustomPosition/Height', Height);
702
1091
fWindowState:=StrToIDEWindowState(Config.GetValue(
703
1092
P+'WindowState/Value',IDEWindowStateNames[fWindowState]));
704
1093
FVisible:=Config.GetValue(P+'Visible/Value',false);
705
1094
//debugln(['TSimpleWindowLayout.LoadFromConfig ',FormID,' ',Left,',',Top,',',Width,',',Height]);
1095
FDividers.LoadFromConfig(Config, P + 'Divider/');
708
1098
procedure TSimpleWindowLayout.SaveToConfig(Config: TConfigStorage;
720
1110
IDEWindowPlacementNames[fWindowPlacement],
721
1111
IDEWindowPlacementNames[iwpRestoreWindowSize]);
722
1112
// custom position
723
Config.SetDeleteValue(P+'CustomPosition/Left',fLeft,0);
724
Config.SetDeleteValue(P+'CustomPosition/Top',fTop,0);
725
Config.SetDeleteValue(P+'CustomPosition/Width',fWidth,0);
726
Config.SetDeleteValue(P+'CustomPosition/Height',fHeight,0);
1113
Config.SetDeleteValue(P+'CustomPosition/Left', Left, 0);
1114
Config.SetDeleteValue(P+'CustomPosition/Top', Top, 0);
1115
Config.SetDeleteValue(P+'CustomPosition/Width', Width, 0);
1116
Config.SetDeleteValue(P+'CustomPosition/Height', Height, 0);
728
1118
Config.SetValue(P+'WindowState/Value',IDEWindowStateNames[fWindowState]);
729
1119
Config.SetDeleteValue(P+'Visible/Value',FVisible,false);
1120
FDividers.SaveToConfig(Config, P + 'Divider/');
732
1123
procedure TSimpleWindowLayout.OnFormClose(Sender: TObject;
1152
function TSimpleWindowLayout.ValidateAndSetCoordinates: Boolean;
1158
if CustomCoordinatesAreValid then begin
1159
// explicit position
1160
NewBounds := Bounds(Left, Top, Width, Height);
1162
if NewBounds.Right - NewBounds.Left < 60 then
1163
NewBounds.Right := NewBounds.Left + 60;
1164
if NewBounds.Bottom - NewBounds.Top < 60 then
1165
NewBounds.Bottom := NewBounds.Top + 60;
1167
// Move to visible area :
1168
// window is out at left side of screen
1169
if NewBounds.Right < Screen.DesktopLeft + 60 then
1170
OffsetRect(NewBounds, Screen.DesktopLeft + 60 - NewBounds.Right, 0);
1172
// window is out above the screen
1173
if NewBounds.Bottom < Screen.DesktopTop+60 then
1174
OffsetRect(NewBounds, 0, Screen.DesktopTop + 60 - NewBounds.Bottom);
1176
// window is out at right side of screen, i = right edge of screen - 60
1177
i := Screen.DesktopWidth + Screen.DesktopLeft - 60;
1178
if NewBounds.Left > i then begin
1179
NewBounds.Left := i;
1180
NewBounds.Right := NewBounds.Right + i - NewBounds.Left;
1183
// window is out below the screen, i = bottom edge of screen - 60
1184
i := Screen.DesktopHeight + Screen.DesktopTop - 60;
1185
if NewBounds.Top > i then begin
1187
NewBounds.Bottom := NewBounds.Bottom + i - NewBounds.Top;
1190
// set bounds (do not use SetRestoredBounds - that flickers with the current LCL implementation)
1191
FForm.SetBounds(NewBounds.Left, NewBounds.Top,
1192
NewBounds.Right - NewBounds.Left,
1193
NewBounds.Bottom - NewBounds.Top);
761
1198
function TSimpleWindowLayout.FormBaseID(out SubIndex: Integer): String;
852
1293
FApplied:=Layout.Applied;
854
fWindowPlacement:=Layout.fWindowPlacement;
857
fWidth:=Layout.fWidth;
858
fHeight:=Layout.fHeight;
859
fWindowState:=Layout.fWindowState;
860
fFormID:=Layout.fFormID;
861
fDefaultWindowPlacement:=Layout.fDefaultWindowPlacement;
1294
FForm:=Layout.FForm;
1295
FWindowPlacement:=Layout.FWindowPlacement;
1296
FLeft:=Layout.FLeft;
1298
FWidth:=Layout.FWidth;
1299
FHeight:=Layout.FHeight;
1300
FWindowState:=Layout.FWindowState;
1301
FFormID:=Layout.FFormID;
1302
FDefaultWindowPlacement:=Layout.FDefaultWindowPlacement;
1303
FDividers.Assign(Layout.FDividers);
1306
procedure TSimpleWindowLayout.ReadCurrentDividers(AForce: Boolean = False);
1310
Creator: TIDEWindowCreator;
1312
Creator:=IDEWindowCreators.FindWithName(FormID);
1313
if (Creator = nil) or (Creator.OnGetDividerSize = nil) then exit;
1314
if fForm = nil then exit;
1315
for i := 0 to FDividers.Count - 1 do begin
1316
if FDividers[i].FId < 0 then continue;
1318
case FDividers[i].Placement of
1321
iwpdUseWindowSetting:
1322
f := WindowPlacement in [iwpRestoreWindowGeometry, iwpRestoreWindowSize];
1325
if Creator.OnGetDividerSize(fForm, FDividers[i].Id, j) then
1326
FDividers[i].Size := j
1328
FDividers[i].Size := -1; // Default / Not Changed / Unavailable
864
1332
procedure TSimpleWindowLayout.GetCurrentPosition;
868
1336
iwpRestoreWindowGeometry, iwpRestoreWindowSize:
869
1337
ReadCurrentCoordinates;
1339
ReadCurrentDividers;
871
1340
ReadCurrentState;
872
1341
//debugln('TSimpleWindowLayout.GetCurrentPosition ',DbgSName(Self),' ',FormID,' Width=',dbgs(Width));
1344
function TSimpleWindowLayout.Apply: Boolean;
1347
if fForm = nil then exit;
1349
{$IFDEF VerboseIDEDocking}
1350
debugln(['TSimpleWindowLayoutList.ApplyAndShow restore ',
1351
FormID,' ',IDEWindowPlacementNames[WindowPlacement],
1352
' ',Left,',',Top,',',Width,',',Height]);
1355
case WindowPlacement of
1356
iwpCustomPosition,iwpRestoreWindowGeometry:
1358
//DebugLn(['TMainIDE.OnApplyWindowLayout ',IDEWindowStateNames[WindowState]]);
1360
iwsMinimized: FForm.WindowState:=wsMinimized;
1361
iwsMaximized: FForm.WindowState:=wsMaximized;
1363
Result := ValidateAndSetCoordinates; // Adjust bounds to screen area and apply them.
1364
if WindowState in [iwsMinimized, iwsMaximized] then
1367
iwpUseWindowManagerSetting:
1374
procedure TSimpleWindowLayout.ApplyDivider(AForce: Boolean = False);
1378
Creator: TIDEWindowCreator;
1380
Creator:=IDEWindowCreators.FindWithName(FormID);
1381
if (Creator <> nil) and (Creator.OnSetDividerSize <> nil) then begin
1382
for i := 0 to FDividers.Count - 1 do begin
1383
if (FDividers[i].FId < 0) or (FDividers[i].Size < 0) then continue;
1385
case FDividers[i].Placement of
1386
iwpdRestore, iwpdCustomSize:
1388
iwpdUseWindowSetting:
1389
f := WindowPlacement in [iwpRestoreWindowGeometry, iwpRestoreWindowSize];
1392
Creator.OnSetDividerSize(fForm, FDividers[i].Id, FDividers[i].Size);
875
1397
{ TSimpleWindowLayoutList }
877
1399
procedure TSimpleWindowLayoutList.Clear;
880
1403
for i:=0 to Count-1 do Items[i].Free;
1026
1550
ALayout.Form:=AForm;
1027
1551
if ALayout.Applied then exit;
1028
ALayout.Applied:=true;
1029
{$IFDEF VerboseIDEDocking}
1030
debugln(['TSimpleWindowLayoutList.ApplyAndShow restore ',ALayout.FormID,' ',IDEWindowPlacementNames[ALayout.WindowPlacement],' Valid=',ALayout.CustomCoordinatesAreValid,' ',ALayout.Left,',',ALayout.Top,',',ALayout.Width,',',ALayout.Height]);
1033
case ALayout.WindowPlacement of
1034
iwpCustomPosition,iwpRestoreWindowGeometry:
1036
//DebugLn(['TMainIDE.OnApplyWindowLayout ',IDEWindowStateNames[ALayout.WindowState]]);
1037
case ALayout.WindowState of
1038
iwsMinimized: AForm.WindowState:=wsMinimized;
1039
iwsMaximized: AForm.WindowState:=wsMaximized;
1042
if (ALayout.CustomCoordinatesAreValid) then begin
1043
// explicit position
1044
NewBounds:=Bounds(ALayout.Left,ALayout.Top,ALayout.Width,ALayout.Height);
1046
if NewBounds.Right-NewBounds.Left<20 then
1047
NewBounds.Right:=NewBounds.Left+20;
1048
if NewBounds.Bottom-NewBounds.Top<20 then
1049
NewBounds.Bottom:=NewBounds.Top+20;
1050
// move to visible area
1051
if NewBounds.Right<20 then
1052
OffsetRect(NewBounds,20-NewBounds.Right,0);
1053
if NewBounds.Bottom<20 then
1054
OffsetRect(NewBounds,0,20-NewBounds.Bottom);
1055
if NewBounds.Left>Screen.DesktopWidth-20 then
1056
OffsetRect(NewBounds,NewBounds.Left-(Screen.DesktopWidth-20),0);
1057
if NewBounds.Top>Screen.DesktopHeight-20 then
1058
OffsetRect(NewBounds,NewBounds.Top-(Screen.DesktopHeight-20),0);
1059
// set bounds (do not use SetRestoredBounds - that flickers with the current LCL implementation)
1061
NewBounds.Left,NewBounds.Top,
1062
NewBounds.Right-NewBounds.Left,NewBounds.Bottom-NewBounds.Top);
1066
if ALayout.WindowState in [iwsMinimized, iwsMaximized] then
1070
iwpUseWindowManagerSetting:
1552
if ALayout.Apply then exit;
1077
1555
{$IFDEF VerboseIDEDocking}
1078
debugln(['TSimpleWindowLayoutList.ApplyAndShow no stored layout found, layout registered=',ALayout<>nil,' AForm=',DbgSName(AForm)]);
1556
debugln(['TSimpleWindowLayoutList.ApplyAndShow no stored layout found, layout registered=',
1557
ALayout<>nil,' AForm=',DbgSName(AForm)]);
1081
1560
// no layout found => use default
1245
1756
aRight: LongInt;
1246
1757
aBottom: LongInt;
1762
ScreenR:=IDEWindowCreators.GetScreenrectForDefaults;
1763
ScreenW:=ScreenR.Right-ScreenR.Left;
1764
ScreenH:=ScreenR.Bottom-ScreenR.Top;
1249
1767
if Left='' then
1250
1768
DefBounds.Left:=AForm.Left
1251
1769
else if Left[length(Left)]='%' then
1252
DefBounds.Left:=Screen.Width*StrToIntDef(copy(Left,1,length(Left)-1),0) div 100
1770
DefBounds.Left:=ScreenR.Left+ScreenW*StrToIntDef(copy(Left,1,length(Left)-1),0) div 100
1254
DefBounds.Left:=StrToIntDef(Left,0);
1772
DefBounds.Left:=ScreenR.Left+StrToIntDef(Left,0);
1257
1775
DefBounds.Top:=AForm.Top
1258
1776
else if Top[length(Top)]='%' then
1259
DefBounds.Top:=Screen.Height*StrToIntDef(copy(Top,1,length(Top)-1),0) div 100
1777
DefBounds.Top:=ScreenR.Top+ScreenH*StrToIntDef(copy(Top,1,length(Top)-1),0) div 100
1261
DefBounds.Top:=StrToIntDef(Top,0);
1779
DefBounds.Top:=ScreenR.Top+StrToIntDef(Top,0);
1263
1781
if Right='' then
1264
1782
aRight:=DefBounds.Left+AForm.Width
1265
else if Right[length(Right)]='%' then
1266
aRight:=Screen.Width*StrToIntDef(copy(Right,1,length(Right)-1),0) div 100
1268
aRight:=StrToIntDef(Right,0);
1270
aRight:=Screen.Width-aRight
1271
else if (Right<>'') and (Right[1]='+') then
1272
inc(aRight,DefBounds.Left);
1784
// 300 = fixed at 300,
1786
// 30% = fixed at 30% on screen
1787
// +30% = Left+30% of screen
1788
// -300 = fixed 300 from right border of screen
1789
// -30% = fixed 30% from right border of screen
1790
if Right[length(Right)]='%' then
1791
aRight:=ScreenW*StrToIntDef(copy(Right,1,length(Right)-1),0) div 100
1793
aRight:=StrToIntDef(Right,0);
1795
aRight:=ScreenR.Right+aRight // relative to right of screen
1796
else if (Right<>'') and (Right[1]='+') then
1797
inc(aRight,DefBounds.Left) // relative to Left
1799
inc(aRight,ScreenR.Left); // relative to left of screen
1273
1801
DefBounds.Right:=aRight;
1275
1803
if Bottom='' then
1276
1804
aBottom:=DefBounds.Top+AForm.Height
1277
else if Bottom[length(Bottom)]='%' then
1278
aBottom:=Screen.Height*StrToIntDef(copy(Bottom,1,length(Bottom)-1),0) div 100
1280
aBottom:=StrToIntDef(Bottom,0);
1282
aBottom:=Screen.Height-aBottom
1283
else if (Bottom<>'') and (Bottom[1]='+') then
1284
inc(aBottom,DefBounds.Top);
1806
// 300 = fixed at 300,
1808
// 30% = fixed at 30% on screen
1809
// +30% = Top+30% of screen
1810
// -300 = fixed 300 from bottom border of screen
1811
// -30% = fixed 30% from bottom border of screen
1812
if Bottom[length(Bottom)]='%' then
1813
aBottom:=ScreenH*StrToIntDef(copy(Bottom,1,length(Bottom)-1),0) div 100
1815
aBottom:=StrToIntDef(Bottom,0);
1817
aBottom:=ScreenR.Bottom+aBottom // relative to bottom of screen
1818
else if (Bottom<>'') and (Bottom[1]='+') then
1819
inc(aBottom,DefBounds.Top) // relative to Top
1821
inc(aBottom,ScreenR.Top); // relative to top of screen
1285
1823
DefBounds.Bottom:=aBottom;
1826
function TIDEWindowCreator.CreateSimpleLayout: TSimpleWindowLayout;
1828
Result:=IDEWindowCreators.SimpleLayoutStorage.ItemByFormID(FormName);
1829
if not Assigned(Result) then
1831
Result := IDEWindowCreators.SimpleLayoutStorage.CreateWindowLayout(FormName);
1832
InitSimpleLayout(Result);
1836
procedure TIDEWindowCreator.InitSimpleLayout(ALayout: TSimpleWindowLayout);
1838
if FDividerTemplate <> nil then
1839
ALayout.Dividers.Assign(FDividerTemplate);
1288
1842
constructor TIDEWindowCreator.Create(aFormName: string);
1290
1844
FFormName:=aFormName;
1845
FDividerTemplate := nil;
1293
1848
constructor TIDEWindowCreator.Create(aFormName: string;