]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/menuitem.cpp
reSWIGed
[wxWidgets.git] / src / os2 / menuitem.cpp
index 574fea6166f10423b0d1eb047f3dc69c5cfb13e9..91c6e9d975be069bbc0a1a3b04e653796c569ca9 100644 (file)
 // static function for translating menu labels
 // ----------------------------------------------------------------------------
 
-static wxString TextToLabel(const wxString& rTitle)
+static wxString TextToLabel(
+  const wxString&                   rsTitle
+)
 {
-    wxString Title;
-    const wxChar *pc;
-    for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
+    wxString                        sTitle;
+    const wxChar*                   zPc;
+
+    if (rsTitle.IsEmpty())
+        return(sTitle);
+
+    for (zPc = rsTitle.c_str(); *zPc != wxT('\0'); zPc++)
     {
-        if (*pc == wxT('&') )
+        if (*zPc == wxT('&'))
         {
-            if (*(pc+1) == wxT('&'))
+            if (*(zPc + 1) == wxT('&'))
             {
-                pc++;
-                Title << wxT('&');
+                zPc++;
+                sTitle << wxT('&');
             }
             else
-                Title << wxT('~');
+                sTitle << wxT('~');
         }
         else
         {
-            if ( *pc == wxT('~') )
+            if ( *zPc == wxT('~'))
             {
-                // tildes must be doubled to prevent them from being
+                //
+                // Tildes must be doubled to prevent them from being
                 // interpreted as accelerator character prefix by PM ???
-                Title << *pc;
+                //
+                sTitle << *zPc;
             }
-            Title << *pc;
+            sTitle << *zPc;
         }
     }
-    return Title;
-}
+    return(sTitle);
+} // end of TextToLabel
 
 // ============================================================================
 // implementation
@@ -127,6 +135,8 @@ wxMenuItem::wxMenuItem(
 #endif // owner drawn
 {
     wxASSERT_MSG(pParentMenu != NULL, wxT("a menu item should have a parent"));
+    memset(&m_vMenuData, '\0', sizeof(m_vMenuData));
+    m_vMenuData.id = (USHORT)nId;
 
     Init();
 } // end of wxMenuItem::wxMenuItem
@@ -173,12 +183,11 @@ void wxMenuItem::Init()
     SetTextColour(SYS_COLOR(MENUTEXT));
     SetBackgroundColour(SYS_COLOR(MENU));
 
-    #undef  SYS_COLOR
-
     //
     // We don't want normal items be owner-drawn
     //
     ResetOwnerDrawn();
+    #undef  SYS_COLOR
 
     //
     // Tell the owner drawing code to to show the accel string as well
@@ -218,23 +227,25 @@ bool wxMenuItem::IsChecked() const
 } // end of wxMenuItem::IsChecked
 
 wxString wxMenuItemBase::GetLabelFromText(
-  const wxString&                   rText
+  const wxString&                   rsText
 )
 {
-    wxString label;
-    for ( const wxChar *pc = rText.c_str(); *pc; pc++ )
+    wxString                        sLabel;
+
+    for (const char* zPc = rsText.c_str(); *zPc; zPc++)
     {
-        if ( *pc == wxT('~') || *pc == wxT('&') )
+        if (*zPc == wxT('~') || *zPc == wxT('&'))
         {
-            // '~' is the escape character for GTK+ and '&' is the one for
+            //
+            // '~' is the escape character for OS/2PM and '&' is the one for
             // wxWindows - skip both of them
+            //
             continue;
         }
-
-        label += *pc;
+        sLabel += *zPc;
     }
-    return label;
-}
+    return sLabel;
+} // end of wxMenuItemBase::GetLabelFromText
 
 //
 // Radio group stuff
@@ -412,6 +423,9 @@ void wxMenuItem::SetText(
 
     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);