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
This commit is contained in:
Vadim Zeitlin
2011-07-24 22:19:33 +00:00
parent 7e0a200b08
commit 9023040798
17 changed files with 31 additions and 122 deletions

View File

@@ -502,18 +502,22 @@ protected:
class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl class WXDLLIMPEXP_AUI wxAuiNotebook : public wxNavigationEnabled<wxControl>
{ {
public: public:
wxAuiNotebook(); wxAuiNotebook() { Init(); }
wxAuiNotebook(wxWindow* parent, wxAuiNotebook(wxWindow* parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, 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(); virtual ~wxAuiNotebook();
@@ -595,6 +599,9 @@ public:
virtual void Thaw(); virtual void Thaw();
protected: protected:
// Common part of all ctors.
void Init();
// choose the default border for this window // choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
@@ -665,9 +672,6 @@ protected:
DECLARE_CLASS(wxAuiNotebook) DECLARE_CLASS(wxAuiNotebook)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
#endif #endif
WX_DECLARE_CONTROL_CONTAINER();
}; };

View File

@@ -25,7 +25,8 @@ class WXDLLIMPEXP_FWD_CORE wxDisclosureTriangle;
// wxGenericCollapsiblePane // wxGenericCollapsiblePane
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : public wxCollapsiblePaneBase class WXDLLIMPEXP_CORE wxGenericCollapsiblePane :
public wxNavigationEnabled<wxCollapsiblePaneBase>
{ {
public: public:
wxGenericCollapsiblePane() { Init(); } wxGenericCollapsiblePane() { Init(); }
@@ -103,7 +104,6 @@ private:
void OnButton(wxCommandEvent &ev); void OnButton(wxCommandEvent &ev);
void OnSize(wxSizeEvent &ev); void OnSize(wxSizeEvent &ev);
WX_DECLARE_CONTROL_CONTAINER();
DECLARE_DYNAMIC_CLASS(wxGenericCollapsiblePane) DECLARE_DYNAMIC_CLASS(wxGenericCollapsiblePane)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -49,7 +49,7 @@ enum
// to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be // to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be
// standard). // standard).
class WXDLLIMPEXP_CORE wxSplitterWindow: public wxWindow class WXDLLIMPEXP_CORE wxSplitterWindow: public wxNavigationEnabled<wxWindow>
{ {
public: public:
@@ -300,8 +300,6 @@ protected:
bool m_checkRequestedSashPosition:1; bool m_checkRequestedSashPosition:1;
private: private:
WX_DECLARE_CONTROL_CONTAINER();
DECLARE_DYNAMIC_CLASS(wxSplitterWindow) DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxSplitterWindow); wxDECLARE_NO_COPY_CLASS(wxSplitterWindow);

View File

@@ -25,7 +25,13 @@ class wxComboBoxChoice;
class wxComboWidgetImpl; class wxComboWidgetImpl;
// Combobox item // Combobox item
class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase class WXDLLIMPEXP_CORE wxComboBox :
#if wxOSX_USE_CARBON
public wxNavigationEnabled<wxControl>,
#else
public wxControl,
#endif
public wxComboBoxBase
{ {
DECLARE_DYNAMIC_CLASS(wxComboBox) DECLARE_DYNAMIC_CLASS(wxComboBox)
@@ -42,7 +48,7 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
virtual void DelegateTextChanged( const wxString& value ); virtual void DelegateTextChanged( const wxString& value );
virtual void DelegateChoice( const wxString& value ); virtual void DelegateChoice( const wxString& value );
wxComboBox() { Init(); } wxComboBox() { }
wxComboBox(wxWindow *parent, wxWindowID id, wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
@@ -53,7 +59,6 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr) const wxString& name = wxComboBoxNameStr)
{ {
Init();
Create(parent, id, value, pos, size, n, choices, style, validator, name); 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 wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr) const wxString& name = wxComboBoxNameStr)
{ {
Init();
Create(parent, id, value, pos, size, choices, style, validator, name); 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 #if wxOSX_USE_CARBON
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
WX_DECLARE_CONTROL_CONTAINER();
#endif #endif
#if wxOSX_USE_COCOA #if wxOSX_USE_COCOA
wxComboWidgetImpl* GetComboPeer() const; wxComboWidgetImpl* GetComboPeer() const;
#endif #endif
protected: protected:
// common part of all ctors
void Init();
// List functions // List functions
virtual void DoDeleteOneItem(unsigned int n); virtual void DoDeleteOneItem(unsigned int n);
virtual void DoClear(); virtual void DoClear();
@@ -187,10 +186,6 @@ protected:
wxComboBoxChoice* m_choice; wxComboBoxChoice* m_choice;
wxComboBoxDataArray m_datas; wxComboBoxDataArray m_datas;
#if wxOSX_USE_CARBON
DECLARE_EVENT_TABLE()
#endif
}; };
#endif // _WX_COMBOBOX_H_ #endif // _WX_COMBOBOX_H_

View File

@@ -33,7 +33,7 @@ class WXDLLIMPEXP_FWD_CORE wxSpinCtrlButton;
// wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton // wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxControl class WXDLLIMPEXP_CORE wxSpinCtrl : public wxNavigationEnabled<wxControl>
{ {
public: public:
wxSpinCtrl() { Init(); } wxSpinCtrl() { Init(); }
@@ -93,8 +93,6 @@ public:
// number is out of range // number is out of range
bool GetTextValue(int *val) const; bool GetTextValue(int *val) const;
WX_DECLARE_CONTROL_CONTAINER();
protected: protected:
// override the base class virtuals involved into geometry calculations // override the base class virtuals involved into geometry calculations
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
@@ -113,7 +111,6 @@ private:
int m_oldValue; int m_oldValue;
private: private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxSpinCtrl) DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
}; };

View File

@@ -28,10 +28,10 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[];
// wxPanel contains other controls and implements TAB traversal between them // wxPanel contains other controls and implements TAB traversal between them
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPanelBase : public wxWindow class WXDLLIMPEXP_CORE wxPanelBase : public wxNavigationEnabled<wxWindow>
{ {
public: public:
wxPanelBase(); wxPanelBase() { }
// Derived classes should also provide this constructor: // Derived classes should also provide this constructor:
/* /*
@@ -69,14 +69,10 @@ public:
virtual void InitDialog(); virtual void InitDialog();
WX_DECLARE_CONTROL_CONTAINER();
protected: protected:
virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) = 0; virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) = 0;
private: private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxPanelBase); wxDECLARE_NO_COPY_CLASS(wxPanelBase);
}; };

View File

@@ -32,12 +32,12 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[];
#define wxPB_USE_TEXTCTRL 0x0002 #define wxPB_USE_TEXTCTRL 0x0002
class WXDLLIMPEXP_CORE wxPickerBase : public wxControl class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled<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)
{ WX_INIT_CONTROL_CONTAINER(); } { }
virtual ~wxPickerBase() {} virtual ~wxPickerBase() {}
@@ -179,9 +179,6 @@ protected:
private: private:
DECLARE_ABSTRACT_CLASS(wxPickerBase) DECLARE_ABSTRACT_CLASS(wxPickerBase)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
// This class must be something just like a panel...
WX_DECLARE_CONTROL_CONTAINER();
}; };

View File

@@ -157,7 +157,8 @@ enum
// wxTopLevelWindow: a top level (as opposed to child) window // wxTopLevelWindow: a top level (as opposed to child) window
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxTopLevelWindowBase : public wxNonOwnedWindow class WXDLLIMPEXP_CORE wxTopLevelWindowBase :
public wxNavigationEnabled<wxNonOwnedWindow>
{ {
public: public:
// construction // construction
@@ -352,7 +353,6 @@ protected:
wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowBase); wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowBase);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
WX_DECLARE_CONTROL_CONTAINER();
}; };

View File

@@ -3497,8 +3497,8 @@ public:
This event is mainly used by wxWidgets implementations. This event is mainly used by wxWidgets implementations.
A wxNavigationKeyEvent handler is automatically provided by wxWidgets A wxNavigationKeyEvent handler is automatically provided by wxWidgets
when you make a class into a control container with the macro when you enable keyboard navigation inside a window by inheriting it from
WX_DECLARE_CONTROL_CONTAINER. wxNavigationEnabled<>.
@beginEventTable{wxNavigationKeyEvent} @beginEventTable{wxNavigationKeyEvent}
@event{EVT_NAVIGATION_KEY(func)} @event{EVT_NAVIGATION_KEY(func)}

View File

@@ -2860,18 +2860,9 @@ BEGIN_EVENT_TABLE(wxAuiNotebook, wxControl)
wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK,
wxAuiNotebook::OnTabBgDClick) wxAuiNotebook::OnTabBgDClick)
EVT_NAVIGATION_KEY(wxAuiNotebook::OnNavigationKeyNotebook) 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() END_EVENT_TABLE()
WX_DELEGATE_TO_CONTROL_CONTAINER(wxAuiNotebook, wxControl) void wxAuiNotebook::Init()
wxAuiNotebook::wxAuiNotebook()
{ {
m_curpage = -1; m_curpage = -1;
m_tab_id_counter = wxAuiBaseTabCtrlId; m_tab_id_counter = wxAuiBaseTabCtrlId;
@@ -2881,18 +2872,6 @@ wxAuiNotebook::wxAuiNotebook()
m_requested_tabctrl_height = -1; 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, bool wxAuiNotebook::Create(wxWindow* parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
@@ -2911,9 +2890,6 @@ bool wxAuiNotebook::Create(wxWindow* parent,
// code called by all constructors // code called by all constructors
void wxAuiNotebook::InitNotebook(long style) void wxAuiNotebook::InitNotebook(long style)
{ {
WX_INIT_CONTROL_CONTAINER();
// SetCanFocus(false);
SetName(wxT("wxAuiNotebook")); SetName(wxT("wxAuiNotebook"));
m_curpage = -1; m_curpage = -1;
m_tab_id_counter = wxAuiBaseTabCtrlId; m_tab_id_counter = wxAuiBaseTabCtrlId;

View File

@@ -85,29 +85,14 @@ wxCONSTRUCTOR_6( wxPanel, wxWindow*, Parent, wxWindowID, Id, \
wxString, Name) wxString, Name)
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxPanelBase, wxWindow)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanelBase)
END_EVENT_TABLE()
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanelBase, wxWindow)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxPanelBase creation // wxPanelBase creation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxPanelBase::wxPanelBase()
{
WX_INIT_CONTROL_CONTAINER();
}
bool wxPanelBase::Create(wxWindow *parent, wxWindowID id, bool wxPanelBase::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,

View File

@@ -45,9 +45,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxPickerBase, wxControl)
BEGIN_EVENT_TABLE(wxPickerBase, wxControl) BEGIN_EVENT_TABLE(wxPickerBase, wxControl)
EVT_SIZE(wxPickerBase::OnSize) EVT_SIZE(wxPickerBase::OnSize)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxPickerBase)
END_EVENT_TABLE() END_EVENT_TABLE()
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPickerBase, wxControl)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -39,11 +39,8 @@
BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow) BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow) EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
EVT_SIZE(wxTopLevelWindowBase::OnSize) EVT_SIZE(wxTopLevelWindowBase::OnSize)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxTopLevelWindowBase)
END_EVENT_TABLE() END_EVENT_TABLE()
WX_DELEGATE_TO_CONTROL_CONTAINER(wxTopLevelWindowBase, wxWindow)
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -58,8 +55,6 @@ wxTopLevelWindowBase::wxTopLevelWindowBase()
{ {
// Unlike windows, top level windows are created hidden by default. // Unlike windows, top level windows are created hidden by default.
m_isShown = false; m_isShown = false;
WX_INIT_CONTROL_CONTAINER();
} }
wxTopLevelWindowBase::~wxTopLevelWindowBase() wxTopLevelWindowBase::~wxTopLevelWindowBase()

View File

@@ -57,16 +57,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneEvent, wxCommandEvent)
BEGIN_EVENT_TABLE(wxGenericCollapsiblePane, wxControl) BEGIN_EVENT_TABLE(wxGenericCollapsiblePane, wxControl)
EVT_BUTTON(wxID_ANY, wxGenericCollapsiblePane::OnButton) EVT_BUTTON(wxID_ANY, wxGenericCollapsiblePane::OnButton)
EVT_SIZE(wxGenericCollapsiblePane::OnSize) EVT_SIZE(wxGenericCollapsiblePane::OnSize)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxGenericCollapsiblePane)
END_EVENT_TABLE() END_EVENT_TABLE()
WX_DELEGATE_TO_CONTROL_CONTAINER(wxGenericCollapsiblePane, wxControl)
void wxGenericCollapsiblePane::Init() void wxGenericCollapsiblePane::Init()
{ {
WX_INIT_CONTROL_CONTAINER();
m_pButton = NULL; m_pButton = NULL;
m_pPane = NULL; m_pPane = NULL;
m_pStaticLine = NULL; m_pStaticLine = NULL;

View File

@@ -66,12 +66,8 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
#if defined( __WXMSW__ ) || defined( __WXMAC__) #if defined( __WXMSW__ ) || defined( __WXMAC__)
EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor) EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor)
#endif // wxMSW #endif // wxMSW
WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow, wxWindow)
static bool IsLive(wxSplitterWindow* wnd) static bool IsLive(wxSplitterWindow* wnd)
{ {
// with wxSP_LIVE_UPDATE style the splitter windows are always resized // 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() void wxSplitterWindow::Init()
{ {
WX_INIT_CONTROL_CONTAINER();
m_splitMode = wxSPLIT_VERTICAL; m_splitMode = wxSPLIT_VERTICAL;
m_permitUnsplitAlways = true; m_permitUnsplitAlways = true;
m_windowOne = NULL; m_windowOne = NULL;

View File

@@ -25,13 +25,6 @@
#include "wx/osx/private.h" #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 // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -318,11 +311,6 @@ void wxComboBox::DelegateChoice( const wxString& value )
SetStringSelection( value ); SetStringSelection( value );
} }
void wxComboBox::Init()
{
WX_INIT_CONTROL_CONTAINER();
}
bool wxComboBox::Create(wxWindow *parent, bool wxComboBox::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& value, const wxString& value,

View File

@@ -196,13 +196,6 @@ BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton)
EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton) EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton)
END_EVENT_TABLE() 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 // implementation
// ============================================================================ // ============================================================================
@@ -215,7 +208,6 @@ void wxSpinCtrl::Init()
{ {
m_text = NULL; m_text = NULL;
m_btn = NULL; m_btn = NULL;
WX_INIT_CONTROL_CONTAINER();
} }
bool wxSpinCtrl::Create(wxWindow *parent, bool wxSpinCtrl::Create(wxWindow *parent,