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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user