X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ca6a5f04692678cd2d9f3ea0843fc3f5a0b254f..135ce19c6765c1163b63071ed84443da989cac7a:/src/common/utilscmn.cpp diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 49c15f3284..e556674f85 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -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 /*