don't use wxControlContainer if wxHAS_NATIVE_TAB_TRAVERSAL is defined (currently it never is)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ad02525dad
commit
de160b0647
@ -13,6 +13,23 @@
|
|||||||
#ifndef _WX_CONTAINR_H_
|
#ifndef _WX_CONTAINR_H_
|
||||||
#define _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 wxFocusEvent;
|
||||||
class WXDLLEXPORT wxNavigationKeyEvent;
|
class WXDLLEXPORT wxNavigationKeyEvent;
|
||||||
class WXDLLEXPORT wxWindow;
|
class WXDLLEXPORT wxWindow;
|
||||||
@ -20,7 +37,7 @@ class WXDLLEXPORT wxWindowBase;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Implementation note: wxControlContainer is not a real mix-in but rather
|
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
|
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
|
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
|
need to play tricks with event handlers which may be difficult to do
|
||||||
@ -92,6 +109,10 @@ public: \
|
|||||||
protected: \
|
protected: \
|
||||||
wxControlContainer m_container
|
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
|
// implement the event table entries for wxControlContainer
|
||||||
#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
|
#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
|
||||||
EVT_SET_FOCUS(classname::OnFocus) \
|
EVT_SET_FOCUS(classname::OnFocus) \
|
||||||
@ -137,5 +158,6 @@ bool classname::AcceptsFocus() const \
|
|||||||
return m_container.AcceptsFocus(); \
|
return m_container.AcceptsFocus(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
|
||||||
|
|
||||||
#endif // _WX_CONTAINR_H_
|
#endif // _WX_CONTAINR_H_
|
||||||
|
@ -37,7 +37,7 @@ class WXDLLIMPEXP_CORE wxPickerBase : public wxControl
|
|||||||
public:
|
public:
|
||||||
// ctor: text is the associated text control
|
// ctor: text is the associated text control
|
||||||
wxPickerBase() : m_text(NULL), m_picker(NULL), m_sizer(NULL)
|
wxPickerBase() : m_text(NULL), m_picker(NULL), m_sizer(NULL)
|
||||||
{ m_container.SetContainerWindow(this); }
|
{ WX_INIT_CONTROL_CONTAINER(); }
|
||||||
virtual ~wxPickerBase() {}
|
virtual ~wxPickerBase() {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,13 +24,18 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/containr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/event.h"
|
#include "wx/event.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
#include "wx/scrolbar.h"
|
#include "wx/scrolbar.h"
|
||||||
#include "wx/radiobut.h"
|
#include "wx/radiobut.h"
|
||||||
#include "wx/containr.h"
|
|
||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
// trace mask for focus messages
|
// trace mask for focus messages
|
||||||
@ -49,43 +54,39 @@ wxControlContainer::wxControlContainer(wxWindow *winParent)
|
|||||||
|
|
||||||
bool wxControlContainer::AcceptsFocus() const
|
bool wxControlContainer::AcceptsFocus() const
|
||||||
{
|
{
|
||||||
// if we're not shown or disabled, we can't accept focus
|
// we can accept focus either if we have no children at all (in this case
|
||||||
if ( m_winParent->IsShown() && m_winParent->IsEnabled() )
|
// 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 ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while ( node )
|
||||||
{
|
{
|
||||||
// otherwise we can accept focus either if we have no children at all
|
wxWindow *child = node->GetData();
|
||||||
// (in this case we're probably not used as a container) or only when
|
node = node->GetNext();
|
||||||
// at least one child will accept focus
|
|
||||||
wxWindowList::compatibility_iterator node = m_winParent->GetChildren().GetFirst();
|
|
||||||
if ( !node )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// wxMac has eventually the two scrollbars as children, they don't count
|
if ( m_winParent->MacIsWindowScrollbar( child ) )
|
||||||
// as real children in the algorithm mentioned above
|
continue;
|
||||||
bool hasRealChildren = false ;
|
hasRealChildren = true ;
|
||||||
#endif
|
#endif
|
||||||
|
if ( child->CanAcceptFocus() )
|
||||||
while ( node )
|
|
||||||
{
|
{
|
||||||
wxWindow *child = node->GetData();
|
return true;
|
||||||
node = node->GetNext();
|
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
|
||||||
if ( m_winParent->MacIsWindowScrollbar( child ) )
|
|
||||||
continue;
|
|
||||||
hasRealChildren = true ;
|
|
||||||
#endif
|
|
||||||
if ( child->AcceptsFocus() )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
if ( !hasRealChildren )
|
if ( !hasRealChildren )
|
||||||
return true ;
|
return true ;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -504,7 +505,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
|
|||||||
}
|
}
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
|
|
||||||
if ( child->AcceptsFocusFromKeyboard() )
|
if ( child->CanAcceptFocusFromKeyboard() )
|
||||||
{
|
{
|
||||||
// if we're setting the focus to a child panel we should prevent it
|
// 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
|
// from giving it to the child which had the focus the last time
|
||||||
@ -650,7 +651,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
|||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( child->AcceptsFocusFromKeyboard() && !child->IsTopLevel() )
|
if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() )
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// If a radiobutton is the first focusable child, search for the
|
// If a radiobutton is the first focusable child, search for the
|
||||||
@ -676,3 +677,5 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
|
||||||
|
@ -121,7 +121,7 @@ void wxDialogBase::Init()
|
|||||||
// undesirable and can lead to unexpected and hard to find bugs
|
// undesirable and can lead to unexpected and hard to find bugs
|
||||||
SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
|
SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
|
||||||
|
|
||||||
m_container.SetContainerWindow(this);
|
WX_INIT_CONTROL_CONTAINER();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_STATTEXT
|
#if wxUSE_STATTEXT
|
||||||
|
@ -105,7 +105,7 @@ WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, wxWindow)
|
|||||||
|
|
||||||
void wxPanel::Init()
|
void wxPanel::Init()
|
||||||
{
|
{
|
||||||
m_container.SetContainerWindow(this);
|
WX_INIT_CONTROL_CONTAINER();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
|
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
|
||||||
|
@ -107,7 +107,7 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
void wxSplitterWindow::Init()
|
void wxSplitterWindow::Init()
|
||||||
{
|
{
|
||||||
m_container.SetContainerWindow(this);
|
WX_INIT_CONTROL_CONTAINER();
|
||||||
|
|
||||||
m_splitMode = wxSPLIT_VERTICAL;
|
m_splitMode = wxSPLIT_VERTICAL;
|
||||||
m_permitUnsplitAlways = true;
|
m_permitUnsplitAlways = true;
|
||||||
|
@ -334,7 +334,7 @@ void wxComboBox::DelegateChoice( const wxString& value )
|
|||||||
|
|
||||||
void wxComboBox::Init()
|
void wxComboBox::Init()
|
||||||
{
|
{
|
||||||
m_container.SetContainerWindow(this);
|
WX_INIT_CONTROL_CONTAINER();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxComboBox::Create(wxWindow *parent,
|
bool wxComboBox::Create(wxWindow *parent,
|
||||||
|
@ -202,7 +202,7 @@ void wxSpinCtrl::Init()
|
|||||||
{
|
{
|
||||||
m_text = NULL;
|
m_text = NULL;
|
||||||
m_btn = NULL;
|
m_btn = NULL;
|
||||||
m_container.SetContainerWindow(this);
|
WX_INIT_CONTROL_CONTAINER();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSpinCtrl::Create(wxWindow *parent,
|
bool wxSpinCtrl::Create(wxWindow *parent,
|
||||||
|
Loading…
Reference in New Issue
Block a user