Commit c038b061 authored by ondrej's avatar ondrej
Browse files

IDE: Remove IDE Options -> Environment -> Windows -> Window Positons. Issue #29742

git-svn-id: trunk@56907 -
parent 089d2c74
......@@ -110,27 +110,9 @@ type
and similar things for an IDE window or dialog, like the source editor,
the object inspector, the main bar or the message view.
}
TIDEWindowPlacement = (
iwpUseWindowManagerSetting, // leave window position, where window manager
// creates the window
iwpDefault, // set window to the default position
iwpRestoreWindowGeometry, // save window geometry at end and restore it
// at start
iwpCustomPosition, // set window to custom position
iwpRestoreWindowSize // save window size at end and restore it
// at start
);
TIDEWindowPlacements = set of TIDEWindowPlacement;
TIDEWindowState = (iwsNormal, iwsMaximized, iwsMinimized, iwsHidden);
TIDEWindowStates = set of TIDEWindowState;
TSimpleWindowLayoutDividerPosPlacement = (
iwpdDefault, // set column/row/splitter to the default size
iwpdCustomSize, // set column/row/splitter to the custom size
iwpdRestore, // save column/row/splitter size on exit, and restore
iwpdUseWindowSetting
);
TSimpleWindowLayoutDividerPosSizeGetter =
function(AForm: TCustomForm; AColId: Integer; var ASize: Integer): Boolean;
......@@ -145,7 +127,6 @@ type
FDisplayName: PString;
FId: Integer;
FIdString: String;
FPlacement: TSimpleWindowLayoutDividerPosPlacement;
FSize: integer;
function GetDisplayName: String;
protected
......@@ -161,7 +142,6 @@ type
property IdString: String read FIdString;
property Id: Integer read FId;
property DisplayName: String read GetDisplayName;
property Placement: TSimpleWindowLayoutDividerPosPlacement read FPlacement write FPlacement;
property Size: integer read FSize write FSize;
property DefaultSize: integer read FDefaultSize write FDefaultSize;
end;
......@@ -203,7 +183,6 @@ type
FApplied: boolean;
FFormCaption: string;
FVisible: boolean;
FWindowPlacement: TIDEWindowPlacement;
FLeft: integer;
FTop: integer;
FWidth: integer;
......@@ -215,7 +194,6 @@ type
FWindowState: TIDEWindowState;
FForm: TCustomForm;
FFormID: string;
FDefaultWindowPlacement: TIDEWindowPlacement;
FDividers: TSimpleWindowLayoutDividerPosList;
procedure SetForm(const AForm: TCustomForm);
function GetFormCaption: string;
......@@ -228,9 +206,9 @@ type
procedure Clear;
procedure GetCurrentPosition;
function Apply(const aForce: Boolean = False): Boolean;
procedure ApplyDivider(AForce: Boolean = False);
procedure ApplyDivider;
procedure Assign(Layout: TSimpleWindowLayout); reintroduce;
procedure ReadCurrentDividers(AForce: Boolean = False);
procedure ReadCurrentDividers;
procedure ReadCurrentCoordinates;
procedure ReadCurrentState;
procedure LoadFromConfig(Config: TConfigStorage; const Path: string; FileVersion: integer);
......@@ -244,9 +222,6 @@ type
property FormID: string read FFormID write FFormID;
function FormBaseID(out SubIndex: Integer): String; // split FormID into name+number
property FormCaption: string read GetFormCaption;
property WindowPlacement: TIDEWindowPlacement read fWindowPlacement write FWindowPlacement;
property DefaultWindowPlacement: TIDEWindowPlacement
read FDefaultWindowPlacement write FDefaultWindowPlacement;
property Left: integer read FLeft write FLeft;
property Top: integer read FTop write FTop;
property Width: integer read FWidth write FWidth;
......@@ -303,18 +278,10 @@ type
end;
const
IDEWindowPlacementNames: array[TIDEWindowPlacement] of string = (
'UseWindowManagerSetting',
'Default',
'RestoreWindowGeometry',
'CustomPosition',
'RestoreWindowSize'
);
IDEWindowStateNames: array[TIDEWindowState] of string = (
'Normal', 'Maximized', 'Minimized', 'Hidden'
);
function StrToIDEWindowPlacement(const s: string): TIDEWindowPlacement;
function StrToIDEWindowState(const s: string): TIDEWindowState;
type
......@@ -525,13 +492,6 @@ begin
AEditorDlg.PopupMode:=pmNone;
end;
function StrToIDEWindowPlacement(const s: string): TIDEWindowPlacement;
begin
for Result:=Low(TIDEWindowPlacement) to High(TIDEWindowPlacement) do
if UTF8CompareText(s,IDEWindowPlacementNames[Result])=0 then exit;
Result:=iwpDefault;
end;
function StrToIDEWindowState(const s: string): TIDEWindowState;
begin
for Result:=Low(TIDEWindowState) to High(TIDEWindowState) do
......@@ -883,44 +843,30 @@ begin
FDisplayName := ADividerPos.FDisplayName;
FId := ADividerPos.FId;
FIdString := ADividerPos.FIdString;
FPlacement := ADividerPos.FPlacement;
FSize := ADividerPos.FSize;
end;
procedure TSimpleWindowLayoutDividerPos.LoadFromConfig(Config: TConfigStorage;
const Path: string);
var
s: String;
begin
Clear;
FIdString := Config.GetValue(Path+'ID', '');
FSize := Config.GetValue(Path+'Size', -1);
s := Config.GetValue(Path+'Placement', 'iwpdUseWindowSetting');
try
ReadStr(s, FPlacement);
except
FPlacement := iwpdUseWindowSetting;
end;
end;
function TSimpleWindowLayoutDividerPos.SaveToConfig(Config: TConfigStorage;
const Path: string): Boolean;
var
s: String;
begin
Result := (FSize <> -1) or (FPlacement <> iwpdUseWindowSetting);
Result := (FSize <> -1);
if not Result then
exit;
WriteStr(s, FPlacement);
Config.SetDeleteValue(Path+'ID', FIdString, '');
Config.SetDeleteValue(Path+'Size', FSize, -1);
Config.SetDeleteValue(Path+'Placement', s, 'iwpdUseWindowSetting');
end;
procedure TSimpleWindowLayoutDividerPos.Clear;
begin
FSize := FDefaultSize;
FPlacement := iwpdUseWindowSetting;
end;
{ TIDEDialogLayout }
......@@ -1186,7 +1132,6 @@ begin
inherited Create(nil);
FDividers := TSimpleWindowLayoutDividerPosList.Create;
FormID := AFormID;
fDefaultWindowPlacement := iwpRestoreWindowGeometry;
Clear;
Creator := IDEWindowCreators.FindWithName(AFormID);
if Creator <> nil then
......@@ -1204,7 +1149,6 @@ procedure TSimpleWindowLayout.LoadFromConfig(Config: TConfigStorage;
const Path: string; FileVersion: integer);
var
P: string;
DefaultValue: TIDEWindowPlacement;
begin
// set all values to default
Clear;
......@@ -1214,13 +1158,6 @@ begin
if P='' then exit;
P:=Path+P+'/';
FFormCaption := Config.GetValue(P+'Caption/Value', fFormID);
// placement
if FileVersion=1 then
DefaultValue:=iwpRestoreWindowSize
else
DefaultValue:=iwpRestoreWindowGeometry;
fWindowPlacement:=StrToIDEWindowPlacement(Config.GetValue(
P+'WindowPlacement/Value',IDEWindowPlacementNames[DefaultValue]));
// custom position
Left := Config.GetValue(P+'CustomPosition/Left', Left);
Top := Config.GetValue(P+'CustomPosition/Top', Top);
......@@ -1257,9 +1194,7 @@ begin
P:=Path+P+'/';
Config.SetDeleteValue(P+'Caption/Value',FFormCaption,'');
// placement
Config.SetDeleteValue(P+'WindowPlacement/Value',
IDEWindowPlacementNames[fWindowPlacement],
IDEWindowPlacementNames[iwpRestoreWindowGeometry]);
Config.DeleteValue(P+'WindowPlacement/Value');
// custom position
Config.SetDeleteValue(P+'CustomPosition/Left', Left, 0);
Config.SetDeleteValue(P+'CustomPosition/Top', Top, 0);
......@@ -1410,7 +1345,6 @@ begin
//debugln(['TSimpleWindowLayout.Clear ',FormID]);
fApplied := False;
fVisible := False;
fWindowPlacement:=fDefaultWindowPlacement;
fLeft:=0;
fTop:=0;
fWidth:=0;
......@@ -1466,20 +1400,17 @@ begin
Assert(FFormID = Layout.FFormID);
//IMPORTANT: do not assign FForm and FFormID!
FVisible:=Layout.FVisible;
FWindowPlacement:=Layout.FWindowPlacement;
FLeft:=Layout.FLeft;
FTop:=Layout.FTop;
FWidth:=Layout.FWidth;
FHeight:=Layout.FHeight;
FWindowState:=Layout.FWindowState;
FDefaultWindowPlacement:=Layout.FDefaultWindowPlacement;
FDividers.Assign(Layout.FDividers);
end;
procedure TSimpleWindowLayout.ReadCurrentDividers(AForce: Boolean = False);
procedure TSimpleWindowLayout.ReadCurrentDividers;
var
i, j: Integer;
f: Boolean;
Creator: TIDEWindowCreator;
xForm: TCustomForm;
begin
......@@ -1489,30 +1420,19 @@ begin
if xForm = nil then exit;
for i := 0 to FDividers.Count - 1 do begin
if FDividers[i].FId < 0 then continue;
f := AForce;
case FDividers[i].Placement of
iwpdRestore:
f := true;
iwpdUseWindowSetting:
f := WindowPlacement in [iwpRestoreWindowGeometry, iwpRestoreWindowSize];
end;
if f then begin
j:=-1;
if Creator.OnGetDividerSize(xForm, FDividers[i].Id, j) then
FDividers[i].Size := j
else
FDividers[i].Size := -1; // Default / Not Changed / Unavailable
end;
j:=-1;
if Creator.OnGetDividerSize(xForm, FDividers[i].Id, j) then
FDividers[i].Size := j
else
FDividers[i].Size := -1; // Default / Not Changed / Unavailable
end;
end;
procedure TSimpleWindowLayout.GetCurrentPosition;
begin
//debugln('TSimpleWindowLayout.GetCurrentPosition ',DbgSName(Self),' ',FormID,' ',IDEWindowPlacementNames[WindowPlacement]);
case WindowPlacement of
iwpRestoreWindowGeometry, iwpRestoreWindowSize:
ReadCurrentCoordinates;
end;
ReadCurrentCoordinates;
ReadCurrentDividers;
ReadCurrentState;
//debugln('TSimpleWindowLayout.GetCurrentPosition ',DbgSName(Self),' ',FormID,' Width=',dbgs(Width));
......@@ -1532,44 +1452,29 @@ begin
' ',Left,',',Top,',',Width,',',Height]);
{$ENDIF}
case WindowPlacement of
iwpCustomPosition,iwpRestoreWindowGeometry:
begin
//DebugLn(['TMainIDE.OnApplyWindowLayout ',IDEWindowStateNames[WindowState]]);
case WindowState of
iwsMinimized: xForm.WindowState:=wsMinimized;
iwsMaximized: xForm.WindowState:=wsMaximized;
end;
Result := ValidateAndSetCoordinates(aForce); // Adjust bounds to screen area and apply them.
if WindowState in [iwsMinimized, iwsMaximized] then
Result := True;
end;
iwpUseWindowManagerSetting:
Result := True;
//DebugLn(['TMainIDE.OnApplyWindowLayout ',IDEWindowStateNames[WindowState]]);
case WindowState of
iwsMinimized: xForm.WindowState:=wsMinimized;
iwsMaximized: xForm.WindowState:=wsMaximized;
end;
Result := ValidateAndSetCoordinates(aForce); // Adjust bounds to screen area and apply them.
if WindowState in [iwsMinimized, iwsMaximized] then
Result := True;
ApplyDivider(aForce);
ApplyDivider;
end;
procedure TSimpleWindowLayout.ApplyDivider(AForce: Boolean = False);
procedure TSimpleWindowLayout.ApplyDivider;
var
i: Integer;
f: Boolean;
Creator: TIDEWindowCreator;
begin
Creator:=IDEWindowCreators.FindWithName(FormID);
if (Creator <> nil) and (Creator.OnSetDividerSize <> nil) then begin
for i := 0 to FDividers.Count - 1 do begin
if (FDividers[i].FId < 0) or (FDividers[i].Size < 0) then continue;
f := AForce;
case FDividers[i].Placement of
iwpdRestore, iwpdCustomSize:
f := true;
iwpdUseWindowSetting:
f := WindowPlacement in [iwpRestoreWindowGeometry, iwpRestoreWindowSize];
end;
if f then
Creator.OnSetDividerSize(Form, FDividers[i].Id, FDividers[i].Size);
Creator.OnSetDividerSize(Form, FDividers[i].Id, FDividers[i].Size);
end;
end;
end;
......
......@@ -14,9 +14,9 @@ object WindowOptionsFrame: TWindowOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 22
Top = 17
Width = 200
Height = 19
Top = 15
Width = 181
Caption = 'SingleTaskBarButtonCheckBox'
ParentShowHint = False
ShowHint = True
......@@ -28,375 +28,22 @@ object WindowOptionsFrame: TWindowOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 22
Top = 39
Width = 166
Height = 19
Top = 34
Width = 151
Caption = 'HideIDEOnRunCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
object WindowPositionsPanel: TPanel
AnchorSideTop.Control = lblWindowPosition
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 383
Top = 197
Width = 570
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 3
Caption = 'WindowPositionsPanel'
ClientHeight = 383
ClientWidth = 570
TabOrder = 8
object LeftLabel: TLabel
AnchorSideTop.Control = LeftEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = LeftEdit
Left = 297
Height = 17
Top = 234
Width = 53
Anchors = [akTop, akRight]
BorderSpacing.Right = 3
Caption = 'LeftLabel'
ParentColor = False
end
object TopLabel: TLabel
AnchorSideTop.Control = TopEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = TopEdit
Left = 297
Height = 17
Top = 263
Width = 53
Anchors = [akTop, akRight]
BorderSpacing.Right = 3
Caption = 'TopLabel'
ParentColor = False
end
object WidthLabel: TLabel
AnchorSideTop.Control = WidthEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = WidthEdit
Left = 420
Height = 17
Top = 234
Width = 65
Anchors = [akTop, akRight]
BorderSpacing.Right = 3
Caption = 'WidthLabel'
ParentColor = False
end
object HeightLabel: TLabel
AnchorSideTop.Control = HeightEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = HeightEdit
Left = 415
Height = 17
Top = 263
Width = 70
Anchors = [akTop, akRight]
BorderSpacing.Right = 3
Caption = 'HeightLabel'
ParentColor = False
end
object WindowPositionsListBox: TListBox
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = WindowPositionsPanel
AnchorSideRight.Control = WindowPositionsPanel
AnchorSideRight.Side = asrBottom
Left = 7
Height = 120
Top = 3
Width = 556
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 2
BorderSpacing.Right = 6
ItemHeight = 0
OnSelectionChange = WindowPositionsListBoxSelectionChange
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object LetWindowManagerDecideRadioButton: TRadioButton
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = RestoreWindowGeometryRadioButton
AnchorSideTop.Side = asrBottom
Left = 7
Height = 23
Top = 257
Width = 248
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'LetWindowManagerDecideRadioButton'
OnClick = WindowGeometryRadioButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
object FixedDefaultRadioButton: TRadioButton
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = LetWindowManagerDecideRadioButton
AnchorSideTop.Side = asrBottom
Left = 7
Height = 23
Top = 283
Width = 167
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'FixedDefaultRadioButton'
OnClick = WindowGeometryRadioButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
object RestoreWindowGeometryRadioButton: TRadioButton
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = SplitterPanel
AnchorSideTop.Side = asrBottom
Left = 7
Height = 23
Top = 231
Width = 241
BorderSpacing.Left = 6
BorderSpacing.Top = 4
Caption = 'RestoreWindowGeometryRadioButton'
Checked = True
OnClick = CustomGeometryRadioButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 2
TabStop = True
end
object CustomGeometryRadioButton: TRadioButton
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = FixedDefaultRadioButton
AnchorSideTop.Side = asrBottom
Left = 7
Height = 23
Top = 309
Width = 196
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'CustomGeometryRadioButton'
OnClick = CustomGeometryRadioButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 5
end
object LeftEdit: TSpinEdit
AnchorSideTop.Control = RestoreWindowGeometryRadioButton
AnchorSideRight.Control = WidthEdit
Left = 353
Height = 23
Top = 231
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 60
MaxValue = 4096
MinValue = -5000
ParentShowHint = False
ShowHint = True
TabOrder = 6
end
object TopEdit: TSpinEdit
AnchorSideTop.Control = LeftEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = HeightEdit
Left = 353
Height = 23
Top = 260
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 60
MaxValue = 4096
MinValue = -5000
ParentShowHint = False
ShowHint = True
TabOrder = 7
end
object WidthEdit: TSpinEdit
AnchorSideTop.Control = LeftEdit
AnchorSideRight.Control = WindowPositionsPanel
AnchorSideRight.Side = asrBottom
Left = 488
Height = 23
Top = 231
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
MaxValue = 4096
ParentShowHint = False
ShowHint = True
TabOrder = 8
end
object HeightEdit: TSpinEdit
AnchorSideTop.Control = WidthEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = WindowPositionsPanel
AnchorSideRight.Side = asrBottom
Left = 488
Height = 23
Top = 260
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 6
MaxValue = 4096
ParentShowHint = False
ShowHint = True
TabOrder = 9
end
object GetWindowPositionButton: TButton
AnchorSideTop.Control = ApplyButton
AnchorSideRight.Control = ApplyButton
Left = 314
Height = 29
Top = 295
Width = 161
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 6
Caption = 'GetWindowPositionButton'
Constraints.MinWidth = 75
OnClick = GetWindowPositionButtonClick
TabOrder = 10
end
object ApplyButton: TButton
AnchorSideTop.Control = HeightEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = WindowPositionsPanel
AnchorSideRight.Side = asrBottom
Left = 481
Height = 29
Top = 295
Width = 82
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 12
BorderSpacing.Right = 6
Caption = 'ApplyButton'
Constraints.MinWidth = 75
OnClick = ApplyButtonClick
TabOrder = 11
end
object SplitterPanel: TPanel
AnchorSideLeft.Control = WindowPositionsPanel
AnchorSideTop.Control = lblWindowCaption
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = WindowPositionsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = WindowPositionsPanel
AnchorSideBottom.Side = asrBottom
Left = 5
Height = 78
Top = 149
Width = 564
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 4
BorderSpacing.Top = 3
BevelOuter = bvNone
BorderWidth = 1
BorderStyle = bsSingle
Caption = ' '
ClientHeight = 74
ClientWidth = 560
TabOrder = 1
Visible = False
object SplitterList: TListBox
AnchorSideLeft.Control = SplitterPanel
AnchorSideTop.Control = SplitterPanel
AnchorSideBottom.Control = SplitterPanel
AnchorSideBottom.Side = asrBottom
Left = 1
Height = 72
Top = 1
Width = 275
Anchors = [akTop, akLeft, akBottom]
ItemHeight = 0
OnSelectionChange = SplitterListSelectionChange
ParentShowHint = False