more wxMGL fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,7 +27,7 @@ public:
|
|||||||
return wxPopupWindowBase::Create(parent) &&
|
return wxPopupWindowBase::Create(parent) &&
|
||||||
wxWindow::Create(parent, -1,
|
wxWindow::Create(parent, -1,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
flags & wxBORDER_MASK);
|
(flags & wxBORDER_MASK) | wxPOPUP_WINDOW);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -164,11 +164,11 @@ bool wxTopLevelWindowMGL::IsMaximized() const
|
|||||||
|
|
||||||
void wxTopLevelWindowMGL::Restore()
|
void wxTopLevelWindowMGL::Restore()
|
||||||
{
|
{
|
||||||
if ( m_isIconized )
|
if ( IsIconized() )
|
||||||
{
|
{
|
||||||
Iconize(FALSE);
|
Iconize(FALSE);
|
||||||
}
|
}
|
||||||
if ( m_isMaximized )
|
if ( IsMaximized() )
|
||||||
{
|
{
|
||||||
Maximize(FALSE);
|
Maximize(FALSE);
|
||||||
}
|
}
|
||||||
|
@@ -64,9 +64,14 @@ winmng_t *g_winMng = NULL;
|
|||||||
MGLDevCtx *g_displayDC = NULL;
|
MGLDevCtx *g_displayDC = NULL;
|
||||||
|
|
||||||
// the window that has keyboard focus:
|
// the window that has keyboard focus:
|
||||||
static wxWindowMGL *g_focusedWindow = NULL;
|
static wxWindowMGL *gs_focusedWindow = NULL;
|
||||||
// the window that is currently under mouse cursor:
|
// the window that is currently under mouse cursor:
|
||||||
static wxWindowMGL *g_windowUnderMouse = NULL;
|
static wxWindowMGL *gs_windowUnderMouse = NULL;
|
||||||
|
// the window that has mouse capture
|
||||||
|
static wxWindowMGL *gs_mouseCapture = NULL;
|
||||||
|
// the frame that is currently active (i.e. its child has focus). It is
|
||||||
|
// used to generate wxActivateEvents
|
||||||
|
static wxWindowMGL *gs_activeFrame = NULL;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -159,6 +164,15 @@ void wxDestroyMGL_WM()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns toplevel grandparent of given window:
|
||||||
|
static wxWindowMGL* wxGetTopLevelParent(wxWindowMGL *win)
|
||||||
|
{
|
||||||
|
wxWindowMGL *p = win;
|
||||||
|
while (p && !p->IsTopLevel())
|
||||||
|
p = p->GetParent();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// MGL_WM hooks:
|
// MGL_WM hooks:
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -223,25 +237,44 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_MOUSEMOVE:
|
case EVT_MOUSEMOVE:
|
||||||
if ( win != g_windowUnderMouse )
|
if ( !gs_mouseCapture )
|
||||||
{
|
{
|
||||||
if ( g_windowUnderMouse )
|
if ( win != gs_windowUnderMouse )
|
||||||
|
{
|
||||||
|
if ( gs_windowUnderMouse )
|
||||||
{
|
{
|
||||||
wxMouseEvent event2(event);
|
wxMouseEvent event2(event);
|
||||||
MGL_wmCoordGlobalToLocal(g_windowUnderMouse->GetHandle(),
|
MGL_wmCoordGlobalToLocal(gs_windowUnderMouse->GetHandle(),
|
||||||
e->where_x, e->where_y,
|
e->where_x, e->where_y,
|
||||||
&event2.m_x, &event2.m_y);
|
&event2.m_x, &event2.m_y);
|
||||||
|
|
||||||
event2.SetEventObject(g_windowUnderMouse);
|
event2.SetEventObject(gs_windowUnderMouse);
|
||||||
event2.SetEventType(wxEVT_LEAVE_WINDOW);
|
event2.SetEventType(wxEVT_LEAVE_WINDOW);
|
||||||
g_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
|
gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMouseEvent event3(event);
|
wxMouseEvent event3(event);
|
||||||
event3.SetEventType(wxEVT_ENTER_WINDOW);
|
event3.SetEventType(wxEVT_ENTER_WINDOW);
|
||||||
win->GetEventHandler()->ProcessEvent(event3);
|
win->GetEventHandler()->ProcessEvent(event3);
|
||||||
|
|
||||||
g_windowUnderMouse = win;
|
gs_windowUnderMouse = win;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // gs_mouseCapture
|
||||||
|
{
|
||||||
|
bool inside = (where.x >= 0 &&
|
||||||
|
where.y >= 0 &&
|
||||||
|
where.x < win->GetSize().x &&
|
||||||
|
where.y < win->GetSize().y);
|
||||||
|
if ( (inside && gs_windowUnderMouse != win) ||
|
||||||
|
(!inside && gs_windowUnderMouse == win) )
|
||||||
|
{
|
||||||
|
wxMouseEvent evt(inside ?
|
||||||
|
wxEVT_ENTER_WINDOW : wxEVT_LEAVE_WINDOW);
|
||||||
|
evt.SetEventObject(win);
|
||||||
|
win->GetEventHandler()->ProcessEvent(evt);
|
||||||
|
gs_windowUnderMouse = inside ? win : NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type = wxEVT_MOTION;
|
type = wxEVT_MOTION;
|
||||||
@@ -497,10 +530,14 @@ wxWindowMGL::~wxWindowMGL()
|
|||||||
{
|
{
|
||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
|
|
||||||
if ( g_focusedWindow == this )
|
if ( gs_mouseCapture == this )
|
||||||
|
ReleaseMouse();
|
||||||
|
if (gs_activeFrame == this)
|
||||||
|
gs_activeFrame = NULL;
|
||||||
|
if ( gs_focusedWindow == this )
|
||||||
KillFocus();
|
KillFocus();
|
||||||
if ( g_windowUnderMouse == this )
|
if ( gs_windowUnderMouse == this )
|
||||||
g_windowUnderMouse = NULL;
|
gs_windowUnderMouse = NULL;
|
||||||
|
|
||||||
// VS: destroy children first and _then_ detach *this from its parent.
|
// VS: destroy children first and _then_ detach *this from its parent.
|
||||||
// If we'd do it the other way around, children wouldn't be able
|
// If we'd do it the other way around, children wouldn't be able
|
||||||
@@ -538,6 +575,7 @@ bool wxWindowMGL::Create(wxWindow *parent,
|
|||||||
h = HeightDefault(size.y);
|
h = HeightDefault(size.y);
|
||||||
|
|
||||||
long mgl_style = 0;
|
long mgl_style = 0;
|
||||||
|
window_t *wnd_parent = parent ? parent->GetHandle() : NULL;
|
||||||
|
|
||||||
if ( !(style & wxNO_FULL_REPAINT_ON_RESIZE) )
|
if ( !(style & wxNO_FULL_REPAINT_ON_RESIZE) )
|
||||||
{
|
{
|
||||||
@@ -552,11 +590,10 @@ bool wxWindowMGL::Create(wxWindow *parent,
|
|||||||
mgl_style |= MGL_WM_ALWAYS_ON_TOP;
|
mgl_style |= MGL_WM_ALWAYS_ON_TOP;
|
||||||
// it is created hidden as other top level windows
|
// it is created hidden as other top level windows
|
||||||
m_isShown = FALSE;
|
m_isShown = FALSE;
|
||||||
|
wnd_parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_wnd = MGL_wmCreateWindow(g_winMng,
|
m_wnd = MGL_wmCreateWindow(g_winMng, wnd_parent, x, y, w, h);
|
||||||
parent ? parent->GetHandle() : NULL,
|
|
||||||
x, y, w, h);
|
|
||||||
|
|
||||||
MGL_wmSetWindowFlags(m_wnd, mgl_style);
|
MGL_wmSetWindowFlags(m_wnd, mgl_style);
|
||||||
MGL_wmSetWindowUserData(m_wnd, (void*) this);
|
MGL_wmSetWindowUserData(m_wnd, (void*) this);
|
||||||
@@ -576,10 +613,10 @@ bool wxWindowMGL::Create(wxWindow *parent,
|
|||||||
|
|
||||||
void wxWindowMGL::SetFocus()
|
void wxWindowMGL::SetFocus()
|
||||||
{
|
{
|
||||||
if (g_focusedWindow)
|
if ( gs_focusedWindow )
|
||||||
g_focusedWindow->KillFocus();
|
gs_focusedWindow->KillFocus();
|
||||||
|
|
||||||
g_focusedWindow = this;
|
gs_focusedWindow = this;
|
||||||
|
|
||||||
MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT, wxMGL_CAPTURE_KEYB);
|
MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT, wxMGL_CAPTURE_KEYB);
|
||||||
|
|
||||||
@@ -590,12 +627,20 @@ void wxWindowMGL::SetFocus()
|
|||||||
caret->OnSetFocus();
|
caret->OnSetFocus();
|
||||||
#endif // wxUSE_CARET
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
if ( IsTopLevel() )
|
wxWindowMGL *active = wxGetTopLevelParent(this);
|
||||||
|
if ( active != gs_activeFrame )
|
||||||
{
|
{
|
||||||
// FIXME_MGL - this is wrong, see wxGTK!
|
if ( gs_activeFrame )
|
||||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId());
|
{
|
||||||
event.SetEventObject(this);
|
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, gs_activeFrame->GetId());
|
||||||
GetEventHandler()->ProcessEvent(event);
|
event.SetEventObject(gs_activeFrame);
|
||||||
|
gs_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
gs_activeFrame = active;
|
||||||
|
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, gs_activeFrame->GetId());
|
||||||
|
event.SetEventObject(gs_activeFrame);
|
||||||
|
gs_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
|
wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
|
||||||
@@ -605,8 +650,8 @@ void wxWindowMGL::SetFocus()
|
|||||||
|
|
||||||
void wxWindowMGL::KillFocus()
|
void wxWindowMGL::KillFocus()
|
||||||
{
|
{
|
||||||
if ( g_focusedWindow != this ) return;
|
if ( gs_focusedWindow != this ) return;
|
||||||
g_focusedWindow = NULL;
|
gs_focusedWindow = NULL;
|
||||||
|
|
||||||
if ( m_isBeingDeleted ) return;
|
if ( m_isBeingDeleted ) return;
|
||||||
|
|
||||||
@@ -638,7 +683,7 @@ void wxWindowMGL::KillFocus()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
wxWindow *wxWindowBase::FindFocus()
|
wxWindow *wxWindowBase::FindFocus()
|
||||||
{
|
{
|
||||||
return (wxWindow*)g_focusedWindow;
|
return (wxWindow*)gs_focusedWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMGL::Show(bool show)
|
bool wxWindowMGL::Show(bool show)
|
||||||
@@ -664,22 +709,24 @@ void wxWindowMGL::Lower()
|
|||||||
|
|
||||||
void wxWindowMGL::CaptureMouse()
|
void wxWindowMGL::CaptureMouse()
|
||||||
{
|
{
|
||||||
|
if ( gs_mouseCapture )
|
||||||
|
MGL_wmUncaptureEvents(gs_mouseCapture->m_wnd, wxMGL_CAPTURE_MOUSE);
|
||||||
|
|
||||||
|
gs_mouseCapture = this;
|
||||||
MGL_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxMGL_CAPTURE_MOUSE);
|
MGL_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxMGL_CAPTURE_MOUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMGL::ReleaseMouse()
|
void wxWindowMGL::ReleaseMouse()
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( gs_mouseCapture == this, wxT("attempt to release mouse, but this window hasn't captured it") )
|
||||||
|
|
||||||
MGL_wmUncaptureEvents(m_wnd, wxMGL_CAPTURE_MOUSE);
|
MGL_wmUncaptureEvents(m_wnd, wxMGL_CAPTURE_MOUSE);
|
||||||
|
gs_mouseCapture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ wxWindow *wxWindowBase::GetCapture()
|
/* static */ wxWindow *wxWindowBase::GetCapture()
|
||||||
{
|
{
|
||||||
for (captureentry_t *c = g_winMng->capturedEvents; c; c = c->next)
|
return (wxWindow*)gs_mouseCapture;
|
||||||
{
|
|
||||||
if ( c->id == wxMGL_CAPTURE_MOUSE )
|
|
||||||
return (wxWindow*)c->wnd->userData;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMGL::SetCursor(const wxCursor& cursor)
|
bool wxWindowMGL::SetCursor(const wxCursor& cursor)
|
||||||
|
Reference in New Issue
Block a user