X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c8a980fc412792e64256724e02e9d387ee38e21..78500b7db1287068a04469e1ce92b4fe99e4e4f0:/src/common/ctrlsub.cpp?ds=sidebyside diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp index 09cff4de8e..1c7e18ea27 100644 --- a/src/common/ctrlsub.cpp +++ b/src/common/ctrlsub.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Name: common/ctrlsub.cpp -// Purpose: wxControlWithItems implementation +// Purpose: wxItemContainer implementation // Author: Vadim Zeitlin // Modified by: // Created: 22.10.99 @@ -28,6 +28,8 @@ #pragma hdrstop #endif +#if wxUSE_CONTROLS + #ifndef WX_PRECOMP #include "wx/ctrlsub.h" #endif @@ -36,11 +38,16 @@ // implementation // ============================================================================ +wxItemContainer::~wxItemContainer() +{ + // this destructor is required for Darwin +} + // ---------------------------------------------------------------------------- // selection // ---------------------------------------------------------------------------- -wxString wxControlWithItems::GetStringSelection() const +wxString wxItemContainer::GetStringSelection() const { wxString s; int sel = GetSelection(); @@ -54,41 +61,52 @@ wxString wxControlWithItems::GetStringSelection() const // client data // ---------------------------------------------------------------------------- -void wxControlWithItems::SetClientObject(int n, wxClientData *data) +void wxItemContainer::SetClientObject(int n, wxClientData *data) { - wxASSERT_MSG( m_clientDataItemsType != ClientData_Void, + wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, wxT("can't have both object and void client data") ); - wxClientData *clientDataOld = DoGetItemClientObject(n); - if ( clientDataOld ) - delete clientDataOld; + // when we call SetClientObject() for the first time, m_clientDataItemsType + // is still wxClientData_None and so calling DoGetItemClientObject() would + // fail (in addition to being useless) - don't do it + if ( m_clientDataItemsType == wxClientData_Object ) + { + wxClientData *clientDataOld = DoGetItemClientObject(n); + if ( clientDataOld ) + delete clientDataOld; + } + else // m_clientDataItemsType == wxClientData_None + { + // now we have object client data + m_clientDataItemsType = wxClientData_Object; + } DoSetItemClientObject(n, data); - m_clientDataItemsType = ClientData_Object; } -wxClientData *wxControlWithItems::GetClientObject(int n) const +wxClientData *wxItemContainer::GetClientObject(int n) const { - wxASSERT_MSG( m_clientDataItemsType == ClientData_Object, + wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object, wxT("this window doesn't have object client data") ); return DoGetItemClientObject(n); } -void wxControlWithItems::SetClientData(int n, void *data) +void wxItemContainer::SetClientData(int n, void *data) { - wxASSERT_MSG( m_clientDataItemsType != ClientData_Object, + wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, wxT("can't have both object and void client data") ); DoSetItemClientData(n, data); - m_clientDataItemsType = ClientData_Void; + m_clientDataItemsType = wxClientData_Void; } -void *wxControlWithItems::GetClientData(int n) const +void *wxItemContainer::GetClientData(int n) const { - wxASSERT_MSG( m_clientDataItemsType == ClientData_Void, + wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void, wxT("this window doesn't have void client data") ); return DoGetItemClientData(n); } +#endif // wxUSE_CONTROLS