IDE: default bounds for windows: use a fixed max of 1200x900, use Screen.WorkArea

git-svn-id: trunk@31347 -
This commit is contained in:
mattias 2011-06-23 20:58:15 +00:00
parent 76aa5b9b12
commit 261318a675
3 changed files with 80 additions and 26 deletions

View File

@ -17369,23 +17369,28 @@ procedure TMainIDE.OnGetLayout(Sender: TObject; aFormName: string; out
aBounds: TRect; out DockSibling: string; out DockAlign: TAlign);
var
SrcEditWnd: TSourceNotebook;
ScreenR: TRect;
begin
DockSibling:='';
DockAlign:=alNone;
if (ObjectInspector1<>nil) and (aFormName=ObjectInspector1.Name) then begin
// place object inspector below main bar
aBounds:=Rect(0,Min(MainIDEBar.Top+MainIDEBar.Height+25,200),230,Screen.Height-150);
// do not dock object inspector, because this would hide the designers
ScreenR:=IDEWindowCreators.GetScreenrectForDefaults;
aBounds:=Rect(ScreenR.Left,
Min(MainIDEBar.Top+MainIDEBar.Height+25,200),230,
ScreenR.Bottom-ScreenR.Top-150);
// do not dock object inspector, because this would hide the floating designers
end
else if (aFormName=NonModalIDEWindowNames[nmiwMessagesViewName]) then begin
// place messages below source editor
ScreenR:=IDEWindowCreators.GetScreenrectForDefaults;
if SourceEditorManager.SourceWindowCount>0 then begin
SrcEditWnd:=SourceEditorManager.SourceWindows[0];
aBounds:=GetParentForm(SrcEditWnd).BoundsRect;
aBounds.Top:=aBounds.Bottom+25;
aBounds.Bottom:=aBounds.Top+100;
end else begin
aBounds:=Rect(250,Screen.Height-200,Screen.Width-250,100);
aBounds:=Rect(ScreenR.Left+250,ScreenR.Bottom-200,ScreenR.Right-250,100);
end;
if IDEDockMaster<>nil then begin
DockSibling:=NonModalIDEWindowNames[nmiwSourceNoteBookName];

View File

@ -8274,6 +8274,7 @@ procedure TSourceEditorManager.GetDefaultLayout(Sender: TObject;
var
i: LongInt;
p: Integer;
ScreenR: TRect;
begin
DockSibling:='';
DockAlign:=alNone;
@ -8283,12 +8284,15 @@ begin
{$IFDEF VerboseIDEDocking}
debugln(['TSourceEditorManager.GetDefaultLayout ',aFormName,' i=',i]);
{$ENDIF}
ScreenR:=IDEWindowCreators.GetScreenrectForDefaults;
if Application.MainForm<>nil then
p:=Min(200,Application.MainForm.Top+Application.MainForm.Height+25)
p:=Min(ScreenR.Left+200,Application.MainForm.Top+Application.MainForm.Height+25)
else
p:=120;
inc(p,30*i);
aBounds:=Rect(250+30*i,p,Min(1000,Screen.Width-300),Screen.Height-200);
aBounds:=Rect(ScreenR.Left+250+30*i,p,
Min(1000,ScreenR.Right-ScreenR.Left),
ScreenR.Bottom-ScreenR.Top-200);
if (i=0) and (IDEDockMaster<>nil) then begin
DockSibling:=NonModalIDEWindowNames[nmiwMainIDEName];
DockAlign:=alBottom;

View File

@ -23,7 +23,7 @@ unit IDEWindowIntf;
interface
uses
Math, Classes, SysUtils, LCLProc, LazConfigStorage, Forms, Controls;
Math, types, Classes, SysUtils, LCLProc, LazConfigStorage, Forms, Controls;
//----------------------------------------------------------------------------
// layout settings of modal forms (dialogs) in the IDE
@ -293,6 +293,7 @@ type
TIDEWindowCreatorList = class
private
fItems: TFPList; // list of TIDEWindowCreator
FScreenMaxSizeForDefaults: TPoint;
FSimpleLayoutStorage: TSimpleWindowLayoutList;
function GetItems(Index: integer): TIDEWindowCreator;
procedure ErrorIfFormExists(FormName: string);
@ -327,6 +328,10 @@ type
property SimpleLayoutStorage: TSimpleWindowLayoutList read FSimpleLayoutStorage;
procedure RestoreSimpleLayout;
property ScreenMaxSizeForDefaults: TPoint read FScreenMaxSizeForDefaults
write FScreenMaxSizeForDefaults; // on big screens: do not span the whole screen
function GetScreenrectForDefaults: TRect;
end;
var
@ -1256,44 +1261,71 @@ procedure TIDEWindowCreator.GetDefaultBounds(AForm: TCustomForm; out
var
aRight: LongInt;
aBottom: LongInt;
ScreenR: TRect;
ScreenW: Integer;
ScreenH: Integer;
begin
ScreenR:=IDEWindowCreators.GetScreenrectForDefaults;
ScreenW:=ScreenR.Right-ScreenR.Left;
ScreenH:=ScreenR.Bottom-ScreenR.Top;
// left
if Left='' then
DefBounds.Left:=AForm.Left
else if Left[length(Left)]='%' then
DefBounds.Left:=Screen.Width*StrToIntDef(copy(Left,1,length(Left)-1),0) div 100
DefBounds.Left:=ScreenR.Left+ScreenW*StrToIntDef(copy(Left,1,length(Left)-1),0) div 100
else
DefBounds.Left:=StrToIntDef(Left,0);
DefBounds.Left:=ScreenR.Left+StrToIntDef(Left,0);
// top
if Top='' then
DefBounds.Top:=AForm.Top
else if Top[length(Top)]='%' then
DefBounds.Top:=Screen.Height*StrToIntDef(copy(Top,1,length(Top)-1),0) div 100
DefBounds.Top:=ScreenR.Top+ScreenH*StrToIntDef(copy(Top,1,length(Top)-1),0) div 100
else
DefBounds.Top:=StrToIntDef(Top,0);
DefBounds.Top:=ScreenR.Top+StrToIntDef(Top,0);
// right
if Right='' then
aRight:=DefBounds.Left+AForm.Width
else if Right[length(Right)]='%' then
aRight:=Screen.Width*StrToIntDef(copy(Right,1,length(Right)-1),0) div 100
else
aRight:=StrToIntDef(Right,0);
if aRight<0 then
aRight:=Screen.Width-aRight
else if (Right<>'') and (Right[1]='+') then
inc(aRight,DefBounds.Left);
else begin
// 300 = fixed at 300,
// +300 = Left+300
// 30% = fixed at 30% on screen
// +30% = Left+30% of screen
// -300 = fixed 300 from right border of screen
// -30% = fixed 30% from right border of screen
if Right[length(Right)]='%' then
aRight:=ScreenW*StrToIntDef(copy(Right,1,length(Right)-1),0) div 100
else
aRight:=StrToIntDef(Right,0);
if aRight<0 then
aRight:=ScreenR.Right-aRight // relative to right of screen
else if (Right<>'') and (Right[1]='+') then
inc(aRight,DefBounds.Left) // relative to Left
else
inc(aRight,ScreenR.Left); // relative to left of screen
end;
DefBounds.Right:=aRight;
// bottom
if Bottom='' then
aBottom:=DefBounds.Top+AForm.Height
else if Bottom[length(Bottom)]='%' then
aBottom:=Screen.Height*StrToIntDef(copy(Bottom,1,length(Bottom)-1),0) div 100
else
aBottom:=StrToIntDef(Bottom,0);
if aBottom<0 then
aBottom:=Screen.Height-aBottom
else if (Bottom<>'') and (Bottom[1]='+') then
inc(aBottom,DefBounds.Top);
else begin
// 300 = fixed at 300,
// +300 = Top+300
// 30% = fixed at 30% on screen
// +30% = Top+30% of screen
// -300 = fixed 300 from bottom border of screen
// -30% = fixed 30% from bottom border of screen
if Bottom[length(Bottom)]='%' then
aBottom:=ScreenH*StrToIntDef(copy(Bottom,1,length(Bottom)-1),0) div 100
else
aBottom:=StrToIntDef(Bottom,0);
if aBottom<0 then
aBottom:=ScreenR.Bottom-aBottom // relative to bottom of screen
else if (Bottom<>'') and (Bottom[1]='+') then
inc(aBottom,DefBounds.Top) // relative to Top
else
inc(aBottom,ScreenR.Top); // relative to top of screen
end;
DefBounds.Bottom:=aBottom;
end;
@ -1344,6 +1376,7 @@ constructor TIDEWindowCreatorList.Create;
begin
fItems:=TFPList.Create;
FSimpleLayoutStorage:=TSimpleWindowLayoutList.Create;
FScreenMaxSizeForDefaults:=Point(1200,900);
end;
destructor TIDEWindowCreatorList.Destroy;
@ -1514,6 +1547,18 @@ begin
end;
end;
function TIDEWindowCreatorList.GetScreenrectForDefaults: TRect;
begin
Result:=Screen.WorkAreaRect;
if (Result.Right-Result.Left<10)
or (Result.Bottom-Result.Top<10) then begin
// screen not recognized
Result:=Rect(0,0,Max(Screen.Width,600),Max(Screen.Height,400));
end;
Result.Right:=Min(Result.Right,Result.Left+IDEWindowCreators.ScreenMaxSizeForDefaults.X);
Result.Bottom:=Min(Result.Bottom,Result.Top+IDEWindowCreators.ScreenMaxSizeForDefaults.Y);
end;
{ TIDEDockMaster }
function TIDEDockMaster.AddableInWindowMenu(AForm: TCustomForm): boolean;