[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 827
Date : Mon Apr 17 10:01:07 BST 2006
Changed paths:
M /Trunk/XaraLX/wxXtra/cwfrompoint.cpp
M /Trunk/XaraLX/wxXtra/cwfrompoint.h
Fixed wxChildWindowFromPoint to default to 1 level of recursion, and ignore whether the window is hidden by default.
Diff:
Index: Trunk/XaraLX/wxXtra/cwfrompoint.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/cwfrompoint.cpp (revision 826)
+++ Trunk/XaraLX/wxXtra/cwfrompoint.cpp (revision 827)
@@ -8,39 +8,66 @@
#include "cwfrompoint.h"
-// This is an exact duplication of wxFindWindowAtPoint
-// (the unexported variant thereof)
+// wxChildWindowFromPoint
+//
+// This is a routine derived from wxFindWindowAtPoint (the unexported variant thereof).
+// It finds the child window of a window passed as a parameter, which contains the point
+// passed in. It fill find the deepest such child window. If no child window contains the
+// point passed in, it will return a pointer to the window itself, unless that also
+// does not contain the point in question, in which case it will return NULL.
+// The "hidden" flag determines whether or not it should examine windows which are
+// hidden (i.e. for which IsShown() is false). The routine can be passed a depth
+// to recurse to, negative depth being infinite recursion, zero meaning do not look at
+// child windows, and positive meaning a limited depth.
+//
+// Inputs:
+// wxWindow * win The window to examine, plus children thereof
+// const wxPoint& pt The coordinate, in screen coords
+// bool hidden Flag, true to examine hidden windows as well (defaults to true)
+// int depth Depth of recursion; zero to not recurse, positive for that number
+// of levels, negative for infinite recursion (defaults to 1)
+// Returns:
+// wxWindow * Pointer to the deepest window searched containing pt, or NULL
-wxWindow* wxChildWindowFromPoint(wxWindow* win, const wxPoint& pt)
+wxWindow* wxChildWindowFromPoint(wxWindow* win, const wxPoint& pt, bool hidden /* =true */, int depth /* =1 */)
{
- if (!win->IsShown())
+ if (!(hidden || win->IsShown()))
return NULL;
// Hack for wxNotebook case: at least in wxGTK, all pages
// claim to be shown, so we must only deal with the selected one.
#if wxUSE_NOTEBOOK
- if (win->IsKindOf(CLASSINFO(wxNotebook)))
+ // If depth is >0, we want to descend as we have more searching to do. If depth
+ // is negative, that means descend to infinite depth. So don't descend if depth
+ // is exactly zero
+ if (depth && (win->IsKindOf(CLASSINFO(wxNotebook))))
{
wxNotebook* nb = (wxNotebook*) win;
int sel = nb->GetSelection();
if (sel >= 0)
{
wxWindow* child = nb->GetPage(sel);
- wxWindow* foundWin = wxChildWindowFromPoint(child, pt);
+ wxWindow* foundWin = wxChildWindowFromPoint(child, pt, hidden, (depth<0)?depth:depth-1);
if (foundWin)
return foundWin;
}
}
#endif
- wxWindowList::compatibility_iterator node = win->GetChildren().GetLast();
- while (node)
+ // If depth is >0, we want to descend as we have more searching to do. If depth
+ // is negative, that means descend to infinite depth. So don't descend if depth
+ // is exactly zero
+ if (depth)
{
- wxWindow* child = node->GetData();
- wxWindow* foundWin = wxChildWindowFromPoint(child, pt);
- if (foundWin)
- return foundWin;
- node = node->GetPrevious();
+ wxWindowList::compatibility_iterator node = win->GetChildren().GetLast();
+ while (node)
+ {
+ wxWindow* child = node->GetData();
+ wxWindow* foundWin = wxChildWindowFromPoint(child, pt, hidden, (depth<0)?depth:depth-1);
+ if (foundWin)
+ return foundWin;
+ node = node->GetPrevious();
+ }
}
wxPoint pos = win->GetPosition();
Index: Trunk/XaraLX/wxXtra/cwfrompoint.h
===================================================================
--- Trunk/XaraLX/wxXtra/cwfrompoint.h (revision 826)
+++ Trunk/XaraLX/wxXtra/cwfrompoint.h (revision 827)
@@ -11,6 +11,6 @@
#include <wx/wx.h>
-extern wxWindow* wxChildWindowFromPoint(wxWindow* win, const wxPoint& pt);
+extern wxWindow* wxChildWindowFromPoint(wxWindow* win, const wxPoint& pt, bool hidden=true, int depth=1);
#endif // __WXXTRA_DOUBLEBUFFER_H
Xara