X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a236aa2058ccf3d36e9cafc20fa7375080c4be50..4521f6c88cbefa7f13e3733d344776b795f981e4:/src/cocoa/combobox.mm diff --git a/src/cocoa/combobox.mm b/src/cocoa/combobox.mm index 041fd382c5..9830122661 100644 --- a/src/cocoa/combobox.mm +++ b/src/cocoa/combobox.mm @@ -4,15 +4,14 @@ // Author: Ryan Norton // Modified by: // Created: 2005/02/16 -// RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // // Impl notes: // There is no custom data source because doing so unnecessarily sacrifices -// some native autocompletion behavior (we would have to make our own - +// some native autocompletion behaviour (we would have to make our own - // the SimpleComboBox sample does so in the developer folder that // comes with OSX). One reason you might want this would be to have // only one array or be able to display numbers returned by an NSNumber @@ -80,6 +79,8 @@ #include "wx/combobox.h" +#include "wx/cocoa/objc/objc_uniquifying.h" + #ifndef WX_PRECOMP #include "wx/window.h" #include "wx/log.h" @@ -132,6 +133,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 @@ -139,7 +141,7 @@ void wxCocoaNSComboBox::DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox) - (void)comboBoxSelectionDidChange:(NSNotification *)notification { wxCocoaNSComboBox *win = wxCocoaNSComboBox::GetFromCocoa(self); - win->doWxEvent(wxEVT_COMMAND_COMBOBOX_SELECTED); + win->doWxEvent(wxEVT_COMBOBOX); } - (void)comboBoxSelectionIsChanging:(NSNotification *)notification @@ -158,16 +160,17 @@ void wxCocoaNSComboBox::DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox) } @end // implementation wxPoserNSComboBox +WX_IMPLEMENT_GET_OBJC_CLASS(wxPoserNSComboBox,NSComboBox) #include "wx/cocoa/autorelease.h" #include "wx/cocoa/string.h" #import -IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxTextCtrl) -BEGIN_EVENT_TABLE(wxComboBox, wxTextCtrl) +BEGIN_EVENT_TABLE(wxComboBox, wxControl) 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, @@ -198,7 +201,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]; @@ -220,18 +223,18 @@ wxComboBox::~wxComboBox() void wxComboBox::doWxEvent(int nEvent) { - wxCommandEvent event2(wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() ); + wxCommandEvent event2(wxEVT_COMBOBOX, GetId() ); 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() ); + wxCommandEvent TextEvent( wxEVT_TEXT, GetId() ); TextEvent.SetString( GetStringSelection() ); TextEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( TextEvent ); + HandleWindowEvent( TextEvent ); } @@ -313,4 +316,93 @@ void* wxComboBox::DoGetItemClientData(unsigned int nIndex) const 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