#endif
#include "wx/combobox.h"
+#include "wx/menu.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
// right now we don't support editable comboboxes
+static int nextPopUpMenuId = 1000 ;
+MenuHandle NewUniqueMenu()
+{
+ MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
+ nextPopUpMenuId++ ;
+ return handle ;
+}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0,
+ m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , -12345 , 0,
kControlPopupButtonProc , (long) this ) ;
- m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
+ m_macPopUpMenuHandle = NewUniqueMenu() ;
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
for ( int i = 0 ; i < n ; i++ )
{
- appendmenu( m_macPopUpMenuHandle , choices[i] ) ;
+ Str255 label;
+ wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
+ AppendMenu( m_macPopUpMenuHandle , label ) ;
}
SetControlMinimum( m_macControl , 0 ) ;
SetControlMaximum( m_macControl , m_noStrings) ;
void wxComboBox::Append(const wxString& item)
{
- appendmenu( m_macPopUpMenuHandle , item ) ;
+ Str255 label;
+ wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
+ AppendMenu( m_macPopUpMenuHandle , label ) ;
m_noStrings ++;
SetControlMaximum( m_macControl , m_noStrings) ;
}
wxString wxComboBox::GetString(int n) const
{
- Str255 text ;
- ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ;
- p2cstr( text ) ;
- return wxString( text );
+ Str255 p_text ;
+ char c_text[255];
+ ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , p_text ) ;
+#if TARGET_CARBON
+ p2cstrcpy( c_text, p_text ) ;
+#else
+ p2cstr( p_text ) ;
+ strcpy( c_text, (char *) p_text ) ;
+#endif
+ return wxString( c_text );
}
wxString wxComboBox::GetStringSelection() const
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
event.SetEventObject(this);
- event.SetString(copystring(GetStringSelection()));
+ event.SetString(GetStringSelection());
ProcessCommand(event);
- delete[] event.GetString();
}