IDE: fix setting IDE window dimensions when a default configuration is created.

git-svn-id: trunk@33590 -
This commit is contained in:
juha 2011-11-17 16:52:20 +00:00
parent 7a39358a8c
commit 19238922cc
2 changed files with 42 additions and 39 deletions

View File

@ -298,8 +298,10 @@ procedure TWindowOptionsFrame.ApplyButtonClick(Sender: TObject);
begin begin
SaveLayout; SaveLayout;
if (Layout<>nil) and (Layout.Form<>nil) and (Layout.Form.Parent=nil) then begin if (Layout<>nil) and (Layout.Form<>nil) and (Layout.Form.Parent=nil) then begin
if (Layout.WindowPlacement in [iwpCustomPosition,iwpRestoreWindowGeometry]) then if (Layout.WindowPlacement in [iwpCustomPosition,iwpRestoreWindowGeometry]) then begin
Layout.SetNewBounds; // Adjust bounds to screen area and apply them. Layout.ValidateAndSetCoordinates; // Adjust bounds to screen area and apply them.
Layout.Applied := True;
end;
Layout.ApplyDivider(True); Layout.ApplyDivider(True);
end; end;
end; end;

View File

@ -233,7 +233,7 @@ type
procedure SaveToConfig(Config: TConfigStorage; const Path: string); procedure SaveToConfig(Config: TConfigStorage; const Path: string);
function CustomCoordinatesAreValid: boolean; function CustomCoordinatesAreValid: boolean;
procedure CloseForm; procedure CloseForm;
function SetNewBounds: Boolean; function ValidateAndSetCoordinates: Boolean;
public public
property FormID: string read GetFormID write FFormID; property FormID: string read GetFormID write FFormID;
function FormBaseID(out SubIndex: Integer): String; // split FormID into name+number function FormBaseID(out SubIndex: Integer): String; // split FormID into name+number
@ -1133,49 +1133,50 @@ begin
Form:=nil; Form:=nil;
end; end;
function TSimpleWindowLayout.SetNewBounds: Boolean; function TSimpleWindowLayout.ValidateAndSetCoordinates: Boolean;
var var
i: Integer; i: Integer;
NewBounds: TRect; NewBounds: TRect;
begin begin
// No need to check coordinate validity because they will be adjusted. Result := False;
// explicit position if CustomCoordinatesAreValid then begin
NewBounds := Bounds(Left, Top, Width, Height); // explicit position
// set minimum size NewBounds := Bounds(Left, Top, Width, Height);
if NewBounds.Right - NewBounds.Left < 60 then // set minimum size
NewBounds.Right := NewBounds.Left + 60; if NewBounds.Right - NewBounds.Left < 60 then
if NewBounds.Bottom - NewBounds.Top < 60 then NewBounds.Right := NewBounds.Left + 60;
NewBounds.Bottom := NewBounds.Top + 60; if NewBounds.Bottom - NewBounds.Top < 60 then
NewBounds.Bottom := NewBounds.Top + 60;
// Move to visible area : // Move to visible area :
// window is out at left side of screen // window is out at left side of screen
if NewBounds.Right < Screen.DesktopLeft + 60 then if NewBounds.Right < Screen.DesktopLeft + 60 then
OffsetRect(NewBounds, Screen.DesktopLeft + 60 - NewBounds.Right, 0); OffsetRect(NewBounds, Screen.DesktopLeft + 60 - NewBounds.Right, 0);
// window is out above the screen // window is out above the screen
if NewBounds.Bottom < Screen.DesktopTop+60 then if NewBounds.Bottom < Screen.DesktopTop+60 then
OffsetRect(NewBounds, 0, Screen.DesktopTop + 60 - NewBounds.Bottom); OffsetRect(NewBounds, 0, Screen.DesktopTop + 60 - NewBounds.Bottom);
// window is out at right side of screen, i = right edge of screen - 60 // window is out at right side of screen, i = right edge of screen - 60
i := Screen.DesktopWidth + Screen.DesktopLeft - 60; i := Screen.DesktopWidth + Screen.DesktopLeft - 60;
if NewBounds.Left > i then begin if NewBounds.Left > i then begin
NewBounds.Left := i; NewBounds.Left := i;
NewBounds.Right := NewBounds.Right + i - NewBounds.Left; NewBounds.Right := NewBounds.Right + i - NewBounds.Left;
end;
// window is out below the screen, i = bottom edge of screen - 60
i := Screen.DesktopHeight + Screen.DesktopTop - 60;
if NewBounds.Top > i then begin
NewBounds.Top := i;
NewBounds.Bottom := NewBounds.Bottom + i - NewBounds.Top;
end;
// set bounds (do not use SetRestoredBounds - that flickers with the current LCL implementation)
FForm.SetBounds(NewBounds.Left, NewBounds.Top,
NewBounds.Right - NewBounds.Left,
NewBounds.Bottom - NewBounds.Top);
Result := True;
end; end;
// window is out below the screen, i = bottom edge of screen - 60
i := Screen.DesktopHeight + Screen.DesktopTop - 60;
if NewBounds.Top > i then begin
NewBounds.Top := i;
NewBounds.Bottom := NewBounds.Bottom + i - NewBounds.Top;
end;
// set bounds (do not use SetRestoredBounds - that flickers with the current LCL implementation)
FForm.SetBounds(NewBounds.Left, NewBounds.Top,
NewBounds.Right - NewBounds.Left,
NewBounds.Bottom - NewBounds.Top);
Applied := True;
Result := True;
end; end;
function TSimpleWindowLayout.FormBaseID(out SubIndex: Integer): String; function TSimpleWindowLayout.FormBaseID(out SubIndex: Integer): String;
@ -1338,7 +1339,7 @@ begin
iwsMinimized: FForm.WindowState:=wsMinimized; iwsMinimized: FForm.WindowState:=wsMinimized;
iwsMaximized: FForm.WindowState:=wsMaximized; iwsMaximized: FForm.WindowState:=wsMaximized;
end; end;
Result := SetNewBounds; // Adjust bounds to screen area and apply them. Result := ValidateAndSetCoordinates; // Adjust bounds to screen area and apply them.
if WindowState in [iwsMinimized, iwsMaximized] then if WindowState in [iwsMinimized, iwsMaximized] then
Result := True; Result := True;
end; end;