From 90230407984b0bbe9d6ed6ae6dc2376700ef1d42 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Jul 2011 22:19:33 +0000 Subject: [PATCH] Replace wxControlContainer-related macros with wxNavigationEnabled<>. Simply inherit classes which need to provide TAB navigation among their children from wxNavigationEnabled<> and remove the now unnecessary WX_DECLARE_CONTROL_CONTAINER() macros. Also remove WX_INIT_CONTROL_CONTAINER(), WX_DELEGATE_TO_CONTROL_CONTAINER() and WX_EVENT_TABLE_CONTROL_CONTAINER() which are not needed neither any more. And remove the event tables which became empty after removing the last macro. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/auibook.h | 16 ++++++++++------ include/wx/generic/collpaneg.h | 4 ++-- include/wx/generic/splitter.h | 4 +--- include/wx/osx/combobox.h | 21 ++++++++------------- include/wx/osx/spinctrl.h | 5 +---- include/wx/panel.h | 8 ++------ include/wx/pickerbase.h | 7 ++----- include/wx/toplevel.h | 4 ++-- interface/wx/event.h | 4 ++-- src/aui/auibook.cpp | 26 +------------------------- src/common/panelcmn.cpp | 15 --------------- src/common/pickerbase.cpp | 2 -- src/common/toplvcmn.cpp | 5 ----- src/generic/collpaneg.cpp | 6 ------ src/generic/splitter.cpp | 6 ------ src/osx/carbon/combobox.cpp | 12 ------------ src/osx/spinctrl_osx.cpp | 8 -------- 17 files changed, 31 insertions(+), 122 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index c10cd632f3..42092662f8 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -502,18 +502,22 @@ protected: -class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl +class WXDLLIMPEXP_AUI wxAuiNotebook : public wxNavigationEnabled { public: - wxAuiNotebook(); + wxAuiNotebook() { Init(); } wxAuiNotebook(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxAUI_NB_DEFAULT_STYLE); + long style = wxAUI_NB_DEFAULT_STYLE) + { + Init(); + Create(parent, id, pos, size, style); + } virtual ~wxAuiNotebook(); @@ -595,6 +599,9 @@ public: virtual void Thaw(); protected: + // Common part of all ctors. + void Init(); + // choose the default border for this window virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } @@ -665,9 +672,6 @@ protected: DECLARE_CLASS(wxAuiNotebook) DECLARE_EVENT_TABLE() #endif - - WX_DECLARE_CONTROL_CONTAINER(); - }; diff --git a/include/wx/generic/collpaneg.h b/include/wx/generic/collpaneg.h index b25c39db4e..4ee8cafcf8 100644 --- a/include/wx/generic/collpaneg.h +++ b/include/wx/generic/collpaneg.h @@ -25,7 +25,8 @@ class WXDLLIMPEXP_FWD_CORE wxDisclosureTriangle; // wxGenericCollapsiblePane // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : public wxCollapsiblePaneBase +class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : + public wxNavigationEnabled { public: wxGenericCollapsiblePane() { Init(); } @@ -103,7 +104,6 @@ private: void OnButton(wxCommandEvent &ev); void OnSize(wxSizeEvent &ev); - WX_DECLARE_CONTROL_CONTAINER(); DECLARE_DYNAMIC_CLASS(wxGenericCollapsiblePane) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/generic/splitter.h b/include/wx/generic/splitter.h index cbb072eecc..fdaeb8023a 100644 --- a/include/wx/generic/splitter.h +++ b/include/wx/generic/splitter.h @@ -49,7 +49,7 @@ enum // to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be // standard). -class WXDLLIMPEXP_CORE wxSplitterWindow: public wxWindow +class WXDLLIMPEXP_CORE wxSplitterWindow: public wxNavigationEnabled { public: @@ -300,8 +300,6 @@ protected: bool m_checkRequestedSashPosition:1; private: - WX_DECLARE_CONTROL_CONTAINER(); - DECLARE_DYNAMIC_CLASS(wxSplitterWindow) DECLARE_EVENT_TABLE() wxDECLARE_NO_COPY_CLASS(wxSplitterWindow); diff --git a/include/wx/osx/combobox.h b/include/wx/osx/combobox.h index d8e5c186e4..8d875edd34 100644 --- a/include/wx/osx/combobox.h +++ b/include/wx/osx/combobox.h @@ -25,7 +25,13 @@ class wxComboBoxChoice; class wxComboWidgetImpl; // Combobox item -class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase +class WXDLLIMPEXP_CORE wxComboBox : +#if wxOSX_USE_CARBON + public wxNavigationEnabled, +#else + public wxControl, +#endif + public wxComboBoxBase { DECLARE_DYNAMIC_CLASS(wxComboBox) @@ -42,7 +48,7 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase virtual void DelegateTextChanged( const wxString& value ); virtual void DelegateChoice( const wxString& value ); - wxComboBox() { Init(); } + wxComboBox() { } wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, @@ -53,7 +59,6 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) { - Init(); Create(parent, id, value, pos, size, n, choices, style, validator, name); } @@ -66,7 +71,6 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) { - Init(); Create(parent, id, value, pos, size, choices, style, validator, name); } @@ -142,17 +146,12 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase #if wxOSX_USE_CARBON wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST - - WX_DECLARE_CONTROL_CONTAINER(); #endif #if wxOSX_USE_COCOA wxComboWidgetImpl* GetComboPeer() const; #endif protected: - // common part of all ctors - void Init(); - // List functions virtual void DoDeleteOneItem(unsigned int n); virtual void DoClear(); @@ -187,10 +186,6 @@ protected: wxComboBoxChoice* m_choice; wxComboBoxDataArray m_datas; - -#if wxOSX_USE_CARBON - DECLARE_EVENT_TABLE() -#endif }; #endif // _WX_COMBOBOX_H_ diff --git a/include/wx/osx/spinctrl.h b/include/wx/osx/spinctrl.h index f95b0c10f2..f8a7ab2057 100644 --- a/include/wx/osx/spinctrl.h +++ b/include/wx/osx/spinctrl.h @@ -33,7 +33,7 @@ class WXDLLIMPEXP_FWD_CORE wxSpinCtrlButton; // wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrl : public wxControl +class WXDLLIMPEXP_CORE wxSpinCtrl : public wxNavigationEnabled { public: wxSpinCtrl() { Init(); } @@ -93,8 +93,6 @@ public: // number is out of range bool GetTextValue(int *val) const; - WX_DECLARE_CONTROL_CONTAINER(); - protected: // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestSize() const; @@ -113,7 +111,6 @@ private: int m_oldValue; private: - DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxSpinCtrl) }; diff --git a/include/wx/panel.h b/include/wx/panel.h index 74016c64f4..bb93a5771b 100644 --- a/include/wx/panel.h +++ b/include/wx/panel.h @@ -28,10 +28,10 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[]; // wxPanel contains other controls and implements TAB traversal between them // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPanelBase : public wxWindow +class WXDLLIMPEXP_CORE wxPanelBase : public wxNavigationEnabled { public: - wxPanelBase(); + wxPanelBase() { } // Derived classes should also provide this constructor: /* @@ -69,14 +69,10 @@ public: virtual void InitDialog(); - WX_DECLARE_CONTROL_CONTAINER(); - protected: virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) = 0; private: - wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(wxPanelBase); }; diff --git a/include/wx/pickerbase.h b/include/wx/pickerbase.h index 1982838cc2..1d6b383cd8 100644 --- a/include/wx/pickerbase.h +++ b/include/wx/pickerbase.h @@ -32,12 +32,12 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; #define wxPB_USE_TEXTCTRL 0x0002 -class WXDLLIMPEXP_CORE wxPickerBase : public wxControl +class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled { public: // ctor: text is the associated text control wxPickerBase() : m_text(NULL), m_picker(NULL), m_sizer(NULL) - { WX_INIT_CONTROL_CONTAINER(); } + { } virtual ~wxPickerBase() {} @@ -179,9 +179,6 @@ protected: private: DECLARE_ABSTRACT_CLASS(wxPickerBase) DECLARE_EVENT_TABLE() - - // This class must be something just like a panel... - WX_DECLARE_CONTROL_CONTAINER(); }; diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index d6af2b0aa1..bf8123e5ab 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -157,7 +157,8 @@ enum // wxTopLevelWindow: a top level (as opposed to child) window // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTopLevelWindowBase : public wxNonOwnedWindow +class WXDLLIMPEXP_CORE wxTopLevelWindowBase : + public wxNavigationEnabled { public: // construction @@ -352,7 +353,6 @@ protected: wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowBase); DECLARE_EVENT_TABLE() - WX_DECLARE_CONTROL_CONTAINER(); }; diff --git a/interface/wx/event.h b/interface/wx/event.h index 2352752d10..06939b2889 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -3497,8 +3497,8 @@ public: This event is mainly used by wxWidgets implementations. A wxNavigationKeyEvent handler is automatically provided by wxWidgets - when you make a class into a control container with the macro - WX_DECLARE_CONTROL_CONTAINER. + when you enable keyboard navigation inside a window by inheriting it from + wxNavigationEnabled<>. @beginEventTable{wxNavigationKeyEvent} @event{EVT_NAVIGATION_KEY(func)} diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 961c45756b..0b7dfad98b 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -2860,18 +2860,9 @@ BEGIN_EVENT_TABLE(wxAuiNotebook, wxControl) wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, wxAuiNotebook::OnTabBgDClick) EVT_NAVIGATION_KEY(wxAuiNotebook::OnNavigationKeyNotebook) - -#ifdef wxHAS_NATIVE_TAB_TRAVERSAL - WX_EVENT_TABLE_CONTROL_CONTAINER(wxAuiNotebook) -#else - // Avoid clash with container event handler functions - EVT_SET_FOCUS(wxAuiNotebook::OnFocus) -#endif END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxAuiNotebook, wxControl) - -wxAuiNotebook::wxAuiNotebook() +void wxAuiNotebook::Init() { m_curpage = -1; m_tab_id_counter = wxAuiBaseTabCtrlId; @@ -2881,18 +2872,6 @@ wxAuiNotebook::wxAuiNotebook() m_requested_tabctrl_height = -1; } -wxAuiNotebook::wxAuiNotebook(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style) : wxControl(parent, id, pos, size, style) -{ - m_dummy_wnd = NULL; - m_requested_bmp_size = wxDefaultSize; - m_requested_tabctrl_height = -1; - InitNotebook(style); -} - bool wxAuiNotebook::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, @@ -2911,9 +2890,6 @@ bool wxAuiNotebook::Create(wxWindow* parent, // code called by all constructors void wxAuiNotebook::InitNotebook(long style) { - WX_INIT_CONTROL_CONTAINER(); - // SetCanFocus(false); - SetName(wxT("wxAuiNotebook")); m_curpage = -1; m_tab_id_counter = wxAuiBaseTabCtrlId; diff --git a/src/common/panelcmn.cpp b/src/common/panelcmn.cpp index a800434b5e..cdc191a7af 100644 --- a/src/common/panelcmn.cpp +++ b/src/common/panelcmn.cpp @@ -85,29 +85,14 @@ wxCONSTRUCTOR_6( wxPanel, wxWindow*, Parent, wxWindowID, Id, \ wxString, Name) -// ---------------------------------------------------------------------------- -// wxWin macros -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxPanelBase, wxWindow) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanelBase) -END_EVENT_TABLE() - // ============================================================================ // implementation // ============================================================================ -WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanelBase, wxWindow) - // ---------------------------------------------------------------------------- // wxPanelBase creation // ---------------------------------------------------------------------------- -wxPanelBase::wxPanelBase() -{ - WX_INIT_CONTROL_CONTAINER(); -} - bool wxPanelBase::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, diff --git a/src/common/pickerbase.cpp b/src/common/pickerbase.cpp index ce17ad7da8..43215b3cfe 100644 --- a/src/common/pickerbase.cpp +++ b/src/common/pickerbase.cpp @@ -45,9 +45,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxPickerBase, wxControl) BEGIN_EVENT_TABLE(wxPickerBase, wxControl) EVT_SIZE(wxPickerBase::OnSize) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxPickerBase) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxPickerBase, wxControl) // ---------------------------------------------------------------------------- diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 5d452fab3d..1ce788ef1f 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -39,11 +39,8 @@ BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow) EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow) EVT_SIZE(wxTopLevelWindowBase::OnSize) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxTopLevelWindowBase) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxTopLevelWindowBase, wxWindow) - // ============================================================================ // implementation // ============================================================================ @@ -58,8 +55,6 @@ wxTopLevelWindowBase::wxTopLevelWindowBase() { // Unlike windows, top level windows are created hidden by default. m_isShown = false; - - WX_INIT_CONTROL_CONTAINER(); } wxTopLevelWindowBase::~wxTopLevelWindowBase() diff --git a/src/generic/collpaneg.cpp b/src/generic/collpaneg.cpp index a0371ad191..dc9874f98c 100644 --- a/src/generic/collpaneg.cpp +++ b/src/generic/collpaneg.cpp @@ -57,16 +57,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneEvent, wxCommandEvent) BEGIN_EVENT_TABLE(wxGenericCollapsiblePane, wxControl) EVT_BUTTON(wxID_ANY, wxGenericCollapsiblePane::OnButton) EVT_SIZE(wxGenericCollapsiblePane::OnSize) - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxGenericCollapsiblePane) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxGenericCollapsiblePane, wxControl) - void wxGenericCollapsiblePane::Init() { - WX_INIT_CONTROL_CONTAINER(); - m_pButton = NULL; m_pPane = NULL; m_pStaticLine = NULL; diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index b0c6dead72..03abc8baa5 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -66,12 +66,8 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow) #if defined( __WXMSW__ ) || defined( __WXMAC__) EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor) #endif // wxMSW - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow, wxWindow) - static bool IsLive(wxSplitterWindow* wnd) { // with wxSP_LIVE_UPDATE style the splitter windows are always resized @@ -117,8 +113,6 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, void wxSplitterWindow::Init() { - WX_INIT_CONTROL_CONTAINER(); - m_splitMode = wxSPLIT_VERTICAL; m_permitUnsplitAlways = true; m_windowOne = NULL; diff --git a/src/osx/carbon/combobox.cpp b/src/osx/carbon/combobox.cpp index 2662bb8bd0..387f7402a5 100644 --- a/src/osx/carbon/combobox.cpp +++ b/src/osx/carbon/combobox.cpp @@ -25,13 +25,6 @@ #include "wx/osx/private.h" -WX_DELEGATE_TO_CONTROL_CONTAINER(wxComboBox, wxControl) - -BEGIN_EVENT_TABLE(wxComboBox, wxControl) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxComboBox) -END_EVENT_TABLE() - - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -318,11 +311,6 @@ void wxComboBox::DelegateChoice( const wxString& value ) SetStringSelection( value ); } -void wxComboBox::Init() -{ - WX_INIT_CONTROL_CONTAINER(); -} - bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, diff --git a/src/osx/spinctrl_osx.cpp b/src/osx/spinctrl_osx.cpp index 7d207e68eb..cace5fd4e6 100644 --- a/src/osx/spinctrl_osx.cpp +++ b/src/osx/spinctrl_osx.cpp @@ -196,13 +196,6 @@ BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton) EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton) END_EVENT_TABLE() -BEGIN_EVENT_TABLE(wxSpinCtrl, wxControl) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxSpinCtrl) -END_EVENT_TABLE() - -WX_DELEGATE_TO_CONTROL_CONTAINER(wxSpinCtrl, wxControl) - - // ============================================================================ // implementation // ============================================================================ @@ -215,7 +208,6 @@ void wxSpinCtrl::Init() { m_text = NULL; m_btn = NULL; - WX_INIT_CONTROL_CONTAINER(); } bool wxSpinCtrl::Create(wxWindow *parent, -- 2.47.2