#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;
/*
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
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) \
return m_container.AcceptsFocus(); \
}
+#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
#endif // _WX_CONTAINR_H_
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() {}
#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
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;
}
}
#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
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
return false;
}
+
+#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
// 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
void wxPanel::Init()
{
- m_container.SetContainerWindow(this);
+ WX_INIT_CONTROL_CONTAINER();
}
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
void wxSplitterWindow::Init()
{
- m_container.SetContainerWindow(this);
+ WX_INIT_CONTROL_CONTAINER();
m_splitMode = wxSPLIT_VERTICAL;
m_permitUnsplitAlways = true;
void wxComboBox::Init()
{
- m_container.SetContainerWindow(this);
+ WX_INIT_CONTROL_CONTAINER();
}
bool wxComboBox::Create(wxWindow *parent,
{
m_text = NULL;
m_btn = NULL;
- m_container.SetContainerWindow(this);
+ WX_INIT_CONTROL_CONTAINER();
}
bool wxSpinCtrl::Create(wxWindow *parent,