avoid duplicated empty help menu in localized applications (patch 1600747
)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,6 +50,10 @@ wxGTK:
|
|||||||
- Added support for colour cursors (Pascal Monasse).
|
- Added support for colour cursors (Pascal Monasse).
|
||||||
- Setting foreground colour of single line wxTextCtrl now works
|
- Setting foreground colour of single line wxTextCtrl now works
|
||||||
|
|
||||||
|
wxMac:
|
||||||
|
|
||||||
|
- Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
- Fixed infinite loop in wxThread::Wait() in console applications.
|
- Fixed infinite loop in wxThread::Wait() in console applications.
|
||||||
|
@@ -94,10 +94,17 @@ bool UMAIsWindowModal( WindowRef inWindow ) ;
|
|||||||
|
|
||||||
void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) ;
|
void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) ;
|
||||||
|
|
||||||
|
// Retrieves the Help menu handle. Warning: As a side-effect this functions also
|
||||||
|
// creates the Help menu if it didn't exist yet.
|
||||||
OSStatus UMAGetHelpMenu(
|
OSStatus UMAGetHelpMenu(
|
||||||
MenuRef * outHelpMenu,
|
MenuRef * outHelpMenu,
|
||||||
MenuItemIndex * outFirstCustomItemIndex); /* can be NULL */
|
MenuItemIndex * outFirstCustomItemIndex); /* can be NULL */
|
||||||
|
|
||||||
|
// Same as UMAGetHelpMenu, but doesn't create the Help menu if UMAGetHelpMenu hasn't been called yet.
|
||||||
|
OSStatus UMAGetHelpMenuDontCreate(
|
||||||
|
MenuRef * outHelpMenu,
|
||||||
|
MenuItemIndex * outFirstCustomItemIndex); /* can be NULL */
|
||||||
|
|
||||||
// Appearance Drawing
|
// Appearance Drawing
|
||||||
|
|
||||||
OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) ;
|
OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) ;
|
||||||
|
@@ -451,16 +451,16 @@ wxMenu* wxFindMenuFromMacCommand( const HICommand &command , wxMenuItem* &item )
|
|||||||
id = wxMacCommandToId( command.commandID ) ;
|
id = wxMacCommandToId( command.commandID ) ;
|
||||||
// make sure it is one of our own menus, or of the 'synthetic' apple and help menus , otherwise don't touch
|
// make sure it is one of our own menus, or of the 'synthetic' apple and help menus , otherwise don't touch
|
||||||
MenuItemIndex firstUserHelpMenuItem ;
|
MenuItemIndex firstUserHelpMenuItem ;
|
||||||
static MenuHandle mh = NULL ;
|
static MenuHandle helpMenuHandle = NULL ;
|
||||||
if ( mh == NULL )
|
if ( helpMenuHandle == NULL )
|
||||||
{
|
{
|
||||||
if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) != noErr )
|
if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
|
||||||
mh = NULL ;
|
helpMenuHandle = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is it part of the application or the Help menu, then look for the id directly
|
// is it part of the application or the Help menu, then look for the id directly
|
||||||
if ( ( GetMenuHandle( kwxMacAppleMenuId ) != NULL && command.menu.menuRef == GetMenuHandle( kwxMacAppleMenuId ) ) ||
|
if ( ( GetMenuHandle( kwxMacAppleMenuId ) != NULL && command.menu.menuRef == GetMenuHandle( kwxMacAppleMenuId ) ) ||
|
||||||
( mh != NULL && command.menu.menuRef == mh ) )
|
( helpMenuHandle != NULL && command.menu.menuRef == helpMenuHandle ) )
|
||||||
{
|
{
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
|
@@ -613,21 +613,18 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
CFSTR("About..."), 0, 0, 0);
|
CFSTR("About..."), 0, 0, 0);
|
||||||
MacInsertMenu( appleMenu , 0 ) ;
|
MacInsertMenu( appleMenu , 0 ) ;
|
||||||
|
|
||||||
// clean-up the help menu before adding new items
|
// if we have a mac help menu, clean it up before adding new items
|
||||||
static MenuHandle mh = NULL ;
|
MenuHandle helpMenuHandle ;
|
||||||
|
MenuItemIndex firstUserHelpMenuItem ;
|
||||||
|
|
||||||
if ( mh != NULL )
|
if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) == noErr )
|
||||||
{
|
{
|
||||||
MenuItemIndex firstUserHelpMenuItem ;
|
for ( int i = CountMenuItems( helpMenuHandle ) ; i >= firstUserHelpMenuItem ; --i )
|
||||||
if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr )
|
DeleteMenuItem( helpMenuHandle , i ) ;
|
||||||
{
|
}
|
||||||
for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i )
|
else
|
||||||
DeleteMenuItem( mh , i ) ;
|
{
|
||||||
}
|
helpMenuHandle = NULL ;
|
||||||
else
|
|
||||||
{
|
|
||||||
mh = NULL ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -654,14 +651,17 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxString strippedHelpMenuTitle = wxStripMenuCodes( wxApp::s_macHelpMenuTitleName ) ;
|
||||||
|
wxString strippedTranslatedHelpMenuTitle = wxStripMenuCodes( wxString( _("&Help") ) ) ;
|
||||||
wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
|
wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
|
||||||
for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
|
for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
|
||||||
{
|
{
|
||||||
wxMenuItemList::compatibility_iterator node;
|
wxMenuItemList::compatibility_iterator node;
|
||||||
wxMenuItem *item;
|
wxMenuItem *item;
|
||||||
wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
|
wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
|
||||||
|
wxString strippedMenuTitle = wxStripMenuCodes(m_titles[i]);
|
||||||
|
|
||||||
if ( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName )
|
if ( strippedMenuTitle == wxT("?") || strippedMenuTitle == strippedHelpMenuTitle || strippedMenuTitle == strippedTranslatedHelpMenuTitle )
|
||||||
{
|
{
|
||||||
for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
|
for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
|
||||||
{
|
{
|
||||||
@@ -675,12 +675,13 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
{
|
{
|
||||||
if ( item->GetId() != wxApp::s_macAboutMenuItemId )
|
if ( item->GetId() != wxApp::s_macAboutMenuItemId )
|
||||||
{
|
{
|
||||||
if ( mh == NULL )
|
// we have found a user help menu and an item other than the about item,
|
||||||
|
// so we can create the mac help menu now, if we haven't created it yet
|
||||||
|
if ( helpMenuHandle == NULL )
|
||||||
{
|
{
|
||||||
MenuItemIndex firstUserHelpMenuItem ;
|
if ( UMAGetHelpMenu( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
|
||||||
if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) != noErr )
|
|
||||||
{
|
{
|
||||||
mh = NULL ;
|
helpMenuHandle = NULL ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -688,8 +689,8 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
|
|
||||||
if ( item->IsSeparator() )
|
if ( item->IsSeparator() )
|
||||||
{
|
{
|
||||||
if ( mh )
|
if ( helpMenuHandle )
|
||||||
AppendMenuItemTextWithCFString( mh,
|
AppendMenuItemTextWithCFString( helpMenuHandle,
|
||||||
CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
|
CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -703,11 +704,11 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( mh )
|
if ( helpMenuHandle )
|
||||||
{
|
{
|
||||||
UMAAppendMenuItem(mh, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding(), entry);
|
UMAAppendMenuItem(helpMenuHandle, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding(), entry);
|
||||||
SetMenuItemCommandID( mh , CountMenuItems(mh) , wxIdToMacCommand ( item->GetId() ) ) ;
|
SetMenuItemCommandID( helpMenuHandle , CountMenuItems(helpMenuHandle) , wxIdToMacCommand ( item->GetId() ) ) ;
|
||||||
SetMenuItemRefCon( mh , CountMenuItems(mh) , (URefCon) item ) ;
|
SetMenuItemRefCon( helpMenuHandle , CountMenuItems(helpMenuHandle) , (URefCon) item ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -645,14 +645,29 @@ static OSStatus helpMenuStatus = noErr ;
|
|||||||
static MenuItemIndex firstCustomItemIndex = 0 ;
|
static MenuItemIndex firstCustomItemIndex = 0 ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSStatus UMAGetHelpMenu(
|
static OSStatus UMAGetHelpMenu(
|
||||||
MenuRef * outHelpMenu,
|
MenuRef * outHelpMenu,
|
||||||
MenuItemIndex * outFirstCustomItemIndex)
|
MenuItemIndex * outFirstCustomItemIndex,
|
||||||
|
bool allowHelpMenuCreation);
|
||||||
|
|
||||||
|
static OSStatus UMAGetHelpMenu(
|
||||||
|
MenuRef * outHelpMenu,
|
||||||
|
MenuItemIndex * outFirstCustomItemIndex,
|
||||||
|
bool allowHelpMenuCreation)
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ;
|
static bool s_createdHelpMenu = false ;
|
||||||
|
|
||||||
|
if ( !s_createdHelpMenu && !allowHelpMenuCreation )
|
||||||
|
{
|
||||||
|
return paramErr ;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus status = HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ;
|
||||||
|
s_createdHelpMenu = ( status == noErr ) ;
|
||||||
|
return status ;
|
||||||
#else
|
#else
|
||||||
|
wxUnusedVar( allowHelpMenuCreation ) ;
|
||||||
MenuRef helpMenuHandle ;
|
MenuRef helpMenuHandle ;
|
||||||
|
|
||||||
helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ;
|
helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ;
|
||||||
@@ -668,6 +683,20 @@ OSStatus UMAGetHelpMenu(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSStatus UMAGetHelpMenu(
|
||||||
|
MenuRef * outHelpMenu,
|
||||||
|
MenuItemIndex * outFirstCustomItemIndex)
|
||||||
|
{
|
||||||
|
return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , true );
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus UMAGetHelpMenuDontCreate(
|
||||||
|
MenuRef * outHelpMenu,
|
||||||
|
MenuItemIndex * outFirstCustomItemIndex)
|
||||||
|
{
|
||||||
|
return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , false );
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
|
|
||||||
wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport )
|
wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport )
|
||||||
|
Reference in New Issue
Block a user