]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/combobox.mm
Allow passing multi-line strings to wxDC::DrawText(), even under MSW.
[wxWidgets.git] / src / cocoa / combobox.mm
index 9986273c6abf18c27ffce7ccb8382200504bb93f..b34e2c8caed375143a22e74367d859c7a3eb207b 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     2005/02/16
 // RCS-ID:      $Id$
 // Copyright:   (c) 2003 David Elliott
 // Created:     2005/02/16
 // RCS-ID:      $Id$
 // Copyright:   (c) 2003 David Elliott
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 //
 /////////////////////////////////////////////////////////////////////////////
 
 //
@@ -168,10 +168,11 @@ WX_IMPLEMENT_GET_OBJC_CLASS(wxPoserNSComboBox,NSComboBox)
 
 #import <AppKit/NSComboBox.h>
 
 
 #import <AppKit/NSComboBox.h>
 
-IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxTextCtrl)
-BEGIN_EVENT_TABLE(wxComboBox, wxTextCtrl)
+IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
+BEGIN_EVENT_TABLE(wxComboBox, wxControl)
 END_EVENT_TABLE()
 WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSComboBox,NSTextField,NSView)
 END_EVENT_TABLE()
 WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSComboBox,NSTextField,NSView)
+WX_IMPLEMENT_COCOA_OWNER(wxComboBox,NSTextField,NSControl,NSView)
 
 bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
             const wxString& value,
 
 bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
             const wxString& value,
@@ -228,14 +229,14 @@ void wxComboBox::doWxEvent(int nEvent)
     event2.SetInt(GetSelection());
     event2.SetEventObject(this);
     event2.SetString(GetStringSelection());
     event2.SetInt(GetSelection());
     event2.SetEventObject(this);
     event2.SetString(GetStringSelection());
-    GetEventHandler()->ProcessEvent(event2);
+    HandleWindowEvent(event2);
 
     // For consistency with MSW and GTK, also send a text updated event
     // After all, the text is updated when a selection is made
     wxCommandEvent TextEvent( wxEVT_COMMAND_TEXT_UPDATED, GetId() );
     TextEvent.SetString( GetStringSelection() );
     TextEvent.SetEventObject( this );
 
     // For consistency with MSW and GTK, also send a text updated event
     // After all, the text is updated when a selection is made
     wxCommandEvent TextEvent( wxEVT_COMMAND_TEXT_UPDATED, GetId() );
     TextEvent.SetString( GetStringSelection() );
     TextEvent.SetEventObject( this );
-    GetEventHandler()->ProcessEvent( TextEvent );
+    HandleWindowEvent( TextEvent );
 }
 
 
 }
 
 
@@ -317,4 +318,93 @@ void* wxComboBox::DoGetItemClientData(unsigned int nIndex) const
     return m_Datas[nIndex];
 }
 
     return m_Datas[nIndex];
 }
 
+/////////////////////////////////////////////////////////////////////////////
+// wxTextEntry virtual implementations:
+
+void wxComboBox::WriteText(wxString const&)
+{
+}
+
+wxString wxComboBox::GetValue() const
+{
+    wxAutoNSAutoreleasePool pool;
+    return wxStringWithNSString([GetNSTextField() stringValue]);
+}
+
+void wxComboBox::Remove(long, long)
+{
+}
+
+void wxComboBox::Cut()
+{
+}
+
+void wxComboBox::Copy()
+{
+}
+
+void wxComboBox::Paste()
+{
+}
+
+void wxComboBox::Undo()
+{
+}
+
+void wxComboBox::Redo()
+{
+}
+
+bool wxComboBox::CanUndo() const
+{
+    return false;
+}
+
+bool wxComboBox::CanRedo() const
+{
+    return false;
+}
+
+void wxComboBox::SetInsertionPoint(long)
+{
+}
+
+long wxComboBox::GetInsertionPoint() const
+{
+    return 0;
+}
+
+wxTextPos wxComboBox::GetLastPosition() const
+{
+    // working - returns the size of the wxString
+    return (long)(GetValue().Len());
+}
+
+void wxComboBox::SetSelection(long, long)
+{
+}
+
+void wxComboBox::GetSelection(long*, long*) const
+{
+}
+
+bool wxComboBox::IsEditable() const
+{
+    return [GetNSTextField() isEditable];
+}
+
+void wxComboBox::SetEditable(bool editable)
+{
+    // first ensure that the current value is stored (in case the user had not finished editing
+    // before SetEditable(FALSE) was called)
+    DoSetValue(GetValue(),1);
+
+    [GetNSTextField() setEditable: editable];
+
+    // forces the focus on the textctrl to be lost - while focus is still maintained
+    // after SetEditable(FALSE) the user may still edit the control
+    // (might not the best way to do this..)
+    [GetNSTextField() abortEditing];
+}
+
 #endif // wxUSE_COMBOBOX
 #endif // wxUSE_COMBOBOX