]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/containr.cpp
Implement wxWindow::SetCursor to invalidate Cocoa's cursor rects.
[wxWidgets.git] / src / common / containr.cpp
index 84be03d1462d980da5ad0ac0434d8519fd6ac7a2..f2d237a36d8f2766b9e9a965eda2876b4f0aba1b 100644 (file)
@@ -28,8 +28,6 @@
     #include "wx/containr.h"
 #endif
 
-#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
-
 #ifndef WX_PRECOMP
     #include "wx/log.h"
     #include "wx/event.h"
 // implementation
 // ============================================================================
 
-wxControlContainer::wxControlContainer(wxWindow *winParent)
-{
-    m_winParent = winParent;
-    m_winLastFocused = NULL;
-    m_inSetFocus = false;
-}
+// ----------------------------------------------------------------------------
+// wxControlContainerBase
+// ----------------------------------------------------------------------------
 
-bool wxControlContainer::AcceptsFocus() const
+void wxControlContainerBase::SetCanFocus(bool acceptsFocus)
 {
-    // we can accept focus either if we have no children at all (in this case
-    // we're probably not used as a container) or only when at least one child
-    // accepts focus
-    wxWindowList::compatibility_iterator node = m_winParent->GetChildren().GetFirst();
-    if ( !node )
-        return true;
+    if ( acceptsFocus == m_acceptsFocus )
+        return;
 
-#ifdef __WXMAC__
-    // wxMac has eventually the two scrollbars as children, they don't count
-    // as real children in the algorithm mentioned above
-    bool hasRealChildren = false ;
-#endif
+    m_acceptsFocus = acceptsFocus;
 
-    while ( node )
+    m_winParent->SetCanFocus(m_acceptsFocus);
+}
+
+bool wxControlContainerBase::HasAnyFocusableChildren() const
+{
+    const wxWindowList& children = m_winParent->GetChildren();
+    for ( wxWindowList::const_iterator i = children.begin(),
+                                     end = children.end();
+          i != end;
+          ++i )
     {
-        wxWindow *child = node->GetData();
-        node = node->GetNext();
+        const wxWindow * const child = *i;
 
-#ifdef __WXMAC__
-        if ( m_winParent->MacIsWindowScrollbar( child ) )
+        if ( !m_winParent->IsClientAreaChild(child) )
             continue;
-        hasRealChildren = true ;
-#endif
+
         if ( child->CanAcceptFocus() )
-        {
             return true;
-        }
     }
 
-#ifdef __WXMAC__
-    if ( !hasRealChildren )
-        return true ;
-#endif
-
     return false;
 }
 
+#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
+
+// ----------------------------------------------------------------------------
+// generic wxControlContainer
+// ----------------------------------------------------------------------------
+
+wxControlContainer::wxControlContainer()
+{
+    m_winLastFocused = NULL;
+    m_inSetFocus = false;
+}
+
 void wxControlContainer::SetLastFocus(wxWindow *win)
 {
     // the panel itself should never get the focus at all but if it does happen
@@ -133,12 +131,16 @@ void wxControlContainer::SetLastFocus(wxWindow *win)
     }
 
     // propagate the last focus upwards so that our parent can set focus back
-    // to us if it loses it now and regains later
-    wxWindow *parent = m_winParent->GetParent();
-    if ( parent )
+    // to us if it loses it now and regains later; do *not* do this if we are
+    // a toplevel window (e.g. wxDialog) that has another frame as its parent
+    if ( !m_winParent->IsTopLevel() )
     {
-        wxChildFocusEvent eventFocus(m_winParent);
-        parent->GetEventHandler()->ProcessEvent(eventFocus);
+        wxWindow *parent = m_winParent->GetParent();
+        if ( parent )
+        {
+            wxChildFocusEvent eventFocus(m_winParent);
+            parent->GetEventHandler()->ProcessEvent(eventFocus);
+        }
     }
 }
 
@@ -646,11 +648,10 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
         wxWindow *child = node->GetData();
         node = node->GetNext();
 
-#ifdef __WXMAC__
-        if ( child->GetParent()->MacIsWindowScrollbar( child ) )
+        // skip special windows:
+        if ( !win->IsClientAreaChild(child) )
             continue;
-#endif
-        
+
         if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() )
         {
 #ifdef __WXMSW__