From f34a6253c750b47f058045e84b32a9eed0653292 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 8 Oct 2017 10:34:19 +0200 Subject: [PATCH] Fix compilation with wxUSE_ACCEL==0 --- include/wx/menuitem.h | 2 ++ include/wx/osx/core/private.h | 2 ++ src/osx/cocoa/menuitem.mm | 4 +++- src/osx/cocoa/window.mm | 5 +++-- src/osx/menuitem_osx.cpp | 10 +++++++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index 826086d118..29f63eec7d 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -25,7 +25,9 @@ // forward declarations // ---------------------------------------------------------------------------- +#if wxUSE_ACCEL class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry; +#endif // wxUSE_ACCEL class WXDLLIMPEXP_FWD_CORE wxMenuItem; class WXDLLIMPEXP_FWD_CORE wxMenu; diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 05b124f492..0d7fe86dcf 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -125,6 +125,8 @@ class wxComboBox; class wxNotebook; class wxTextCtrl; class wxSearchCtrl; +class wxMenuItem; +class wxAcceleratorEntry; WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl ); diff --git a/src/osx/cocoa/menuitem.mm b/src/osx/cocoa/menuitem.mm index df189aae79..85e9abe3e1 100644 --- a/src/osx/cocoa/menuitem.mm +++ b/src/osx/cocoa/menuitem.mm @@ -131,7 +131,8 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* [menuItem setKeyEquivalent:@""]; return; } - + +#if wxUSE_ACCEL unsigned int modifiers = 0 ; int key = entry->GetKeyCode() ; if ( key ) @@ -227,6 +228,7 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* [menuItem setKeyEquivalent:[NSString stringWithCharacters:&shortcut length:1]]; [menuItem setKeyEquivalentModifierMask:modifiers]; } +#endif // wxUSE_ACCEL } @interface NSMenuItem(PossibleMethods) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 8b424e38ac..3a34b6fc65 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1491,7 +1491,7 @@ bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, voi // because performKeyEquivalent is going up the entire view hierarchy, we don't have to // walk up the ancestors ourselves but let cocoa do it - +#if wxUSE_ACCEL int command = m_wxPeer->GetAcceleratorTable()->GetCommand( wxevent ); if (command != -1) { @@ -1508,7 +1508,8 @@ bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, voi handled = handler->ProcessEvent( command_event ); } } - +#endif // wxUSE_ACCEL + if ( !handled ) { wxOSX_PerformKeyEventHandlerPtr superimpl = (wxOSX_PerformKeyEventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd]; diff --git a/src/osx/menuitem_osx.cpp b/src/osx/menuitem_osx.cpp index bac59e73ac..01170b14c0 100644 --- a/src/osx/menuitem_osx.cpp +++ b/src/osx/menuitem_osx.cpp @@ -51,10 +51,14 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); } - wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; // use accessors for ID and Kind because they might have been changed in the base constructor +#if wxUSE_ACCEL + wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; m_peer = wxMenuItemImpl::Create( this, pParentMenu, GetId(), text, entry, strHelp, GetKind(), pSubMenu ); delete entry; +#else + m_peer = wxMenuItemImpl::Create( this, pParentMenu, GetId(), text, NULL, strHelp, GetKind(), pSubMenu ); +#endif // wxUSE_ACCEL/!wxUSE_ACCEL } wxMenuItem::~wxMenuItem() @@ -194,9 +198,13 @@ void wxMenuItem::UpdateItemText() text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); } +#if wxUSE_ACCEL wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; GetPeer()->SetLabel( text, entry ); delete entry ; +#else + GetPeer()->SetLabel( text, NULL ); +#endif // wxUSE_ACCEL/!wxUSE_ACCEL } // ----------------------------------------------------------------------------