From 76c18f5955b96688273ee6a1bd9ddee858d618a8 Mon Sep 17 00:00:00 2001 From: kmcclusk Date: Mon, 1 Jun 1998 17:04:16 +0000 Subject: [PATCH] GetBounds returns the client area not the window area Resize new returns the client area not the window area Removed the commented out RelayEvent method in nsWindow.cpp Add a nsDispatchListener for nsIAppShell. git-svn-id: svn://10.0.0.236/trunk@2812 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/public/nsGUIEvent.h | 12 ++++++ mozilla/widget/public/nsIAppShell.h | 19 +++++++++ mozilla/widget/src/windows/nsAppShell.cpp | 8 ++++ mozilla/widget/src/windows/nsAppShell.h | 3 ++ mozilla/widget/src/windows/nsWindow.cpp | 47 ++++++++--------------- 5 files changed, 59 insertions(+), 30 deletions(-) diff --git a/mozilla/widget/public/nsGUIEvent.h b/mozilla/widget/public/nsGUIEvent.h index 7dccd96c97b..85e03f33d2d 100644 --- a/mozilla/widget/public/nsGUIEvent.h +++ b/mozilla/widget/public/nsGUIEvent.h @@ -126,6 +126,16 @@ struct nsTooltipEvent : public nsGUIEvent { PRUint32 tipIndex; }; +/** + * MenuItem event + */ + +struct nsMenuEvent : public nsGUIEvent { + /// Index of the selected menu item + PRUint32 menuItem; +}; + + /** * GUI MESSAGES */ @@ -160,6 +170,8 @@ struct nsTooltipEvent : public nsGUIEvent { #define NS_SHOW_TOOLTIP (NS_WINDOW_START + 36) // Tooltip should be hidden #define NS_HIDE_TOOLTIP (NS_WINDOW_START + 37) +// Menu item selected +#define NS_MENU_SELECTED (NS_WINDOW_START + 38) #define NS_MOUSE_MESSAGE_START 300 diff --git a/mozilla/widget/public/nsIAppShell.h b/mozilla/widget/public/nsIAppShell.h index 810aa9c124f..387818931b5 100644 --- a/mozilla/widget/public/nsIAppShell.h +++ b/mozilla/widget/public/nsIAppShell.h @@ -24,6 +24,19 @@ #define NS_IAPPSHELL_IID \ { 0xa0757c31, 0xeeac, 0x11d1, { 0x9e, 0xc1, 0x0, 0xaa, 0x0, 0x2f, 0xb8, 0x21 } }; + +/** + * During the nsIAppShell Run method notify this listener + * after each message dispatch. + * @see SetDispatchListener member function of nsIAppShell + */ + +class nsDispatchListener { + public: + virtual void AfterDispatch() = 0; +}; + + /** * Application shell used for Test applications */ @@ -46,6 +59,12 @@ public: virtual nsresult Run() = 0; + /** + * After event dispatch execute app specific code + */ + + virtual void SetDispatchListener(nsDispatchListener* aDispatchListener) = 0; + /** * Exit the handle event loop */ diff --git a/mozilla/widget/src/windows/nsAppShell.cpp b/mozilla/widget/src/windows/nsAppShell.cpp index 14639e15332..519de2f8618 100644 --- a/mozilla/widget/src/windows/nsAppShell.cpp +++ b/mozilla/widget/src/windows/nsAppShell.cpp @@ -29,6 +29,11 @@ void nsAppShell::Create() { } +void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener) +{ + mDispatchListener = aDispatchListener; +} + //------------------------------------------------------------------------- // // Enter a message handler loop @@ -42,6 +47,8 @@ nsresult nsAppShell::Run() while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); + if (mDispatchListener) + mDispatchListener->AfterDispatch(); } return msg.wParam; } @@ -64,6 +71,7 @@ void nsAppShell::Exit() //------------------------------------------------------------------------- nsAppShell::nsAppShell(nsISupports *aOuter) : nsObject(aOuter) { + mDispatchListener = 0; } //------------------------------------------------------------------------- diff --git a/mozilla/widget/src/windows/nsAppShell.h b/mozilla/widget/src/windows/nsAppShell.h index 54895b3a06d..049341a34d6 100644 --- a/mozilla/widget/src/windows/nsAppShell.h +++ b/mozilla/widget/src/windows/nsAppShell.h @@ -42,7 +42,10 @@ class nsAppShell : public nsIAppShell, public nsObject virtual void Create(); virtual nsresult Run(); + virtual void SetDispatchListener(nsDispatchListener* aDispatchListener); virtual void Exit(); + private: + nsDispatchListener* mDispatchListener; }; #endif // nsAppShell_h__ diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index fd119f44c2f..eaa62330210 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -858,7 +858,7 @@ void nsWindow::GetBounds(nsRect &aRect) { if (mWnd) { RECT r; - VERIFY(::GetWindowRect(mWnd, &r)); + VERIFY(::GetClientRect(mWnd, &r)); // assign size aRect.width = r.right - r.left; @@ -1163,29 +1163,6 @@ void nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) ::UpdateWindow(mWnd); } -//------------------------------------------------------------------------- -// -// Relay mouse events to the tooltip control -// -//------------------------------------------------------------------------- - -void nsWindow::RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam) -{ - printf("relaying event\n"); -#if 0 - MSG msg; - msg.hwnd = mWnd; - msg.message = aMsg; - msg.wParam = wParam; - msg.lParam = lParam; - msg.time = ::GetMessageTime(); - DWORD pos = ::GetMessagePos(); - POINT pt; - msg.pt.x = LOWORD(pos); - msg.pt.y = HIWORD(pos); - ::SendMessage(mTooltip, TTM_RELAYEVENT, 0, (LPARAM)(LPMSG) &msg); -#endif -} //------------------------------------------------------------------------- // @@ -1267,6 +1244,17 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT switch (msg) { + case WM_COMMAND: { + WORD wNotifyCode = HIWORD(wParam); // notification code + if (wNotifyCode == 0) { // Menu selection + nsMenuEvent event; + event.menuItem = LOWORD(wParam); + InitEvent(event, NS_MENU_SELECTED); + result = DispatchEvent(&event); + } + } + break; + case WM_NOTIFY: // TAB change @@ -1370,12 +1358,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; case WM_MBUTTONDOWN: - //RelayMouseEvent(msg,wParam, lParam); result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_DOWN); break; case WM_MBUTTONUP: - //RelayMouseEvent(msg,wParam, lParam); result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_UP); break; @@ -1384,12 +1370,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; case WM_RBUTTONDOWN: - //RelayMouseEvent(msg,wParam, lParam); result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_DOWN); break; case WM_RBUTTONUP: - //RelayMouseEvent(msg,wParam, lParam); result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_UP); break; @@ -1442,7 +1426,11 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT case WM_WINDOWPOSCHANGED: { WINDOWPOS *wp = (LPWINDOWPOS)lParam; - nsRect rect(wp->x, wp->y, wp->cx, wp->cy); + RECT r; + ::GetClientRect(mWnd, &r); + nsRect rect(wp->x, wp->y, PRInt32(r.right - r.left), PRInt32(r.bottom - r.top)); + ///nsRect rect(wp->x, wp->y, wp->cx, wp->cy); + //nsRect rect(wp->x, wp->y, r->width, r->height); result = OnResize(rect); break; } @@ -1605,7 +1593,6 @@ void nsWindow::OnDestroy() NS_RELEASE(mToolkit); mToolkit = NULL; } - DispatchStandardEvent(NS_DESTROY); }