]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/menu.cpp
Ensure the caret flashes properly
[wxWidgets.git] / src / os2 / menu.cpp
index 2ed0039e5a644fc6a10026dbdb5fbfc6430a3436..26a12fecfdc421b20e01b294f38d9e57e2fc4c6f 100644 (file)
@@ -188,6 +188,14 @@ void wxMenu::Break()
 
 #if wxUSE_ACCEL
 
+void wxMenu::EndRadioGroup()
+{
+    //
+    // We're not inside a radio group any longer
+    //
+    m_nStartRadioGroup = -1;
+} // end of wxMenu::EndRadioGroup
+
 int wxMenu::FindAccel(
   int                               nId
 ) const
@@ -207,45 +215,58 @@ void wxMenu::UpdateAccel(
   wxMenuItem*                       pItem
 )
 {
-    //
-    // Find the (new) accel for this item
-    //
-    wxAcceleratorEntry*             pAccel = wxGetAccelFromString(pItem->GetText());
-
-    if (pAccel)
-        pAccel->m_command = pItem->GetId();
-
-    //
-    // Find the old one
-    //
-    int                             n = FindAccel(pItem->GetId());
+    if (pItem->IsSubMenu())
+    {
+        wxMenu*                     pSubmenu = pItem->GetSubMenu();
+        wxMenuItemList::Node*       pNode = pSubmenu->GetMenuItems().GetFirst();
 
-    if (n == wxNOT_FOUND)
+        while (pNode)
+        {
+            UpdateAccel(pNode->GetData());
+            pNode = pNode->GetNext();
+        }
+    }
+    else if (!pItem->IsSeparator())
     {
         //
-        // No old, add new if any
+        // Find the (new) accel for this item
         //
+        wxAcceleratorEntry*         pAccel = wxGetAccelFromString(pItem->GetText());
         if (pAccel)
-            m_vAccels.Add(pAccel);
-        else
-            return;     // skipping RebuildAccelTable() below
-    }
-    else
-    {
+            pAccel->m_command = pItem->GetId();
+
         //
-        // Replace old with new or just remove the old one if no new
+        // Find the old one
         //
-        delete                      m_vAccels[n];
+        int                             n = FindAccel(pItem->GetId());
 
-        if (pAccel)
-            m_vAccels[n] = pAccel;
+        if (n == wxNOT_FOUND)
+        {
+            //
+            // No old, add new if any
+            //
+            if (pAccel)
+                m_vAccels.Add(pAccel);
+            else
+                return;     // skipping RebuildAccelTable() below
+        }
         else
-            m_vAccels.RemoveAt(n);
-    }
+        {
+            //
+            // Replace old with new or just remove the old one if no new
+            //
+            delete                      m_vAccels[n];
 
-    if (IsAttached())
-    {
-        m_menuBar->RebuildAccelTable();
+            if (pAccel)
+                m_vAccels[n] = pAccel;
+            else
+                m_vAccels.RemoveAt(n);
+        }
+
+        if (IsAttached())
+        {
+            m_menuBar->RebuildAccelTable();
+        }
     }
 } // wxMenu::UpdateAccel
 
@@ -406,18 +427,18 @@ bool wxMenu::DoAppend(
     {
         int                         nCount = GetMenuItemCount();
 
-        if (m_lStartRadioGroup == -1)
+        if (m_nStartRadioGroup == -1)
         {
             //
             // Start a new radio group
             //
-            m_lStartRadioGroup = lCount;
+            m_nStartRadioGroup = nCount;
 
             //
             // For now it has just one element
             //
             pItem->SetAsRadioGroupStart();
-            pItem->SetRadioGroupEnd(m_startRadioGroup);
+            pItem->SetRadioGroupEnd(m_nStartRadioGroup);
 
             //
             // Ensure that we have a checked item in the radio group
@@ -429,12 +450,12 @@ bool wxMenu::DoAppend(
             //
             // We need to update its end item
             //
-            pItem->SetRadioGroupStart(m_lStartRadioGroup);
-            wxMenuItemList::Node *node = GetMenuItems().Item(m_startRadioGroup);
+            pItem->SetRadioGroupStart(m_nStartRadioGroup);
+            wxMenuItemList::Node*   pNode = GetMenuItems().Item(m_nStartRadioGroup);
 
-            if (node)
+            if (pNode)
             {
-                node->GetData()->SetRadioGroupEnd(count);
+                pNode->GetData()->SetRadioGroupEnd(nCount);
             }
             else
             {