00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include "cwfrompoint.h"
00010 
00011 #include <wx/notebook.h>
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 wxWindow* wxChildWindowFromPoint(wxWindow* win, const wxPoint& pt, bool hidden , int depth )
00035 {
00036     bool shown = win->IsShown();
00037 
00038     if (win->IsKindOf(CLASSINFO(wxMDIChildFrame)))
00039     {
00040         wxWindow * pParent=win;
00041         
00042         while ((pParent =  pParent->GetParent()) && !(pParent->IsKindOf(CLASSINFO(wxMDIParentFrame)))) {}
00043         if (pParent)
00044         {
00045             
00046             if (((wxMDIParentFrame *)pParent)->GetActiveChild() != win)
00047                 shown=FALSE;
00048         }
00049     }
00050 
00051     if (!(hidden || shown))
00052         return NULL;
00053 
00054     
00055     
00056 #if wxUSE_NOTEBOOK
00057     
00058     
00059     
00060     if (depth && (win->IsKindOf(CLASSINFO(wxNotebook))))
00061     {
00062       wxNotebook* nb = (wxNotebook*) win;
00063       int sel = nb->GetSelection();
00064       if (sel >= 0)
00065       {
00066         wxWindow* child = nb->GetPage(sel);
00067         wxWindow* foundWin = wxChildWindowFromPoint(child, pt, hidden, (depth<0)?depth:depth-1);
00068         if (foundWin)
00069            return foundWin;
00070       }
00071     }
00072 #endif
00073 
00074     
00075     
00076     
00077     if (depth)
00078     {
00079         wxWindowList::compatibility_iterator node = win->GetChildren().GetLast();
00080         while (node)
00081         {
00082             wxWindow* child = node->GetData();
00083             wxWindow* foundWin = wxChildWindowFromPoint(child, pt, hidden, (depth<0)?depth:depth-1);
00084             if (foundWin)
00085               return foundWin;
00086             node = node->GetPrevious();
00087         }
00088     }
00089 
00090     wxPoint pos = win->GetPosition();
00091     wxSize sz = win->GetSize();
00092     if (win->GetParent() && !win->IsTopLevel()) 
00093     {
00094         pos = win->GetParent()->ClientToScreen(pos);
00095     }
00096 
00097     wxRect rect(pos, sz);
00098     if (rect.Inside(pt))
00099         return win;
00100     else
00101         return NULL;
00102 }
00103 
00104 
00105 
00106 wxWindow* wxChildWindowFromPoint(const wxPoint& pt, bool hidden , int depth )
00107 {
00108     
00109     
00110     
00111     wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetLast();
00112     while (node)
00113     {
00114         wxWindow* win = node->GetData();
00115         wxWindow* found = wxChildWindowFromPoint(win, pt, hidden, depth);
00116         if (found)
00117             return found;
00118         node = node->GetPrevious();
00119     }
00120     return NULL;
00121 }
00122 
00123