X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/105fbe1ffa8968cb85fd2cac7192957e522d17ba..562e60a0f2ef165ab75c999eb8002d547c3585aa:/src/motif/combobox_native.cpp diff --git a/src/motif/combobox_native.cpp b/src/motif/combobox_native.cpp index 242a507bd9..1cadd49e94 100644 --- a/src/motif/combobox_native.cpp +++ b/src/motif/combobox_native.cpp @@ -161,8 +161,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, int width, int WXUNUSED(height), int sizeFlags) @@ -171,15 +169,6 @@ void wxComboBox::DoSetSize(int x, int y, int width, int WXUNUSED(height), int si wxWindow::DoSetSize(x, y, width, DoGetBestSize().y, sizeFlags); } -wxString wxComboBox::GetValue() const -{ - char* s = XmTextGetString (GetXmText (this)); - wxString str(s); - if (s) - XtFree (s); - return str; -} - void wxComboBox::SetString(unsigned int n, const wxString& s) { wxXmString text(s); @@ -196,39 +185,34 @@ void wxComboBox::SetValue(const wxString& value) m_inSetValue = true; XtVaSetValues( GetXmText(this), - XmNvalue, value.mb_str(), + XmNvalue, (const char*)value.mb_str(), NULL); m_inSetValue = false; } -int wxComboBox::DoAppend(const wxString& item) -{ - wxXmString str( item.c_str() ); - XmComboBoxAddItem((Widget) m_mainWidget, str(), 0, False); - m_noStrings ++; - AdjustDropDownListSize(); - - return GetCount() - 1; -} - -int wxComboBox::DoInsert(const wxString& item, unsigned int pos) +int wxComboBox::DoInsertItems(const wxArrayStringsAdapter & items, + unsigned int pos, + void **clientData, wxClientDataType type) { - wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); - wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index")); + const unsigned int numItems = items.GetCount(); - if (pos == GetCount()) - return DoAppend(item); + AllocClientData(numItems); + for ( unsigned int i = 0; i < numItems; ++i, ++pos ) + { + wxXmString str( items[i].c_str() ); + XmComboBoxAddItem((Widget) m_mainWidget, str(), + GetMotifPosition(pos), False); + m_noStrings ++; + InsertNewItemClientData(pos, clientData, i, type); + } - wxXmString str( item.c_str() ); - XmComboBoxAddItem((Widget) m_mainWidget, str(), pos+1, False); - m_noStrings ++; AdjustDropDownListSize(); - return GetCount() - 1; + return pos - 1; } -void wxComboBox::Delete(unsigned int n) +void wxComboBox::DoDeleteOneItem(unsigned int n) { #ifdef LESSTIF_VERSION XmListDeletePos (GetXmList(this), n + 1); @@ -236,7 +220,7 @@ void wxComboBox::Delete(unsigned int n) XmComboBoxDeletePos((Widget) m_mainWidget, n+1); #endif - m_clientDataDict.Delete(n, HasClientObjectData()); + wxControlWithItems::DoDeleteOneItem(n); m_noStrings--; AdjustDropDownListSize(); @@ -253,10 +237,10 @@ void wxComboBox::Clear() } #endif - if ( HasClientObjectData() ) - m_clientDataDict.DestroyData(); m_noStrings = 0; AdjustDropDownListSize(); + + wxTextEntry::Clear(); } void wxComboBox::SetSelection (int n) @@ -279,7 +263,7 @@ void wxComboBox::SetSelection (int n) m_inSetSelection = false; } -int wxComboBox::GetSelection (void) const +int wxComboBox::GetSelection() const { return wxDoGetSelectionInList( GetXmList( this ) ); } @@ -296,69 +280,6 @@ int wxComboBox::FindString(const wxString& s, bool WXUNUSED(bCase)) const return wxDoFindStringInList( GetXmList( this ), s ); } -// Clipboard operations -void wxComboBox::Copy() -{ - XmTextCopy( GetXmText(this), CurrentTime ); -} - -void wxComboBox::Cut() -{ - XmTextCut( GetXmText(this), CurrentTime ); -} - -void wxComboBox::Paste() -{ - XmTextPaste( GetXmText(this) ); -} - -void wxComboBox::SetEditable(bool WXUNUSED(editable)) -{ - // TODO -} - -void wxComboBox::SetInsertionPoint(long pos) -{ - XmTextSetInsertionPosition( GetXmText(this), (XmTextPosition)pos ); -} - -void wxComboBox::SetInsertionPointEnd() -{ - SetInsertionPoint( GetLastPosition() ); -} - -long wxComboBox::GetInsertionPoint() const -{ - return (long)XmTextGetInsertionPosition( GetXmText(this) ); -} - -wxTextPos wxComboBox::GetLastPosition() const -{ - XmTextPosition pos = XmTextGetLastPosition( GetXmText(this) ); - return (long)pos; -} - -void wxComboBox::Replace(long from, long to, const wxString& value) -{ - XmTextReplace( GetXmText(this), (XmTextPosition)from, (XmTextPosition)to, - wxConstCast(value.mb_str(), char) ); -} - -void wxComboBox::Remove(long from, long to) -{ - SetSelection( from, to ); - XmTextRemove( GetXmText(this) ); -} - -void wxComboBox::SetSelection(long from, long to) -{ - if( to == -1 ) - to = GetLastPosition(); - - XmTextSetSelection( GetXmText(this), (XmTextPosition)from, - (XmTextPosition)to, (Time)0 ); -} - void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, XmComboBoxCallbackStruct * cbs) { @@ -454,6 +375,11 @@ wxSize wxComboBox::DoGetBestSize() const return wxWindow::DoGetBestSize(); } +WXWidget wxComboBox::GetTextWidget() const +{ + return (WXWidget)GetXmText(this); +} + #endif // XmVersion >= 2000 #endif // wxUSE_COMBOBOX