diff --git a/widget/src/windows/nsButton.cpp b/widget/src/windows/nsButton.cpp index eafc6ff3b88e..60adee814c72 100644 --- a/widget/src/windows/nsButton.cpp +++ b/widget/src/windows/nsButton.cpp @@ -139,3 +139,15 @@ DWORD nsButton::WindowExStyle() return 0; } + +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsButton::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + diff --git a/widget/src/windows/nsButton.h b/widget/src/windows/nsButton.h index 7617ae406e1b..60840e98fe2e 100644 --- a/widget/src/windows/nsButton.h +++ b/widget/src/windows/nsButton.h @@ -51,6 +51,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); protected: virtual LPCTSTR WindowClass(); diff --git a/widget/src/windows/nsCheckButton.cpp b/widget/src/windows/nsCheckButton.cpp index 70362ead5f2e..3ae4fa3e9e37 100644 --- a/widget/src/windows/nsCheckButton.cpp +++ b/widget/src/windows/nsCheckButton.cpp @@ -173,3 +173,15 @@ DWORD nsCheckButton::WindowExStyle() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsCheckButton::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + + diff --git a/widget/src/windows/nsCheckButton.h b/widget/src/windows/nsCheckButton.h index ef4065be2905..4393eeff4286 100644 --- a/widget/src/windows/nsCheckButton.h +++ b/widget/src/windows/nsCheckButton.h @@ -52,6 +52,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); virtual void SetState(PRBool aState); virtual PRBool GetState(); diff --git a/widget/src/windows/nsComboBox.cpp b/widget/src/windows/nsComboBox.cpp index 3deedf065bab..b17107f37314 100644 --- a/widget/src/windows/nsComboBox.cpp +++ b/widget/src/windows/nsComboBox.cpp @@ -260,3 +260,15 @@ PRInt32 nsComboBox::GetHeight(PRInt32 aProposedHeight) } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsComboBox::GetBounds(nsRect &aRect) +{ + nsWindow::GetNonClientBounds(aRect); +} + + diff --git a/widget/src/windows/nsComboBox.h b/widget/src/windows/nsComboBox.h index 23fc16c4ac0d..a5472983ce0a 100644 --- a/widget/src/windows/nsComboBox.h +++ b/widget/src/windows/nsComboBox.h @@ -44,6 +44,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); // nsIWidget interface BASE_IWIDGET_IMPL diff --git a/widget/src/windows/nsListBox.cpp b/widget/src/windows/nsListBox.cpp index 7bf4448b8814..2fa7da27756d 100644 --- a/widget/src/windows/nsListBox.cpp +++ b/widget/src/windows/nsListBox.cpp @@ -308,3 +308,15 @@ PRBool nsListBox::AutoErase() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsListBox::GetBounds(nsRect &aRect) +{ + nsWindow::GetNonClientBounds(aRect); +} + + diff --git a/widget/src/windows/nsListBox.h b/widget/src/windows/nsListBox.h index e4704ddddd30..82e22274df3c 100644 --- a/widget/src/windows/nsListBox.h +++ b/widget/src/windows/nsListBox.h @@ -43,6 +43,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); // nsIWidget interface BASE_IWIDGET_IMPL diff --git a/widget/src/windows/nsRadioButton.cpp b/widget/src/windows/nsRadioButton.cpp index c582e162dea2..f5ffdffbab1d 100644 --- a/widget/src/windows/nsRadioButton.cpp +++ b/widget/src/windows/nsRadioButton.cpp @@ -167,3 +167,15 @@ DWORD nsRadioButton::WindowExStyle() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsRadioButton::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + + diff --git a/widget/src/windows/nsRadioButton.h b/widget/src/windows/nsRadioButton.h index f682c5e4b3f8..6fc883cef3b0 100644 --- a/widget/src/windows/nsRadioButton.h +++ b/widget/src/windows/nsRadioButton.h @@ -54,6 +54,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); virtual void SetState(PRBool aState); virtual PRBool GetState(); diff --git a/widget/src/windows/nsScrollbar.cpp b/widget/src/windows/nsScrollbar.cpp index 70fcd37b529f..a0dba25cd695 100644 --- a/widget/src/windows/nsScrollbar.cpp +++ b/widget/src/windows/nsScrollbar.cpp @@ -450,3 +450,15 @@ DWORD nsScrollbar::WindowExStyle() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsScrollbar::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + + diff --git a/widget/src/windows/nsScrollbar.h b/widget/src/windows/nsScrollbar.h index 82adbf9b8475..894030c3bca1 100644 --- a/widget/src/windows/nsScrollbar.h +++ b/widget/src/windows/nsScrollbar.h @@ -61,6 +61,7 @@ public: virtual PRBool OnPaint(); virtual PRBool OnScroll(UINT scrollCode, int cPos); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); protected: diff --git a/widget/src/windows/nsTabWidget.cpp b/widget/src/windows/nsTabWidget.cpp index 8e660c18c697..6dc5449bb781 100644 --- a/widget/src/windows/nsTabWidget.cpp +++ b/widget/src/windows/nsTabWidget.cpp @@ -141,3 +141,15 @@ DWORD nsTabWidget::WindowExStyle() return 0; } + +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsTabWidget::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + diff --git a/widget/src/windows/nsTabWidget.h b/widget/src/windows/nsTabWidget.h index fd8c6199c82e..f8c9aa1b69d8 100644 --- a/widget/src/windows/nsTabWidget.h +++ b/widget/src/windows/nsTabWidget.h @@ -50,6 +50,7 @@ public: virtual PRUint32 GetSelectedTab(); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); protected: virtual LPCTSTR WindowClass(); diff --git a/widget/src/windows/nsTextAreaWidget.cpp b/widget/src/windows/nsTextAreaWidget.cpp index 2efc498ddd37..0e850f4e0e3f 100644 --- a/widget/src/windows/nsTextAreaWidget.cpp +++ b/widget/src/windows/nsTextAreaWidget.cpp @@ -176,4 +176,16 @@ DWORD nsTextAreaWidget::WindowExStyle() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsTextAreaWidget::GetBounds(nsRect &aRect) +{ + nsWindow::GetNonClientBounds(aRect); +} + + diff --git a/widget/src/windows/nsTextAreaWidget.h b/widget/src/windows/nsTextAreaWidget.h index 77ad2c665a6f..22227b10fb94 100644 --- a/widget/src/windows/nsTextAreaWidget.h +++ b/widget/src/windows/nsTextAreaWidget.h @@ -45,6 +45,7 @@ public: virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); // nsIWidget interface BASE_IWIDGET_IMPL diff --git a/widget/src/windows/nsTextWidget.cpp b/widget/src/windows/nsTextWidget.cpp index fad5421ca98d..7d6042994e0a 100644 --- a/widget/src/windows/nsTextWidget.cpp +++ b/widget/src/windows/nsTextWidget.cpp @@ -116,3 +116,15 @@ DWORD nsTextWidget::WindowExStyle() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsTextWidget::GetBounds(nsRect &aRect) +{ + nsWindow::GetNonClientBounds(aRect); +} + + diff --git a/widget/src/windows/nsTextWidget.h b/widget/src/windows/nsTextWidget.h index cbf73c6b2068..6bbc0558103c 100644 --- a/widget/src/windows/nsTextWidget.h +++ b/widget/src/windows/nsTextWidget.h @@ -44,6 +44,7 @@ public: virtual PRBool OnPaint(); virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnResize(nsRect &aWindowRect); + virtual void GetBounds(nsRect &aRect); // nsIWidget interface BASE_IWIDGET_IMPL diff --git a/widget/src/windows/nsTooltipWidget.cpp b/widget/src/windows/nsTooltipWidget.cpp index 40636b156c13..b66d1289237e 100644 --- a/widget/src/windows/nsTooltipWidget.cpp +++ b/widget/src/windows/nsTooltipWidget.cpp @@ -141,4 +141,16 @@ PRBool nsTooltipWidget::AutoErase() } +//------------------------------------------------------------------------- +// +// get position/dimensions +// +//------------------------------------------------------------------------- + +void nsTooltipWidget::GetBounds(nsRect &aRect) +{ + nsWindow::GetBounds(aRect); +} + + diff --git a/widget/src/windows/nsTooltipWidget.h b/widget/src/windows/nsTooltipWidget.h index 3060cd252d92..d57e45f1225e 100644 --- a/widget/src/windows/nsTooltipWidget.h +++ b/widget/src/windows/nsTooltipWidget.h @@ -48,6 +48,7 @@ public: virtual PRBool OnPaint(); virtual PRBool OnResize(nsRect &aWindowRect); virtual PRBool AutoErase(); + virtual void GetBounds(nsRect &aRect); protected: virtual LPCTSTR WindowClass(); diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 045dc58016f3..132c1edc0d8e 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -743,17 +743,19 @@ void nsWindow::Move(PRUint32 aX, PRUint32 aY) if (nsnull != par) { deferrer = ((nsWindow *)par)->mDeferredPositioner; - NS_RELEASE(par); } if (NULL != deferrer) { - VERIFY(::DeferWindowPos(deferrer, mWnd, NULL, aX, aY, 0, 0, + VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer, + mWnd, NULL, aX, aY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE)); } else { VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE)); } + + NS_IF_RELEASE(par); } } @@ -770,7 +772,6 @@ void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) if (nsnull != par) { deferrer = ((nsWindow *)par)->mDeferredPositioner; - NS_RELEASE(par); } UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE; @@ -779,13 +780,15 @@ void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) } if (NULL != deferrer) { - VERIFY(::DeferWindowPos(deferrer, mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), - flags)); + VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer, + mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags)); } else { VERIFY(::SetWindowPos(mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags)); } + + NS_IF_RELEASE(par); } } @@ -807,7 +810,6 @@ void nsWindow::Resize(PRUint32 aX, if (nsnull != par) { deferrer = ((nsWindow *)par)->mDeferredPositioner; - NS_RELEASE(par); } UINT flags = SWP_NOZORDER | SWP_NOACTIVATE; @@ -816,13 +818,16 @@ void nsWindow::Resize(PRUint32 aX, } if (NULL != deferrer) { - VERIFY(::DeferWindowPos(deferrer, mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), + VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer, + mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), flags)); } else { VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), flags)); } + + NS_IF_RELEASE(par); } } @@ -881,7 +886,37 @@ void nsWindow::GetBounds(nsRect &aRect) // convert coordinates if parent exists HWND parent = ::GetParent(mWnd); if (parent) { - ::ScreenToClient(parent, (LPPOINT)&r); + RECT pr; + VERIFY(::GetClientRect(parent, &pr)); + VERIFY(::ClientToScreen(mWnd, (LPPOINT)&r)); + VERIFY(::ClientToScreen(parent, (LPPOINT)&pr)); + r.left -= pr.left; + r.top -= pr.top; + } + aRect.x = r.left; + aRect.y = r.top; + } +} + +//get the bounds, but don't take into account the client size + +void nsWindow::GetNonClientBounds(nsRect &aRect) +{ + if (mWnd) { + RECT r; + VERIFY(::GetWindowRect(mWnd, &r)); + + // assign size + aRect.width = r.right - r.left; + aRect.height = r.bottom - r.top; + + // convert coordinates if parent exists + HWND parent = ::GetParent(mWnd); + if (parent) { + RECT pr; + VERIFY(::GetWindowRect(parent, &pr)); + r.left -= pr.left; + r.top -= pr.top; } aRect.x = r.left; aRect.y = r.top; diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index a0f775d35159..42edf0da4013 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -159,6 +159,8 @@ protected: void AddTooltip(HWND hwndOwner, nsRect* aRect, int aId); void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam); + void GetNonClientBounds(nsRect &aRect); + protected: static nsWindow* gCurrentWindow; nsPoint mLastPoint; @@ -312,10 +314,6 @@ protected: { \ nsWindow::SetFocus(); \ } \ - void GetBounds(nsRect &aRect) \ - { \ - nsWindow::GetBounds(aRect); \ - } \ nscolor GetForegroundColor(void) \ { \ return nsWindow::GetForegroundColor(); \