#include "wx/wxprec.h"
#include "wx/menuitem.h"
+#include "wx/stockitem.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
+ DoUpdateItemBitmap( mhandle, index );
+}
+
+void wxMenuItem::DoUpdateItemBitmap( WXHMENU menu, wxUint16 index)
+{
+ MenuHandle mhandle = (MenuHandle) menu;
+
if ( mhandle == NULL || index == 0)
return ;
if ( info.contentType == kControlContentIconRef )
SetMenuItemIconHandle( mhandle , index ,
kMenuIconRefType , (Handle) info.u.iconRef ) ;
+ else if ( info.contentType == kControlContentCGImageRef )
+ SetMenuItemIconHandle( mhandle , index ,
+ kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
}
wxMacReleaseBitmapButton( &info ) ;
#endif
if ( IsSeparator() )
return ;
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macPreferencesMenuItemId)
+ if ( GetId() == wxApp::s_macPreferencesMenuItemId)
{
if ( !IsEnabled() )
DisableMenuCommand( NULL , kHICommandPreferences ) ;
EnableMenuCommand( NULL , kHICommandPreferences ) ;
}
- if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macExitMenuItemId)
+ if ( GetId() == wxApp::s_macExitMenuItemId)
{
if ( !IsEnabled() )
DisableMenuCommand( NULL , kHICommandQuit ) ;
else
EnableMenuCommand( NULL , kHICommandQuit ) ;
}
-#endif
{
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
::SetItemMark( mhandle , index , 0 ) ; // no mark
UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ;
- wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ;
+ wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ;
UMASetMenuItemShortcut( mhandle , index , entry ) ;
delete entry ;
}
if (mhandle == NULL || index == 0)
return ;
- UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ;
- wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ;
+ wxString text = m_text;
+ if (text.IsEmpty() && !IsSeparator())
+ {
+ wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
+ text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC);
+ }
+
+ UMASetMenuItemText( mhandle , index , wxStripMenuCodes(text) , wxFont::GetDefaultEncoding() ) ;
+ wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( text ) ;
UMASetMenuItemShortcut( mhandle , index , entry ) ;
delete entry ;
}
void wxMenuItem::Enable(bool bDoEnable)
{
if (( m_isEnabled != bDoEnable
-#if TARGET_CARBON
// avoid changing menuitem state when menu is disabled
// eg. BeginAppModalStateForWindow() will disable menus and ignore this change
// which in turn causes m_isEnabled to become out of sync with real menuitem state
|| ( GetId() == wxApp::s_macPreferencesMenuItemId
|| GetId() == wxApp::s_macExitMenuItemId
|| GetId() == wxApp::s_macAboutMenuItemId
-#endif
))
{
wxMenuItemBase::Enable( bDoEnable ) ;
}
}
-void wxMenuItem::SetText(const wxString& text)
+void wxMenuItem::SetItemLabel(const wxString& text)
{
// don't do anything if label didn't change
if ( m_text == text )
return;
- wxMenuItemBase::SetText(text);
+ wxMenuItemBase::SetItemLabel(text);
UpdateItemText() ;
}
// ----------------------------------------------------------------------------
/* static */
-wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
+wxString wxMenuItemBase::GetLabelText(const wxString& text)
{
return wxStripMenuCodes(text);
}