X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/76c32e7b97bbd5d0c809dd59cba2926be016f7af..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/motif/combobox.cpp diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index f7326ad98c..aac9cc7e4e 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -38,8 +38,6 @@ void wxComboBoxCallback (Widget w, XtPointer clientData, XmComboBoxSelectionCallbackStruct * cbs); -IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) - bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -53,8 +51,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, return false; PreCreation(); - m_noStrings = n; - Widget parentWidget = (Widget) parent->GetClientWidget(); Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(), @@ -72,7 +68,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, { wxXmString str( choices[i] ); XmComboBoxAddItem(buttonWidget, str(), 0); - m_stringList.Add(choices[i]); + m_stringArray.Add(choices[i]); } m_mainWidget = (Widget) buttonWidget; @@ -165,9 +161,7 @@ int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items, { 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 ++; + m_stringArray.Insert(items[i], pos); InsertNewItemClientData(pos, clientData, i, type); } @@ -177,23 +171,16 @@ int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items, void wxComboBox::DoDeleteOneItem(unsigned int n) { XmComboBoxDeletePos((Widget) m_mainWidget, n+1); - wxStringList::Node *node = m_stringList.Item(n); - if (node) - { - delete[] node->GetData(); - delete node; - } + m_stringArray.RemoveAt(n); wxControlWithItems::DoDeleteOneItem(n); - m_noStrings--; } void wxComboBox::Clear() { XmComboBoxDeleteAllItems((Widget) m_mainWidget); - m_stringList.Clear(); + m_stringArray.Clear(); wxControlWithItems::DoClear(); - m_noStrings = 0; } void wxComboBox::SetSelection (int n) @@ -212,11 +199,7 @@ int wxComboBox::GetSelection (void) const wxString wxComboBox::GetString(unsigned int n) const { - wxStringList::Node *node = m_stringList.Item(n); - if (node) - return wxString(node->GetData ()); - else - return wxEmptyString; + return m_stringArray[n]; } int wxComboBox::FindString(const wxString& s, bool WXUNUSED(bCase)) const @@ -249,7 +232,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, case XmCR_SINGLE_SELECT: case XmCR_BROWSE_SELECT: { - wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, + wxCommandEvent event (wxEVT_COMBOBOX, item->GetId()); event.SetInt(cbs->index - 1); event.SetString( item->GetString ( event.GetInt() ) ); @@ -264,7 +247,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, } case XmCR_VALUE_CHANGED: { - wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId()); + wxCommandEvent event (wxEVT_TEXT, item->GetId()); event.SetInt(-1); event.SetString( item->GetValue() ); event.SetExtraLong(true);