зеркало из https://github.com/mozilla/gecko-dev.git
added GetScreenBounds. part of bug 5998. r:pierre
This commit is contained in:
Родитель
16068a8e4e
Коммит
7e86489156
|
@ -53,7 +53,7 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||||
// Windows and Mac.
|
// Windows and Mac.
|
||||||
#define WINDOW_SIZE_TWEAKING
|
#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?
|
// an elaborate theme with wide window borders?
|
||||||
const short kWindowTitleBarHeight = 22;
|
const short kWindowTitleBarHeight = 22;
|
||||||
const short kWindowMarginWidth = 6;
|
const short kWindowMarginWidth = 6;
|
||||||
|
@ -574,6 +574,9 @@ NS_METHOD nsWindow::Restore(void)
|
||||||
// Move this window
|
// Move this window
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Move
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
|
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)
|
else if (((PRInt32)aX) > screenRect.right)
|
||||||
aX = screenRect.right;
|
aX = screenRect.right;
|
||||||
|
|
||||||
if (((PRInt32)aY) < screenRect.top)
|
if (((PRInt32)aY) > screenRect.bottom-screenRect.top)
|
||||||
aY = screenRect.top;
|
|
||||||
else if (((PRInt32)aY) > screenRect.bottom)
|
|
||||||
aY = screenRect.bottom;
|
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
|
// move the window if it has not been moved yet
|
||||||
// (ie. if this function isn't called in response to a DragWindow event)
|
// (ie. if this function isn't called in response to a DragWindow event)
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
|
@ -625,35 +639,8 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
|
||||||
macPoint = topLeft(mWindowPtr->portRect);
|
macPoint = topLeft(mWindowPtr->portRect);
|
||||||
#endif
|
#endif
|
||||||
::LocalToGlobal(&macPoint);
|
::LocalToGlobal(&macPoint);
|
||||||
if ((macPoint.h != aX) || (macPoint.v != aY))
|
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;
|
|
||||||
|
|
||||||
::MoveWindow(mWindowPtr, aX, aY, false);
|
::MoveWindow(mWindowPtr, aX, aY, false);
|
||||||
}
|
|
||||||
|
|
||||||
// propagate the event in global coordinates
|
// propagate the event in global coordinates
|
||||||
Inherited::Move(aX, aY);
|
Inherited::Move(aX, aY);
|
||||||
|
@ -698,6 +685,26 @@ NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
|
||||||
return NS_OK;
|
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 Show(PRBool aState);
|
||||||
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
||||||
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
||||||
|
NS_IMETHOD GetScreenBounds(nsRect &aRect);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||||
|
|
||||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче