#ifndef WX_PRECOMP
#include "wx/app.h"
+ #include "wx/log.h"
#include "wx/menu.h"
#endif // WX_PRECOMP
#include "wx/osx/private.h"
-@interface wxNSMenuItem : NSMenuItem
-{
- wxMenuItemImpl* impl;
-}
-
-- (void) setImplementation:(wxMenuItemImpl*) item;
-- (wxMenuItemImpl*) implementation;
-
-- (void) clickedAction: (id) sender;
-- (BOOL)validateMenuItem:(NSMenuItem *) menuItem;
-
-@end
-
@implementation wxNSMenuItem
- (id) init
public :
wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item)
{
+ if ( ![m_osxMenuItem isSeparatorItem] )
+ [(wxNSMenuItem*)m_osxMenuItem setImplementation:this];
}
~wxMenuItemCocoaImpl();
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 )
wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl()
{
+ if ( ![m_osxMenuItem isSeparatorItem] )
+ [(wxNSMenuItem*)m_osxMenuItem setImplementation:nil];
}
item = temp;
}
c = new wxMenuItemCocoaImpl( peer, item );
- if ( kind != wxITEM_SEPARATOR )
- {
- [(wxNSMenuItem*)item setImplementation:c];
- }
return c;
}