diff --git a/widget/src/windows/nsButton.cpp b/widget/src/windows/nsButton.cpp index eafc6ff3b88..60adee814c7 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 7617ae406e1..60840e98fe2 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 70362ead5f2..3ae4fa3e9e3 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 ef4065be290..4393eeff428 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 3deedf065ba..b17107f3731 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 23fc16c4ac0..a5472983ce0 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 7bf4448b881..2fa7da27756 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 e4704ddddd3..82e22274df3 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 c582e162dea..f5ffdffbab1 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 f682c5e4b3f..6fc883cef3b 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 70fcd37b529..a0dba25cd69 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 82adbf9b847..894030c3bca 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 8e660c18c69..6dc5449bb78 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 fd8c6199c82..f8c9aa1b69d 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 2efc498ddd3..0e850f4e0e3 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 77ad2c665a6..22227b10fb9 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 fad5421ca98..7d6042994e0 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 cbf73c6b206..6bbc0558103 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 40636b156c1..b66d1289237 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 3060cd252d9..d57e45f1225 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 045dc58016f..132c1edc0d8 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 a0f775d3515..42edf0da401 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(); \