]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/utilscmn.cpp
Committing in .
[wxWidgets.git] / src / common / utilscmn.cpp
index 49c15f328409766841d5ed091a39a822082f497b..e556674f850700ed37ca81ec0e3b803b5b6fad3b 100644 (file)
@@ -667,6 +667,50 @@ wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& i
   return menuBar->FindMenuItem (menuString, itemString);
 }
 
+// Try to find the deepest child that contains 'pt'
+wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt)
+{
+    wxNode* node = win->GetChildren().First();
+    while (node)
+    {
+        wxWindow* child = (wxWindow*) node->Data();
+        wxWindow* foundWin = wxFindWindowAtPoint(child, pt);
+        if (foundWin)
+            return foundWin;
+        node = node->Next();
+    }
+
+    wxPoint pos = win->GetPosition();
+    wxSize sz = win->GetSize();
+    if (win->GetParent())
+    {
+        pos = win->GetParent()->ClientToScreen(pos);
+    }
+
+    wxRect rect(pos, sz);
+    if (rect.Inside(pt))
+        return win;
+    else
+        return NULL;
+}
+
+wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt)
+{
+    // Go backwards through the list since windows
+    // on top are likely to have been appended most
+    // recently.
+    wxNode* node = wxTopLevelWindows.Last();
+    while (node)
+    {
+        wxWindow* win = (wxWindow*) node->Data();
+        wxWindow* found = wxFindWindowAtPoint(win, pt);
+        if (found)
+            return found;
+        node = node->Previous();
+    }
+    return NULL;
+}
+
 #endif // wxUSE_GUI
 
 /*