client<->screen coords conversion fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-10-02 22:22:41 +00:00
parent 2ec3892d77
commit 985520bc47

View File

@@ -178,7 +178,10 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc)
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
{ {
wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd); wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
wxPoint where = win->ScreenToClient(wxPoint(e->where_x, e->where_y)); wxPoint where;
MGL_wmCoordGlobalToLocal(win->GetHandle(),
e->where_x, e->where_y, &where.x, &where.y);
if ( !win->IsEnabled() ) return FALSE; if ( !win->IsEnabled() ) return FALSE;
@@ -225,10 +228,10 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
if ( g_windowUnderMouse ) if ( g_windowUnderMouse )
{ {
wxMouseEvent event2(event); wxMouseEvent event2(event);
wxPoint where2 = g_windowUnderMouse->ScreenToClient( MGL_wmCoordGlobalToLocal(g_windowUnderMouse->GetHandle(),
wxPoint(e->where_x, e->where_y)); e->where_x, e->where_y,
event2.m_x = where2.x; &event2.m_x, &event2.m_y);
event2.m_y = where2.y;
event2.SetEventObject(g_windowUnderMouse); event2.SetEventObject(g_windowUnderMouse);
event2.SetEventType(wxEVT_LEAVE_WINDOW); event2.SetEventType(wxEVT_LEAVE_WINDOW);
g_windowUnderMouse->GetEventHandler()->ProcessEvent(event2); g_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
@@ -393,7 +396,9 @@ static ibool wxWindowKeybHandler(window_t *wnd, event_t *e)
if ( !win->IsEnabled() ) return FALSE; if ( !win->IsEnabled() ) return FALSE;
wxPoint where = win->ScreenToClient(wxPoint(e->where_x, e->where_y)); wxPoint where;
MGL_wmCoordGlobalToLocal(win->GetHandle(),
e->where_x, e->where_y, &where.x, &where.y);
wxKeyEvent event; wxKeyEvent event;
event.SetEventObject(win); event.SetEventObject(win);
@@ -793,27 +798,21 @@ void wxWindowMGL::DoGetPosition(int *x, int *y) const
void wxWindowMGL::DoScreenToClient(int *x, int *y) const void wxWindowMGL::DoScreenToClient(int *x, int *y) const
{ {
int ax, ay; int ax, ay;
wxPoint co = GetClientAreaOrigin(); MGL_wmCoordGlobalToLocal(m_wnd, 0, 0, &ax, &ay);
MGL_wmCoordGlobalToLocal(m_wnd, m_wnd->x, m_wnd->y, &ax, &ay);
ax -= co.x;
ay -= co.y;
if (x) if (x)
*x = ax; (*x) += ax;
if (y) if (y)
*y = ay; (*y) += ay;
} }
void wxWindowMGL::DoClientToScreen(int *x, int *y) const void wxWindowMGL::DoClientToScreen(int *x, int *y) const
{ {
int ax, ay; int ax, ay;
wxPoint co = GetClientAreaOrigin(); MGL_wmCoordLocalToGlobal(m_wnd, 0, 0, &ax, &ay);
MGL_wmCoordGlobalToLocal(m_wnd, m_wnd->x+co.x, m_wnd->y+co.y, &ax, &ay);
if (x) if (x)
*x = ax; (*x) += ax;
if (y) if (y)
*y = ay; (*y) += ay;
} }
// Get size *available for subwindows* i.e. excluding menu bar etc. // Get size *available for subwindows* i.e. excluding menu bar etc.