X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de6185e212ebc37ff11ff70278e3c4f68419b097..6445acc7832ccd1f2fc5211a68c90f4426ab4346:/src/mac/carbon/menu.cpp diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index 94f29966bc..09cf4450c1 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -24,13 +24,10 @@ #include "wx/log.h" #include "wx/app.h" #include "wx/utils.h" + #include "wx/frame.h" + #include "wx/menuitem.h" #endif -#include "wx/menuitem.h" -#include "wx/window.h" -#include "wx/log.h" -#include "wx/frame.h" - #include "wx/mac/uma.h" // other standard headers @@ -43,8 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler) // the (popup) menu title has this special id static const int idMenuTitle = -3; -const short kwxMacMenuBarResource = 1 ; -const short kwxMacAppleMenuId = 1 ; +static const short kwxMacAppleMenuId = 1 ; // Find an item given the Macintosh Menu Reference @@ -165,9 +161,11 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) if ( pItem->IsSeparator() ) { if ( pos == (size_t)-1 ) - MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-"); + AppendMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu), + CFSTR(""), kMenuItemAttrSeparator, 0,NULL); else - MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos); + InsertMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu), + CFSTR(""), pos, kMenuItemAttrSeparator, 0); } else { @@ -205,7 +203,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) } SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , wxIdToMacCommand ( pItem->GetId() ) ) ; - SetMenuItemRefCon( MAC_WXHMENU(m_hMenu) , pos , (UInt32) pItem ) ; + SetMenuItemRefCon( MAC_WXHMENU(m_hMenu) , pos , (URefCon) pItem ) ; pItem->UpdateItemText() ; pItem->UpdateItemBitmap() ; pItem->UpdateItemStatus() ; @@ -490,12 +488,10 @@ void wxMenu::MacAfterDisplay( bool isSubMenu ) if ( isSubMenu ) ::DeleteMenu(MacGetMenuId()); - wxMenuItem* previousItem = NULL ; wxMenuItemList::compatibility_iterator node; wxMenuItem *item; - int pos ; - for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + for (node = GetMenuItems().GetFirst(); node; node = node->GetNext()) { item = (wxMenuItem *)node->GetData(); wxMenu* subMenu = item->GetSubMenu() ; @@ -507,8 +503,6 @@ void wxMenu::MacAfterDisplay( bool isSubMenu ) { // no need to undo hidings } - - previousItem = item ; } } @@ -604,19 +598,19 @@ void wxMenuBar::MacInstallMenuBar() ::SetMenuBar( menubar ) ; DisposeMenuBar( menubar ) ; MenuHandle appleMenu = NULL ; - char appleMenuTitle[3] = { 01 , kMenuAppleLogoFilledGlyph , 0 } ; verify_noerr( CreateNewMenu( kwxMacAppleMenuId , 0 , &appleMenu ) ) ; - verify_noerr( SetMenuTitle( appleMenu , (ConstStr255Param) appleMenuTitle ) ); + verify_noerr( SetMenuTitleWithCFString( appleMenu , CFSTR( "\x14" ) ) ); // Add About/Preferences separator only on OS X // KH/RN: Separator is always present on 10.3 but not on 10.2 // However, the change from 10.2 to 10.3 suggests it is preferred #if TARGET_API_MAC_OSX - MacInsertMenuItem( appleMenu , "\p-" , 0 ) ; + InsertMenuItemTextWithCFString( appleMenu, + CFSTR(""), 0, kMenuItemAttrSeparator, 0); #endif - - MacInsertMenuItem( appleMenu , "\pAbout..." , 0 ) ; + InsertMenuItemTextWithCFString( appleMenu, + CFSTR("About..."), 0, 0, 0); MacInsertMenu( appleMenu , 0 ) ; // clean-up the help menu before adding new items @@ -665,12 +659,11 @@ void wxMenuBar::MacInstallMenuBar() { wxMenuItemList::compatibility_iterator node; wxMenuItem *item; - int pos ; wxMenu* menu = menuIter->GetData() , *subMenu = NULL ; if ( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName ) { - for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext()) { item = (wxMenuItem *)node->GetData(); subMenu = item->GetSubMenu() ; @@ -696,11 +689,13 @@ void wxMenuBar::MacInstallMenuBar() if ( item->IsSeparator() ) { if ( mh ) - MacAppendMenu(mh, "\p-" ); + AppendMenuItemTextWithCFString( mh, + CFSTR(""), kMenuItemAttrSeparator, 0,NULL); } else { - wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ; + wxAcceleratorEntry* + entry = wxAcceleratorEntry::Create( item->GetText() ) ; if ( item->GetId() == wxApp::s_macAboutMenuItemId ) { @@ -712,7 +707,7 @@ void wxMenuBar::MacInstallMenuBar() { UMAAppendMenuItem(mh, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding(), entry); SetMenuItemCommandID( mh , CountMenuItems(mh) , wxIdToMacCommand ( item->GetId() ) ) ; - SetMenuItemRefCon( mh , CountMenuItems(mh) , (UInt32)item ) ; + SetMenuItemRefCon( mh , CountMenuItems(mh) , (URefCon) item ) ; } } @@ -735,11 +730,12 @@ void wxMenuBar::MacInstallMenuBar() wxMenuItem *aboutMenuItem = FindItem(wxApp::s_macAboutMenuItemId , &aboutMenu) ; if ( aboutMenuItem ) { - wxAcceleratorEntry* entry = wxGetAccelFromString( aboutMenuItem->GetText() ) ; + wxAcceleratorEntry* + entry = wxAcceleratorEntry::Create( aboutMenuItem->GetText() ) ; UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , wxStripMenuCodes ( aboutMenuItem->GetText() ) , wxFont::GetDefaultEncoding() ); UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true ); SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , kHICommandAbout ) ; - SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (UInt32)aboutMenuItem ) ; + SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (URefCon)aboutMenuItem ) ; UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ; } }