]> git.saurik.com Git - wxWidgets.git/commitdiff
don't use wxControlContainer if wxHAS_NATIVE_TAB_TRAVERSAL is defined (currently...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Mar 2007 22:41:11 +0000 (22:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Mar 2007 22:41:11 +0000 (22:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/containr.h
include/wx/pickerbase.h
src/common/containr.cpp
src/common/dlgcmn.cpp
src/generic/panelg.cpp
src/generic/splitter.cpp
src/mac/carbon/combobox.cpp
src/mac/carbon/spinctrl.cpp

index 1bf91cfef58c78a467d6b64473f36a3f7676599b..e6750713bcdb053b19e7c0b5ea303ae8573fddd0 100644 (file)
 #ifndef _WX_CONTAINR_H_
 #define _WX_CONTAINR_H_
 
+// use native tab traversal logic under GTK+ 2 (doesn't work yet)
+#if 0 // def __WXGTK20__
+    #define wxHAS_NATIVE_TAB_TRAVERSAL
+#endif
+
+#ifdef wxHAS_NATIVE_TAB_TRAVERSAL
+
+#define WX_DECLARE_CONTROL_CONTAINER() \
+    virtual bool AcceptsFocus() const { return false; } \
+    void SetFocusIgnoringChildren() { SetFocus(); }
+
+#define WX_INIT_CONTROL_CONTAINER()
+#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname)
+#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename)
+
+#else // !wxHAS_NATIVE_TAB_TRAVERSAL
+
 class WXDLLEXPORT wxFocusEvent;
 class WXDLLEXPORT wxNavigationKeyEvent;
 class WXDLLEXPORT wxWindow;
@@ -20,7 +37,7 @@ class WXDLLEXPORT wxWindowBase;
 
 /*
    Implementation note: wxControlContainer is not a real mix-in but rather
-   a class meant to be agregated with (and not inherited from). Although
+   a class meant to be aggregated with (and not inherited from). Although
    logically it should be a mix-in, doing it like this has no advantage from
    the point of view of the existing code but does have some problems (we'd
    need to play tricks with event handlers which may be difficult to do
@@ -92,6 +109,10 @@ public: \
 protected: \
     wxControlContainer m_container
 
+// this macro must be used in the derived class ctor
+#define WX_INIT_CONTROL_CONTAINER() \
+    m_container.SetContainerWindow(this)
+
 // implement the event table entries for wxControlContainer
 #define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
     EVT_SET_FOCUS(classname::OnFocus) \
@@ -137,5 +158,6 @@ bool classname::AcceptsFocus() const \
     return m_container.AcceptsFocus(); \
 }
 
+#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
 
 #endif // _WX_CONTAINR_H_
index c1b8bb9b496961e248fd075be1c33ae092dca556..8fc0846b2ac82bbd7643eb302a9ad783e114c553 100644 (file)
@@ -37,7 +37,7 @@ class WXDLLIMPEXP_CORE wxPickerBase : public wxControl
 public:
     // ctor: text is the associated text control
     wxPickerBase() : m_text(NULL), m_picker(NULL), m_sizer(NULL)
-        { m_container.SetContainerWindow(this); }
+        { WX_INIT_CONTROL_CONTAINER(); }
     virtual ~wxPickerBase() {}
 
 
index 3333232ec59e31e61aa101a4d06750037aff463a..84be03d1462d980da5ad0ac0434d8519fd6ac7a2 100644 (file)
     #pragma hdrstop
 #endif
 
+#ifndef WX_PRECOMP
+    #include "wx/containr.h"
+#endif
+
+#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
+
 #ifndef WX_PRECOMP
     #include "wx/log.h"
     #include "wx/event.h"
     #include "wx/window.h"
     #include "wx/scrolbar.h"
     #include "wx/radiobut.h"
-    #include "wx/containr.h"
 #endif //WX_PRECOMP
 
 // trace mask for focus messages
@@ -49,43 +54,39 @@ wxControlContainer::wxControlContainer(wxWindow *winParent)
 
 bool wxControlContainer::AcceptsFocus() const
 {
-    // if we're not shown or disabled, we can't accept focus
-    if ( m_winParent->IsShown() && m_winParent->IsEnabled() )
-    {
-        // otherwise 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 will accept focus
-        wxWindowList::compatibility_iterator node = m_winParent->GetChildren().GetFirst();
-        if ( !node )
-            return true;
+    // 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;
 
 #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 ;
+    // wxMac has eventually the two scrollbars as children, they don't count
+    // as real children in the algorithm mentioned above
+    bool hasRealChildren = false ;
 #endif
 
-        while ( node )
-        {
-            wxWindow *child = node->GetData();
-            node = node->GetNext();
+    while ( node )
+    {
+        wxWindow *child = node->GetData();
+        node = node->GetNext();
 
 #ifdef __WXMAC__
-            if ( m_winParent->MacIsWindowScrollbar( child ) )
-                continue;
-            hasRealChildren = true ;
+        if ( m_winParent->MacIsWindowScrollbar( child ) )
+            continue;
+        hasRealChildren = true ;
 #endif
-            if ( child->AcceptsFocus() )
-            {
-                return true;
-            }
+        if ( child->CanAcceptFocus() )
+        {
+            return true;
         }
+    }
 
 #ifdef __WXMAC__
-        if ( !hasRealChildren )
-            return true ;
+    if ( !hasRealChildren )
+        return true ;
 #endif
-    }
 
     return false;
 }
@@ -504,7 +505,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
         }
 #endif // __WXMSW__
 
-        if ( child->AcceptsFocusFromKeyboard() )
+        if ( child->CanAcceptFocusFromKeyboard() )
         {
             // if we're setting the focus to a child panel we should prevent it
             // from giving it to the child which had the focus the last time
@@ -650,7 +651,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
             continue;
 #endif
         
-        if ( child->AcceptsFocusFromKeyboard() && !child->IsTopLevel() )
+        if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() )
         {
 #ifdef __WXMSW__
             // If a radiobutton is the first focusable child, search for the
@@ -676,3 +677,5 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
 
     return false;
 }
+
+#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
index 74af36254e2e6ef3e87351d943a2c0a3ba4ec1fb..cf4557e88322392a8b80266b86a7fd508bbe700a 100644 (file)
@@ -121,7 +121,7 @@ void wxDialogBase::Init()
     // undesirable and can lead to unexpected and hard to find bugs
     SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
 
-    m_container.SetContainerWindow(this);
+    WX_INIT_CONTROL_CONTAINER();
 }
 
 #if wxUSE_STATTEXT
index 34c59bb52da38761e7f6dc4126ecd59fd9d9d0db..d714bce3c08935bc3602c6f9453b590ea8e3adb7 100644 (file)
@@ -105,7 +105,7 @@ WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, wxWindow)
 
 void wxPanel::Init()
 {
-    m_container.SetContainerWindow(this);
+    WX_INIT_CONTROL_CONTAINER();
 }
 
 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
index a8747b4652dcc967e926875ce8f63dca50147a1b..958de8cc0bcf1e076fd676530c289fd6327196fb 100644 (file)
@@ -107,7 +107,7 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,
 
 void wxSplitterWindow::Init()
 {
-    m_container.SetContainerWindow(this);
+    WX_INIT_CONTROL_CONTAINER();
 
     m_splitMode = wxSPLIT_VERTICAL;
     m_permitUnsplitAlways = true;
index 6a155d9636af25e6bb608d4cfdf69944c1648f45..734e631e288566789124016d560ffc5f019e8d80 100644 (file)
@@ -334,7 +334,7 @@ void wxComboBox::DelegateChoice( const wxString& value )
 
 void wxComboBox::Init()
 {
-    m_container.SetContainerWindow(this);
+    WX_INIT_CONTROL_CONTAINER();
 }
 
 bool wxComboBox::Create(wxWindow *parent,
index 63b1a7c41c2a1b441b7682a9ee0f38dd0fe788e3..e0e3bcb59780f510ac6115529c9f1da24b9bd0db 100644 (file)
@@ -202,7 +202,7 @@ void wxSpinCtrl::Init()
 {
     m_text = NULL;
     m_btn = NULL;
-    m_container.SetContainerWindow(this);
+    WX_INIT_CONTROL_CONTAINER();
 }
 
 bool wxSpinCtrl::Create(wxWindow *parent,