cwfrompoint.h File Reference

(r1785/r1127)

#include <wx/wx.h>

Go to the source code of this file.

Functions

wxWindow * wxChildWindowFromPoint (wxWindow *win, const wxPoint &pt, bool hidden=true, int depth=1)
wxWindow * wxChildWindowFromPoint (const wxPoint &pt, bool hidden=true, int depth=1)


Function Documentation

wxWindow* wxChildWindowFromPoint const wxPoint &  pt,
bool  hidden = true,
int  depth = 1
 

Definition at line 106 of file cwfrompoint.cpp.

00107 {
00108     // Go backwards through the list since windows
00109     // on top are likely to have been appended most
00110     // recently.
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 }

wxWindow* wxChildWindowFromPoint wxWindow *  win,
const wxPoint &  pt,
bool  hidden = true,
int  depth = 1
 

Definition at line 34 of file cwfrompoint.cpp.

00035 {
00036     bool shown = win->IsShown();
00037 
00038     if (win->IsKindOf(CLASSINFO(wxMDIChildFrame)))
00039     {
00040         wxWindow * pParent=win;
00041         // Look for a wxMDIParentFrame
00042         while ((pParent = /*assignment*/ pParent->GetParent()) && !(pParent->IsKindOf(CLASSINFO(wxMDIParentFrame)))) {}
00043         if (pParent)
00044         {
00045             // If this isn't the active child, then treat it as if it was hidden.
00046             if (((wxMDIParentFrame *)pParent)->GetActiveChild() != win)
00047                 shown=FALSE;
00048         }
00049     }
00050 
00051     if (!(hidden || shown))
00052         return NULL;
00053 
00054     // Hack for wxNotebook case: at least in wxGTK, all pages
00055     // claim to be shown, so we must only deal with the selected one.
00056 #if wxUSE_NOTEBOOK
00057     // If depth is >0, we want to descend as we have more searching to do. If depth
00058     // is negative, that means descend to infinite depth. So don't descend if depth
00059     // is exactly zero
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     // If depth is >0, we want to descend as we have more searching to do. If depth
00075     // is negative, that means descend to infinite depth. So don't descend if depth
00076     // is exactly zero
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()) // Do not translate coords in TLWs as they are already screen coords
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 }


Generated on Sat Nov 10 03:49:37 2007 for Camelot by  doxygen 1.4.4