]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mgl/window.cpp
added msw/gccpriv.h and others to headers list
[wxWidgets.git] / src / mgl / window.cpp
index 00bc22aae5a88ebd208f742f368d7c2000c395b5..dac506d5186ae21523d726edc4ca99391bd0fa6d 100644 (file)
@@ -173,6 +173,21 @@ static wxWindowMGL* wxGetTopLevelParent(wxWindowMGL *win)
     return p;
 }
 
+#ifdef __WXDEBUG__
+// Add an easy way to capture screenshots:
+static void CaptureScreenshot()
+{
+    wxBusyCursor bcur;
+    
+    static int screenshot_num = 0;
+    char screenshot[128];
+    sprintf(screenshot, "screenshot-%03i.png", screenshot_num++);
+    g_displayDC->savePNGFromDC(screenshot, 0, 0, 
+                               g_displayDC->sizex(), 
+                               g_displayDC->sizey());
+}
+#endif
+
 // ---------------------------------------------------------------------------
 // MGL_WM hooks:
 // ---------------------------------------------------------------------------
@@ -180,6 +195,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);
@@ -197,7 +213,13 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
     MGL_wmCoordGlobalToLocal(win->GetHandle(), 
                              e->where_x, e->where_y, &where.x, &where.y);
 
-    if ( !win->IsEnabled() ) return FALSE;
+    for (wxWindowMGL *w = win; w; w = w->GetParent())
+    {
+        if ( !w->IsEnabled() ) 
+            return FALSE;
+        if ( w->IsTopLevel() )
+            break;
+    }
     
     wxEventType type = wxEVT_NULL;
     wxMouseEvent event;
@@ -460,6 +482,14 @@ static ibool wxWindowKeybHandler(window_t *wnd, event_t *e)
     
         ret = win->GetEventHandler()->ProcessEvent(event);
 
+
+#ifdef __WXDEBUG__
+        // Add an easy way to capture screenshots:
+        if ( event.m_keyCode == WXK_F1 && 
+             event.m_shiftDown && event.m_controlDown )
+            CaptureScreenshot();
+#endif
+
 #if wxUSE_ACCEL
         if ( !ret )
         {
@@ -535,13 +565,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 )
@@ -624,6 +654,8 @@ bool wxWindowMGL::Create(wxWindow *parent,
 
 void wxWindowMGL::SetFocus()
 {
+    if ( gs_focusedWindow == this ) return;
+
     if ( gs_focusedWindow )
         gs_focusedWindow->KillFocus();
     
@@ -639,7 +671,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 )
         {
@@ -675,14 +707,6 @@ 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);
@@ -703,6 +727,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 +1079,7 @@ void wxWindowMGL::Clear()
     dc.Clear();
 }
 
+#include "wx/menu.h"
 void wxWindowMGL::Refresh(bool eraseBack, const wxRect *rect)
 {
     if ( m_eraseBackground == -1 )
@@ -1090,6 +1126,12 @@ void wxWindowMGL::HandlePaint(MGLDevCtx *dc)
         return;
     }
     
+#if 0 // FIXME_MGL -- debugging stuff!
+    dc->setColorRGB(255,0,255);
+    dc->fillRect(-1000,-1000,2000,2000);
+    wxUsleep(100);
+#endif
+
     MGLRegion clip;
     dc->getClipRegion(clip);
     m_updateRegion = wxRegion(clip);