X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..cbe6a493b66ad18b6a1f490589f2706f0f841b01:/src/common/ctrlsub.cpp?ds=sidebyside diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp index d668d66503..7f35cfa947 100644 --- a/src/common/ctrlsub.cpp +++ b/src/common/ctrlsub.cpp @@ -123,7 +123,7 @@ void wxItemContainer::Delete(unsigned int pos) } // ---------------------------------------------------------------------------- -// +// // ---------------------------------------------------------------------------- int wxItemContainer::DoInsertItemsInLoop(const wxArrayStringsAdapter& items, @@ -165,6 +165,8 @@ void wxItemContainer::SetClientObject(unsigned int n, wxClientData *data) wxASSERT_MSG( !HasClientUntypedData(), wxT("can't have both object and void client data") ); + wxCHECK_RET( IsValid(n), "Invalid index passed to SetClientObject()" ); + if ( HasClientObjectData() ) { wxClientData * clientDataOld @@ -188,9 +190,24 @@ wxClientData *wxItemContainer::GetClientObject(unsigned int n) const wxCHECK_MSG( HasClientObjectData(), NULL, wxT("this window doesn't have object client data") ); + wxCHECK_MSG( IsValid(n), NULL, + "Invalid index passed to GetClientObject()" ); + return static_cast(DoGetItemClientData(n)); } +wxClientData *wxItemContainer::DetachClientObject(unsigned int n) +{ + wxClientData * const data = GetClientObject(n); + if ( data ) + { + // reset the pointer as we don't own it any more + DoSetItemClientData(n, NULL); + } + + return data; +} + void wxItemContainer::SetClientData(unsigned int n, void *data) { if ( !HasClientData() ) @@ -202,6 +219,8 @@ void wxItemContainer::SetClientData(unsigned int n, void *data) wxASSERT_MSG( HasClientUntypedData(), wxT("can't have both object and void client data") ); + wxCHECK_RET( IsValid(n), "Invalid index passed to SetClientData()" ); + DoSetItemClientData(n, data); } @@ -210,6 +229,9 @@ void *wxItemContainer::GetClientData(unsigned int n) const wxCHECK_MSG( HasClientUntypedData(), NULL, wxT("this window doesn't have void client data") ); + wxCHECK_MSG( IsValid(n), NULL, + "Invalid index passed to GetClientData()" ); + return DoGetItemClientData(n); } @@ -270,4 +292,19 @@ wxControlWithItemsBase::InitCommandEventWithItems(wxCommandEvent& event, int n) } } +void wxControlWithItemsBase::SendSelectionChangedEvent(wxEventType eventType) +{ + const int n = GetSelection(); + if ( n == wxNOT_FOUND ) + return; + + wxCommandEvent event(eventType, m_windowId); + event.SetInt(n); + event.SetEventObject(this); + event.SetString(GetStringSelection()); + InitCommandEventWithItems(event, n); + + HandleWindowEvent(event); +} + #endif // wxUSE_CONTROLS