X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffad7b0dd2907634d93daacfb54d503c6f7a4ad4..030495ecf11a16c27e711f0d812226d6b940d42b:/src/osx/cocoa/menuitem.mm diff --git a/src/osx/cocoa/menuitem.mm b/src/osx/cocoa/menuitem.mm index 6b05d359fb..680d3c0cc7 100644 --- a/src/osx/cocoa/menuitem.mm +++ b/src/osx/cocoa/menuitem.mm @@ -16,6 +16,7 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/log.h" #include "wx/menu.h" #endif // WX_PRECOMP @@ -31,6 +32,7 @@ - (void) clickedAction: (id) sender { + wxUnusedVar(sender); if ( impl ) { impl->GetWXPeer()->GetMenu()->HandleCommandProcess(impl->GetWXPeer()); @@ -39,6 +41,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *) menuItem { + wxUnusedVar(menuItem); if( impl ) { impl->GetWXPeer()->GetMenu()->HandleCommandUpdateStatus(impl->GetWXPeer()); @@ -165,45 +168,51 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* } } -class wxMenuItemCocoaImpl : public wxMenuItemImpl +class wxMenuItemCocoaImpl : public wxMenuItemImpl { public : wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item) { + if ( ![m_osxMenuItem isSeparatorItem] ) + [(wxNSMenuItem*)m_osxMenuItem setImplementation:this]; } - + ~wxMenuItemCocoaImpl(); - - void SetBitmap( const wxBitmap& bitmap ) + + void SetBitmap( const wxBitmap& bitmap ) { [m_osxMenuItem setImage:bitmap.GetNSImage()]; } - - void Enable( bool enable ) + + void Enable( bool enable ) { [m_osxMenuItem setEnabled:enable]; } - - void Check( bool check ) + + void Check( bool check ) { [m_osxMenuItem setState:( check ? NSOnState : NSOffState) ]; } - + void Hide( bool hide ) { - [m_osxMenuItem setHidden:hide ]; + // NB: setHidden is new as of 10.5 so we should not call it below there + if ([m_osxMenuItem respondsToSelector:@selector(setHidden:)]) + [m_osxMenuItem setHidden:hide ]; + else + wxLogDebug("wxMenuItemCocoaImpl::Hide not yet supported under OS X < 10.5"); } - - void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) + + void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) { wxCFStringRef cfText(text); [m_osxMenuItem setTitle:cfText.AsNSString()]; - + if ( entry ) wxMacCocoaMenuItemSetAccelerator( m_osxMenuItem, entry ); } - + void * GetHMenuItem() { return m_osxMenuItem; } protected : @@ -212,20 +221,22 @@ protected : wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl() { + if ( ![m_osxMenuItem isSeparatorItem] ) + [(wxNSMenuItem*)m_osxMenuItem setImplementation:nil]; } wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, - int id, + int WXUNUSED(id), const wxString& text, wxAcceleratorEntry *entry, - const wxString& strHelp, + const wxString& WXUNUSED(strHelp), wxItemKind kind, wxMenu *pSubMenu ) { wxMenuItemImpl* c = NULL; NSMenuItem* item = nil; - + if ( kind == wxITEM_SEPARATOR ) { item = [[NSMenuItem separatorItem] retain]; @@ -253,9 +264,5 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, item = temp; } c = new wxMenuItemCocoaImpl( peer, item ); - if ( kind != wxITEM_SEPARATOR ) - { - [(wxNSMenuItem*)item setImplementation:c]; - } return c; }