mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
IDE: allow to center mainidebar on non windows
git-svn-id: trunk@58087 -
This commit is contained in:
parent
e02905c546
commit
3112fddc73
@ -125,6 +125,7 @@ type
|
|||||||
procedure SetToolStatus(const AValue: TIDEToolStatus); override;
|
procedure SetToolStatus(const AValue: TIDEToolStatus); override;
|
||||||
|
|
||||||
procedure DoMnuWindowClicked(Sender: TObject);
|
procedure DoMnuWindowClicked(Sender: TObject);
|
||||||
|
procedure ShowMainIDEBar(Center: boolean);
|
||||||
procedure mnuOpenProjectClicked(Sender: TObject); virtual; abstract;
|
procedure mnuOpenProjectClicked(Sender: TObject); virtual; abstract;
|
||||||
procedure mnuOpenRecentClicked(Sender: TObject);
|
procedure mnuOpenRecentClicked(Sender: TObject);
|
||||||
procedure mnuWindowItemClick(Sender: TObject); virtual;
|
procedure mnuWindowItemClick(Sender: TObject); virtual;
|
||||||
@ -651,8 +652,14 @@ end;
|
|||||||
{ TMainIDEBase }
|
{ TMainIDEBase }
|
||||||
|
|
||||||
procedure TMainIDEBase.mnuWindowItemClick(Sender: TObject);
|
procedure TMainIDEBase.mnuWindowItemClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
Form: TCustomForm;
|
||||||
begin
|
begin
|
||||||
IDEWindowCreators.ShowForm(TCustomForm(TIDEMenuCommand(Sender).UserTag), true);
|
Form:=TCustomForm(TIDEMenuCommand(Sender).UserTag);
|
||||||
|
if Form=MainIDEBar then
|
||||||
|
ShowMainIDEBar(false)
|
||||||
|
else
|
||||||
|
IDEWindowCreators.ShowForm(Form, true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDEBase.mnuCenterWindowItemClick(Sender: TObject);
|
procedure TMainIDEBase.mnuCenterWindowItemClick(Sender: TObject);
|
||||||
@ -661,6 +668,12 @@ var
|
|||||||
Form: TCustomForm;
|
Form: TCustomForm;
|
||||||
r, NewBounds: TRect;
|
r, NewBounds: TRect;
|
||||||
begin
|
begin
|
||||||
|
Form:=TCustomForm(TIDEMenuCommand(Sender).UserTag);
|
||||||
|
if Form=MainIDEBar then begin
|
||||||
|
ShowMainIDEBar(true);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
i:=Screen.CustomFormCount-1;
|
i:=Screen.CustomFormCount-1;
|
||||||
while (i>=0) do begin
|
while (i>=0) do begin
|
||||||
Form:=Screen.CustomForms[i];
|
Form:=Screen.CustomForms[i];
|
||||||
@ -900,6 +913,50 @@ begin
|
|||||||
UpdateWindowMenu;
|
UpdateWindowMenu;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDEBase.ShowMainIDEBar(Center: boolean);
|
||||||
|
var
|
||||||
|
NewBounds, WorkArea: TRect;
|
||||||
|
aMonitor: TMonitor;
|
||||||
|
x, y: LongInt;
|
||||||
|
begin
|
||||||
|
debugln(['TMainIDEBase.ShowMainIDEBar Center=',Center]);
|
||||||
|
NewBounds:=MainIDEBar.BoundsRect;
|
||||||
|
aMonitor:=MainIDEBar.Monitor;
|
||||||
|
if aMonitor=nil then
|
||||||
|
aMonitor:=Screen.PrimaryMonitor;
|
||||||
|
WorkArea:=aMonitor.WorkareaRect;
|
||||||
|
|
||||||
|
// for experimental or buggy widgetsets: sanity check workarea
|
||||||
|
WorkArea.Right:=Max(WorkArea.Right,WorkArea.Left+400);
|
||||||
|
WorkArea.Bottom:=Max(WorkArea.Bottom,WorkArea.Top+400);
|
||||||
|
|
||||||
|
if NewBounds.Left<WorkArea.Left then begin
|
||||||
|
// move right
|
||||||
|
OffsetRect(NewBounds,WorkArea.Left-NewBounds.Left,0);
|
||||||
|
NewBounds.Right:=Min(NewBounds.Right,WorkArea.Right);
|
||||||
|
end else if NewBounds.Right>WorkArea.Right then begin
|
||||||
|
// move left
|
||||||
|
NewBounds.Left:=Max(NewBounds.Left-(NewBounds.Right-WorkArea.Right),WorkArea.Left);
|
||||||
|
end;
|
||||||
|
if NewBounds.Top<WorkArea.Top then begin
|
||||||
|
// move down
|
||||||
|
OffsetRect(NewBounds,0,WorkArea.Top-NewBounds.Top);
|
||||||
|
NewBounds.Bottom:=Min(NewBounds.Bottom,WorkArea.Bottom);
|
||||||
|
end else if NewBounds.Bottom>WorkArea.Bottom then begin
|
||||||
|
// move up
|
||||||
|
NewBounds.Top:=Max(NewBounds.Top-(NewBounds.Bottom-WorkArea.Bottom),WorkArea.Top);
|
||||||
|
end;
|
||||||
|
if Center then begin
|
||||||
|
x:=(WorkArea.Right-WorkArea.Left-(NewBounds.Right-NewBounds.Left)) div 2;
|
||||||
|
y:=(WorkArea.Bottom-WorkArea.Top-(NewBounds.Bottom-NewBounds.Top)) div 2;
|
||||||
|
OffsetRect(NewBounds,x-NewBounds.Left,y-NewBounds.Top);
|
||||||
|
end;
|
||||||
|
|
||||||
|
MainIDEBar.BoundsRect:=NewBounds;
|
||||||
|
MainIDEBar.WindowState:=wsNormal;
|
||||||
|
MainIDEBar.BringToFront;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainIDEBase.SetDisplayState(AValue: TDisplayState);
|
procedure TMainIDEBase.SetDisplayState(AValue: TDisplayState);
|
||||||
begin
|
begin
|
||||||
if FDisplayState=AValue then Exit;
|
if FDisplayState=AValue then Exit;
|
||||||
@ -1744,7 +1801,7 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDEBase.UpdateWindowMenu;
|
procedure TMainIDEBase.UpdateWindowMenu;
|
||||||
|
|
||||||
function GetMenuItem(Index: Integer; ASection: TIDEMenuSection): TIDEMenuItem; inline;
|
function GetMenuItem(Index: Integer; ASection: TIDEMenuSection): TIDEMenuItem;
|
||||||
begin
|
begin
|
||||||
if ASection.Count > Index then
|
if ASection.Count > Index then
|
||||||
Result := ASection.Items[Index]
|
Result := ASection.Items[Index]
|
||||||
@ -1755,7 +1812,7 @@ procedure TMainIDEBase.UpdateWindowMenu;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ClearMenuItem(ARemainCount: Integer; ASection: TIDEMenuSection); inline;
|
procedure ClearMenuItem(ARemainCount: Integer; ASection: TIDEMenuSection);
|
||||||
begin
|
begin
|
||||||
with ASection do
|
with ASection do
|
||||||
while Count > ARemainCount do
|
while Count > ARemainCount do
|
||||||
@ -1780,6 +1837,10 @@ begin
|
|||||||
WindowsList.Add(SourceEditorManager.SourceWindows[i]);
|
WindowsList.Add(SourceEditorManager.SourceWindows[i]);
|
||||||
if (ObjectInspector1<>nil) and (ObjectInspector1.Visible) then
|
if (ObjectInspector1<>nil) and (ObjectInspector1.Visible) then
|
||||||
WindowsList.Add(ObjectInspector1);
|
WindowsList.Add(ObjectInspector1);
|
||||||
|
{$IFNDEF MSWindows}
|
||||||
|
if MainIDEBar.Parent=nil then
|
||||||
|
WindowsList.Add(MainIDEBar);
|
||||||
|
{$ENDIF}
|
||||||
// add special IDE windows
|
// add special IDE windows
|
||||||
for i:=0 to Screen.FormCount-1 do begin
|
for i:=0 to Screen.FormCount-1 do begin
|
||||||
AForm:=Screen.Forms[i];
|
AForm:=Screen.Forms[i];
|
||||||
@ -1811,7 +1872,7 @@ begin
|
|||||||
and IsFormDesign(TWinControl(WindowsList[i])) then
|
and IsFormDesign(TWinControl(WindowsList[i])) then
|
||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
||||||
else
|
else
|
||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
||||||
CurMenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
|
CurMenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
|
||||||
CurMenuItem.UserTag := {%H-}PtrUInt(WindowsList[i]);
|
CurMenuItem.UserTag := {%H-}PtrUInt(WindowsList[i]);
|
||||||
CurMenuItem.OnClick:=@mnuWindowItemClick;
|
CurMenuItem.OnClick:=@mnuWindowItemClick;
|
||||||
@ -1822,6 +1883,7 @@ begin
|
|||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
|
||||||
else
|
else
|
||||||
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
|
||||||
|
CurMenuItem.UserTag := {%H-}PtrUInt(WindowsList[i]);
|
||||||
CurMenuItem.OnClick:=@mnuCenterWindowItemClick;
|
CurMenuItem.OnClick:=@mnuCenterWindowItemClick;
|
||||||
end;
|
end;
|
||||||
//create source page menuitems
|
//create source page menuitems
|
||||||
|
Loading…
Reference in New Issue
Block a user