// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
-// RCS-ID: $Id: choice.cpp 54129 2008-06-11 19:30:52Z SC $
+// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
if ( !wxChoiceBase::Create( parent, id, pos, size, style, validator, name ) )
return false;
-
+
m_popUpMenu = new wxMenu();
m_popUpMenu->SetNoEventsMode(true);
-
+
m_peer = wxWidgetImpl::CreateChoice( this, parent, id, m_popUpMenu, pos, size, style, GetExtraStyle() );
MacPostControlCreate( pos, size );
m_strings.Insert( items[i], idx );
}
- m_popUpMenu->Insert( idx, i+1, items[i] );
+ wxString text = items[i];
+ if (text == wxEmptyString)
+ text = " "; // menu items can't have empty labels
+ m_popUpMenu->Insert( idx, i+1, text );
m_datas.Insert( NULL, idx );
AssignNewItemClientData(idx, clientData, i, type);
}
if ( HasClientObjectData() )
delete GetClientObject( n );
-
+
m_popUpMenu->Delete( m_popUpMenu->FindItemByPosition( n ) );
m_strings.RemoveAt( n ) ;
return (void *)m_datas[n];
}
-bool wxChoice::OSXHandleClicked( double timestampsec )
+bool wxChoice::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
wxCommandEvent event( wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
event.SetInt( n );
event.SetString( GetStringSelection() );
event.SetEventObject( this );
-
+
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject( n ) );
else if ( HasClientUntypedData() )
wxSize wxChoice::DoGetBestSize() const
{
int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults
- int lbHeight = 20;
+ wxSize baseSize = wxWindow::DoGetBestSize();
+ int lbHeight = baseSize.y;
int wLine;
{
wxCoord width, height ;
dc.GetTextExtent( wxT("X"), &width, &height);
int cx = width ;
- lbHeight += 4;
lbWidth += cx ;
}