void wxChoice::SetString(unsigned int n, const wxString& rsStr) { LONG nIndexType = 0; void* pData; if ( HasClientData() ) { pData = DoGetItemClientData(n); } else // no client data { pData = NULL; } ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)n, 0); if (m_windowStyle & wxCB_SORT) nIndexType = LIT_SORTASCENDING; else nIndexType = LIT_END; ::WinSendMsg( GetHwnd() ,LM_INSERTITEM ,(MPARAM)nIndexType ,(MPARAM)rsStr.wx_str() ); if (pData) { DoSetItemClientData(n, pData); } } // end of wxChoice::SetString
void wxChoice::SetString(int n, const wxString& s) { wxCHECK_RET( n >= 0 && n < GetCount(), wxT("invalid item index in wxChoice::SetString") ); // we have to delete and add back the string as there is no way to change a // string in place // we need to preserve the client data void *data; if ( m_clientDataItemsType != wxClientData_None ) { data = DoGetItemClientData(n); } else // no client data { data = NULL; } ::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.c_str() ); if ( data ) { DoSetItemClientData(n, data); } //else: it's already NULL by default InvalidateBestSize(); }
// ---------------------------------------------------------------------------- // adding/deleting items to/from the list // ---------------------------------------------------------------------------- int wxChoice::DoAppend(const wxString& item) { #if wxUSE_STL wxArrayString::iterator insertPoint; size_t index; if (GetWindowStyle() & wxCB_SORT) { insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), item ); index = insertPoint - m_strings.begin(); } else { insertPoint = m_strings.end(); index = m_strings.size(); } m_strings.insert( insertPoint, item ); #else size_t index = m_strings.Add( item ) ; #endif m_datas.Insert( NULL , index ) ; UMAInsertMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() , index ); DoSetItemClientData( index , NULL ) ; m_peer->SetMaximum( GetCount() ) ; return index ; }
void wxItemContainer::SetClientData(int n, void *data) { wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, wxT("can't have both object and void client data") ); DoSetItemClientData(n, data); m_clientDataItemsType = wxClientData_Void; }
void wxChoice::DoSetItemClientObject( int n , wxClientData* pClientData ) { DoSetItemClientData( n ,pClientData ); } // end of wxChoice::DoSetItemClientObject
void wxItemContainer::ResetItemClientObject(unsigned int n) { wxClientData * const data = GetClientObject(n); if ( data ) { delete data; DoSetItemClientData(n, NULL); } }
void wxListBox::DoSetItemClientObject( int n , wxClientData* pClientData ) { DoSetItemClientData( n ,pClientData ); } // end of wxListBox::DoSetItemClientObject
void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData) { ListView_SetItemCount( GetHwnd(), GetCount() + items.GetCount() ); for( unsigned int i = 0; i < items.GetCount(); i++ ) { int pos = Append(items[i]); if( pos >= 0 && clientData ) DoSetItemClientData(pos, clientData[i]); } }
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() ) { DoInitItemClientData(); SetClientDataType(wxClientData_Void); } wxASSERT_MSG( HasClientUntypedData(), wxT("can't have both object and void client data") ); DoSetItemClientData(n, data); }
int wxListBox::DoAppend(const wxString& item) { InvalidateBestSize(); unsigned int index = m_noItems ; m_stringArray.Add( item ) ; m_dataArray.Add( NULL ); m_noItems ++; DoSetItemClientData( index , NULL ) ; MacAppend( item ) ; return index ; }
void wxItemContainer::SetClientData(unsigned int n, void *data) { if ( !HasClientData() ) { DoInitItemClientData(); SetClientDataType(wxClientData_Void); } 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); }
int wxChoice::DoInsert(const wxString& item, int pos) { wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index")); if (pos == GetCount()) return DoAppend(item); UMAInsertMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() , pos ); m_strings.Insert( item, pos ) ; m_datas.Insert( NULL, pos ) ; DoSetItemClientData( pos , NULL ) ; m_peer->SetMaximum( GetCount() ) ; return pos ; }
void wxItemContainer::SetClientObject(unsigned int n, wxClientData *data) { wxASSERT_MSG( !HasClientUntypedData(), wxT("can't have both object and void client data") ); if ( HasClientObjectData() ) { wxClientData * clientDataOld = static_cast<wxClientData *>(DoGetItemClientData(n)); if ( clientDataOld ) delete clientDataOld; } else // didn't have any client data so far { // now we have object client data DoInitItemClientData(); SetClientDataType(wxClientData_Object); } DoSetItemClientData(n, data); }
void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData) { DoSetItemClientData(n, clientData); }
void wxOwnerDrawnComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData) { DoSetItemClientData(n, (void*) clientData); }
void wxListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData) { DoSetItemClientData(n, clientData); }