X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90527a50d74bed6ed6b4d163e8170ae8c3f5d869..eec960fa8987d15fd87e249c8441474188124425:/src/mac/carbon/menu.cpp diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index 391e97b560..a76f7e6dd9 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -24,7 +24,6 @@ #include "wx/log.h" #include "wx/app.h" #include "wx/utils.h" - #include "wx/window.h" #include "wx/frame.h" #include "wx/menuitem.h" #endif @@ -41,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 @@ -163,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 { @@ -203,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() ; @@ -488,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() ; @@ -505,8 +503,6 @@ void wxMenu::MacAfterDisplay( bool isSubMenu ) { // no need to undo hidings } - - previousItem = item ; } } @@ -602,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, kMenuItemAttrSeparator, 0); MacInsertMenu( appleMenu , 0 ) ; // clean-up the help menu before adding new items @@ -663,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() ; @@ -694,7 +689,8 @@ void wxMenuBar::MacInstallMenuBar() if ( item->IsSeparator() ) { if ( mh ) - MacAppendMenu(mh, "\p-" ); + AppendMenuItemTextWithCFString( mh, + CFSTR(""), kMenuItemAttrSeparator, 0,NULL); } else { @@ -711,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 ) ; } } @@ -739,7 +735,7 @@ void wxMenuBar::MacInstallMenuBar() 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 ) ; } }