X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d1cd787b75f5ba9df06b1d51818496e0a6b214dd..8d18e3653e85fb6dbb00ef13dae3dae1fd46007e:/include/wx/containr.h diff --git a/include/wx/containr.h b/include/wx/containr.h index 375caff127..6ac64a4616 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -15,8 +15,8 @@ #include "wx/defs.h" -class WXDLLEXPORT wxWindow; -class WXDLLEXPORT wxWindowBase; +class WXDLLIMPEXP_FWD_CORE wxWindow; +class WXDLLIMPEXP_FWD_CORE wxWindowBase; /* Implementation note: wxControlContainer is not a real mix-in but rather @@ -57,12 +57,21 @@ public: // returns whether we should accept focus ourselves or not bool AcceptsFocus() const { return m_acceptsFocus; } + // returns whether we or one of our children accepts focus: we always do + // because if we don't have any focusable children it probably means that + // we're not being used as a container at all (think of wxGrid or generic + // wxListCtrl) and so should get focus for ourselves + bool AcceptsFocusRecursively() const { return true; } + // call this when the number of children of the window changes - void UpdateCanFocus() { SetCanFocus(ShouldAcceptFocus()); } + // + // note that we have any children, this panel (used just as container for + // them) shouldn't get focus for itself + void UpdateCanFocus() { SetCanFocus(!HasAnyFocusableChildren()); } protected: - // return true if we should be focusable - bool ShouldAcceptFocus() const; + // return true if we have any children accepting focus + bool HasAnyFocusableChildren() const; // the parent window we manage the children for wxWindow *m_winParent; @@ -78,6 +87,7 @@ private: #define WX_DECLARE_CONTROL_CONTAINER_BASE() \ public: \ virtual bool AcceptsFocus() const; \ + virtual bool AcceptsFocusRecursively() const; \ virtual void AddChild(wxWindowBase *child); \ virtual void RemoveChild(wxWindowBase *child); \ void SetFocusIgnoringChildren(); \ @@ -103,6 +113,11 @@ protected: \ m_container.UpdateCanFocus(); \ } \ \ + bool classname::AcceptsFocusRecursively() const \ + { \ + return m_container.AcceptsFocusRecursively(); \ + } \ + \ bool classname::AcceptsFocus() const \ { \ return m_container.AcceptsFocus(); \ @@ -141,8 +156,8 @@ class WXDLLEXPORT wxControlContainer : public wxControlContainerBase #else // !wxHAS_NATIVE_TAB_TRAVERSAL -class WXDLLEXPORT wxFocusEvent; -class WXDLLEXPORT wxNavigationKeyEvent; +class WXDLLIMPEXP_FWD_CORE wxFocusEvent; +class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent; // ---------------------------------------------------------------------------- // wxControlContainer for TAB navigation implemented in wx itself