X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/70412bd46ca03700a7bb4b4af57d690d079e9230..f9b4d680d72930c31fe14dd63421a85d97ccd739:/src/osx/cocoa/menuitem.mm diff --git a/src/osx/cocoa/menuitem.mm b/src/osx/cocoa/menuitem.mm index 8b34b63bf3..c253f75672 100644 --- a/src/osx/cocoa/menuitem.mm +++ b/src/osx/cocoa/menuitem.mm @@ -32,14 +32,19 @@ - (void) clickedAction: (id) sender { + wxUnusedVar(sender); if ( impl ) { - impl->GetWXPeer()->GetMenu()->HandleCommandProcess(impl->GetWXPeer()); + wxMenuItem* menuitem = impl->GetWXPeer(); + if ( menuitem->GetMenu()->HandleCommandProcess(menuitem) == false ) + { + } } } - (BOOL)validateMenuItem:(NSMenuItem *) menuItem { + wxUnusedVar(menuItem); if( impl ) { impl->GetWXPeer()->GetMenu()->HandleCommandUpdateStatus(impl->GetWXPeer()); @@ -66,7 +71,7 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* int key = entry->GetKeyCode() ; if ( key ) { - if (entry->GetFlags() & wxACCEL_CTRL); + if (entry->GetFlags() & wxACCEL_CTRL) modifiers |= NSCommandKeyMask; if (entry->GetFlags() & wxACCEL_ALT) @@ -166,7 +171,7 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* } } -class wxMenuItemCocoaImpl : public wxMenuItemImpl +class wxMenuItemCocoaImpl : public wxMenuItemImpl { public : wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item) @@ -174,24 +179,24 @@ public : 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 ) { // NB: setHidden is new as of 10.5 so we should not call it below there @@ -200,17 +205,19 @@ public : 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 ); } + bool DoDefault(); + void * GetHMenuItem() { return m_osxMenuItem; } protected : @@ -221,20 +228,44 @@ wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl() { if ( ![m_osxMenuItem isSeparatorItem] ) [(wxNSMenuItem*)m_osxMenuItem setImplementation:nil]; + [m_osxMenuItem release]; } +bool wxMenuItemCocoaImpl::DoDefault() +{ + bool handled=false; + int menuid = m_peer->GetId(); + + NSApplication *theNSApplication = [NSApplication sharedApplication]; + if (menuid == wxID_OSX_HIDE) + { + [theNSApplication hide:nil]; + handled=true; + } + else if (menuid == wxID_OSX_HIDEOTHERS) + { + [theNSApplication hideOtherApplications:nil]; + handled=true; + } + else if (menuid == wxID_OSX_SHOWALL) + { + [theNSApplication unhideAllApplications:nil]; + handled=true; + } + return handled; +} 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];