From f42e7fcc661315bc52b1a701ee5a37d30cf47ce1 Mon Sep 17 00:00:00 2001 From: ondrej Date: Sat, 2 Jan 2016 09:33:40 +0000 Subject: [PATCH] lcl: forms: add TPosition.poWorkAreaCenter git-svn-id: trunk@51112 - --- docs/xml/lcl/forms.xml | 10 +--------- lcl/forms.pp | 3 ++- lcl/include/customform.inc | 14 +++++++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/xml/lcl/forms.xml b/docs/xml/lcl/forms.xml index 35270068c3..e347fc0b3d 100644 --- a/docs/xml/lcl/forms.xml +++ b/docs/xml/lcl/forms.xml @@ -162,15 +162,7 @@ Represents the Position and Size of a Form on Screen. - -

poDesigned - The Form appears exactly as it is positioned and sized in the Form Designer

-

poDefault - The window manager decides how the form is to appear, in a default position and size

-

poDefaultPosOnly - keeps the Designed size, but position determined by windowmanager

-

poDefaultSizeOnly - keeps the Designed position, but size determined by windowmanager

-

poScreenCenter - Centers the form on screen

-

poDeskTopCenter - Centers the form on desktop

-

poMainFormCenter - Centers the Form on the Main Form

-

poOwnerFormCenter - Centers the Form on Owner form

+

poDesigned - The Form appears exactly as it is positioned and sized in the Form Designer

poDefault - The window manager decides how the form is to appear, in a default position and size

poDefaultPosOnly - keeps the Designed size, but position determined by windowmanager

poDefaultSizeOnly - keeps the Designed position, but size determined by windowmanager

poScreenCenter - Centers the form on screen

poDeskTopCenter - Centers the form on desktop

poMainFormCenter - Centers the Form on the Main Form

poOwnerFormCenter - Centers the Form on Owner form

poWorkAreaCenter - Centers the Form on working area

diff --git a/lcl/forms.pp b/lcl/forms.pp index 3b1f99e410..100508844e 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -57,7 +57,8 @@ type poScreenCenter, // center form on screen (depends on DefaultMonitor) poDesktopCenter, // center form on desktop (total of all screens) poMainFormCenter, // center form on main form (depends on DefaultMonitor) - poOwnerFormCenter // center form on owner form (depends on DefaultMonitor) + poOwnerFormCenter, // center form on owner form (depends on DefaultMonitor) + poWorkAreaCenter // center form on working area (depends on DefaultMonitor) ); TWindowState = (wsNormal, wsMinimized, wsMaximized, wsFullScreen); diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index 44459ed9e3..784de8b2d2 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -1272,9 +1272,12 @@ var if Y < ABounds.Top then Y := ABounds.Top; end - else + else // poWorkAreaCenter, poScreenCenter begin - ABounds := Target.BoundsRect; + if Position = poWorkAreaCenter then + ABounds := Target.WorkareaRect + else + ABounds := Target.BoundsRect; X := (ABounds.Left + ABounds.Right - RealWidth) div 2; Y := (ABounds.Top + ABounds.Bottom - RealHeight) div 2; end; @@ -1317,6 +1320,11 @@ begin X := (Screen.Width - RealWidth) div 2; Y := (Screen.Height - RealHeight) div 2; end; + poWorkAreaCenter: + begin + X := Screen.WorkAreaLeft + (Screen.WorkAreaWidth - RealWidth) div 2; + Y := Screen.WorkAreaTop + (Screen.WorkAreaHeight - RealHeight) div 2; + end; poMainFormCenter, poOwnerFormCenter: begin @@ -1341,7 +1349,7 @@ begin // get current widgetset position if (p in [poDefault, poDefaultPosOnly]) and HandleAllocated then GetWindowRelativePosition(Handle,X,Y); - if (Position in [poScreenCenter, poMainFormCenter, poOwnerFormCenter]) then + if (Position in [poScreenCenter, poMainFormCenter, poOwnerFormCenter, poWorkAreaCenter]) then MoveToDefaultMonitor(X, Y); SetBounds(X, Y, Width, Height); end;