]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/menuitem.cpp
IsEmpty to empty change, warning fix to OW, whitespaces cleaning.
[wxWidgets.git] / src / os2 / menuitem.cpp
index ca9fc82f000815b8d7eb4fd3718b2caf30f6df38..d5417f8a0daacb40afc4053d3e69f14848c37429 100644 (file)
     #define OWNER_DRAWN_ONLY( code )
 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
 
-// ----------------------------------------------------------------------------
-// static function for translating menu labels
-// ----------------------------------------------------------------------------
-
-static wxString TextToLabel(
-  const wxString&                   rsTitle
-)
-{
-    wxString                        sTitle;
-    const wxChar*                   zPc;
-
-    if (rsTitle.IsEmpty())
-        return(sTitle);
-
-    for (zPc = rsTitle.c_str(); *zPc != wxT('\0'); zPc++)
-    {
-        if (*zPc == wxT('&'))
-        {
-            if (*(zPc + 1) == wxT('&'))
-            {
-                zPc++;
-                sTitle << wxT('&');
-            }
-            else
-                sTitle << wxT('~');
-        }
-        else
-        {
-            if ( *zPc == wxT('~'))
-            {
-                //
-                // Tildes must be doubled to prevent them from being
-                // interpreted as accelerator character prefix by PM ???
-                //
-                sTitle << *zPc;
-            }
-            sTitle << *zPc;
-        }
-    }
-    return(sTitle);
-} // end of TextToLabel
-
 // ============================================================================
 // implementation
 // ============================================================================
@@ -123,13 +81,13 @@ wxMenuItem::wxMenuItem(
 )
 : wxMenuItemBase( pParentMenu
                  ,nId
-                 ,TextToLabel(rsText)
+                 ,wxPMTextToLabel(rsText)
                  ,rsHelp
                  ,eKind
                  ,pSubMenu
                 )
 #if wxUSE_OWNER_DRAWN
-,  wxOwnerDrawn( TextToLabel(rsText)
+,  wxOwnerDrawn( wxPMTextToLabel(rsText)
                 ,eKind == wxITEM_CHECK
                )
 #endif // owner drawn
@@ -151,13 +109,13 @@ wxMenuItem::wxMenuItem(
 )
 : wxMenuItemBase( pParentMenu
                  ,nId
-                 ,TextToLabel(rsText)
+                 ,wxPMTextToLabel(rsText)
                  ,rsHelp
                  ,bIsCheckable ? wxITEM_CHECK : wxITEM_NORMAL
                  ,pSubMenu
                 )
 #if wxUSE_OWNER_DRAWN
-,  wxOwnerDrawn( TextToLabel(rsText)
+,  wxOwnerDrawn( wxPMTextToLabel(rsText)
                 ,bIsCheckable
                )
 #endif // owner drawn
@@ -238,7 +196,7 @@ wxString wxMenuItemBase::GetLabelFromText(
         {
             //
             // '~' is the escape character for OS/2PM and '&' is the one for
-            // wxWindows - skip both of them
+            // wxWidgets - skip both of them
             //
             continue;
         }
@@ -417,12 +375,15 @@ void wxMenuItem::SetText(
     // Don't do anything if label didn't change
     //
 
-    wxString                        sText = TextToLabel(rText);
+    wxString                        sText = wxPMTextToLabel(rText);
     if (m_text == sText)
         return;
 
     wxMenuItemBase::SetText(sText);
     OWNER_DRAWN_ONLY(wxOwnerDrawn::SetName(sText));
+#if  wxUSE_OWNER_DRAWN
+    SetAccelString(rText.AfterFirst(_T('\t')));
+#endif // wxUSE_OWNER_DRAWN
 
     HWND                            hMenu = GetHmenuOf(m_parentMenu);