// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
wxASSERT_MSG( !(style & wxCB_SORT),
"wxCB_SORT not currently supported by wxOSX/Cocoa");
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
wxASSERT_MSG( !(style & wxCB_SORT),
"wxCB_SORT not currently supported by wxOSX/Cocoa");
- m_peer = wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() );
+ SetPeer(wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() ));
AssignNewItemClientData(idx, clientData, i, type);
}
AssignNewItemClientData(idx, clientData, i, type);
}
// ----------------------------------------------------------------------------
void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
{
// ----------------------------------------------------------------------------
void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
{
- return GetString(GetSelection());
+ const int sel = GetSelection();
+ return sel == wxNOT_FOUND ? wxString() : GetString(sel);
+}
+
+void wxComboBox::SetValue(const wxString& value)
+{
+ if ( HasFlag(wxCB_READONLY) )
+ SetStringSelection( value ) ;
+ else
+ wxTextEntry::SetValue( value );
- Delete(n);
- Insert(s, n);
+ // Notice that we shouldn't delete and insert the item in this control
+ // itself as this would also affect the client data which we need to
+ // preserve here.
+ GetComboPeer()->RemoveItem(n);
+ GetComboPeer()->InsertItem(n, s);
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());
- return dynamic_cast<wxComboWidgetImpl*> (m_peer);
+ return dynamic_cast<wxComboWidgetImpl*> (GetPeer());
+}
+
+void wxComboBox::Popup()
+{
+ GetComboPeer()->Popup();
+}
+
+void wxComboBox::Dismiss()
+{
+ GetComboPeer()->Dismiss();