X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/105fbe1ffa8968cb85fd2cac7192957e522d17ba..3c0f8ed2509f8b6e806af093f1b5041c61649da1:/src/motif/combobox.cpp?ds=sidebyside diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index 201a8aa4ad..4083a88ebd 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -111,8 +111,6 @@ wxComboBox::~wxComboBox() DetachWidget((Widget) m_mainWidget); // Removes event handlers XtDestroyWidget((Widget) m_mainWidget); m_mainWidget = (WXWidget) 0; - if ( HasClientObjectData() ) - m_clientDataDict.DestroyData(); } void wxComboBox::DoSetSize(int x, int y, @@ -138,11 +136,12 @@ wxString wxComboBox::GetValue() const void wxComboBox::SetValue(const wxString& value) { - m_inSetValue = true; if( !value.empty() ) - XmComboBoxSetString( (Widget)m_mainWidget, - wxConstCast(value.c_str(), char) ); - m_inSetValue = false; + { + m_inSetValue = true; + XmComboBoxSetString((Widget)m_mainWidget, value.char_str()); + m_inSetValue = false; + } } void wxComboBox::SetString(unsigned int WXUNUSED(n), const wxString& WXUNUSED(s)) @@ -150,34 +149,29 @@ void wxComboBox::SetString(unsigned int WXUNUSED(n), const wxString& WXUNUSED(s) wxFAIL_MSG( wxT("wxComboBox::SetString only implemented for Motif 2.0") ); } -int wxComboBox::DoAppend(const wxString& item) +// TODO auto-sorting is not supported by the code +int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items, + unsigned int pos, + void **clientData, + wxClientDataType type) { - wxXmString str( item.c_str() ); - XmComboBoxAddItem((Widget) m_mainWidget, str(), 0); - m_stringList.Add(item); - m_noStrings ++; + const unsigned int numItems = items.GetCount(); - return GetCount() - 1; -} - -int wxComboBox::DoInsert(const wxString& item, unsigned int pos) -{ - wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); - wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index")); - - if (pos == GetCount()) - return DoAppend(item); - - wxXmString str( item.c_str() ); - XmComboBoxAddItem((Widget) m_mainWidget, str(), pos+1); - wxChar* copy = wxStrcpy(new wxChar[item.length() + 1], item.c_str()); - m_stringList.Insert(pos, copy); - m_noStrings ++; + AllocClientData(numItems); + for( unsigned int i = 0; i < numItems; ++i, ++pos ) + { + wxXmString str( items[i].c_str() ); + XmComboBoxAddItem((Widget) m_mainWidget, str(), GetMotifPosition(pos)); + wxChar* copy = wxStrcpy(new wxChar[items[i].length() + 1], items[i].c_str()); + m_stringList.Insert(pos, copy); + m_noStrings ++; + InsertNewItemClientData(pos, clientData, i, type); + } - return pos; + return pos - 1; } -void wxComboBox::Delete(unsigned int n) +void wxComboBox::DoDeleteOneItem(unsigned int n) { XmComboBoxDeletePos((Widget) m_mainWidget, n+1); wxStringList::Node *node = m_stringList.Item(n); @@ -186,17 +180,16 @@ void wxComboBox::Delete(unsigned int n) delete[] node->GetData(); delete node; } - m_clientDataDict.Delete(n, HasClientObjectData()); + wxControlWithItems::DoDeleteOneItem(n); m_noStrings--; } -void wxComboBox::Clear() +void wxComboBox::DoClear() { XmComboBoxDeleteAllItems((Widget) m_mainWidget); m_stringList.Clear(); - if ( HasClientObjectData() ) - m_clientDataDict.DestroyData(); + wxControlWithItems::DoClear(); m_noStrings = 0; } @@ -289,7 +282,7 @@ void wxComboBox::Replace(long from, long to, const wxString& value) { XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to, - wxConstCast(value.c_str(), char)); + value.char_str()); } void wxComboBox::Remove(long from, long to)