+// 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;
+}
+