]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/menu_osx.cpp
Fix wxCommandProcessor::IsDirty() result after undoing everything after save.
[wxWidgets.git] / src / osx / menu_osx.cpp
index 964915949f9b7c5e8e6d700cc567c35bc02fc57c..e36c6901c78a76f12b2097d970740bd5182ac69a 100644 (file)
@@ -210,6 +210,17 @@ wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
 {
+    if ( m_startRadioGroup != -1 )
+    {
+        // Check if we're removing the item starting the radio group
+        if ( GetMenuItems().Item(m_startRadioGroup)->GetData() == item )
+        {
+            // Yes, we do, so reset its index as the next item added shouldn't
+            // count as part of the same radio group anyhow.
+            m_startRadioGroup = -1;
+        }
+    }
+
 /*
     // we need to find the items position in the child list
     size_t pos;
@@ -441,16 +452,25 @@ void wxMenu::HandleMenuItemHighlighted( wxMenuItem* item )
     DoHandleMenuEvent( wxevent );
 }
 
-void wxMenu::HandleMenuOpened()
+void wxMenu::DoHandleMenuOpenedOrClosed(wxEventType evtType)
 {
-    wxMenuEvent wxevent(wxEVT_MENU_OPEN, 0, this);
+    // Popup menu being currently shown or NULL, defined in wincmn.cpp.
+    extern wxMenu *wxCurrentPopupMenu;
+
+    // Set the id to allow wxMenuEvent::IsPopup() to work correctly.
+    int menuid = this == wxCurrentPopupMenu ? wxID_ANY : 0;
+    wxMenuEvent wxevent(evtType, menuid, this);
     DoHandleMenuEvent( wxevent );
 }
 
+void wxMenu::HandleMenuOpened()
+{
+    DoHandleMenuOpenedOrClosed(wxEVT_MENU_OPEN);
+}
+
 void wxMenu::HandleMenuClosed()
 {
-    wxMenuEvent wxevent(wxEVT_MENU_CLOSE, 0, this);
-    DoHandleMenuEvent( wxevent );
+    DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
 }
 
 bool wxMenu::DoHandleMenuEvent(wxEvent& wxevent)
@@ -813,6 +833,17 @@ void wxMenuBar::EnableTop(size_t pos, bool enable)
     Refresh();
 }
 
+bool wxMenuBar::IsEnabledTop(size_t pos) const
+{
+    wxCHECK_MSG( IsAttached(), true,
+                 wxT("doesn't work with unattached menubars") );
+
+    wxMenuItem* const item = m_rootMenu->FindItemByPosition(pos+firstMenuPos);
+    wxCHECK_MSG( item, false, wxT("invalid menu index") );
+
+    return item->IsEnabled();
+}
+
 bool wxMenuBar::Enable(bool enable)
 {
     wxCHECK_MSG( IsAttached(), false, wxT("doesn't work with unattached menubars") );