+// common part of WX_DECLARE_CONTROL_CONTAINER in the native and generic cases,
+// it should be used in the wxWindow-derived class declaration
+#define WX_DECLARE_CONTROL_CONTAINER_BASE() \
+public: \
+ virtual bool AcceptsFocus() const; \
+ virtual bool AcceptsFocusRecursively() const; \
+ virtual bool AcceptsFocusFromKeyboard() const; \
+ virtual void AddChild(wxWindowBase *child); \
+ virtual void RemoveChild(wxWindowBase *child); \
+ virtual void SetFocus(); \
+ void SetFocusIgnoringChildren(); \
+ void AcceptFocus(bool acceptFocus) \
+ { \
+ m_container.SetCanFocus(acceptFocus); \
+ } \
+ \
+protected: \
+ wxControlContainer m_container
+
+// this macro must be used in the derived class ctor
+#define WX_INIT_CONTROL_CONTAINER() \
+ m_container.SetContainerWindow(this)
+
+// common part of WX_DELEGATE_TO_CONTROL_CONTAINER in the native and generic
+// cases, must be used in the wxWindow-derived class implementation
+#define WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \
+ void classname::AddChild(wxWindowBase *child) \
+ { \
+ basename::AddChild(child); \
+ \
+ m_container.UpdateCanFocus(); \
+ } \
+ \
+ bool classname::AcceptsFocusRecursively() const \
+ { \
+ return m_container.AcceptsFocusRecursively(); \
+ } \
+ \
+ void classname::SetFocus() \
+ { \
+ if ( !m_container.DoSetFocus() ) \
+ basename::SetFocus(); \
+ } \
+ \
+ bool classname::AcceptsFocus() const \
+ { \
+ return m_container.AcceptsFocus(); \
+ } \
+ \
+ bool classname::AcceptsFocusFromKeyboard() const \
+ { \
+ return m_container.AcceptsFocusFromKeyboard(); \
+ }
+
+#ifdef wxHAS_NATIVE_TAB_TRAVERSAL
+
+// ----------------------------------------------------------------------------
+// wxControlContainer for native TAB navigation
+// ----------------------------------------------------------------------------
+
+// this must be a real class as we forward-declare it elsewhere
+class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase
+{
+protected:
+ // set the focus to the child which had it the last time
+ virtual bool SetFocusToChild();
+};
+
+#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname)
+
+#define WX_DECLARE_CONTROL_CONTAINER WX_DECLARE_CONTROL_CONTAINER_BASE
+
+#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \
+ WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \
+ \
+ void classname::RemoveChild(wxWindowBase *child) \
+ { \
+ basename::RemoveChild(child); \
+ \
+ m_container.UpdateCanFocus(); \
+ } \
+ \
+ void classname::SetFocusIgnoringChildren() \
+ { \
+ basename::SetFocus(); \
+ }
+
+#else // !wxHAS_NATIVE_TAB_TRAVERSAL
+
+class WXDLLIMPEXP_FWD_CORE wxFocusEvent;
+class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent;
+
+// ----------------------------------------------------------------------------
+// wxControlContainer for TAB navigation implemented in wx itself
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase
+{
+public:
+ // default ctor, SetContainerWindow() must be called later
+ wxControlContainer();
+
+ // the methods to be called from the window event handlers
+ void HandleOnNavigationKey(wxNavigationKeyEvent& event);
+ void HandleOnFocus(wxFocusEvent& event);
+ void HandleOnWindowDestroy(wxWindowBase *child);
+
+ // called from OnChildFocus() handler, i.e. when one of our (grand)
+ // children gets the focus
+ void SetLastFocus(wxWindow *win);
+
+protected:
+
+ wxDECLARE_NO_COPY_CLASS(wxControlContainer);
+};