]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mgl/window.cpp
fixed crash in OnSize() handler
[wxWidgets.git] / src / mgl / window.cpp
index 00bc22aae5a88ebd208f742f368d7c2000c395b5..09f69f1dd7bc31b08d558be9f5e6be191887122a 100644 (file)
@@ -117,6 +117,7 @@ bool wxCreateMGL_WM()
     
 #if wxUSE_SYSTEM_OPTIONS
     // FIXME_MGL -- so what is The Proper Way?
+    width=800, height=600;
     if ( wxSystemOptions::HasOption(wxT("mgl.screen-width") )
         width = wxSystemOptions::GetOptionInt(wxT("mgl.screen-width"));
     if ( wxSystemOptions::HasOption(wxT("mgl.screen-height") )
@@ -180,6 +181,7 @@ static wxWindowMGL* wxGetTopLevelParent(wxWindowMGL *win)
 static void wxWindowPainter(window_t *wnd, MGLDC *dc)
 {
     wxWindowMGL *w = (wxWindow*) wnd->userData;
+    
     if ( w && !(w->GetWindowStyle() & wxTRANSPARENT_WINDOW) )
     {
         MGLDevCtx ctx(dc);
@@ -535,13 +537,13 @@ wxWindowMGL::~wxWindowMGL()
 
     if (gs_activeFrame == this)
     {
+       gs_activeFrame = NULL;
        // activate next frame in Z-order:
        if ( m_wnd->prev )
        {
            wxWindowMGL *win = (wxWindowMGL*)m_wnd->prev->userData;
            win->SetFocus();
         }
-        gs_activeFrame = NULL;
     }
     
     if ( gs_focusedWindow == this )
@@ -639,7 +641,7 @@ void wxWindowMGL::SetFocus()
 #endif // wxUSE_CARET
 
     wxWindowMGL *active = wxGetTopLevelParent(this);
-    if ( active != gs_activeFrame )
+    if ( !(m_windowStyle & wxPOPUP_WINDOW) && active != gs_activeFrame )
     {
         if ( gs_activeFrame )
         {
@@ -656,7 +658,7 @@ void wxWindowMGL::SetFocus()
     
     wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
     event.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(event);
+    AddPendingEvent(event);
 }
 
 void wxWindowMGL::KillFocus()
@@ -675,17 +677,9 @@ void wxWindowMGL::KillFocus()
         caret->OnKillFocus();
 #endif // wxUSE_CARET
 
-    if ( IsTopLevel() )
-    {
-        // FIXME_MGL - this is wrong, see wxGTK!
-        wxActivateEvent event(wxEVT_ACTIVATE, FALSE, GetId());
-        event.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(event);
-    }
-
     wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
     event.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(event);
+    AddPendingEvent(event);
 }
 
 // ----------------------------------------------------------------------------
@@ -703,6 +697,17 @@ bool wxWindowMGL::Show(bool show)
         return FALSE;
 
     MGL_wmShowWindow(m_wnd, show);
+    
+    if (!show && gs_activeFrame == this)
+    {
+       // activate next frame in Z-order:
+       if ( m_wnd->prev )
+       {
+           wxWindowMGL *win = (wxWindowMGL*)m_wnd->prev->userData;
+           win->SetFocus();
+        }
+    }
+
     return TRUE;
 }
 
@@ -1044,6 +1049,7 @@ void wxWindowMGL::Clear()
     dc.Clear();
 }
 
+#include "wx/menu.h"
 void wxWindowMGL::Refresh(bool eraseBack, const wxRect *rect)
 {
     if ( m_eraseBackground == -1 )