Get rid of ugly wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST macro.
Replace it with wxWindowWithItems<> template class which takes care of disambiguating between the two inherited Get/SetClientXXX() versions and use it as a base class in all clases that previously used the macro. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68460 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -395,41 +395,48 @@ private:
|
||||
wxClientDataType m_clientDataItemsType;
|
||||
};
|
||||
|
||||
// this macro must (unfortunately) be used in any class deriving from both
|
||||
// wxItemContainer and wxControl because otherwise there is ambiguity when
|
||||
// calling GetClientXXX() functions -- the compiler can't choose between the
|
||||
// two versions
|
||||
#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \
|
||||
void SetClientData(void *data) \
|
||||
{ wxEvtHandler::SetClientData(data); } \
|
||||
void *GetClientData() const \
|
||||
{ return wxEvtHandler::GetClientData(); } \
|
||||
void SetClientObject(wxClientData *data) \
|
||||
{ wxEvtHandler::SetClientObject(data); } \
|
||||
wxClientData *GetClientObject() const \
|
||||
{ return wxEvtHandler::GetClientObject(); } \
|
||||
void SetClientData(unsigned int n, void* clientData) \
|
||||
{ wxItemContainer::SetClientData(n, clientData); } \
|
||||
void* GetClientData(unsigned int n) const \
|
||||
{ return wxItemContainer::GetClientData(n); } \
|
||||
void SetClientObject(unsigned int n, wxClientData* clientData) \
|
||||
{ wxItemContainer::SetClientObject(n, clientData); } \
|
||||
wxClientData* GetClientObject(unsigned int n) const \
|
||||
{ return wxItemContainer::GetClientObject(n); }
|
||||
// Inheriting directly from a wxWindow-derived class and wxItemContainer
|
||||
// unfortunately introduces an ambiguity for all GetClientXXX() methods as they
|
||||
// are inherited twice: the "global" versions from wxWindow and the per-item
|
||||
// versions taking the index from wxItemContainer.
|
||||
//
|
||||
// So we need to explicitly resolve them and this helper template class is
|
||||
// provided to do it. To use it, simply inherit from wxWindowWithItems<Window,
|
||||
// Container> instead of Window and Container interface directly.
|
||||
template <class W, class C>
|
||||
class wxWindowWithItems : public W, public C
|
||||
{
|
||||
public:
|
||||
typedef W BaseWindowClass;
|
||||
typedef C BaseContainerInterface;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxControlWithItemsBase : public wxControl,
|
||||
public wxItemContainer
|
||||
wxWindowWithItems() { }
|
||||
|
||||
void SetClientData(void *data)
|
||||
{ BaseWindowClass::SetClientData(data); }
|
||||
void *GetClientData() const
|
||||
{ return BaseWindowClass::GetClientData(); }
|
||||
void SetClientObject(wxClientData *data)
|
||||
{ BaseWindowClass::SetClientObject(data); }
|
||||
wxClientData *GetClientObject() const
|
||||
{ return BaseWindowClass::GetClientObject(); }
|
||||
|
||||
void SetClientData(unsigned int n, void* clientData)
|
||||
{ wxItemContainer::SetClientData(n, clientData); }
|
||||
void* GetClientData(unsigned int n) const
|
||||
{ return wxItemContainer::GetClientData(n); }
|
||||
void SetClientObject(unsigned int n, wxClientData* clientData)
|
||||
{ wxItemContainer::SetClientObject(n, clientData); }
|
||||
wxClientData* GetClientObject(unsigned int n) const
|
||||
{ return wxItemContainer::GetClientObject(n); }
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_CORE wxControlWithItemsBase :
|
||||
public wxWindowWithItems<wxControl, wxItemContainer>
|
||||
{
|
||||
public:
|
||||
wxControlWithItemsBase() { }
|
||||
|
||||
// we have to redefine these functions here to avoid ambiguities in classes
|
||||
// deriving from us which would arise otherwise because both base classses
|
||||
// have the methods with the same names - hopefully, a smart compiler can
|
||||
// optimize away these simple inline wrappers so we don't suffer much from
|
||||
// this
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
// usually the controls like list/combo boxes have their own background
|
||||
// colour
|
||||
virtual bool ShouldInheritColours() const { return false; }
|
||||
|
@@ -34,7 +34,8 @@ extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString;
|
||||
// wxComboBox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
|
||||
class WXDLLIMPEXP_CORE wxComboBox :
|
||||
public wxWindowWithItems<wxControl, wxComboBoxBase>
|
||||
{
|
||||
public:
|
||||
inline wxComboBox() {}
|
||||
@@ -154,8 +155,6 @@ public:
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
|
||||
|
@@ -196,8 +196,8 @@ private:
|
||||
#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN
|
||||
#define wxHLB_MULTIPLE wxLB_MULTIPLE
|
||||
|
||||
class WXDLLIMPEXP_HTML wxSimpleHtmlListBox : public wxHtmlListBox,
|
||||
public wxItemContainer
|
||||
class WXDLLIMPEXP_HTML wxSimpleHtmlListBox :
|
||||
public wxWindowWithItems<wxHtmlListBox, wxItemContainer>
|
||||
{
|
||||
DECLARE_ABSTRACT_CLASS(wxSimpleHtmlListBox)
|
||||
public:
|
||||
@@ -254,9 +254,6 @@ public:
|
||||
int GetSelection() const
|
||||
{ return wxVListBox::GetSelection(); }
|
||||
|
||||
// see ctrlsub.h for more info about this:
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
|
||||
// accessing strings
|
||||
// -----------------
|
||||
|
@@ -233,15 +233,15 @@ private:
|
||||
// the wxComboCtrl.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox : public wxComboCtrl,
|
||||
public wxItemContainer
|
||||
class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox :
|
||||
public wxWindowWithItems<wxComboCtrl, wxItemContainer>
|
||||
{
|
||||
//friend class wxComboPopupWindow;
|
||||
friend class wxVListBoxComboPopup;
|
||||
public:
|
||||
|
||||
// ctors and such
|
||||
wxOwnerDrawnComboBox() : wxComboCtrl() { Init(); }
|
||||
wxOwnerDrawnComboBox() { Init(); }
|
||||
|
||||
wxOwnerDrawnComboBox(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@@ -253,7 +253,6 @@ public:
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxComboBoxNameStr)
|
||||
: wxComboCtrl()
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -339,8 +338,6 @@ public:
|
||||
|
||||
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
protected:
|
||||
virtual void DoClear();
|
||||
virtual void DoDeleteOneItem(unsigned int n);
|
||||
|
@@ -26,12 +26,13 @@ class wxComboWidgetImpl;
|
||||
|
||||
// Combobox item
|
||||
class WXDLLIMPEXP_CORE wxComboBox :
|
||||
public wxWindowWithItems<
|
||||
#if wxOSX_USE_CARBON
|
||||
public wxNavigationEnabled<wxControl>,
|
||||
wxNavigationEnabled<wxControl>,
|
||||
#else
|
||||
public wxControl,
|
||||
wxControl,
|
||||
#endif
|
||||
public wxComboBoxBase
|
||||
wxComboBoxBase>
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
|
||||
@@ -144,8 +145,6 @@ class WXDLLIMPEXP_CORE wxComboBox :
|
||||
|
||||
virtual bool OSXHandleClicked( double timestampsec );
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
wxComboWidgetImpl* GetComboPeer() const;
|
||||
#endif
|
||||
|
@@ -34,7 +34,8 @@ class WXDLLIMPEXP_FWD_CORE wxListBox;
|
||||
// NB: Normally we'd like wxComboBox to inherit from wxComboBoxBase, but here
|
||||
// we can't really do that since both wxComboBoxBase and wxComboCtrl inherit
|
||||
// from wxTextCtrl.
|
||||
class WXDLLIMPEXP_CORE wxComboBox : public wxComboCtrl, public wxItemContainer
|
||||
class WXDLLIMPEXP_CORE wxComboBox :
|
||||
public wxWindowWithItems<wxComboCtrl, wxItemContainer>
|
||||
{
|
||||
public:
|
||||
// ctors and such
|
||||
@@ -141,8 +142,6 @@ public:
|
||||
virtual int GetSelection() const;
|
||||
virtual wxString GetStringSelection() const;
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
// we have our own input handler and our own actions
|
||||
// (but wxComboCtrl already handled Popup/Dismiss)
|
||||
/*
|
||||
|
@@ -902,7 +902,6 @@ wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
: wxComboCtrl()
|
||||
{
|
||||
Init();
|
||||
|
||||
|
Reference in New Issue
Block a user