]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/popupcmn.cpp
Applied patch [ 1183157 ] Compilation with GCC 4.0
[wxWidgets.git] / src / common / popupcmn.cpp
index 50b97f508074bbcdeda1e5619bbce1e3fcce1470..5e6586bb3ccf48ec1c3504ce1afafc9fcd97acc7 100644 (file)
@@ -110,6 +110,12 @@ BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler)
     EVT_KEY_DOWN(wxPopupFocusHandler::OnKeyDown)
 END_EVENT_TABLE()
 
+BEGIN_EVENT_TABLE(wxPopupTransientWindow, wxPopupWindow)
+#ifdef __WXMSW__
+    EVT_IDLE(wxPopupTransientWindow::OnIdle)
+#endif
+END_EVENT_TABLE()
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -199,7 +205,10 @@ void wxPopupTransientWindow::PopHandlers()
             // handler - so don't risk deleting it second time
             m_handlerPopup = NULL;
         }
-
+        if (m_child->HasCapture())
+        {       
+            m_child->ReleaseMouse();
+        }
         m_child = NULL;
     }
 
@@ -303,6 +312,13 @@ bool wxPopupTransientWindow::Show( bool show )
     }
 #endif
 
+#ifdef __WXMSW__
+    if (!show && m_child && m_child->HasCapture())
+    {       
+        m_child->ReleaseMouse();
+    }
+#endif
+    
     bool ret = wxPopupWindow::Show( show );
 
 #ifdef __WXGTK__
@@ -337,20 +353,27 @@ bool wxPopupTransientWindow::Show( bool show )
             CurrentTime );
     }
 #endif
+
+#ifdef __WXMSW__
+    if (show && m_child)
+    {
+        // Assume that the mouse is outside the popup to begin with
+        m_child->CaptureMouse();
+    }
+#endif
+
     return ret;
 }
 
 void wxPopupTransientWindow::Dismiss()
 {
-    PopHandlers();
-
     Hide();
+    PopHandlers();
 }
 
 void wxPopupTransientWindow::DismissAndNotify()
 {
     Dismiss();
-
     OnDismiss();
 }
 
@@ -373,6 +396,35 @@ void wxPopupTransientWindow::OnDestroy(wxWindowDestroyEvent& event)
         m_focus = NULL;
 }
 
+#ifdef __WXMSW__
+void wxPopupTransientWindow::OnIdle(wxIdleEvent& event)
+{
+    event.Skip();
+
+    if (IsShown() && m_child)
+    {
+        wxPoint pos = ScreenToClient(wxGetMousePosition());
+        wxRect rect(GetSize());
+
+        if ( rect.Inside(pos) )
+        {
+            if ( m_child->HasCapture() )
+            {
+                m_child->ReleaseMouse();
+            }
+        }
+        else
+        {
+            if ( !m_child->HasCapture() )
+            {
+                m_child->CaptureMouse();
+            }
+        }                
+    }
+}
+#endif
+
+
 #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
 
 // ----------------------------------------------------------------------------