]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/combobox.mm
include jconfig.vc under OS/2 too
[wxWidgets.git] / src / cocoa / combobox.mm
index 406bce80e443fb7d8ad97af280c39699782e6ab6..9986273c6abf18c27ffce7ccb8382200504bb93f 100644 (file)
 
 #if wxUSE_COMBOBOX
 
+#include "wx/combobox.h"
+
+#include "wx/cocoa/objc/objc_uniquifying.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 <AppKit/NSComboBox.h>
 #import <Foundation/NSNotification.h>
 #import <Foundation/NSString.h>
@@ -133,6 +134,7 @@ void wxCocoaNSComboBox::DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox)
 - (void)comboBoxWillDismiss:(NSNotification *)notification;
 - (void)comboBoxWillPopUp:(NSNotification *)notification;
 @end // wxPoserNSComboBox
+WX_DECLARE_GET_OBJC_CLASS(wxPoserNSComboBox,NSComboBox)
 
 //WX_IMPLEMENT_POSER(wxPoserNSComboBox);
 @implementation wxPoserNSComboBox : NSComboBox
@@ -159,8 +161,7 @@ void wxCocoaNSComboBox::DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox)
 }
 
 @end // implementation wxPoserNSComboBox
-
-#include "wx/combobox.h"
+WX_IMPLEMENT_GET_OBJC_CLASS(wxPoserNSComboBox,NSComboBox)
 
 #include "wx/cocoa/autorelease.h"
 #include "wx/cocoa/string.h"
@@ -201,7 +202,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
         return false;
 
     m_cocoaNSView = NULL;
-    SetNSComboBox([[wxPoserNSComboBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
+    SetNSComboBox([[WX_GET_OBJC_CLASS(wxPoserNSComboBox) alloc] initWithFrame:MakeDefaultNSRect(size)]);
     [m_cocoaNSView release];
     [GetNSTextField() setStringValue:wxNSStringWithWxString(value.c_str())];
     [GetNSControl() sizeToFit];
@@ -209,8 +210,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 +249,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 +291,20 @@ int wxComboBox::GetSelection() const
     return [GetNSComboBox() indexOfSelectedItem];
 }
 
-int wxComboBox::DoAppend(const wxString& szItem)
+int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
+                              unsigned int pos,
+                              void **clientData,
+                              wxClientDataType type)
 {
-    m_Datas.Add(NULL);
     wxAutoNSAutoreleasePool pool;
-    [GetNSComboBox() addItemWithObjectValue:wxNSStringWithWxString(szItem)];
-    return [GetNSComboBox() numberOfItems];
-}
-
-int wxComboBox::DoInsert(const wxString& szItem, unsigned int nIndex)
-{
-    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 +317,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