X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/670f9935630beb2123a5ca62894ae92a3f0efa4f..11fe6505b848a968f4c89cb3c3fd37a6a03bcaea:/src/cocoa/combobox.mm?ds=sidebyside diff --git a/src/cocoa/combobox.mm b/src/cocoa/combobox.mm index 406bce80e4..041fd382c5 100644 --- a/src/cocoa/combobox.mm +++ b/src/cocoa/combobox.mm @@ -78,15 +78,14 @@ #if wxUSE_COMBOBOX +#include "wx/combobox.h" + #ifndef WX_PRECOMP #include "wx/window.h" #include "wx/log.h" #include "wx/app.h" #endif // WX_PRECOMP -#include "wx/cocoa/ObjcPose.h" -#include "wx/combobox.h" - #import #import #import @@ -160,8 +159,6 @@ void wxCocoaNSComboBox::DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox) @end // implementation wxPoserNSComboBox -#include "wx/combobox.h" - #include "wx/cocoa/autorelease.h" #include "wx/cocoa/string.h" @@ -209,8 +206,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid, m_parent->CocoaAddChild(this); SetInitialFrameRect(pos,size); - for(int i = 0; i < n; ++i) - wxComboBox::DoAppend(choices[i]); + wxComboBox::Append(n, choices); [GetNSComboBox() setCompletes:true]; //autocomplete :) @@ -249,13 +245,13 @@ wxString wxComboBox::GetStringSelection() return wxStringWithNSString([GetNSComboBox() objectValueOfSelectedItem]); } -void wxComboBox::Clear() +void wxComboBox::DoClear() { [GetNSComboBox() removeAllItems]; m_Datas.Clear(); } -void wxComboBox::Delete(unsigned int n) +void wxComboBox::DoDeleteOneItem(unsigned int n) { [GetNSComboBox() removeItemAtIndex:n]; m_Datas.RemoveAt(n); @@ -291,20 +287,20 @@ int wxComboBox::GetSelection() const return [GetNSComboBox() indexOfSelectedItem]; } -int wxComboBox::DoAppend(const wxString& szItem) -{ - m_Datas.Add(NULL); - wxAutoNSAutoreleasePool pool; - [GetNSComboBox() addItemWithObjectValue:wxNSStringWithWxString(szItem)]; - return [GetNSComboBox() numberOfItems]; -} - -int wxComboBox::DoInsert(const wxString& szItem, unsigned int nIndex) +int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items, + unsigned int pos, + void **clientData, + wxClientDataType type) { - m_Datas.Insert(NULL, nIndex); wxAutoNSAutoreleasePool pool; - [GetNSComboBox() insertItemWithObjectValue:wxNSStringWithWxString(szItem) atIndex:nIndex]; - return (int)nIndex; + const unsigned int numITems = items.GetCount(); + for ( unsigned int i = 0; i < numITems; ++i, ++pos ) + { + [GetNSComboBox() insertItemWithObjectValue:wxNSStringWithWxString(items[i]) atIndex:(pos)]; + m_Datas.Insert(NULL, pos); + AssignNewItemClientData(pos, clientData, i, type); + } + return pos - 1; } void wxComboBox::DoSetItemClientData(unsigned int nIndex, void* pData) @@ -317,14 +313,4 @@ void* wxComboBox::DoGetItemClientData(unsigned int nIndex) const return m_Datas[nIndex]; } -void wxComboBox::DoSetItemClientObject(unsigned int nIndex, wxClientData* pClientData) -{ - m_Datas[nIndex] = (void*) pClientData; -} - -wxClientData* wxComboBox::DoGetItemClientObject(unsigned int nIndex) const -{ - return (wxClientData*) m_Datas[nIndex]; -} - -#endif //wxUSE_COMBOBOX +#endif // wxUSE_COMBOBOX