Added GetNativeEvent and DispatchNativeEvent, these are neded for future modal dialog support

This commit is contained in:
rods%netscape.com 1999-02-10 16:20:29 +00:00
Родитель 17b0c21d87
Коммит 2074e5a217
7 изменённых файлов: 131 добавлений и 4 удалений

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

@ -42,6 +42,7 @@ class nsDispatchListener {
virtual void AfterDispatch() = 0;
};
class nsIWidget;
/**
* Application shell used for Test applications
@ -65,6 +66,18 @@ public:
virtual nsresult Run() = 0;
/**
* After event dispatch execute app specific code
*/
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent) = 0;
/**
* After event dispatch execute app specific code
*/
NS_IMETHOD DispatchNativeEvent(void * aEvent) = 0;
/**
* After event dispatch execute app specific code
*/

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

@ -173,3 +173,17 @@ void* nsAppShell::GetNativeData(PRUint32 aDataType)
}
return nsnull;
}
// XXX temporary code for Dialog investigation
nsresult nsAppShell::GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent)
{
aIsInWindow = PR_FALSE;
aIsMouseEvent = PR_FALSE;
return NS_ERROR_FAILURE;
}
nsresult nsAppShell::DispatchNativeEvent(void * aEvent)
{
return NS_ERROR_FAILURE;
}

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

@ -44,6 +44,10 @@ class nsAppShell : public nsIAppShell
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);
// XXX temporary for Dialog investigation
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent);
NS_IMETHOD DispatchNativeEvent(void * aEvent);
private:
nsDispatchListener *mDispatchListener;

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

@ -158,3 +158,16 @@ void* nsAppShell::GetNativeData(PRUint32 aDataType)
}
// XXX temporary code for Dialog investigation
nsresult nsAppShell::GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent)
{
aIsInWindow = PR_FALSE;
aIsMouseEvent = PR_FALSE;
return NS_ERROR_FAILURE;
}
nsresult nsAppShell::DispatchNativeEvent(void * aEvent)
{
return NS_ERROR_FAILURE;
}

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

@ -66,6 +66,9 @@ class nsAppShell : public nsIAppShell
virtual void* GetNativeData(PRUint32 aDataType);
// XXX temporary for Dialog investigation
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent);
NS_IMETHOD DispatchNativeEvent(void * aEvent);
};
#endif // nsAppShell_h__

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

@ -17,6 +17,7 @@
*/
#include "nsAppShell.h"
#include "nsIWidget.h"
#include <windows.h>
NS_IMPL_ISUPPORTS(nsAppShell, NS_IAPPSHELL_IID)
@ -64,15 +65,89 @@ nsresult nsAppShell::Run()
// Process messages
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
if (mDispatchListener)
mDispatchListener->AfterDispatch();
TranslateMessage(&msg);
DispatchMessage(&msg);
if (mDispatchListener)
mDispatchListener->AfterDispatch();
}
Release();
return msg.wParam;
}
nsresult nsAppShell::GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent)
{
aIsInWindow = PR_TRUE;
static MSG msg;
BOOL isOK = GetMessage(&msg, NULL, 0, 0);
if (msg.message != 275) {
printf("-> %d\n", msg.message);
}
if (isOK) {
TranslateMessage(&msg);
/*if (msg.message == 275) {
aIsInWindow = 0;
aIsMouseEvent = 1;
return NS_ERROR_FAILURE;
} else {
printf("******** %d\n", msg.message);
}*/
switch (msg.message) {
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
aIsMouseEvent = PR_TRUE;
break;
default:
aIsMouseEvent = PR_FALSE;
} // switch
aEvent = &msg;
if (nsnull != aWidget) {
// Get Native Window for dialog window
HWND win;
win = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW);
// Find top most window of event window
HWND eWin = msg.hwnd;
if (NULL != eWin) {
/*HWND parent = ::GetParent(eWin);
while (parent != NULL) {
eWin = parent;
parent = ::GetParent(eWin);
}
*/
if (win == eWin) {
printf("Short circut\n");
aIsInWindow = PR_TRUE;
} else {
RECT r;
VERIFY(::GetWindowRect(win, &r));
if (msg.pt.x >= r.left && msg.pt.x <= r.right && msg.pt.y >= r.top && msg.pt.y <= r.bottom) {
aIsInWindow = PR_TRUE;
} else {
aIsInWindow = PR_FALSE;
}
}
}
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult nsAppShell::DispatchNativeEvent(void * aEvent)
{
DispatchMessage((MSG *)aEvent);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Exit a message handler loop

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

@ -44,6 +44,11 @@ class nsAppShell : public nsIAppShell
NS_IMETHOD Exit();
virtual void* GetNativeData(PRUint32 aDataType);
// XXX temporary for Dialog investigation
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent);
NS_IMETHOD DispatchNativeEvent(void * aEvent);
private:
nsDispatchListener* mDispatchListener;
};