added GetScreenBounds. part of bug 5998. r:pierre

This commit is contained in:
danm%netscape.com 2000-01-06 16:01:15 +00:00
Родитель 95dd580531
Коммит e5211eb69b
2 изменённых файлов: 40 добавлений и 32 удалений

Просмотреть файл

@ -53,7 +53,7 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
// Windows and Mac.
#define WINDOW_SIZE_TWEAKING
// these should come from the system, not be hard-coded. What if I'm running
// ¥¥¥ TODO: these should come from the system, not be hard-coded. What if I'm running
// an elaborate theme with wide window borders?
const short kWindowTitleBarHeight = 22;
const short kWindowMarginWidth = 6;
@ -574,6 +574,9 @@ NS_METHOD nsWindow::Restore(void)
// Move this window
//
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Move
//-------------------------------------------------------------------------
NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
{
@ -611,11 +614,22 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
else if (((PRInt32)aX) > screenRect.right)
aX = screenRect.right;
if (((PRInt32)aY) < screenRect.top)
aY = screenRect.top;
else if (((PRInt32)aY) > screenRect.bottom)
if (((PRInt32)aY) > screenRect.bottom-screenRect.top)
aY = screenRect.bottom;
if (mIsDialog)
{
aX += kDialogMarginWidth;
aY += kDialogTitleBarHeight;
}
else
{
aX += kWindowMarginWidth;
aY += kWindowTitleBarHeight;
}
aX += screenRect.left;
aY += screenRect.top;
// move the window if it has not been moved yet
// (ie. if this function isn't called in response to a DragWindow event)
#if TARGET_CARBON
@ -625,35 +639,8 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
macPoint = topLeft(mWindowPtr->portRect);
#endif
::LocalToGlobal(&macPoint);
if ((macPoint.h != aX) || (macPoint.v != aY))
{
// in that case, the window borders should be visible too
PRUint32 minX, minY;
if (mIsDialog)
{
minX = kDialogMarginWidth;
#if TARGET_CARBON
minY = kDialogTitleBarHeight + ::GetMBarHeight();
#else
minY = kDialogTitleBarHeight + ::LMGetMBarHeight();
#endif
}
else
{
minX = kWindowMarginWidth;
#if TARGET_CARBON
minY = kWindowTitleBarHeight + ::GetMBarHeight();
#else
minY = kWindowTitleBarHeight + ::LMGetMBarHeight();
#endif
}
if (aX < minX)
aX = minX;
if (aY < minY)
aY = minY;
if (macPoint.h != aX || macPoint.v != aY)
::MoveWindow(mWindowPtr, aX, aY, false);
}
// propagate the event in global coordinates
Inherited::Move(aX, aY);
@ -698,6 +685,26 @@ NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
return NS_OK;
}
NS_IMETHODIMP nsMacWindow::GetScreenBounds(nsRect &aRect) {
#if TARGET_CARBON
Rect screenRect;
::GetRegionBounds(::GetGrayRgn(), &screenRect);
#else
Rect screenRect = (**::GetGrayRgn()).rgnBBox;
#endif
nsRect localBounds;
GetBounds(localBounds);
WidgetToScreen(localBounds, aRect);
if (mIsDialog)
aRect.MoveBy(-kDialogMarginWidth-screenRect.left, -kDialogTitleBarHeight-screenRect.top);
else
aRect.MoveBy(-kWindowMarginWidth-screenRect.left, -kWindowTitleBarHeight-screenRect.top);
return NS_OK;
}
//-------------------------------------------------------------------------
//
//

Просмотреть файл

@ -78,6 +78,7 @@ public:
NS_IMETHOD Show(PRBool aState);
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD GetScreenBounds(nsRect &aRect);
virtual PRBool OnPaint(nsPaintEvent &event);
NS_IMETHOD SetTitle(const nsString& aTitle);